@seafile/seafile-editor 0.4.7 → 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 -132
- 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/comment-dialog.css +0 -50
- 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/issue-card.css +0 -43
- 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/comment-dialog.js +0 -97
- 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/markdown-lint.js +0 -72
- 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/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 -280
- 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/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
package/.babelrc
ADDED
package/.eslintignore
ADDED
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"env": {
|
|
3
|
+
"browser": true,
|
|
4
|
+
"es6": true
|
|
5
|
+
},
|
|
6
|
+
"extends": ["react-app", "eslint:recommended"],
|
|
7
|
+
"parser": "@babel/eslint-parser",
|
|
8
|
+
"parserOptions": {
|
|
9
|
+
"ecmaFeatures": {
|
|
10
|
+
"experimentalObjectRestSpread": true,
|
|
11
|
+
"jsx": true
|
|
12
|
+
},
|
|
13
|
+
"sourceType": "module"
|
|
14
|
+
},
|
|
15
|
+
"plugins": ["react"],
|
|
16
|
+
"rules": {
|
|
17
|
+
// enbale console.log
|
|
18
|
+
"no-console": "off",
|
|
19
|
+
// enable declare variable in if
|
|
20
|
+
"no-cond-assign": "off",
|
|
21
|
+
// enable declare variable width var
|
|
22
|
+
"no-var": "off",
|
|
23
|
+
// enable declare in case
|
|
24
|
+
"no-case-declarations": "off",
|
|
25
|
+
// enable redeclare variable
|
|
26
|
+
"no-redeclare": "off",
|
|
27
|
+
"indent": ["warn", 2, {
|
|
28
|
+
"SwitchCase": 1,
|
|
29
|
+
"ignoreComments": false
|
|
30
|
+
}],
|
|
31
|
+
"linebreak-style": ["warn", "unix"],
|
|
32
|
+
"quotes": ["warn", "single"],
|
|
33
|
+
"semi": ["warn", "always"],
|
|
34
|
+
"no-unreachable": "warn",
|
|
35
|
+
"no-class-assign": "warn",
|
|
36
|
+
"no-unused-vars": "warn",
|
|
37
|
+
"no-useless-escape": "off",
|
|
38
|
+
"no-irregular-whitespace": "warn",
|
|
39
|
+
"no-trailing-spaces": "warn",
|
|
40
|
+
"react/jsx-indent": ["warn", 2],
|
|
41
|
+
"eol-last": "error",
|
|
42
|
+
"space-before-function-paren": ["warn", {"named": "never"}],
|
|
43
|
+
"array-bracket-spacing": ["warn", "never"],
|
|
44
|
+
"object-curly-spacing": ["warn", "always"],
|
|
45
|
+
"spaced-comment": "warn",
|
|
46
|
+
"keyword-spacing": ["warn", {"before": true}],
|
|
47
|
+
"space-infix-ops": "error",
|
|
48
|
+
"key-spacing": ["error", { "beforeColon": false }],
|
|
49
|
+
"arrow-spacing": ["error", { "before": true, "after": true }],
|
|
50
|
+
"comma-spacing": ["error", { "before": false, "after": true }]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: Node CI
|
|
2
|
+
|
|
3
|
+
on: [push]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
|
|
10
|
+
strategy:
|
|
11
|
+
matrix:
|
|
12
|
+
node-version: [14.x, 16.x]
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v2
|
|
16
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
17
|
+
uses: actions/setup-node@v2
|
|
18
|
+
with:
|
|
19
|
+
node-version: ${{ matrix.node-version }}
|
|
20
|
+
- name: npm install, build, and test
|
|
21
|
+
run: |
|
|
22
|
+
npm install
|
|
23
|
+
npm test
|
|
24
|
+
env:
|
|
25
|
+
CI: true
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
2
|
+
const TerserPlugin = require('terser-webpack-plugin');
|
|
3
|
+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
|
|
4
|
+
const webpack = require('webpack')
|
|
5
|
+
|
|
6
|
+
module.exports = function getCommon(config) {
|
|
7
|
+
const lessLoader = [
|
|
8
|
+
{
|
|
9
|
+
loader: MiniCssExtractPlugin.loader,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
loader: 'css-loader',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
loader: 'postcss-loader',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
loader: 'less-loader',
|
|
19
|
+
options: {
|
|
20
|
+
modifyVars: {
|
|
21
|
+
'so-prefix': process.env.SO_PREFIX || 'so',
|
|
22
|
+
...config.modifyVars,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
]
|
|
27
|
+
const jsLoaders = [
|
|
28
|
+
{
|
|
29
|
+
loader: 'babel-loader',
|
|
30
|
+
options: {
|
|
31
|
+
cacheDirectory: true,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
]
|
|
35
|
+
const plugins = [
|
|
36
|
+
new MiniCssExtractPlugin({
|
|
37
|
+
filename: `${config.extractTextPluginPath}`,
|
|
38
|
+
}),
|
|
39
|
+
new webpack.DefinePlugin({
|
|
40
|
+
'process.env': {
|
|
41
|
+
SO_PREFIX: JSON.stringify(process.env.SO_PREFIX || ''),
|
|
42
|
+
CSS_MODULE: !!process.env.LOCAL_IDENT_NAME,
|
|
43
|
+
LOG_ENV: JSON.stringify(process.env.LOG_ENV || ''),
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
]
|
|
47
|
+
if (config.IGNORE_LESS) {
|
|
48
|
+
jsLoaders.splice(0, 0, { loader: 'remove-less-loader' })
|
|
49
|
+
plugins.push(
|
|
50
|
+
new webpack.IgnorePlugin({
|
|
51
|
+
resourceRegExp: /\.less$/,
|
|
52
|
+
})
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
optimization: {
|
|
57
|
+
minimizer: [
|
|
58
|
+
new TerserPlugin({
|
|
59
|
+
terserOptions: {
|
|
60
|
+
parse: {
|
|
61
|
+
// We want terser to parse ecma 8 code. However, we don't want it
|
|
62
|
+
// to apply any minification steps that turns valid ecma 5 code
|
|
63
|
+
// into invalid ecma 5 code. This is why the 'compress' and 'output'
|
|
64
|
+
// sections only apply transformations that are ecma 5 safe
|
|
65
|
+
// https://github.com/facebook/create-react-app/pull/4234
|
|
66
|
+
ecma: 8,
|
|
67
|
+
},
|
|
68
|
+
compress: {
|
|
69
|
+
ecma: 5,
|
|
70
|
+
warnings: false,
|
|
71
|
+
// Disabled because of an issue with Uglify breaking seemingly valid code:
|
|
72
|
+
// https://github.com/facebook/create-react-app/issues/2376
|
|
73
|
+
// Pending further investigation:
|
|
74
|
+
// https://github.com/mishoo/UglifyJS2/issues/2011
|
|
75
|
+
comparisons: false,
|
|
76
|
+
// Disabled because of an issue with Terser breaking valid code:
|
|
77
|
+
// https://github.com/facebook/create-react-app/issues/5250
|
|
78
|
+
// Pending further investigation:
|
|
79
|
+
// https://github.com/terser-js/terser/issues/120
|
|
80
|
+
inline: 2,
|
|
81
|
+
},
|
|
82
|
+
mangle: {
|
|
83
|
+
safari10: true,
|
|
84
|
+
},
|
|
85
|
+
output: {
|
|
86
|
+
ecma: 5,
|
|
87
|
+
comments: false,
|
|
88
|
+
// Turned on because emoji and regex is not minified properly using default
|
|
89
|
+
// https://github.com/facebook/create-react-app/issues/2488
|
|
90
|
+
ascii_only: true,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
}),
|
|
94
|
+
new CssMinimizerPlugin({}),
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
externals: config.externals,
|
|
98
|
+
resolve: {
|
|
99
|
+
alias: config.alias,
|
|
100
|
+
extensions: ['.js', '.json', '.jsx'],
|
|
101
|
+
},
|
|
102
|
+
resolveLoader: {
|
|
103
|
+
modules: ['node_modules'],
|
|
104
|
+
},
|
|
105
|
+
module: {
|
|
106
|
+
rules: [
|
|
107
|
+
{
|
|
108
|
+
test: /\.(js|jsx|ts|tsx)$/,
|
|
109
|
+
exclude: [/node_modules/],
|
|
110
|
+
use: jsLoaders,
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
{
|
|
114
|
+
test: /\.less$/,
|
|
115
|
+
use: config.DEV ? 'ignore-loader' : lessLoader,
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
{
|
|
119
|
+
test: /\.css$/,
|
|
120
|
+
use: ['style-loader', 'css-loader'],
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
{
|
|
124
|
+
test: /\.(png|jpg|jpeg|gif)$/,
|
|
125
|
+
use: [
|
|
126
|
+
{
|
|
127
|
+
loader: 'url-loader',
|
|
128
|
+
options: {
|
|
129
|
+
limit: 10000,
|
|
130
|
+
name: './images/[name].[ext]',
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
{
|
|
137
|
+
test: /\.(ttf|eot|woff|woff2|otf|svg)/,
|
|
138
|
+
use: [
|
|
139
|
+
{
|
|
140
|
+
loader: 'file-loader',
|
|
141
|
+
options: {
|
|
142
|
+
name: './font/[name].[ext]',
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
{
|
|
149
|
+
test: /\.md$/,
|
|
150
|
+
use: 'raw-loader',
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
plugins,
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const webpack = require('webpack')
|
|
2
|
+
const { merge } = require('webpack-merge')
|
|
3
|
+
const config = require('../config')
|
|
4
|
+
const common = require('./config.common')
|
|
5
|
+
const cssConf = require('./utils/theme.css')
|
|
6
|
+
|
|
7
|
+
function getEntry(entry) {
|
|
8
|
+
const newEntry = {}
|
|
9
|
+
Object.keys(entry).forEach(key => {
|
|
10
|
+
newEntry[key] = [
|
|
11
|
+
'webpack/hot/dev-server.js',
|
|
12
|
+
`webpack-dev-server/client/index.js?hot=true&live-reload=true&hostname=127.0.0.1&port=${config.dev.webpackPort}`,
|
|
13
|
+
entry[key],
|
|
14
|
+
]
|
|
15
|
+
})
|
|
16
|
+
return newEntry
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getPublishPath() {
|
|
20
|
+
if (config.dev.publishPort === 80) return 'http://localhost/'
|
|
21
|
+
return `http://localhost:${config.dev.publishPort}/`
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const jsConfig = merge(common({ ...config.webpack, DEV: true }), {
|
|
25
|
+
devtool: config.webpack.devtool,
|
|
26
|
+
entry: getEntry(config.webpack.entry),
|
|
27
|
+
output: {
|
|
28
|
+
filename: '[name].js',
|
|
29
|
+
publicPath: getPublishPath(),
|
|
30
|
+
libraryTarget: 'umd',
|
|
31
|
+
},
|
|
32
|
+
mode: 'development',
|
|
33
|
+
plugins: [new webpack.HotModuleReplacementPlugin()],
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const cssConfig = config.themes.map(name =>
|
|
37
|
+
cssConf({
|
|
38
|
+
mode: 'development',
|
|
39
|
+
hot: true,
|
|
40
|
+
name,
|
|
41
|
+
entry: [
|
|
42
|
+
`webpack-dev-server/client/index.js?hot=true&live-reload=true&hostname=127.0.0.1&port=${config.dev.webpackPort}`,
|
|
43
|
+
'webpack/hot/only-dev-server',
|
|
44
|
+
'./site/index.js',
|
|
45
|
+
],
|
|
46
|
+
output: { publicPath: getPublishPath() },
|
|
47
|
+
clean: false,
|
|
48
|
+
filename: '__css_hot_loader.js',
|
|
49
|
+
prefix: '',
|
|
50
|
+
})
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
module.exports = [jsConfig]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// This is a custom Jest transformer turning style imports into empty objects.
|
|
4
|
+
// http://facebook.github.io/jest/docs/en/webpack.html
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
process() {
|
|
8
|
+
return {
|
|
9
|
+
code: `module.exports = {};`,
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
getCacheKey() {
|
|
13
|
+
// The output is always the same.
|
|
14
|
+
return 'cssTransform';
|
|
15
|
+
},
|
|
16
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const camelcase = require('camelcase');
|
|
5
|
+
|
|
6
|
+
// This is a custom Jest transformer turning file imports into filenames.
|
|
7
|
+
// http://facebook.github.io/jest/docs/en/webpack.html
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
process(src, filename) {
|
|
11
|
+
const assetFilename = JSON.stringify(path.basename(filename));
|
|
12
|
+
|
|
13
|
+
if (filename.match(/\.svg$/)) {
|
|
14
|
+
// Based on how SVGR generates a component name:
|
|
15
|
+
// https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
|
|
16
|
+
const pascalCaseFileName = camelcase(path.parse(filename).name, {
|
|
17
|
+
pascalCase: true,
|
|
18
|
+
});
|
|
19
|
+
const componentName = `Svg${pascalCaseFileName}`;
|
|
20
|
+
return `const React = require('react');
|
|
21
|
+
module.exports = {
|
|
22
|
+
__esModule: true,
|
|
23
|
+
default: ${assetFilename},
|
|
24
|
+
ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
|
|
25
|
+
return {
|
|
26
|
+
$$typeof: Symbol.for('react.element'),
|
|
27
|
+
type: 'svg',
|
|
28
|
+
ref: ref,
|
|
29
|
+
key: null,
|
|
30
|
+
props: Object.assign({}, props, {
|
|
31
|
+
children: ${assetFilename}
|
|
32
|
+
})
|
|
33
|
+
};
|
|
34
|
+
}),
|
|
35
|
+
};`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return `module.exports = ${assetFilename};`;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
|
|
2
|
+
const CleanWebpackPlugin = require('clean-webpack-plugin')
|
|
3
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
4
|
+
const webpack = require('webpack')
|
|
5
|
+
const config = require('../../config')
|
|
6
|
+
|
|
7
|
+
const lessLoader = (name, hot) => {
|
|
8
|
+
const loaders = [
|
|
9
|
+
{
|
|
10
|
+
loader: MiniCssExtractPlugin.loader,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
loader: 'css-loader',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
loader: 'postcss-loader',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
loader: 'less-loader',
|
|
20
|
+
options: {
|
|
21
|
+
modifyVars: {
|
|
22
|
+
'so-prefix': process.env.SO_PREFIX || 'so',
|
|
23
|
+
'so-theme': name,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
]
|
|
28
|
+
if (hot) loaders.splice(0, 0, { loader: 'css-hot-loader' })
|
|
29
|
+
return loaders
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const jsLoaders = [
|
|
33
|
+
{
|
|
34
|
+
loader: 'babel-loader',
|
|
35
|
+
options: {
|
|
36
|
+
cacheDirectory: true,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
module.exports = function({
|
|
42
|
+
name,
|
|
43
|
+
hot,
|
|
44
|
+
entry,
|
|
45
|
+
output,
|
|
46
|
+
clean,
|
|
47
|
+
prefix = 'theme',
|
|
48
|
+
mode = 'production',
|
|
49
|
+
filename = '_temp.file',
|
|
50
|
+
}) {
|
|
51
|
+
const conf = {
|
|
52
|
+
mode,
|
|
53
|
+
optimization: {
|
|
54
|
+
minimizer: [new CssMinimizerPlugin({})]
|
|
55
|
+
},
|
|
56
|
+
entry,
|
|
57
|
+
resolveLoader: {
|
|
58
|
+
modules: ['node_modules', 'webpack/loaders'],
|
|
59
|
+
},
|
|
60
|
+
resolve: {
|
|
61
|
+
alias: config.webpack.alias,
|
|
62
|
+
},
|
|
63
|
+
output: {
|
|
64
|
+
...output,
|
|
65
|
+
filename,
|
|
66
|
+
},
|
|
67
|
+
module: {
|
|
68
|
+
rules: [
|
|
69
|
+
{
|
|
70
|
+
test: /\.(js|jsx|ts|tsx)$/,
|
|
71
|
+
exclude: [/node_modules/],
|
|
72
|
+
use: jsLoaders,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
test: /\.less$/,
|
|
76
|
+
use: lessLoader(name, hot),
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
test: /\.css$/,
|
|
80
|
+
use: ['style-loader', 'css-loader'],
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
plugins: [
|
|
85
|
+
new MiniCssExtractPlugin({
|
|
86
|
+
filename: prefix ? `${prefix}.${name}.css` : `${name}.css`,
|
|
87
|
+
}),
|
|
88
|
+
],
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (clean) {
|
|
92
|
+
conf.plugins.push(
|
|
93
|
+
new CleanWebpackPlugin({
|
|
94
|
+
verbose: true,
|
|
95
|
+
protectWebpackAssets: false,
|
|
96
|
+
cleanAfterEveryBuildPatterns: ['_temp.file'],
|
|
97
|
+
cleanOnceBeforeBuildPatterns: [],
|
|
98
|
+
})
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
if (hot) conf.plugins.push(new webpack.HotModuleReplacementPlugin())
|
|
102
|
+
return conf
|
|
103
|
+
}
|
package/config.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
|
|
4
|
+
const versions = {};
|
|
5
|
+
['react', 'react-dom', 'prop-types'].forEach(lib => {
|
|
6
|
+
const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'node_modules/', lib, 'package.json')))
|
|
7
|
+
versions[lib] = pkg.version
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
appName: '@seafile/seafile-editor',
|
|
12
|
+
dev: {
|
|
13
|
+
publishPort: 4000,
|
|
14
|
+
webpackPort: 4001,
|
|
15
|
+
scriptPath: '/*.*',
|
|
16
|
+
scripts: [
|
|
17
|
+
`/react@${versions['react']}/umd/react.production.min.js`,
|
|
18
|
+
`/react-dom@${versions['react-dom']}/umd/react-dom.production.min.js`,
|
|
19
|
+
`/prop-types@${versions['prop-types']}/prop-types.min.js`,
|
|
20
|
+
],
|
|
21
|
+
styles: [
|
|
22
|
+
// '/prism/1.15.0/themes/prism.min.css',
|
|
23
|
+
'public/media/seafile-ui.css',
|
|
24
|
+
'public/media/seafile-editor-font.css'
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
themes: ['default'],
|
|
28
|
+
webpack: {
|
|
29
|
+
entry: {
|
|
30
|
+
app: './site/index.js',
|
|
31
|
+
},
|
|
32
|
+
output: {
|
|
33
|
+
chunkFileName: '[name].[chunkhash].js',
|
|
34
|
+
filename: '[name].js'
|
|
35
|
+
},
|
|
36
|
+
alias: {
|
|
37
|
+
'@seafile/seafile-editor': path.resolve(__dirname, 'src')
|
|
38
|
+
},
|
|
39
|
+
devtool: 'cheap-module-source-map',
|
|
40
|
+
externals: {
|
|
41
|
+
react: {
|
|
42
|
+
root: 'React',
|
|
43
|
+
commonjs2: 'react',
|
|
44
|
+
commonjs: 'react',
|
|
45
|
+
amd: 'react',
|
|
46
|
+
},
|
|
47
|
+
'react-dom': {
|
|
48
|
+
root: 'ReactDOM',
|
|
49
|
+
commonjs2: 'react-dom',
|
|
50
|
+
commonjs: 'react-dom',
|
|
51
|
+
amd: 'react-dom',
|
|
52
|
+
},
|
|
53
|
+
'prop-types': {
|
|
54
|
+
root: 'PropTypes',
|
|
55
|
+
commonjs2: 'prop-types',
|
|
56
|
+
commonjs: 'prop-types',
|
|
57
|
+
amd: 'prop-types',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
}
|
package/dev-server.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
const axios = require('axios')
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const Koa = require('koa')
|
|
4
|
+
const send = require('koa-send')
|
|
5
|
+
const Router = require('koa-router')
|
|
6
|
+
const cors = require('koa2-cors');
|
|
7
|
+
const webpack = require('webpack')
|
|
8
|
+
const WebpackDevServer = require('webpack-dev-server')
|
|
9
|
+
|
|
10
|
+
const { version } = require('./package.json')
|
|
11
|
+
const config = require('./config')
|
|
12
|
+
const webpackConfig = require('./config/config.dev')
|
|
13
|
+
const ejs = require('./scripts/ejs')
|
|
14
|
+
|
|
15
|
+
// error handle
|
|
16
|
+
process.on('unhandledRejection', err => {
|
|
17
|
+
throw err;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
process.on('uncaughtException', (err, origin) => {
|
|
21
|
+
console.log(err);
|
|
22
|
+
throw err;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
['SIGINT', 'SIGTERM'].forEach(function(sig) {
|
|
26
|
+
process.on(sig, function() {
|
|
27
|
+
process.exit();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// webpack server ===========================================
|
|
32
|
+
|
|
33
|
+
const serverConfig = {
|
|
34
|
+
hot: true,
|
|
35
|
+
client: false,
|
|
36
|
+
host: '127.0.0.1',
|
|
37
|
+
static: {
|
|
38
|
+
directory: path.join(__dirname, 'public'),
|
|
39
|
+
},
|
|
40
|
+
port: config.dev.webpackPort,
|
|
41
|
+
// noInfo: true,
|
|
42
|
+
headers: {
|
|
43
|
+
'Access-Control-Allow-Origin': '*',
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const webpackServer = new WebpackDevServer(serverConfig, webpack(webpackConfig));
|
|
48
|
+
|
|
49
|
+
webpackServer.startCallback(() => {
|
|
50
|
+
console.log(`webpack server is running on http://127.0.0.1:${config.dev.webpackPort}`)
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
// dev server ================================================
|
|
55
|
+
const app = new Koa()
|
|
56
|
+
const router = new Router()
|
|
57
|
+
|
|
58
|
+
// use devlopment version React
|
|
59
|
+
router.get('**/react.production.min.js', async ctx => {
|
|
60
|
+
await send(ctx, 'node_modules/react/umd/react.development.js')
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
router.get('**/react-dom.production.min.js', async ctx => {
|
|
64
|
+
await send(ctx, 'node_modules/react-dom/umd/react-dom.development.js')
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
router.get('**/prop-types.min.js', async ctx => {
|
|
68
|
+
await send(ctx, 'node_modules/prop-types/prop-types.js')
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
router.get('/public/**', async ctx => {
|
|
72
|
+
await send(ctx, `${ctx.path}`);
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
router.get('/images/**', async ctx => {
|
|
76
|
+
await send(ctx, `site/${ctx.path}`)
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
// dev code proxy: webpack packaged file
|
|
80
|
+
router.get(config.dev.scriptPath, async (ctx, next) => {
|
|
81
|
+
// console.log(ctx.url)
|
|
82
|
+
let url = ctx.url.split('/')
|
|
83
|
+
url = url[url.length - 1]
|
|
84
|
+
if (
|
|
85
|
+
url.indexOf('seafile-editor') > -1 ||
|
|
86
|
+
url.indexOf('seafile-viewer') > -1 ||
|
|
87
|
+
url.indexOf('wiki-viewer') > -1
|
|
88
|
+
) {
|
|
89
|
+
await next()
|
|
90
|
+
} else if (url.endsWith('.Form') || url.endsWith('.List')) {
|
|
91
|
+
await next()
|
|
92
|
+
} else {
|
|
93
|
+
const options = {
|
|
94
|
+
url: `http://127.0.0.1:${config.dev.webpackPort}/${url}`,
|
|
95
|
+
method: 'GET',
|
|
96
|
+
}
|
|
97
|
+
const result = await axios(options);
|
|
98
|
+
ctx.body = result.data;
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
// react-hot-loader proxy
|
|
103
|
+
router.get('/*.hot-update.json?', async ctx => {
|
|
104
|
+
const options = {
|
|
105
|
+
url: `http://127.0.0.1:${config.dev.webpackPort}/${ctx.url}`,
|
|
106
|
+
method: 'GET',
|
|
107
|
+
}
|
|
108
|
+
ctx.set('Access-Control-Allow-Origin', '*')
|
|
109
|
+
const result = await axios(options);
|
|
110
|
+
ctx.body = result.data;
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
router.get('/*', async ctx => {
|
|
114
|
+
// if (ctx.url === '/') ctx.redirect('/index')
|
|
115
|
+
|
|
116
|
+
const prepath = config.dev.scriptPath.replace('**', version)
|
|
117
|
+
|
|
118
|
+
const scripts = [
|
|
119
|
+
...(config.dev.scripts || []),
|
|
120
|
+
...Object.keys(config.webpack.entry).map(s => prepath.replace('*.*', `${s}.js`)),
|
|
121
|
+
// '__css_hot_loader.js',
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
const styles = config.dev.styles || []
|
|
125
|
+
ctx.type = 'text/html; charest=utf-8'
|
|
126
|
+
ctx.body = await ejs.renderFile(`./site/index.html`, {
|
|
127
|
+
scripts,
|
|
128
|
+
env: 'development',
|
|
129
|
+
appName: config.appName,
|
|
130
|
+
styles,
|
|
131
|
+
description: '',
|
|
132
|
+
icoUrl: 'public/favicon.ico',
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
// if (config.proxy) config.proxy(router)
|
|
137
|
+
|
|
138
|
+
app.use(cors())
|
|
139
|
+
app.use(router.routes())
|
|
140
|
+
|
|
141
|
+
app.listen(`${config.dev.publishPort}`, () => {
|
|
142
|
+
const ps = config.dev.publishPort === 80 ? '' : `:${config.dev.publishPort}`
|
|
143
|
+
console.log(`server running on http://127.0.0.1${ps}/`)
|
|
144
|
+
})
|
|
145
|
+
|