-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from cameron-toy/release
Final changes before first release
- Loading branch information
Showing
36 changed files
with
2,396 additions
and
4,643 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
Oops, something went wrong.