@seafile/seafile-editor 0.4.8 → 1.0.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/.babelrc +5 -0
- package/.eslintignore +19 -0
- package/.eslintrc.json +52 -0
- package/.github/workflows/nodejs.yml +25 -0
- package/.vscode/settings.json +5 -0
- package/config/config.common.js +157 -0
- package/config/config.dev.js +53 -0
- package/config/jest/cssTransform.js +16 -0
- package/config/jest/fileTransform.js +40 -0
- package/config/utils/theme.css.js +103 -0
- package/config.js +61 -0
- package/dev-server.js +145 -0
- package/jest.config.js +16 -0
- package/package.json +81 -131
- package/public/locales/en/seafile-editor.json +145 -148
- package/public/locales/zh-CN/seafile-editor.json +123 -135
- package/public/media/seafile-ui.css +6 -11166
- package/scripts/ejs.js +16 -0
- package/site/_i18n/index.js +35 -0
- package/site/api/index.js +212 -0
- package/site/app.js +21 -0
- package/site/assets/css/app.css +47 -0
- package/site/assets/css/seafile-editor.css +33 -0
- package/site/commons/loading/index.js +14 -0
- package/site/commons/loading/style.css +49 -0
- package/site/commons/switch/index.css +14 -0
- package/site/commons/switch/index.js +37 -0
- package/site/commons/toast/alert.js +106 -0
- package/site/commons/toast/index.js +5 -0
- package/site/commons/toast/toast.js +195 -0
- package/site/commons/toast/toastManager.js +138 -0
- package/site/commons/toast/toaster.js +64 -0
- package/site/index.html +23 -0
- package/site/index.js +21 -0
- package/site/pages/home.js +21 -0
- package/site/pages/plain-markdown-view.js +6 -0
- package/site/pages/rich-seafile-editor.js +72 -0
- package/site/pages/seafile-editor.js +39 -0
- package/site/pages/seafile-viewer.js +45 -0
- package/site/pages/simple-editor.js +44 -0
- package/site/pages/wiki-viewer.js +7 -0
- package/site/setting.js +36 -0
- package/site/setting.local.dist.js +23 -0
- package/src/assets/css/slate-editor.css +57 -0
- package/src/constants/event-types.js +11 -0
- package/src/constants/hot-keys.js +47 -0
- package/src/containers/article-info/index.js +49 -0
- package/src/containers/article-info/style.css +52 -0
- package/src/containers/custom/get-event-transfer.js +28 -0
- package/{dist → src}/containers/custom/set-event-transfer.js +13 -11
- package/src/containers/hotkeys-helper/classify-hotkeys.js +30 -0
- package/src/containers/hotkeys-helper/index.js +43 -0
- package/{dist/assets/css/user-help.css → src/containers/hotkeys-helper/style.css} +37 -29
- package/src/containers/loading/index.js +14 -0
- package/src/containers/loading/style.css +49 -0
- package/src/containers/outline/index.js +75 -0
- package/src/containers/outline/outline-item.js +28 -0
- package/src/containers/outline/style.css +45 -0
- package/src/editors/plain-markdown-editor/code-mirror.css +8 -0
- package/src/editors/plain-markdown-editor/code-mirror.js +73 -0
- package/src/editors/plain-markdown-editor/index.js +136 -0
- package/{dist/assets/editor/plain-editor.css → src/editors/plain-markdown-editor/style.css} +12 -4
- package/src/editors/simple-slate-editor /index.js +71 -0
- package/src/editors/simple-slate-editor /with-props-editor.js +15 -0
- package/src/editors/slate-editor/editor-help/index.js +46 -0
- package/src/editors/slate-editor/editor-help/style.css +15 -0
- package/src/editors/slate-editor/index.js +77 -0
- package/src/editors/slate-editor/with-props-editor.js +15 -0
- package/src/editors/slate-viewer/index.js +35 -0
- package/src/editors/slate-viewer/style.css +40 -0
- package/src/extension/commons/element-popover/index.js +52 -0
- package/src/extension/commons/index.js +10 -0
- package/src/extension/commons/menu/index.js +9 -0
- package/src/extension/commons/menu/menu-drop-down.js +110 -0
- package/src/extension/commons/menu/menu-group.js +20 -0
- package/src/extension/commons/menu/menu-item.js +60 -0
- package/src/extension/commons/menu/menu.css +120 -0
- package/src/extension/commons/tooltip/index.css +21 -0
- package/src/extension/commons/tooltip/index.js +26 -0
- package/src/extension/constants/element-types.js +23 -0
- package/src/extension/constants/index.js +37 -0
- package/src/extension/constants/keyboard.js +29 -0
- package/src/extension/constants/menus-config.js +149 -0
- package/src/extension/core/index.js +3 -0
- package/src/extension/core/queries/index.js +410 -0
- package/src/extension/core/transforms/focus-editor.js +12 -0
- package/src/extension/core/transforms/index.js +4 -0
- package/src/extension/core/transforms/move-children.js +23 -0
- package/src/extension/core/transforms/remove-node-children.js +8 -0
- package/src/extension/core/transforms/replace-node-children.js +14 -0
- package/src/extension/core/utils/index.js +76 -0
- package/src/extension/editor.js +14 -0
- package/src/extension/index.js +15 -0
- package/src/extension/plugins/blockquote/helpers.js +65 -0
- package/src/extension/plugins/blockquote/index.js +13 -0
- package/src/extension/plugins/blockquote/menu/index.js +31 -0
- package/src/extension/plugins/blockquote/plugin.js +64 -0
- package/src/extension/plugins/blockquote/render-elem.js +9 -0
- package/src/extension/plugins/check-list/helper.js +34 -0
- package/src/extension/plugins/check-list/index.js +14 -0
- package/src/extension/plugins/check-list/menu/index.js +44 -0
- package/src/extension/plugins/check-list/plugin.js +46 -0
- package/src/extension/plugins/check-list/render-elem.js +23 -0
- package/src/extension/plugins/clear-format/helpers.js +48 -0
- package/src/extension/plugins/clear-format/menu/index.js +39 -0
- package/src/extension/plugins/code-block/helpers.js +107 -0
- package/src/extension/plugins/code-block/index.js +14 -0
- package/src/extension/plugins/code-block/menu/index.js +40 -0
- package/src/extension/plugins/code-block/plugin.js +210 -0
- package/src/extension/plugins/code-block/render-elem/constant.js +17 -0
- package/src/extension/plugins/code-block/render-elem/index.js +55 -0
- package/src/extension/plugins/code-block/render-elem/language-selector.js +38 -0
- package/src/extension/plugins/code-block/render-elem/style.css +27 -0
- package/src/extension/plugins/formula/formula.css +22 -0
- package/src/extension/plugins/formula/helper.js +68 -0
- package/src/extension/plugins/formula/index.js +14 -0
- package/src/extension/plugins/formula/menu/formula-modal.js +73 -0
- package/src/extension/plugins/formula/menu/index.js +63 -0
- package/src/extension/plugins/formula/plugin.js +18 -0
- package/src/extension/plugins/formula/render-elem.js +40 -0
- package/src/extension/plugins/header/helper.js +47 -0
- package/src/extension/plugins/header/index.js +14 -0
- package/src/extension/plugins/header/menu/index.js +114 -0
- package/src/extension/plugins/header/menu/style.css +115 -0
- package/src/extension/plugins/header/plugin.js +134 -0
- package/src/extension/plugins/header/render-elem.js +31 -0
- package/src/extension/plugins/image/helper.js +50 -0
- package/src/extension/plugins/image/index.js +14 -0
- package/src/extension/plugins/image/menu/image-menu-dialog.js +68 -0
- package/src/extension/plugins/image/menu/image-menu-popover.js +76 -0
- package/src/extension/plugins/image/menu/index.js +61 -0
- package/src/extension/plugins/image/menu/style.css +36 -0
- package/src/extension/plugins/image/plugin.js +23 -0
- package/src/extension/plugins/image/render-element/image-previewer.js +71 -0
- package/src/extension/plugins/image/render-element/index.js +94 -0
- package/src/extension/plugins/image/render-element/style.css +60 -0
- package/src/extension/plugins/index.js +47 -0
- package/src/extension/plugins/link/helper.js +161 -0
- package/src/extension/plugins/link/index.js +14 -0
- package/src/extension/plugins/link/menu/index.js +82 -0
- package/src/extension/plugins/link/menu/link-modal.js +135 -0
- package/src/extension/plugins/link/plugin.js +85 -0
- package/src/extension/plugins/link/render-elem/index.js +69 -0
- package/src/extension/plugins/link/render-elem/link-popover.js +79 -0
- package/src/extension/plugins/link/render-elem/style.css +60 -0
- package/src/extension/plugins/list/constant.js +3 -0
- package/src/extension/plugins/list/helpers.js +53 -0
- package/src/extension/plugins/list/index.js +14 -0
- package/src/extension/plugins/list/menu/index.js +48 -0
- package/src/extension/plugins/list/plugin/index.js +48 -0
- package/src/extension/plugins/list/plugin/insert-break-list.js +25 -0
- package/src/extension/plugins/list/plugin/insert-fragment-list.js +162 -0
- package/src/extension/plugins/list/plugin/normalize-list.js +64 -0
- package/src/extension/plugins/list/plugin/on-tab-handle.js +34 -0
- package/src/extension/plugins/list/queries/index.js +39 -0
- package/src/extension/plugins/list/render-elem/index.js +26 -0
- package/src/extension/plugins/list/render-elem/style.css +6 -0
- package/src/extension/plugins/list/transforms/index.js +23 -0
- package/src/extension/plugins/list/transforms/insert-list-item.js +65 -0
- package/src/extension/plugins/list/transforms/move-list-item-down.js +40 -0
- package/src/extension/plugins/list/transforms/move-list-item-up.js +105 -0
- package/src/extension/plugins/list/transforms/move-list-items-to-list.js +58 -0
- package/src/extension/plugins/list/transforms/move-list-items.js +76 -0
- package/src/extension/plugins/list/transforms/normalize-list-item.js +92 -0
- package/src/extension/plugins/list/transforms/normalize-nested-list.js +31 -0
- package/src/extension/plugins/list/transforms/remove-first-list-item.js +11 -0
- package/src/extension/plugins/list/transforms/transforms-to-list.js +91 -0
- package/src/extension/plugins/list/transforms/unwrap-list.js +44 -0
- package/src/extension/plugins/node-id/constants.js +18 -0
- package/src/extension/plugins/node-id/helpers.js +61 -0
- package/src/extension/plugins/node-id/index.js +7 -0
- package/src/extension/plugins/node-id/with-node-id.js +37 -0
- package/src/extension/plugins/paragraph/helper.js +9 -0
- package/src/extension/plugins/paragraph/index.js +12 -0
- package/src/extension/plugins/paragraph/plugin.js +40 -0
- package/src/extension/plugins/paragraph/render-elem.js +11 -0
- package/src/extension/plugins/table/constant.js +3 -0
- package/src/extension/plugins/table/helper.js +175 -0
- package/src/extension/plugins/table/index.js +15 -0
- package/src/extension/plugins/table/menu/index.js +69 -0
- package/src/extension/plugins/table/menu/style.css +32 -0
- package/src/extension/plugins/table/menu/table-operator.js +101 -0
- package/src/extension/plugins/table/menu/table-size-selector.js +71 -0
- package/src/extension/plugins/table/model.js +69 -0
- package/src/extension/plugins/table/plugin.js +159 -0
- package/src/extension/plugins/table/render-elem/context-menu.js +78 -0
- package/src/extension/plugins/table/render-elem/index.js +157 -0
- package/src/extension/plugins/table/render-elem/style.css +94 -0
- package/src/extension/plugins/table/table-operations.js +162 -0
- package/src/extension/plugins/text-style/helpers.js +38 -0
- package/src/extension/plugins/text-style/index.js +12 -0
- package/src/extension/plugins/text-style/menu/index.js +41 -0
- package/src/extension/plugins/text-style/plugin.js +37 -0
- package/src/extension/plugins/text-style/render-elem.js +45 -0
- package/src/extension/render/render-element.js +82 -0
- package/src/extension/render/render-leaf.js +16 -0
- package/src/extension/toolbar/header-toolbar/index.js +129 -0
- package/src/extension/toolbar/header-toolbar/style.css +41 -0
- package/src/extension/toolbar/index.js +5 -0
- package/src/extension/toolbar/user-help/shortcut-dialog.js +144 -0
- package/src/hooks/use-mathjax.js +44 -0
- package/src/hooks/use-scroll-context.js +14 -0
- package/src/hooks/use-selection-update.js +14 -0
- package/src/index.js +22 -0
- package/src/pages/markdown-editor.js +53 -0
- package/src/pages/markdown-view.js +36 -0
- package/src/pages/rich-markdown-editor.js +95 -0
- package/src/pages/simple-editor.js +52 -0
- package/src/slate-convert/html-to-slate/constants.js +54 -0
- package/src/slate-convert/html-to-slate/helper.js +22 -0
- package/src/slate-convert/html-to-slate/index.js +144 -0
- package/src/slate-convert/html-to-slate/rules/blockquote.js +16 -0
- package/src/slate-convert/html-to-slate/rules/check-list.js +22 -0
- package/src/slate-convert/html-to-slate/rules/code-block.js +91 -0
- package/src/slate-convert/html-to-slate/rules/header.js +18 -0
- package/src/slate-convert/html-to-slate/rules/image.js +18 -0
- package/src/slate-convert/html-to-slate/rules/index.js +23 -0
- package/src/slate-convert/html-to-slate/rules/link.js +24 -0
- package/src/slate-convert/html-to-slate/rules/list.js +52 -0
- package/src/slate-convert/html-to-slate/rules/paragraph.js +16 -0
- package/src/slate-convert/html-to-slate/rules/table.js +37 -0
- package/src/slate-convert/html-to-slate/rules/text.js +63 -0
- package/src/slate-convert/index.js +11 -0
- package/src/slate-convert/md-to-html/index.js +44 -0
- package/src/slate-convert/md-to-html/sanitize-schema.js +41 -0
- package/src/slate-convert/md-to-slate/index.js +42 -0
- package/src/slate-convert/md-to-slate/transform.js +336 -0
- package/src/slate-convert/slate-to-md/index.js +44 -0
- package/src/slate-convert/slate-to-md/transform.js +248 -0
- package/src/utils/common.js +30 -0
- package/src/utils/deserialize-html.js +174 -0
- package/src/utils/dom-utils.js +45 -0
- package/src/utils/event-bus.js +37 -0
- package/src/utils/event-handler.js +36 -0
- package/src/utils/object-utils.js +51 -0
- package/tests/core/constants/index.js +54 -0
- package/tests/core/index.js +11 -0
- package/tests/core/jsx/index.js +9 -0
- package/tests/core/stub-editor/index.js +26 -0
- package/tests/core/utils.js +58 -0
- package/tests/extension/plugins/list/insert-block.test.js +40 -0
- package/tests/extension/plugins/list/insert-fragment-list.test.js +392 -0
- package/tests/extension/plugins/list/toggle-list.test.js +160 -0
- package/tests/extension/plugins/text/text.test.js +29 -0
- package/tests/extension/plugins/text-style/toggle-text-style.test.js +148 -0
- package/tests/slate-convert/html-to-slate/blockquote.test.js +107 -0
- package/tests/slate-convert/html-to-slate/code-block.test.js +32 -0
- package/tests/slate-convert/html-to-slate/header.test.js +56 -0
- package/tests/slate-convert/html-to-slate/link.test.js +77 -0
- package/tests/slate-convert/html-to-slate/list.test.js +190 -0
- package/tests/slate-convert/html-to-slate/paragraph.test.js +40 -0
- package/tests/slate-convert/html-to-slate/text.test.js +131 -0
- package/tests/slate-convert/md-to-html/blockquote.test.js +110 -0
- package/tests/slate-convert/md-to-html/check-list.test.js +19 -0
- package/tests/slate-convert/md-to-html/code-block.test.js +19 -0
- package/tests/slate-convert/md-to-html/header.test.js +20 -0
- package/tests/slate-convert/md-to-html/image.test.js +17 -0
- package/tests/slate-convert/md-to-html/image_reference.test.js +17 -0
- package/tests/slate-convert/md-to-html/link.test.js +15 -0
- package/tests/slate-convert/md-to-html/link_reference.test.js +15 -0
- package/tests/slate-convert/md-to-html/list-ordered.test.js +22 -0
- package/tests/slate-convert/md-to-html/list-unordered.test.js +22 -0
- package/tests/slate-convert/md-to-html/paragraph.test.js +15 -0
- package/tests/slate-convert/md-to-html/table.test.js +29 -0
- package/tests/slate-convert/md-to-html/text_base.test.js +14 -0
- package/tests/slate-convert/md-to-html/text_bold.test.js +14 -0
- package/tests/slate-convert/md-to-html/text_bold_italic.test.js +15 -0
- package/tests/slate-convert/md-to-html/text_code.test.js +14 -0
- package/tests/slate-convert/md-to-html/text_code_bold.test.js +14 -0
- package/tests/slate-convert/md-to-html/text_code_bold_italic.test.js +14 -0
- package/tests/slate-convert/md-to-html/text_code_italic.test.js +14 -0
- package/tests/slate-convert/md-to-html/text_italic.test.js +14 -0
- package/tests/slate-convert/md-to-slate/blockquote.test.js +200 -0
- package/tests/slate-convert/md-to-slate/check-list.test.js +34 -0
- package/tests/slate-convert/md-to-slate/code-block.test.js +32 -0
- package/tests/slate-convert/md-to-slate/header.test.js +49 -0
- package/tests/slate-convert/md-to-slate/image.test.js +31 -0
- package/tests/slate-convert/md-to-slate/link.test.js +30 -0
- package/tests/slate-convert/md-to-slate/list-ordered.test.js +42 -0
- package/tests/slate-convert/md-to-slate/list-unordered.test.js +42 -0
- package/tests/slate-convert/md-to-slate/paragraph.test.js +19 -0
- package/tests/slate-convert/md-to-slate/table.test.js +34 -0
- package/tests/slate-convert/md-to-slate/text_base.test.js +19 -0
- package/tests/slate-convert/md-to-slate/text_bold.test.js +22 -0
- package/tests/slate-convert/md-to-slate/text_bold_italic.test.js +23 -0
- package/tests/slate-convert/md-to-slate/text_code.test.js +22 -0
- package/tests/slate-convert/md-to-slate/text_code_bold.test.js +23 -0
- package/tests/slate-convert/md-to-slate/text_code_bold_italic.test.js +24 -0
- package/tests/slate-convert/md-to-slate/text_code_italic.test.js +23 -0
- package/tests/slate-convert/md-to-slate/text_italic.test.js +22 -0
- package/tests/slate-convert/slate-to-md/blockquote.test.js +416 -0
- package/tests/slate-convert/slate-to-md/check-list.test.js +96 -0
- package/tests/slate-convert/slate-to-md/code-block.test.js +35 -0
- package/tests/slate-convert/slate-to-md/formula.test.js +26 -0
- package/tests/slate-convert/slate-to-md/header.test.js +109 -0
- package/tests/slate-convert/slate-to-md/image.test.js +98 -0
- package/tests/slate-convert/slate-to-md/link.test.js +52 -0
- package/tests/slate-convert/slate-to-md/list-ordered.test.js +87 -0
- package/tests/slate-convert/slate-to-md/list-unordered.test.js +81 -0
- package/tests/slate-convert/slate-to-md/paragraph.test.js +28 -0
- package/tests/slate-convert/slate-to-md/table.test.js +56 -0
- package/tests/slate-convert/slate-to-md/text_base.test.js +28 -0
- package/tests/slate-convert/slate-to-md/text_bold.test.js +36 -0
- package/tests/slate-convert/slate-to-md/text_bold_italic.test.js +42 -0
- package/tests/slate-convert/slate-to-md/text_code.test.js +31 -0
- package/tests/slate-convert/slate-to-md/text_code_bold.test.js +37 -0
- package/tests/slate-convert/slate-to-md/text_code_bold_italic.test.js +43 -0
- package/tests/slate-convert/slate-to-md/text_code_italic.test.js +37 -0
- package/tests/slate-convert/slate-to-md/text_italic.test.js +36 -0
- package/README.md +0 -52
- package/TODO.md +0 -55
- package/dist/assets/css/diff-viewer.css +0 -105
- package/dist/assets/css/formula.css +0 -19
- package/dist/assets/css/history-viewer.css +0 -104
- package/dist/assets/css/image.css +0 -134
- package/dist/assets/css/link.css +0 -7
- package/dist/assets/css/markdown-editor.css +0 -12
- package/dist/assets/css/markdown-viewer.css +0 -69
- package/dist/assets/css/navbar-imgbutton.css +0 -83
- package/dist/assets/css/outline.css +0 -29
- package/dist/assets/css/table.css +0 -57
- package/dist/assets/css/textlink-hovermenu.css +0 -47
- package/dist/assets/css/topbar.css +0 -350
- package/dist/assets/css/tree-view.css +0 -67
- package/dist/assets/editor/seatable-editor.css +0 -77
- package/dist/assets/editor/simple-editor.css +0 -77
- package/dist/components/click-outside.js +0 -46
- package/dist/components/context-menu.js +0 -97
- package/dist/components/dialogs/add-formula-dialog.js +0 -116
- package/dist/components/dialogs/add-image-dialog.js +0 -69
- package/dist/components/dialogs/add-link-dialog.js +0 -133
- package/dist/components/dialogs/shortcut-dialog.js +0 -131
- package/dist/components/error-boundary.js +0 -28
- package/dist/components/load-script/index.js +0 -69
- package/dist/components/loading.js +0 -25
- package/dist/components/menu/index.js +0 -4
- package/dist/components/menu/item.js +0 -49
- package/dist/components/menu/menu.js +0 -38
- package/dist/components/menu/style.css +0 -42
- package/dist/components/modal-portal.js +0 -38
- package/dist/components/outline/index.js +0 -92
- package/dist/components/outline/outline-item.js +0 -58
- package/dist/components/select/_option.js +0 -44
- package/dist/components/select/field-setting.js +0 -106
- package/dist/components/select/index.js +0 -149
- package/dist/components/select/style.css +0 -144
- package/dist/components/svg-icons/check-mark-icon.js +0 -14
- package/dist/components/svg-icons/column-icon.js +0 -17
- package/dist/components/svg-icons/text-icon.js +0 -34
- package/dist/components/text-link-hover-menu/index.js +0 -123
- package/dist/components/toast/alert.js +0 -138
- package/dist/components/toast/index.js +0 -3
- package/dist/components/toast/toast.js +0 -159
- package/dist/components/toast/toastManager.js +0 -139
- package/dist/components/toast/toaster.js +0 -65
- package/dist/components/toolbar/header-list.js +0 -114
- package/dist/components/toolbar/help-group.js +0 -33
- package/dist/components/toolbar/index.js +0 -4
- package/dist/components/toolbar/insert-image.js +0 -106
- package/dist/components/toolbar/insert-table.js +0 -136
- package/dist/components/toolbar/table-group.js +0 -74
- package/dist/components/toolbar/toolbar.js +0 -317
- package/dist/components/toolbar/widgets/button-group.js +0 -24
- package/dist/components/toolbar/widgets/button-item.js +0 -129
- package/dist/components/toolbar/widgets/drop-list.js +0 -88
- package/dist/components/user-help/index.js +0 -179
- package/dist/config.js +0 -15
- package/dist/constants/cell-types.js +0 -29
- package/dist/constants/column.js +0 -4
- package/dist/containers/code-highlight-package.js +0 -14
- package/dist/containers/controller/block-element-controller.js +0 -375
- package/dist/containers/controller/index.js +0 -5
- package/dist/containers/controller/inline-element-controller.js +0 -134
- package/dist/containers/controller/normalize-controller.js +0 -95
- package/dist/containers/controller/shortcut-controller.js +0 -385
- package/dist/containers/controller/void-element-controller.js +0 -9
- package/dist/containers/custom/custom.js +0 -18
- package/dist/containers/custom/get-event-transfer.js +0 -33
- package/dist/containers/custom/getNodesByTypeAtRange.js +0 -57
- package/dist/containers/custom/insertNodes.js +0 -120
- package/dist/containers/custom/is-empty-paragraph.js +0 -9
- package/dist/containers/custom/split-nodes-at-point.js +0 -136
- package/dist/containers/custom/unwrap-node-by-type-at-range.js +0 -70
- package/dist/containers/editor-context.js +0 -85
- package/dist/containers/editor-utils/block-element-utils/blockquote-utils.js +0 -80
- package/dist/containers/editor-utils/block-element-utils/code-utils.js +0 -145
- package/dist/containers/editor-utils/block-element-utils/formula-utils.js +0 -51
- package/dist/containers/editor-utils/block-element-utils/index.js +0 -31
- package/dist/containers/editor-utils/block-element-utils/list-utils.js +0 -395
- package/dist/containers/editor-utils/block-element-utils/table-utils.js +0 -412
- package/dist/containers/editor-utils/clear-format-utils.js +0 -84
- package/dist/containers/editor-utils/common-editor-utils.js +0 -492
- package/dist/containers/editor-utils/inline-element-utils/index.js +0 -95
- package/dist/containers/editor-utils/mark-utils.js +0 -20
- package/dist/containers/editor-utils/range-utils.js +0 -7
- package/dist/containers/editor-utils/selection-utils.js +0 -30
- package/dist/containers/editor-utils/text-utils.js +0 -117
- package/dist/containers/editor-widgets/check-list-item.js +0 -53
- package/dist/containers/editor-widgets/code-block.js +0 -128
- package/dist/containers/editor-widgets/column.js +0 -100
- package/dist/containers/editor-widgets/formula.js +0 -67
- package/dist/containers/editor-widgets/image.js +0 -237
- package/dist/containers/editor-widgets/link.js +0 -9
- package/dist/containers/editor-widgets/table.js +0 -144
- package/dist/containers/element-model/blockquote.js +0 -13
- package/dist/containers/element-model/column.js +0 -19
- package/dist/containers/element-model/image.js +0 -16
- package/dist/containers/element-model/link.js +0 -16
- package/dist/containers/element-model/table.js +0 -57
- package/dist/containers/element-model/text.js +0 -10
- package/dist/containers/render-utils/common-utils.js +0 -80
- package/dist/containers/render-utils/editor-utils.js +0 -133
- package/dist/containers/render-utils/viewer-utils.js +0 -198
- package/dist/containers/viewer-widgets/viewer-formula/index.js +0 -54
- package/dist/containers/viewer-widgets/viewer-image/index.js +0 -70
- package/dist/containers/viewer-widgets/viewer-image/viewer-image.css +0 -3
- package/dist/editors/index.js +0 -78
- package/dist/editors/markdown-editor.js +0 -206
- package/dist/editors/plain-markdown-editor.js +0 -285
- package/dist/editors/seatable-editor.js +0 -210
- package/dist/editors/simple-editor.js +0 -200
- package/dist/index.js +0 -11
- package/dist/setting.local.js +0 -14
- package/dist/utils/deserialize-html.js +0 -260
- package/dist/utils/diff/compare-strings.js +0 -35
- package/dist/utils/diff/diff.js +0 -769
- package/dist/utils/diff/index.js +0 -2
- package/dist/utils/seafile-markdown2html.js +0 -52
- package/dist/utils/slate2markdown/deserialize.js +0 -588
- package/dist/utils/slate2markdown/index.js +0 -3
- package/dist/utils/slate2markdown/serialize.js +0 -366
- package/dist/utils/utils.js +0 -68
- package/dist/viewer/diff-viewer.js +0 -85
- package/dist/viewer/index.js +0 -4
- package/dist/viewer/markdown-viewer.js +0 -121
- package/dist/viewer/seatable-viewer.js +0 -63
- package/dist/viewer/slate-viewer.js +0 -71
- package/public/index.html +0 -45
- package/public/manifest.json +0 -15
- package/public/media/seafile-logo.png +0 -0
- /package/{dist/assets/css/keyboard-shortcuts.css → src/extension/toolbar/user-help/style.css} +0 -0
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import { Node } from 'slate';
|
|
5
|
-
import detectIndent from 'detect-indent';
|
|
6
|
-
import { SfEditor } from '../../custom/custom';
|
|
7
|
-
import getEventTransfer from '../../custom/get-event-transfer';
|
|
8
|
-
import { normailizeSelection } from '../selection-utils';
|
|
9
|
-
var CodeUtils = /*#__PURE__*/function () {
|
|
10
|
-
function CodeUtils(editor) {
|
|
11
|
-
var _this = this;
|
|
12
|
-
_classCallCheck(this, CodeUtils);
|
|
13
|
-
this.isInCodeBlock = function () {
|
|
14
|
-
var block = SfEditor.match(_this.editor, _this.editor.selection.anchor, 'block');
|
|
15
|
-
var blockParent = Node.parent(_this.editor, block[1]);
|
|
16
|
-
if (blockParent.type === 'code_block') return true;
|
|
17
|
-
return false;
|
|
18
|
-
};
|
|
19
|
-
this.getIndent = function (text) {
|
|
20
|
-
return detectIndent(text).indent;
|
|
21
|
-
};
|
|
22
|
-
this.insertIndent = function (indent) {
|
|
23
|
-
SfEditor.insertText(_this.editor, indent, {
|
|
24
|
-
at: _this.editor.selection
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
this.wrapCodeBlock = function () {
|
|
28
|
-
normailizeSelection(_this.editor);
|
|
29
|
-
SfEditor.setNodes(_this.editor, {
|
|
30
|
-
type: 'code_line'
|
|
31
|
-
}, {
|
|
32
|
-
match: 'block',
|
|
33
|
-
at: _this.editor.selection
|
|
34
|
-
});
|
|
35
|
-
SfEditor.wrapNodes(_this.editor, {
|
|
36
|
-
type: 'code_block',
|
|
37
|
-
children: [],
|
|
38
|
-
data: {}
|
|
39
|
-
});
|
|
40
|
-
SfEditor.collapse(_this.editor, {
|
|
41
|
-
edge: 'end'
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
this.splitCodeLine = function () {
|
|
45
|
-
var block = SfEditor.match(_this.editor, _this.editor.selection, 'block');
|
|
46
|
-
var indent = _this.getIndent(Node.text(block[0]));
|
|
47
|
-
SfEditor.splitNodes(_this.editor, {
|
|
48
|
-
split: true,
|
|
49
|
-
always: true,
|
|
50
|
-
at: _this.editor.selection
|
|
51
|
-
});
|
|
52
|
-
_this.insertIndent(indent);
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Todo: unwrap code block
|
|
56
|
-
* split: Is split the code block at selection when unwrap node
|
|
57
|
-
* split = true: Unwrap current code line from code block
|
|
58
|
-
* split = false: Unwrap whole code block
|
|
59
|
-
*/
|
|
60
|
-
this.unwrapCodeBlock = function () {
|
|
61
|
-
var split = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
62
|
-
var codeBlock = SfEditor.match(_this.editor, _this.editor.selection, {
|
|
63
|
-
type: 'code_block'
|
|
64
|
-
});
|
|
65
|
-
var codeBlockPath = codeBlock[1];
|
|
66
|
-
|
|
67
|
-
// unwrap whole code block
|
|
68
|
-
if (!split) {
|
|
69
|
-
codeBlock[0].children.forEach(function (codeLine, index) {
|
|
70
|
-
var path = [].concat(_toConsumableArray(codeBlockPath), [index]);
|
|
71
|
-
SfEditor.setNodes(_this.editor, {
|
|
72
|
-
type: 'paragraph'
|
|
73
|
-
}, {
|
|
74
|
-
at: path
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
} else {
|
|
78
|
-
// unwrap a code line
|
|
79
|
-
SfEditor.setNodes(_this.editor, {
|
|
80
|
-
type: 'paragraph'
|
|
81
|
-
}, {
|
|
82
|
-
at: _this.editor.selection,
|
|
83
|
-
match: 'block'
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
SfEditor.unwrapNodesByTypeAtRange(_this.editor, {
|
|
87
|
-
at: _this.editor.selection,
|
|
88
|
-
split: split,
|
|
89
|
-
match: {
|
|
90
|
-
type: 'code_block'
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
this.editor = editor;
|
|
95
|
-
}
|
|
96
|
-
_createClass(CodeUtils, [{
|
|
97
|
-
key: "pasteContentInCodeBlock",
|
|
98
|
-
value: function pasteContentInCodeBlock(command) {
|
|
99
|
-
var _this2 = this;
|
|
100
|
-
var data = command.data;
|
|
101
|
-
var _getEventTransfer = getEventTransfer(data),
|
|
102
|
-
text = _getEventTransfer.text,
|
|
103
|
-
fragment = _getEventTransfer.fragment,
|
|
104
|
-
type = _getEventTransfer.type;
|
|
105
|
-
if (text.length === 0) return;
|
|
106
|
-
if (type === 'text' || type === 'html') {
|
|
107
|
-
var codeLineFragment = text.split(/\r\n|\n/).map(function (textLine) {
|
|
108
|
-
return {
|
|
109
|
-
type: 'code_line',
|
|
110
|
-
children: [{
|
|
111
|
-
text: textLine
|
|
112
|
-
}]
|
|
113
|
-
};
|
|
114
|
-
});
|
|
115
|
-
SfEditor.insertFragment(this.editor, codeLineFragment);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
fragment.map(function (node, index) {
|
|
119
|
-
if (node.type === 'code_block') {
|
|
120
|
-
node.children.forEach(function (codeLine, index1) {
|
|
121
|
-
if (index1 === 0) {
|
|
122
|
-
SfEditor.insertText(_this2.editor, Node.text(codeLine));
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
SfEditor.insertNodes(_this2.editor, codeLine);
|
|
126
|
-
});
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
if (index === 0) {
|
|
130
|
-
SfEditor.insertText(_this2.editor, Node.text(node));
|
|
131
|
-
} else {
|
|
132
|
-
SfEditor.insertNodes(_this2.editor, {
|
|
133
|
-
type: 'code_line',
|
|
134
|
-
children: [{
|
|
135
|
-
text: Node.text(node)
|
|
136
|
-
}]
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
return true;
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}]);
|
|
143
|
-
return CodeUtils;
|
|
144
|
-
}();
|
|
145
|
-
export default CodeUtils;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import { SfEditor } from '../../custom/custom';
|
|
4
|
-
var FormulaUtils = /*#__PURE__*/function () {
|
|
5
|
-
function FormulaUtils(editor) {
|
|
6
|
-
_classCallCheck(this, FormulaUtils);
|
|
7
|
-
this.editor = editor;
|
|
8
|
-
}
|
|
9
|
-
_createClass(FormulaUtils, [{
|
|
10
|
-
key: "isFormulaActive",
|
|
11
|
-
value: function isFormulaActive() {
|
|
12
|
-
var nodes = SfEditor.match(this.editor, this.editor.selection, {
|
|
13
|
-
type: 'formula'
|
|
14
|
-
});
|
|
15
|
-
if (nodes) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
}, {
|
|
21
|
-
key: "insertFormula",
|
|
22
|
-
value: function insertFormula(data) {
|
|
23
|
-
SfEditor.insertNodes(this.editor, {
|
|
24
|
-
type: 'formula',
|
|
25
|
-
children: [{
|
|
26
|
-
text: ''
|
|
27
|
-
}],
|
|
28
|
-
data: data
|
|
29
|
-
}, {
|
|
30
|
-
at: data.at,
|
|
31
|
-
void: true
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}, {
|
|
35
|
-
key: "setFormula",
|
|
36
|
-
value: function setFormula(data) {
|
|
37
|
-
var formula = data.formula,
|
|
38
|
-
at = data.at;
|
|
39
|
-
SfEditor.setNodes(this.editor, {
|
|
40
|
-
data: {
|
|
41
|
-
formula: formula
|
|
42
|
-
}
|
|
43
|
-
}, {
|
|
44
|
-
at: at,
|
|
45
|
-
void: true
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}]);
|
|
49
|
-
return FormulaUtils;
|
|
50
|
-
}();
|
|
51
|
-
export default FormulaUtils;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
-
import { Editor } from 'slate';
|
|
5
|
-
var BlockElementUtils = /*#__PURE__*/_createClass(function BlockElementUtils(editor) {
|
|
6
|
-
var _this = this;
|
|
7
|
-
_classCallCheck(this, BlockElementUtils);
|
|
8
|
-
this.getActiveHeader = function (types) {
|
|
9
|
-
var selection = _this.editor.selection;
|
|
10
|
-
if (!selection) return false;
|
|
11
|
-
var match = Editor.match(_this.editor, selection, types);
|
|
12
|
-
if (!match) return [{
|
|
13
|
-
type: 'paragraph'
|
|
14
|
-
}];
|
|
15
|
-
return match;
|
|
16
|
-
};
|
|
17
|
-
this.isBlockActive = function (type) {
|
|
18
|
-
var selection = _this.editor.selection;
|
|
19
|
-
if (!selection) return false;
|
|
20
|
-
var _Editor$nodes = Editor.nodes(_this.editor, {
|
|
21
|
-
match: {
|
|
22
|
-
type: type
|
|
23
|
-
}
|
|
24
|
-
}),
|
|
25
|
-
_Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
|
|
26
|
-
match = _Editor$nodes2[0];
|
|
27
|
-
return !!match;
|
|
28
|
-
};
|
|
29
|
-
this.editor = editor;
|
|
30
|
-
});
|
|
31
|
-
export default BlockElementUtils;
|
|
@@ -1,395 +0,0 @@
|
|
|
1
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
6
|
-
import { Node, Range, Path, Editor } from 'slate';
|
|
7
|
-
import { SfEditor } from '../../custom/custom';
|
|
8
|
-
import getEventTransfer from '../../custom/get-event-transfer';
|
|
9
|
-
import { htmlDeserializer } from '../../../utils/deserialize-html';
|
|
10
|
-
import { normailizeSelection } from '../selection-utils';
|
|
11
|
-
var LitsUtils = /*#__PURE__*/_createClass(function LitsUtils(editor) {
|
|
12
|
-
var _this = this;
|
|
13
|
-
_classCallCheck(this, LitsUtils);
|
|
14
|
-
this.unwrapList = function () {
|
|
15
|
-
// defer normalization util the unwrap operartions completed
|
|
16
|
-
SfEditor.withoutNormalizing(_this.editor, function () {
|
|
17
|
-
normailizeSelection(_this.editor);
|
|
18
|
-
// selected list item
|
|
19
|
-
var selectedListItem = _this.getCurrentListItem();
|
|
20
|
-
// first selected item path and node
|
|
21
|
-
var firstSelectedItem = selectedListItem[0];
|
|
22
|
-
var firstSelectedItemPath = firstSelectedItem[1];
|
|
23
|
-
// get selected list and the path of the list
|
|
24
|
-
var selectedListPath = firstSelectedItemPath.slice(0, firstSelectedItemPath.length - 1);
|
|
25
|
-
var selectedList = Node.get(_this.editor, selectedListPath);
|
|
26
|
-
// get the node and path of parent of selected list
|
|
27
|
-
var listParent = Node.parent(_this.editor, selectedListPath);
|
|
28
|
-
var listParentPath = selectedListPath.slice(0, selectedListPath.length - 1);
|
|
29
|
-
|
|
30
|
-
// unwrap list of selected list item
|
|
31
|
-
// if the type of parent of selected list is a list and it should be a list item
|
|
32
|
-
if (listParent.type && listParent.type.includes('list')) {
|
|
33
|
-
// get the path of parent of listParent
|
|
34
|
-
var ancesstorPath = listParentPath.slice(0, listParentPath.length - 1);
|
|
35
|
-
var lastSelectedListItem = selectedListItem.slice(-1)[0];
|
|
36
|
-
var lastSelectedListItemPath = lastSelectedListItem[1];
|
|
37
|
-
var lastSelectedListItemIndex = lastSelectedListItemPath.slice(-1)[0];
|
|
38
|
-
var unSelectedListItem = selectedList.children.slice(selectedListItem.slice(-1)[0][1].slice(-1)[0] + 1);
|
|
39
|
-
|
|
40
|
-
// insert a new list to the last selected list item
|
|
41
|
-
if (!(lastSelectedListItemIndex === selectedList.children.length - 1)) {
|
|
42
|
-
SfEditor.insertNodes(_this.editor, {
|
|
43
|
-
type: selectedList.type,
|
|
44
|
-
children: []
|
|
45
|
-
}, {
|
|
46
|
-
at: [].concat(_toConsumableArray(lastSelectedListItemPath), [lastSelectedListItem[0].children.length])
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// move the unselected list item to the new created list
|
|
51
|
-
unSelectedListItem.forEach(function (item, index) {
|
|
52
|
-
SfEditor.moveNodes(_this.editor, {
|
|
53
|
-
at: [].concat(_toConsumableArray(lastSelectedListItemPath.slice(0, -1)), [lastSelectedListItemIndex + 1]),
|
|
54
|
-
to: [].concat(_toConsumableArray(lastSelectedListItemPath), [lastSelectedListItem[0].children.length, index])
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
var currentItemPath = firstSelectedItemPath;
|
|
58
|
-
var startIndexOfItemInNewList = listParentPath[listParentPath.length - 1] + 1;
|
|
59
|
-
|
|
60
|
-
// move item to outer list by path
|
|
61
|
-
selectedListItem.forEach(function (item, index) {
|
|
62
|
-
var itemTargetPath = [].concat(_toConsumableArray(ancesstorPath), [index + startIndexOfItemInNewList]);
|
|
63
|
-
SfEditor.moveNodes(_this.editor, {
|
|
64
|
-
at: currentItemPath,
|
|
65
|
-
to: itemTargetPath
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
var currentList = Node.get(_this.editor, selectedListPath);
|
|
69
|
-
// delete empty list
|
|
70
|
-
if (!currentList.children[0] || currentList.children[0].type !== 'list_item') {
|
|
71
|
-
SfEditor.removeNodes(_this.editor, {
|
|
72
|
-
at: selectedListPath
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
} else {
|
|
76
|
-
// unwrap list item if the selected list is the outest of the root
|
|
77
|
-
var firstListItemIndex = firstSelectedItem[1].slice(-1)[0];
|
|
78
|
-
var restCount = 0;
|
|
79
|
-
selectedListItem.forEach(function (item) {
|
|
80
|
-
SfEditor.unwrapNodesByTypeAtRange(_this.editor, {
|
|
81
|
-
match: {
|
|
82
|
-
type: 'list_item'
|
|
83
|
-
},
|
|
84
|
-
mode: 'highest',
|
|
85
|
-
at: [].concat(_toConsumableArray(selectedListPath), [firstListItemIndex + restCount])
|
|
86
|
-
});
|
|
87
|
-
restCount += item[0].children.length;
|
|
88
|
-
});
|
|
89
|
-
var startItemRange = Editor.range(_this.editor, [].concat(_toConsumableArray(selectedListPath), [firstListItemIndex]));
|
|
90
|
-
var endItemRange = Editor.range(_this.editor, [].concat(_toConsumableArray(selectedListPath), [firstListItemIndex + restCount - 1]));
|
|
91
|
-
SfEditor.unwrapNodesByTypeAtRange(_this.editor, {
|
|
92
|
-
match: [{
|
|
93
|
-
type: selectedList.type
|
|
94
|
-
}],
|
|
95
|
-
split: true,
|
|
96
|
-
mode: 'highest',
|
|
97
|
-
at: {
|
|
98
|
-
anchor: startItemRange.anchor,
|
|
99
|
-
focus: endItemRange.focus
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
this.wrapList = function (type) {
|
|
106
|
-
normailizeSelection(_this.editor);
|
|
107
|
-
var selection = _this.editor.selection;
|
|
108
|
-
var focusPath = selection.focus.path;
|
|
109
|
-
var anchorPath = selection.anchor.path;
|
|
110
|
-
if (Path.equals(focusPath, anchorPath)) {
|
|
111
|
-
var _SfEditor$match = SfEditor.match(_this.editor, _this.editor.selection, 'block'),
|
|
112
|
-
_SfEditor$match2 = _slicedToArray(_SfEditor$match, 2),
|
|
113
|
-
block = _SfEditor$match2[0],
|
|
114
|
-
path = _SfEditor$match2[1];
|
|
115
|
-
Editor.withoutNormalizing(_this.editor, function (editor) {
|
|
116
|
-
SfEditor.wrapNodes(_this.editor, {
|
|
117
|
-
type: 'list_item',
|
|
118
|
-
children: [block],
|
|
119
|
-
data: {}
|
|
120
|
-
}, {
|
|
121
|
-
at: path
|
|
122
|
-
});
|
|
123
|
-
SfEditor.wrapNodes(_this.editor, {
|
|
124
|
-
type: type,
|
|
125
|
-
children: []
|
|
126
|
-
}, {
|
|
127
|
-
split: false,
|
|
128
|
-
at: path
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
var commonPath = Path.common(focusPath, anchorPath);
|
|
134
|
-
var commonAncestor = Node.get(_this.editor, commonPath);
|
|
135
|
-
var startIndex = anchorPath[commonPath.length];
|
|
136
|
-
var endIndex = focusPath[commonPath.length];
|
|
137
|
-
// get hightest selected commonAncestor block items
|
|
138
|
-
var selectedBlock = commonAncestor.children.slice(startIndex, endIndex + 1);
|
|
139
|
-
Editor.withoutNormalizing(_this.editor, function (editor) {
|
|
140
|
-
selectedBlock.forEach(function (blockItem, index) {
|
|
141
|
-
// wrap block into list
|
|
142
|
-
if (!blockItem.type.includes('list')) {
|
|
143
|
-
SfEditor.wrapNodes(_this.editor, {
|
|
144
|
-
type: 'list_item',
|
|
145
|
-
children: [blockItem],
|
|
146
|
-
data: {}
|
|
147
|
-
}, {
|
|
148
|
-
at: [].concat(_toConsumableArray(commonPath), [startIndex + index])
|
|
149
|
-
});
|
|
150
|
-
SfEditor.wrapNodes(_this.editor, {
|
|
151
|
-
type: type,
|
|
152
|
-
children: []
|
|
153
|
-
}, {
|
|
154
|
-
split: false,
|
|
155
|
-
at: [].concat(_toConsumableArray(commonPath), [startIndex + index])
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
};
|
|
161
|
-
// unwrap list wrap list
|
|
162
|
-
this.getCurrentListItem = function () {
|
|
163
|
-
var selection = _this.editor.selection;
|
|
164
|
-
if (!selection) {
|
|
165
|
-
return [];
|
|
166
|
-
}
|
|
167
|
-
if (Range.isCollapsed(selection)) {
|
|
168
|
-
// get the nearest ancesstor of block, judge if the ancesstor is list item to compat the possibility that
|
|
169
|
-
// a code block or blockquote in a list item
|
|
170
|
-
var block = SfEditor.match(_this.editor, _this.editor.selection, 'block');
|
|
171
|
-
var blockPath = block[1];
|
|
172
|
-
var blockParent = Node.parent(_this.editor, blockPath);
|
|
173
|
-
if (blockParent.type && blockParent.type.indexOf('list') < 0) {
|
|
174
|
-
return [];
|
|
175
|
-
}
|
|
176
|
-
var listItemNodes = SfEditor.nodes(_this.editor, {
|
|
177
|
-
match: {
|
|
178
|
-
type: 'list_item'
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
var listItemNode;
|
|
182
|
-
var _iterator = _createForOfIteratorHelper(listItemNodes),
|
|
183
|
-
_step;
|
|
184
|
-
try {
|
|
185
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
186
|
-
var item = _step.value;
|
|
187
|
-
listItemNode = item;
|
|
188
|
-
}
|
|
189
|
-
} catch (err) {
|
|
190
|
-
_iterator.e(err);
|
|
191
|
-
} finally {
|
|
192
|
-
_iterator.f();
|
|
193
|
-
}
|
|
194
|
-
if (listItemNode) {
|
|
195
|
-
return [listItemNode];
|
|
196
|
-
}
|
|
197
|
-
return [];
|
|
198
|
-
}
|
|
199
|
-
var focusPath = selection.focus.path;
|
|
200
|
-
var anchorPath = selection.anchor.path;
|
|
201
|
-
var _SfEditor$nodes = SfEditor.nodes(_this.editor, {
|
|
202
|
-
match: 'block',
|
|
203
|
-
at: anchorPath
|
|
204
|
-
}),
|
|
205
|
-
_SfEditor$nodes2 = _slicedToArray(_SfEditor$nodes, 1),
|
|
206
|
-
startItem = _SfEditor$nodes2[0];
|
|
207
|
-
var _SfEditor$nodes3 = SfEditor.nodes(_this.editor, {
|
|
208
|
-
match: 'block',
|
|
209
|
-
at: focusPath
|
|
210
|
-
}),
|
|
211
|
-
_SfEditor$nodes4 = _slicedToArray(_SfEditor$nodes3, 1),
|
|
212
|
-
endItem = _SfEditor$nodes4[0];
|
|
213
|
-
var _startItem = _slicedToArray(startItem, 2),
|
|
214
|
-
startPath = _startItem[1];
|
|
215
|
-
var _endItem = _slicedToArray(endItem, 2),
|
|
216
|
-
endPath = _endItem[1];
|
|
217
|
-
if (Path.equals(startPath, endPath)) {
|
|
218
|
-
var _blockParent = Node.parent(_this.editor, startPath);
|
|
219
|
-
if (!_blockParent.type || _blockParent.type.indexOf('list') < 0) {
|
|
220
|
-
return [];
|
|
221
|
-
}
|
|
222
|
-
return [[_blockParent, startPath.slice(0, -1)]];
|
|
223
|
-
}
|
|
224
|
-
var commonPath = Path.common(focusPath, anchorPath);
|
|
225
|
-
var commonAncestor = Node.get(_this.editor, commonPath);
|
|
226
|
-
var nodeType = commonAncestor.type;
|
|
227
|
-
if (nodeType === 'ordered_list' || nodeType === 'unordered_list') {
|
|
228
|
-
var startIndex = anchorPath.slice(commonPath.length)[0];
|
|
229
|
-
var endIndex = focusPath.slice(commonPath.length)[0];
|
|
230
|
-
var selectedListItem = [];
|
|
231
|
-
for (var index = startIndex; index <= endIndex; index++) {
|
|
232
|
-
selectedListItem.push([commonAncestor.children[index], [].concat(_toConsumableArray(commonPath), [index])]);
|
|
233
|
-
}
|
|
234
|
-
return selectedListItem;
|
|
235
|
-
} else if (nodeType === 'list_item') {
|
|
236
|
-
return [[commonAncestor, commonPath]];
|
|
237
|
-
}
|
|
238
|
-
return [];
|
|
239
|
-
};
|
|
240
|
-
this.increaseListDepth = function () {
|
|
241
|
-
var listNodes = SfEditor.nodes(_this.editor, {
|
|
242
|
-
match: {
|
|
243
|
-
type: 'list_item'
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
var node;
|
|
247
|
-
|
|
248
|
-
//get the nearest list_item of current selection
|
|
249
|
-
var _iterator2 = _createForOfIteratorHelper(listNodes),
|
|
250
|
-
_step2;
|
|
251
|
-
try {
|
|
252
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
253
|
-
var item = _step2.value;
|
|
254
|
-
node = item;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// if current list item is the first child of the list return
|
|
258
|
-
} catch (err) {
|
|
259
|
-
_iterator2.e(err);
|
|
260
|
-
} finally {
|
|
261
|
-
_iterator2.f();
|
|
262
|
-
}
|
|
263
|
-
var listItemPath = _toConsumableArray(node[1]);
|
|
264
|
-
if (listItemPath[listItemPath.length - 1] === 0) return;
|
|
265
|
-
var listNode = Node.parent(_this.editor, listItemPath);
|
|
266
|
-
var listItemIndex = listItemPath.pop();
|
|
267
|
-
var listNodePath = listItemPath;
|
|
268
|
-
var previousListItem = listNode.children[listItemIndex - 1];
|
|
269
|
-
var previousListItemPath = [].concat(_toConsumableArray(listNodePath), [listItemIndex - 1]);
|
|
270
|
-
var lastIndex = previousListItem.children.length;
|
|
271
|
-
var newListPath = [].concat(_toConsumableArray(previousListItemPath), [lastIndex]);
|
|
272
|
-
// Deferring normalization list untils after operations completes.
|
|
273
|
-
SfEditor.withoutNormalizing(_this.editor, function () {
|
|
274
|
-
SfEditor.insertNodes(_this.editor, {
|
|
275
|
-
type: listNode.type,
|
|
276
|
-
children: []
|
|
277
|
-
}, {
|
|
278
|
-
at: newListPath,
|
|
279
|
-
split: true
|
|
280
|
-
});
|
|
281
|
-
var newListItemPath = [].concat(_toConsumableArray(newListPath), [0]);
|
|
282
|
-
SfEditor.moveNodes(_this.editor, {
|
|
283
|
-
at: node[1],
|
|
284
|
-
to: newListItemPath
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
};
|
|
288
|
-
this.isInlist = function () {
|
|
289
|
-
var node = _this.getCurrentListItem();
|
|
290
|
-
if (node.length > 0) return true;
|
|
291
|
-
return false;
|
|
292
|
-
};
|
|
293
|
-
/**
|
|
294
|
-
* When copying a sublist, the list item in the list returned by slate contains only one sublis,
|
|
295
|
-
* pasting the list item directly into the list will produce an incorrect list structure,
|
|
296
|
-
* the list item that contains only one list need to flatten
|
|
297
|
-
* Input: {type: 'list', children: [{type: 'list_item', children: [{type: 'list', children[{type: 'list_item'}, ...]}]}]}
|
|
298
|
-
* Output: [{type: 'list_item'},....]
|
|
299
|
-
*/
|
|
300
|
-
this.getNormalizedListItems = function (list) {
|
|
301
|
-
var listItems = [];
|
|
302
|
-
list.children.forEach(function (listItem) {
|
|
303
|
-
var children = listItem.children || [];
|
|
304
|
-
var child = children[0];
|
|
305
|
-
if (child && child.type.includes('_list') && children.length === 1) {
|
|
306
|
-
listItems.push.apply(listItems, _toConsumableArray(_this.getNormalizedListItems(child)));
|
|
307
|
-
} else {
|
|
308
|
-
listItems.push(listItem);
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
return listItems;
|
|
312
|
-
};
|
|
313
|
-
this.pasteContentInList = function (command) {
|
|
314
|
-
var data = command.data;
|
|
315
|
-
var _getEventTransfer = getEventTransfer(data),
|
|
316
|
-
fragment = _getEventTransfer.fragment,
|
|
317
|
-
text = _getEventTransfer.text,
|
|
318
|
-
type = _getEventTransfer.type,
|
|
319
|
-
html = _getEventTransfer.html;
|
|
320
|
-
if (type === 'text' && !fragment) {
|
|
321
|
-
var newText = text.replace(/\r\n|\n/g, ' ');
|
|
322
|
-
SfEditor.insertText(_this.editor, newText);
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
if (type === 'html') {
|
|
326
|
-
fragment = htmlDeserializer(html);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// insert fragment
|
|
330
|
-
if (text.length > 0) {
|
|
331
|
-
var newtext = text.replace(/\r\n|\n/g, ' ');
|
|
332
|
-
var firstBlock = fragment[0];
|
|
333
|
-
var firstBlockType = firstBlock.type;
|
|
334
|
-
var currentItem = _this.getCurrentListItem();
|
|
335
|
-
var currentItemPath = currentItem[0][1];
|
|
336
|
-
var currentItemIndex = currentItemPath[currentItemPath.length - 1];
|
|
337
|
-
var listPath = currentItemPath.slice(0, currentItemPath.length - 1);
|
|
338
|
-
if (firstBlockType === 'ordered_list' || firstBlockType === 'unordered_list') {
|
|
339
|
-
var listItems = _this.getNormalizedListItems(firstBlock);
|
|
340
|
-
listItems.forEach(function (listItem, index) {
|
|
341
|
-
var itemChildren = listItem.children;
|
|
342
|
-
if (itemChildren[0].type.includes('list')) {
|
|
343
|
-
SfEditor.insertNodes(_this.editor, [itemChildren[0]]);
|
|
344
|
-
} else {
|
|
345
|
-
SfEditor.insertFragment(_this.editor, [itemChildren[0]]);
|
|
346
|
-
}
|
|
347
|
-
if (itemChildren.length > 1) {
|
|
348
|
-
var currentListItem = Node.get(_this.editor, [].concat(_toConsumableArray(listPath), [currentItemIndex + index]));
|
|
349
|
-
SfEditor.insertNodes(_this.editor, itemChildren.slice(1), {
|
|
350
|
-
at: [].concat(_toConsumableArray(listPath), [currentItemIndex + index, currentListItem.children.length])
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
if (index < listItems.length - 1) {
|
|
354
|
-
SfEditor.insertNodes(_this.editor, {
|
|
355
|
-
type: 'list_item',
|
|
356
|
-
data: {},
|
|
357
|
-
children: [{
|
|
358
|
-
type: 'paragraph',
|
|
359
|
-
children: [{
|
|
360
|
-
text: ''
|
|
361
|
-
}]
|
|
362
|
-
}]
|
|
363
|
-
}, {
|
|
364
|
-
at: [].concat(_toConsumableArray(listPath), [currentItemIndex + index + 1])
|
|
365
|
-
});
|
|
366
|
-
SfEditor.select(_this.editor, [].concat(_toConsumableArray(listPath), [currentItemIndex + index + 1]));
|
|
367
|
-
}
|
|
368
|
-
});
|
|
369
|
-
if (fragment.length > 1) {
|
|
370
|
-
var outestListItem = SfEditor.match(_this.editor, _this.editor.selection, {
|
|
371
|
-
type: 'list_item'
|
|
372
|
-
});
|
|
373
|
-
var outestListItemPath = outestListItem[1];
|
|
374
|
-
var outestListPath = outestListItemPath.slice(0, outestListItemPath.length - 1);
|
|
375
|
-
var outestListIndex = outestListPath[outestListPath.length - 1];
|
|
376
|
-
var nextBlockPath = [].concat(_toConsumableArray(outestListPath.slice(0, outestListPath.length - 1)), [outestListIndex + 1]);
|
|
377
|
-
SfEditor.insertNodes(_this.editor, fragment.slice(1), {
|
|
378
|
-
at: nextBlockPath
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
} else {
|
|
382
|
-
if (fragment.length === 1 && fragment[0].type === 'paragraph') {
|
|
383
|
-
SfEditor.insertFragment(_this.editor, fragment);
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
// insert text directly when the first block is not a list
|
|
387
|
-
SfEditor.insertText(_this.editor, newtext);
|
|
388
|
-
}
|
|
389
|
-
} else {
|
|
390
|
-
SfEditor.insertFragment(_this.editor, fragment);
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
this.editor = editor;
|
|
394
|
-
});
|
|
395
|
-
export default LitsUtils;
|