cosey 0.9.5 → 0.10.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/README.md +1 -1
- package/components/audio-card/audio-card.js +1 -1
- package/components/close/close.js +1 -1
- package/components/col/col.api.d.ts +1 -1
- package/components/context-menu/content.js +1 -1
- package/components/dnd-sort/dnd-sort-item.js +1 -1
- package/components/editor/button-group.d.ts +2 -0
- package/components/editor/button-group.js +20 -0
- package/components/editor/button-select.d.ts +14 -0
- package/components/editor/button-select.js +51 -0
- package/components/editor/button-split.d.ts +25 -0
- package/components/editor/button-split.js +68 -0
- package/components/editor/button.d.ts +19 -0
- package/components/editor/button.js +40 -0
- package/components/editor/contents/content-code-block.d.ts +18 -0
- package/components/editor/contents/content-code-block.js +51 -0
- package/components/editor/contents/content-formula.d.ts +12 -0
- package/components/editor/contents/content-formula.js +48 -0
- package/components/editor/contents/content-formula.style.js +14 -0
- package/components/editor/contents/content-image.d.ts +29 -0
- package/components/editor/contents/content-image.js +89 -0
- package/components/editor/{components/list/list.style.d.ts → contents/content-image.style.d.ts} +1 -1
- package/components/editor/contents/content-image.style.js +20 -0
- package/components/editor/contents/content-link.d.ts +16 -0
- package/components/editor/contents/content-link.js +74 -0
- package/components/editor/contents/content-link.stye.d.ts +4 -0
- package/components/editor/contents/content-link.stye.js +17 -0
- package/components/editor/contents/content-list-item.d.ts +21 -0
- package/components/editor/contents/content-list-item.js +41 -0
- package/components/editor/contents/content-list-item.style.d.ts +4 -0
- package/components/editor/contents/content-list-item.style.js +52 -0
- package/components/editor/contents/content-placeholder.d.ts +2 -0
- package/components/editor/contents/content-placeholder.js +24 -0
- package/components/editor/contents/content-placeholder.style.d.ts +4 -0
- package/components/editor/contents/content-placeholder.style.js +19 -0
- package/components/editor/contents/content-table.d.ts +2 -0
- package/components/editor/contents/content-table.js +133 -0
- package/components/editor/contents/content-table.style.d.ts +4 -0
- package/components/editor/contents/content-table.style.js +21 -0
- package/components/editor/contents/content-video.d.ts +26 -0
- package/components/editor/contents/content-video.js +73 -0
- package/components/editor/contents/content-video.style.d.ts +4 -0
- package/components/editor/contents/content-video.style.js +20 -0
- package/components/editor/contents/resize.d.ts +37 -0
- package/components/editor/contents/resize.js +133 -0
- package/components/editor/{components/resize → contents}/resize.style.d.ts +1 -1
- package/components/editor/{components/resize → contents}/resize.style.js +14 -34
- package/components/editor/contents/upload.d.ts +17 -0
- package/components/editor/contents/upload.js +80 -0
- package/components/editor/contents/upload.style.d.ts +4 -0
- package/components/editor/contents/upload.style.js +38 -0
- package/components/editor/contents/widget-popover.d.ts +389 -0
- package/components/editor/contents/widget-popover.js +36 -0
- package/components/editor/contents/widget-popover.style.d.ts +4 -0
- package/components/editor/contents/widget-popover.style.js +15 -0
- package/components/editor/editor.api.d.ts +14 -6
- package/components/editor/editor.api.js +10 -6
- package/components/editor/editor.d.ts +15 -8
- package/components/editor/editor.js +178 -76
- package/components/editor/editor.style.d.ts +5 -1
- package/components/editor/editor.style.js +121 -253
- package/components/editor/{components/color-picker/color-picker.js → formats/color-picker.api.js} +3 -3
- package/components/editor/formats/color-picker.d.ts +20 -0
- package/components/editor/formats/color-picker.js +154 -0
- package/components/editor/{components/color-picker → formats}/color-picker.style.d.ts +1 -1
- package/components/editor/{components/color-picker → formats}/color-picker.style.js +1 -1
- package/components/editor/formats/format-align.d.ts +22 -0
- package/components/editor/formats/format-align.js +38 -0
- package/components/editor/formats/format-background.d.ts +2 -0
- package/components/editor/formats/format-background.js +60 -0
- package/components/editor/formats/format-block-quote.d.ts +2 -0
- package/components/editor/formats/format-block-quote.js +27 -0
- package/components/editor/formats/format-clear.d.ts +2 -0
- package/components/editor/formats/format-clear.js +25 -0
- package/components/editor/formats/format-code-block.d.ts +2 -0
- package/components/editor/formats/format-code-block.js +27 -0
- package/components/editor/formats/format-color.d.ts +2 -0
- package/components/editor/formats/format-color.js +59 -0
- package/components/editor/formats/format-font.d.ts +2 -0
- package/components/editor/formats/format-font.js +46 -0
- package/components/editor/formats/format-formula.d.ts +2 -0
- package/components/editor/formats/format-formula.js +133 -0
- package/components/editor/formats/format-heading.d.ts +2 -0
- package/components/editor/formats/format-heading.js +52 -0
- package/components/editor/formats/format-image.d.ts +2 -0
- package/components/editor/formats/format-image.js +140 -0
- package/components/editor/formats/format-indent.d.ts +20 -0
- package/components/editor/formats/format-indent.js +35 -0
- package/components/editor/formats/format-link.d.ts +2 -0
- package/components/editor/formats/format-link.js +114 -0
- package/components/editor/formats/format-list.d.ts +22 -0
- package/components/editor/formats/format-list.js +39 -0
- package/components/editor/formats/format-mark.d.ts +20 -0
- package/components/editor/formats/format-mark.js +38 -0
- package/components/editor/formats/format-size-delta.d.ts +24 -0
- package/components/editor/formats/format-size-delta.js +43 -0
- package/components/editor/formats/format-size.d.ts +2 -0
- package/components/editor/formats/format-size.js +51 -0
- package/components/editor/formats/format-source.d.ts +2 -0
- package/components/editor/formats/format-source.js +69 -0
- package/components/editor/formats/format-table.d.ts +2 -0
- package/components/editor/formats/format-table.js +85 -0
- package/components/editor/formats/format-table.style.d.ts +4 -0
- package/components/editor/{components/toolbar/formats/table.style.js → formats/format-table.style.js} +2 -2
- package/components/editor/formats/format-video.d.ts +2 -0
- package/components/editor/formats/format-video.js +117 -0
- package/components/editor/formats/picker.d.ts +45 -0
- package/components/editor/formats/picker.js +91 -0
- package/components/editor/{components/picker → formats}/picker.style.d.ts +1 -1
- package/components/editor/{components/picker → formats}/picker.style.js +1 -1
- package/components/editor/formats/select-list.d.ts +28 -0
- package/components/editor/formats/select-list.js +47 -0
- package/components/editor/formats/select-list.style.d.ts +4 -0
- package/components/editor/{components/list/list.style.js → formats/select-list.style.js} +2 -2
- package/components/editor/formats/select.d.ts +32 -0
- package/components/editor/formats/select.js +61 -0
- package/components/editor/hooks/useBlockValueActive.d.ts +1 -0
- package/components/editor/hooks/useBlockValueActive.js +21 -0
- package/components/editor/hooks/useFocus.d.ts +5 -0
- package/components/editor/hooks/useFocus.js +18 -0
- package/components/editor/{components/color-picker → hooks}/useHistoryColor.js +1 -1
- package/components/editor/hooks/useMarkActive.d.ts +1 -0
- package/components/editor/hooks/useMarkActive.js +13 -0
- package/components/editor/hooks/useMarkValue.d.ts +1 -0
- package/components/editor/hooks/useMarkValue.js +21 -0
- package/components/editor/index.d.ts +25 -13
- package/components/editor/index.js +3 -21
- package/components/editor/plugins/align.d.ts +8 -0
- package/components/editor/plugins/align.js +13 -0
- package/components/editor/plugins/background.d.ts +7 -0
- package/components/editor/plugins/background.js +19 -0
- package/components/editor/plugins/block-quote.d.ts +8 -0
- package/components/editor/plugins/block-quote.js +34 -0
- package/components/editor/plugins/clear.d.ts +7 -0
- package/components/editor/plugins/clear.js +53 -0
- package/components/editor/plugins/code-block.d.ts +13 -0
- package/components/editor/plugins/code-block.js +356 -0
- package/components/editor/plugins/color.d.ts +7 -0
- package/components/editor/plugins/color.js +21 -0
- package/components/editor/plugins/font.d.ts +7 -0
- package/components/editor/plugins/font.js +17 -0
- package/components/editor/plugins/formula.d.ts +11 -0
- package/components/editor/{components/toolbar/formats → plugins}/formula.js +50 -1
- package/components/editor/plugins/heading.d.ts +9 -0
- package/components/editor/plugins/heading.js +70 -0
- package/components/editor/plugins/html.d.ts +7 -0
- package/components/editor/plugins/html.js +30 -0
- package/components/editor/plugins/image.d.ts +8 -0
- package/components/editor/plugins/image.js +63 -0
- package/components/editor/plugins/indent.d.ts +7 -0
- package/components/editor/plugins/indent.js +47 -0
- package/components/editor/plugins/index.d.ts +2 -0
- package/components/editor/plugins/index.js +50 -0
- package/components/editor/plugins/keyboard.d.ts +41 -0
- package/components/editor/plugins/keyboard.js +120 -0
- package/components/editor/plugins/link.d.ts +8 -0
- package/components/editor/plugins/link.js +56 -0
- package/components/editor/plugins/list/deserialize.d.ts +3 -0
- package/components/editor/plugins/list/deserialize.js +106 -0
- package/components/editor/plugins/list/format.d.ts +3 -0
- package/components/editor/plugins/list/format.js +155 -0
- package/components/editor/plugins/list/indent.d.ts +2 -0
- package/components/editor/plugins/list/indent.js +38 -0
- package/components/editor/plugins/list/index.d.ts +10 -0
- package/components/editor/plugins/list/index.js +61 -0
- package/components/editor/plugins/list/insert-break.d.ts +2 -0
- package/components/editor/plugins/list/insert-break.js +19 -0
- package/components/editor/plugins/list/normalize.d.ts +3 -0
- package/components/editor/plugins/list/normalize.js +168 -0
- package/components/editor/plugins/list/serialize.d.ts +3 -0
- package/components/editor/plugins/list/serialize.js +63 -0
- package/components/editor/plugins/list/utils.d.ts +6 -0
- package/components/editor/plugins/list/utils.js +24 -0
- package/components/editor/plugins/mark.d.ts +7 -0
- package/components/editor/plugins/mark.js +27 -0
- package/components/editor/plugins/render.d.ts +11 -0
- package/components/editor/plugins/render.js +54 -0
- package/components/editor/plugins/serialize.d.ts +10 -0
- package/components/editor/plugins/serialize.js +342 -0
- package/components/editor/plugins/size.d.ts +8 -0
- package/components/editor/plugins/size.js +47 -0
- package/components/editor/plugins/table.d.ts +21 -0
- package/components/editor/plugins/table.js +702 -0
- package/components/editor/plugins/video.d.ts +8 -0
- package/components/editor/plugins/video.js +40 -0
- package/components/editor/toolbar.d.ts +2 -0
- package/components/editor/toolbar.js +20 -0
- package/components/editor/types.d.ts +194 -0
- package/components/editor/types.js +55 -0
- package/components/editor/usePopoverContainer.d.ts +8 -0
- package/components/editor/usePopoverContainer.js +31 -0
- package/components/editor/utils.d.ts +77 -0
- package/components/editor/utils.js +165 -0
- package/components/field/components/checkbox-group/checkbox-group.vue.js +1 -1
- package/components/field/components/editor/editor.d.ts +16 -0
- package/components/field/components/editor/editor.vue.d.ts +4 -0
- package/components/field/components/editor/editor.vue.js +21 -0
- package/components/field/components/password/password.vue.js +1 -1
- package/components/field/components/select/select.vue.js +1 -1
- package/components/field/field.api.d.ts +3 -0
- package/components/field/field.api.js +18 -16
- package/components/file-card/file-card.js +1 -1
- package/components/form/form-item.vue.js +2 -2
- package/components/form/form.api.d.ts +3 -3
- package/components/form/form.api.js +1 -1
- package/components/form/form.d.ts +6 -6
- package/components/form/index.d.ts +17 -17
- package/components/form/useBubbleTemplate.js +1 -1
- package/components/form-dialog/form-dialog.api.js +1 -1
- package/components/form-dialog/form-dialog.d.ts +5 -5
- package/components/form-drawer/form-drawer.d.ts +5 -5
- package/components/form-drawer/index.d.ts +15 -15
- package/components/form-group/form-group.js +1 -1
- package/components/form-list/index.d.ts +5 -5
- package/components/form-query/form-query.d.ts +5 -5
- package/components/form-query/form-query.js +1 -1
- package/components/form-query/index.d.ts +15 -15
- package/components/highlight/highlight.api.d.ts +30 -12
- package/components/highlight/highlight.api.js +3 -19
- package/components/highlight/highlight.d.ts +7 -3
- package/components/highlight/highlight.js +6 -6
- package/components/highlight/highlight.style.d.ts +1 -0
- package/components/highlight/highlight.style.js +288 -54
- package/components/highlight/index.d.ts +15 -6
- package/components/highlight/index.js +1 -1
- package/components/icon/icon.api.d.ts +11 -0
- package/components/icon/icon.api.js +10 -0
- package/components/icon/icon.d.ts +16 -5
- package/components/icon/icon.js +59 -0
- package/components/icon/icon.style.d.ts +4 -0
- package/components/icon/{style/index.js → icon.style.js} +1 -1
- package/components/icon/index.d.ts +24 -7
- package/components/icon/index.js +2 -1
- package/components/iconify-icon/iconify-icon.api.d.ts +15 -0
- package/components/iconify-icon/iconify-icon.api.js +20 -0
- package/components/iconify-icon/iconify-icon.d.ts +21 -6
- package/components/iconify-icon/iconify-icon.js +22 -8
- package/components/iconify-icon/index.d.ts +37 -4
- package/components/iconify-icon/index.js +2 -2
- package/components/index.d.ts +1 -0
- package/components/index.js +5 -4
- package/components/input-number-range/index.d.ts +39 -30
- package/components/input-number-range/input-number-range.api.d.ts +10 -10
- package/components/input-number-range/input-number-range.d.ts +23 -20
- package/components/input-number-range/input-number-range.js +1 -1
- package/components/snug-menu/snug-menu-item.vue.js +2 -2
- package/components/stack-dialog/index.d.ts +3 -3
- package/components/stack-dialog/stack-dialog.d.ts +1 -1
- package/components/svg-icon/index.d.ts +16 -4
- package/components/svg-icon/index.js +2 -1
- package/components/svg-icon/svg-icon.api.d.ts +7 -0
- package/components/svg-icon/svg-icon.api.js +7 -0
- package/components/svg-icon/svg-icon.d.ts +10 -3
- package/components/svg-icon/svg-icon.js +18 -0
- package/components/table/index.d.ts +12 -12
- package/components/table/table-column/table-column.js +1 -1
- package/components/table/table-export/table-export.d.ts +5 -5
- package/components/table/table-query/table-query.d.ts +5 -5
- package/components/table/table.d.ts +5 -5
- package/components/table/table.js +1 -1
- package/components/table/table.vue.d.ts +7 -7
- package/components/table/table.vue.js +5 -5
- package/components/table-action/item.js +1 -1
- package/components/toggle/toggle.js +1 -1
- package/components/upload/index.d.ts +3 -4
- package/components/upload/index.js +0 -1
- package/components/upload/upload-item.js +1 -1
- package/components/upload/upload.api.d.ts +2 -2
- package/components/upload/upload.d.ts +2 -2
- package/components/upload/upload.js +4 -4
- package/components/video-card/video-card.js +1 -1
- package/config/root-config-provider.js +2 -2
- package/{components/upload-context.d.ts → config/upload.d.ts} +2 -2
- package/{components/upload-context.js → config/upload.js} +3 -3
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +2 -0
- package/hooks/useObjectUrl.d.ts +2 -0
- package/hooks/useObjectUrl.js +27 -0
- package/hooks/useSingleUpload.d.ts +15 -0
- package/hooks/useSingleUpload.js +64 -0
- package/layout/layout-menu/style/index.js +1 -1
- package/locale/lang/ar.d.ts +2 -0
- package/locale/lang/ar.js +3 -1
- package/locale/lang/en.d.ts +2 -0
- package/locale/lang/en.js +3 -1
- package/locale/lang/zh-cn.d.ts +2 -0
- package/locale/lang/zh-cn.js +3 -1
- package/package.json +11 -7
- package/utils/array.d.ts +1 -1
- package/utils/browser.d.ts +1 -0
- package/utils/browser.js +3 -2
- package/utils/file.d.ts +5 -0
- package/utils/file.js +24 -1
- package/utils/index.js +2 -2
- package/utils/url.d.ts +4 -0
- package/utils/url.js +10 -0
- package/components/editor/components/button-group.vue.d.ts +0 -12
- package/components/editor/components/button-group.vue.js +0 -19
- package/components/editor/components/button.vue.d.ts +0 -17
- package/components/editor/components/button.vue.js +0 -35
- package/components/editor/components/color-picker/color-picker.vue.d.ts +0 -23
- package/components/editor/components/color-picker/color-picker.vue.js +0 -181
- package/components/editor/components/list/list.d.ts +0 -6
- package/components/editor/components/list/list.vue.d.ts +0 -11
- package/components/editor/components/list/list.vue.js +0 -51
- package/components/editor/components/picker/picker.vue.d.ts +0 -25
- package/components/editor/components/picker/picker.vue.js +0 -95
- package/components/editor/components/resize/resize.d.ts +0 -23
- package/components/editor/components/resize/resize.js +0 -88
- package/components/editor/components/resize/resize.vue.d.ts +0 -2
- package/components/editor/components/resize/resize.vue.js +0 -204
- package/components/editor/components/select-button.vue.d.ts +0 -15
- package/components/editor/components/select-button.vue.js +0 -46
- package/components/editor/components/select.vue.d.ts +0 -14
- package/components/editor/components/select.vue.js +0 -67
- package/components/editor/components/split-button.vue.d.ts +0 -22
- package/components/editor/components/split-button.vue.js +0 -69
- package/components/editor/components/table-toolbar/table-toolbar.style.d.ts +0 -4
- package/components/editor/components/table-toolbar/table-toolbar.style.js +0 -22
- package/components/editor/components/table-toolbar/table-toolbar.vue.d.ts +0 -2
- package/components/editor/components/table-toolbar/table-toolbar.vue.js +0 -182
- package/components/editor/components/toolbar/formats/align.vue.d.ts +0 -5
- package/components/editor/components/toolbar/formats/align.vue.js +0 -52
- package/components/editor/components/toolbar/formats/background.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/background.vue.js +0 -70
- package/components/editor/components/toolbar/formats/blockquote.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/blockquote.vue.js +0 -39
- package/components/editor/components/toolbar/formats/bold.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/bold.vue.js +0 -39
- package/components/editor/components/toolbar/formats/clean.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/clean.vue.js +0 -26
- package/components/editor/components/toolbar/formats/code-block.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/code-block.vue.js +0 -39
- package/components/editor/components/toolbar/formats/code.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/code.vue.js +0 -39
- package/components/editor/components/toolbar/formats/color.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/color.vue.js +0 -69
- package/components/editor/components/toolbar/formats/font.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/font.vue.js +0 -59
- package/components/editor/components/toolbar/formats/formula.d.ts +0 -4
- package/components/editor/components/toolbar/formats/formula.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/formula.vue.js +0 -154
- package/components/editor/components/toolbar/formats/header.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/header.vue.js +0 -68
- package/components/editor/components/toolbar/formats/image.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/image.vue.js +0 -26
- package/components/editor/components/toolbar/formats/indent.vue.d.ts +0 -5
- package/components/editor/components/toolbar/formats/indent.vue.js +0 -36
- package/components/editor/components/toolbar/formats/italic.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/italic.vue.js +0 -39
- package/components/editor/components/toolbar/formats/link.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/link.vue.js +0 -218
- package/components/editor/components/toolbar/formats/list.vue.d.ts +0 -5
- package/components/editor/components/toolbar/formats/list.vue.js +0 -50
- package/components/editor/components/toolbar/formats/script.vue.d.ts +0 -5
- package/components/editor/components/toolbar/formats/script.vue.js +0 -50
- package/components/editor/components/toolbar/formats/size-delta.vue.d.ts +0 -5
- package/components/editor/components/toolbar/formats/size-delta.vue.js +0 -79
- package/components/editor/components/toolbar/formats/size.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/size.vue.js +0 -56
- package/components/editor/components/toolbar/formats/source.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/source.vue.js +0 -78
- package/components/editor/components/toolbar/formats/strike.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/strike.vue.js +0 -39
- package/components/editor/components/toolbar/formats/strikethrough.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/strikethrough.vue.js +0 -39
- package/components/editor/components/toolbar/formats/table.style.d.ts +0 -4
- package/components/editor/components/toolbar/formats/table.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/table.vue.js +0 -100
- package/components/editor/components/toolbar/formats/underline.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/underline.vue.js +0 -39
- package/components/editor/components/toolbar/formats/video.vue.d.ts +0 -2
- package/components/editor/components/toolbar/formats/video.vue.js +0 -123
- package/components/editor/components/toolbar/toolbar.d.ts +0 -36
- package/components/editor/components/toolbar/toolbar.js +0 -137
- package/components/editor/components/toolbar/toolbar.vue.d.ts +0 -3
- package/components/editor/components/toolbar/toolbar.vue.js +0 -130
- package/components/editor/components/toolbar/toolbarContext.d.ts +0 -8
- package/components/editor/components/toolbar/toolbarContext.js +0 -3
- package/components/editor/formats/align.d.ts +0 -2
- package/components/editor/formats/align.js +0 -6
- package/components/editor/formats/font.d.ts +0 -7
- package/components/editor/formats/font.js +0 -36
- package/components/editor/formats/formula.d.ts +0 -9
- package/components/editor/formats/formula.js +0 -29
- package/components/editor/formats/image.d.ts +0 -13
- package/components/editor/formats/image.js +0 -46
- package/components/editor/formats/indent.d.ts +0 -10
- package/components/editor/formats/indent.js +0 -37
- package/components/editor/formats/kbd.d.ts +0 -7
- package/components/editor/formats/kbd.js +0 -13
- package/components/editor/formats/link.d.ts +0 -28
- package/components/editor/formats/link.js +0 -51
- package/components/editor/formats/list.d.ts +0 -13
- package/components/editor/formats/list.js +0 -57
- package/components/editor/formats/size.d.ts +0 -3
- package/components/editor/formats/size.js +0 -9
- package/components/editor/formats/video.d.ts +0 -16
- package/components/editor/formats/video.js +0 -44
- package/components/editor/modules/custom-list.d.ts +0 -5
- package/components/editor/modules/custom-list.js +0 -23
- package/components/editor/modules/image-uploader/formats/image-loading.d.ts +0 -16
- package/components/editor/modules/image-uploader/formats/image-loading.js +0 -31
- package/components/editor/modules/image-uploader/formats/image-loading.style.d.ts +0 -2
- package/components/editor/modules/image-uploader/formats/image-loading.style.js +0 -46
- package/components/editor/modules/image-uploader/image-uploader.d.ts +0 -18
- package/components/editor/modules/image-uploader/image-uploader.js +0 -134
- package/components/editor/modules/syntax/index.d.ts +0 -2
- package/components/editor/modules/syntax/index.js +0 -1
- package/components/editor/modules/syntax/syntaxOptions.d.ts +0 -8
- package/components/editor/modules/syntax/syntaxOptions.js +0 -23
- package/components/editor/quill.d.ts +0 -1
- package/components/editor/quill.js +0 -33
- package/components/editor/quillContext.d.ts +0 -6
- package/components/editor/quillContext.js +0 -3
- package/components/icon/icon.vue.d.ts +0 -13
- package/components/icon/icon.vue.js +0 -76
- package/components/iconify-icon/iconify-icon.vue.d.ts +0 -3
- package/components/iconify-icon/iconify-icon.vue.js +0 -38
- package/components/svg-icon/svg-icon.vue.d.ts +0 -3
- package/components/svg-icon/svg-icon.vue.js +0 -29
- /package/components/{icon/style/index.d.ts → editor/contents/content-formula.style.d.ts} +0 -0
- /package/components/editor/{components/color-picker/color-picker.d.ts → formats/color-picker.api.d.ts} +0 -0
- /package/components/editor/{components/picker/picker.d.ts → formats/picker.api.d.ts} +0 -0
- /package/components/editor/{components/picker/picker.js → formats/picker.api.js} +0 -0
- /package/components/editor/{components/color-picker → hooks}/useHistoryColor.d.ts +0 -0
- /package/components/{editor/components/list/list.js → field/components/editor/editor.js} +0 -0
|
@@ -0,0 +1,702 @@
|
|
|
1
|
+
import { h } from 'vue';
|
|
2
|
+
import { Range, Editor, Point, Path, Element, Node } from 'slate-vue3/core';
|
|
3
|
+
import { isBlockElement, isPointAtLastLine, isPointAtFirstLine, isEdgesEqual } from '../utils.js';
|
|
4
|
+
import { Hotkeys } from './keyboard.js';
|
|
5
|
+
import stdin_default from '../contents/content-table.js';
|
|
6
|
+
import { DOMEditor } from 'slate-vue3/dom';
|
|
7
|
+
import { useInheritRef } from 'slate-vue3';
|
|
8
|
+
|
|
9
|
+
function isTable(node) {
|
|
10
|
+
return Element.isElementType(node, "table");
|
|
11
|
+
}
|
|
12
|
+
function isTableHead(node) {
|
|
13
|
+
return Element.isElementType(node, "table-head");
|
|
14
|
+
}
|
|
15
|
+
function isTableBody(node) {
|
|
16
|
+
return Element.isElementType(node, "table-body");
|
|
17
|
+
}
|
|
18
|
+
function isTableRow(node) {
|
|
19
|
+
return Element.isElementType(node, "table-row");
|
|
20
|
+
}
|
|
21
|
+
function isTableCell(node) {
|
|
22
|
+
return Element.isElementType(node, "table-cell");
|
|
23
|
+
}
|
|
24
|
+
function createTableCell() {
|
|
25
|
+
return {
|
|
26
|
+
type: "table-cell",
|
|
27
|
+
children: [{ text: "" }]
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function createTableRow(cellCount) {
|
|
31
|
+
return {
|
|
32
|
+
type: "table-row",
|
|
33
|
+
children: Array(cellCount).fill(0).map(createTableCell)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function insertTable(editor, rowCount, columnCount) {
|
|
37
|
+
if (!editor.selection) return;
|
|
38
|
+
const generator = editor.nodes({
|
|
39
|
+
at: editor.selection,
|
|
40
|
+
mode: "lowest",
|
|
41
|
+
match(n, path) {
|
|
42
|
+
return isBlockElement(editor, n) && isEdgesEqual(editor.edges(path), editor.edges(editor.selection));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const { done, value } = generator.next();
|
|
46
|
+
const shouldRemoveNode = !done;
|
|
47
|
+
const table = {
|
|
48
|
+
type: "table",
|
|
49
|
+
children: [
|
|
50
|
+
{
|
|
51
|
+
type: "table-body",
|
|
52
|
+
children: Array(rowCount).fill(0).map(() => createTableRow(columnCount))
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
};
|
|
56
|
+
const nodes = [table];
|
|
57
|
+
const after = editor.after(editor.selection);
|
|
58
|
+
if (!after) {
|
|
59
|
+
nodes.push({
|
|
60
|
+
type: "paragraph",
|
|
61
|
+
children: [{ text: "" }]
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
editor.insertNodes(nodes);
|
|
65
|
+
if (shouldRemoveNode) {
|
|
66
|
+
editor.removeNodes({
|
|
67
|
+
at: value[1]
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function insertRow(editor, _tablePath, cellPath, isNext) {
|
|
72
|
+
const rowPath = Path.parent(cellPath);
|
|
73
|
+
const rowNode = editor.node(rowPath)[0];
|
|
74
|
+
const columns = rowNode.children.length;
|
|
75
|
+
editor.insertNodes(createTableRow(columns), {
|
|
76
|
+
at: isNext ? Path.next(rowPath) : rowPath
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function insertRowAbove(editor, tablePath, cellPath) {
|
|
80
|
+
insertRow(editor, tablePath, cellPath);
|
|
81
|
+
}
|
|
82
|
+
function insertRowBelow(editor, tablePath, cellPath) {
|
|
83
|
+
insertRow(editor, tablePath, cellPath, true);
|
|
84
|
+
}
|
|
85
|
+
function insertColumn(editor, tablePath, cellPath, isNext) {
|
|
86
|
+
const tableNode = editor.node(tablePath)[0];
|
|
87
|
+
const bodyIndex = tableNode.children.findIndex(isTableBody);
|
|
88
|
+
const headIndex = tableNode.children.findIndex(isTableHead);
|
|
89
|
+
const cellIndex = cellPath[cellPath.length - 1] + (isNext ? 1 : 0);
|
|
90
|
+
function insertNodes(node) {
|
|
91
|
+
node.children.forEach((row) => {
|
|
92
|
+
const rowPath = DOMEditor.findPath(editor, row);
|
|
93
|
+
editor.insertNodes(createTableCell(), {
|
|
94
|
+
at: [...rowPath, cellIndex]
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (bodyIndex !== -1) {
|
|
99
|
+
const bodyPath = [...tablePath, bodyIndex];
|
|
100
|
+
const bodyNode = editor.node(bodyPath)[0];
|
|
101
|
+
insertNodes(bodyNode);
|
|
102
|
+
}
|
|
103
|
+
if (headIndex !== -1) {
|
|
104
|
+
const headPath = [...tablePath, headIndex];
|
|
105
|
+
const headNode = editor.node(headPath)[0];
|
|
106
|
+
insertNodes(headNode);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function insertColumnLeft(editor, tablePath, cellPath) {
|
|
110
|
+
insertColumn(editor, tablePath, cellPath);
|
|
111
|
+
}
|
|
112
|
+
function insertColumnRight(editor, tablePath, cellPath) {
|
|
113
|
+
insertColumn(editor, tablePath, cellPath, true);
|
|
114
|
+
}
|
|
115
|
+
function deleteRow(editor, tablePath, cellPath) {
|
|
116
|
+
const rowPath = Path.parent(cellPath);
|
|
117
|
+
editor.removeNodes({
|
|
118
|
+
at: rowPath
|
|
119
|
+
});
|
|
120
|
+
const tableNode = editor.node(tablePath)[0];
|
|
121
|
+
const bodyIndex = tableNode.children.findIndex(isTableBody);
|
|
122
|
+
if (bodyIndex !== -1) {
|
|
123
|
+
const bodyPath = [...tablePath, bodyIndex];
|
|
124
|
+
const bodyNode = editor.node(bodyPath)[0];
|
|
125
|
+
if (!bodyNode.children.find(isTableRow)) {
|
|
126
|
+
editor.removeNodes({
|
|
127
|
+
at: bodyPath
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const headIndex = tableNode.children.findIndex(isTableHead);
|
|
132
|
+
if (headIndex !== -1) {
|
|
133
|
+
const headPath = [...tablePath, headIndex];
|
|
134
|
+
const headNode = editor.node(headPath)[0];
|
|
135
|
+
if (!headNode.children.find(isTableRow)) {
|
|
136
|
+
editor.removeNodes({
|
|
137
|
+
at: headPath
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (!tableNode.children.find((node) => isTableHead(node) || isTableBody(node))) {
|
|
142
|
+
editor.removeNodes({
|
|
143
|
+
at: tablePath
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function deleteColumn(editor, tablePath, cellPath) {
|
|
148
|
+
const tableNode = editor.node(tablePath)[0];
|
|
149
|
+
const rowPath = Path.parent(cellPath);
|
|
150
|
+
const rowNode = editor.node(rowPath)[0];
|
|
151
|
+
function removeNodes(node) {
|
|
152
|
+
const cellIndex = cellPath[cellPath.length - 1];
|
|
153
|
+
node.children.forEach((row) => {
|
|
154
|
+
const rowPath2 = DOMEditor.findPath(editor, row);
|
|
155
|
+
editor.removeNodes({
|
|
156
|
+
at: [...rowPath2, cellIndex]
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
if (rowNode.children.length === 1) {
|
|
161
|
+
deleteTable(editor, tablePath);
|
|
162
|
+
} else {
|
|
163
|
+
const bodyIndex = tableNode.children.findIndex(isTableBody);
|
|
164
|
+
if (bodyIndex !== -1) {
|
|
165
|
+
const bodyPath = [...tablePath, bodyIndex];
|
|
166
|
+
const bodyNode = editor.node(bodyPath)[0];
|
|
167
|
+
removeNodes(bodyNode);
|
|
168
|
+
}
|
|
169
|
+
const headIndex = tableNode.children.findIndex(isTableHead);
|
|
170
|
+
if (headIndex !== -1) {
|
|
171
|
+
const headPath = [...tablePath, headIndex];
|
|
172
|
+
const headNode = editor.node(headPath)[0];
|
|
173
|
+
removeNodes(headNode);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function deleteTable(editor, tablePath) {
|
|
178
|
+
editor.removeNodes({
|
|
179
|
+
at: tablePath
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function moveToHead(editor, tablePath, cellPath) {
|
|
183
|
+
const rowPath = Path.parent(cellPath);
|
|
184
|
+
const rowParentPath = Path.parent(rowPath);
|
|
185
|
+
const rowParentNode = editor.node(rowParentPath)[0];
|
|
186
|
+
if (rowParentNode.type === "table-head") return;
|
|
187
|
+
const tableNode = editor.node(tablePath)[0];
|
|
188
|
+
editor.withoutNormalizing(() => {
|
|
189
|
+
const rowPathRef = editor.pathRef(rowPath);
|
|
190
|
+
let headIndex = tableNode.children.findIndex(isTableHead);
|
|
191
|
+
if (headIndex === -1) {
|
|
192
|
+
editor.insertNodes(
|
|
193
|
+
{
|
|
194
|
+
type: "table-head",
|
|
195
|
+
children: []
|
|
196
|
+
},
|
|
197
|
+
{ at: rowParentPath }
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
headIndex = tableNode.children.findIndex(isTableHead);
|
|
201
|
+
const headPath = [...tablePath, headIndex];
|
|
202
|
+
const headNode = editor.node(headPath)[0];
|
|
203
|
+
const lastRowIndex = headNode.children.length;
|
|
204
|
+
editor.moveNodes({
|
|
205
|
+
at: rowPathRef.unref(),
|
|
206
|
+
to: [...headPath, lastRowIndex]
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
const bodyIndex = tableNode.children.findIndex(isTableBody);
|
|
210
|
+
const bodyPath = [...tablePath, bodyIndex];
|
|
211
|
+
const bodyNode = editor.node(bodyPath)[0];
|
|
212
|
+
if (!bodyNode.children.find(isTableRow)) {
|
|
213
|
+
editor.removeNodes({
|
|
214
|
+
at: bodyPath
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function moveToBody(editor, tablePath, cellPath) {
|
|
219
|
+
const rowPath = Path.parent(cellPath);
|
|
220
|
+
const rowParentPath = Path.parent(rowPath);
|
|
221
|
+
const rowParentNode = editor.node(rowParentPath)[0];
|
|
222
|
+
if (rowParentNode.type === "table-body") return;
|
|
223
|
+
const tableNode = editor.node(tablePath)[0];
|
|
224
|
+
editor.withoutNormalizing(() => {
|
|
225
|
+
const rowPathRef = editor.pathRef(rowPath);
|
|
226
|
+
let bodyIndex = tableNode.children.findIndex(isTableBody);
|
|
227
|
+
if (bodyIndex === -1) {
|
|
228
|
+
editor.insertNodes(
|
|
229
|
+
{
|
|
230
|
+
type: "table-body",
|
|
231
|
+
children: []
|
|
232
|
+
},
|
|
233
|
+
{ at: Path.next(rowParentPath) }
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
bodyIndex = tableNode.children.findIndex(isTableBody);
|
|
237
|
+
const bodyPath = [...tablePath, bodyIndex];
|
|
238
|
+
editor.moveNodes({
|
|
239
|
+
at: rowPathRef.unref(),
|
|
240
|
+
to: [...bodyPath, 0]
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
const headIndex = tableNode.children.findIndex(isTableHead);
|
|
244
|
+
const headPath = [...tablePath, headIndex];
|
|
245
|
+
const headNode = editor.node(headPath)[0];
|
|
246
|
+
if (!headNode.children.find(isTableRow)) {
|
|
247
|
+
editor.removeNodes({
|
|
248
|
+
at: headPath
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function deleteBackward(editor) {
|
|
253
|
+
if (editor.selection && Range.isCollapsed(editor.selection)) {
|
|
254
|
+
const generator = editor.nodes({
|
|
255
|
+
match: isTableCell
|
|
256
|
+
});
|
|
257
|
+
const { value: cell, done } = generator.next();
|
|
258
|
+
if (!done) {
|
|
259
|
+
const [, cellPath] = cell;
|
|
260
|
+
const start = Editor.start(editor, cellPath);
|
|
261
|
+
if (Point.equals(editor.selection.anchor, start)) {
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
} else {
|
|
265
|
+
const generator2 = editor.nodes({
|
|
266
|
+
at: editor.before(editor.selection.anchor),
|
|
267
|
+
match: isTable
|
|
268
|
+
});
|
|
269
|
+
if (!generator2.next().done) {
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function deleteForward(editor) {
|
|
276
|
+
if (editor.selection && Range.isCollapsed(editor.selection)) {
|
|
277
|
+
const generator = editor.nodes({
|
|
278
|
+
match: isTableCell
|
|
279
|
+
});
|
|
280
|
+
const { value: cell, done } = generator.next();
|
|
281
|
+
if (!done) {
|
|
282
|
+
const [, cellPath] = cell;
|
|
283
|
+
const end = editor.end(cellPath);
|
|
284
|
+
if (Point.equals(editor.selection.anchor, end)) {
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
} else {
|
|
288
|
+
const generator2 = editor.nodes({
|
|
289
|
+
at: editor.after(editor.selection.anchor),
|
|
290
|
+
match: isTable
|
|
291
|
+
});
|
|
292
|
+
if (!generator2.next().done) {
|
|
293
|
+
const [[node, path]] = editor.nodes({
|
|
294
|
+
at: editor.selection,
|
|
295
|
+
mode: "lowest",
|
|
296
|
+
match: (n) => isBlockElement(editor, n)
|
|
297
|
+
});
|
|
298
|
+
if (editor.isEmpty(node)) {
|
|
299
|
+
editor.removeNodes({
|
|
300
|
+
at: path
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
function getSplitedTableRange(editor) {
|
|
309
|
+
const tableEntries = Array.from(
|
|
310
|
+
editor.nodes({
|
|
311
|
+
match: isTable
|
|
312
|
+
})
|
|
313
|
+
);
|
|
314
|
+
const ranges = tableEntries.reduce((ranges2, current) => {
|
|
315
|
+
const [tableStart, tableEnd] = Range.edges(editor.range(current[1]));
|
|
316
|
+
const prev = ranges2[ranges2.length - 1];
|
|
317
|
+
if (prev) {
|
|
318
|
+
ranges2.push({
|
|
319
|
+
type: "non-table",
|
|
320
|
+
range: {
|
|
321
|
+
anchor: editor.after(prev.range.focus),
|
|
322
|
+
focus: editor.before(tableStart)
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
ranges2.push({
|
|
327
|
+
type: "table",
|
|
328
|
+
full: true,
|
|
329
|
+
range: {
|
|
330
|
+
anchor: tableStart,
|
|
331
|
+
focus: tableEnd
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
return ranges2;
|
|
335
|
+
}, []);
|
|
336
|
+
const [selectionStart, selectionEnd] = Range.edges(editor.selection);
|
|
337
|
+
const firstRange = ranges[0].range;
|
|
338
|
+
if (Point.isBefore(selectionStart, firstRange.anchor)) {
|
|
339
|
+
ranges.unshift({
|
|
340
|
+
type: "non-table",
|
|
341
|
+
range: {
|
|
342
|
+
anchor: selectionStart,
|
|
343
|
+
focus: editor.before(firstRange.anchor)
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
} else {
|
|
347
|
+
ranges[0].full = false;
|
|
348
|
+
firstRange.anchor = selectionStart;
|
|
349
|
+
}
|
|
350
|
+
const lastRange = ranges[ranges.length - 1].range;
|
|
351
|
+
if (Point.isAfter(selectionEnd, lastRange.focus)) {
|
|
352
|
+
ranges.push({
|
|
353
|
+
type: "non-table",
|
|
354
|
+
range: {
|
|
355
|
+
anchor: editor.after(lastRange.focus),
|
|
356
|
+
focus: selectionEnd
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
} else {
|
|
360
|
+
ranges[ranges.length - 1].full = false;
|
|
361
|
+
lastRange.focus = selectionEnd;
|
|
362
|
+
}
|
|
363
|
+
return ranges;
|
|
364
|
+
}
|
|
365
|
+
function clearTableCells(editor, range) {
|
|
366
|
+
const cellEntries = Array.from(
|
|
367
|
+
editor.nodes({
|
|
368
|
+
at: range,
|
|
369
|
+
match: isTableCell
|
|
370
|
+
})
|
|
371
|
+
);
|
|
372
|
+
const [start, end] = editor.edges(editor.selection);
|
|
373
|
+
for (const [, path] of cellEntries) {
|
|
374
|
+
const [cellStart, cellEnd] = editor.edges(path);
|
|
375
|
+
const anchor = Point.isBefore(start, cellStart) ? cellStart : start;
|
|
376
|
+
const focus = Point.isAfter(end, cellEnd) ? cellEnd : end;
|
|
377
|
+
if (Point.equals(anchor, focus)) {
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
editor.delete({
|
|
381
|
+
at: {
|
|
382
|
+
anchor,
|
|
383
|
+
focus
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
function deleteFragment(editor) {
|
|
389
|
+
if (!editor.selection) return;
|
|
390
|
+
const [anchorCell] = editor.nodes({ at: editor.selection.anchor, match: isTableCell });
|
|
391
|
+
const [focusCell] = editor.nodes({ at: editor.selection.focus, match: isTableCell });
|
|
392
|
+
if (!anchorCell && !focusCell) return;
|
|
393
|
+
if (anchorCell && focusCell && Path.equals(anchorCell[1], focusCell[1])) return;
|
|
394
|
+
const ranges = getSplitedTableRange(editor);
|
|
395
|
+
for (let i = ranges.length - 1; i >= 0; i--) {
|
|
396
|
+
const { type, full, range } = ranges[i];
|
|
397
|
+
if (Range.isCollapsed(range)) continue;
|
|
398
|
+
if (type === "non-table") {
|
|
399
|
+
editor.delete({
|
|
400
|
+
at: range
|
|
401
|
+
});
|
|
402
|
+
} else if (full) {
|
|
403
|
+
editor.delete({
|
|
404
|
+
at: {
|
|
405
|
+
anchor: editor.before(range.anchor),
|
|
406
|
+
focus: editor.after(range.focus)
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
} else {
|
|
410
|
+
clearTableCells(editor, range);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return true;
|
|
414
|
+
}
|
|
415
|
+
function wrapTableCellChildren(editor, cellPath) {
|
|
416
|
+
const children = Array.from(Node.children(editor, cellPath));
|
|
417
|
+
for (const [childNode, childPath] of children) {
|
|
418
|
+
if (!Element.isElement(childNode) || editor.isInline(childNode)) {
|
|
419
|
+
editor.wrapNodes(
|
|
420
|
+
{
|
|
421
|
+
type: "paragraph",
|
|
422
|
+
children: []
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
at: childPath
|
|
426
|
+
}
|
|
427
|
+
);
|
|
428
|
+
return true;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
function insertBreak(editor) {
|
|
433
|
+
if (!editor.selection || Range.isCollapsed(editor.selection)) return;
|
|
434
|
+
const [anchorCell] = editor.nodes({ at: editor.selection.anchor, match: isTableCell });
|
|
435
|
+
const [focusCell] = editor.nodes({ at: editor.selection.focus, match: isTableCell });
|
|
436
|
+
if (!anchorCell && !focusCell) return;
|
|
437
|
+
if (anchorCell && focusCell && Path.equals(anchorCell[1], focusCell[1])) return;
|
|
438
|
+
return true;
|
|
439
|
+
}
|
|
440
|
+
function onKeydown(editor, event) {
|
|
441
|
+
if (Hotkeys.isMoveDown(event)) {
|
|
442
|
+
if (editor.selection) {
|
|
443
|
+
const [cell] = editor.nodes({
|
|
444
|
+
match: isTableCell,
|
|
445
|
+
at: editor.selection.focus
|
|
446
|
+
});
|
|
447
|
+
if (!cell) return;
|
|
448
|
+
const cellPath = cell[1];
|
|
449
|
+
if (isPointAtLastLine(editor, cellPath, editor.selection.focus)) {
|
|
450
|
+
event.preventDefault();
|
|
451
|
+
const cellIndex = cellPath[cellPath.length - 1];
|
|
452
|
+
const [[, tablePath]] = editor.nodes({
|
|
453
|
+
at: cellPath,
|
|
454
|
+
match: isTable
|
|
455
|
+
});
|
|
456
|
+
const [, rowPath] = editor.parent(cellPath);
|
|
457
|
+
const maybeNextRow = editor.next({
|
|
458
|
+
at: rowPath,
|
|
459
|
+
match: (n, path) => isTableRow(n) && Path.isAncestor(tablePath, path)
|
|
460
|
+
});
|
|
461
|
+
if (maybeNextRow) {
|
|
462
|
+
const nextRowCellPath = [...maybeNextRow[1], cellIndex];
|
|
463
|
+
editor.select(editor.start(nextRowCellPath));
|
|
464
|
+
} else {
|
|
465
|
+
const after = editor.after(tablePath);
|
|
466
|
+
if (after) {
|
|
467
|
+
editor.select(after);
|
|
468
|
+
} else {
|
|
469
|
+
editor.insertNodes(
|
|
470
|
+
{
|
|
471
|
+
type: "paragraph",
|
|
472
|
+
children: [{ text: "" }]
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
at: Path.next(tablePath)
|
|
476
|
+
}
|
|
477
|
+
);
|
|
478
|
+
editor.select(Path.next(tablePath));
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
return true;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
if (Hotkeys.isMoveUp(event)) {
|
|
486
|
+
if (editor.selection) {
|
|
487
|
+
const [cell] = editor.nodes({
|
|
488
|
+
match: isTableCell,
|
|
489
|
+
at: editor.selection.focus
|
|
490
|
+
});
|
|
491
|
+
if (!cell) return;
|
|
492
|
+
const cellPath = cell[1];
|
|
493
|
+
if (isPointAtFirstLine(editor, cellPath, editor.selection.focus)) {
|
|
494
|
+
event.preventDefault();
|
|
495
|
+
const cellIndex = cellPath[cellPath.length - 1];
|
|
496
|
+
const [[, tablePath]] = editor.nodes({
|
|
497
|
+
at: cellPath,
|
|
498
|
+
match: isTable
|
|
499
|
+
});
|
|
500
|
+
const [, rowPath] = editor.parent(cellPath);
|
|
501
|
+
const maybeNextRow = editor.previous({
|
|
502
|
+
at: rowPath,
|
|
503
|
+
match: (n, path) => isTableRow(n) && Path.isAncestor(tablePath, path)
|
|
504
|
+
});
|
|
505
|
+
if (maybeNextRow) {
|
|
506
|
+
const nextRowCellPath = [...maybeNextRow[1], cellIndex];
|
|
507
|
+
editor.select(editor.end(nextRowCellPath));
|
|
508
|
+
} else {
|
|
509
|
+
const before = editor.before(tablePath);
|
|
510
|
+
if (before) {
|
|
511
|
+
editor.select(before);
|
|
512
|
+
} else {
|
|
513
|
+
editor.insertNodes(
|
|
514
|
+
{
|
|
515
|
+
type: "paragraph",
|
|
516
|
+
children: [{ text: "" }]
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
at: [0]
|
|
520
|
+
}
|
|
521
|
+
);
|
|
522
|
+
editor.select([0]);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return true;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
function normalizeTable(editor, entry) {
|
|
531
|
+
const [node, path] = entry;
|
|
532
|
+
if (!isTable(node)) return;
|
|
533
|
+
const children = Array.from(Node.children(editor, path));
|
|
534
|
+
for (const [childNode, childPath] of children) {
|
|
535
|
+
if (!isTableHead(childNode) && !isTableBody(childNode)) {
|
|
536
|
+
editor.removeNodes({
|
|
537
|
+
at: childPath
|
|
538
|
+
});
|
|
539
|
+
return true;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
function normalizeTableHead(editor, entry) {
|
|
544
|
+
const [node, path] = entry;
|
|
545
|
+
if (!isTableHead(node)) return;
|
|
546
|
+
const children = Array.from(Node.children(editor, path));
|
|
547
|
+
for (const [childNode, childPath] of children) {
|
|
548
|
+
if (!isTableRow(childNode)) {
|
|
549
|
+
editor.removeNodes({
|
|
550
|
+
at: childPath
|
|
551
|
+
});
|
|
552
|
+
return true;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
function normalizeTableBody(editor, entry) {
|
|
557
|
+
const [node, path] = entry;
|
|
558
|
+
if (!isTableBody(node)) return;
|
|
559
|
+
const children = Array.from(Node.children(editor, path));
|
|
560
|
+
for (const [childNode, childPath] of children) {
|
|
561
|
+
if (!isTableRow(childNode)) {
|
|
562
|
+
editor.removeNodes({
|
|
563
|
+
at: childPath
|
|
564
|
+
});
|
|
565
|
+
return true;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
function normalizeTableRow(editor, entry) {
|
|
570
|
+
const [node, path] = entry;
|
|
571
|
+
if (!isTableRow(node)) return;
|
|
572
|
+
const children = Array.from(Node.children(editor, path));
|
|
573
|
+
for (const [childNode, childPath] of children) {
|
|
574
|
+
if (!isTableCell(childNode)) {
|
|
575
|
+
editor.removeNodes({
|
|
576
|
+
at: childPath
|
|
577
|
+
});
|
|
578
|
+
return true;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
function normalizeTableCell(editor, entry) {
|
|
583
|
+
const [node, path] = entry;
|
|
584
|
+
if (!isTableCell(node)) return;
|
|
585
|
+
return wrapTableCellChildren(editor, path);
|
|
586
|
+
}
|
|
587
|
+
function normalizeNode(editor, entry) {
|
|
588
|
+
return normalizeTable(editor, entry) || normalizeTableHead(editor, entry) || normalizeTableBody(editor, entry) || normalizeTableRow(editor, entry) || normalizeTableCell(editor, entry);
|
|
589
|
+
}
|
|
590
|
+
function insertData(editor) {
|
|
591
|
+
if (!editor.selection) return;
|
|
592
|
+
const [anchorCell] = editor.nodes({ at: editor.selection.anchor, match: isTableCell });
|
|
593
|
+
const [focusCell] = editor.nodes({ at: editor.selection.focus, match: isTableCell });
|
|
594
|
+
if (!anchorCell && !focusCell) return;
|
|
595
|
+
if (anchorCell && focusCell && Path.equals(anchorCell[1], focusCell[1])) return;
|
|
596
|
+
return true;
|
|
597
|
+
}
|
|
598
|
+
function withTable(editor) {
|
|
599
|
+
const {
|
|
600
|
+
renderElement,
|
|
601
|
+
deleteBackward: srcDeleteBackward,
|
|
602
|
+
deleteForward: srcDeleteForward,
|
|
603
|
+
deleteFragment: srcDeleteFragment,
|
|
604
|
+
insertBreak: srcInsertBreak,
|
|
605
|
+
onKeydown: srcOnKeydown,
|
|
606
|
+
normalizeNode: srcNormalizeNode,
|
|
607
|
+
insertData: srcInsertData
|
|
608
|
+
} = editor;
|
|
609
|
+
editor.renderElement = (props) => {
|
|
610
|
+
const { attributes, children, element } = props;
|
|
611
|
+
switch (element.type) {
|
|
612
|
+
case "table": {
|
|
613
|
+
return h(stdin_default, useInheritRef(attributes), () => children);
|
|
614
|
+
}
|
|
615
|
+
case "table-head":
|
|
616
|
+
return h("thead", attributes, children);
|
|
617
|
+
case "table-body":
|
|
618
|
+
return h("tbody", attributes, children);
|
|
619
|
+
case "table-row":
|
|
620
|
+
return h("tr", attributes, children);
|
|
621
|
+
case "table-cell":
|
|
622
|
+
return h("td", attributes, children);
|
|
623
|
+
}
|
|
624
|
+
return renderElement(props);
|
|
625
|
+
};
|
|
626
|
+
editor.deleteBackward = (unit) => {
|
|
627
|
+
if (!deleteBackward(editor)) {
|
|
628
|
+
srcDeleteBackward(unit);
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
editor.deleteForward = (unit) => {
|
|
632
|
+
if (!deleteForward(editor)) {
|
|
633
|
+
srcDeleteForward(unit);
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
editor.deleteFragment = (options) => {
|
|
637
|
+
if (!deleteFragment(editor)) {
|
|
638
|
+
srcDeleteFragment(options);
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
editor.insertBreak = () => {
|
|
642
|
+
if (!insertBreak(editor)) {
|
|
643
|
+
srcInsertBreak();
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
editor.onKeydown = (event) => {
|
|
647
|
+
if (!onKeydown(editor, event)) {
|
|
648
|
+
srcOnKeydown(event);
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
editor.insertTable = (rowCount, columnCount) => {
|
|
652
|
+
insertTable(editor, rowCount, columnCount);
|
|
653
|
+
};
|
|
654
|
+
editor.insertRow = (tablePath, cellPath, isNext) => {
|
|
655
|
+
insertRow(editor, tablePath, cellPath, isNext);
|
|
656
|
+
};
|
|
657
|
+
editor.insertRowAbove = (tablePath, cellPath) => {
|
|
658
|
+
insertRowAbove(editor, tablePath, cellPath);
|
|
659
|
+
};
|
|
660
|
+
editor.insertRowBelow = (tablePath, cellPath) => {
|
|
661
|
+
insertRowBelow(editor, tablePath, cellPath);
|
|
662
|
+
};
|
|
663
|
+
editor.insertColumn = (tablePath, cellPath, isNext) => {
|
|
664
|
+
insertColumn(editor, tablePath, cellPath, isNext);
|
|
665
|
+
};
|
|
666
|
+
editor.insertColumnLeft = (tablePath, cellPath) => {
|
|
667
|
+
insertColumnLeft(editor, tablePath, cellPath);
|
|
668
|
+
};
|
|
669
|
+
editor.insertColumnRight = (tablePath, cellPath) => {
|
|
670
|
+
insertColumnRight(editor, tablePath, cellPath);
|
|
671
|
+
};
|
|
672
|
+
editor.deleteRow = (tablePath, cellPath) => {
|
|
673
|
+
deleteRow(editor, tablePath, cellPath);
|
|
674
|
+
};
|
|
675
|
+
editor.deleteColumn = (tablePath, cellPath) => {
|
|
676
|
+
deleteColumn(editor, tablePath, cellPath);
|
|
677
|
+
};
|
|
678
|
+
editor.deleteTable = (tablePath) => {
|
|
679
|
+
deleteTable(editor, tablePath);
|
|
680
|
+
};
|
|
681
|
+
editor.moveToHead = (tablePath, cellPath) => {
|
|
682
|
+
moveToHead(editor, tablePath, cellPath);
|
|
683
|
+
};
|
|
684
|
+
editor.moveToBody = (tablePath, cellPath) => {
|
|
685
|
+
moveToBody(editor, tablePath, cellPath);
|
|
686
|
+
};
|
|
687
|
+
editor.isTable = isTable;
|
|
688
|
+
editor.isTableCell = isTableCell;
|
|
689
|
+
editor.normalizeNode = (entry, options) => {
|
|
690
|
+
if (!normalizeNode(editor, entry)) {
|
|
691
|
+
srcNormalizeNode(entry, options);
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
editor.insertData = (data) => {
|
|
695
|
+
if (!insertData(editor)) {
|
|
696
|
+
srcInsertData(data);
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
return editor;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
export { withTable };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Editor } from 'slate-vue3/core';
|
|
2
|
+
import { CustomEditor } from '../types';
|
|
3
|
+
declare module 'slate-vue3/core' {
|
|
4
|
+
interface BaseEditor {
|
|
5
|
+
insertVideo: (url: string, width?: number | string, height?: number | string) => void;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare function withVideo(editor: Editor): CustomEditor;
|