@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,46 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
import { useEditor } from '@/hooks'
|
|
3
|
+
import { Icon } from '@/core/icon'
|
|
4
|
+
import Menu from '../../menu'
|
|
5
|
+
import { UnderlineMenuPropsType } from './props'
|
|
6
|
+
|
|
7
|
+
export default function UnderlineMenu(props: UnderlineMenuPropsType) {
|
|
8
|
+
const { state } = useEditor()
|
|
9
|
+
|
|
10
|
+
//是否激活
|
|
11
|
+
const isActive = useMemo(() => {
|
|
12
|
+
return state.editor.value?.commands.isUnderline?.() ?? false
|
|
13
|
+
}, [state.editor])
|
|
14
|
+
|
|
15
|
+
//是否禁用
|
|
16
|
+
const isDisabled = useMemo(() => {
|
|
17
|
+
if (!state.editor.value?.selection.focused()) {
|
|
18
|
+
return true
|
|
19
|
+
}
|
|
20
|
+
if (!state.editor.value.selection.collapsed() && !state.editor.value.getFocusNodesBySelection('text').length) {
|
|
21
|
+
return true
|
|
22
|
+
}
|
|
23
|
+
if (state.editor.value.selection.collapsed() && (!!state.editor.value.commands.getAttachment?.() || !!state.editor.value.commands.getMath?.())) {
|
|
24
|
+
return true
|
|
25
|
+
}
|
|
26
|
+
if (!!state.editor.value.commands.getCodeBlock?.()) {
|
|
27
|
+
return true
|
|
28
|
+
}
|
|
29
|
+
return props.disabled ?? false
|
|
30
|
+
}, [state.editor, props.disabled])
|
|
31
|
+
|
|
32
|
+
//方法
|
|
33
|
+
const onOperate = () => {
|
|
34
|
+
if (isActive) {
|
|
35
|
+
state.editor.value?.commands.unsetUnderline?.()
|
|
36
|
+
} else {
|
|
37
|
+
state.editor.value?.commands.setUnderline?.()
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Menu disabled={isDisabled} active={isActive} onOperate={onOperate} shortcut={props.shortcut}>
|
|
43
|
+
<Icon name='kaitify-icon-underline' />
|
|
44
|
+
</Menu>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
import { useEditor } from '@/hooks'
|
|
3
|
+
import { Icon } from '@/core/icon'
|
|
4
|
+
import Menu from '../../menu'
|
|
5
|
+
import { UndoMenuPropsType } from './props'
|
|
6
|
+
|
|
7
|
+
export default function UndoMenu(props: UndoMenuPropsType) {
|
|
8
|
+
const { state } = useEditor()
|
|
9
|
+
|
|
10
|
+
//是否禁用
|
|
11
|
+
const isDisabled = useMemo(() => {
|
|
12
|
+
if (!state.editor.value?.selection.focused()) {
|
|
13
|
+
return true
|
|
14
|
+
}
|
|
15
|
+
if (!state.editor.value.commands.canUndo?.()) {
|
|
16
|
+
return true
|
|
17
|
+
}
|
|
18
|
+
return props.disabled ?? false
|
|
19
|
+
}, [state.editor, props.disabled])
|
|
20
|
+
|
|
21
|
+
//方法
|
|
22
|
+
const onOperate = () => {
|
|
23
|
+
state.editor.value?.commands.undo?.()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Menu disabled={isDisabled} active={false} onOperate={onOperate}>
|
|
28
|
+
<Icon name='kaitify-icon-undo' />
|
|
29
|
+
</Menu>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MenuPropsType } from '@/editor/menu/props'
|
|
2
|
+
|
|
3
|
+
export type UnorderedListMenuPropsType = {
|
|
4
|
+
/**
|
|
5
|
+
* 是否禁用
|
|
6
|
+
*/
|
|
7
|
+
disabled?: boolean
|
|
8
|
+
/**
|
|
9
|
+
* 浮层属性
|
|
10
|
+
*/
|
|
11
|
+
popoverProps?: Omit<NonNullable<MenuPropsType['popoverProps']>, 'onShow' | 'onShowing' | 'onShown' | 'onHide' | 'onHiding' | 'onHidden'>
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.kaitify-unordered-list {
|
|
2
|
+
display: flex;
|
|
3
|
+
justify-content: flex-start;
|
|
4
|
+
flex-wrap: wrap;
|
|
5
|
+
width: 100%;
|
|
6
|
+
padding: @small-padding;
|
|
7
|
+
|
|
8
|
+
.kaitify-unordered-list-item {
|
|
9
|
+
padding: @small-padding;
|
|
10
|
+
|
|
11
|
+
:deep(.kaitify-button) {
|
|
12
|
+
width: 40px;
|
|
13
|
+
padding: 0;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useCallback, useMemo, useRef } from 'react'
|
|
2
|
+
import { UnorderListType } from '@kaitify/core'
|
|
3
|
+
import { useEditor } from '@/hooks'
|
|
4
|
+
import { Button } from '@/core/button'
|
|
5
|
+
import { Icon } from '@/core/icon'
|
|
6
|
+
import { MenuRefType } from '../../props'
|
|
7
|
+
import Menu from '../../menu'
|
|
8
|
+
import { UnorderedListMenuPropsType } from './props'
|
|
9
|
+
import styles from './style.module.less'
|
|
10
|
+
|
|
11
|
+
export default function UnorderedListMenu(props: UnorderedListMenuPropsType) {
|
|
12
|
+
const { state } = useEditor()
|
|
13
|
+
|
|
14
|
+
//菜单组件实例
|
|
15
|
+
const menuRef = useRef<MenuRefType | null>(null)
|
|
16
|
+
//有序列表序标列表
|
|
17
|
+
const listTypes: UnorderListType[] = ['disc', 'square', 'circle']
|
|
18
|
+
//是否禁用
|
|
19
|
+
const isDisabled = useMemo(() => {
|
|
20
|
+
if (!state.editor.value?.selection.focused()) {
|
|
21
|
+
return true
|
|
22
|
+
}
|
|
23
|
+
return props.disabled ?? false
|
|
24
|
+
}, [state.editor, props.disabled])
|
|
25
|
+
|
|
26
|
+
//选项是否激活
|
|
27
|
+
const itemActive = useCallback(
|
|
28
|
+
(item: UnorderListType) => {
|
|
29
|
+
return (
|
|
30
|
+
state.editor.value?.commands.allList?.({
|
|
31
|
+
ordered: false,
|
|
32
|
+
listType: item
|
|
33
|
+
}) ?? false
|
|
34
|
+
)
|
|
35
|
+
},
|
|
36
|
+
[state.editor]
|
|
37
|
+
)
|
|
38
|
+
//菜单是否激活
|
|
39
|
+
const isActive = useMemo(() => {
|
|
40
|
+
return (
|
|
41
|
+
state.editor.value?.commands.allList?.({
|
|
42
|
+
ordered: false
|
|
43
|
+
}) ?? false
|
|
44
|
+
)
|
|
45
|
+
}, [state.editor])
|
|
46
|
+
|
|
47
|
+
//选择选项
|
|
48
|
+
const onSelect = (item: UnorderListType) => {
|
|
49
|
+
if (itemActive(item)) {
|
|
50
|
+
state.editor.value?.commands.unsetList?.({
|
|
51
|
+
ordered: false,
|
|
52
|
+
listType: item
|
|
53
|
+
})
|
|
54
|
+
} else {
|
|
55
|
+
state.editor.value?.commands.setList?.({
|
|
56
|
+
ordered: false,
|
|
57
|
+
listType: item
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
menuRef.current?.hidePopover()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<Menu
|
|
65
|
+
ref={menuRef}
|
|
66
|
+
disabled={isDisabled}
|
|
67
|
+
active={isActive}
|
|
68
|
+
popover
|
|
69
|
+
popoverProps={{ width: props.popoverProps?.width ?? 160, 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 }}
|
|
70
|
+
customPopover={
|
|
71
|
+
<div className={styles['kaitify-unordered-list']}>
|
|
72
|
+
{listTypes.map(item => (
|
|
73
|
+
<div key={item} className={styles['kaitify-unordered-list-item']}>
|
|
74
|
+
<Button large active={itemActive(item)} onClick={() => onSelect(item)}>
|
|
75
|
+
<Icon name={'kaitify-icon-list-' + item} />
|
|
76
|
+
</Button>
|
|
77
|
+
</div>
|
|
78
|
+
))}
|
|
79
|
+
</div>
|
|
80
|
+
}
|
|
81
|
+
>
|
|
82
|
+
<Icon name='kaitify-icon-list-disc' />
|
|
83
|
+
</Menu>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { MenuPropsType } from '@/editor/menu/props'
|
|
2
|
+
|
|
3
|
+
export type VideoMenuPropsType = {
|
|
4
|
+
/**
|
|
5
|
+
* 是否禁用
|
|
6
|
+
*/
|
|
7
|
+
disabled?: boolean
|
|
8
|
+
/**
|
|
9
|
+
* 初始视频宽度
|
|
10
|
+
*/
|
|
11
|
+
width?: string | number
|
|
12
|
+
/**
|
|
13
|
+
* tabs配置
|
|
14
|
+
*/
|
|
15
|
+
tabs?: {
|
|
16
|
+
data: ('remote' | 'upload')[]
|
|
17
|
+
default: 'remote' | 'upload'
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 自定义上传方法
|
|
21
|
+
*/
|
|
22
|
+
customUpload?: (file: File) => string | Promise<string>
|
|
23
|
+
/**
|
|
24
|
+
* 浮层属性
|
|
25
|
+
*/
|
|
26
|
+
popoverProps?: Omit<NonNullable<MenuPropsType['popoverProps']>, 'onShow' | 'onShowing' | 'onShown' | 'onHide' | 'onHiding' | 'onHidden'>
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type VideoControlsMenuPropsType = {
|
|
30
|
+
/**
|
|
31
|
+
* 是否禁用
|
|
32
|
+
*/
|
|
33
|
+
disabled?: boolean
|
|
34
|
+
/**
|
|
35
|
+
* 快捷键设置
|
|
36
|
+
*/
|
|
37
|
+
shortcut?: (e: KeyboardEvent) => boolean
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type VideoMutedMenuPropsType = {
|
|
41
|
+
/**
|
|
42
|
+
* 是否禁用
|
|
43
|
+
*/
|
|
44
|
+
disabled?: boolean
|
|
45
|
+
/**
|
|
46
|
+
* 快捷键设置
|
|
47
|
+
*/
|
|
48
|
+
shortcut?: (e: KeyboardEvent) => boolean
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type VideoLoopMenuPropsType = {
|
|
52
|
+
/**
|
|
53
|
+
* 是否禁用
|
|
54
|
+
*/
|
|
55
|
+
disabled?: boolean
|
|
56
|
+
/**
|
|
57
|
+
* 快捷键设置
|
|
58
|
+
*/
|
|
59
|
+
shortcut?: (e: KeyboardEvent) => boolean
|
|
60
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
.kaitify-video-upload {
|
|
2
|
+
display: block;
|
|
3
|
+
width: 100%;
|
|
4
|
+
|
|
5
|
+
.kaitify-video-upload-wrapper {
|
|
6
|
+
display: flex;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
align-items: center;
|
|
9
|
+
width: 100%;
|
|
10
|
+
height: 80px;
|
|
11
|
+
font-size: 30px;
|
|
12
|
+
position: relative;
|
|
13
|
+
opacity: 0.7;
|
|
14
|
+
transition: all 300ms;
|
|
15
|
+
|
|
16
|
+
input[type='file'] {
|
|
17
|
+
opacity: 0;
|
|
18
|
+
position: absolute;
|
|
19
|
+
left: 0;
|
|
20
|
+
top: 0;
|
|
21
|
+
z-index: 1;
|
|
22
|
+
width: 100%;
|
|
23
|
+
height: 100%;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&:hover {
|
|
27
|
+
opacity: 1;
|
|
28
|
+
|
|
29
|
+
input[type='file'] {
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.kaitify-video-upload-footer {
|
|
36
|
+
display: flex;
|
|
37
|
+
justify-content: flex-start;
|
|
38
|
+
align-items: center;
|
|
39
|
+
width: 100%;
|
|
40
|
+
padding: @padding;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.kaitify-video-remote {
|
|
45
|
+
display: block;
|
|
46
|
+
width: 100%;
|
|
47
|
+
padding: @small-padding @padding;
|
|
48
|
+
|
|
49
|
+
input[type='url'] {
|
|
50
|
+
display: block;
|
|
51
|
+
width: 100%;
|
|
52
|
+
border: none;
|
|
53
|
+
border-bottom: 1px solid @border-color;
|
|
54
|
+
font-size: @font-size;
|
|
55
|
+
font-family: @font-family;
|
|
56
|
+
line-height: @line-height;
|
|
57
|
+
color: @font-color;
|
|
58
|
+
background: transparent;
|
|
59
|
+
padding: @small-padding 0;
|
|
60
|
+
margin-bottom: @margin;
|
|
61
|
+
transition: all 300ms;
|
|
62
|
+
|
|
63
|
+
&:focus {
|
|
64
|
+
border-bottom-color: @theme;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&::placeholder,
|
|
68
|
+
&::-webkit-input-placeholder {
|
|
69
|
+
opacity: 0.5;
|
|
70
|
+
font-family: @font-family;
|
|
71
|
+
color: inherit;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.kaitify-video-remote-footer {
|
|
76
|
+
display: flex;
|
|
77
|
+
justify-content: space-between;
|
|
78
|
+
align-items: center;
|
|
79
|
+
width: 100%;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&.kaitify-dark {
|
|
83
|
+
input[type='url'] {
|
|
84
|
+
border-bottom-color: @border-color-dark;
|
|
85
|
+
color: @font-color-dark;
|
|
86
|
+
|
|
87
|
+
&:focus {
|
|
88
|
+
border-bottom-color: @theme;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
import { useEditor } from '@/hooks'
|
|
3
|
+
import { Icon } from '@/core/icon'
|
|
4
|
+
import Menu from '../../menu'
|
|
5
|
+
import { VideoControlsMenuPropsType } from './props'
|
|
6
|
+
|
|
7
|
+
export default function VideoControlsMenu(props: VideoControlsMenuPropsType) {
|
|
8
|
+
const { state } = useEditor()
|
|
9
|
+
|
|
10
|
+
//是否激活
|
|
11
|
+
const isActive = useMemo(() => {
|
|
12
|
+
const videoNode = state.editor.value?.commands.getVideo?.()
|
|
13
|
+
if (!videoNode) {
|
|
14
|
+
return false
|
|
15
|
+
}
|
|
16
|
+
return videoNode.hasMarks() && videoNode.marks!.hasOwnProperty('controls')
|
|
17
|
+
}, [state.editor])
|
|
18
|
+
//是否禁用
|
|
19
|
+
const isDisabled = useMemo(() => {
|
|
20
|
+
if (!state.editor.value?.commands.getVideo?.()) {
|
|
21
|
+
return true
|
|
22
|
+
}
|
|
23
|
+
return props.disabled ?? false
|
|
24
|
+
}, [state.editor, props.disabled])
|
|
25
|
+
|
|
26
|
+
//方法
|
|
27
|
+
const onOperate = () => {
|
|
28
|
+
if (isActive) {
|
|
29
|
+
state.editor.value?.commands.updateVideo?.({
|
|
30
|
+
controls: false
|
|
31
|
+
})
|
|
32
|
+
} else {
|
|
33
|
+
state.editor.value?.commands.updateVideo?.({
|
|
34
|
+
controls: true
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Menu disabled={isDisabled} active={isActive} onOperate={onOperate} shortcut={props.shortcut}>
|
|
41
|
+
<Icon name='kaitify-icon-controls' />
|
|
42
|
+
</Menu>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
import { useEditor } from '@/hooks'
|
|
3
|
+
import { Icon } from '@/core/icon'
|
|
4
|
+
import Menu from '../../menu'
|
|
5
|
+
import { VideoLoopMenuPropsType } from './props'
|
|
6
|
+
|
|
7
|
+
export default function VideoLoopMenu(props: VideoLoopMenuPropsType) {
|
|
8
|
+
const { state } = useEditor()
|
|
9
|
+
|
|
10
|
+
//是否激活
|
|
11
|
+
const isActive = useMemo(() => {
|
|
12
|
+
const videoNode = state.editor.value?.commands.getVideo?.()
|
|
13
|
+
if (!videoNode) {
|
|
14
|
+
return false
|
|
15
|
+
}
|
|
16
|
+
return videoNode.hasMarks() && videoNode.marks!.hasOwnProperty('loop')
|
|
17
|
+
}, [state.editor])
|
|
18
|
+
//是否禁用
|
|
19
|
+
const isDisabled = useMemo(() => {
|
|
20
|
+
if (!state.editor.value?.selection.focused()) {
|
|
21
|
+
return true
|
|
22
|
+
}
|
|
23
|
+
if (!state.editor.value.commands.getVideo?.()) {
|
|
24
|
+
return true
|
|
25
|
+
}
|
|
26
|
+
return props.disabled ?? false
|
|
27
|
+
}, [state.editor, props.disabled])
|
|
28
|
+
|
|
29
|
+
//方法
|
|
30
|
+
const onOperate = () => {
|
|
31
|
+
if (isActive) {
|
|
32
|
+
state.editor.value?.commands.updateVideo?.({
|
|
33
|
+
loop: false
|
|
34
|
+
})
|
|
35
|
+
} else {
|
|
36
|
+
state.editor.value?.commands.updateVideo?.({
|
|
37
|
+
loop: true
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Menu disabled={isDisabled} active={isActive} onOperate={onOperate} shortcut={props.shortcut}>
|
|
44
|
+
<Icon name='kaitify-icon-loop' />
|
|
45
|
+
</Menu>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
import { useEditor } from '@/hooks'
|
|
3
|
+
import { Icon } from '@/core/icon'
|
|
4
|
+
import Menu from '../../menu'
|
|
5
|
+
import { VideoMutedMenuPropsType } from './props'
|
|
6
|
+
|
|
7
|
+
export default function VideoMutedMenu(props: VideoMutedMenuPropsType) {
|
|
8
|
+
const { state } = useEditor()
|
|
9
|
+
|
|
10
|
+
//是否激活
|
|
11
|
+
const isActive = useMemo(() => {
|
|
12
|
+
const videoNode = state.editor.value?.commands.getVideo?.()
|
|
13
|
+
if (!videoNode) {
|
|
14
|
+
return false
|
|
15
|
+
}
|
|
16
|
+
return videoNode.hasMarks() && videoNode.marks!.hasOwnProperty('muted')
|
|
17
|
+
}, [state.editor])
|
|
18
|
+
|
|
19
|
+
//是否禁用
|
|
20
|
+
const isDisabled = useMemo(() => {
|
|
21
|
+
if (!state.editor.value?.selection.focused()) {
|
|
22
|
+
return true
|
|
23
|
+
}
|
|
24
|
+
if (!state.editor.value.commands.getVideo?.()) {
|
|
25
|
+
return true
|
|
26
|
+
}
|
|
27
|
+
return props.disabled ?? false
|
|
28
|
+
}, [state.editor, props.disabled])
|
|
29
|
+
|
|
30
|
+
//方法
|
|
31
|
+
const onOperate = () => {
|
|
32
|
+
if (isActive) {
|
|
33
|
+
state.editor.value?.commands.updateVideo?.({
|
|
34
|
+
muted: false
|
|
35
|
+
})
|
|
36
|
+
} else {
|
|
37
|
+
state.editor.value?.commands.updateVideo?.({
|
|
38
|
+
muted: true
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Menu disabled={isDisabled} active={isActive} onOperate={onOperate} shortcut={props.shortcut}>
|
|
45
|
+
<Icon name='kaitify-icon-muted' />
|
|
46
|
+
</Menu>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import React, { useMemo, useRef, useState } from 'react'
|
|
2
|
+
import { file as DapFile } from 'dap-util'
|
|
3
|
+
import { useEditor } from '@/hooks'
|
|
4
|
+
import { SetVideoOptionType } from '@kaitify/core'
|
|
5
|
+
import { Tabs, TabsPropsType } from '@/core/tabs'
|
|
6
|
+
import { Checkbox } from '@/core/checkbox'
|
|
7
|
+
import { Button } from '@/core/button'
|
|
8
|
+
import { Icon } from '@/core/icon'
|
|
9
|
+
import { MenuRefType } from '../../props'
|
|
10
|
+
import Menu from '../../menu'
|
|
11
|
+
import { VideoMenuPropsType } from './props'
|
|
12
|
+
import styles from './style.module.less'
|
|
13
|
+
import classNames from 'classnames'
|
|
14
|
+
|
|
15
|
+
export default function VideoMenu({
|
|
16
|
+
tabs = {
|
|
17
|
+
data: ['remote', 'upload'],
|
|
18
|
+
default: 'remote'
|
|
19
|
+
},
|
|
20
|
+
...props
|
|
21
|
+
}: VideoMenuPropsType) {
|
|
22
|
+
const { state, t, dark } = useEditor()
|
|
23
|
+
|
|
24
|
+
//菜单组件实例
|
|
25
|
+
const menuRef = useRef<MenuRefType | null>(null)
|
|
26
|
+
//远程视频数据
|
|
27
|
+
const [remoteData, setRemoteData] = useState<SetVideoOptionType>({
|
|
28
|
+
src: '',
|
|
29
|
+
autoplay: false
|
|
30
|
+
})
|
|
31
|
+
//选项卡数据
|
|
32
|
+
const tabData = useMemo<TabsPropsType['data']>(() => {
|
|
33
|
+
return tabs.data.map(item => {
|
|
34
|
+
return [
|
|
35
|
+
{
|
|
36
|
+
label: t('远程地址'),
|
|
37
|
+
value: 'remote'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
label: t('本地上传'),
|
|
41
|
+
value: 'upload'
|
|
42
|
+
}
|
|
43
|
+
].find(v => v.value == item)!
|
|
44
|
+
})
|
|
45
|
+
}, [tabs])
|
|
46
|
+
//是否禁用
|
|
47
|
+
const isDisabled = useMemo(() => {
|
|
48
|
+
if (!state.editor.value?.selection.focused()) {
|
|
49
|
+
return true
|
|
50
|
+
}
|
|
51
|
+
if (state.editor.value.commands.hasAttachment?.()) {
|
|
52
|
+
return true
|
|
53
|
+
}
|
|
54
|
+
if (state.editor.value.commands.hasMath?.()) {
|
|
55
|
+
return true
|
|
56
|
+
}
|
|
57
|
+
if (state.editor.value.commands.hasCodeBlock?.()) {
|
|
58
|
+
return true
|
|
59
|
+
}
|
|
60
|
+
return props.disabled ?? false
|
|
61
|
+
}, [state.editor, props.disabled])
|
|
62
|
+
|
|
63
|
+
//选择本地视频
|
|
64
|
+
const fileChange = async (e: React.ChangeEvent) => {
|
|
65
|
+
const file = (e.currentTarget as HTMLInputElement).files?.[0]
|
|
66
|
+
if (!file) {
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
const url = typeof props.customUpload == 'function' ? await props.customUpload(file) : await DapFile.dataFileToBase64(file)
|
|
70
|
+
if (!url) {
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
state.editor.value?.commands.setVideo?.({
|
|
74
|
+
src: url,
|
|
75
|
+
width: typeof props.width == 'number' ? `${props.width}px` : props.width,
|
|
76
|
+
autoplay: remoteData.autoplay
|
|
77
|
+
})
|
|
78
|
+
menuRef.current?.hidePopover()
|
|
79
|
+
}
|
|
80
|
+
//插入远程视频
|
|
81
|
+
const insert = async () => {
|
|
82
|
+
if (!remoteData.src) {
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
state.editor.value?.commands.setVideo?.({
|
|
86
|
+
src: remoteData.src,
|
|
87
|
+
width: typeof props.width == 'number' ? `${props.width}px` : props.width,
|
|
88
|
+
autoplay: remoteData.autoplay
|
|
89
|
+
})
|
|
90
|
+
menuRef.current?.hidePopover()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<Menu
|
|
95
|
+
ref={menuRef}
|
|
96
|
+
disabled={isDisabled}
|
|
97
|
+
active={false}
|
|
98
|
+
popover
|
|
99
|
+
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 }}
|
|
100
|
+
customPopover={
|
|
101
|
+
<Tabs defaultValue={tabs.default} data={tabData}>
|
|
102
|
+
{current => (
|
|
103
|
+
<>
|
|
104
|
+
{current === 'remote' && (
|
|
105
|
+
<div
|
|
106
|
+
className={classNames(styles['kaitify-video-remote'], {
|
|
107
|
+
[styles['kaitify-dark']]: dark
|
|
108
|
+
})}
|
|
109
|
+
>
|
|
110
|
+
<input value={remoteData.src} onChange={e => setRemoteData(oldValue => ({ ...oldValue, src: e.target.value }))} placeholder={t('视频地址')} type='url' />
|
|
111
|
+
<div className={styles['kaitify-video-remote-footer']}>
|
|
112
|
+
<Checkbox checked={remoteData.autoplay} onChange={v => setRemoteData(oldValue => ({ ...oldValue, autoplay: v }))} label={t('是否自动播放')} />
|
|
113
|
+
<Button onClick={insert} disabled={!remoteData.src}>
|
|
114
|
+
{t('插入')}
|
|
115
|
+
</Button>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
)}
|
|
119
|
+
{current === 'upload' && (
|
|
120
|
+
<div className={styles['kaitify-video-upload']}>
|
|
121
|
+
<div className={styles['kaitify-video-upload-wrapper']}>
|
|
122
|
+
<input type='file' accept='video/*' onChange={fileChange} />
|
|
123
|
+
<Icon name='kaitify-icon-upload' />
|
|
124
|
+
</div>
|
|
125
|
+
<div className={styles['kaitify-video-upload-footer']}>
|
|
126
|
+
<Checkbox checked={remoteData.autoplay} onChange={v => setRemoteData(oldValue => ({ ...oldValue, autoplay: v }))} label={t('是否自动播放')} />
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
)}
|
|
130
|
+
</>
|
|
131
|
+
)}
|
|
132
|
+
</Tabs>
|
|
133
|
+
}
|
|
134
|
+
>
|
|
135
|
+
<Icon name='kaitify-icon-video' />
|
|
136
|
+
</Menu>
|
|
137
|
+
)
|
|
138
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { KNodeMatchOptionType } from '@/index'
|
|
2
|
+
|
|
3
|
+
export type WrapDownMenuPropsType = {
|
|
4
|
+
/**
|
|
5
|
+
* 是否禁用
|
|
6
|
+
*/
|
|
7
|
+
disabled?: boolean
|
|
8
|
+
/**
|
|
9
|
+
* 指定换行的块节点条件
|
|
10
|
+
*/
|
|
11
|
+
match: KNodeMatchOptionType
|
|
12
|
+
/**
|
|
13
|
+
* 快捷键设置
|
|
14
|
+
*/
|
|
15
|
+
shortcut?: (e: KeyboardEvent) => boolean
|
|
16
|
+
}
|