-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: improve types, close #970 #974
Changes from all commits
db87ce6
3fcbd91
3104a5e
bc84744
6e1a698
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -8,7 +8,7 @@ declare namespace toastui { | |||
type HandlerFunc = (...args: any[]) => void; | ||||
type ReplacerFunc = (inputString: string) => string; | ||||
type CodeMirrorType = CodeMirror.EditorFromTextArea; | ||||
type CommandManagerExecFunc = (name: string, ...args: any[]) => any; | ||||
type CommandManagerExecFunc = (editor: Editor | MarkdownEditor | WysiwygEditor, ...args: any[]) => any; | ||||
type PopupTableUtils = LayerPopup; | ||||
type AddImageBlobHook = (fileOrBlob: File | Blob, callback: Function, source: string) => void; | ||||
type Plugin = (editor: Editor | Viewer, options: any) => void; | ||||
|
@@ -570,8 +570,19 @@ declare namespace toastui { | |||
public styleToSelectedCells(onStyle: SquireExt, options?: object): void; | ||||
} | ||||
|
||||
interface MarkdownRange { | ||||
from: CodeMirror.Position; | ||||
to: CodeMirror.Position; | ||||
ollapsed: boolean; | ||||
} | ||||
|
||||
class CodeMirrorExt { | ||||
getCurrentRange(): MarkdownRange; | ||||
getEditor(): CodeMirrorType; | ||||
} | ||||
|
||||
// @TODO: change toastMark type definition to @toast-ui/toastmark type file through importing | ||||
class MarkdownEditor { | ||||
class MarkdownEditor extends CodeMirrorExt { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is actually a type bug fix. MarkdownEditor extends a CodeMirrorExt class: https://github.com/nhn/tui.editor/blob/master/apps/editor/src/js/markdownEditor.js#L113 but this isn't represented in the types. I added two methods from CodeMirrorExt I found useful when developing custom commands: ideally I think they would all be added but this is quite a lot more work! |
||||
static factory( | ||||
el: HTMLElement, | ||||
eventManager: EventManager, | ||||
|
@@ -695,7 +706,7 @@ declare namespace toastui { | |||
class EventManager { | ||||
public addEventType(type: string): void; | ||||
|
||||
public emit(eventName: string): any[]; | ||||
public emit(eventName: string, ...args: any): any[]; | ||||
|
||||
public emitReduce(eventName: string, sourceText: string): string; | ||||
|
||||
|
@@ -729,6 +740,12 @@ declare namespace toastui { | |||
|
||||
public addWidget(selection: Range, node: Node, style: string, offset?: number): void; | ||||
|
||||
public addCommand(type: Command): void; | ||||
|
||||
public addCommand(type: string, props: CommandPropsOptions): void; | ||||
Comment on lines
+743
to
+745
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you declare There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The first type is different: the first one takes a single Command, the second one takes two parameters: a string and a CommandPropsOptions https://github.com/nhn/tui.editor/blob/master/apps/editor/src/js/editor.js#L359-L365 I could declare it
but I thought declaring the two options separately was more precise. |
||||
|
||||
public addEventType(type: string): void; | ||||
|
||||
public afterAddedCommand(): void; | ||||
|
||||
public blur(): void; | ||||
|
@@ -835,8 +852,6 @@ declare namespace toastui { | |||
|
||||
public setMarkdown(markdown: string): void; | ||||
|
||||
public setValue(markdown: string): void; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍
|
||||
|
||||
public setCodeBlockLanguages(languages?: string[]): void; | ||||
} | ||||
} | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value of this property is wrong,
collapsed
is correct.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, I will fix this