cosey 0.9.4 → 0.10.0
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 +8 -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 +47 -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 +120 -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 +348 -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.api.d.ts +9 -4
- package/components/form-group/form-group.api.js +4 -1
- package/components/form-group/form-group.d.ts +8 -2
- package/components/form-group/form-group.js +13 -3
- package/components/form-group/form-group.style.js +5 -0
- package/components/form-group/index.d.ts +12 -3
- 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 +4 -5
- package/components/highlight/highlight.style.js +285 -50
- 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
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
import { defineComponent, defineAsyncComponent, h } from 'vue';
|
|
2
1
|
import { withInstall } from '../utils.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { isClient } from '../../utils/env.js';
|
|
2
|
+
import stdin_default$1 from './editor.js';
|
|
3
|
+
export { editorEmits, editorProps, editorSlots } from './editor.api.js';
|
|
6
4
|
|
|
7
|
-
const
|
|
8
|
-
name: "Editor",
|
|
9
|
-
setup(props, { slots }) {
|
|
10
|
-
const AsyncComponent = defineAsyncComponent(() => import('./editor.js'));
|
|
11
|
-
const isMounted = useMounted();
|
|
12
|
-
return () => {
|
|
13
|
-
if (!isClient()) {
|
|
14
|
-
return isMounted.value && h(AsyncComponent, props, slots);
|
|
15
|
-
}
|
|
16
|
-
return h(AsyncComponent, props, slots);
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
if (isClient()) {
|
|
21
|
-
import('./editor.js');
|
|
22
|
-
}
|
|
23
|
-
const _Editor = withInstall(Editor);
|
|
5
|
+
const _Editor = withInstall(stdin_default$1);
|
|
24
6
|
var stdin_default = _Editor;
|
|
25
7
|
|
|
26
8
|
export { _Editor as Editor, stdin_default as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Editor } from 'slate-vue3/core';
|
|
2
|
+
declare module 'slate-vue3/core' {
|
|
3
|
+
interface BaseEditor {
|
|
4
|
+
formatAlign: (value: string) => void;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export type FormatAlign = 'left' | 'center' | 'right' | 'justify';
|
|
8
|
+
export declare function withAlign(editor: Editor): import("../types").CustomEditor;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { toggleBlockAttr } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
function formatAlign(editor, value) {
|
|
4
|
+
toggleBlockAttr(editor, "align", value);
|
|
5
|
+
}
|
|
6
|
+
function withAlign(editor) {
|
|
7
|
+
editor.formatAlign = (value) => {
|
|
8
|
+
formatAlign(editor, value);
|
|
9
|
+
};
|
|
10
|
+
return editor;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { withAlign };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Range, Editor } from 'slate-vue3/core';
|
|
2
|
+
|
|
3
|
+
function formatBackground(editor, color) {
|
|
4
|
+
if (!editor.selection) return;
|
|
5
|
+
if (Range.isCollapsed(editor.selection)) return;
|
|
6
|
+
if (color) {
|
|
7
|
+
Editor.addMark(editor, "background", color);
|
|
8
|
+
} else {
|
|
9
|
+
Editor.removeMark(editor, "background");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function withBackground(editor) {
|
|
13
|
+
editor.formatBackground = (color) => {
|
|
14
|
+
formatBackground(editor, color);
|
|
15
|
+
};
|
|
16
|
+
return editor;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { withBackground };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Editor } from 'slate-vue3/core';
|
|
2
|
+
declare module 'slate-vue3/core' {
|
|
3
|
+
interface BaseEditor {
|
|
4
|
+
formatBlockQuote: () => void;
|
|
5
|
+
isBlockQuoteActive: () => boolean;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare function withBlockQuote(editor: Editor): import("../types").CustomEditor;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Element } from 'slate-vue3/core';
|
|
2
|
+
import { isNormalBlock } from '../utils.js';
|
|
3
|
+
|
|
4
|
+
function isBlockQuoteActive(editor) {
|
|
5
|
+
if (!editor.selection) return false;
|
|
6
|
+
const nodes = editor.nodes({
|
|
7
|
+
at: editor.edges(editor.selection)[0],
|
|
8
|
+
match: (n) => Element.isElement(n) && n.type === "block-quote"
|
|
9
|
+
});
|
|
10
|
+
return !nodes.next().done;
|
|
11
|
+
}
|
|
12
|
+
function formatBlockQuote(editor) {
|
|
13
|
+
if (!editor.selection) return;
|
|
14
|
+
const isActive = editor.isBlockQuoteActive();
|
|
15
|
+
editor.setNodes(
|
|
16
|
+
{
|
|
17
|
+
type: isActive ? "paragraph" : "block-quote"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
match: isNormalBlock
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
function withBlockQuote(editor) {
|
|
25
|
+
editor.formatBlockQuote = () => {
|
|
26
|
+
formatBlockQuote(editor);
|
|
27
|
+
};
|
|
28
|
+
editor.isBlockQuoteActive = () => {
|
|
29
|
+
return isBlockQuoteActive(editor);
|
|
30
|
+
};
|
|
31
|
+
return editor;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { withBlockQuote };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Range, Text, Editor, Element, Point } from 'slate-vue3/core';
|
|
2
|
+
|
|
3
|
+
const clearableElementProps = ["align", "indent"];
|
|
4
|
+
function clearForamts(editor) {
|
|
5
|
+
if (!editor.selection) return;
|
|
6
|
+
if (Range.isCollapsed(editor.selection)) return;
|
|
7
|
+
const textNodes = Array.from(
|
|
8
|
+
editor.nodes({
|
|
9
|
+
at: editor.selection,
|
|
10
|
+
match: (n) => Text.isText(n)
|
|
11
|
+
})
|
|
12
|
+
);
|
|
13
|
+
Editor.withoutNormalizing(editor, () => {
|
|
14
|
+
textNodes.forEach(([node, path]) => {
|
|
15
|
+
const newProps = {};
|
|
16
|
+
Object.keys(node).forEach((key) => {
|
|
17
|
+
if (key !== "text") newProps[key] = void 0;
|
|
18
|
+
});
|
|
19
|
+
if (Object.keys(newProps).length > 0) {
|
|
20
|
+
editor.setNodes(newProps, { at: path });
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
const elementNodes = Array.from(
|
|
25
|
+
editor.nodes({
|
|
26
|
+
at: editor.selection,
|
|
27
|
+
match: (n) => Element.isElement(n)
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
elementNodes.forEach(([node, path]) => {
|
|
31
|
+
const [selectionStart, selectionEnd] = Range.edges(editor.selection);
|
|
32
|
+
const [elementStart, elementEnd] = Range.edges(Editor.range(editor, path));
|
|
33
|
+
if (Point.compare(selectionStart, elementStart) <= 0 && Point.compare(selectionEnd, elementEnd) >= 0) {
|
|
34
|
+
const newProps = {};
|
|
35
|
+
Object.keys(node).forEach((key) => {
|
|
36
|
+
if (clearableElementProps.includes(key)) {
|
|
37
|
+
newProps[key] = void 0;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
if (Object.keys(newProps).length > 0) {
|
|
41
|
+
editor.setNodes(newProps, { at: path });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function withClear(editor) {
|
|
47
|
+
editor.clearForamts = () => {
|
|
48
|
+
clearForamts(editor);
|
|
49
|
+
};
|
|
50
|
+
return editor;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { withClear };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Editor, Node, Range } from 'slate-vue3/core';
|
|
2
|
+
export declare const languageOptions: {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
}[];
|
|
6
|
+
declare module 'slate-vue3/core' {
|
|
7
|
+
interface BaseEditor {
|
|
8
|
+
decorate: (nodeList: Node[]) => Range[];
|
|
9
|
+
formatCodeBlock: () => void;
|
|
10
|
+
isCodeBlockActive: () => boolean;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export declare function withCodeBlock(editor: Editor): import("../types").CustomEditor;
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import Prism from 'prismjs';
|
|
2
|
+
import { h } from 'vue';
|
|
3
|
+
import { useInheritRef, toRawWeakMap } from 'slate-vue3';
|
|
4
|
+
import { Range, Editor, Node, Text, Element, Path } from 'slate-vue3/core';
|
|
5
|
+
import stdin_default from '../contents/content-code-block.js';
|
|
6
|
+
import { Hotkeys } from './keyboard.js';
|
|
7
|
+
import { isNormalBlock, isPointAtEndOfElement, getSortedRange, getRangePosition, RangePosition } from '../utils.js';
|
|
8
|
+
|
|
9
|
+
const languageOptions = [
|
|
10
|
+
{ value: "text", label: "PlainText" },
|
|
11
|
+
{ value: "css", label: "CSS" },
|
|
12
|
+
{ value: "less", label: "Less" },
|
|
13
|
+
{ value: "scss", label: "Scss" },
|
|
14
|
+
{ value: "html", label: "HTML" },
|
|
15
|
+
{ value: "javascript", label: "JavaScript" },
|
|
16
|
+
{ value: "jsx", label: "JSX" },
|
|
17
|
+
{ value: "typescript", label: "TypeScript" },
|
|
18
|
+
{ value: "tsx", label: "TSX" },
|
|
19
|
+
{ value: "json", label: "JSON" },
|
|
20
|
+
{ value: "markdown", label: "Markdown" },
|
|
21
|
+
{ value: "php", label: "PHP" },
|
|
22
|
+
{ value: "java", label: "Java" },
|
|
23
|
+
{ value: "python", label: "Python" },
|
|
24
|
+
{ value: "sql", label: "SQL" }
|
|
25
|
+
];
|
|
26
|
+
const newlineRe = /\r\n|\r|\n/;
|
|
27
|
+
const normalizeEmptyLines = (line) => {
|
|
28
|
+
if (line.length === 0) {
|
|
29
|
+
line.push({
|
|
30
|
+
types: ["plain"],
|
|
31
|
+
content: "\n",
|
|
32
|
+
empty: true
|
|
33
|
+
});
|
|
34
|
+
} else if (line.length === 1 && line[0].content === "") {
|
|
35
|
+
line[0].content = "\n";
|
|
36
|
+
line[0].empty = true;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const appendTypes = (types, add) => {
|
|
40
|
+
const typesSize = types.length;
|
|
41
|
+
if (typesSize > 0 && types[typesSize - 1] === add) {
|
|
42
|
+
return types;
|
|
43
|
+
}
|
|
44
|
+
return types.concat(add);
|
|
45
|
+
};
|
|
46
|
+
const normalizeTokens = (tokens) => {
|
|
47
|
+
const typeArrStack = [[]];
|
|
48
|
+
const tokenArrStack = [tokens];
|
|
49
|
+
const tokenArrIndexStack = [0];
|
|
50
|
+
const tokenArrSizeStack = [tokens.length];
|
|
51
|
+
let i = 0;
|
|
52
|
+
let stackIndex = 0;
|
|
53
|
+
let currentLine = [];
|
|
54
|
+
const acc = [currentLine];
|
|
55
|
+
while (stackIndex > -1) {
|
|
56
|
+
while ((i = tokenArrIndexStack[stackIndex]++) < tokenArrSizeStack[stackIndex]) {
|
|
57
|
+
let content;
|
|
58
|
+
let types = typeArrStack[stackIndex];
|
|
59
|
+
const tokenArr = tokenArrStack[stackIndex];
|
|
60
|
+
const token = tokenArr[i];
|
|
61
|
+
if (typeof token === "string") {
|
|
62
|
+
types = stackIndex > 0 ? types : ["plain"];
|
|
63
|
+
content = token;
|
|
64
|
+
} else {
|
|
65
|
+
types = appendTypes(types, token.type);
|
|
66
|
+
if (token.alias) {
|
|
67
|
+
types = appendTypes(types, token.alias);
|
|
68
|
+
}
|
|
69
|
+
content = token.content;
|
|
70
|
+
}
|
|
71
|
+
if (typeof content !== "string") {
|
|
72
|
+
stackIndex++;
|
|
73
|
+
typeArrStack.push(types);
|
|
74
|
+
tokenArrStack.push(content);
|
|
75
|
+
tokenArrIndexStack.push(0);
|
|
76
|
+
tokenArrSizeStack.push(content.length);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const splitByNewlines = content.split(newlineRe);
|
|
80
|
+
const newlineCount = splitByNewlines.length;
|
|
81
|
+
currentLine.push({ types, content: splitByNewlines[0] });
|
|
82
|
+
for (let i2 = 1; i2 < newlineCount; i2++) {
|
|
83
|
+
normalizeEmptyLines(currentLine);
|
|
84
|
+
acc.push(currentLine = []);
|
|
85
|
+
currentLine.push({ types, content: splitByNewlines[i2] });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
stackIndex--;
|
|
89
|
+
typeArrStack.pop();
|
|
90
|
+
tokenArrStack.pop();
|
|
91
|
+
tokenArrIndexStack.pop();
|
|
92
|
+
tokenArrSizeStack.pop();
|
|
93
|
+
}
|
|
94
|
+
normalizeEmptyLines(currentLine);
|
|
95
|
+
return acc;
|
|
96
|
+
};
|
|
97
|
+
function node2Decorations(editor) {
|
|
98
|
+
const decorationsMap = new toRawWeakMap();
|
|
99
|
+
const blockEntries = editor.nodes({
|
|
100
|
+
at: [],
|
|
101
|
+
mode: "highest",
|
|
102
|
+
match: isCodeBlock
|
|
103
|
+
});
|
|
104
|
+
Array.from(blockEntries).forEach(([block, blockPath]) => {
|
|
105
|
+
const text = block.children.map((line) => Node.string(line)).join("\n");
|
|
106
|
+
const tokens = Prism.tokenize(text, Prism.languages[block.language]);
|
|
107
|
+
normalizeTokens(tokens).forEach((tokens2, index) => {
|
|
108
|
+
const element = block.children[index];
|
|
109
|
+
if (!decorationsMap.has(element)) {
|
|
110
|
+
decorationsMap.set(element, []);
|
|
111
|
+
}
|
|
112
|
+
let start = 0;
|
|
113
|
+
tokens2.forEach((token) => {
|
|
114
|
+
const length = token.content.length;
|
|
115
|
+
if (!length) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const end = start + length;
|
|
119
|
+
const path = [...blockPath, index, 0];
|
|
120
|
+
const range = {
|
|
121
|
+
anchor: { path, offset: start },
|
|
122
|
+
focus: { path, offset: end },
|
|
123
|
+
token: true,
|
|
124
|
+
...Object.fromEntries(token.types.map((type) => [type, true]))
|
|
125
|
+
};
|
|
126
|
+
decorationsMap.get(element).push(range);
|
|
127
|
+
start = end;
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
return decorationsMap;
|
|
132
|
+
}
|
|
133
|
+
function formatCodeBlock(editor) {
|
|
134
|
+
if (!editor.selection) return;
|
|
135
|
+
const isActive = editor.isCodeBlockActive();
|
|
136
|
+
if (isActive) {
|
|
137
|
+
editor.unwrapNodes({
|
|
138
|
+
match: isCodeBlock,
|
|
139
|
+
split: true
|
|
140
|
+
});
|
|
141
|
+
editor.setNodes(
|
|
142
|
+
{
|
|
143
|
+
type: "paragraph"
|
|
144
|
+
},
|
|
145
|
+
{ match: isCodeLine }
|
|
146
|
+
);
|
|
147
|
+
} else {
|
|
148
|
+
editor.wrapNodes(
|
|
149
|
+
{ type: "code-block", language: "plain", children: [] },
|
|
150
|
+
{ match: isNormalBlock }
|
|
151
|
+
);
|
|
152
|
+
editor.setNodes({ type: "code-line" }, { match: isNormalBlock });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function decorate(editor, nodeList) {
|
|
156
|
+
const node = nodeList[0];
|
|
157
|
+
if (isCodeLine(node)) {
|
|
158
|
+
return node2Decorations(editor).get(node) || [];
|
|
159
|
+
}
|
|
160
|
+
return [];
|
|
161
|
+
}
|
|
162
|
+
function formatIndent(editor, value) {
|
|
163
|
+
const codeLineNodes = Array.from(
|
|
164
|
+
editor.nodes({
|
|
165
|
+
match: isCodeLine
|
|
166
|
+
})
|
|
167
|
+
);
|
|
168
|
+
function shouldInsert() {
|
|
169
|
+
const range = getSortedRange(editor.selection);
|
|
170
|
+
if (codeLineNodes.length === 1) {
|
|
171
|
+
const pos = getRangePosition(editor.range(codeLineNodes[0][1]), range);
|
|
172
|
+
return pos === RangePosition.CONTAIN || pos === RangePosition.AFTER_BEGIN || pos === RangePosition.BEFORE_END;
|
|
173
|
+
}
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
if (codeLineNodes.length > 0) {
|
|
177
|
+
const selection = editor.selection;
|
|
178
|
+
if (Range.isCollapsed(selection) || shouldInsert()) {
|
|
179
|
+
if (value === 1) {
|
|
180
|
+
Editor.insertText(editor, " ");
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
codeLineNodes.forEach(([, path]) => {
|
|
184
|
+
const firstNode = Node.first(editor, path);
|
|
185
|
+
if (Text.isText(firstNode[0])) {
|
|
186
|
+
const text = firstNode[0].text;
|
|
187
|
+
if (value === 1) {
|
|
188
|
+
editor.insertText(" ", {
|
|
189
|
+
at: editor.start(firstNode[1])
|
|
190
|
+
});
|
|
191
|
+
} else {
|
|
192
|
+
const blankNum = Math.min(text.match(/^ +/)?.[0].length || 0, 2);
|
|
193
|
+
if (blankNum > 0) {
|
|
194
|
+
editor.delete({
|
|
195
|
+
at: {
|
|
196
|
+
anchor: {
|
|
197
|
+
path: firstNode[1],
|
|
198
|
+
offset: 0
|
|
199
|
+
},
|
|
200
|
+
focus: {
|
|
201
|
+
path: firstNode[1],
|
|
202
|
+
offset: blankNum
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function onKeydown(editor, event) {
|
|
214
|
+
if (Hotkeys.isSoftBreak(event)) {
|
|
215
|
+
if (isPointAtEndOfElement(editor, "code-block", ([, path]) => {
|
|
216
|
+
editor.insertNodes(
|
|
217
|
+
{
|
|
218
|
+
type: "paragraph",
|
|
219
|
+
children: [{ text: "" }]
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
at: Path.next(path)
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
editor.move();
|
|
226
|
+
})) {
|
|
227
|
+
event.preventDefault();
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function isCodeBlock(element) {
|
|
233
|
+
return Element.isElementType(element, "code-block");
|
|
234
|
+
}
|
|
235
|
+
function isCodeLine(element) {
|
|
236
|
+
return Element.isElementType(element, "code-line");
|
|
237
|
+
}
|
|
238
|
+
function normalizeCodeBlock(editor, entry) {
|
|
239
|
+
const [node, path] = entry;
|
|
240
|
+
if (!isCodeBlock(node)) return;
|
|
241
|
+
const children = Array.from(Node.children(editor, path));
|
|
242
|
+
for (const [childNode, childPath] of children) {
|
|
243
|
+
if (!isCodeLine(childNode)) {
|
|
244
|
+
const text = editor.string(childPath);
|
|
245
|
+
editor.removeNodes({
|
|
246
|
+
at: childPath
|
|
247
|
+
});
|
|
248
|
+
editor.insertNodes(
|
|
249
|
+
{
|
|
250
|
+
type: "code-line",
|
|
251
|
+
children: [{ text }]
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
at: childPath
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function normalizeCodeLine(editor, entry) {
|
|
262
|
+
const [node, path] = entry;
|
|
263
|
+
if (!isCodeLine(node)) return;
|
|
264
|
+
if (!isCodeBlock(Node.parent(editor, path))) {
|
|
265
|
+
editor.setNodes(
|
|
266
|
+
{
|
|
267
|
+
type: "paragraph"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
at: path
|
|
271
|
+
}
|
|
272
|
+
);
|
|
273
|
+
return true;
|
|
274
|
+
}
|
|
275
|
+
const children = Array.from(Node.children(editor, path));
|
|
276
|
+
for (const [childNode, childPath] of children) {
|
|
277
|
+
if (!Text.isText(childNode)) {
|
|
278
|
+
const text = editor.string(childPath);
|
|
279
|
+
editor.removeNodes({
|
|
280
|
+
at: childPath
|
|
281
|
+
});
|
|
282
|
+
editor.insertNodes(
|
|
283
|
+
{
|
|
284
|
+
text
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
at: childPath
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function normalizeNode(editor, entry) {
|
|
295
|
+
return normalizeCodeBlock(editor, entry) || normalizeCodeLine(editor, entry);
|
|
296
|
+
}
|
|
297
|
+
function isCodeBlockActive(editor) {
|
|
298
|
+
if (!editor.selection) return false;
|
|
299
|
+
const nodes = editor.nodes({
|
|
300
|
+
at: editor.edges(editor.selection)[0],
|
|
301
|
+
match: isCodeBlock
|
|
302
|
+
});
|
|
303
|
+
return !nodes.next().done;
|
|
304
|
+
}
|
|
305
|
+
function withCodeBlock(editor) {
|
|
306
|
+
const {
|
|
307
|
+
renderElement,
|
|
308
|
+
formatIndent: srcFormatIndent,
|
|
309
|
+
onKeydown: srcOnKeydown,
|
|
310
|
+
normalizeNode: srcNormalizeNode
|
|
311
|
+
} = editor;
|
|
312
|
+
editor.decorate = (nodeList) => {
|
|
313
|
+
return decorate(editor, nodeList);
|
|
314
|
+
};
|
|
315
|
+
editor.formatCodeBlock = () => {
|
|
316
|
+
formatCodeBlock(editor);
|
|
317
|
+
};
|
|
318
|
+
editor.renderElement = (props) => {
|
|
319
|
+
const { attributes, children, element } = props;
|
|
320
|
+
if (element.type === "code-block") {
|
|
321
|
+
return h(stdin_default, useInheritRef(attributes), () => children);
|
|
322
|
+
}
|
|
323
|
+
if (element.type === "code-line") {
|
|
324
|
+
return h("div", { ...attributes, style: { position: "relative" } }, children);
|
|
325
|
+
}
|
|
326
|
+
return renderElement(props);
|
|
327
|
+
};
|
|
328
|
+
editor.formatIndent = (value) => {
|
|
329
|
+
formatIndent(editor, value);
|
|
330
|
+
return srcFormatIndent(value);
|
|
331
|
+
};
|
|
332
|
+
editor.onKeydown = (event) => {
|
|
333
|
+
if (!onKeydown(editor, event)) {
|
|
334
|
+
srcOnKeydown(event);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
editor.normalizeNode = (entry, options) => {
|
|
338
|
+
if (!normalizeNode(editor, entry)) {
|
|
339
|
+
srcNormalizeNode(entry, options);
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
editor.isCodeBlockActive = () => {
|
|
343
|
+
return isCodeBlockActive(editor);
|
|
344
|
+
};
|
|
345
|
+
return editor;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export { languageOptions, withCodeBlock };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Range, Editor } from 'slate-vue3/core';
|
|
2
|
+
|
|
3
|
+
function formatColor(editor, color) {
|
|
4
|
+
if (!editor.selection) return;
|
|
5
|
+
if (Range.isCollapsed(editor.selection)) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
if (color) {
|
|
9
|
+
Editor.addMark(editor, "color", color);
|
|
10
|
+
} else {
|
|
11
|
+
Editor.removeMark(editor, "color");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function withColor(editor) {
|
|
15
|
+
editor.formatColor = (color) => {
|
|
16
|
+
formatColor(editor, color);
|
|
17
|
+
};
|
|
18
|
+
return editor;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { withColor };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Range, Editor } from 'slate-vue3/core';
|
|
2
|
+
|
|
3
|
+
function formatFont(editor, value) {
|
|
4
|
+
if (!editor.selection) return;
|
|
5
|
+
if (Range.isCollapsed(editor.selection)) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
Editor.addMark(editor, "font", value);
|
|
9
|
+
}
|
|
10
|
+
function withFont(editor) {
|
|
11
|
+
editor.formatFont = (value) => {
|
|
12
|
+
formatFont(editor, value);
|
|
13
|
+
};
|
|
14
|
+
return editor;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { withFont };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Editor } from 'slate-vue3/core';
|
|
2
|
+
export declare const formulas: {
|
|
3
|
+
name: string;
|
|
4
|
+
formula: string;
|
|
5
|
+
}[];
|
|
6
|
+
declare module 'slate-vue3/core' {
|
|
7
|
+
interface BaseEditor {
|
|
8
|
+
insertFormula: (value: string) => void;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export declare function withFormula(editor: Editor): import("../types").CustomEditor;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { h } from 'vue';
|
|
2
|
+
import { useInheritRef } from 'slate-vue3';
|
|
3
|
+
import stdin_default from '../contents/content-formula.js';
|
|
4
|
+
import { isPointingAt, getPointingOptions } from '../utils.js';
|
|
5
|
+
|
|
1
6
|
const formulas = [
|
|
2
7
|
{
|
|
3
8
|
name: "\u5085\u91CC\u53F6\u7EA7\u6570",
|
|
@@ -84,5 +89,49 @@ const formulas = [
|
|
|
84
89
|
formula: "\\frac{{\\partial f}}{{\\partial l}} = \\frac{{\\partial f}}{{\\partial x}}\\cos \\phi + \\frac{{\\partial f}}{{\\partial y}}\\sin \\phi"
|
|
85
90
|
}
|
|
86
91
|
];
|
|
92
|
+
function insertFormula(editor, value) {
|
|
93
|
+
if (!editor.selection) return;
|
|
94
|
+
if (isPointingAt(editor, "formula")) {
|
|
95
|
+
editor.setNodes(
|
|
96
|
+
{
|
|
97
|
+
formula: value
|
|
98
|
+
},
|
|
99
|
+
getPointingOptions(editor, "formula")
|
|
100
|
+
);
|
|
101
|
+
} else {
|
|
102
|
+
editor.insertNodes({
|
|
103
|
+
type: "formula",
|
|
104
|
+
formula: value,
|
|
105
|
+
children: [{ text: "" }]
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function withFormula(editor) {
|
|
110
|
+
const { isInline, isVoid, renderElement } = editor;
|
|
111
|
+
editor.isInline = (element) => {
|
|
112
|
+
return element.type === "formula" ? true : isInline(element);
|
|
113
|
+
};
|
|
114
|
+
editor.isVoid = (element) => {
|
|
115
|
+
return element.type === "formula" ? true : isVoid(element);
|
|
116
|
+
};
|
|
117
|
+
editor.insertFormula = (value) => {
|
|
118
|
+
insertFormula(editor, value);
|
|
119
|
+
};
|
|
120
|
+
editor.renderElement = (props) => {
|
|
121
|
+
const { attributes, children, element } = props;
|
|
122
|
+
if (element.type === "formula") {
|
|
123
|
+
return h(
|
|
124
|
+
stdin_default,
|
|
125
|
+
{
|
|
126
|
+
...useInheritRef(attributes),
|
|
127
|
+
formula: element.formula
|
|
128
|
+
},
|
|
129
|
+
() => children
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
return renderElement(props);
|
|
133
|
+
};
|
|
134
|
+
return editor;
|
|
135
|
+
}
|
|
87
136
|
|
|
88
|
-
export { formulas };
|
|
137
|
+
export { formulas, withFormula };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Editor } from 'slate-vue3/core';
|
|
2
|
+
import { type HeadingParagraphType } from '../types';
|
|
3
|
+
declare module 'slate-vue3/core' {
|
|
4
|
+
interface BaseEditor {
|
|
5
|
+
formatHeading: (value: HeadingParagraphType) => void;
|
|
6
|
+
getActiveHeadingType: () => HeadingParagraphType;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare function withHeading(editor: Editor): import("../types").CustomEditor;
|