Skip to content

Commit

Permalink
Merge pull request #134 from cameron-toy/release
Browse files Browse the repository at this point in the history
Final changes before first release
  • Loading branch information
cameron-toy authored Aug 24, 2021
2 parents ea5eca2 + 33fe63e commit adc4bef
Show file tree
Hide file tree
Showing 36 changed files with 2,396 additions and 4,643 deletions.
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jupyterlab-comments",
"version": "0.1.0",
"description": "Chat and comment in JupyterLab",
"description": "Comment on files JupyterLab",
"keywords": [
"jupyter",
"jupyterlab",
Expand Down Expand Up @@ -47,16 +47,16 @@
"watch:labextension": "jupyter labextension watch ."
},
"dependencies": {
"@jupyterlab/rendermime": "^3.1.3",
"@jupyterlab/application": "^3.1.6",
"@jupyterlab/cells": "^3.1.6",
"@jupyterlab/codeeditor": "^3.1.6",
"@jupyterlab/codemirror": "^3.1.6",
"@jupyterlab/mathjax2": "^3.1.6",
"@jupyterlab/notebook": "^3.1.6",
"@jupyterlab/rendermime": "^3.1.6",
"@jupyterlab/services": "^6.0.9",
"@jupyterlab/application": "^3.1.3",
"@jupyterlab/cells": "^3.1.3",
"@jupyterlab/codeeditor": "^3.1.3",
"@jupyterlab/codemirror": "^3.1.3",
"@jupyterlab/mathjax2": "^3.1.3",
"@jupyterlab/notebook": "^3.1.3",
"@jupyterlab/shared-models": "^3.1.3",
"@jupyterlab/ui-components": "^3.1.3",
"@jupyterlab/shared-models": "^3.1.6",
"@jupyterlab/ui-components": "^3.1.6",
"@lumino/widgets": "^1.23.0",
"@types/codemirror": "^5.60.2",
"codemirror": "~5.61.0",
Expand Down
16 changes: 15 additions & 1 deletion src/button.ts → src/api/button.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BlueCreateCommentIcon } from './icons';
import { Widget } from '@lumino/widgets';
import { Message } from '@lumino/messaging';
import { ISignal, Signal } from '@lumino/signaling';

