@kaitify/react 0.0.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/docs/.vitepress/cache/deps/_metadata.json +52 -0
- package/docs/.vitepress/cache/deps/chunk-Q2AYPHVK.js +9719 -0
- package/docs/.vitepress/cache/deps/chunk-Q2AYPHVK.js.map +7 -0
- package/docs/.vitepress/cache/deps/chunk-QAXAIFA7.js +12705 -0
- package/docs/.vitepress/cache/deps/chunk-QAXAIFA7.js.map +7 -0
- package/docs/.vitepress/cache/deps/package.json +3 -0
- package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +4505 -0
- package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +583 -0
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +7 -0
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_integrations_useFocusTrap.js +1145 -0
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_integrations_useFocusTrap.js.map +7 -0
- package/docs/.vitepress/cache/deps/vitepress___mark__js_src_vanilla__js.js +1665 -0
- package/docs/.vitepress/cache/deps/vitepress___mark__js_src_vanilla__js.js.map +7 -0
- package/docs/.vitepress/cache/deps/vitepress___minisearch.js +1813 -0
- package/docs/.vitepress/cache/deps/vitepress___minisearch.js.map +7 -0
- package/docs/.vitepress/cache/deps/vue.js +343 -0
- package/docs/.vitepress/cache/deps/vue.js.map +7 -0
- package/docs/.vitepress/config.ts +185 -0
- package/docs/.vitepress/global.d.ts +1 -0
- package/docs/.vitepress/theme/index.ts +6 -0
- package/docs/.vitepress/theme/style.less +17 -0
- package/docs/.vitepress/tsconfig.json +12 -0
- package/docs/changelog.md +10 -0
- package/docs/guide/bubble.md +71 -0
- package/docs/guide/checkbox.md +38 -0
- package/docs/guide/divider.md +41 -0
- package/docs/guide/icon.md +34 -0
- package/docs/guide/install.md +70 -0
- package/docs/guide/introduction.md +28 -0
- package/docs/guide/locale.md +67 -0
- package/docs/guide/menu.md +112 -0
- package/docs/guide/quick-start.md +76 -0
- package/docs/guide/shortcut.md +77 -0
- package/docs/guide/tabs.md +42 -0
- package/docs/guide/wrapper.md +303 -0
- package/docs/index.md +41 -0
- package/docs/menus/built-in/align-center.md +29 -0
- package/docs/menus/built-in/align-justify.md +29 -0
- package/docs/menus/built-in/align-left.md +29 -0
- package/docs/menus/built-in/align-right.md +29 -0
- package/docs/menus/built-in/attachment.md +41 -0
- package/docs/menus/built-in/back-color.md +33 -0
- package/docs/menus/built-in/blockquote.md +29 -0
- package/docs/menus/built-in/bold.md +29 -0
- package/docs/menus/built-in/clear-format.md +29 -0
- package/docs/menus/built-in/code-block-languages.md +37 -0
- package/docs/menus/built-in/code-block.md +29 -0
- package/docs/menus/built-in/code.md +29 -0
- package/docs/menus/built-in/color.md +33 -0
- package/docs/menus/built-in/decrease-indent.md +29 -0
- package/docs/menus/built-in/emoji.md +35 -0
- package/docs/menus/built-in/font-family.md +44 -0
- package/docs/menus/built-in/font-size.md +44 -0
- package/docs/menus/built-in/full-screen.md +39 -0
- package/docs/menus/built-in/heading.md +66 -0
- package/docs/menus/built-in/horizontal.md +29 -0
- package/docs/menus/built-in/image.md +41 -0
- package/docs/menus/built-in/increase-indent.md +29 -0
- package/docs/menus/built-in/italic.md +29 -0
- package/docs/menus/built-in/line-height.md +44 -0
- package/docs/menus/built-in/link-unset.md +29 -0
- package/docs/menus/built-in/link.md +29 -0
- package/docs/menus/built-in/math.md +29 -0
- package/docs/menus/built-in/ordered-list.md +29 -0
- package/docs/menus/built-in/redo.md +25 -0
- package/docs/menus/built-in/strikethrough.md +29 -0
- package/docs/menus/built-in/subscript.md +29 -0
- package/docs/menus/built-in/superscript.md +29 -0
- package/docs/menus/built-in/table-add-column.md +33 -0
- package/docs/menus/built-in/table-add-row.md +33 -0
- package/docs/menus/built-in/table-delete-column.md +29 -0
- package/docs/menus/built-in/table-delete-row.md +29 -0
- package/docs/menus/built-in/table-merge-cell.md +33 -0
- package/docs/menus/built-in/table-unset.md +29 -0
- package/docs/menus/built-in/table.md +37 -0
- package/docs/menus/built-in/task.md +29 -0
- package/docs/menus/built-in/underline.md +29 -0
- package/docs/menus/built-in/undo.md +25 -0
- package/docs/menus/built-in/unordered-list.md +29 -0
- package/docs/menus/built-in/video-controls.md +29 -0
- package/docs/menus/built-in/video-loop.md +29 -0
- package/docs/menus/built-in/video-muted.md +29 -0
- package/docs/menus/built-in/video.md +41 -0
- package/docs/menus/built-in/wrap-down.md +33 -0
- package/docs/menus/built-in/wrap-up.md +33 -0
- package/docs/menus/introduction.md +27 -0
- package/examples/App.tsx +179 -0
- package/examples/main.tsx +9 -0
- package/examples/style.less +21 -0
- package/index.html +13 -0
- package/lib/core/button/button.d.ts +5 -0
- package/lib/core/button/index.d.ts +3 -0
- package/lib/core/button/props.d.ts +38 -0
- package/lib/core/checkbox/checkbox.d.ts +5 -0
- package/lib/core/checkbox/index.d.ts +3 -0
- package/lib/core/checkbox/props.d.ts +21 -0
- package/lib/core/divider/divider.d.ts +4 -0
- package/lib/core/divider/index.d.ts +2 -0
- package/lib/core/icon/icon.d.ts +5 -0
- package/lib/core/icon/index.d.ts +3 -0
- package/lib/core/icon/props.d.ts +22 -0
- package/lib/core/popover/index.d.ts +3 -0
- package/lib/core/popover/popover.d.ts +7 -0
- package/lib/core/popover/props.d.ts +94 -0
- package/lib/core/tabs/index.d.ts +3 -0
- package/lib/core/tabs/props.d.ts +21 -0
- package/lib/core/tabs/tabs.d.ts +2 -0
- package/lib/core/teleport/index.d.ts +3 -0
- package/lib/core/teleport/props.d.ts +11 -0
- package/lib/core/teleport/teleport.d.ts +5 -0
- package/lib/editor/bubble/bubble.d.ts +6 -0
- package/lib/editor/bubble/index.d.ts +3 -0
- package/lib/editor/bubble/props.d.ts +63 -0
- package/lib/editor/menu/built-in/align-center/align-center.d.ts +2 -0
- package/lib/editor/menu/built-in/align-center/index.d.ts +3 -0
- package/lib/editor/menu/built-in/align-center/props.d.ts +10 -0
- package/lib/editor/menu/built-in/align-justify/align-justify.d.ts +2 -0
- package/lib/editor/menu/built-in/align-justify/index.d.ts +3 -0
- package/lib/editor/menu/built-in/align-justify/props.d.ts +10 -0
- package/lib/editor/menu/built-in/align-left/align-left.d.ts +2 -0
- package/lib/editor/menu/built-in/align-left/index.d.ts +3 -0
- package/lib/editor/menu/built-in/align-left/props.d.ts +10 -0
- package/lib/editor/menu/built-in/align-right/align-right.d.ts +2 -0
- package/lib/editor/menu/built-in/align-right/index.d.ts +3 -0
- package/lib/editor/menu/built-in/align-right/props.d.ts +10 -0
- package/lib/editor/menu/built-in/attachment/attachment.d.ts +2 -0
- package/lib/editor/menu/built-in/attachment/index.d.ts +3 -0
- package/lib/editor/menu/built-in/attachment/props.d.ts +26 -0
- package/lib/editor/menu/built-in/back-color/back-color.d.ts +2 -0
- package/lib/editor/menu/built-in/back-color/index.d.ts +3 -0
- package/lib/editor/menu/built-in/back-color/props.d.ts +15 -0
- package/lib/editor/menu/built-in/blockquote/blockquote.d.ts +2 -0
- package/lib/editor/menu/built-in/blockquote/index.d.ts +3 -0
- package/lib/editor/menu/built-in/blockquote/props.d.ts +10 -0
- package/lib/editor/menu/built-in/bold/bold.d.ts +2 -0
- package/lib/editor/menu/built-in/bold/index.d.ts +3 -0
- package/lib/editor/menu/built-in/bold/props.d.ts +10 -0
- package/lib/editor/menu/built-in/clear-format/clear-format.d.ts +2 -0
- package/lib/editor/menu/built-in/clear-format/index.d.ts +3 -0
- package/lib/editor/menu/built-in/clear-format/props.d.ts +10 -0
- package/lib/editor/menu/built-in/code/code.d.ts +2 -0
- package/lib/editor/menu/built-in/code/index.d.ts +3 -0
- package/lib/editor/menu/built-in/code/props.d.ts +10 -0
- package/lib/editor/menu/built-in/code-block/code-block-languages.d.ts +2 -0
- package/lib/editor/menu/built-in/code-block/code-block.d.ts +2 -0
- package/lib/editor/menu/built-in/code-block/index.d.ts +4 -0
- package/lib/editor/menu/built-in/code-block/props.d.ts +32 -0
- package/lib/editor/menu/built-in/color/color.d.ts +2 -0
- package/lib/editor/menu/built-in/color/index.d.ts +3 -0
- package/lib/editor/menu/built-in/color/props.d.ts +15 -0
- package/lib/editor/menu/built-in/decrease-indent/decrease-indent.d.ts +2 -0
- package/lib/editor/menu/built-in/decrease-indent/index.d.ts +3 -0
- package/lib/editor/menu/built-in/decrease-indent/props.d.ts +10 -0
- package/lib/editor/menu/built-in/emoji/emoji.d.ts +2 -0
- package/lib/editor/menu/built-in/emoji/index.d.ts +3 -0
- package/lib/editor/menu/built-in/emoji/props.d.ts +15 -0
- package/lib/editor/menu/built-in/font-family/font-family.d.ts +2 -0
- package/lib/editor/menu/built-in/font-family/index.d.ts +3 -0
- package/lib/editor/menu/built-in/font-family/props.d.ts +21 -0
- package/lib/editor/menu/built-in/font-size/font-size.d.ts +2 -0
- package/lib/editor/menu/built-in/font-size/index.d.ts +3 -0
- package/lib/editor/menu/built-in/font-size/props.d.ts +21 -0
- package/lib/editor/menu/built-in/full-screen/full-screen.d.ts +2 -0
- package/lib/editor/menu/built-in/full-screen/index.d.ts +3 -0
- package/lib/editor/menu/built-in/full-screen/props.d.ts +18 -0
- package/lib/editor/menu/built-in/heading/heading.d.ts +2 -0
- package/lib/editor/menu/built-in/heading/index.d.ts +3 -0
- package/lib/editor/menu/built-in/heading/props.d.ts +21 -0
- package/lib/editor/menu/built-in/horizontal/horizontal.d.ts +2 -0
- package/lib/editor/menu/built-in/horizontal/index.d.ts +3 -0
- package/lib/editor/menu/built-in/horizontal/props.d.ts +10 -0
- package/lib/editor/menu/built-in/image/image.d.ts +2 -0
- package/lib/editor/menu/built-in/image/index.d.ts +3 -0
- package/lib/editor/menu/built-in/image/props.d.ts +26 -0
- package/lib/editor/menu/built-in/increase-indent/increase-indent.d.ts +2 -0
- package/lib/editor/menu/built-in/increase-indent/index.d.ts +3 -0
- package/lib/editor/menu/built-in/increase-indent/props.d.ts +10 -0
- package/lib/editor/menu/built-in/index.d.ts +38 -0
- package/lib/editor/menu/built-in/italic/index.d.ts +3 -0
- package/lib/editor/menu/built-in/italic/italic.d.ts +2 -0
- package/lib/editor/menu/built-in/italic/props.d.ts +10 -0
- package/lib/editor/menu/built-in/line-height/index.d.ts +3 -0
- package/lib/editor/menu/built-in/line-height/line-height.d.ts +2 -0
- package/lib/editor/menu/built-in/line-height/props.d.ts +21 -0
- package/lib/editor/menu/built-in/link/index.d.ts +4 -0
- package/lib/editor/menu/built-in/link/link-unset.d.ts +2 -0
- package/lib/editor/menu/built-in/link/link.d.ts +2 -0
- package/lib/editor/menu/built-in/link/props.d.ts +21 -0
- package/lib/editor/menu/built-in/math/index.d.ts +3 -0
- package/lib/editor/menu/built-in/math/math.d.ts +2 -0
- package/lib/editor/menu/built-in/math/props.d.ts +11 -0
- package/lib/editor/menu/built-in/ordered-list/index.d.ts +3 -0
- package/lib/editor/menu/built-in/ordered-list/ordered-list.d.ts +2 -0
- package/lib/editor/menu/built-in/ordered-list/props.d.ts +11 -0
- package/lib/editor/menu/built-in/redo/index.d.ts +3 -0
- package/lib/editor/menu/built-in/redo/props.d.ts +6 -0
- package/lib/editor/menu/built-in/redo/redo.d.ts +2 -0
- package/lib/editor/menu/built-in/strikethrough/index.d.ts +3 -0
- package/lib/editor/menu/built-in/strikethrough/props.d.ts +10 -0
- package/lib/editor/menu/built-in/strikethrough/strikethrough.d.ts +2 -0
- package/lib/editor/menu/built-in/subscript/index.d.ts +3 -0
- package/lib/editor/menu/built-in/subscript/props.d.ts +10 -0
- package/lib/editor/menu/built-in/subscript/subscript.d.ts +2 -0
- package/lib/editor/menu/built-in/superscript/index.d.ts +3 -0
- package/lib/editor/menu/built-in/superscript/props.d.ts +10 -0
- package/lib/editor/menu/built-in/superscript/superscript.d.ts +2 -0
- package/lib/editor/menu/built-in/table/index.d.ts +9 -0
- package/lib/editor/menu/built-in/table/props.d.ts +97 -0
- package/lib/editor/menu/built-in/table/table-add-column.d.ts +2 -0
- package/lib/editor/menu/built-in/table/table-add-row.d.ts +2 -0
- package/lib/editor/menu/built-in/table/table-delete-column.d.ts +2 -0
- package/lib/editor/menu/built-in/table/table-delete-row.d.ts +2 -0
- package/lib/editor/menu/built-in/table/table-merge-cell.d.ts +2 -0
- package/lib/editor/menu/built-in/table/table-unset.d.ts +2 -0
- package/lib/editor/menu/built-in/table/table.d.ts +2 -0
- package/lib/editor/menu/built-in/task/index.d.ts +3 -0
- package/lib/editor/menu/built-in/task/props.d.ts +10 -0
- package/lib/editor/menu/built-in/task/task.d.ts +2 -0
- package/lib/editor/menu/built-in/underline/index.d.ts +3 -0
- package/lib/editor/menu/built-in/underline/props.d.ts +10 -0
- package/lib/editor/menu/built-in/underline/underline.d.ts +2 -0
- package/lib/editor/menu/built-in/undo/index.d.ts +3 -0
- package/lib/editor/menu/built-in/undo/props.d.ts +6 -0
- package/lib/editor/menu/built-in/undo/undo.d.ts +2 -0
- package/lib/editor/menu/built-in/unordered-list/index.d.ts +3 -0
- package/lib/editor/menu/built-in/unordered-list/props.d.ts +11 -0
- package/lib/editor/menu/built-in/unordered-list/unordered-list.d.ts +2 -0
- package/lib/editor/menu/built-in/video/index.d.ts +6 -0
- package/lib/editor/menu/built-in/video/props.d.ts +56 -0
- package/lib/editor/menu/built-in/video/video-controls.d.ts +2 -0
- package/lib/editor/menu/built-in/video/video-loop.d.ts +2 -0
- package/lib/editor/menu/built-in/video/video-muted.d.ts +2 -0
- package/lib/editor/menu/built-in/video/video.d.ts +2 -0
- package/lib/editor/menu/built-in/wrap-down/index.d.ts +3 -0
- package/lib/editor/menu/built-in/wrap-down/props.d.ts +15 -0
- package/lib/editor/menu/built-in/wrap-down/wrap-down.d.ts +2 -0
- package/lib/editor/menu/built-in/wrap-up/index.d.ts +3 -0
- package/lib/editor/menu/built-in/wrap-up/props.d.ts +15 -0
- package/lib/editor/menu/built-in/wrap-up/wrap-up.d.ts +2 -0
- package/lib/editor/menu/index.d.ts +4 -0
- package/lib/editor/menu/menu.d.ts +6 -0
- package/lib/editor/menu/props.d.ts +89 -0
- package/lib/editor/wrapper/index.d.ts +3 -0
- package/lib/editor/wrapper/props.d.ts +206 -0
- package/lib/editor/wrapper/render.d.ts +18 -0
- package/lib/editor/wrapper/wrapper.d.ts +6 -0
- package/lib/hooks/index.d.ts +1 -0
- package/lib/hooks/use-editor.d.ts +32 -0
- package/lib/index.d.ts +9 -0
- package/lib/kaitify-react.es.js +47868 -0
- package/lib/kaitify-react.umd.js +30 -0
- package/lib/locale/en-us.d.ts +31 -0
- package/lib/locale/index.d.ts +2 -0
- package/lib/locale/ja-jp.d.ts +31 -0
- package/lib/locale/ko-kr.d.ts +31 -0
- package/package.json +56 -0
- package/src/core/button/button.tsx +29 -0
- package/src/core/button/index.ts +3 -0
- package/src/core/button/props.ts +39 -0
- package/src/core/button/style.module.less +57 -0
- package/src/core/checkbox/checkbox.tsx +39 -0
- package/src/core/checkbox/index.ts +3 -0
- package/src/core/checkbox/props.ts +21 -0
- package/src/core/checkbox/style.module.less +99 -0
- package/src/core/divider/divider.tsx +17 -0
- package/src/core/divider/index.ts +2 -0
- package/src/core/divider/style.module.less +12 -0
- package/src/core/icon/icon.tsx +14 -0
- package/src/core/icon/index.ts +3 -0
- package/src/core/icon/props.ts +23 -0
- package/src/core/icon/style.module.less +19 -0
- package/src/core/popover/index.ts +3 -0
- package/src/core/popover/popover.tsx +286 -0
- package/src/core/popover/props.ts +97 -0
- package/src/core/popover/style.module.less +247 -0
- package/src/core/tabs/index.ts +3 -0
- package/src/core/tabs/props.ts +19 -0
- package/src/core/tabs/style.module.less +62 -0
- package/src/core/tabs/tabs.tsx +35 -0
- package/src/core/teleport/index.ts +3 -0
- package/src/core/teleport/props.ts +12 -0
- package/src/core/teleport/teleport.tsx +23 -0
- package/src/editor/bubble/bubble.tsx +244 -0
- package/src/editor/bubble/index.ts +3 -0
- package/src/editor/bubble/props.ts +65 -0
- package/src/editor/bubble/style.module.less +33 -0
- package/src/editor/menu/built-in/align-center/align-center.tsx +37 -0
- package/src/editor/menu/built-in/align-center/index.ts +3 -0
- package/src/editor/menu/built-in/align-center/props.ts +10 -0
- package/src/editor/menu/built-in/align-justify/align-justify.tsx +37 -0
- package/src/editor/menu/built-in/align-justify/index.ts +3 -0
- package/src/editor/menu/built-in/align-justify/props.ts +10 -0
- package/src/editor/menu/built-in/align-left/align-left.tsx +37 -0
- package/src/editor/menu/built-in/align-left/index.ts +3 -0
- package/src/editor/menu/built-in/align-left/props.ts +10 -0
- package/src/editor/menu/built-in/align-right/align-right.tsx +37 -0
- package/src/editor/menu/built-in/align-right/index.ts +3 -0
- package/src/editor/menu/built-in/align-right/props.ts +10 -0
- package/src/editor/menu/built-in/attachment/attachment.tsx +190 -0
- package/src/editor/menu/built-in/attachment/index.ts +3 -0
- package/src/editor/menu/built-in/attachment/props.ts +27 -0
- package/src/editor/menu/built-in/attachment/style.module.less +138 -0
- package/src/editor/menu/built-in/back-color/back-color.tsx +97 -0
- package/src/editor/menu/built-in/back-color/index.ts +3 -0
- package/src/editor/menu/built-in/back-color/props.ts +16 -0
- package/src/editor/menu/built-in/back-color/style.module.less +62 -0
- package/src/editor/menu/built-in/blockquote/blockquote.tsx +36 -0
- package/src/editor/menu/built-in/blockquote/index.ts +3 -0
- package/src/editor/menu/built-in/blockquote/props.ts +10 -0
- package/src/editor/menu/built-in/bold/bold.tsx +45 -0
- package/src/editor/menu/built-in/bold/index.ts +3 -0
- package/src/editor/menu/built-in/bold/props.ts +10 -0
- package/src/editor/menu/built-in/clear-format/clear-format.tsx +28 -0
- package/src/editor/menu/built-in/clear-format/index.ts +3 -0
- package/src/editor/menu/built-in/clear-format/props.ts +10 -0
- package/src/editor/menu/built-in/code/code.tsx +49 -0
- package/src/editor/menu/built-in/code/index.ts +3 -0
- package/src/editor/menu/built-in/code/props.ts +10 -0
- package/src/editor/menu/built-in/code-block/code-block-languages.tsx +73 -0
- package/src/editor/menu/built-in/code-block/code-block.tsx +36 -0
- package/src/editor/menu/built-in/code-block/index.ts +4 -0
- package/src/editor/menu/built-in/code-block/props.ts +32 -0
- package/src/editor/menu/built-in/color/color.tsx +96 -0
- package/src/editor/menu/built-in/color/index.ts +3 -0
- package/src/editor/menu/built-in/color/props.ts +16 -0
- package/src/editor/menu/built-in/color/style.module.less +62 -0
- package/src/editor/menu/built-in/decrease-indent/decrease-indent.tsx +31 -0
- package/src/editor/menu/built-in/decrease-indent/index.ts +3 -0
- package/src/editor/menu/built-in/decrease-indent/props.ts +10 -0
- package/src/editor/menu/built-in/emoji/emoji.tsx +143 -0
- package/src/editor/menu/built-in/emoji/index.ts +3 -0
- package/src/editor/menu/built-in/emoji/props.ts +16 -0
- package/src/editor/menu/built-in/emoji/style.module.less +26 -0
- package/src/editor/menu/built-in/font-family/font-family.tsx +99 -0
- package/src/editor/menu/built-in/font-family/index.ts +3 -0
- package/src/editor/menu/built-in/font-family/props.ts +20 -0
- package/src/editor/menu/built-in/font-size/font-size.tsx +110 -0
- package/src/editor/menu/built-in/font-size/index.ts +3 -0
- package/src/editor/menu/built-in/font-size/props.ts +20 -0
- package/src/editor/menu/built-in/full-screen/full-screen.tsx +66 -0
- package/src/editor/menu/built-in/full-screen/index.ts +3 -0
- package/src/editor/menu/built-in/full-screen/props.ts +18 -0
- package/src/editor/menu/built-in/heading/heading.tsx +101 -0
- package/src/editor/menu/built-in/heading/index.ts +3 -0
- package/src/editor/menu/built-in/heading/props.ts +20 -0
- package/src/editor/menu/built-in/horizontal/horizontal.tsx +40 -0
- package/src/editor/menu/built-in/horizontal/index.ts +3 -0
- package/src/editor/menu/built-in/horizontal/props.ts +10 -0
- package/src/editor/menu/built-in/image/image.tsx +189 -0
- package/src/editor/menu/built-in/image/index.ts +3 -0
- package/src/editor/menu/built-in/image/props.ts +27 -0
- package/src/editor/menu/built-in/image/style.module.less +138 -0
- package/src/editor/menu/built-in/increase-indent/increase-indent.tsx +31 -0
- package/src/editor/menu/built-in/increase-indent/index.ts +3 -0
- package/src/editor/menu/built-in/increase-indent/props.ts +10 -0
- package/src/editor/menu/built-in/index.ts +38 -0
- package/src/editor/menu/built-in/italic/index.ts +3 -0
- package/src/editor/menu/built-in/italic/italic.tsx +45 -0
- package/src/editor/menu/built-in/italic/props.ts +10 -0
- package/src/editor/menu/built-in/line-height/index.ts +3 -0
- package/src/editor/menu/built-in/line-height/line-height.tsx +81 -0
- package/src/editor/menu/built-in/line-height/props.ts +20 -0
- package/src/editor/menu/built-in/link/index.ts +4 -0
- package/src/editor/menu/built-in/link/link-unset.tsx +30 -0
- package/src/editor/menu/built-in/link/link.tsx +147 -0
- package/src/editor/menu/built-in/link/props.ts +23 -0
- package/src/editor/menu/built-in/link/style.module.less +51 -0
- package/src/editor/menu/built-in/math/index.ts +3 -0
- package/src/editor/menu/built-in/math/math.tsx +98 -0
- package/src/editor/menu/built-in/math/props.ts +12 -0
- package/src/editor/menu/built-in/math/style.module.less +54 -0
- package/src/editor/menu/built-in/ordered-list/index.ts +3 -0
- package/src/editor/menu/built-in/ordered-list/ordered-list.tsx +85 -0
- package/src/editor/menu/built-in/ordered-list/props.ts +12 -0
- package/src/editor/menu/built-in/ordered-list/style.module.less +16 -0
- package/src/editor/menu/built-in/redo/index.ts +3 -0
- package/src/editor/menu/built-in/redo/props.ts +6 -0
- package/src/editor/menu/built-in/redo/redo.tsx +30 -0
- package/src/editor/menu/built-in/strikethrough/index.ts +3 -0
- package/src/editor/menu/built-in/strikethrough/props.ts +10 -0
- package/src/editor/menu/built-in/strikethrough/strikethrough.tsx +45 -0
- package/src/editor/menu/built-in/subscript/index.ts +3 -0
- package/src/editor/menu/built-in/subscript/props.ts +10 -0
- package/src/editor/menu/built-in/subscript/subscript.tsx +45 -0
- package/src/editor/menu/built-in/superscript/index.ts +3 -0
- package/src/editor/menu/built-in/superscript/props.ts +10 -0
- package/src/editor/menu/built-in/superscript/superscript.tsx +45 -0
- package/src/editor/menu/built-in/table/index.ts +9 -0
- package/src/editor/menu/built-in/table/props.ts +105 -0
- package/src/editor/menu/built-in/table/style.module.less +63 -0
- package/src/editor/menu/built-in/table/table-add-column.tsx +31 -0
- package/src/editor/menu/built-in/table/table-add-row.tsx +31 -0
- package/src/editor/menu/built-in/table/table-delete-column.tsx +31 -0
- package/src/editor/menu/built-in/table/table-delete-row.tsx +31 -0
- package/src/editor/menu/built-in/table/table-merge-cell.tsx +34 -0
- package/src/editor/menu/built-in/table/table-unset.tsx +31 -0
- package/src/editor/menu/built-in/table/table.tsx +144 -0
- package/src/editor/menu/built-in/task/index.ts +3 -0
- package/src/editor/menu/built-in/task/props.ts +10 -0
- package/src/editor/menu/built-in/task/task.tsx +36 -0
- package/src/editor/menu/built-in/underline/index.ts +3 -0
- package/src/editor/menu/built-in/underline/props.ts +10 -0
- package/src/editor/menu/built-in/underline/underline.tsx +46 -0
- package/src/editor/menu/built-in/undo/index.ts +3 -0
- package/src/editor/menu/built-in/undo/props.ts +6 -0
- package/src/editor/menu/built-in/undo/undo.tsx +31 -0
- package/src/editor/menu/built-in/unordered-list/index.ts +3 -0
- package/src/editor/menu/built-in/unordered-list/props.ts +12 -0
- package/src/editor/menu/built-in/unordered-list/style.module.less +16 -0
- package/src/editor/menu/built-in/unordered-list/unordered-list.tsx +85 -0
- package/src/editor/menu/built-in/video/index.ts +6 -0
- package/src/editor/menu/built-in/video/props.ts +60 -0
- package/src/editor/menu/built-in/video/style.module.less +92 -0
- package/src/editor/menu/built-in/video/video-controls.tsx +44 -0
- package/src/editor/menu/built-in/video/video-loop.tsx +47 -0
- package/src/editor/menu/built-in/video/video-muted.tsx +48 -0
- package/src/editor/menu/built-in/video/video.tsx +138 -0
- package/src/editor/menu/built-in/wrap-down/index.ts +3 -0
- package/src/editor/menu/built-in/wrap-down/props.ts +16 -0
- package/src/editor/menu/built-in/wrap-down/wrap-down.tsx +49 -0
- package/src/editor/menu/built-in/wrap-up/index.ts +3 -0
- package/src/editor/menu/built-in/wrap-up/props.ts +16 -0
- package/src/editor/menu/built-in/wrap-up/wrap-up.tsx +52 -0
- package/src/editor/menu/index.ts +4 -0
- package/src/editor/menu/menu.tsx +176 -0
- package/src/editor/menu/props.ts +90 -0
- package/src/editor/menu/style.module.less +80 -0
- package/src/editor/wrapper/index.ts +3 -0
- package/src/editor/wrapper/props.ts +209 -0
- package/src/editor/wrapper/render.ts +79 -0
- package/src/editor/wrapper/style.module.less +10 -0
- package/src/editor/wrapper/wrapper.tsx +220 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-editor.ts +47 -0
- package/src/iconfont/iconfont.css +247 -0
- package/src/iconfont/iconfont.ttf +0 -0
- package/src/iconfont/iconfont.woff +0 -0
- package/src/index.ts +20 -0
- package/src/locale/en-us.ts +30 -0
- package/src/locale/index.ts +18 -0
- package/src/locale/ja-jp.ts +30 -0
- package/src/locale/ko-kr.ts +30 -0
- package/src/var.less +19 -0
- package/tsconfig.json +32 -0
- package/tsconfig.node.json +11 -0
- package/vite-env.d.ts +5 -0
- package/vite.config.ts +58 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import React, { useMemo, useRef, useState } from 'react'
|
|
2
|
+
import { file as DapFile } from 'dap-util'
|
|
3
|
+
import classNames from 'classnames'
|
|
4
|
+
import { SetAttachmentOptionType, UpdateAttachmentOptionType } from '@kaitify/core'
|
|
5
|
+
import { Tabs, TabsPropsType } from '@/core/tabs'
|
|
6
|
+
import { Button } from '@/core/button'
|
|
7
|
+
import { Icon } from '@/core/icon'
|
|
8
|
+
import { useEditor } from '@/hooks'
|
|
9
|
+
import Menu from '../../menu'
|
|
10
|
+
import { MenuRefType } from '../../props'
|
|
11
|
+
import { AttachmentMenuPropsType } from './props'
|
|
12
|
+
import styles from './style.module.less'
|
|
13
|
+
|
|
14
|
+
export default function AttachmentMenu({
|
|
15
|
+
tabs = {
|
|
16
|
+
data: ['remote', 'upload'],
|
|
17
|
+
default: 'remote'
|
|
18
|
+
},
|
|
19
|
+
...props
|
|
20
|
+
}: AttachmentMenuPropsType) {
|
|
21
|
+
const { state, t, dark } = useEditor()
|
|
22
|
+
//菜单组件实例
|
|
23
|
+
const menuRef = useRef<MenuRefType | null>(null)
|
|
24
|
+
//远程附件数据
|
|
25
|
+
const [remoteData, setRemoteData] = useState<Omit<SetAttachmentOptionType, 'icon'>>({
|
|
26
|
+
url: '',
|
|
27
|
+
text: ''
|
|
28
|
+
})
|
|
29
|
+
//更新附件数据
|
|
30
|
+
const [updateData, setUpdateData] = useState<UpdateAttachmentOptionType>({
|
|
31
|
+
url: '',
|
|
32
|
+
text: ''
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
//选项卡数据
|
|
36
|
+
const tabData = useMemo<TabsPropsType['data']>(() => {
|
|
37
|
+
return tabs.data.map(item => {
|
|
38
|
+
return [
|
|
39
|
+
{
|
|
40
|
+
label: t('远程地址'),
|
|
41
|
+
value: 'remote'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
label: t('本地上传'),
|
|
45
|
+
value: 'upload'
|
|
46
|
+
}
|
|
47
|
+
].find(v => v.value == item)!
|
|
48
|
+
})
|
|
49
|
+
}, [tabs])
|
|
50
|
+
//是否激活
|
|
51
|
+
const isActive = useMemo(() => {
|
|
52
|
+
return !!state.editor.value?.commands.getAttachment?.()
|
|
53
|
+
}, [state.editor])
|
|
54
|
+
//是否禁用
|
|
55
|
+
const isDisabled = useMemo(() => {
|
|
56
|
+
if (!state.editor.value?.selection.focused()) {
|
|
57
|
+
return true
|
|
58
|
+
}
|
|
59
|
+
if (state.editor.value.commands.hasMath?.()) {
|
|
60
|
+
return true
|
|
61
|
+
}
|
|
62
|
+
if (state.editor.value.commands.hasCodeBlock?.()) {
|
|
63
|
+
return true
|
|
64
|
+
}
|
|
65
|
+
if (state.editor.value.commands.hasLink?.()) {
|
|
66
|
+
return true
|
|
67
|
+
}
|
|
68
|
+
if (state.editor.value.commands.hasAttachment?.() && !isActive) {
|
|
69
|
+
return true
|
|
70
|
+
}
|
|
71
|
+
return props.disabled ?? false
|
|
72
|
+
}, [state.editor, props.disabled, isActive])
|
|
73
|
+
|
|
74
|
+
//浮层显示
|
|
75
|
+
const menuShowing = () => {
|
|
76
|
+
const info = state.editor.value?.commands.getAttachmentInfo?.()
|
|
77
|
+
if (info) {
|
|
78
|
+
setUpdateData({
|
|
79
|
+
text: info.text,
|
|
80
|
+
url: info.url
|
|
81
|
+
})
|
|
82
|
+
} else {
|
|
83
|
+
setRemoteData({
|
|
84
|
+
text: '',
|
|
85
|
+
url: ''
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//选择本地文件
|
|
90
|
+
const fileChange = async (e: React.ChangeEvent) => {
|
|
91
|
+
const file = (e.currentTarget as HTMLInputElement).files?.[0]
|
|
92
|
+
if (!file || !state.editor.value) {
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
const url = typeof props.customUpload == 'function' ? await props.customUpload(file) : await DapFile.dataFileToBase64(file)
|
|
96
|
+
if (!url) {
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
state.editor.value.commands.setAttachment?.({
|
|
100
|
+
url: url,
|
|
101
|
+
text: file.name || t('附件'),
|
|
102
|
+
icon: props.iconUrl
|
|
103
|
+
})
|
|
104
|
+
menuRef.current?.hidePopover()
|
|
105
|
+
}
|
|
106
|
+
//插入远程附件
|
|
107
|
+
const insert = async () => {
|
|
108
|
+
if (!remoteData.url || !remoteData.text || !state.editor.value) {
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
state.editor.value.commands.setAttachment?.({
|
|
112
|
+
url: remoteData.url,
|
|
113
|
+
text: remoteData.text,
|
|
114
|
+
icon: props.iconUrl
|
|
115
|
+
})
|
|
116
|
+
menuRef.current?.hidePopover()
|
|
117
|
+
}
|
|
118
|
+
//更新远程附件
|
|
119
|
+
const update = async () => {
|
|
120
|
+
if (!updateData.url || !updateData.text || !state.editor.value) {
|
|
121
|
+
return
|
|
122
|
+
}
|
|
123
|
+
state.editor.value.commands.updateAttachment?.({
|
|
124
|
+
url: updateData.url,
|
|
125
|
+
text: updateData.text
|
|
126
|
+
})
|
|
127
|
+
menuRef.current?.hidePopover()
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<Menu
|
|
132
|
+
ref={menuRef}
|
|
133
|
+
disabled={isDisabled}
|
|
134
|
+
active={isActive}
|
|
135
|
+
popover
|
|
136
|
+
popoverProps={{ width: props.popoverProps?.width ?? 300, maxHeight: props.popoverProps?.maxHeight, minWidth: props.popoverProps?.minWidth, animation: props.popoverProps?.animation, arrow: props.popoverProps?.arrow, placement: props.popoverProps?.placement, trigger: props.popoverProps?.trigger, zIndex: props.popoverProps?.zIndex, onShowing: menuShowing }}
|
|
137
|
+
customPopover={
|
|
138
|
+
isActive ? (
|
|
139
|
+
<div
|
|
140
|
+
className={classNames(styles['kaitify-attachment-update'], {
|
|
141
|
+
[styles['kaitify-dark']]: dark
|
|
142
|
+
})}
|
|
143
|
+
>
|
|
144
|
+
<input value={updateData.text} onChange={e => setUpdateData(oldValue => ({ ...oldValue, text: e.target.value }))} placeholder={t('附件名称')} type='text' />
|
|
145
|
+
<input value={updateData.url} onChange={e => setUpdateData(oldValue => ({ ...oldValue, url: e.target.value }))} placeholder={t('附件地址')} type='url' />
|
|
146
|
+
<div className={styles['kaitify-attachment-update-footer']}>
|
|
147
|
+
<Button onClick={update} disabled={!updateData.url || !updateData.text}>
|
|
148
|
+
{t('更新')}
|
|
149
|
+
</Button>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
) : (
|
|
153
|
+
<Tabs defaultValue={tabs.default} data={tabData}>
|
|
154
|
+
{current => (
|
|
155
|
+
<>
|
|
156
|
+
{current === 'remote' && (
|
|
157
|
+
<div
|
|
158
|
+
className={classNames(styles['kaitify-attachment-remote'], {
|
|
159
|
+
[styles['kaitify-dark']]: dark
|
|
160
|
+
})}
|
|
161
|
+
>
|
|
162
|
+
<input value={remoteData.text} onChange={e => setRemoteData(oldValue => ({ ...oldValue, text: e.target.value }))} placeholder={t('附件名称')} type='text' />
|
|
163
|
+
<input value={remoteData.url} onChange={e => setRemoteData(oldValue => ({ ...oldValue, url: e.target.value }))} placeholder={t('附件地址')} type='url' />
|
|
164
|
+
<div className={styles['kaitify-attachment-remote-footer']}>
|
|
165
|
+
<Button onClick={insert} disabled={!remoteData.url || !remoteData.text}>
|
|
166
|
+
{t('插入')}
|
|
167
|
+
</Button>
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
)}
|
|
171
|
+
{current === 'upload' && (
|
|
172
|
+
<div
|
|
173
|
+
className={classNames(styles['kaitify-attachment-upload'], {
|
|
174
|
+
[styles['kaitify-dark']]: dark
|
|
175
|
+
})}
|
|
176
|
+
>
|
|
177
|
+
<input type='file' accept='*' onChange={fileChange} />
|
|
178
|
+
<Icon name='kaitify-icon-upload' />
|
|
179
|
+
</div>
|
|
180
|
+
)}
|
|
181
|
+
</>
|
|
182
|
+
)}
|
|
183
|
+
</Tabs>
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
>
|
|
187
|
+
<Icon name='kaitify-icon-attachment' />
|
|
188
|
+
</Menu>
|
|
189
|
+
)
|
|
190
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { MenuPropsType } from '@/editor/menu/props'
|
|
2
|
+
|
|
3
|
+
export type AttachmentMenuPropsType = {
|
|
4
|
+
/**
|
|
5
|
+
* 是否禁用
|
|
6
|
+
*/
|
|
7
|
+
disabled?: boolean
|
|
8
|
+
/**
|
|
9
|
+
* tabs配置
|
|
10
|
+
*/
|
|
11
|
+
tabs?: {
|
|
12
|
+
data: ('remote' | 'upload')[]
|
|
13
|
+
default: 'remote' | 'upload'
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 浮层属性
|
|
17
|
+
*/
|
|
18
|
+
popoverProps?: Omit<NonNullable<MenuPropsType['popoverProps']>, 'onShow' | 'onShowing' | 'onShown' | 'onHide' | 'onHiding' | 'onHidden'>
|
|
19
|
+
/**
|
|
20
|
+
* 附件logo图片地址
|
|
21
|
+
*/
|
|
22
|
+
iconUrl?: string
|
|
23
|
+
/**
|
|
24
|
+
* 自定义上传方法
|
|
25
|
+
*/
|
|
26
|
+
customUpload?: (file: File) => string | Promise<string>
|
|
27
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
.kaitify-attachment-upload {
|
|
2
|
+
display: flex;
|
|
3
|
+
justify-content: center;
|
|
4
|
+
align-items: center;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100px;
|
|
7
|
+
font-size: 30px;
|
|
8
|
+
color: @font-color;
|
|
9
|
+
position: relative;
|
|
10
|
+
opacity: 0.7;
|
|
11
|
+
transition: all 300ms;
|
|
12
|
+
|
|
13
|
+
input[type='file'] {
|
|
14
|
+
opacity: 0;
|
|
15
|
+
position: absolute;
|
|
16
|
+
left: 0;
|
|
17
|
+
top: 0;
|
|
18
|
+
z-index: 1;
|
|
19
|
+
width: 100%;
|
|
20
|
+
height: 100%;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&:hover {
|
|
24
|
+
opacity: 1;
|
|
25
|
+
|
|
26
|
+
input[type='file'] {
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&.kaitify-dark {
|
|
32
|
+
color: @font-color-dark;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.kaitify-attachment-remote {
|
|
37
|
+
display: block;
|
|
38
|
+
width: 100%;
|
|
39
|
+
padding: @small-padding @padding;
|
|
40
|
+
|
|
41
|
+
input[type='text'],
|
|
42
|
+
input[type='url'] {
|
|
43
|
+
display: block;
|
|
44
|
+
width: 100%;
|
|
45
|
+
border: none;
|
|
46
|
+
border-bottom: 1px solid @border-color;
|
|
47
|
+
font-size: @font-size;
|
|
48
|
+
font-family: @font-family;
|
|
49
|
+
line-height: @line-height;
|
|
50
|
+
color: @font-color;
|
|
51
|
+
background: transparent;
|
|
52
|
+
padding: @small-padding 0;
|
|
53
|
+
margin-bottom: @margin;
|
|
54
|
+
transition: all 300ms;
|
|
55
|
+
|
|
56
|
+
&:focus {
|
|
57
|
+
border-bottom-color: @theme;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&::placeholder,
|
|
61
|
+
&::-webkit-input-placeholder {
|
|
62
|
+
opacity: 0.5;
|
|
63
|
+
font-family: @font-family;
|
|
64
|
+
color: inherit;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.kaitify-attachment-remote-footer {
|
|
69
|
+
display: flex;
|
|
70
|
+
justify-content: flex-end;
|
|
71
|
+
align-items: center;
|
|
72
|
+
width: 100%;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&.kaitify-dark {
|
|
76
|
+
input[type='text'],
|
|
77
|
+
input[type='url'] {
|
|
78
|
+
border-bottom-color: @border-color-dark;
|
|
79
|
+
color: @font-color-dark;
|
|
80
|
+
|
|
81
|
+
&:focus {
|
|
82
|
+
border-bottom-color: @theme;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.kaitify-attachment-update {
|
|
89
|
+
display: block;
|
|
90
|
+
width: 100%;
|
|
91
|
+
padding: @padding @padding @small-padding @padding;
|
|
92
|
+
|
|
93
|
+
input[type='text'],
|
|
94
|
+
input[type='url'] {
|
|
95
|
+
display: block;
|
|
96
|
+
width: 100%;
|
|
97
|
+
border: none;
|
|
98
|
+
border-bottom: 1px solid @border-color;
|
|
99
|
+
font-size: @font-size;
|
|
100
|
+
font-family: @font-family;
|
|
101
|
+
line-height: @line-height;
|
|
102
|
+
color: @font-color;
|
|
103
|
+
background: transparent;
|
|
104
|
+
padding: @small-padding 0;
|
|
105
|
+
margin-bottom: @margin;
|
|
106
|
+
transition: all 300ms;
|
|
107
|
+
|
|
108
|
+
&:focus {
|
|
109
|
+
border-bottom-color: @theme;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
&::placeholder,
|
|
113
|
+
&::-webkit-input-placeholder {
|
|
114
|
+
opacity: 0.5;
|
|
115
|
+
font-family: @font-family;
|
|
116
|
+
color: inherit;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.kaitify-attachment-update-footer {
|
|
121
|
+
display: flex;
|
|
122
|
+
justify-content: flex-end;
|
|
123
|
+
align-items: center;
|
|
124
|
+
width: 100%;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&.kaitify-dark {
|
|
128
|
+
input[type='text'],
|
|
129
|
+
input[type='url'] {
|
|
130
|
+
border-bottom-color: @border-color-dark;
|
|
131
|
+
color: @font-color-dark;
|
|
132
|
+
|
|
133
|
+
&:focus {
|
|
134
|
+
border-bottom-color: @theme;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { useEditor } from '@/hooks'
|
|
2
|
+
import { useCallback, useMemo, useRef } from 'react'
|
|
3
|
+
import classNames from 'classnames'
|
|
4
|
+
import { Icon } from '@/core/icon'
|
|
5
|
+
import { Button } from '@/core/button'
|
|
6
|
+
import { MenuRefType } from '../../props'
|
|
7
|
+
import Menu from '../../menu'
|
|
8
|
+
import { BackColorMenuPropsType } from './props'
|
|
9
|
+
import styles from './style.module.less'
|
|
10
|
+
|
|
11
|
+
const defaultColors: string[] = ['#000000', '#505050', '#808080', '#BBBBBB', '#CCCCCC', '#EEEEEE', '#F7F7F7', '#FFFFFF', '#EC1A0A', '#FF9900', '#FFFF00', '#07C160', '#00FFFF', '#0B73DE', '#9C00FF', '#FF00FF', '#F7C6CE', '#FFE7CE', '#FFEFC6', '#D6EFD6', '#CEDEE7', '#CEE7F7', '#D6D6E7', '#E7D6DE', '#E79C9C', '#FFC69C', '#FFE79C', '#B5D6A5', '#A5C6CE', '#9CC6EF', '#B5A5D6', '#D6A5BD', '#e45649', '#F7AD6B', '#FFD663', '#94BD7B', '#73A5AD', '#6BADDE', '#8C7BC6', '#C67BA5', '#CE0000', '#E79439', '#EFC631', '#50a14f', '#4A7B8C', '#03A8F3', '#634AA5', '#A54A7B', '#9C0000', '#B56308', '#BD9400', '#397B21', '#104A5A', '#085294', '#311873', '#731842', '#630000', '#7B3900', '#986801', '#295218', '#083139', '#003163', '#21104A', '#4A1031']
|
|
12
|
+
|
|
13
|
+
export default function BackColorMenu({ colors = defaultColors, ...props }: BackColorMenuPropsType) {
|
|
14
|
+
const { state, t, dark } = useEditor()
|
|
15
|
+
|
|
16
|
+
//菜单组件实例
|
|
17
|
+
const menuRef = useRef<MenuRefType | null>(null)
|
|
18
|
+
|
|
19
|
+
//颜色是否激活
|
|
20
|
+
const isActive = useCallback(
|
|
21
|
+
(item: string) => {
|
|
22
|
+
return state.editor.value?.commands.isBackColor?.(item) ?? false
|
|
23
|
+
},
|
|
24
|
+
[state.editor]
|
|
25
|
+
)
|
|
26
|
+
//是否禁用
|
|
27
|
+
const isDisabled = useMemo(() => {
|
|
28
|
+
if (!state.editor.value?.selection.focused()) {
|
|
29
|
+
return true
|
|
30
|
+
}
|
|
31
|
+
if (!state.editor.value.selection.collapsed() && !state.editor.value.getFocusNodesBySelection('text').length) {
|
|
32
|
+
return true
|
|
33
|
+
}
|
|
34
|
+
if (state.editor.value.selection.collapsed() && (!!state.editor.value.commands.getAttachment?.() || !!state.editor.value.commands.getMath?.())) {
|
|
35
|
+
return true
|
|
36
|
+
}
|
|
37
|
+
if (!!state.editor.value.commands.getCodeBlock?.()) {
|
|
38
|
+
return true
|
|
39
|
+
}
|
|
40
|
+
return props.disabled ?? false
|
|
41
|
+
}, [state.editor, props.disabled])
|
|
42
|
+
|
|
43
|
+
//设置颜色
|
|
44
|
+
const setBackColor = (val: string) => {
|
|
45
|
+
if (!state.editor.value || state.editor.value.commands.isBackColor?.(val)) {
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
state.editor.value.commands.setBackColor?.(val)
|
|
49
|
+
menuRef.current?.hidePopover()
|
|
50
|
+
}
|
|
51
|
+
//移除颜色
|
|
52
|
+
const unsetBackColor = () => {
|
|
53
|
+
if (!state.editor.value) {
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
state.editor.value.commands.removeTextStyle?.(['backgroundColor', 'background'])
|
|
57
|
+
menuRef.current?.hidePopover()
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<Menu
|
|
62
|
+
ref={menuRef}
|
|
63
|
+
disabled={isDisabled}
|
|
64
|
+
active={false}
|
|
65
|
+
popover
|
|
66
|
+
popoverProps={{ width: props.popoverProps?.width, maxHeight: props.popoverProps?.maxHeight, minWidth: props.popoverProps?.minWidth, animation: props.popoverProps?.animation, arrow: props.popoverProps?.arrow, placement: props.popoverProps?.placement, trigger: props.popoverProps?.trigger, zIndex: props.popoverProps?.zIndex }}
|
|
67
|
+
customPopover={
|
|
68
|
+
<div
|
|
69
|
+
className={classNames(styles['kaitify-colors-panel'], {
|
|
70
|
+
[styles['kaitify-dark']]: dark
|
|
71
|
+
})}
|
|
72
|
+
>
|
|
73
|
+
<div className={styles['kaitify-colors-header']}>
|
|
74
|
+
<Button onClick={unsetBackColor} block large>
|
|
75
|
+
<Icon name='kaitify-icon-remove' />
|
|
76
|
+
<span className={styles['kaitify-colors-header-text']}>{t('默认颜色')}</span>
|
|
77
|
+
</Button>
|
|
78
|
+
</div>
|
|
79
|
+
<div className={styles['kaitify-colors-content']}>
|
|
80
|
+
{colors.map(item => (
|
|
81
|
+
<div
|
|
82
|
+
key={item}
|
|
83
|
+
className={classNames(styles['kaitify-colors-el'], {
|
|
84
|
+
[styles['kaitify-color-el-active']]: isActive(item)
|
|
85
|
+
})}
|
|
86
|
+
>
|
|
87
|
+
<div style={{ background: item }} onClick={() => setBackColor(item)} />
|
|
88
|
+
</div>
|
|
89
|
+
))}
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
}
|
|
93
|
+
>
|
|
94
|
+
<Icon name='kaitify-icon-brush' />
|
|
95
|
+
</Menu>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MenuPropsType } from '@/editor/menu/props'
|
|
2
|
+
|
|
3
|
+
export type BackColorMenuPropsType = {
|
|
4
|
+
/**
|
|
5
|
+
* 是否禁用
|
|
6
|
+
*/
|
|
7
|
+
disabled?: boolean
|
|
8
|
+
/**
|
|
9
|
+
* 颜色数组
|
|
10
|
+
*/
|
|
11
|
+
colors?: string[]
|
|
12
|
+
/**
|
|
13
|
+
* 浮层属性
|
|
14
|
+
*/
|
|
15
|
+
popoverProps?: Omit<NonNullable<MenuPropsType['popoverProps']>, 'onShow' | 'onShowing' | 'onShown' | 'onHide' | 'onHiding' | 'onHidden'>
|
|
16
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
.kaitify-colors-panel {
|
|
2
|
+
display: block;
|
|
3
|
+
width: 100%;
|
|
4
|
+
padding: @small-padding;
|
|
5
|
+
|
|
6
|
+
.kaitify-colors-header {
|
|
7
|
+
display: block;
|
|
8
|
+
width: 100%;
|
|
9
|
+
padding-bottom: @small-padding;
|
|
10
|
+
margin-bottom: @margin;
|
|
11
|
+
border-bottom: 1px solid @border-color;
|
|
12
|
+
|
|
13
|
+
.kaitify-colors-header-text {
|
|
14
|
+
margin-left: 10px;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.kaitify-colors-content {
|
|
19
|
+
display: grid;
|
|
20
|
+
width: 100%;
|
|
21
|
+
grid-template-columns: repeat(8, 1fr);
|
|
22
|
+
gap: 2px;
|
|
23
|
+
|
|
24
|
+
.kaitify-colors-el {
|
|
25
|
+
padding: 2px;
|
|
26
|
+
border: 1px solid transparent;
|
|
27
|
+
border-radius: 1px;
|
|
28
|
+
|
|
29
|
+
&.kaitify-color-el-active {
|
|
30
|
+
border-color: @theme;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
& > div {
|
|
34
|
+
display: block;
|
|
35
|
+
width: 16px;
|
|
36
|
+
height: 16px;
|
|
37
|
+
border: 1px solid @border-color;
|
|
38
|
+
border-radius: 1px;
|
|
39
|
+
transition: all 300ms;
|
|
40
|
+
|
|
41
|
+
&:hover {
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
transform: scale(1.2);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&.kaitify-dark {
|
|
50
|
+
.kaitify-colors-header {
|
|
51
|
+
border-bottom-color: @border-color-dark;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.kaitify-colors-content {
|
|
55
|
+
.kaitify-colors-el {
|
|
56
|
+
& > div {
|
|
57
|
+
border-color: @border-color-dark;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
import { useEditor } from '@/hooks'
|
|
3
|
+
import { Icon } from '@/core/icon'
|
|
4
|
+
import Menu from '../../menu'
|
|
5
|
+
import { BlockquoteMenuPropsType } from './props'
|
|
6
|
+
|
|
7
|
+
export default function BlockquoteMenu(props: BlockquoteMenuPropsType) {
|
|
8
|
+
const { state } = useEditor()
|
|
9
|
+
|
|
10
|
+
//是否激活
|
|
11
|
+
const isActive = useMemo(() => {
|
|
12
|
+
return state.editor.value?.commands.allBlockquote?.() ?? false
|
|
13
|
+
}, [state.editor])
|
|
14
|
+
//是否禁用
|
|
15
|
+
const isDisabled = useMemo(() => {
|
|
16
|
+
if (!state.editor.value?.selection.focused()) {
|
|
17
|
+
return true
|
|
18
|
+
}
|
|
19
|
+
return props.disabled
|
|
20
|
+
}, [state.editor, props.disabled])
|
|
21
|
+
|
|
22
|
+
//方法
|
|
23
|
+
const onOperate = () => {
|
|
24
|
+
if (isActive) {
|
|
25
|
+
state.editor.value?.commands.unsetBlockquote?.()
|
|
26
|
+
} else {
|
|
27
|
+
state.editor.value?.commands.setBlockquote?.()
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Menu disabled={isDisabled} active={isActive} onOperate={onOperate} shortcut={props.shortcut}>
|
|
33
|
+
<Icon name='kaitify-icon-quote' />
|
|
34
|
+
</Menu>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
import { Icon } from '@/core/icon'
|
|
3
|
+
import { useEditor } from '@/hooks'
|
|
4
|
+
import Menu from '../../menu'
|
|
5
|
+
import { BoldMenuPropsType } from './props'
|
|
6
|
+
|
|
7
|
+
export default function BoldMenu(props: BoldMenuPropsType) {
|
|
8
|
+
const { state } = useEditor()
|
|
9
|
+
|
|
10
|
+
//是否激活
|
|
11
|
+
const isActive = useMemo(() => {
|
|
12
|
+
return state.editor.value?.commands.isBold?.() ?? false
|
|
13
|
+
}, [state.editor])
|
|
14
|
+
//是否禁用
|
|
15
|
+
const isDisabled = useMemo(() => {
|
|
16
|
+
if (!state.editor.value?.selection.focused()) {
|
|
17
|
+
return true
|
|
18
|
+
}
|
|
19
|
+
if (!state.editor.value.selection.collapsed() && !state.editor.value.getFocusNodesBySelection('text').length) {
|
|
20
|
+
return true
|
|
21
|
+
}
|
|
22
|
+
if (state.editor.value.selection.collapsed() && (!!state.editor.value.commands.getAttachment?.() || !!state.editor.value.commands.getMath?.())) {
|
|
23
|
+
return true
|
|
24
|
+
}
|
|
25
|
+
if (!!state.editor.value.commands.getCodeBlock?.()) {
|
|
26
|
+
return true
|
|
27
|
+
}
|
|
28
|
+
return props.disabled ?? false
|
|
29
|
+
}, [state.editor, props.disabled])
|
|
30
|
+
|
|
31
|
+
//方法
|
|
32
|
+
const onOperate = () => {
|
|
33
|
+
if (isActive) {
|
|
34
|
+
state.editor.value?.commands.unsetBold?.()
|
|
35
|
+
} else {
|
|
36
|
+
state.editor.value?.commands.setBold?.()
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Menu disabled={isDisabled} active={isActive} onOperate={onOperate} shortcut={props.shortcut}>
|
|
42
|
+
<Icon name='kaitify-icon-bold' />
|
|
43
|
+
</Menu>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
import { useEditor } from '@/hooks'
|
|
3
|
+
import { Icon } from '@/core/icon'
|
|
4
|
+
import Menu from '../../menu'
|
|
5
|
+
import { ClearFormatMenuPropsType } from './props'
|
|
6
|
+
|
|
7
|
+
export default function ClearFormatMenu(props: ClearFormatMenuPropsType) {
|
|
8
|
+
const { state } = useEditor()
|
|
9
|
+
|
|
10
|
+
//是否禁用
|
|
11
|
+
const isDisabled = useMemo(() => {
|
|
12
|
+
if (!state.editor.value?.selection.focused()) {
|
|
13
|
+
return true
|
|
14
|
+
}
|
|
15
|
+
return props.disabled
|
|
16
|
+
}, [state.editor, props.disabled])
|
|
17
|
+
|
|
18
|
+
//方法
|
|
19
|
+
const onOperate = () => {
|
|
20
|
+
state.editor.value?.commands.clearFormat?.()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<Menu disabled={isDisabled} active={false} onOperate={onOperate} shortcut={props.shortcut}>
|
|
25
|
+
<Icon name='kaitify-icon-format-clear' />
|
|
26
|
+
</Menu>
|
|
27
|
+
)
|
|
28
|
+
}
|