From 614131e8104ea52f14a1fb52a36713c3f6375b1e Mon Sep 17 00:00:00 2001 From: yanmao <55792257+yanmao-cc@users.noreply.github.com> Date: Fri, 7 Jan 2022 00:13:10 +0800 Subject: [PATCH] update: toolbar popup --- examples/react/components/editor/config.tsx | 154 +++++++++--------- examples/vue/src/components/config.ts | 78 +++++++++ .../toolbar-vue/src/components/button.vue | 5 +- .../src/components/color/color.vue | 18 +- .../toolbar-vue/src/components/dropdown.vue | 4 +- packages/toolbar-vue/src/components/group.vue | 8 +- .../toolbar-vue/src/components/toolbar.vue | 1 + .../src/plugin/component/index.css | 3 +- packages/toolbar-vue/src/types.ts | 18 +- packages/toolbar/src/button/index.css | 3 +- packages/toolbar/src/button/index.tsx | 17 +- packages/toolbar/src/color/index.css | 16 +- packages/toolbar/src/color/index.tsx | 6 +- packages/toolbar/src/dropdown/index.css | 5 +- packages/toolbar/src/dropdown/index.tsx | 5 +- packages/toolbar/src/group/index.css | 2 + packages/toolbar/src/group/index.tsx | 24 ++- packages/toolbar/src/index.css | 1 + .../toolbar/src/plugin/component/index.css | 2 +- plugins/file/src/component/index.ts | 12 +- plugins/file/src/index.ts | 3 +- plugins/file/src/types.ts | 5 + plugins/image/src/component/index.ts | 7 +- plugins/image/src/index.ts | 7 +- plugins/image/src/types.ts | 6 +- plugins/video/src/component/index.ts | 6 +- plugins/video/src/index.ts | 9 +- plugins/video/src/types.ts | 9 + 28 files changed, 272 insertions(+), 162 deletions(-) create mode 100644 plugins/file/src/types.ts create mode 100644 plugins/video/src/types.ts diff --git a/examples/react/components/editor/config.tsx b/examples/react/components/editor/config.tsx index 9d20067e..80e24e19 100644 --- a/examples/react/components/editor/config.tsx +++ b/examples/react/components/editor/config.tsx @@ -311,84 +311,82 @@ export const lineHeightOptions: LineHeightOptions = { }; export const toolbarOptions: ToolbarOptions = { - // popup: { - // items: [ - // ['undo', 'redo'], - // { - // icon: 'text', - // items: [ - // 'bold', - // 'italic', - // 'strikethrough', - // 'underline', - // 'fontsize', - // 'fontcolor', - // 'backcolor', - // 'moremark', - // ], - // }, - // [ - // { - // type: 'button', - // name: 'image-uploader', - // icon: 'image', - // }, - // 'link', - // 'tasklist', - // 'heading', - // ], - // { - // icon: 'more', - // items: [ - // { - // type: 'button', - // name: 'video-uploader', - // icon: 'video', - // }, - // { - // type: 'button', - // name: 'file-uploader', - // icon: 'attachment', - // }, - // { - // type: 'button', - // name: 'table', - // icon: 'table', - // }, - // { - // type: 'button', - // name: 'math', - // icon: 'math', - // }, - // { - // type: 'button', - // name: 'codeblock', - // icon: 'codeblock', - // }, - // { - // type: 'button', - // name: 'orderedlist', - // icon: 'ordered-list', - // }, - // { - // type: 'button', - // name: 'unordered-list', - // icon: 'unordered-list', - // }, - // { - // type: 'button', - // name: 'hr', - // icon: 'hr', - // }, - // { - // type: 'button', - // name: 'quote', - // icon: 'quote', - // }, - // ], - // }, - // ] - // } + popup: { + items: [ + ['undo', 'redo'], + { + icon: 'text', + items: [ + 'bold', + 'italic', + 'strikethrough', + 'underline', + 'backcolor', + 'moremark', + ], + }, + [ + { + type: 'button', + name: 'image-uploader', + icon: 'image', + }, + 'link', + 'tasklist', + 'heading', + ], + { + icon: 'more', + items: [ + { + type: 'button', + name: 'video-uploader', + icon: 'video', + }, + { + type: 'button', + name: 'file-uploader', + icon: 'attachment', + }, + { + type: 'button', + name: 'table', + icon: 'table', + }, + { + type: 'button', + name: 'math', + icon: 'math', + }, + { + type: 'button', + name: 'codeblock', + icon: 'codeblock', + }, + { + type: 'button', + name: 'orderedlist', + icon: 'ordered-list', + }, + { + type: 'button', + name: 'unordered-list', + icon: 'unordered-list', + }, + { + type: 'button', + name: 'hr', + icon: 'hr', + }, + { + type: 'button', + name: 'quote', + icon: 'quote', + }, + ], + }, + ], + }, }; export const pluginConfig: Record = { diff --git a/examples/vue/src/components/config.ts b/examples/vue/src/components/config.ts index dd2a73a4..a1bee22f 100644 --- a/examples/vue/src/components/config.ts +++ b/examples/vue/src/components/config.ts @@ -111,6 +111,84 @@ export const cards: Array = [ ]; export const pluginConfig: { [key: string]: PluginOptions } = { + [ToolbarPlugin.pluginName]: { + popup: { + items: [ + ['undo', 'redo'], + { + icon: 'text', + items: [ + 'bold', + 'italic', + 'strikethrough', + 'underline', + 'backcolor', + 'moremark', + ], + }, + [ + { + type: 'button', + name: 'image-uploader', + icon: 'image', + }, + 'link', + 'tasklist', + 'heading', + ], + { + icon: 'more', + items: [ + { + type: 'button', + name: 'video-uploader', + icon: 'video', + }, + { + type: 'button', + name: 'file-uploader', + icon: 'attachment', + }, + { + type: 'button', + name: 'table', + icon: 'table', + }, + { + type: 'button', + name: 'math', + icon: 'math', + }, + { + type: 'button', + name: 'codeblock', + icon: 'codeblock', + }, + { + type: 'button', + name: 'orderedlist', + icon: 'ordered-list', + }, + { + type: 'button', + name: 'unordered-list', + icon: 'unordered-list', + }, + { + type: 'button', + name: 'hr', + icon: 'hr', + }, + { + type: 'button', + name: 'quote', + icon: 'quote', + }, + ], + }, + ], + }, + }, [Italic.pluginName]: { // 默认为 _ 下划线,这里修改为单个 * 号 markdown: '*', diff --git a/packages/toolbar-vue/src/components/button.vue b/packages/toolbar-vue/src/components/button.vue index 6e4f1868..5f2ff6f9 100644 --- a/packages/toolbar-vue/src/components/button.vue +++ b/packages/toolbar-vue/src/components/button.vue @@ -99,7 +99,7 @@ export default defineComponent({