export class NewCommentButton extends Widget {
constructor() {
Expand All @@ -26,10 +27,17 @@ export class NewCommentButton extends Widget {
}

private _handleClick(event: MouseEvent): void {
event.preventDefault();
event.stopPropagation();
this._onClick();
this.close();
}

close(): void {
super.close();
this._closed.emit(undefined);
}

open(x: number, y: number, f: () => void, anchor?: HTMLElement): void {
// Bail if button is already attached
// if (this.isAttached) {
Expand Down Expand Up @@ -87,11 +95,17 @@ export class NewCommentButton extends Widget {
style.visibility = '';
}

get closed(): ISignal<this, undefined> {
return this._closed;
}

private _onClick: () => void = () =>
console.warn('no onClick function registered', this);

private _closed = new Signal<this, undefined>(this);
}

export namespace Private {
namespace Private {
export function createNode() {
const node = document.createElement('div');
node.className = 'jc-Indicator';
Expand Down
31 changes: 31 additions & 0 deletions src/api/commentformat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { PartialJSONObject, PartialJSONValue } from '@lumino/coreutils';

/**
* A type for the identity of a commenter.
*/
export interface IIdentity extends PartialJSONObject {
id: number;
name: string;
color: string;
icon: number;
}

export interface IBaseComment extends PartialJSONObject {
id: string;
type: string;
identity: IIdentity;
text: string;
time: string;
}

export interface IReply extends IBaseComment {
type: 'reply';
}

export interface ICommentWithReplies extends IBaseComment {
replies: IReply[];
}

export interface IComment extends ICommentWithReplies {
target: PartialJSONValue;
}
75 changes: 75 additions & 0 deletions src/api/factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { IComment, IIdentity, IReply } from './commentformat';
import { UUID } from '@lumino/coreutils';
import { getCommentTimeString } from './utils';
import { CommentFileModel } from './model';
import { CommentWidget } from './widget';
import { ICommentRegistry } from './token';

export abstract class CommentWidgetFactory<T, C extends IComment = IComment> {
constructor(options: CommentWidgetFactory.IOptions) {
this.commentRegistry = options.commentRegistry;
}

abstract createWidget(
comment: C,
model: CommentFileModel,
target?: T
): CommentWidget<T> | undefined;

get commentFactory(): CommentFactory | undefined {
return this.commentRegistry.getFactory(this.commentType);
}

readonly widgetType: string = '';
readonly commentType: string = '';
readonly commentRegistry: ICommentRegistry;
}

export namespace CommentWidgetFactory {
export interface IOptions {
commentRegistry: ICommentRegistry;
}
}

export abstract class CommentFactory<C extends IComment = IComment> {
createComment(options: CommentFactory.ICommentOptions<any>): C {
const { identity, replies, id, text } = options;

return {
text,
identity,
type: this.type,
time: getCommentTimeString(),
id: id ?? UUID.uuid4(),
replies: replies ?? [],
target: null
} as C;
}

static createReply(options: CommentFactory.IReplyOptions): IReply {
const { text, identity, id } = options;

return {
text,
identity,
id: id ?? UUID.uuid4(),
time: getCommentTimeString(),
type: 'reply'
};
}

readonly type: string = '';
}

export namespace CommentFactory {
export interface IReplyOptions {
text: string;
identity: IIdentity;
id?: string;
}

export interface ICommentOptions<T> extends IReplyOptions {
source: T;
replies?: IReply[];
}
}
14 changes: 13 additions & 1 deletion src/panelHeaderWidget.tsx → src/api/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ function FileTitle(props: FileTitleProps): JSX.Element {
}
};

const pathChangedHandler = (_: any, newPath: string): void => {
SetTooltip(panel.fileWidget?.context.path ?? '');
SetFilename(panel.sourcePath ?? '');
};

const modelChangedHandler = (
_: any,
widget: CommentFileWidget | undefined
Expand All @@ -64,8 +69,15 @@ function FileTitle(props: FileTitleProps): JSX.Element {

React.useEffect(() => {
panel.modelChanged.connect(modelChangedHandler);
const fileWidget = panel.fileWidget;
if (fileWidget != null) {
fileWidget.context.pathChanged.connect(pathChangedHandler);
}

return () => void panel.modelChanged.disconnect(modelChangedHandler);
return () => {
Signal.disconnectAll(modelChangedHandler);
Signal.disconnectAll(pathChangedHandler);
};
});

return (
Expand Down
48 changes: 24 additions & 24 deletions src/icons.ts → src/api/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@ import { LabIcon } from '@jupyterlab/ui-components';
// svgstr: '<svg>...</svg>'
// });

import userIcon0Svgstr from '../style/icons/user-icon-0.svg';
import userIcon1Svgstr from '../style/icons/user-icon-1.svg';
import userIcon2Svgstr from '../style/icons/user-icon-2.svg';
import userIcon3Svgstr from '../style/icons/user-icon-3.svg';
import userIcon4Svgstr from '../style/icons/user-icon-4.svg';
import userIcon5Svgstr from '../style/icons/user-icon-5.svg';
import userIcon6Svgstr from '../style/icons/user-icon-6.svg';
import userIcon7Svgstr from '../style/icons/user-icon-7.svg';
import userIcon8Svgstr from '../style/icons/user-icon-8.svg';
import userIcon9Svgstr from '../style/icons/user-icon-9.svg';
import userIcon10Svgstr from '../style/icons/user-icon-10.svg';
import userIcon11Svgstr from '../style/icons/user-icon-11.svg';
import userIcon12Svgstr from '../style/icons/user-icon-12.svg';
import userIcon13Svgstr from '../style/icons/user-icon-13.svg';
import userIcon14Svgstr from '../style/icons/user-icon-14.svg';
import userIcon15Svgstr from '../style/icons/user-icon-15.svg';
import userIcon16Svgstr from '../style/icons/user-icon-16.svg';
import userIcon17Svgstr from '../style/icons/user-icon-17.svg';
import userIcon18Svgstr from '../style/icons/user-icon-18.svg';
import userIcon19Svgstr from '../style/icons/user-icon-19.svg';
import userIcon20Svgstr from '../style/icons/user-icon-20.svg';
import userIcon21Svgstr from '../style/icons/user-icon-21.svg';
import userIcon22Svgstr from '../style/icons/user-icon-22.svg';
import userIcon23Svgstr from '../style/icons/user-icon-23.svg';
import userIcon0Svgstr from '../../style/icons/user-icon-0.svg';
import userIcon1Svgstr from '../../style/icons/user-icon-1.svg';
import userIcon2Svgstr from '../../style/icons/user-icon-2.svg';
import userIcon3Svgstr from '../../style/icons/user-icon-3.svg';
import userIcon4Svgstr from '../../style/icons/user-icon-4.svg';
import userIcon5Svgstr from '../../style/icons/user-icon-5.svg';
import userIcon6Svgstr from '../../style/icons/user-icon-6.svg';
import userIcon7Svgstr from '../../style/icons/user-icon-7.svg';
import userIcon8Svgstr from '../../style/icons/user-icon-8.svg';
import userIcon9Svgstr from '../../style/icons/user-icon-9.svg';
import userIcon10Svgstr from '../../style/icons/user-icon-10.svg';
import userIcon11Svgstr from '../../style/icons/user-icon-11.svg';
import userIcon12Svgstr from '../../style/icons/user-icon-12.svg';
import userIcon13Svgstr from '../../style/icons/user-icon-13.svg';
import userIcon14Svgstr from '../../style/icons/user-icon-14.svg';
import userIcon15Svgstr from '../../style/icons/user-icon-15.svg';
import userIcon16Svgstr from '../../style/icons/user-icon-16.svg';
import userIcon17Svgstr from '../../style/icons/user-icon-17.svg';
import userIcon18Svgstr from '../../style/icons/user-icon-18.svg';
import userIcon19Svgstr from '../../style/icons/user-icon-19.svg';
import userIcon20Svgstr from '../../style/icons/user-icon-20.svg';
import userIcon21Svgstr from '../../style/icons/user-icon-21.svg';
import userIcon22Svgstr from '../../style/icons/user-icon-22.svg';
import userIcon23Svgstr from '../../style/icons/user-icon-23.svg';

const userIconSvgstrs = [
userIcon0Svgstr,
Expand Down
12 changes: 12 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export * from './button';
export * from './commentformat';
export * from './factory';
export * from './icons';
export * from './model';
export * from './panel';
export * from './plugin';
export * from './header';
export * from './registry';
export * from './utils';
export * from './token';
export * from './widget';
Loading

0 comments on commit adc4bef

Please sign in to comment.