@ecomcx/ecomweb-editor 0.0.0-stage → 1.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -2
- package/node_modules/@floating-ui/core/LICENSE +20 -0
- package/node_modules/@floating-ui/core/README.md +4 -0
- package/node_modules/@floating-ui/core/dist/floating-ui.core.browser.min.mjs +1 -0
- package/node_modules/@floating-ui/core/dist/floating-ui.core.browser.mjs +1164 -0
- package/node_modules/@floating-ui/core/dist/floating-ui.core.d.mts +535 -0
- package/node_modules/@floating-ui/core/dist/floating-ui.core.d.ts +535 -0
- package/node_modules/@floating-ui/core/dist/floating-ui.core.esm.js +1038 -0
- package/node_modules/@floating-ui/core/dist/floating-ui.core.mjs +1038 -0
- package/node_modules/@floating-ui/core/dist/floating-ui.core.umd.js +1183 -0
- package/node_modules/@floating-ui/core/dist/floating-ui.core.umd.min.js +1 -0
- package/node_modules/@floating-ui/core/package.json +63 -0
- package/node_modules/@floating-ui/dom/LICENSE +20 -0
- package/node_modules/@floating-ui/dom/README.md +4 -0
- package/node_modules/@floating-ui/dom/dist/floating-ui.dom.browser.min.mjs +1 -0
- package/node_modules/@floating-ui/dom/dist/floating-ui.dom.browser.mjs +964 -0
- package/node_modules/@floating-ui/dom/dist/floating-ui.dom.d.mts +362 -0
- package/node_modules/@floating-ui/dom/dist/floating-ui.dom.d.ts +362 -0
- package/node_modules/@floating-ui/dom/dist/floating-ui.dom.esm.js +789 -0
- package/node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs +789 -0
- package/node_modules/@floating-ui/dom/dist/floating-ui.dom.umd.js +983 -0
- package/node_modules/@floating-ui/dom/dist/floating-ui.dom.umd.min.js +1 -0
- package/node_modules/@floating-ui/dom/package.json +72 -0
- package/node_modules/@floating-ui/utils/LICENSE +20 -0
- package/node_modules/@floating-ui/utils/README.md +4 -0
- package/node_modules/@floating-ui/utils/dist/floating-ui.utils.d.mts +105 -0
- package/node_modules/@floating-ui/utils/dist/floating-ui.utils.d.ts +105 -0
- package/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.d.mts +47 -0
- package/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.d.ts +47 -0
- package/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.esm.js +165 -0
- package/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs +165 -0
- package/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.umd.js +192 -0
- package/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.umd.min.js +1 -0
- package/node_modules/@floating-ui/utils/dist/floating-ui.utils.esm.js +136 -0
- package/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs +136 -0
- package/node_modules/@floating-ui/utils/dist/floating-ui.utils.umd.js +167 -0
- package/node_modules/@floating-ui/utils/dist/floating-ui.utils.umd.min.js +1 -0
- package/node_modules/@floating-ui/utils/dom/floating-ui.utils.dom.d.ts +47 -0
- package/node_modules/@floating-ui/utils/dom/floating-ui.utils.dom.esm.js +165 -0
- package/node_modules/@floating-ui/utils/dom/floating-ui.utils.dom.umd.js +192 -0
- package/node_modules/@floating-ui/utils/dom/package.json +6 -0
- package/node_modules/@floating-ui/utils/package.json +70 -0
- package/node_modules/@tiptap/core/LICENSE.md +21 -0
- package/node_modules/@tiptap/core/README.md +18 -0
- package/node_modules/@tiptap/core/dist/index.cjs +8463 -0
- package/node_modules/@tiptap/core/dist/index.d.cts +5798 -0
- package/node_modules/@tiptap/core/dist/index.d.ts +5797 -0
- package/node_modules/@tiptap/core/dist/index.js +8288 -0
- package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.cjs +70 -0
- package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.d.cts +28 -0
- package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.d.ts +28 -0
- package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js +64 -0
- package/node_modules/@tiptap/core/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/node_modules/@tiptap/core/jsx-dev-runtime/index.cjs +1 -0
- package/node_modules/@tiptap/core/jsx-dev-runtime/index.d.cts +1 -0
- package/node_modules/@tiptap/core/jsx-dev-runtime/index.d.ts +1 -0
- package/node_modules/@tiptap/core/jsx-dev-runtime/index.js +1 -0
- package/node_modules/@tiptap/core/jsx-runtime/index.cjs +1 -0
- package/node_modules/@tiptap/core/jsx-runtime/index.d.cts +1 -0
- package/node_modules/@tiptap/core/jsx-runtime/index.d.ts +1 -0
- package/node_modules/@tiptap/core/jsx-runtime/index.js +1 -0
- package/node_modules/@tiptap/core/package.json +74 -0
- package/node_modules/@tiptap/extension-blockquote/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-blockquote/README.md +18 -0
- package/node_modules/@tiptap/extension-blockquote/dist/index.cjs +132 -0
- package/node_modules/@tiptap/extension-blockquote/dist/index.d.cts +40 -0
- package/node_modules/@tiptap/extension-blockquote/dist/index.d.ts +40 -0
- package/node_modules/@tiptap/extension-blockquote/dist/index.js +126 -0
- package/node_modules/@tiptap/extension-blockquote/package.json +52 -0
- package/node_modules/@tiptap/extension-bold/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-bold/README.md +18 -0
- package/node_modules/@tiptap/extension-bold/dist/index.cjs +117 -0
- package/node_modules/@tiptap/extension-bold/dist/index.d.cts +52 -0
- package/node_modules/@tiptap/extension-bold/dist/index.d.ts +52 -0
- package/node_modules/@tiptap/extension-bold/dist/index.js +108 -0
- package/node_modules/@tiptap/extension-bold/package.json +50 -0
- package/node_modules/@tiptap/extension-bubble-menu/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-bubble-menu/README.md +18 -0
- package/node_modules/@tiptap/extension-bubble-menu/dist/index.cjs +333 -0
- package/node_modules/@tiptap/extension-bubble-menu/dist/index.d.cts +170 -0
- package/node_modules/@tiptap/extension-bubble-menu/dist/index.d.ts +170 -0
- package/node_modules/@tiptap/extension-bubble-menu/dist/index.js +326 -0
- package/node_modules/@tiptap/extension-bubble-menu/package.json +56 -0
- package/node_modules/@tiptap/extension-bullet-list/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-bullet-list/README.md +18 -0
- package/node_modules/@tiptap/extension-bullet-list/dist/index.cjs +17 -0
- package/node_modules/@tiptap/extension-bullet-list/dist/index.d.cts +2 -0
- package/node_modules/@tiptap/extension-bullet-list/dist/index.d.ts +2 -0
- package/node_modules/@tiptap/extension-bullet-list/dist/index.js +7 -0
- package/node_modules/@tiptap/extension-bullet-list/package.json +50 -0
- package/node_modules/@tiptap/extension-code/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-code/README.md +18 -0
- package/node_modules/@tiptap/extension-code/dist/index.cjs +136 -0
- package/node_modules/@tiptap/extension-code/dist/index.d.cts +60 -0
- package/node_modules/@tiptap/extension-code/dist/index.d.ts +60 -0
- package/node_modules/@tiptap/extension-code/dist/index.js +127 -0
- package/node_modules/@tiptap/extension-code/package.json +50 -0
- package/node_modules/@tiptap/extension-code-block/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-code-block/README.md +18 -0
- package/node_modules/@tiptap/extension-code-block/dist/index.cjs +255 -0
- package/node_modules/@tiptap/extension-code-block/dist/index.d.cts +84 -0
- package/node_modules/@tiptap/extension-code-block/dist/index.d.ts +84 -0
- package/node_modules/@tiptap/extension-code-block/dist/index.js +248 -0
- package/node_modules/@tiptap/extension-code-block/package.json +52 -0
- package/node_modules/@tiptap/extension-document/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-document/README.md +18 -0
- package/node_modules/@tiptap/extension-document/dist/index.cjs +26 -0
- package/node_modules/@tiptap/extension-document/dist/index.d.cts +10 -0
- package/node_modules/@tiptap/extension-document/dist/index.d.ts +10 -0
- package/node_modules/@tiptap/extension-document/dist/index.js +22 -0
- package/node_modules/@tiptap/extension-document/package.json +50 -0
- package/node_modules/@tiptap/extension-dropcursor/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-dropcursor/README.md +18 -0
- package/node_modules/@tiptap/extension-dropcursor/dist/index.cjs +17 -0
- package/node_modules/@tiptap/extension-dropcursor/dist/index.d.cts +2 -0
- package/node_modules/@tiptap/extension-dropcursor/dist/index.d.ts +2 -0
- package/node_modules/@tiptap/extension-dropcursor/dist/index.js +7 -0
- package/node_modules/@tiptap/extension-dropcursor/package.json +50 -0
- package/node_modules/@tiptap/extension-floating-menu/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-floating-menu/README.md +18 -0
- package/node_modules/@tiptap/extension-floating-menu/dist/index.cjs +272 -0
- package/node_modules/@tiptap/extension-floating-menu/dist/index.d.cts +180 -0
- package/node_modules/@tiptap/extension-floating-menu/dist/index.d.ts +180 -0
- package/node_modules/@tiptap/extension-floating-menu/dist/index.js +265 -0
- package/node_modules/@tiptap/extension-floating-menu/package.json +55 -0
- package/node_modules/@tiptap/extension-gapcursor/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-gapcursor/README.md +18 -0
- package/node_modules/@tiptap/extension-gapcursor/dist/index.cjs +17 -0
- package/node_modules/@tiptap/extension-gapcursor/dist/index.d.cts +2 -0
- package/node_modules/@tiptap/extension-gapcursor/dist/index.d.ts +2 -0
- package/node_modules/@tiptap/extension-gapcursor/dist/index.js +7 -0
- package/node_modules/@tiptap/extension-gapcursor/package.json +50 -0
- package/node_modules/@tiptap/extension-hard-break/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-hard-break/README.md +18 -0
- package/node_modules/@tiptap/extension-hard-break/dist/index.cjs +69 -0
- package/node_modules/@tiptap/extension-hard-break/dist/index.d.cts +35 -0
- package/node_modules/@tiptap/extension-hard-break/dist/index.d.ts +35 -0
- package/node_modules/@tiptap/extension-hard-break/dist/index.js +64 -0
- package/node_modules/@tiptap/extension-hard-break/package.json +50 -0
- package/node_modules/@tiptap/extension-heading/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-heading/README.md +18 -0
- package/node_modules/@tiptap/extension-heading/dist/index.cjs +93 -0
- package/node_modules/@tiptap/extension-heading/dist/index.d.cts +50 -0
- package/node_modules/@tiptap/extension-heading/dist/index.d.ts +50 -0
- package/node_modules/@tiptap/extension-heading/dist/index.js +88 -0
- package/node_modules/@tiptap/extension-heading/package.json +50 -0
- package/node_modules/@tiptap/extension-highlight/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-highlight/README.md +18 -0
- package/node_modules/@tiptap/extension-highlight/dist/index.cjs +113 -0
- package/node_modules/@tiptap/extension-highlight/dist/index.d.cts +59 -0
- package/node_modules/@tiptap/extension-highlight/dist/index.d.ts +59 -0
- package/node_modules/@tiptap/extension-highlight/dist/index.js +106 -0
- package/node_modules/@tiptap/extension-highlight/package.json +50 -0
- package/node_modules/@tiptap/extension-horizontal-rule/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-horizontal-rule/README.md +18 -0
- package/node_modules/@tiptap/extension-horizontal-rule/dist/index.cjs +78 -0
- package/node_modules/@tiptap/extension-horizontal-rule/dist/index.d.cts +35 -0
- package/node_modules/@tiptap/extension-horizontal-rule/dist/index.d.ts +35 -0
- package/node_modules/@tiptap/extension-horizontal-rule/dist/index.js +73 -0
- package/node_modules/@tiptap/extension-horizontal-rule/package.json +52 -0
- package/node_modules/@tiptap/extension-image/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-image/README.md +18 -0
- package/node_modules/@tiptap/extension-image/dist/index.cjs +181 -0
- package/node_modules/@tiptap/extension-image/dist/index.d.cts +69 -0
- package/node_modules/@tiptap/extension-image/dist/index.d.ts +69 -0
- package/node_modules/@tiptap/extension-image/dist/index.js +175 -0
- package/node_modules/@tiptap/extension-image/package.json +50 -0
- package/node_modules/@tiptap/extension-italic/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-italic/README.md +18 -0
- package/node_modules/@tiptap/extension-italic/dist/index.cjs +113 -0
- package/node_modules/@tiptap/extension-italic/dist/index.d.cts +55 -0
- package/node_modules/@tiptap/extension-italic/dist/index.d.ts +55 -0
- package/node_modules/@tiptap/extension-italic/dist/index.js +104 -0
- package/node_modules/@tiptap/extension-italic/package.json +50 -0
- package/node_modules/@tiptap/extension-link/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-link/README.md +18 -0
- package/node_modules/@tiptap/extension-link/dist/index.cjs +560 -0
- package/node_modules/@tiptap/extension-link/dist/index.d.cts +159 -0
- package/node_modules/@tiptap/extension-link/dist/index.d.ts +159 -0
- package/node_modules/@tiptap/extension-link/dist/index.js +553 -0
- package/node_modules/@tiptap/extension-link/package.json +56 -0
- package/node_modules/@tiptap/extension-list/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-list/README.md +18 -0
- package/node_modules/@tiptap/extension-list/dist/bullet-list/index.cjs +84 -0
- package/node_modules/@tiptap/extension-list/dist/bullet-list/index.d.cts +52 -0
- package/node_modules/@tiptap/extension-list/dist/bullet-list/index.d.ts +52 -0
- package/node_modules/@tiptap/extension-list/dist/bullet-list/index.js +82 -0
- package/node_modules/@tiptap/extension-list/dist/index.cjs +1570 -0
- package/node_modules/@tiptap/extension-list/dist/index.d.cts +391 -0
- package/node_modules/@tiptap/extension-list/dist/index.d.ts +390 -0
- package/node_modules/@tiptap/extension-list/dist/index.js +1533 -0
- package/node_modules/@tiptap/extension-list/dist/item/index.cjs +308 -0
- package/node_modules/@tiptap/extension-list/dist/item/index.d.cts +30 -0
- package/node_modules/@tiptap/extension-list/dist/item/index.d.ts +30 -0
- package/node_modules/@tiptap/extension-list/dist/item/index.js +307 -0
- package/node_modules/@tiptap/extension-list/dist/keymap/index.cjs +263 -0
- package/node_modules/@tiptap/extension-list/dist/keymap/index.d.cts +66 -0
- package/node_modules/@tiptap/extension-list/dist/keymap/index.d.ts +65 -0
- package/node_modules/@tiptap/extension-list/dist/keymap/index.js +245 -0
- package/node_modules/@tiptap/extension-list/dist/keymap/rolldown-runtime-D7D4PA-g.js +13 -0
- package/node_modules/@tiptap/extension-list/dist/kit/index.cjs +1487 -0
- package/node_modules/@tiptap/extension-list/dist/kit/index.d.cts +235 -0
- package/node_modules/@tiptap/extension-list/dist/kit/index.d.ts +235 -0
- package/node_modules/@tiptap/extension-list/dist/kit/index.js +1486 -0
- package/node_modules/@tiptap/extension-list/dist/ordered-list/index.cjs +671 -0
- package/node_modules/@tiptap/extension-list/dist/ordered-list/index.d.cts +120 -0
- package/node_modules/@tiptap/extension-list/dist/ordered-list/index.d.ts +120 -0
- package/node_modules/@tiptap/extension-list/dist/ordered-list/index.js +659 -0
- package/node_modules/@tiptap/extension-list/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/node_modules/@tiptap/extension-list/dist/task-item/index.cjs +327 -0
- package/node_modules/@tiptap/extension-list/dist/task-item/index.d.cts +69 -0
- package/node_modules/@tiptap/extension-list/dist/task-item/index.d.ts +69 -0
- package/node_modules/@tiptap/extension-list/dist/task-item/index.js +325 -0
- package/node_modules/@tiptap/extension-list/dist/task-list/index.cjs +121 -0
- package/node_modules/@tiptap/extension-list/dist/task-list/index.d.cts +35 -0
- package/node_modules/@tiptap/extension-list/dist/task-list/index.d.ts +35 -0
- package/node_modules/@tiptap/extension-list/dist/task-list/index.js +120 -0
- package/node_modules/@tiptap/extension-list/package.json +108 -0
- package/node_modules/@tiptap/extension-list-item/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-list-item/README.md +18 -0
- package/node_modules/@tiptap/extension-list-item/dist/index.cjs +17 -0
- package/node_modules/@tiptap/extension-list-item/dist/index.d.cts +2 -0
- package/node_modules/@tiptap/extension-list-item/dist/index.d.ts +2 -0
- package/node_modules/@tiptap/extension-list-item/dist/index.js +7 -0
- package/node_modules/@tiptap/extension-list-item/package.json +50 -0
- package/node_modules/@tiptap/extension-list-keymap/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-list-keymap/README.md +18 -0
- package/node_modules/@tiptap/extension-list-keymap/dist/index.cjs +23 -0
- package/node_modules/@tiptap/extension-list-keymap/dist/index.d.cts +2 -0
- package/node_modules/@tiptap/extension-list-keymap/dist/index.d.ts +2 -0
- package/node_modules/@tiptap/extension-list-keymap/dist/index.js +7 -0
- package/node_modules/@tiptap/extension-list-keymap/package.json +50 -0
- package/node_modules/@tiptap/extension-ordered-list/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-ordered-list/README.md +18 -0
- package/node_modules/@tiptap/extension-ordered-list/dist/index.cjs +17 -0
- package/node_modules/@tiptap/extension-ordered-list/dist/index.d.cts +2 -0
- package/node_modules/@tiptap/extension-ordered-list/dist/index.d.ts +2 -0
- package/node_modules/@tiptap/extension-ordered-list/dist/index.js +7 -0
- package/node_modules/@tiptap/extension-ordered-list/package.json +50 -0
- package/node_modules/@tiptap/extension-paragraph/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-paragraph/README.md +18 -0
- package/node_modules/@tiptap/extension-paragraph/dist/index.cjs +73 -0
- package/node_modules/@tiptap/extension-paragraph/dist/index.d.cts +29 -0
- package/node_modules/@tiptap/extension-paragraph/dist/index.d.ts +29 -0
- package/node_modules/@tiptap/extension-paragraph/dist/index.js +68 -0
- package/node_modules/@tiptap/extension-paragraph/package.json +50 -0
- package/node_modules/@tiptap/extension-strike/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-strike/README.md +18 -0
- package/node_modules/@tiptap/extension-strike/dist/index.cjs +88 -0
- package/node_modules/@tiptap/extension-strike/dist/index.d.cts +47 -0
- package/node_modules/@tiptap/extension-strike/dist/index.d.ts +47 -0
- package/node_modules/@tiptap/extension-strike/dist/index.js +81 -0
- package/node_modules/@tiptap/extension-strike/package.json +50 -0
- package/node_modules/@tiptap/extension-subscript/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-subscript/README.md +18 -0
- package/node_modules/@tiptap/extension-subscript/dist/index.cjs +56 -0
- package/node_modules/@tiptap/extension-subscript/dist/index.d.cts +39 -0
- package/node_modules/@tiptap/extension-subscript/dist/index.d.ts +39 -0
- package/node_modules/@tiptap/extension-subscript/dist/index.js +51 -0
- package/node_modules/@tiptap/extension-subscript/package.json +52 -0
- package/node_modules/@tiptap/extension-superscript/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-superscript/README.md +18 -0
- package/node_modules/@tiptap/extension-superscript/dist/index.cjs +56 -0
- package/node_modules/@tiptap/extension-superscript/dist/index.d.cts +39 -0
- package/node_modules/@tiptap/extension-superscript/dist/index.d.ts +39 -0
- package/node_modules/@tiptap/extension-superscript/dist/index.js +51 -0
- package/node_modules/@tiptap/extension-superscript/package.json +52 -0
- package/node_modules/@tiptap/extension-table/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-table/README.md +18 -0
- package/node_modules/@tiptap/extension-table/dist/cell/index.cjs +142 -0
- package/node_modules/@tiptap/extension-table/dist/cell/index.d.cts +35 -0
- package/node_modules/@tiptap/extension-table/dist/cell/index.d.ts +35 -0
- package/node_modules/@tiptap/extension-table/dist/cell/index.js +141 -0
- package/node_modules/@tiptap/extension-table/dist/header/index.cjs +142 -0
- package/node_modules/@tiptap/extension-table/dist/header/index.d.cts +35 -0
- package/node_modules/@tiptap/extension-table/dist/header/index.d.ts +35 -0
- package/node_modules/@tiptap/extension-table/dist/header/index.js +141 -0
- package/node_modules/@tiptap/extension-table/dist/index.cjs +832 -0
- package/node_modules/@tiptap/extension-table/dist/index.d.cts +344 -0
- package/node_modules/@tiptap/extension-table/dist/index.d.ts +344 -0
- package/node_modules/@tiptap/extension-table/dist/index.js +819 -0
- package/node_modules/@tiptap/extension-table/dist/kit/index.cjs +817 -0
- package/node_modules/@tiptap/extension-table/dist/kit/index.d.cts +265 -0
- package/node_modules/@tiptap/extension-table/dist/kit/index.d.ts +265 -0
- package/node_modules/@tiptap/extension-table/dist/kit/index.js +816 -0
- package/node_modules/@tiptap/extension-table/dist/row/index.cjs +29 -0
- package/node_modules/@tiptap/extension-table/dist/row/index.d.cts +35 -0
- package/node_modules/@tiptap/extension-table/dist/row/index.d.ts +35 -0
- package/node_modules/@tiptap/extension-table/dist/row/index.js +28 -0
- package/node_modules/@tiptap/extension-table/dist/table/index.cjs +616 -0
- package/node_modules/@tiptap/extension-table/dist/table/index.d.cts +254 -0
- package/node_modules/@tiptap/extension-table/dist/table/index.d.ts +254 -0
- package/node_modules/@tiptap/extension-table/dist/table/index.js +609 -0
- package/node_modules/@tiptap/extension-table/package.json +92 -0
- package/node_modules/@tiptap/extension-text/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-text/README.md +18 -0
- package/node_modules/@tiptap/extension-text/dist/index.cjs +28 -0
- package/node_modules/@tiptap/extension-text/dist/index.d.cts +10 -0
- package/node_modules/@tiptap/extension-text/dist/index.d.ts +10 -0
- package/node_modules/@tiptap/extension-text/dist/index.js +24 -0
- package/node_modules/@tiptap/extension-text/package.json +50 -0
- package/node_modules/@tiptap/extension-text-align/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-text-align/README.md +18 -0
- package/node_modules/@tiptap/extension-text-align/dist/index.cjs +73 -0
- package/node_modules/@tiptap/extension-text-align/dist/index.d.cts +53 -0
- package/node_modules/@tiptap/extension-text-align/dist/index.d.ts +53 -0
- package/node_modules/@tiptap/extension-text-align/dist/index.js +68 -0
- package/node_modules/@tiptap/extension-text-align/package.json +50 -0
- package/node_modules/@tiptap/extension-text-style/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-text-style/README.md +18 -0
- package/node_modules/@tiptap/extension-text-style/dist/background-color/index.cjs +121 -0
- package/node_modules/@tiptap/extension-text-style/dist/background-color/index.d.cts +161 -0
- package/node_modules/@tiptap/extension-text-style/dist/background-color/index.d.ts +161 -0
- package/node_modules/@tiptap/extension-text-style/dist/background-color/index.js +116 -0
- package/node_modules/@tiptap/extension-text-style/dist/color/index.cjs +121 -0
- package/node_modules/@tiptap/extension-text-style/dist/color/index.d.cts +161 -0
- package/node_modules/@tiptap/extension-text-style/dist/color/index.d.ts +161 -0
- package/node_modules/@tiptap/extension-text-style/dist/color/index.js +116 -0
- package/node_modules/@tiptap/extension-text-style/dist/font-family/index.cjs +120 -0
- package/node_modules/@tiptap/extension-text-style/dist/font-family/index.d.cts +161 -0
- package/node_modules/@tiptap/extension-text-style/dist/font-family/index.d.ts +161 -0
- package/node_modules/@tiptap/extension-text-style/dist/font-family/index.js +115 -0
- package/node_modules/@tiptap/extension-text-style/dist/font-size/index.cjs +120 -0
- package/node_modules/@tiptap/extension-text-style/dist/font-size/index.d.cts +161 -0
- package/node_modules/@tiptap/extension-text-style/dist/font-size/index.d.ts +161 -0
- package/node_modules/@tiptap/extension-text-style/dist/font-size/index.js +115 -0
- package/node_modules/@tiptap/extension-text-style/dist/index.cjs +298 -0
- package/node_modules/@tiptap/extension-text-style/dist/index.d.cts +275 -0
- package/node_modules/@tiptap/extension-text-style/dist/index.d.ts +275 -0
- package/node_modules/@tiptap/extension-text-style/dist/index.js +291 -0
- package/node_modules/@tiptap/extension-text-style/dist/line-height/index.cjs +120 -0
- package/node_modules/@tiptap/extension-text-style/dist/line-height/index.d.cts +161 -0
- package/node_modules/@tiptap/extension-text-style/dist/line-height/index.d.ts +161 -0
- package/node_modules/@tiptap/extension-text-style/dist/line-height/index.js +115 -0
- package/node_modules/@tiptap/extension-text-style/dist/text-style/index.cjs +80 -0
- package/node_modules/@tiptap/extension-text-style/dist/text-style/index.d.cts +170 -0
- package/node_modules/@tiptap/extension-text-style/dist/text-style/index.d.ts +170 -0
- package/node_modules/@tiptap/extension-text-style/dist/text-style/index.js +79 -0
- package/node_modules/@tiptap/extension-text-style/dist/text-style-kit/index.cjs +292 -0
- package/node_modules/@tiptap/extension-text-style/dist/text-style-kit/index.d.cts +244 -0
- package/node_modules/@tiptap/extension-text-style/dist/text-style-kit/index.d.ts +244 -0
- package/node_modules/@tiptap/extension-text-style/dist/text-style-kit/index.js +291 -0
- package/node_modules/@tiptap/extension-text-style/package.json +106 -0
- package/node_modules/@tiptap/extension-underline/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-underline/README.md +18 -0
- package/node_modules/@tiptap/extension-underline/dist/index.cjs +81 -0
- package/node_modules/@tiptap/extension-underline/dist/index.d.cts +39 -0
- package/node_modules/@tiptap/extension-underline/dist/index.d.ts +39 -0
- package/node_modules/@tiptap/extension-underline/dist/index.js +76 -0
- package/node_modules/@tiptap/extension-underline/package.json +50 -0
- package/node_modules/@tiptap/extension-youtube/LICENSE.md +21 -0
- package/node_modules/@tiptap/extension-youtube/README.md +18 -0
- package/node_modules/@tiptap/extension-youtube/dist/index.cjs +254 -0
- package/node_modules/@tiptap/extension-youtube/dist/index.d.cts +204 -0
- package/node_modules/@tiptap/extension-youtube/dist/index.d.ts +204 -0
- package/node_modules/@tiptap/extension-youtube/dist/index.js +246 -0
- package/node_modules/@tiptap/extension-youtube/package.json +50 -0
- package/node_modules/@tiptap/extensions/LICENSE.md +21 -0
- package/node_modules/@tiptap/extensions/README.md +18 -0
- package/node_modules/@tiptap/extensions/dist/character-count/index.cjs +87 -0
- package/node_modules/@tiptap/extensions/dist/character-count/index.d.cts +70 -0
- package/node_modules/@tiptap/extensions/dist/character-count/index.d.ts +70 -0
- package/node_modules/@tiptap/extensions/dist/character-count/index.js +86 -0
- package/node_modules/@tiptap/extensions/dist/drop-cursor/index.cjs +27 -0
- package/node_modules/@tiptap/extensions/dist/drop-cursor/index.d.cts +32 -0
- package/node_modules/@tiptap/extensions/dist/drop-cursor/index.d.ts +32 -0
- package/node_modules/@tiptap/extensions/dist/drop-cursor/index.js +26 -0
- package/node_modules/@tiptap/extensions/dist/focus/index.cjs +48 -0
- package/node_modules/@tiptap/extensions/dist/focus/index.d.cts +29 -0
- package/node_modules/@tiptap/extensions/dist/focus/index.d.ts +29 -0
- package/node_modules/@tiptap/extensions/dist/focus/index.js +47 -0
- package/node_modules/@tiptap/extensions/dist/gap-cursor/index.cjs +29 -0
- package/node_modules/@tiptap/extensions/dist/gap-cursor/index.d.cts +26 -0
- package/node_modules/@tiptap/extensions/dist/gap-cursor/index.d.ts +26 -0
- package/node_modules/@tiptap/extensions/dist/gap-cursor/index.js +28 -0
- package/node_modules/@tiptap/extensions/dist/index.cjs +711 -0
- package/node_modules/@tiptap/extensions/dist/index.d.cts +321 -0
- package/node_modules/@tiptap/extensions/dist/index.d.ts +321 -0
- package/node_modules/@tiptap/extensions/dist/index.js +699 -0
- package/node_modules/@tiptap/extensions/dist/placeholder/index.cjs +372 -0
- package/node_modules/@tiptap/extensions/dist/placeholder/index.d.cts +91 -0
- package/node_modules/@tiptap/extensions/dist/placeholder/index.d.ts +91 -0
- package/node_modules/@tiptap/extensions/dist/placeholder/index.js +368 -0
- package/node_modules/@tiptap/extensions/dist/selection/index.cjs +72 -0
- package/node_modules/@tiptap/extensions/dist/selection/index.d.cts +20 -0
- package/node_modules/@tiptap/extensions/dist/selection/index.d.ts +20 -0
- package/node_modules/@tiptap/extensions/dist/selection/index.js +71 -0
- package/node_modules/@tiptap/extensions/dist/trailing-node/index.cjs +62 -0
- package/node_modules/@tiptap/extensions/dist/trailing-node/index.d.cts +30 -0
- package/node_modules/@tiptap/extensions/dist/trailing-node/index.d.ts +30 -0
- package/node_modules/@tiptap/extensions/dist/trailing-node/index.js +60 -0
- package/node_modules/@tiptap/extensions/dist/undo-redo/index.cjs +48 -0
- package/node_modules/@tiptap/extensions/dist/undo-redo/index.d.cts +45 -0
- package/node_modules/@tiptap/extensions/dist/undo-redo/index.d.ts +45 -0
- package/node_modules/@tiptap/extensions/dist/undo-redo/index.js +47 -0
- package/node_modules/@tiptap/extensions/package.json +116 -0
- package/node_modules/@tiptap/pm/LICENSE +21 -0
- package/node_modules/@tiptap/pm/README.md +22 -0
- package/node_modules/@tiptap/pm/THIRD_PARTY_LICENSES.md +47 -0
- package/node_modules/@tiptap/pm/changeset/index.ts +1 -0
- package/node_modules/@tiptap/pm/commands/index.ts +1 -0
- package/node_modules/@tiptap/pm/dist/changeset/index.cjs +9 -0
- package/node_modules/@tiptap/pm/dist/changeset/index.d.cts +1 -0
- package/node_modules/@tiptap/pm/dist/changeset/index.d.ts +1 -0
- package/node_modules/@tiptap/pm/dist/changeset/index.js +2 -0
- package/node_modules/@tiptap/pm/dist/commands/index.cjs +9 -0
- package/node_modules/@tiptap/pm/dist/commands/index.d.cts +1 -0
- package/node_modules/@tiptap/pm/dist/commands/index.d.ts +1 -0
- package/node_modules/@tiptap/pm/dist/commands/index.js +2 -0
- package/node_modules/@tiptap/pm/dist/dropcursor/index.cjs +9 -0
- package/node_modules/@tiptap/pm/dist/dropcursor/index.d.cts +1 -0
- package/node_modules/@tiptap/pm/dist/dropcursor/index.d.ts +1 -0
- package/node_modules/@tiptap/pm/dist/dropcursor/index.js +2 -0
- package/node_modules/@tiptap/pm/dist/gapcursor/index.cjs +9 -0
- package/node_modules/@tiptap/pm/dist/gapcursor/index.d.cts +1 -0
- package/node_modules/@tiptap/pm/dist/gapcursor/index.d.ts +1 -0
- package/node_modules/@tiptap/pm/dist/gapcursor/index.js +2 -0
- package/node_modules/@tiptap/pm/dist/history/index.cjs +9 -0
- package/node_modules/@tiptap/pm/dist/history/index.d.cts +1 -0
- package/node_modules/@tiptap/pm/dist/history/index.d.ts +1 -0
- package/node_modules/@tiptap/pm/dist/history/index.js +2 -0
- package/node_modules/@tiptap/pm/dist/inputrules/index.cjs +9 -0
- package/node_modules/@tiptap/pm/dist/inputrules/index.d.cts +1 -0
- package/node_modules/@tiptap/pm/dist/inputrules/index.d.ts +1 -0
- package/node_modules/@tiptap/pm/dist/inputrules/index.js +2 -0
- package/node_modules/@tiptap/pm/dist/keymap/index.cjs +9 -0
- package/node_modules/@tiptap/pm/dist/keymap/index.d.cts +1 -0
- package/node_modules/@tiptap/pm/dist/keymap/index.d.ts +1 -0
- package/node_modules/@tiptap/pm/dist/keymap/index.js +2 -0
- package/node_modules/@tiptap/pm/dist/model/index.cjs +9 -0
- package/node_modules/@tiptap/pm/dist/model/index.d.cts +1 -0
- package/node_modules/@tiptap/pm/dist/model/index.d.ts +1 -0
- package/node_modules/@tiptap/pm/dist/model/index.js +2 -0
- package/node_modules/@tiptap/pm/dist/schema-list/index.cjs +9 -0
- package/node_modules/@tiptap/pm/dist/schema-list/index.d.cts +1 -0
- package/node_modules/@tiptap/pm/dist/schema-list/index.d.ts +1 -0
- package/node_modules/@tiptap/pm/dist/schema-list/index.js +2 -0
- package/node_modules/@tiptap/pm/dist/state/index.cjs +9 -0
- package/node_modules/@tiptap/pm/dist/state/index.d.cts +1 -0
- package/node_modules/@tiptap/pm/dist/state/index.d.ts +1 -0
- package/node_modules/@tiptap/pm/dist/state/index.js +2 -0
- package/node_modules/@tiptap/pm/dist/tables/index.cjs +9 -0
- package/node_modules/@tiptap/pm/dist/tables/index.d.cts +1 -0
- package/node_modules/@tiptap/pm/dist/tables/index.d.ts +1 -0
- package/node_modules/@tiptap/pm/dist/tables/index.js +2 -0
- package/node_modules/@tiptap/pm/dist/transform/index.cjs +9 -0
- package/node_modules/@tiptap/pm/dist/transform/index.d.cts +1 -0
- package/node_modules/@tiptap/pm/dist/transform/index.d.ts +1 -0
- package/node_modules/@tiptap/pm/dist/transform/index.js +2 -0
- package/node_modules/@tiptap/pm/dist/view/index.cjs +9 -0
- package/node_modules/@tiptap/pm/dist/view/index.d.cts +1 -0
- package/node_modules/@tiptap/pm/dist/view/index.d.ts +1 -0
- package/node_modules/@tiptap/pm/dist/view/index.js +2 -0
- package/node_modules/@tiptap/pm/dropcursor/index.ts +1 -0
- package/node_modules/@tiptap/pm/gapcursor/index.ts +1 -0
- package/node_modules/@tiptap/pm/history/index.ts +1 -0
- package/node_modules/@tiptap/pm/inputrules/index.ts +1 -0
- package/node_modules/@tiptap/pm/keymap/index.ts +1 -0
- package/node_modules/@tiptap/pm/model/index.ts +1 -0
- package/node_modules/@tiptap/pm/package.json +166 -0
- package/node_modules/@tiptap/pm/schema-list/index.ts +1 -0
- package/node_modules/@tiptap/pm/state/index.ts +1 -0
- package/node_modules/@tiptap/pm/tables/index.ts +1 -0
- package/node_modules/@tiptap/pm/transform/index.ts +1 -0
- package/node_modules/@tiptap/pm/view/index.ts +1 -0
- package/node_modules/@tiptap/react/LICENSE.md +21 -0
- package/node_modules/@tiptap/react/README.md +18 -0
- package/node_modules/@tiptap/react/dist/index.cjs +1396 -0
- package/node_modules/@tiptap/react/dist/index.d.cts +632 -0
- package/node_modules/@tiptap/react/dist/index.d.ts +632 -0
- package/node_modules/@tiptap/react/dist/index.js +1337 -0
- package/node_modules/@tiptap/react/dist/menus/index.cjs +469 -0
- package/node_modules/@tiptap/react/dist/menus/index.d.cts +21 -0
- package/node_modules/@tiptap/react/dist/menus/index.d.ts +21 -0
- package/node_modules/@tiptap/react/dist/menus/index.js +444 -0
- package/node_modules/@tiptap/react/package.json +80 -0
- package/node_modules/@tiptap/starter-kit/LICENSE.md +21 -0
- package/node_modules/@tiptap/starter-kit/README.md +18 -0
- package/node_modules/@tiptap/starter-kit/dist/index.cjs +76 -0
- package/node_modules/@tiptap/starter-kit/dist/index.d.cts +137 -0
- package/node_modules/@tiptap/starter-kit/dist/index.d.ts +137 -0
- package/node_modules/@tiptap/starter-kit/dist/index.js +71 -0
- package/node_modules/@tiptap/starter-kit/package.json +70 -0
- package/node_modules/@tiptap/suggestion/LICENSE.md +21 -0
- package/node_modules/@tiptap/suggestion/README.md +18 -0
- package/node_modules/@tiptap/suggestion/dist/index.cjs +665 -0
- package/node_modules/@tiptap/suggestion/dist/index.d.cts +419 -0
- package/node_modules/@tiptap/suggestion/dist/index.d.ts +419 -0
- package/node_modules/@tiptap/suggestion/dist/index.js +657 -0
- package/node_modules/@tiptap/suggestion/package.json +54 -0
- package/node_modules/@types/use-sync-external-store/LICENSE +21 -0
- package/node_modules/@types/use-sync-external-store/README.md +15 -0
- package/node_modules/@types/use-sync-external-store/index.d.ts +5 -0
- package/node_modules/@types/use-sync-external-store/package.json +30 -0
- package/node_modules/@types/use-sync-external-store/shim/index.d.ts +1 -0
- package/node_modules/@types/use-sync-external-store/shim/with-selector.d.ts +1 -0
- package/node_modules/@types/use-sync-external-store/with-selector.d.ts +7 -0
- package/node_modules/fast-equals/LICENSE +21 -0
- package/node_modules/fast-equals/README.md +479 -0
- package/node_modules/fast-equals/dist/cjs/index.cjs +796 -0
- package/node_modules/fast-equals/dist/cjs/index.d.cts +211 -0
- package/node_modules/fast-equals/dist/es/index.d.mts +211 -0
- package/node_modules/fast-equals/dist/es/index.mjs +785 -0
- package/node_modules/fast-equals/dist/umd/index.d.ts +211 -0
- package/node_modules/fast-equals/dist/umd/index.js +802 -0
- package/node_modules/fast-equals/index.d.ts +211 -0
- package/node_modules/fast-equals/package.json +120 -0
- package/node_modules/linkifyjs/LICENSE +19 -0
- package/node_modules/linkifyjs/README.md +47 -0
- package/node_modules/linkifyjs/dist/linkify.cjs +1854 -0
- package/node_modules/linkifyjs/dist/linkify.d.cts +637 -0
- package/node_modules/linkifyjs/dist/linkify.d.mts +637 -0
- package/node_modules/linkifyjs/dist/linkify.js +1859 -0
- package/node_modules/linkifyjs/dist/linkify.min.js +1 -0
- package/node_modules/linkifyjs/dist/linkify.mjs +1836 -0
- package/node_modules/linkifyjs/package.json +38 -0
- package/node_modules/orderedmap/LICENSE +19 -0
- package/node_modules/orderedmap/README.md +69 -0
- package/node_modules/orderedmap/dist/index.cjs +139 -0
- package/node_modules/orderedmap/dist/index.d.cts +33 -0
- package/node_modules/orderedmap/dist/index.d.ts +33 -0
- package/node_modules/orderedmap/dist/index.js +137 -0
- package/node_modules/orderedmap/package.json +39 -0
- package/node_modules/prosemirror-changeset/CHANGELOG.md +171 -0
- package/node_modules/prosemirror-changeset/LICENSE +19 -0
- package/node_modules/prosemirror-changeset/README.md +175 -0
- package/node_modules/prosemirror-changeset/dist/index.cjs +588 -0
- package/node_modules/prosemirror-changeset/dist/index.d.cts +187 -0
- package/node_modules/prosemirror-changeset/dist/index.d.ts +187 -0
- package/node_modules/prosemirror-changeset/dist/index.js +722 -0
- package/node_modules/prosemirror-changeset/package.json +40 -0
- package/node_modules/prosemirror-changeset/test/test-changed-range.ts +48 -0
- package/node_modules/prosemirror-changeset/test/test-changes.ts +211 -0
- package/node_modules/prosemirror-changeset/test/test-diff.ts +77 -0
- package/node_modules/prosemirror-changeset/test/test-merge.ts +56 -0
- package/node_modules/prosemirror-changeset/test/test-simplify.ts +74 -0
- package/node_modules/prosemirror-commands/.tern-project +8 -0
- package/node_modules/prosemirror-commands/CHANGELOG.md +328 -0
- package/node_modules/prosemirror-commands/CONTRIBUTING.md +104 -0
- package/node_modules/prosemirror-commands/LICENSE +19 -0
- package/node_modules/prosemirror-commands/README.md +28 -0
- package/node_modules/prosemirror-commands/dist/index.cjs +688 -0
- package/node_modules/prosemirror-commands/dist/index.d.cts +215 -0
- package/node_modules/prosemirror-commands/dist/index.d.ts +215 -0
- package/node_modules/prosemirror-commands/dist/index.js +852 -0
- package/node_modules/prosemirror-commands/package.json +39 -0
- package/node_modules/prosemirror-dropcursor/CHANGELOG.md +149 -0
- package/node_modules/prosemirror-dropcursor/CONTRIBUTING.md +104 -0
- package/node_modules/prosemirror-dropcursor/LICENSE +19 -0
- package/node_modules/prosemirror-dropcursor/README.md +50 -0
- package/node_modules/prosemirror-dropcursor/dist/index.cjs +200 -0
- package/node_modules/prosemirror-dropcursor/dist/index.d.cts +38 -0
- package/node_modules/prosemirror-dropcursor/dist/index.d.ts +38 -0
- package/node_modules/prosemirror-dropcursor/dist/index.js +163 -0
- package/node_modules/prosemirror-dropcursor/package.json +38 -0
- package/node_modules/prosemirror-gapcursor/CHANGELOG.md +122 -0
- package/node_modules/prosemirror-gapcursor/CONTRIBUTING.md +104 -0
- package/node_modules/prosemirror-gapcursor/LICENSE +19 -0
- package/node_modules/prosemirror-gapcursor/README.md +31 -0
- package/node_modules/prosemirror-gapcursor/dist/index.cjs +239 -0
- package/node_modules/prosemirror-gapcursor/dist/index.d.cts +31 -0
- package/node_modules/prosemirror-gapcursor/dist/index.d.ts +31 -0
- package/node_modules/prosemirror-gapcursor/dist/index.js +239 -0
- package/node_modules/prosemirror-gapcursor/package.json +43 -0
- package/node_modules/prosemirror-gapcursor/style/gapcursor.css +25 -0
- package/node_modules/prosemirror-history/.tern-project +8 -0
- package/node_modules/prosemirror-history/CHANGELOG.md +176 -0
- package/node_modules/prosemirror-history/CONTRIBUTING.md +104 -0
- package/node_modules/prosemirror-history/LICENSE +19 -0
- package/node_modules/prosemirror-history/README.md +27 -0
- package/node_modules/prosemirror-history/dist/index.cjs +383 -0
- package/node_modules/prosemirror-history/dist/index.d.cts +64 -0
- package/node_modules/prosemirror-history/dist/index.d.ts +64 -0
- package/node_modules/prosemirror-history/dist/index.js +454 -0
- package/node_modules/prosemirror-history/package.json +40 -0
- package/node_modules/prosemirror-inputrules/.tern-project +8 -0
- package/node_modules/prosemirror-inputrules/CHANGELOG.md +127 -0
- package/node_modules/prosemirror-inputrules/CONTRIBUTING.md +104 -0
- package/node_modules/prosemirror-inputrules/LICENSE +19 -0
- package/node_modules/prosemirror-inputrules/README.md +29 -0
- package/node_modules/prosemirror-inputrules/dist/index.cjs +194 -0
- package/node_modules/prosemirror-inputrules/dist/index.d.cts +131 -0
- package/node_modules/prosemirror-inputrules/dist/index.d.ts +131 -0
- package/node_modules/prosemirror-inputrules/dist/index.js +239 -0
- package/node_modules/prosemirror-inputrules/package.json +36 -0
- package/node_modules/prosemirror-keymap/.tern-project +8 -0
- package/node_modules/prosemirror-keymap/CHANGELOG.md +104 -0
- package/node_modules/prosemirror-keymap/CONTRIBUTING.md +104 -0
- package/node_modules/prosemirror-keymap/LICENSE +19 -0
- package/node_modules/prosemirror-keymap/README.md +27 -0
- package/node_modules/prosemirror-keymap/dist/index.cjs +65 -0
- package/node_modules/prosemirror-keymap/dist/index.d.cts +47 -0
- package/node_modules/prosemirror-keymap/dist/index.d.ts +47 -0
- package/node_modules/prosemirror-keymap/dist/index.js +128 -0
- package/node_modules/prosemirror-keymap/package.json +38 -0
- package/node_modules/prosemirror-model/.tern-project +8 -0
- package/node_modules/prosemirror-model/CHANGELOG.md +782 -0
- package/node_modules/prosemirror-model/CONTRIBUTING.md +104 -0
- package/node_modules/prosemirror-model/LICENSE +19 -0
- package/node_modules/prosemirror-model/README.md +29 -0
- package/node_modules/prosemirror-model/dist/index.cjs +2911 -0
- package/node_modules/prosemirror-model/dist/index.d.cts +1683 -0
- package/node_modules/prosemirror-model/dist/index.d.ts +1683 -0
- package/node_modules/prosemirror-model/dist/index.js +3463 -0
- package/node_modules/prosemirror-model/package.json +38 -0
- package/node_modules/prosemirror-schema-list/.tern-project +8 -0
- package/node_modules/prosemirror-schema-list/CHANGELOG.md +140 -0
- package/node_modules/prosemirror-schema-list/CONTRIBUTING.md +100 -0
- package/node_modules/prosemirror-schema-list/LICENSE +19 -0
- package/node_modules/prosemirror-schema-list/README.md +28 -0
- package/node_modules/prosemirror-schema-list/dist/index.cjs +253 -0
- package/node_modules/prosemirror-schema-list/dist/index.d.cts +71 -0
- package/node_modules/prosemirror-schema-list/dist/index.d.ts +71 -0
- package/node_modules/prosemirror-schema-list/dist/index.js +289 -0
- package/node_modules/prosemirror-schema-list/package.json +40 -0
- package/node_modules/prosemirror-state/.tern-project +8 -0
- package/node_modules/prosemirror-state/CHANGELOG.md +296 -0
- package/node_modules/prosemirror-state/CONTRIBUTING.md +104 -0
- package/node_modules/prosemirror-state/LICENSE +19 -0
- package/node_modules/prosemirror-state/README.md +28 -0
- package/node_modules/prosemirror-state/dist/index.cjs +884 -0
- package/node_modules/prosemirror-state/dist/index.d.cts +709 -0
- package/node_modules/prosemirror-state/dist/index.d.ts +709 -0
- package/node_modules/prosemirror-state/dist/index.js +1002 -0
- package/node_modules/prosemirror-state/package.json +39 -0
- package/node_modules/prosemirror-tables/LICENSE +19 -0
- package/node_modules/prosemirror-tables/README.md +254 -0
- package/node_modules/prosemirror-tables/dist/index.cjs +2683 -0
- package/node_modules/prosemirror-tables/dist/index.d.cts +751 -0
- package/node_modules/prosemirror-tables/dist/index.d.ts +751 -0
- package/node_modules/prosemirror-tables/dist/index.js +2626 -0
- package/node_modules/prosemirror-tables/package.json +80 -0
- package/node_modules/prosemirror-tables/style/tables.css +48 -0
- package/node_modules/prosemirror-transform/.tern-project +8 -0
- package/node_modules/prosemirror-transform/CHANGELOG.md +530 -0
- package/node_modules/prosemirror-transform/CONTRIBUTING.md +104 -0
- package/node_modules/prosemirror-transform/LICENSE +19 -0
- package/node_modules/prosemirror-transform/README.md +29 -0
- package/node_modules/prosemirror-transform/dist/index.cjs +2014 -0
- package/node_modules/prosemirror-transform/dist/index.d.cts +857 -0
- package/node_modules/prosemirror-transform/dist/index.d.ts +857 -0
- package/node_modules/prosemirror-transform/dist/index.js +2272 -0
- package/node_modules/prosemirror-transform/package.json +37 -0
- package/node_modules/prosemirror-view/.tern-project +8 -0
- package/node_modules/prosemirror-view/CHANGELOG.md +2543 -0
- package/node_modules/prosemirror-view/CONTRIBUTING.md +104 -0
- package/node_modules/prosemirror-view/LICENSE +19 -0
- package/node_modules/prosemirror-view/README.md +28 -0
- package/node_modules/prosemirror-view/dist/index.cjs +5549 -0
- package/node_modules/prosemirror-view/dist/index.d.cts +913 -0
- package/node_modules/prosemirror-view/dist/index.d.ts +913 -0
- package/node_modules/prosemirror-view/dist/index.js +6053 -0
- package/node_modules/prosemirror-view/package.json +43 -0
- package/node_modules/prosemirror-view/style/prosemirror.css +54 -0
- package/node_modules/rope-sequence/LICENSE +19 -0
- package/node_modules/rope-sequence/README.md +63 -0
- package/node_modules/rope-sequence/dist/index.cjs +209 -0
- package/node_modules/rope-sequence/dist/index.d.cts +11 -0
- package/node_modules/rope-sequence/dist/index.d.ts +11 -0
- package/node_modules/rope-sequence/dist/index.js +207 -0
- package/node_modules/rope-sequence/index.js +190 -0
- package/node_modules/rope-sequence/package.json +34 -0
- package/node_modules/rope-sequence/test.js +78 -0
- package/node_modules/use-sync-external-store/LICENSE +21 -0
- package/node_modules/use-sync-external-store/README.md +5 -0
- package/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +97 -0
- package/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +85 -0
- package/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +95 -0
- package/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.native.development.js +88 -0
- package/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.native.production.js +59 -0
- package/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +66 -0
- package/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.development.js +96 -0
- package/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.production.js +84 -0
- package/node_modules/use-sync-external-store/cjs/use-sync-external-store.development.js +27 -0
- package/node_modules/use-sync-external-store/cjs/use-sync-external-store.production.js +13 -0
- package/node_modules/use-sync-external-store/index.js +7 -0
- package/node_modules/use-sync-external-store/package.json +43 -0
- package/node_modules/use-sync-external-store/shim/index.js +7 -0
- package/node_modules/use-sync-external-store/shim/index.native.js +7 -0
- package/node_modules/use-sync-external-store/shim/with-selector.js +7 -0
- package/node_modules/use-sync-external-store/with-selector.js +7 -0
- package/node_modules/w3c-keyname/.tern-port +1 -0
- package/node_modules/w3c-keyname/LICENSE +19 -0
- package/node_modules/w3c-keyname/README.md +18 -0
- package/node_modules/w3c-keyname/index.cjs +127 -0
- package/node_modules/w3c-keyname/index.d.cts +5 -0
- package/node_modules/w3c-keyname/index.d.ts +5 -0
- package/node_modules/w3c-keyname/index.js +119 -0
- package/node_modules/w3c-keyname/package.json +37 -0
- package/package.json +79 -4
- package/src/Editor.tsx +425 -0
- package/src/ask.tsx +154 -0
- package/src/basic.tsx +149 -0
- package/src/blockMeta.ts +42 -0
- package/src/blockops.ts +179 -0
- package/src/blocks.tsx +189 -0
- package/src/boundary.tsx +17 -0
- package/src/content.ts +22 -0
- package/src/dynamic.tsx +105 -0
- package/src/editor.css +345 -0
- package/src/extensions.ts +78 -0
- package/src/handle.tsx +188 -0
- package/src/handles.tsx +149 -0
- package/src/index.ts +29 -0
- package/src/insert.ts +9 -0
- package/src/inserter.tsx +163 -0
- package/src/inspector.tsx +237 -0
- package/src/labels.ts +135 -0
- package/src/layout.tsx +174 -0
- package/src/layoutUi.tsx +226 -0
- package/src/media.ts +31 -0
- package/src/nodes.tsx +107 -0
- package/src/outline.tsx +124 -0
- package/src/panels.ts +59 -0
- package/src/paste.ts +100 -0
- package/src/patterns.ts +129 -0
- package/src/rank.ts +22 -0
- package/src/registry.ts +20 -0
- package/src/styleattr.ts +55 -0
- package/src/stylepanel.tsx +275 -0
- package/src/synced.tsx +128 -0
- package/src/toolbar.tsx +238 -0
- package/src/types.ts +55 -0
- package/src/unknown.tsx +74 -0
- package/src/util.ts +3 -0
package/src/Editor.tsx
ADDED
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
import { Extension, type Editor as TiptapEditor, type Range } from "@tiptap/core";
|
|
2
|
+
import { EditorContent, useEditor, useEditorState } from "@tiptap/react";
|
|
3
|
+
import { BubbleMenu } from "@tiptap/react/menus";
|
|
4
|
+
import { Placeholder } from "@tiptap/extensions";
|
|
5
|
+
import { NodeSelection } from "@tiptap/pm/state";
|
|
6
|
+
import Suggestion, { type SuggestionProps } from "@tiptap/suggestion";
|
|
7
|
+
import {
|
|
8
|
+
AlignCenter, AlignLeft, AlignRight, Bold, Braces, Code, FileText, Heading2, Heading3, Heading4, ImageIcon, Images, Italic, Link2, List,
|
|
9
|
+
ListOrdered, Minus, Music, Pilcrow, Quote, Redo2, SquareCode, Strikethrough, Table2, Underline, Undo2, Video, type LucideIcon,
|
|
10
|
+
} from "lucide-react";
|
|
11
|
+
import { useEffect, useMemo, useRef, useState, useSyncExternalStore, type ReactNode } from "react";
|
|
12
|
+
import { createPortal } from "react-dom";
|
|
13
|
+
import { viLabels, type EditorLabels } from "./labels";
|
|
14
|
+
import { galleryImage, imageAttrs } from "./media";
|
|
15
|
+
import { coreExtensions, knownTypes } from "./extensions";
|
|
16
|
+
import { unwrapUnknown, wrapUnknown } from "./unknown";
|
|
17
|
+
import { onExtensionsChange, registeredExtensions } from "./registry";
|
|
18
|
+
import { DYNAMIC_BLOCKS } from "./dynamic";
|
|
19
|
+
import type { EditorExtensionPack, InsertItem, MediaItem, MediaKind, MediaProvider } from "./types";
|
|
20
|
+
import { cx } from "./util";
|
|
21
|
+
import { rankItems } from "./rank";
|
|
22
|
+
export { rankItems } from "./rank";
|
|
23
|
+
import { AskPopover, askOf, createAskStore, type Ask } from "./ask";
|
|
24
|
+
import type { PatternHost } from "./synced";
|
|
25
|
+
import { BlockHandle, BlockKeys } from "./handle";
|
|
26
|
+
import { BlockSettingsBar, layoutItems } from "./layoutUi";
|
|
27
|
+
import { BlockToolbar } from "./toolbar";
|
|
28
|
+
import { OverlayBoundary } from "./boundary";
|
|
29
|
+
import { CanvasHandles } from "./handles";
|
|
30
|
+
import { documentStyleCss, presetsCss } from "./styleattr";
|
|
31
|
+
import type { StylePresets } from "@ecomcx/ecomweb-content";
|
|
32
|
+
import { registerBasicBlocks } from "./basic";
|
|
33
|
+
import { registerCorePatterns } from "./patterns";
|
|
34
|
+
import { setImagePicker } from "./blocks";
|
|
35
|
+
|
|
36
|
+
// Bộ khối cơ bản có sẵn ở mọi trình soạn (ứng dụng gọi lại registerBasicBlocks("en") để đổi nhãn)
|
|
37
|
+
registerBasicBlocks();
|
|
38
|
+
registerCorePatterns();
|
|
39
|
+
import { cleanPastedHtml, isUrl } from "./paste";
|
|
40
|
+
import { handleInsertDrop } from "./inserter";
|
|
41
|
+
import { embedInfo } from "@ecomcx/ecomweb-content";
|
|
42
|
+
|
|
43
|
+
export interface EditorProps {
|
|
44
|
+
/** Nội dung ban đầu (TipTap JSON hoặc HTML). */
|
|
45
|
+
initial: any;
|
|
46
|
+
onChange(json: any): void;
|
|
47
|
+
/** Nguồn media của ứng dụng; không có → chèn ảnh bằng URL. */
|
|
48
|
+
media?: MediaProvider;
|
|
49
|
+
/** Chữ giao diện (mặc định tiếng Việt; có sẵn enLabels). */
|
|
50
|
+
labels?: Partial<EditorLabels>;
|
|
51
|
+
/** Gói mở rộng riêng cho trình soạn này (ngoài các gói đăng ký toàn cục bằng registerEditorExtension). */
|
|
52
|
+
extensions?: EditorExtensionPack[];
|
|
53
|
+
/** Class cho thanh công cụ (vd để dính đầu trang: sticky top). */
|
|
54
|
+
toolbarClassName?: string;
|
|
55
|
+
className?: string;
|
|
56
|
+
/** Nhận đối tượng TipTap Editor để điều khiển từ bên ngoài. */
|
|
57
|
+
onReady?(editor: TiptapEditor): void;
|
|
58
|
+
/** Tên vùng soạn cho trình đọc màn hình (mặc định labels.editorLabel). */
|
|
59
|
+
ariaLabel?: string;
|
|
60
|
+
/** Cho chèn khối động (tên website, menu, danh sách bài…) — Trình dựng, trang dựng bằng khối. Nội dung có sẵn khối động luôn mở được. */
|
|
61
|
+
dynamicBlocks?: boolean;
|
|
62
|
+
/** Preset kiểu dáng của theme (màu, cỡ chữ, khoảng cách, phông) — vùng soạn dùng cùng biến CSS với website. */
|
|
63
|
+
presets?: StylePresets;
|
|
64
|
+
/** Mẫu của ứng dụng: nội dung mẫu đồng bộ, "Tạo mẫu" từ khối đang chọn, mở mẫu gốc. */
|
|
65
|
+
patterns?: PatternHost;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
// Lệnh chèn mặc định
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
const chain = (editor: TiptapEditor, range?: Range) => (range ? editor.chain().focus().deleteRange(range) : editor.chain().focus());
|
|
72
|
+
|
|
73
|
+
type RequestMedia = (editor: TiptapEditor, kind: MediaKind) => void;
|
|
74
|
+
|
|
75
|
+
function defaultItems(t: EditorLabels, requestMedia: RequestMedia): InsertItem[] {
|
|
76
|
+
return [
|
|
77
|
+
{ key: "p", title: t.paragraph, hint: t.paragraphHint, icon: Pilcrow, keywords: "doan van text paragraph", run: (e, r) => chain(e, r).setParagraph().run() },
|
|
78
|
+
{ key: "h2", title: t.h2, hint: "H2", icon: Heading2, keywords: "tieu de heading h2", run: (e, r) => chain(e, r).setHeading({ level: 2 }).run() },
|
|
79
|
+
{ key: "h3", title: t.h3, hint: "H3", icon: Heading3, keywords: "tieu de heading h3", run: (e, r) => chain(e, r).setHeading({ level: 3 }).run() },
|
|
80
|
+
{ key: "h4", title: t.h4, hint: "H4", icon: Heading4, keywords: "tieu de heading h4", run: (e, r) => chain(e, r).setHeading({ level: 4 }).run() },
|
|
81
|
+
{ key: "ul", title: t.bulletList, hint: t.bulletListHint, icon: List, keywords: "danh sach list bullet", run: (e, r) => chain(e, r).toggleBulletList().run() },
|
|
82
|
+
{ key: "ol", title: t.orderedList, hint: "1. 2. 3.", icon: ListOrdered, keywords: "danh sach so ordered number", run: (e, r) => chain(e, r).toggleOrderedList().run() },
|
|
83
|
+
{ key: "quote", title: t.quote, hint: "Blockquote", icon: Quote, keywords: "trich dan quote", run: (e, r) => chain(e, r).toggleBlockquote().run() },
|
|
84
|
+
{ key: "code", title: t.codeBlock, hint: "Code block", icon: SquareCode, keywords: "ma code", run: (e, r) => chain(e, r).toggleCodeBlock().run() },
|
|
85
|
+
{ key: "image", title: t.image, hint: t.imageHint, icon: ImageIcon, keywords: "anh hinh image photo", run: (e, r) => { chain(e, r).run(); requestMedia(e, "image"); } },
|
|
86
|
+
{ key: "gallery", title: t.gallery, hint: t.galleryHint, icon: Images, keywords: "gallery bo suu tap nhieu anh album", run: (e, r) => { chain(e, r).run(); requestMedia(e, "gallery"); } },
|
|
87
|
+
{ key: "video", title: t.video, hint: t.videoHint, icon: Video, keywords: "video mp4 phim", run: (e, r) => { chain(e, r).run(); requestMedia(e, "video"); } },
|
|
88
|
+
{ key: "audio", title: t.audio, hint: t.audioHint, icon: Music, keywords: "am thanh audio nhac mp3 podcast", run: (e, r) => { chain(e, r).run(); requestMedia(e, "audio"); } },
|
|
89
|
+
{ key: "file", title: t.file, hint: t.fileHint, icon: FileText, keywords: "tep file pdf tai xuong download tai lieu", run: (e, r) => { chain(e, r).run(); requestMedia(e, "file"); } },
|
|
90
|
+
{ key: "table", title: t.table, hint: t.tableHint, icon: Table2, keywords: "bang table", run: (e, r) => { chain(e, r).run(); insertTableAsk(e, t); } },
|
|
91
|
+
{ key: "youtube", title: t.youtube, hint: t.youtubeHint, icon: Video, keywords: "video youtube", run: async (e, r) => {
|
|
92
|
+
chain(e, r).run();
|
|
93
|
+
const res = await askOf(e)({ title: t.youtube, fields: [{ key: "url", label: t.youtubePrompt, type: "url", placeholder: "https://www.youtube.com/watch?v=…" }], submit: t.insert });
|
|
94
|
+
if (res && res !== "remove" && res.url) e.chain().focus().setYoutubeVideo({ src: String(res.url) }).run();
|
|
95
|
+
} },
|
|
96
|
+
...layoutItems(t),
|
|
97
|
+
{ key: "hr", title: t.hr, hint: t.hrHint, icon: Minus, keywords: "duong ke divider hr", run: (e, r) => chain(e, r).setHorizontalRule().run() },
|
|
98
|
+
{ key: "shortcode", title: t.shortcode, hint: "[ten-shortcode]", icon: Braces, keywords: "shortcode plugin", run: async (e, r) => {
|
|
99
|
+
chain(e, r).run();
|
|
100
|
+
const res = await askOf(e)({ title: t.shortcode, fields: [{ key: "sc", label: t.shortcodePrompt, placeholder: "contact-form" }], submit: t.insert });
|
|
101
|
+
const sc = res && res !== "remove" ? String(res.sc).trim().replace(/^\[|\]$/g, "") : "";
|
|
102
|
+
if (sc) e.chain().focus().insertContent({ type: "paragraph", content: [{ type: "text", text: `[${sc}]` }] }).run();
|
|
103
|
+
} },
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ---------------------------------------------------------------------------
|
|
108
|
+
// Slash menu ("/") — trạng thái riêng cho từng trình soạn
|
|
109
|
+
// ---------------------------------------------------------------------------
|
|
110
|
+
type SlashState = { props: SuggestionProps<InsertItem> | null; index: number };
|
|
111
|
+
|
|
112
|
+
function createSlashStore() {
|
|
113
|
+
let state: SlashState = { props: null, index: 0 };
|
|
114
|
+
const listeners = new Set<() => void>();
|
|
115
|
+
return {
|
|
116
|
+
get: () => state,
|
|
117
|
+
set(s: Partial<SlashState>) { state = { ...state, ...s }; listeners.forEach((l) => l()); },
|
|
118
|
+
subscribe(l: () => void) { listeners.add(l); return () => { listeners.delete(l); }; },
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
type SlashStore = ReturnType<typeof createSlashStore>;
|
|
122
|
+
|
|
123
|
+
function slashExtension(store: SlashStore, items: () => InsertItem[]) {
|
|
124
|
+
return Extension.create({
|
|
125
|
+
name: "slashCommand",
|
|
126
|
+
addProseMirrorPlugins() {
|
|
127
|
+
return [Suggestion<InsertItem>({
|
|
128
|
+
editor: this.editor,
|
|
129
|
+
char: "/",
|
|
130
|
+
startOfLine: false,
|
|
131
|
+
allowSpaces: true,
|
|
132
|
+
items: ({ query }) => rankItems(items(), query),
|
|
133
|
+
command: ({ editor, range, props }) => props.run(editor, range),
|
|
134
|
+
render: () => ({
|
|
135
|
+
onStart: (props) => store.set({ props, index: 0 }),
|
|
136
|
+
onUpdate: (props) => store.set({ props, index: 0 }),
|
|
137
|
+
onExit: () => store.set({ props: null, index: 0 }),
|
|
138
|
+
onKeyDown: ({ event }) => {
|
|
139
|
+
const s = store.get();
|
|
140
|
+
const list = s.props?.items ?? [];
|
|
141
|
+
if (list.length === 0) return false;
|
|
142
|
+
if (event.key === "ArrowDown") { store.set({ index: (s.index + 1) % list.length }); return true; }
|
|
143
|
+
if (event.key === "ArrowUp") { store.set({ index: (s.index - 1 + list.length) % list.length }); return true; }
|
|
144
|
+
if (event.key === "Enter") { const it = list[s.index]; if (it) s.props?.command(it); return true; }
|
|
145
|
+
if (event.key === "Escape") { store.set({ props: null }); return true; }
|
|
146
|
+
return false;
|
|
147
|
+
},
|
|
148
|
+
}),
|
|
149
|
+
})];
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function SlashMenu({ store, t }: { store: SlashStore; t: EditorLabels }) {
|
|
155
|
+
const s = useSyncExternalStore(store.subscribe, store.get);
|
|
156
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
157
|
+
useEffect(() => { ref.current?.querySelector(`[data-i="${s.index}"]`)?.scrollIntoView({ block: "nearest" }); }, [s.index]);
|
|
158
|
+
if (!s.props) return null;
|
|
159
|
+
// Đang viết câu có dấu "/" (không còn lệnh phù hợp) → ẩn menu
|
|
160
|
+
if (s.props.items.length === 0 && /\s\S*\s/.test(s.props.query + " ")) return null;
|
|
161
|
+
const rect = s.props.clientRect?.();
|
|
162
|
+
if (!rect) return null;
|
|
163
|
+
return createPortal(
|
|
164
|
+
<div ref={ref} className="cms-ed-slash" style={{ top: Math.min(rect.bottom + 6, window.innerHeight - 320), left: rect.left }}>
|
|
165
|
+
{s.props.items.length === 0 ? <div className="cms-ed-slash-empty">{t.noCommand}</div> : s.props.items.map((it, i) => (
|
|
166
|
+
<button key={it.key} type="button" data-i={i} className={cx("cms-ed-slash-item", i === s.index && "is-active")}
|
|
167
|
+
onMouseDown={(e) => { e.preventDefault(); s.props?.command(it); }} onMouseMove={() => store.get().index !== i && store.set({ index: i })}>
|
|
168
|
+
<span className="cms-ed-slash-icon"><it.icon size={16} /></span>
|
|
169
|
+
<span><span className="cms-ed-slash-title">{it.title}</span><span className="cms-ed-slash-hint">{it.hint}</span></span>
|
|
170
|
+
</button>
|
|
171
|
+
))}
|
|
172
|
+
</div>,
|
|
173
|
+
document.body,
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// ---------------------------------------------------------------------------
|
|
178
|
+
// Thanh công cụ & menu nổi
|
|
179
|
+
// ---------------------------------------------------------------------------
|
|
180
|
+
function Btn({ onClick, active, title, children, disabled }: { onClick(): void; active?: boolean; title: string; children: ReactNode; disabled?: boolean }) {
|
|
181
|
+
return (
|
|
182
|
+
<button type="button" title={title} aria-label={title} aria-pressed={active} disabled={disabled} onMouseDown={(e) => e.preventDefault()} onClick={onClick}
|
|
183
|
+
className={cx("cms-ed-btn", active && "is-active")}>{children}</button>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
const Sep = () => <span className="cms-ed-sep" />;
|
|
187
|
+
|
|
188
|
+
function useMarks(editor: TiptapEditor) {
|
|
189
|
+
return useEditorState({
|
|
190
|
+
editor,
|
|
191
|
+
selector: ({ editor: e }) => ({
|
|
192
|
+
bold: e.isActive("bold"), italic: e.isActive("italic"), underline: e.isActive("underline"), strike: e.isActive("strike"),
|
|
193
|
+
code: e.isActive("code"), link: e.isActive("link"), h2: e.isActive("heading", { level: 2 }), h3: e.isActive("heading", { level: 3 }),
|
|
194
|
+
ul: e.isActive("bulletList"), ol: e.isActive("orderedList"), quote: e.isActive("blockquote"),
|
|
195
|
+
left: e.isActive({ textAlign: "left" }), center: e.isActive({ textAlign: "center" }), right: e.isActive({ textAlign: "right" }),
|
|
196
|
+
table: e.isActive("table"), canUndo: e.can().undo(), canRedo: e.can().redo(),
|
|
197
|
+
}),
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Chèn bảng: hỏi số cột × số hàng (mặc định 3 × 3, có hàng tiêu đề). */
|
|
202
|
+
async function insertTableAsk(editor: TiptapEditor, t: EditorLabels) {
|
|
203
|
+
const res = await askOf(editor)({
|
|
204
|
+
title: t.table,
|
|
205
|
+
fields: [
|
|
206
|
+
{ key: "cols", label: t.tableCols, type: "number", value: "3" },
|
|
207
|
+
{ key: "rows", label: t.tableRows, type: "number", value: "3" },
|
|
208
|
+
{ key: "header", label: t.headerRow, type: "checkbox", value: true },
|
|
209
|
+
],
|
|
210
|
+
submit: t.insert,
|
|
211
|
+
});
|
|
212
|
+
if (!res || res === "remove") return;
|
|
213
|
+
const clamp = (v: unknown, d: number) => Math.min(20, Math.max(1, Number(v) || d));
|
|
214
|
+
editor.chain().focus().insertTable({ cols: clamp(res.cols, 3), rows: clamp(res.rows, 3), withHeaderRow: !!res.header }).run();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async function setLink(editor: TiptapEditor, t: EditorLabels) {
|
|
218
|
+
const prev = editor.getAttributes("link") as { href?: string; target?: string | null };
|
|
219
|
+
const res = await askOf(editor)({
|
|
220
|
+
title: t.link.replace(/\s*\(.*\)$/, ""),
|
|
221
|
+
fields: [
|
|
222
|
+
{ key: "href", label: t.linkPrompt, type: "url", value: prev.href ?? "", placeholder: "https://" },
|
|
223
|
+
{ key: "blank", label: t.linkNewTab, type: "checkbox", value: prev.href ? prev.target === "_blank" : false },
|
|
224
|
+
],
|
|
225
|
+
remove: prev.href ? t.removeLink : undefined,
|
|
226
|
+
});
|
|
227
|
+
if (!res) return;
|
|
228
|
+
const c = editor.chain().focus().extendMarkRange("link");
|
|
229
|
+
const url = res === "remove" ? "" : String(res.href).trim();
|
|
230
|
+
if (url === "") c.unsetLink().run();
|
|
231
|
+
else c.setLink({ href: url, target: res !== "remove" && res.blank ? "_blank" : null }).run();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function Toolbar({ editor, t, requestMedia, items }: { editor: TiptapEditor; t: EditorLabels; requestMedia: RequestMedia; items: InsertItem[] }) {
|
|
235
|
+
const s = useMarks(editor);
|
|
236
|
+
const c = () => editor.chain().focus();
|
|
237
|
+
return (
|
|
238
|
+
<div className="cms-ed-toolbar-row">
|
|
239
|
+
<Btn title={t.undo} disabled={!s.canUndo} onClick={() => c().undo().run()}><Undo2 size={16} /></Btn>
|
|
240
|
+
<Btn title={t.redo} disabled={!s.canRedo} onClick={() => c().redo().run()}><Redo2 size={16} /></Btn>
|
|
241
|
+
<Sep />
|
|
242
|
+
<Btn title={t.h2} active={s.h2} onClick={() => c().toggleHeading({ level: 2 }).run()}><Heading2 size={16} /></Btn>
|
|
243
|
+
<Btn title={t.h3} active={s.h3} onClick={() => c().toggleHeading({ level: 3 }).run()}><Heading3 size={16} /></Btn>
|
|
244
|
+
<Btn title={t.bulletList} active={s.ul} onClick={() => c().toggleBulletList().run()}><List size={16} /></Btn>
|
|
245
|
+
<Btn title={t.orderedList} active={s.ol} onClick={() => c().toggleOrderedList().run()}><ListOrdered size={16} /></Btn>
|
|
246
|
+
<Btn title={t.quote} active={s.quote} onClick={() => c().toggleBlockquote().run()}><Quote size={16} /></Btn>
|
|
247
|
+
<Sep />
|
|
248
|
+
<Btn title={t.alignLeft} active={s.left} onClick={() => c().setTextAlign("left").run()}><AlignLeft size={16} /></Btn>
|
|
249
|
+
<Btn title={t.alignCenter} active={s.center} onClick={() => c().setTextAlign("center").run()}><AlignCenter size={16} /></Btn>
|
|
250
|
+
<Btn title={t.alignRight} active={s.right} onClick={() => c().setTextAlign("right").run()}><AlignRight size={16} /></Btn>
|
|
251
|
+
<Sep />
|
|
252
|
+
<Btn title={t.insertImage} onClick={() => requestMedia(editor, "image")}><ImageIcon size={16} /></Btn>
|
|
253
|
+
<Btn title={t.gallery} onClick={() => requestMedia(editor, "gallery")}><Images size={16} /></Btn>
|
|
254
|
+
<Btn title={t.insertTable} active={s.table} onClick={() => insertTableAsk(editor, t)}><Table2 size={16} /></Btn>
|
|
255
|
+
<Btn title={t.insertVideo} onClick={() => items.find((x) => x.key === "youtube")?.run(editor)}><Video size={16} /></Btn>
|
|
256
|
+
{s.table && (
|
|
257
|
+
<span className="cms-ed-table-tools">
|
|
258
|
+
{([[t.addRow, () => c().addRowAfter().run()], [t.addCol, () => c().addColumnAfter().run()], [t.delRow, () => c().deleteRow().run()], [t.delCol, () => c().deleteColumn().run()]] as const).map(([l, f]) => (
|
|
259
|
+
<button key={l} type="button" onClick={f}>{l}</button>
|
|
260
|
+
))}
|
|
261
|
+
<button type="button" className="is-danger" onClick={() => c().deleteTable().run()}>{t.delTable}</button>
|
|
262
|
+
</span>
|
|
263
|
+
)}
|
|
264
|
+
<span className="cms-ed-hint">{t.slashHint}</span>
|
|
265
|
+
</div>
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function SelectionMenu({ editor, t }: { editor: TiptapEditor; t: EditorLabels }) {
|
|
270
|
+
const s = useMarks(editor);
|
|
271
|
+
const c = () => editor.chain().focus();
|
|
272
|
+
return (
|
|
273
|
+
<BubbleMenu editor={editor} shouldShow={({ editor: e, from, to }) => from !== to && !(e.state.selection instanceof NodeSelection) && !e.isActive("codeBlock")} className="cms-ed-bubble">
|
|
274
|
+
<Btn title={t.bold} active={s.bold} onClick={() => c().toggleBold().run()}><Bold size={16} /></Btn>
|
|
275
|
+
<Btn title={t.italic} active={s.italic} onClick={() => c().toggleItalic().run()}><Italic size={16} /></Btn>
|
|
276
|
+
<Btn title={t.underline} active={s.underline} onClick={() => c().toggleUnderline().run()}><Underline size={16} /></Btn>
|
|
277
|
+
<Btn title={t.strike} active={s.strike} onClick={() => c().toggleStrike().run()}><Strikethrough size={16} /></Btn>
|
|
278
|
+
<Btn title={t.code} active={s.code} onClick={() => c().toggleCode().run()}><Code size={16} /></Btn>
|
|
279
|
+
<Sep />
|
|
280
|
+
<Btn title={t.link} active={s.link} onClick={() => setLink(editor, t)}><Link2 size={16} /></Btn>
|
|
281
|
+
<Sep />
|
|
282
|
+
<Btn title={t.h2} active={s.h2} onClick={() => c().toggleHeading({ level: 2 }).run()}><Heading2 size={16} /></Btn>
|
|
283
|
+
<Btn title={t.h3} active={s.h3} onClick={() => c().toggleHeading({ level: 3 }).run()}><Heading3 size={16} /></Btn>
|
|
284
|
+
<Btn title={t.quote} active={s.quote} onClick={() => c().toggleBlockquote().run()}><Quote size={16} /></Btn>
|
|
285
|
+
</BubbleMenu>
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** CSS kiểu dáng khối (attrs.style) của bài — cùng CSS với website. */
|
|
290
|
+
function DocumentStyles({ editor, presets }: { editor: TiptapEditor; presets?: StylePresets }) {
|
|
291
|
+
const css = presetsCss(presets) + useEditorState({ editor, selector: ({ editor: e }) => documentStyleCss(e) });
|
|
292
|
+
return css ? <style data-ecx-styles="">{css}</style> : null;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** Đếm từ / ký tự / thời gian đọc (200 từ mỗi phút) — dưới vùng soạn. */
|
|
296
|
+
function Stats({ editor, t }: { editor: TiptapEditor; t: EditorLabels }) {
|
|
297
|
+
const s = useEditorState({ editor, selector: ({ editor: e }) => {
|
|
298
|
+
const text = e.state.doc.textBetween(0, e.state.doc.content.size, "\n", "\n");
|
|
299
|
+
const words = text.split(/\s+/).filter(Boolean).length;
|
|
300
|
+
return { words, chars: text.replace(/\n/g, "").length };
|
|
301
|
+
} });
|
|
302
|
+
const fmt = (tpl: string, n: number) => tpl.replace("{n}", n.toLocaleString());
|
|
303
|
+
return (
|
|
304
|
+
<div className="cms-ed-stats" aria-label={t.stats}>
|
|
305
|
+
<span>{fmt(t.words, s.words)}</span><span>{fmt(t.chars, s.chars)}</span>{s.words > 0 && <span>{fmt(t.readingTime, Math.max(1, Math.round(s.words / 200)))}</span>}
|
|
306
|
+
</div>
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// ---------------------------------------------------------------------------
|
|
311
|
+
// Editor
|
|
312
|
+
// ---------------------------------------------------------------------------
|
|
313
|
+
/** Trình soạn nội dung. Dùng kèm CSS: import "@ecomcx/ecomweb-editor/style.css". */
|
|
314
|
+
const NO_PACKS: EditorExtensionPack[] = [];
|
|
315
|
+
|
|
316
|
+
export function Editor({ initial, onChange, media, labels, extensions: localPacks = NO_PACKS, toolbarClassName, className, onReady, ariaLabel, dynamicBlocks = false, presets, patterns }: EditorProps) {
|
|
317
|
+
const t = useMemo(() => ({ ...viLabels, ...labels }), [labels]);
|
|
318
|
+
const slash = useMemo(createSlashStore, []);
|
|
319
|
+
const globalPacks = useSyncExternalStore(onExtensionsChange, registeredExtensions);
|
|
320
|
+
const packs = useMemo(() => [...globalPacks, ...localPacks], [globalPacks, localPacks]);
|
|
321
|
+
const mediaRef = useRef(media); mediaRef.current = media;
|
|
322
|
+
const asker = useMemo(createAskStore, []);
|
|
323
|
+
const [menuRequest, setMenuRequest] = useState(0);
|
|
324
|
+
const editorRef = useRef<TiptapEditor | null>(null);
|
|
325
|
+
|
|
326
|
+
// Chọn media → chèn node phù hợp. Không có MediaProvider: ảnh/video nhập bằng URL.
|
|
327
|
+
const requestMedia: RequestMedia = async (editor, kind) => {
|
|
328
|
+
const provider = mediaRef.current;
|
|
329
|
+
let list: MediaItem[] = [];
|
|
330
|
+
if (provider) list = await provider.pick({ kind, multiple: kind === "gallery" });
|
|
331
|
+
else {
|
|
332
|
+
const res = await asker.ask({ title: kind === "video" ? t.video : t.image, fields: [{ key: "url", label: t.imageUrlPrompt, type: "url", placeholder: "https://" }], submit: t.insert });
|
|
333
|
+
const url = res && res !== "remove" ? String(res.url).trim() : "";
|
|
334
|
+
if (url) list = [{ id: url, url, mimeType: kind === "video" ? "video/mp4" : "image/*", fileName: url.split("/").pop() ?? url }];
|
|
335
|
+
}
|
|
336
|
+
if (!list.length) return;
|
|
337
|
+
const m = list[0];
|
|
338
|
+
const c = editor.chain().focus();
|
|
339
|
+
switch (kind) {
|
|
340
|
+
case "image": editor.isActive("image") ? c.updateAttributes("image", { ...imageAttrs(m), align: editor.getAttributes("image").align }).run() : c.insertContent({ type: "image", attrs: imageAttrs(m) }).run(); break;
|
|
341
|
+
case "gallery": c.insertContent({ type: "gallery", attrs: { images: list.map(galleryImage), columns: Math.min(4, Math.max(2, list.length)) } }).run(); break;
|
|
342
|
+
case "video": c.insertContent({ type: "video", attrs: { src: m.url, name: m.fileName, mime: m.mimeType, mediaId: m.id } }).run(); break;
|
|
343
|
+
case "audio": c.insertContent({ type: "audio", attrs: { src: m.url, name: m.fileName, mime: m.mimeType, mediaId: m.id } }).run(); break;
|
|
344
|
+
case "file": c.insertContent({ type: "file", attrs: { src: m.url, name: m.title || m.fileName, mime: m.mimeType, mediaId: m.id, size: m.size } }).run(); break;
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
const items = useMemo(() => [...defaultItems(t, requestMedia), ...packs.flatMap((p) => p.insertItems ?? [])]
|
|
348
|
+
.filter((i) => dynamicBlocks || !(i.key.startsWith("block:") && DYNAMIC_BLOCKS.has(i.key.slice(6)))), [t, packs, dynamicBlocks]);
|
|
349
|
+
const itemsRef = useRef(items); itemsRef.current = items;
|
|
350
|
+
|
|
351
|
+
const editor = useEditor({
|
|
352
|
+
extensions: [
|
|
353
|
+
...coreExtensions(),
|
|
354
|
+
Placeholder.configure({ placeholder: ({ node }) => (node.type.name === "heading" ? t.headingPlaceholder : t.placeholder), showOnlyCurrent: true }),
|
|
355
|
+
slashExtension(slash, () => itemsRef.current),
|
|
356
|
+
BlockKeys.configure({ openMenu: () => setMenuRequest((n) => n + 1) }),
|
|
357
|
+
...packs.flatMap((p) => p.extensions ?? []),
|
|
358
|
+
],
|
|
359
|
+
// Khối / định dạng lạ (plugin đã tắt) được bọc giữ nguyên thay vì làm trình soạn báo lỗi
|
|
360
|
+
content: initial && typeof initial === "object" ? wrapUnknown(initial, knownTypes(packs.flatMap((p) => p.extensions ?? []))) : initial || "",
|
|
361
|
+
onUpdate: ({ editor: e }) => onChange(unwrapUnknown(e.getJSON() as any)),
|
|
362
|
+
editorProps: {
|
|
363
|
+
// Vùng soạn là ô nhập nhiều dòng có tên (axe: aria-input-field-name)
|
|
364
|
+
attributes: { class: "cms-ed-content ecx-content", role: "textbox", "aria-multiline": "true", "aria-label": ariaLabel ?? t.editorLabel },
|
|
365
|
+
// Dán từ Word / Google Docs: bỏ style, font, màu, thẻ Office; danh sách Word thành danh sách thật
|
|
366
|
+
transformPastedHTML: (html) => cleanPastedHtml(html),
|
|
367
|
+
// Dán một đường dẫn của nhà cung cấp hỗ trợ vào dòng trống → khối nhúng
|
|
368
|
+
// Thả một khối từ trình chèn (cột trái của ứng dụng)
|
|
369
|
+
handleDrop: (view, event): boolean => !!editorRef.current && handleInsertDrop(editorRef.current, view, event as DragEvent),
|
|
370
|
+
handlePaste: (view, event) => {
|
|
371
|
+
const text = event.clipboardData?.getData("text/plain") ?? "";
|
|
372
|
+
const { $from, empty } = view.state.selection;
|
|
373
|
+
if (!empty || !isUrl(text) || $from.parent.type.name !== "paragraph" || $from.parent.content.size > 0 || !embedInfo(text.trim())) return false;
|
|
374
|
+
const node = view.state.schema.nodes.embed.create({ url: text.trim() });
|
|
375
|
+
view.dispatch(view.state.tr.replaceWith($from.before(), $from.after(), node).scrollIntoView());
|
|
376
|
+
return true;
|
|
377
|
+
},
|
|
378
|
+
handleKeyDown: (_view, event) => {
|
|
379
|
+
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k" && editor) { event.preventDefault(); event.stopPropagation(); setLink(editor, t); return true; }
|
|
380
|
+
return false;
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
immediatelyRender: true,
|
|
384
|
+
}, [packs.map((p) => p.name).join(",")]);
|
|
385
|
+
|
|
386
|
+
editorRef.current = editor;
|
|
387
|
+
useEffect(() => {
|
|
388
|
+
if (!editor) return;
|
|
389
|
+
const ctx = (editor.storage as any).cmsEditorContext as { labels: EditorLabels; ask: Ask };
|
|
390
|
+
ctx.labels = t; ctx.ask = asker.ask;
|
|
391
|
+
(ctx as any).setLink = () => setLink(editor, t);
|
|
392
|
+
// Điều khiển "media" trong form cài đặt khối: chọn từ thư viện của ứng dụng, không có thì nhập URL
|
|
393
|
+
setImagePicker(async () => {
|
|
394
|
+
const provider = mediaRef.current;
|
|
395
|
+
if (provider) { const [m] = await provider.pick({ kind: "image", multiple: false }); return m ? { url: m.url, id: m.id, alt: m.alt } : null; }
|
|
396
|
+
const r = await asker.ask({ title: t.image, fields: [{ key: "url", label: t.imageUrlPrompt, type: "url", placeholder: "https://" }], submit: t.insert });
|
|
397
|
+
return r && r !== "remove" && String(r.url).trim() ? { url: String(r.url).trim() } : null;
|
|
398
|
+
});
|
|
399
|
+
onReady?.(editor);
|
|
400
|
+
}, [editor, t]);
|
|
401
|
+
// Nguồn mẫu của ứng dụng (mẫu đồng bộ, "Tạo mẫu") cho node view và menu khối
|
|
402
|
+
useEffect(() => { if (editor) (editor.storage as any).cmsEditorContext.patterns = patterns; }, [editor, patterns]);
|
|
403
|
+
// Lệnh chèn (gồm khối plugin) cho trình chèn ở ngoài trình soạn (BlockInserter); giao dịch rỗng để nó đọc lại
|
|
404
|
+
useEffect(() => {
|
|
405
|
+
if (!editor || editor.isDestroyed) return;
|
|
406
|
+
(editor.storage as any).cmsEditorContext.items = items;
|
|
407
|
+
editor.view.dispatch(editor.state.tr.setMeta("cmsItems", true));
|
|
408
|
+
}, [editor, items]);
|
|
409
|
+
|
|
410
|
+
return (
|
|
411
|
+
<div className={cx("cms-editor", className)}>
|
|
412
|
+
{editor && <div className={cx("cms-ed-toolbar", toolbarClassName)}><Toolbar editor={editor} t={t} requestMedia={requestMedia} items={items} /></div>}
|
|
413
|
+
{editor && <OverlayBoundary editor={editor} name="SelectionMenu"><SelectionMenu editor={editor} t={t} /></OverlayBoundary>}
|
|
414
|
+
{editor && <DocumentStyles editor={editor} presets={presets} />}
|
|
415
|
+
<EditorContent editor={editor} />
|
|
416
|
+
<SlashMenu store={slash} t={t} />
|
|
417
|
+
{editor && <OverlayBoundary editor={editor} name="BlockHandle"><BlockHandle editor={editor} t={t} menuRequest={menuRequest} /></OverlayBoundary>}
|
|
418
|
+
{editor && <OverlayBoundary editor={editor} name="AskPopover"><AskPopover store={asker} editor={editor} t={t} /></OverlayBoundary>}
|
|
419
|
+
{editor && <OverlayBoundary editor={editor} name="BlockSettingsBar"><BlockSettingsBar editor={editor} t={t} /></OverlayBoundary>}
|
|
420
|
+
{editor && <OverlayBoundary editor={editor} name="BlockToolbar"><BlockToolbar editor={editor} t={t} media={media} requestMedia={requestMedia} /></OverlayBoundary>}
|
|
421
|
+
{editor && <OverlayBoundary editor={editor} name="CanvasHandles"><CanvasHandles editor={editor} t={t} /></OverlayBoundary>}
|
|
422
|
+
{editor && <OverlayBoundary editor={editor} name="Stats"><Stats editor={editor} t={t} /></OverlayBoundary>}
|
|
423
|
+
</div>
|
|
424
|
+
);
|
|
425
|
+
}
|
package/src/ask.tsx
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { Editor as TiptapEditor } from "@tiptap/core";
|
|
2
|
+
import { useEffect, useId, useLayoutEffect, useRef, useState, useSyncExternalStore, type KeyboardEvent } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import type { EditorLabels } from "./labels";
|
|
5
|
+
import { cx } from "./util";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Hộp nhập nhỏ đặt cạnh chỗ đang soạn (thay window.prompt): link, alt, chú thích, YouTube, shortcode, cài đặt khối.
|
|
9
|
+
* Enter = áp dụng, Esc / bấm ra ngoài = huỷ, Tab không thoát khỏi hộp; đóng xong con trỏ về trình soạn.
|
|
10
|
+
*/
|
|
11
|
+
export interface AskField {
|
|
12
|
+
key: string;
|
|
13
|
+
label: string;
|
|
14
|
+
value?: string | boolean;
|
|
15
|
+
type?: "text" | "url" | "number" | "textarea" | "checkbox" | "select";
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
options?: Array<{ value: string; label: string }>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface AskOptions {
|
|
21
|
+
title: string;
|
|
22
|
+
fields: AskField[];
|
|
23
|
+
/** Chữ nút áp dụng (mặc định labels.apply). */
|
|
24
|
+
submit?: string;
|
|
25
|
+
/** Có → hiện nút phụ (vd "Gỡ liên kết"); bấm trả về "remove". */
|
|
26
|
+
remove?: string;
|
|
27
|
+
/** Vị trí neo (mặc định: chỗ con trỏ). */
|
|
28
|
+
anchor?: { left: number; top: number; bottom: number };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type AskResult = Record<string, string | boolean> | "remove" | null;
|
|
32
|
+
export type Ask = (opts: AskOptions) => Promise<AskResult>;
|
|
33
|
+
|
|
34
|
+
type AskState = { opts: AskOptions; resolve(r: AskResult): void } | null;
|
|
35
|
+
|
|
36
|
+
export function createAskStore() {
|
|
37
|
+
let state: AskState = null;
|
|
38
|
+
const listeners = new Set<() => void>();
|
|
39
|
+
const set = (s: AskState) => { state = s; listeners.forEach((l) => l()); };
|
|
40
|
+
return {
|
|
41
|
+
get: () => state,
|
|
42
|
+
subscribe(l: () => void) { listeners.add(l); return () => { listeners.delete(l); }; },
|
|
43
|
+
ask: ((opts) => new Promise<AskResult>((resolve) => { state?.resolve(null); set({ opts, resolve }); })) as Ask,
|
|
44
|
+
close(r: AskResult) { const s = state; set(null); s?.resolve(r); },
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export type AskStore = ReturnType<typeof createAskStore>;
|
|
48
|
+
|
|
49
|
+
/** Hàm hỏi của trình soạn (để node view / gói mở rộng dùng chung một kiểu hộp nhập). */
|
|
50
|
+
export const askOf = (editor: TiptapEditor): Ask => (editor.storage as any).cmsEditorContext?.ask ?? (async () => null);
|
|
51
|
+
|
|
52
|
+
function anchorOf(editor: TiptapEditor) {
|
|
53
|
+
try {
|
|
54
|
+
const c = editor.view.coordsAtPos(editor.state.selection.from);
|
|
55
|
+
return { left: c.left, top: c.top, bottom: c.bottom };
|
|
56
|
+
} catch {
|
|
57
|
+
const r = editor.view.dom.getBoundingClientRect();
|
|
58
|
+
return { left: r.left + 16, top: r.top, bottom: r.top + 24 };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const FOCUSABLE = "input, select, textarea, button:not(:disabled)";
|
|
63
|
+
|
|
64
|
+
export function AskPopover({ store, editor, t }: { store: AskStore; editor: TiptapEditor; t: EditorLabels }) {
|
|
65
|
+
const state = useSyncExternalStore(store.subscribe, store.get);
|
|
66
|
+
if (!state) return null;
|
|
67
|
+
// key: mở hộp mới → làm mới giá trị
|
|
68
|
+
return <AskForm key={state.opts.title + state.opts.fields.map((f) => f.key).join()} state={state} store={store} editor={editor} t={t} />;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function AskForm({ state, store, editor, t }: { state: NonNullable<AskState>; store: AskStore; editor: TiptapEditor; t: EditorLabels }) {
|
|
72
|
+
const { opts } = state;
|
|
73
|
+
const id = useId();
|
|
74
|
+
const ref = useRef<HTMLFormElement>(null);
|
|
75
|
+
const [values, setValues] = useState<Record<string, string | boolean>>(() =>
|
|
76
|
+
Object.fromEntries(opts.fields.map((f) => [f.key, f.value ?? (f.type === "checkbox" ? false : f.type === "select" ? f.options?.[0]?.value ?? "" : "")])));
|
|
77
|
+
const [anchor] = useState(() => opts.anchor ?? anchorOf(editor));
|
|
78
|
+
const [pos, setPos] = useState<{ left: number; top: number } | null>(null);
|
|
79
|
+
|
|
80
|
+
const close = (r: AskResult) => { store.close(r); editor.commands.focus(); };
|
|
81
|
+
|
|
82
|
+
// Đặt dưới chỗ neo; không đủ chỗ thì lên trên; luôn nằm trong màn hình
|
|
83
|
+
useLayoutEffect(() => {
|
|
84
|
+
const el = ref.current;
|
|
85
|
+
if (!el) return;
|
|
86
|
+
const w = el.offsetWidth, h = el.offsetHeight;
|
|
87
|
+
const left = Math.max(8, Math.min(anchor.left, window.innerWidth - w - 8));
|
|
88
|
+
const below = anchor.bottom + 8;
|
|
89
|
+
const top = below + h > window.innerHeight - 8 && anchor.top - h - 8 > 8 ? anchor.top - h - 8 : Math.max(8, Math.min(below, window.innerHeight - h - 8));
|
|
90
|
+
setPos({ left, top });
|
|
91
|
+
}, [anchor]);
|
|
92
|
+
|
|
93
|
+
// Focus khi hộp đã hiện (lúc còn ẩn để đo kích thước thì không nhận focus)
|
|
94
|
+
const focused = useRef(false);
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (!pos || focused.current) return;
|
|
97
|
+
focused.current = true;
|
|
98
|
+
const first = ref.current?.querySelector<HTMLElement>(FOCUSABLE);
|
|
99
|
+
first?.focus();
|
|
100
|
+
if (first instanceof HTMLInputElement && first.type !== "checkbox") first.select();
|
|
101
|
+
}, [pos]);
|
|
102
|
+
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
const outside = (e: MouseEvent) => { if (ref.current && !ref.current.contains(e.target as Node)) close(null); };
|
|
105
|
+
// Esc huỷ cả khi focus không nằm trong hộp
|
|
106
|
+
const esc = (e: globalThis.KeyboardEvent) => { if (e.key === "Escape") { e.preventDefault(); e.stopPropagation(); close(null); } };
|
|
107
|
+
document.addEventListener("mousedown", outside, true);
|
|
108
|
+
document.addEventListener("keydown", esc, true);
|
|
109
|
+
return () => { document.removeEventListener("mousedown", outside, true); document.removeEventListener("keydown", esc, true); };
|
|
110
|
+
}, []);
|
|
111
|
+
|
|
112
|
+
function onKeyDown(e: KeyboardEvent) {
|
|
113
|
+
if (e.key === "Tab") {
|
|
114
|
+
const items = [...(ref.current?.querySelectorAll<HTMLElement>(FOCUSABLE) ?? [])];
|
|
115
|
+
if (!items.length) return;
|
|
116
|
+
const i = items.indexOf(document.activeElement as HTMLElement);
|
|
117
|
+
const next = e.shiftKey ? (i <= 0 ? items.length - 1 : i - 1) : (i === items.length - 1 ? 0 : i + 1);
|
|
118
|
+
e.preventDefault(); items[next].focus();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const set = (k: string, v: string | boolean) => setValues((s) => ({ ...s, [k]: v }));
|
|
123
|
+
return createPortal(
|
|
124
|
+
<form ref={ref} role="dialog" aria-labelledby={`${id}-title`} className="cms-ed-ask" onKeyDown={onKeyDown}
|
|
125
|
+
style={pos ? { left: pos.left, top: pos.top } : { left: anchor.left, top: anchor.bottom + 8, visibility: "hidden" }}
|
|
126
|
+
onSubmit={(e) => { e.preventDefault(); close(values); }}>
|
|
127
|
+
<div id={`${id}-title`} className="cms-ed-ask-title">{opts.title}</div>
|
|
128
|
+
{opts.fields.map((f) => {
|
|
129
|
+
const fid = `${id}-${f.key}`;
|
|
130
|
+
if (f.type === "checkbox") return (
|
|
131
|
+
<label key={f.key} className="cms-ed-ask-check" htmlFor={fid}>
|
|
132
|
+
<input id={fid} type="checkbox" checked={!!values[f.key]} onChange={(e) => set(f.key, e.target.checked)} /> {f.label}
|
|
133
|
+
</label>
|
|
134
|
+
);
|
|
135
|
+
return (
|
|
136
|
+
<label key={f.key} className="cms-ed-ask-field" htmlFor={fid}>
|
|
137
|
+
<span>{f.label}</span>
|
|
138
|
+
{f.type === "textarea" ? <textarea id={fid} rows={3} value={String(values[f.key])} placeholder={f.placeholder} onChange={(e) => set(f.key, e.target.value)}
|
|
139
|
+
onKeyDown={(e) => { if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) { e.preventDefault(); close(values); } }} />
|
|
140
|
+
: f.type === "select" ? <select id={fid} value={String(values[f.key])} onChange={(e) => set(f.key, e.target.value)}>{f.options?.map((o) => <option key={o.value} value={o.value}>{o.label}</option>)}</select>
|
|
141
|
+
: <input id={fid} type={f.type === "url" || f.type === "number" ? f.type : "text"} min={f.type === "number" ? 1 : undefined} value={String(values[f.key])} placeholder={f.placeholder} onChange={(e) => set(f.key, e.target.value)} />}
|
|
142
|
+
</label>
|
|
143
|
+
);
|
|
144
|
+
})}
|
|
145
|
+
<div className="cms-ed-ask-actions">
|
|
146
|
+
{opts.remove && <button type="button" className={cx("cms-ed-ask-btn", "is-danger")} onClick={() => close("remove")}>{opts.remove}</button>}
|
|
147
|
+
<span className="cms-ed-ask-spacer" />
|
|
148
|
+
<button type="button" className="cms-ed-ask-btn" onClick={() => close(null)}>{t.cancel}</button>
|
|
149
|
+
<button type="submit" className={cx("cms-ed-ask-btn", "is-primary")}>{opts.submit ?? t.apply}</button>
|
|
150
|
+
</div>
|
|
151
|
+
</form>,
|
|
152
|
+
document.body,
|
|
153
|
+
);
|
|
154
|
+
}
|