From c02f1685c3f98f2b40d26af115b4a1ed392d103a Mon Sep 17 00:00:00 2001 From: yanmao <55792257+yanmao-cc@users.noreply.github.com> Date: Wed, 29 Dec 2021 02:39:21 +0800 Subject: [PATCH] update: plugin options type --- packages/toolbar/src/plugin/index.ts | 4 +++- plugins/codeblock/src/index.ts | 4 +++- plugins/embed/src/index.ts | 2 +- plugins/file/src/uploader.ts | 4 +++- plugins/hr/src/index.ts | 2 +- plugins/image/src/uploader.ts | 4 +++- plugins/line-height/src/index.ts | 4 +++- plugins/mention/src/index.ts | 4 +++- plugins/paintformat/src/index.ts | 4 +++- plugins/redo/src/index.ts | 2 +- plugins/removeformat/src/index.ts | 4 +++- plugins/selectall/src/index.ts | 4 +++- plugins/table/src/index.ts | 2 +- plugins/undo/src/index.ts | 2 +- plugins/video/src/uploader.ts | 4 +++- 15 files changed, 35 insertions(+), 15 deletions(-) diff --git a/packages/toolbar/src/plugin/index.ts b/packages/toolbar/src/plugin/index.ts index 946eb044..8f499643 100644 --- a/packages/toolbar/src/plugin/index.ts +++ b/packages/toolbar/src/plugin/index.ts @@ -47,7 +47,9 @@ const defaultConfig = (editor: EditorInterface): Config => { ]; }; -class ToolbarPlugin extends Plugin { +class ToolbarPlugin< + T extends ToolbarOptions = ToolbarOptions, +> extends Plugin { static get pluginName() { return 'toolbar'; } diff --git a/plugins/codeblock/src/index.ts b/plugins/codeblock/src/index.ts index edc1ed25..3580544f 100644 --- a/plugins/codeblock/src/index.ts +++ b/plugins/codeblock/src/index.ts @@ -40,7 +40,9 @@ const MODE_ALIAS = { 'c++': 'cpp', }; -export default class extends Plugin { +export default class< + T extends CodeBlockOptions = CodeBlockOptions, +> extends Plugin { static get pluginName() { return 'codeblock'; } diff --git a/plugins/embed/src/index.ts b/plugins/embed/src/index.ts index ec0e2b39..8c06cad9 100644 --- a/plugins/embed/src/index.ts +++ b/plugins/embed/src/index.ts @@ -22,7 +22,7 @@ export interface EmbedOptions extends PluginOptions { renderBefore?: EmbedRenderBeforeEvent; } -class Embed extends Plugin { +class Embed extends Plugin { static get pluginName() { return 'embed'; } diff --git a/plugins/file/src/uploader.ts b/plugins/file/src/uploader.ts index 327bda82..c5a87597 100644 --- a/plugins/file/src/uploader.ts +++ b/plugins/file/src/uploader.ts @@ -76,7 +76,9 @@ export interface FileUploaderOptions extends PluginOptions { }; } -export default class extends Plugin { +export default class< + T extends FileUploaderOptions = FileUploaderOptions, +> extends Plugin { private cardComponents: { [key: string]: FileComponent } = {}; static get pluginName() { diff --git a/plugins/hr/src/index.ts b/plugins/hr/src/index.ts index 3ff41b20..dc5a54a9 100644 --- a/plugins/hr/src/index.ts +++ b/plugins/hr/src/index.ts @@ -14,7 +14,7 @@ export interface HrOptions extends PluginOptions { hotkey?: string | Array; markdown?: boolean; } -export default class extends Plugin { +export default class extends Plugin { static get pluginName() { return 'hr'; } diff --git a/plugins/image/src/uploader.ts b/plugins/image/src/uploader.ts index 67108b11..0e4f6af6 100644 --- a/plugins/image/src/uploader.ts +++ b/plugins/image/src/uploader.ts @@ -122,7 +122,9 @@ export interface ImageUploaderOptions extends PluginOptions { isRemote?: (src: string) => boolean; } -export default class extends Plugin { +export default class< + T extends ImageUploaderOptions = ImageUploaderOptions, +> extends Plugin { private cardComponents: { [key: string]: ImageComponent } = {}; private loadCounts: { [key: string]: number } = {}; diff --git a/plugins/line-height/src/index.ts b/plugins/line-height/src/index.ts index 215ee019..629f9a04 100644 --- a/plugins/line-height/src/index.ts +++ b/plugins/line-height/src/index.ts @@ -11,7 +11,9 @@ export interface LineHeightOptions extends PluginOptions { filter?: (lineHeight: string) => string | boolean; } -export default class extends Plugin { +export default class< + T extends LineHeightOptions = LineHeightOptions, +> extends Plugin { static get pluginName() { return 'line-height'; } diff --git a/plugins/mention/src/index.ts b/plugins/mention/src/index.ts index 89a99162..6fb4325f 100644 --- a/plugins/mention/src/index.ts +++ b/plugins/mention/src/index.ts @@ -73,7 +73,9 @@ export interface MentionOptions extends PluginOptions { }; } -class MentionPlugin extends Plugin { +class MentionPlugin< + T extends MentionOptions = MentionOptions, +> extends Plugin { #request?: AjaxInterface; static get pluginName() { return 'mention'; diff --git a/plugins/paintformat/src/index.ts b/plugins/paintformat/src/index.ts index 8afc27c3..6ea2af15 100644 --- a/plugins/paintformat/src/index.ts +++ b/plugins/paintformat/src/index.ts @@ -21,7 +21,9 @@ export interface PaintformatOptions extends PluginOptions { const PAINTFORMAT_CLASS = 'data-paintformat-mode'; -export default class extends Plugin { +export default class< + T extends PaintformatOptions = PaintformatOptions, +> extends Plugin { private activeMarks?: NodeInterface[]; private activeBlocks?: NodeInterface[]; private type?: string; diff --git a/plugins/redo/src/index.ts b/plugins/redo/src/index.ts index e45bb886..0cfd52c9 100644 --- a/plugins/redo/src/index.ts +++ b/plugins/redo/src/index.ts @@ -3,7 +3,7 @@ import { isEngine, Plugin, PluginOptions } from '@aomao/engine'; export interface RedoOptions extends PluginOptions { hotkey?: string | Array; } -export default class extends Plugin { +export default class extends Plugin { static get pluginName() { return 'redo'; } diff --git a/plugins/removeformat/src/index.ts b/plugins/removeformat/src/index.ts index c132956b..51931487 100644 --- a/plugins/removeformat/src/index.ts +++ b/plugins/removeformat/src/index.ts @@ -3,7 +3,9 @@ import { isEngine, Plugin, PluginOptions } from '@aomao/engine'; export interface RemoveformatOptions extends PluginOptions { hotkey?: string | Array; } -export default class extends Plugin { +export default class< + T extends RemoveformatOptions = RemoveformatOptions, +> extends Plugin { static get pluginName() { return 'removeformat'; } diff --git a/plugins/selectall/src/index.ts b/plugins/selectall/src/index.ts index 9cf78c29..9ed0ddce 100644 --- a/plugins/selectall/src/index.ts +++ b/plugins/selectall/src/index.ts @@ -7,7 +7,9 @@ import { export interface SelectAllOptions extends PluginOptions {} -export default class extends Plugin { +export default class< + T extends SelectAllOptions = SelectAllOptions, +> extends Plugin { static get pluginName() { return 'selectall'; } diff --git a/plugins/table/src/index.ts b/plugins/table/src/index.ts index 7535b45e..865c03d0 100644 --- a/plugins/table/src/index.ts +++ b/plugins/table/src/index.ts @@ -27,7 +27,7 @@ export interface TableOptions extends PluginOptions { markdown?: boolean; } -class Table extends Plugin { +class Table extends Plugin { static get pluginName() { return 'table'; } diff --git a/plugins/undo/src/index.ts b/plugins/undo/src/index.ts index 20c9ff00..f9ba4a9e 100644 --- a/plugins/undo/src/index.ts +++ b/plugins/undo/src/index.ts @@ -3,7 +3,7 @@ import { isEngine, Plugin, PluginOptions } from '@aomao/engine'; export interface UndoOptions extends PluginOptions { hotkey?: string | Array; } -export default class extends Plugin { +export default class extends Plugin { static get pluginName() { return 'undo'; } diff --git a/plugins/video/src/uploader.ts b/plugins/video/src/uploader.ts index 31a0aef6..1b0a451a 100644 --- a/plugins/video/src/uploader.ts +++ b/plugins/video/src/uploader.ts @@ -99,7 +99,9 @@ export interface VideoUploaderOptions extends PluginOptions { }; } -export default class extends Plugin { +export default class< + T extends VideoUploaderOptions = VideoUploaderOptions, +> extends Plugin { private cardComponents: { [key: string]: VideoComponent } = {}; static get pluginName() {