superdoc 0.30.0-next.1 → 0.30.0-next.3
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/dist/chunks/{PdfViewer-Mru9qU0u.cjs → PdfViewer-BIJ6vJck.cjs} +1 -1
- package/dist/chunks/{PdfViewer-DNnHwEf_.es.js → PdfViewer-YWtbYClb.es.js} +1 -1
- package/dist/chunks/{index-DcqOqWRC.es.js → index-Bh45DPpT.es.js} +3 -3
- package/dist/chunks/{index-s9auAjqk.cjs → index-Br4fKccD.cjs} +3 -3
- package/dist/chunks/{index-C3nnrhrj-D6qn1DZi.cjs → index-D9ggxe26-BbC5rNDO.cjs} +1 -1
- package/dist/chunks/{index-C3nnrhrj-D8emuLzt.es.js → index-D9ggxe26-Dk1kDrfi.es.js} +1 -1
- package/dist/chunks/{super-editor.es-DPd8_luo.cjs → super-editor.es-4me2z6up.cjs} +14026 -15594
- package/dist/chunks/{super-editor.es-D1glcoJr.es.js → super-editor.es-FtXwm03k.es.js} +14026 -15594
- package/dist/packages/superdoc/src/core/SuperDoc.d.ts.map +1 -1
- package/dist/packages/superdoc/src/core/types/index.d.ts.map +1 -1
- package/dist/style.css +4 -25
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-Z2aFlUnt.js → converter-SZ8xM5Dw.js} +13677 -14180
- package/dist/super-editor/chunks/{docx-zipper-DIZfYOpO.js → docx-zipper-GNdwONoA.js} +1 -1
- package/dist/super-editor/chunks/{editor-DCiWw1F7.js → editor-Bb8HzfEh.js} +1473 -2522
- package/dist/super-editor/chunks/{index-C3nnrhrj.js → index-D9ggxe26.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-B5-PSkGu.js → toolbar-DtCz6r-y.js} +2 -2
- package/dist/super-editor/converter.es.js +2 -2
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/style.css +4 -25
- package/dist/super-editor/super-editor/src/components/slash-menu/utils.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/components/toolbar/defaultItems.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/components/toolbar/super-toolbar.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/ExtensionService.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/InputRule.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/commands/__tests__/schemaWithLists.d.ts +1 -1
- package/dist/super-editor/super-editor/src/core/commands/changeListLevel.d.ts +15 -0
- package/dist/super-editor/super-editor/src/core/commands/changeListLevel.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/commands/decreaseListIndent.d.ts +1 -1
- package/dist/super-editor/super-editor/src/core/commands/decreaseListIndent.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/commands/increaseListIndent.d.ts +2 -1
- package/dist/super-editor/super-editor/src/core/commands/increaseListIndent.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/commands/index.d.ts +2 -7
- package/dist/super-editor/super-editor/src/core/commands/list-helpers/is-list.d.ts +1 -1
- package/dist/super-editor/super-editor/src/core/commands/list-helpers/is-list.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/commands/list-helpers/list-indent-helpers.d.ts +0 -1
- package/dist/super-editor/super-editor/src/core/commands/list-helpers/list-indent-helpers.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/commands/removeNumberingProperties.d.ts +4 -0
- package/dist/super-editor/super-editor/src/core/commands/removeNumberingProperties.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/commands/restartNumbering.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/commands/restartNumbering.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/commands/splitBlock.d.ts +2 -1
- package/dist/super-editor/super-editor/src/core/commands/splitBlock.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/commands/tests/test-schema.d.ts +1 -1
- package/dist/super-editor/super-editor/src/core/commands/toggleList.d.ts +6 -56
- package/dist/super-editor/super-editor/src/core/commands/toggleList.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/extensions/keymap.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/helpers/contentProcessor.d.ts +3 -3
- package/dist/super-editor/super-editor/src/core/helpers/createNodeFromContent.d.ts +2 -2
- package/dist/super-editor/super-editor/src/core/helpers/createNodeFromContent.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/helpers/importHtml.d.ts +2 -2
- package/dist/super-editor/super-editor/src/core/helpers/importHtml.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/helpers/importMarkdown.d.ts +2 -2
- package/dist/super-editor/super-editor/src/core/helpers/list-numbering-helpers.d.ts +15 -42
- package/dist/super-editor/super-editor/src/core/helpers/list-numbering-helpers.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/helpers/pasteListHelpers.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/helpers/pasteListHelpers.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/inputRules/docx-paste/docx-paste.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/inputRules/html/html-helpers.d.ts +2 -5
- package/dist/super-editor/super-editor/src/core/inputRules/html/html-helpers.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/SuperConverter.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/exporter.d.ts +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/exporter.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/helpers.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/helpers.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/styles.d.ts +26 -0
- package/dist/super-editor/super-editor/src/core/super-converter/styles.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/docxImporter.d.ts +3 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/docxImporter.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/listImporter.d.ts +0 -97
- package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/listImporter.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/markImporter.d.ts +11 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/markImporter.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/trackChangesImporter.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/index.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/utils.d.ts +30 -4
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/utils.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/adjustRightInd/adjustRightInd-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/adjustRightInd/adjustRightInd-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/adjustRightInd/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/adjustRightInd/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/autoSpaceDE/autoSpaceDE-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/autoSpaceDE/autoSpaceDE-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/autoSpaceDE/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/autoSpaceDE/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/autoSpaceDN/autoSpaceDN-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/autoSpaceDN/autoSpaceDN-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/autoSpaceDN/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/autoSpaceDN/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/b/b-translator.d.ts +1 -2
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/b/b-translator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/bCs/bCs-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/bCs/bCs-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/bCs/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/bCs/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/bar/bar-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/bar/bar-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/bar/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/bar/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/between/between-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/between/between-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/between/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/between/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/bidi/bidi-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/bidi/bidi-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/bidi/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/bidi/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/caps/caps-translator.d.ts +1 -2
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/caps/caps-translator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/color/color-translator.d.ts +1 -2
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/color/color-translator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/contextualSpacing/contextualSpacing-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/contextualSpacing/contextualSpacing-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/contextualSpacing/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/contextualSpacing/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/dstrike/dstrike-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/dstrike/dstrike-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/framePr/framePr-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/framePr/framePr-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/framePr/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/framePr/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/headers/headers-translator.d.ts +0 -2
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/headers/headers-translator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/i/i-translator.d.ts +1 -2
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/i/i-translator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/ilvl/ilvl-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/ilvl/ilvl-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/ilvl/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/ilvl/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/ind/ind-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/ind/ind-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/ind/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/ind/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/keepLines/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/keepLines/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/keepLines/keepLines-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/keepLines/keepLines-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/keepNext/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/keepNext/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/keepNext/keepNext-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/keepNext/keepNext-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/kinsoku/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/kinsoku/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/kinsoku/kinsoku-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/kinsoku/kinsoku-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/lang/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/lang/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/lang/lang-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/lang/lang-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/mirrorIndents/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/mirrorIndents/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/mirrorIndents/mirrorIndents-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/mirrorIndents/mirrorIndents-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/numId/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/numId/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/numId/numId-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/numId/numId-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/numPr/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/numPr/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/numPr/numPr-translator.d.ts +6 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/numPr/numPr-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/outlineLvl/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/outlineLvl/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/outlineLvl/outlineLvl-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/outlineLvl/outlineLvl-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/overflowPunct/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/overflowPunct/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/overflowPunct/overflowPunct-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/overflowPunct/overflowPunct-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/index.d.ts +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/legacy-handle-paragraph-node.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pBdr/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pBdr/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pBdr/pBdr-translator.d.ts +6 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pBdr/pBdr-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pPr/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pPr/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pPr/pPr-translator.d.ts +6 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pPr/pPr-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pStyle/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pStyle/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pStyle/pStyle-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pStyle/pStyle-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pageBreakBefore/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pageBreakBefore/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pageBreakBefore/pageBreakBefore-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pageBreakBefore/pageBreakBefore-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pict/helpers/handle-v-rect-import.d.ts +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pict/helpers/handle-v-rect-import.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/r/helpers/helpers.d.ts +1 -37
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/r/helpers/helpers.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/r/helpers/index.d.ts +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/r/r-translator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rFonts/rFonts-translator.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rFonts/rFonts-translator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rStyle/rstyle-translator.d.ts +1 -2
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rStyle/rstyle-translator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rpr/rpr-translator.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rpr/rpr-translator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/snapToGrid/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/snapToGrid/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/snapToGrid/snapToGrid-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/snapToGrid/snapToGrid-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/spacing/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/spacing/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/spacing/letter-spacing-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/spacing/letter-spacing-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/spacing/spacing-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/spacing/spacing-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/strike/strike-translator.d.ts +1 -2
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/strike/strike-translator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/suppressAutoHyphens/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/suppressAutoHyphens/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/suppressAutoHyphens/suppressAutoHyphens-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/suppressAutoHyphens/suppressAutoHyphens-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/suppressLineNumbers/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/suppressLineNumbers/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/suppressLineNumbers/suppressLineNumbers-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/suppressLineNumbers/suppressLineNumbers-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/suppressOverlap/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/suppressOverlap/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/suppressOverlap/suppressOverlap-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/suppressOverlap/suppressOverlap-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/sz/sz-translator.d.ts +5 -3
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/sz/sz-translator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/szcs/szcs-translator.d.ts +5 -3
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/szcs/szcs-translator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tab/attributes/w-tab-pos.d.ts +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tab/attributes/w-tab-pos.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tab/attributes/{w-tab-size.d.ts → w-tab-type.d.ts} +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tab/attributes/w-tab-type.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tab/tab-translator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tabs/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tabs/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tabs/tabs-translator.d.ts +6 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tabs/tabs-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-translator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/textAlignment/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/textAlignment/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/textAlignment/textAlignment-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/textAlignment/textAlignment-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/textboxTightWrap/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/textboxTightWrap/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/textboxTightWrap/textboxTightWrap-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/textboxTightWrap/textboxTightWrap-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/topLinePunct/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/topLinePunct/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/topLinePunct/topLinePunct-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/topLinePunct/topLinePunct-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/widowControl/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/widowControl/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/widowControl/widowControl-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/widowControl/widowControl-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/wordWrap/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/wordWrap/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/wordWrap/wordWrap-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/wordWrap/wordWrap-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/extensions/field-annotation/cleanup-commands/cleanUpListsWithAnnotations.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/field-annotation/cleanup-commands/index.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/index.d.ts +1 -4
- package/dist/super-editor/super-editor/src/extensions/index.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/linked-styles/helpers.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/linked-styles/helpers.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/paragraph/NumberingManager.d.ts +30 -0
- package/dist/super-editor/super-editor/src/extensions/paragraph/NumberingManager.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/extensions/paragraph/ParagraphNodeView.d.ts +37 -0
- package/dist/super-editor/super-editor/src/extensions/paragraph/ParagraphNodeView.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/extensions/paragraph/helpers/getDefaultSpacing.d.ts +4 -4
- package/dist/super-editor/super-editor/src/extensions/paragraph/numberingPlugin.d.ts +9 -0
- package/dist/super-editor/super-editor/src/extensions/paragraph/numberingPlugin.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/extensions/paragraph/paragraph.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/run/commands/split-run.d.ts +1 -0
- package/dist/super-editor/super-editor/src/extensions/run/commands/split-run.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/tab/helpers/tabDecorations.d.ts +13 -2
- package/dist/super-editor/super-editor/src/extensions/tab/helpers/tabDecorations.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/text-style/text-style.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/track-changes/permission-helpers.d.ts.map +1 -1
- package/dist/super-editor/super-editor.es.js +88 -51
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +13965 -15533
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/super-editor/super-editor/src/core/commands/backspaceNextToList.d.ts +0 -6
- package/dist/super-editor/super-editor/src/core/commands/backspaceNextToList.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/commands/deleteListItem.d.ts +0 -2
- package/dist/super-editor/super-editor/src/core/commands/deleteListItem.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/commands/deleteNextToList.d.ts +0 -15
- package/dist/super-editor/super-editor/src/core/commands/deleteNextToList.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/commands/liftListItem.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/commands/liftListItem.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/commands/sinkListItem.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/commands/sinkListItem.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/commands/splitListItem.d.ts +0 -2
- package/dist/super-editor/super-editor/src/core/commands/splitListItem.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/commands/wrapInList.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/commands/wrapInList.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/b/attributes/index.d.ts +0 -4
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/b/attributes/index.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/b/attributes/w-val.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/b/attributes/w-val.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/index.d.ts +0 -3
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/index.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-theme-color.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-theme-color.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-theme-shade.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-theme-shade.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-theme-tint.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-theme-tint.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-val.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-val.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/i/attributes/index.d.ts +0 -3
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/i/attributes/index.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/i/attributes/w-val.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/i/attributes/w-val.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/w-p-helpers.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/w-p-helpers.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/r/helpers/split-run-properties.d.ts +0 -10
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/r/helpers/split-run-properties.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/index.d.ts +0 -3
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/index.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-ascii.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-ascii.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-cs.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-cs.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-east-asia.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-east-asia.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-hansi.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-hansi.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-val.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-val.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rStyle/attributes/index.d.ts +0 -3
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rStyle/attributes/index.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rStyle/attributes/w-val.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rStyle/attributes/w-val.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rpr/run-property-translators.d.ts +0 -12
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/rpr/run-property-translators.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/strike/attributes/index.d.ts +0 -3
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/strike/attributes/index.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/strike/attributes/w-val.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/strike/attributes/w-val.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/sz/attributes/index.d.ts +0 -3
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/sz/attributes/index.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/sz/attributes/w-val.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/sz/attributes/w-val.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tab/attributes/w-tab-size.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/extensions/bullet-list/bullet-list.d.ts +0 -15
- package/dist/super-editor/super-editor/src/extensions/bullet-list/bullet-list.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/extensions/bullet-list/index.d.ts +0 -2
- package/dist/super-editor/super-editor/src/extensions/bullet-list/index.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/extensions/list-item/ListItemNodeView.d.ts +0 -43
- package/dist/super-editor/super-editor/src/extensions/list-item/ListItemNodeView.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/extensions/list-item/helpers/listItemTypography.d.ts +0 -68
- package/dist/super-editor/super-editor/src/extensions/list-item/helpers/listItemTypography.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/extensions/list-item/helpers/styledListMarkerPlugin.d.ts +0 -13
- package/dist/super-editor/super-editor/src/extensions/list-item/helpers/styledListMarkerPlugin.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/extensions/list-item/index.d.ts +0 -2
- package/dist/super-editor/super-editor/src/extensions/list-item/index.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/extensions/list-item/list-item.d.ts +0 -51
- package/dist/super-editor/super-editor/src/extensions/list-item/list-item.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/extensions/ordered-list/helpers/orderedListMarkerPlugin.d.ts +0 -3
- package/dist/super-editor/super-editor/src/extensions/ordered-list/helpers/orderedListMarkerPlugin.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/extensions/ordered-list/helpers/orderedListSyncPlugin.d.ts +0 -6
- package/dist/super-editor/super-editor/src/extensions/ordered-list/helpers/orderedListSyncPlugin.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/extensions/ordered-list/index.d.ts +0 -2
- package/dist/super-editor/super-editor/src/extensions/ordered-list/index.d.ts.map +0 -1
- package/dist/super-editor/super-editor/src/extensions/ordered-list/ordered-list.d.ts +0 -38
- package/dist/super-editor/super-editor/src/extensions/ordered-list/ordered-list.d.ts.map +0 -1
|
@@ -9,11 +9,11 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
9
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
10
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
11
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
12
|
-
var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn,
|
|
12
|
+
var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, updateHTMLAttributes_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
|
|
13
13
|
import * as Y from "yjs";
|
|
14
14
|
import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
|
|
15
|
-
import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as
|
|
16
|
-
import { D as DocxZipper } from "./docx-zipper-
|
|
15
|
+
import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, L as ListHelpers, G as updateNumberingProperties, H as changeListLevel, I as findParentNode, J as isList, K as isMacOS, O as isIOS, Q as getSchemaTypeByName, U as inputRulesPlugin, V as TrackDeleteMarkName, W as TrackInsertMarkName, X as v4, Y as TrackFormatMarkName, Z as comments_module_events, _ as findMark, $ as objectIncludes, a0 as AddMarkStep, a1 as RemoveMarkStep, a2 as twipsToLines, a3 as pixelsToTwips, a4 as helpers, a5 as posToDOMRect, a6 as CommandService, a7 as SuperConverter, a8 as createDocument, a9 as createDocFromMarkdown, aa as createDocFromHTML, ab as EditorState, ac as hasSomeParentWithClass, ad as isActive, ae as unflattenListsInHtml, af as parseSizeUnit, ag as minMax, ah as getLineHeightValueString, ai as updateDOMAttributes, aj as findChildren$5, ak as generateRandomSigned32BitIntStrId, al as kebabCase, am as twipsToPixels, an as halfPointToPixels, ao as getUnderlineCssString, ap as findParentNodeClosestToPos, aq as resolveRunProperties, ar as encodeCSSFromRPr, as as docxNumberingHelpers, at as InputRule, au as resolveParagraphProperties, av as eighthPointsToPixels, aw as linesToTwips, ax as PIXELS_PER_INCH, ay as SelectionRange, az as Transform, aA as isInTable$1, aB as generateDocxRandomId, aC as insertNewRelationship, aD as inchesToPixels } from "./converter-SZ8xM5Dw.js";
|
|
16
|
+
import { D as DocxZipper } from "./docx-zipper-GNdwONoA.js";
|
|
17
17
|
import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
|
|
18
18
|
var GOOD_LEAF_SIZE = 200;
|
|
19
19
|
var RopeSequence = function RopeSequence2() {
|
|
@@ -8251,12 +8251,15 @@ const ensureMarks = (state, splittableMarks) => {
|
|
|
8251
8251
|
state.tr.ensureMarks(filtered);
|
|
8252
8252
|
}
|
|
8253
8253
|
};
|
|
8254
|
-
const splitBlock$1 = ({ keepMarks = true } = {}) => (props) => {
|
|
8254
|
+
const splitBlock$1 = ({ keepMarks = true, attrsToRemoveOverride = [] } = {}) => (props) => {
|
|
8255
8255
|
const { tr, state, dispatch, editor } = props;
|
|
8256
8256
|
const { selection, doc: doc2 } = tr;
|
|
8257
8257
|
const { $from, $to } = selection;
|
|
8258
8258
|
const extensionAttrs = editor.extensionService.attributes;
|
|
8259
|
-
|
|
8259
|
+
let newAttrs = Attribute.getSplittedAttributes(extensionAttrs, $from.node().type.name, $from.node().attrs);
|
|
8260
|
+
if (attrsToRemoveOverride.length > 0) {
|
|
8261
|
+
newAttrs = deleteAttributes(newAttrs, attrsToRemoveOverride);
|
|
8262
|
+
}
|
|
8260
8263
|
if (selection instanceof NodeSelection && selection.node.isBlock) {
|
|
8261
8264
|
if (!$from.parentOffset || !canSplit(doc2, $from.pos)) return false;
|
|
8262
8265
|
if (dispatch) {
|
|
@@ -8291,6 +8294,23 @@ const splitBlock$1 = ({ keepMarks = true } = {}) => (props) => {
|
|
|
8291
8294
|
}
|
|
8292
8295
|
return true;
|
|
8293
8296
|
};
|
|
8297
|
+
function deleteAttributes(attrs, attrsToRemove) {
|
|
8298
|
+
const newAttrs = { ...attrs };
|
|
8299
|
+
attrsToRemove.forEach((attrName) => {
|
|
8300
|
+
const parts = attrName.split(".");
|
|
8301
|
+
if (parts.length === 1) {
|
|
8302
|
+
delete newAttrs[attrName];
|
|
8303
|
+
} else {
|
|
8304
|
+
let current = newAttrs;
|
|
8305
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
8306
|
+
if (current[parts[i]] == null) return;
|
|
8307
|
+
current = current[parts[i]];
|
|
8308
|
+
}
|
|
8309
|
+
delete current[parts[parts.length - 1]];
|
|
8310
|
+
}
|
|
8311
|
+
});
|
|
8312
|
+
return newAttrs;
|
|
8313
|
+
}
|
|
8294
8314
|
const deleteSelection$1 = (state, dispatch) => {
|
|
8295
8315
|
if (state.selection.empty)
|
|
8296
8316
|
return false;
|
|
@@ -9111,7 +9131,7 @@ const selectNodeBackward = () => ({ state, dispatch }) => {
|
|
|
9111
9131
|
const selectNodeForward = () => ({ state, dispatch }) => selectNodeForward$1(state, dispatch);
|
|
9112
9132
|
const selectTextblockStart = () => ({ state, dispatch }) => selectTextblockStart$1(state, dispatch);
|
|
9113
9133
|
const selectTextblockEnd = () => ({ state, dispatch }) => selectTextblockEnd$1(state, dispatch);
|
|
9114
|
-
const insertContent = (value, options = {}) => ({ tr,
|
|
9134
|
+
const insertContent = (value, options = {}) => ({ tr, commands: commands2, editor }) => {
|
|
9115
9135
|
if (options.contentType) {
|
|
9116
9136
|
const validTypes = ["html", "markdown", "text", "schema"];
|
|
9117
9137
|
if (!validTypes.includes(options.contentType)) {
|
|
@@ -9122,7 +9142,7 @@ const insertContent = (value, options = {}) => ({ tr, state, commands: commands2
|
|
|
9122
9142
|
const processedDoc = processContent({
|
|
9123
9143
|
content: value,
|
|
9124
9144
|
type: options.contentType,
|
|
9125
|
-
|
|
9145
|
+
editor
|
|
9126
9146
|
});
|
|
9127
9147
|
const jsonContent = processedDoc.toJSON();
|
|
9128
9148
|
const ok = commands2.insertContentAt({ from: tr.selection.from, to: tr.selection.to }, jsonContent, options);
|
|
@@ -9149,12 +9169,13 @@ const removeWhitespaces = (node) => {
|
|
|
9149
9169
|
}
|
|
9150
9170
|
return node;
|
|
9151
9171
|
};
|
|
9152
|
-
function elementFromString(value) {
|
|
9172
|
+
function elementFromString(value, editor) {
|
|
9153
9173
|
const wrappedValue = `<body>${value}</body>`;
|
|
9154
|
-
const html =
|
|
9174
|
+
const html = htmlHandler(wrappedValue, editor);
|
|
9155
9175
|
return removeWhitespaces(html);
|
|
9156
9176
|
}
|
|
9157
|
-
function createNodeFromContent(content,
|
|
9177
|
+
function createNodeFromContent(content, editor, options) {
|
|
9178
|
+
const schema = editor.schema;
|
|
9158
9179
|
options = {
|
|
9159
9180
|
slice: true,
|
|
9160
9181
|
parseOptions: {},
|
|
@@ -9178,7 +9199,7 @@ function createNodeFromContent(content, schema, options) {
|
|
|
9178
9199
|
throw new Error("[super-editor error]: Invalid JSON content", { cause: error });
|
|
9179
9200
|
}
|
|
9180
9201
|
console.warn("[super-editor warn]: Invalid content.", "Passed value:", content, "Error:", error);
|
|
9181
|
-
return createNodeFromContent("",
|
|
9202
|
+
return createNodeFromContent("", editor, options);
|
|
9182
9203
|
}
|
|
9183
9204
|
}
|
|
9184
9205
|
if (isTextContent) {
|
|
@@ -9208,9 +9229,9 @@ function createNodeFromContent(content, schema, options) {
|
|
|
9208
9229
|
})
|
|
9209
9230
|
});
|
|
9210
9231
|
if (options.slice) {
|
|
9211
|
-
DOMParser$1.fromSchema(contentCheckSchema).parseSlice(elementFromString(content), options.parseOptions);
|
|
9232
|
+
DOMParser$1.fromSchema(contentCheckSchema).parseSlice(elementFromString(content, editor), options.parseOptions);
|
|
9212
9233
|
} else {
|
|
9213
|
-
DOMParser$1.fromSchema(contentCheckSchema).parse(elementFromString(content), options.parseOptions);
|
|
9234
|
+
DOMParser$1.fromSchema(contentCheckSchema).parse(elementFromString(content, editor), options.parseOptions);
|
|
9214
9235
|
}
|
|
9215
9236
|
if (options.errorOnInvalidContent && hasInvalidContent) {
|
|
9216
9237
|
throw new Error("[super-editor error]: Invalid HTML content", {
|
|
@@ -9220,11 +9241,11 @@ function createNodeFromContent(content, schema, options) {
|
|
|
9220
9241
|
}
|
|
9221
9242
|
const parser = DOMParser$1.fromSchema(schema);
|
|
9222
9243
|
if (options.slice) {
|
|
9223
|
-
return parser.parseSlice(elementFromString(content), options.parseOptions).content;
|
|
9244
|
+
return parser.parseSlice(elementFromString(content, editor), options.parseOptions).content;
|
|
9224
9245
|
}
|
|
9225
|
-
return parser.parse(elementFromString(content), options.parseOptions);
|
|
9246
|
+
return parser.parse(elementFromString(content, editor), options.parseOptions);
|
|
9226
9247
|
}
|
|
9227
|
-
return createNodeFromContent("",
|
|
9248
|
+
return createNodeFromContent("", editor, options);
|
|
9228
9249
|
}
|
|
9229
9250
|
function selectionToInsertionEnd(tr, startLen, bias) {
|
|
9230
9251
|
const last = tr.steps.length - 1;
|
|
@@ -9260,7 +9281,7 @@ const insertContentAt = (position, value, options) => ({ tr, dispatch, editor })
|
|
|
9260
9281
|
};
|
|
9261
9282
|
let content;
|
|
9262
9283
|
try {
|
|
9263
|
-
content = createNodeFromContent(value, editor
|
|
9284
|
+
content = createNodeFromContent(value, editor, {
|
|
9264
9285
|
parseOptions: {
|
|
9265
9286
|
preserveWhitespace: "full",
|
|
9266
9287
|
...options.parseOptions
|
|
@@ -9347,539 +9368,112 @@ const undoInputRule = () => ({ state, dispatch }) => {
|
|
|
9347
9368
|
}
|
|
9348
9369
|
return false;
|
|
9349
9370
|
};
|
|
9350
|
-
|
|
9351
|
-
|
|
9352
|
-
|
|
9353
|
-
|
|
9354
|
-
|
|
9355
|
-
|
|
9356
|
-
|
|
9357
|
-
if (!wrapRangeInList(tr, range, listType, attrs))
|
|
9358
|
-
return false;
|
|
9359
|
-
if (dispatch)
|
|
9360
|
-
dispatch(tr.scrollIntoView());
|
|
9361
|
-
return true;
|
|
9362
|
-
};
|
|
9363
|
-
}
|
|
9364
|
-
function wrapRangeInList(tr, range, listType, attrs = null) {
|
|
9365
|
-
let doJoin = false, outerRange = range, doc2 = range.$from.doc;
|
|
9366
|
-
if (range.depth >= 2 && range.$from.node(range.depth - 1).type.compatibleContent(listType) && range.startIndex == 0) {
|
|
9367
|
-
if (range.$from.index(range.depth - 1) == 0)
|
|
9368
|
-
return false;
|
|
9369
|
-
let $insert = doc2.resolve(range.start - 2);
|
|
9370
|
-
outerRange = new NodeRange($insert, $insert, range.depth);
|
|
9371
|
-
if (range.endIndex < range.parent.childCount)
|
|
9372
|
-
range = new NodeRange(range.$from, doc2.resolve(range.$to.end(range.depth)), range.depth);
|
|
9373
|
-
doJoin = true;
|
|
9374
|
-
}
|
|
9375
|
-
let wrap = findWrapping(outerRange, listType, attrs, range);
|
|
9376
|
-
if (!wrap)
|
|
9377
|
-
return false;
|
|
9378
|
-
if (tr)
|
|
9379
|
-
doWrapInList(tr, range, wrap, doJoin, listType);
|
|
9380
|
-
return true;
|
|
9381
|
-
}
|
|
9382
|
-
function doWrapInList(tr, range, wrappers, joinBefore, listType) {
|
|
9383
|
-
let content = Fragment.empty;
|
|
9384
|
-
for (let i = wrappers.length - 1; i >= 0; i--)
|
|
9385
|
-
content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
|
|
9386
|
-
tr.step(new ReplaceAroundStep$1(range.start - (joinBefore ? 2 : 0), range.end, range.start, range.end, new Slice(content, 0, 0), wrappers.length, true));
|
|
9387
|
-
let found = 0;
|
|
9388
|
-
for (let i = 0; i < wrappers.length; i++)
|
|
9389
|
-
if (wrappers[i].type == listType)
|
|
9390
|
-
found = i + 1;
|
|
9391
|
-
let splitDepth = wrappers.length - found;
|
|
9392
|
-
let splitPos = range.start + wrappers.length - (joinBefore ? 2 : 0), parent = range.parent;
|
|
9393
|
-
for (let i = range.startIndex, e = range.endIndex, first2 = true; i < e; i++, first2 = false) {
|
|
9394
|
-
if (!first2 && canSplit(tr.doc, splitPos, splitDepth)) {
|
|
9395
|
-
tr.split(splitPos, splitDepth);
|
|
9396
|
-
splitPos += 2 * splitDepth;
|
|
9397
|
-
}
|
|
9398
|
-
splitPos += parent.child(i).nodeSize;
|
|
9399
|
-
}
|
|
9400
|
-
return tr;
|
|
9401
|
-
}
|
|
9402
|
-
function liftListItem$1(itemType) {
|
|
9403
|
-
return function(state, dispatch) {
|
|
9404
|
-
let { $from, $to } = state.selection;
|
|
9405
|
-
let range = $from.blockRange($to, (node) => node.childCount > 0 && node.firstChild.type == itemType);
|
|
9406
|
-
if (!range)
|
|
9407
|
-
return false;
|
|
9408
|
-
if (!dispatch)
|
|
9409
|
-
return true;
|
|
9410
|
-
if ($from.node(range.depth - 1).type == itemType)
|
|
9411
|
-
return liftToOuterList(state, dispatch, itemType, range);
|
|
9412
|
-
else
|
|
9413
|
-
return liftOutOfList(state, dispatch, range);
|
|
9414
|
-
};
|
|
9415
|
-
}
|
|
9416
|
-
function liftToOuterList(state, dispatch, itemType, range) {
|
|
9417
|
-
let tr = state.tr, end2 = range.end, endOfList = range.$to.end(range.depth);
|
|
9418
|
-
if (end2 < endOfList) {
|
|
9419
|
-
tr.step(new ReplaceAroundStep$1(end2 - 1, endOfList, end2, endOfList, new Slice(Fragment.from(itemType.create(null, range.parent.copy())), 1, 0), 1, true));
|
|
9420
|
-
range = new NodeRange(tr.doc.resolve(range.$from.pos), tr.doc.resolve(endOfList), range.depth);
|
|
9421
|
-
}
|
|
9422
|
-
const target = liftTarget(range);
|
|
9423
|
-
if (target == null)
|
|
9371
|
+
const toggleList = (listType) => ({ editor, state, tr, dispatch }) => {
|
|
9372
|
+
let predicate;
|
|
9373
|
+
if (listType === "orderedList") {
|
|
9374
|
+
predicate = (n) => n.attrs.numberingProperties && n.attrs.listRendering && n.attrs.listRendering.numberingType !== "bullet";
|
|
9375
|
+
} else if (listType === "bulletList") {
|
|
9376
|
+
predicate = (n) => n.attrs.numberingProperties && n.attrs.listRendering && n.attrs.listRendering.numberingType === "bullet";
|
|
9377
|
+
} else {
|
|
9424
9378
|
return false;
|
|
9425
|
-
tr.lift(range, target);
|
|
9426
|
-
let $after = tr.doc.resolve(tr.mapping.map(end2, -1) - 1);
|
|
9427
|
-
if (canJoin(tr.doc, $after.pos) && $after.nodeBefore.type == $after.nodeAfter.type)
|
|
9428
|
-
tr.join($after.pos);
|
|
9429
|
-
dispatch(tr.scrollIntoView());
|
|
9430
|
-
return true;
|
|
9431
|
-
}
|
|
9432
|
-
function liftOutOfList(state, dispatch, range) {
|
|
9433
|
-
let tr = state.tr, list = range.parent;
|
|
9434
|
-
for (let pos = range.end, i = range.endIndex - 1, e = range.startIndex; i > e; i--) {
|
|
9435
|
-
pos -= list.child(i).nodeSize;
|
|
9436
|
-
tr.delete(pos - 1, pos + 1);
|
|
9437
9379
|
}
|
|
9438
|
-
|
|
9439
|
-
|
|
9440
|
-
|
|
9441
|
-
let
|
|
9442
|
-
let
|
|
9443
|
-
|
|
9444
|
-
|
|
9445
|
-
|
|
9446
|
-
|
|
9447
|
-
|
|
9448
|
-
|
|
9449
|
-
|
|
9450
|
-
|
|
9451
|
-
return function(state, dispatch) {
|
|
9452
|
-
let { $from, $to } = state.selection;
|
|
9453
|
-
let range = $from.blockRange($to, (node) => node.childCount > 0 && node.firstChild.type == itemType);
|
|
9454
|
-
if (!range)
|
|
9455
|
-
return false;
|
|
9456
|
-
let startIndex = range.startIndex;
|
|
9457
|
-
if (startIndex == 0)
|
|
9458
|
-
return false;
|
|
9459
|
-
let parent = range.parent, nodeBefore = parent.child(startIndex - 1);
|
|
9460
|
-
if (nodeBefore.type != itemType)
|
|
9380
|
+
const { selection } = state;
|
|
9381
|
+
const { from: from2, to } = selection;
|
|
9382
|
+
let firstListNode = null;
|
|
9383
|
+
let hasNonListParagraphs = false;
|
|
9384
|
+
let paragraphsInSelection = [];
|
|
9385
|
+
state.doc.nodesBetween(from2, to, (node, pos) => {
|
|
9386
|
+
if (node.type.name === "paragraph") {
|
|
9387
|
+
paragraphsInSelection.push({ node, pos });
|
|
9388
|
+
if (!firstListNode && predicate(node)) {
|
|
9389
|
+
firstListNode = node;
|
|
9390
|
+
} else if (!predicate(node)) {
|
|
9391
|
+
hasNonListParagraphs = true;
|
|
9392
|
+
}
|
|
9461
9393
|
return false;
|
|
9462
|
-
if (dispatch) {
|
|
9463
|
-
let nestedBefore = nodeBefore.lastChild && nodeBefore.lastChild.type == parent.type;
|
|
9464
|
-
let inner = Fragment.from(nestedBefore ? itemType.create() : null);
|
|
9465
|
-
let slice2 = new Slice(Fragment.from(itemType.create(null, Fragment.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
|
|
9466
|
-
let before = range.start, after = range.end;
|
|
9467
|
-
dispatch(state.tr.step(new ReplaceAroundStep$1(before - (nestedBefore ? 3 : 1), after, before, after, slice2, 1, true)).scrollIntoView());
|
|
9468
9394
|
}
|
|
9469
9395
|
return true;
|
|
9470
|
-
};
|
|
9471
|
-
}
|
|
9472
|
-
const wrapInList = (typeOrName, attrs = {}) => ({ state, dispatch }) => {
|
|
9473
|
-
const type = getNodeType(typeOrName, state.schema);
|
|
9474
|
-
return wrapInList$1(type, attrs)(state, dispatch);
|
|
9475
|
-
};
|
|
9476
|
-
function nearestListAt($pos, OrderedType, BulletType) {
|
|
9477
|
-
for (let d2 = $pos.depth; d2 >= 0; d2--) {
|
|
9478
|
-
const node = $pos.node(d2);
|
|
9479
|
-
if (node.type === OrderedType || node.type === BulletType) {
|
|
9480
|
-
return { node, pos: $pos.before(d2), depth: d2 };
|
|
9481
|
-
}
|
|
9482
|
-
}
|
|
9483
|
-
return null;
|
|
9484
|
-
}
|
|
9485
|
-
function getEffectiveListKind(node) {
|
|
9486
|
-
if (!node) return null;
|
|
9487
|
-
const typeName = node.type?.name;
|
|
9488
|
-
const style = node.attrs?.["list-style-type"];
|
|
9489
|
-
if (typeName === "bulletList") return "bullet";
|
|
9490
|
-
if (typeName === "orderedList") {
|
|
9491
|
-
if (style === "bullet") return "bullet";
|
|
9492
|
-
const firstLI = node.firstChild;
|
|
9493
|
-
const liFmt = firstLI?.attrs?.listNumberingType;
|
|
9494
|
-
if (liFmt === "bullet") return "bullet";
|
|
9495
|
-
return "ordered";
|
|
9496
|
-
}
|
|
9497
|
-
return null;
|
|
9498
|
-
}
|
|
9499
|
-
function collectIntersectingTopLists({ doc: doc2, selection, OrderedType, BulletType }) {
|
|
9500
|
-
const { from: from2, to, $from, $to } = selection;
|
|
9501
|
-
const hit = /* @__PURE__ */ new Map();
|
|
9502
|
-
const startList = nearestListAt($from, OrderedType, BulletType);
|
|
9503
|
-
if (startList) hit.set(startList.pos, startList);
|
|
9504
|
-
const endList = nearestListAt($to, OrderedType, BulletType);
|
|
9505
|
-
if (endList) hit.set(endList.pos, endList);
|
|
9506
|
-
const a = $from.nodeAfter;
|
|
9507
|
-
if (a && (a.type === OrderedType || a.type === BulletType)) {
|
|
9508
|
-
hit.set($from.pos, { node: a, pos: $from.pos, depth: null });
|
|
9509
|
-
}
|
|
9510
|
-
const b = $to.nodeBefore;
|
|
9511
|
-
if (b && (b.type === OrderedType || b.type === BulletType)) {
|
|
9512
|
-
const posB = $to.pos - b.nodeSize;
|
|
9513
|
-
hit.set(posB, { node: b, pos: posB, depth: null });
|
|
9514
|
-
}
|
|
9515
|
-
doc2.nodesBetween(from2, to, (node, pos, parent) => {
|
|
9516
|
-
const isList2 = node.type === OrderedType || node.type === BulletType;
|
|
9517
|
-
if (!isList2) return true;
|
|
9518
|
-
const parentIsList = parent && (parent.type === OrderedType || parent.type === BulletType);
|
|
9519
|
-
if (!parentIsList) hit.set(pos, { node, pos, depth: null });
|
|
9520
|
-
return false;
|
|
9521
9396
|
});
|
|
9522
|
-
|
|
9523
|
-
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9527
|
-
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
counters.splice(lvl + 1);
|
|
9531
|
-
counters[lvl] = (counters[lvl] ?? 0) + 1;
|
|
9532
|
-
levelsOut.push(counters.slice(0, lvl + 1));
|
|
9533
|
-
}
|
|
9534
|
-
return levelsOut;
|
|
9535
|
-
}
|
|
9536
|
-
function rebuildListNodeWithNewNum({ oldList, toType, editor, schema, fixedNumId }) {
|
|
9537
|
-
const OrderedType = schema.nodes.orderedList;
|
|
9538
|
-
const isOrdered = toType === OrderedType;
|
|
9539
|
-
const numId = fixedNumId ?? ListHelpers.getNewListId(editor);
|
|
9540
|
-
if (fixedNumId == null) {
|
|
9541
|
-
ListHelpers.generateNewListDefinition?.({ numId: Number(numId), listType: toType, editor });
|
|
9542
|
-
}
|
|
9543
|
-
const liNodes = [];
|
|
9544
|
-
for (let i = 0; i < oldList.childCount; i++) {
|
|
9545
|
-
const li = oldList.child(i);
|
|
9546
|
-
if (li?.type?.name === "listItem") liNodes.push(li);
|
|
9547
|
-
}
|
|
9548
|
-
const computedLevels = isOrdered ? computeListLevels(liNodes) : [];
|
|
9549
|
-
const items = [];
|
|
9550
|
-
for (let i = 0; i < liNodes.length; i++) {
|
|
9551
|
-
const li = liNodes[i];
|
|
9552
|
-
const level = Math.max(0, Number(li.attrs?.level ?? 0));
|
|
9553
|
-
const listLevel = isOrdered ? computedLevels[i] ?? [i + 1] : Array.isArray(li.attrs?.listLevel) ? li.attrs.listLevel : [level + 1];
|
|
9554
|
-
const details = ListHelpers.getListDefinitionDetails?.({ numId: Number(numId), level, listType: toType, editor }) || {};
|
|
9555
|
-
const effectiveFmt = isOrdered ? details.numFmt || "decimal" : details.numFmt || "bullet";
|
|
9556
|
-
const effectiveLvlText = isOrdered ? details.lvlText || "%1." : details.lvlText || "•";
|
|
9557
|
-
const baseAttrs = li.attrs || {};
|
|
9558
|
-
const itemAttrs = {
|
|
9559
|
-
...baseAttrs,
|
|
9560
|
-
level,
|
|
9561
|
-
listLevel,
|
|
9562
|
-
numId,
|
|
9563
|
-
numPrType: "inline",
|
|
9564
|
-
listNumberingType: effectiveFmt,
|
|
9565
|
-
lvlText: effectiveLvlText
|
|
9566
|
-
};
|
|
9567
|
-
const contentJSON = li.content && li.content.size > 0 ? li.content.toJSON() : [{ type: "paragraph", content: [] }];
|
|
9568
|
-
items.push({
|
|
9569
|
-
type: "listItem",
|
|
9570
|
-
attrs: itemAttrs,
|
|
9571
|
-
content: contentJSON
|
|
9572
|
-
});
|
|
9573
|
-
}
|
|
9574
|
-
const containerJSON = {
|
|
9575
|
-
type: isOrdered ? "orderedList" : "bulletList",
|
|
9576
|
-
attrs: {
|
|
9577
|
-
listId: numId,
|
|
9578
|
-
"list-style-type": isOrdered ? items[0]?.attrs?.listNumberingType ?? "decimal" : items[0]?.attrs?.listNumberingType ?? "bullet",
|
|
9579
|
-
...isOrdered ? { order: 1 } : {}
|
|
9580
|
-
},
|
|
9581
|
-
content: items
|
|
9582
|
-
};
|
|
9583
|
-
return editor.schema.nodeFromJSON(containerJSON);
|
|
9584
|
-
}
|
|
9585
|
-
function buildListContainersFromParagraphs({ paragraphs, targetKind, editor, schema }) {
|
|
9586
|
-
const OrderedType = schema.nodes.orderedList;
|
|
9587
|
-
const BulletType = schema.nodes.bulletList;
|
|
9588
|
-
const toType = targetKind === "ordered" ? OrderedType : BulletType;
|
|
9589
|
-
const numId = ListHelpers.getNewListId(editor);
|
|
9590
|
-
ListHelpers.generateNewListDefinition?.({ numId, listType: toType, editor });
|
|
9591
|
-
const isOrdered = targetKind === "ordered";
|
|
9592
|
-
const containers = [];
|
|
9593
|
-
for (let i = 0; i < paragraphs.length; i++) {
|
|
9594
|
-
const { node } = paragraphs[i];
|
|
9595
|
-
const level = 0;
|
|
9596
|
-
const listLevel = [1];
|
|
9597
|
-
const numFmt = isOrdered ? "decimal" : "bullet";
|
|
9598
|
-
const lvlText = isOrdered ? "%1." : "•";
|
|
9599
|
-
const itemJSON = ListHelpers.createListItemNodeJSON({
|
|
9600
|
-
level,
|
|
9601
|
-
listLevel,
|
|
9602
|
-
numId,
|
|
9603
|
-
numFmt,
|
|
9604
|
-
lvlText,
|
|
9605
|
-
contentNode: node.toJSON()
|
|
9606
|
-
// preserve runs
|
|
9607
|
-
});
|
|
9608
|
-
itemJSON.attrs = {
|
|
9609
|
-
...itemJSON.attrs || {},
|
|
9610
|
-
level,
|
|
9611
|
-
listLevel,
|
|
9612
|
-
numId,
|
|
9613
|
-
numPrType: "inline",
|
|
9614
|
-
listNumberingType: numFmt,
|
|
9615
|
-
lvlText
|
|
9616
|
-
};
|
|
9617
|
-
const containerJSON = {
|
|
9618
|
-
type: isOrdered ? "orderedList" : "bulletList",
|
|
9619
|
-
attrs: {
|
|
9620
|
-
listId: numId,
|
|
9621
|
-
"list-style-type": isOrdered ? "decimal" : "bullet",
|
|
9622
|
-
...isOrdered ? { order: 1 } : {}
|
|
9623
|
-
},
|
|
9624
|
-
content: [itemJSON]
|
|
9625
|
-
};
|
|
9626
|
-
containers.push(editor.schema.nodeFromJSON(containerJSON));
|
|
9627
|
-
}
|
|
9628
|
-
return containers;
|
|
9629
|
-
}
|
|
9630
|
-
function setMappedSelectionSpan(tr, fromBefore, toBefore) {
|
|
9631
|
-
const mappedFrom = tr.mapping.map(fromBefore, -1);
|
|
9632
|
-
const mappedTo = tr.mapping.map(toBefore, 1);
|
|
9633
|
-
const $from = tr.doc.resolve(Math.max(1, Math.min(mappedFrom, tr.doc.content.size)));
|
|
9634
|
-
const $to = tr.doc.resolve(Math.max(1, Math.min(mappedTo, tr.doc.content.size)));
|
|
9635
|
-
tr.setSelection(TextSelection.between($from, $to));
|
|
9636
|
-
}
|
|
9637
|
-
function setCaretInsideFirstTextblockOfNodeAt(tr, containerPos) {
|
|
9638
|
-
const node = tr.doc.nodeAt(containerPos);
|
|
9639
|
-
if (!node) return;
|
|
9640
|
-
let found = null;
|
|
9641
|
-
node.descendants((n, p) => {
|
|
9642
|
-
if (n.isTextblock) {
|
|
9643
|
-
found = containerPos + p + 2;
|
|
9644
|
-
return false;
|
|
9397
|
+
if (!firstListNode && from2 > 0) {
|
|
9398
|
+
const $from = state.doc.resolve(from2);
|
|
9399
|
+
const parentIndex = $from.index(-1);
|
|
9400
|
+
if (parentIndex > 0) {
|
|
9401
|
+
const beforeNode = $from.node(-1).child(parentIndex - 1);
|
|
9402
|
+
if (beforeNode && beforeNode.type.name === "paragraph" && predicate(beforeNode)) {
|
|
9403
|
+
firstListNode = beforeNode;
|
|
9404
|
+
}
|
|
9645
9405
|
}
|
|
9646
|
-
return true;
|
|
9647
|
-
});
|
|
9648
|
-
if (found != null) {
|
|
9649
|
-
tr.setSelection(TextSelection.create(tr.doc, found, found));
|
|
9650
|
-
} else {
|
|
9651
|
-
const fallback = Math.min(tr.doc.content.size, Math.max(1, containerPos + 1));
|
|
9652
|
-
tr.setSelection(TextSelection.create(tr.doc, fallback, fallback));
|
|
9653
9406
|
}
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
|
|
9658
|
-
|
|
9659
|
-
const TargetType = typeof listType === "string" ? editor.schema.nodes[listType] : listType;
|
|
9660
|
-
const targetKind = TargetType === OrderedType ? "ordered" : "bullet";
|
|
9661
|
-
const isListNode = (n) => !!n && (n.type === OrderedType || n.type === BulletType);
|
|
9662
|
-
let near = nearestListAt(selection.$from, OrderedType, BulletType);
|
|
9663
|
-
if (!near) {
|
|
9664
|
-
const after = selection.$from.nodeAfter;
|
|
9665
|
-
if (isListNode(after)) {
|
|
9666
|
-
near = { node: after, pos: selection.$from.pos, depth: selection.$from.depth + 1 };
|
|
9407
|
+
let mode = null;
|
|
9408
|
+
let sharedNumberingProperties = null;
|
|
9409
|
+
if (firstListNode) {
|
|
9410
|
+
if (!hasNonListParagraphs) {
|
|
9411
|
+
mode = "remove";
|
|
9667
9412
|
} else {
|
|
9668
|
-
|
|
9669
|
-
|
|
9670
|
-
|
|
9671
|
-
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
}
|
|
9675
|
-
const nearKind = near ? getEffectiveListKind(near.node) : null;
|
|
9676
|
-
if (near) {
|
|
9677
|
-
const isSameAsTarget = nearKind === targetKind;
|
|
9678
|
-
if (isSameAsTarget) {
|
|
9679
|
-
const candidateLists = collectIntersectingTopLists({ doc: doc2, selection, OrderedType, BulletType });
|
|
9680
|
-
let listsToUnwrap = candidateLists.filter(({ node }) => getEffectiveListKind(node) === targetKind);
|
|
9681
|
-
if (listsToUnwrap.length === 0 && getEffectiveListKind(near.node) === targetKind) {
|
|
9682
|
-
listsToUnwrap = [{ node: near.node, pos: near.pos, depth: near.depth ?? null }];
|
|
9683
|
-
}
|
|
9684
|
-
if (listsToUnwrap.length === 0) return false;
|
|
9685
|
-
let spanFromBefore2 = listsToUnwrap[0].pos;
|
|
9686
|
-
let spanToBefore2 = listsToUnwrap[0].pos + listsToUnwrap[0].node.nodeSize;
|
|
9687
|
-
for (let i = 1; i < listsToUnwrap.length; i++) {
|
|
9688
|
-
const { node, pos: pos2 } = listsToUnwrap[i];
|
|
9689
|
-
spanFromBefore2 = Math.min(spanFromBefore2, pos2);
|
|
9690
|
-
spanToBefore2 = Math.max(spanToBefore2, pos2 + node.nodeSize);
|
|
9691
|
-
}
|
|
9692
|
-
const ParagraphType = editor.schema.nodes.paragraph;
|
|
9693
|
-
listsToUnwrap.sort((a, b) => b.pos - a.pos);
|
|
9694
|
-
for (const { node, pos: pos2 } of listsToUnwrap) {
|
|
9695
|
-
const mappedFrom = tr.mapping.map(pos2, -1);
|
|
9696
|
-
const mappedTo = tr.mapping.map(pos2 + node.nodeSize, 1);
|
|
9697
|
-
const currentListNode = tr.doc.nodeAt(mappedFrom);
|
|
9698
|
-
const sourceListNode = currentListNode && (currentListNode.type === OrderedType || currentListNode.type === BulletType) ? currentListNode : node;
|
|
9699
|
-
const paragraphs = [];
|
|
9700
|
-
for (let i = 0; i < sourceListNode.childCount; i++) {
|
|
9701
|
-
const li = sourceListNode.child(i);
|
|
9702
|
-
if (li.type !== editor.schema.nodes.listItem) continue;
|
|
9703
|
-
const firstChild = li.firstChild;
|
|
9704
|
-
paragraphs.push(firstChild || ParagraphType.create());
|
|
9705
|
-
}
|
|
9706
|
-
if (paragraphs.length === 0) {
|
|
9707
|
-
paragraphs.push(ParagraphType.create());
|
|
9708
|
-
}
|
|
9709
|
-
const replacement = paragraphs.length === 1 ? paragraphs[0] : Fragment.from(paragraphs);
|
|
9710
|
-
tr.replaceWith(mappedFrom, mappedTo, replacement);
|
|
9711
|
-
}
|
|
9712
|
-
setMappedSelectionSpan(tr, spanFromBefore2, spanToBefore2);
|
|
9713
|
-
if (dispatch) dispatch(tr);
|
|
9714
|
-
return true;
|
|
9715
|
-
}
|
|
9716
|
-
let touchedLists = collectIntersectingTopLists({ doc: doc2, selection, OrderedType, BulletType });
|
|
9717
|
-
if (touchedLists.length === 0) {
|
|
9718
|
-
touchedLists = [{ node: near.node, pos: near.pos, depth: near.depth }];
|
|
9719
|
-
}
|
|
9720
|
-
let spanFromBefore = Infinity;
|
|
9721
|
-
let spanToBefore = -Infinity;
|
|
9722
|
-
for (const { node, pos: pos2 } of touchedLists) {
|
|
9723
|
-
spanFromBefore = Math.min(spanFromBefore, pos2);
|
|
9724
|
-
spanToBefore = Math.max(spanToBefore, pos2 + node.nodeSize);
|
|
9725
|
-
}
|
|
9726
|
-
const sharedNumId = ListHelpers.getNewListId(editor);
|
|
9727
|
-
ListHelpers.generateNewListDefinition?.({ numId: sharedNumId, listType: TargetType, editor });
|
|
9728
|
-
touchedLists.sort((a, b) => b.pos - a.pos);
|
|
9729
|
-
for (const { node: oldList, pos: pos2 } of touchedLists) {
|
|
9730
|
-
const mapped = tr.mapping.map(pos2);
|
|
9731
|
-
const newList = rebuildListNodeWithNewNum({
|
|
9732
|
-
oldList,
|
|
9733
|
-
toType: TargetType,
|
|
9734
|
-
editor,
|
|
9735
|
-
schema: editor.schema,
|
|
9736
|
-
fixedNumId: String(sharedNumId)
|
|
9737
|
-
});
|
|
9738
|
-
tr.replaceWith(mapped, mapped + oldList.nodeSize, newList);
|
|
9413
|
+
mode = "reuse";
|
|
9414
|
+
const baseNumbering = firstListNode.attrs.numberingProperties || {};
|
|
9415
|
+
sharedNumberingProperties = {
|
|
9416
|
+
...baseNumbering,
|
|
9417
|
+
ilvl: baseNumbering.ilvl ?? 0
|
|
9418
|
+
};
|
|
9739
9419
|
}
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
|
|
9420
|
+
} else {
|
|
9421
|
+
mode = "create";
|
|
9422
|
+
const numId = ListHelpers.getNewListId(editor);
|
|
9423
|
+
ListHelpers.generateNewListDefinition({ numId: Number(numId), listType, editor });
|
|
9424
|
+
sharedNumberingProperties = {
|
|
9425
|
+
numId: Number(numId),
|
|
9426
|
+
ilvl: 0
|
|
9427
|
+
};
|
|
9743
9428
|
}
|
|
9744
|
-
const {
|
|
9745
|
-
|
|
9746
|
-
|
|
9747
|
-
|
|
9748
|
-
if (node.type.name === "paragraph") {
|
|
9749
|
-
const nodeFrom = pos2;
|
|
9750
|
-
const nodeTo = pos2 + node.nodeSize;
|
|
9751
|
-
if (nodeFrom < to && nodeTo > from2) out.push({ node, pos: pos2 });
|
|
9752
|
-
return false;
|
|
9753
|
-
}
|
|
9754
|
-
return true;
|
|
9755
|
-
});
|
|
9756
|
-
return out;
|
|
9757
|
-
};
|
|
9758
|
-
if (!empty2 && from2 !== to) {
|
|
9759
|
-
const paragraphs = collectParagraphs();
|
|
9760
|
-
if (paragraphs.length >= 1) {
|
|
9761
|
-
const first2 = paragraphs[0];
|
|
9762
|
-
const last = paragraphs[paragraphs.length - 1];
|
|
9763
|
-
const spanFromBefore = first2.pos;
|
|
9764
|
-
const spanToBefore = last.pos + last.node.nodeSize;
|
|
9765
|
-
const containers2 = buildListContainersFromParagraphs({
|
|
9766
|
-
paragraphs,
|
|
9767
|
-
targetKind,
|
|
9768
|
-
editor,
|
|
9769
|
-
schema: editor.schema
|
|
9770
|
-
});
|
|
9771
|
-
const replacement = paragraphs.length === 1 ? containers2[0] : Fragment.from(containers2);
|
|
9772
|
-
tr.replaceWith(spanFromBefore, spanToBefore, replacement);
|
|
9773
|
-
if (paragraphs.length === 1) {
|
|
9774
|
-
setCaretInsideFirstTextblockOfNodeAt(tr, spanFromBefore);
|
|
9775
|
-
} else {
|
|
9776
|
-
setMappedSelectionSpan(tr, spanFromBefore, spanToBefore);
|
|
9777
|
-
}
|
|
9778
|
-
if (dispatch) dispatch(tr);
|
|
9779
|
-
return true;
|
|
9429
|
+
for (const { node, pos } of paragraphsInSelection) {
|
|
9430
|
+
if (mode === "remove") {
|
|
9431
|
+
updateNumberingProperties(null, node, pos, editor, tr);
|
|
9432
|
+
continue;
|
|
9780
9433
|
}
|
|
9434
|
+
if (mode === "reuse" && predicate(node)) {
|
|
9435
|
+
continue;
|
|
9436
|
+
}
|
|
9437
|
+
updateNumberingProperties(sharedNumberingProperties, node, pos, editor, tr);
|
|
9781
9438
|
}
|
|
9782
|
-
const paraAtCursor = findParentNode((n) => n.type.name === "paragraph")(selection);
|
|
9783
|
-
if (!paraAtCursor) return false;
|
|
9784
|
-
const { node: paragraph, pos } = paraAtCursor;
|
|
9785
|
-
const containers = buildListContainersFromParagraphs({
|
|
9786
|
-
paragraphs: [{ node: paragraph, pos }],
|
|
9787
|
-
targetKind,
|
|
9788
|
-
editor,
|
|
9789
|
-
schema: editor.schema
|
|
9790
|
-
});
|
|
9791
|
-
tr.replaceWith(pos, pos + paragraph.nodeSize, containers[0]);
|
|
9792
|
-
setCaretInsideFirstTextblockOfNodeAt(tr, pos);
|
|
9793
9439
|
if (dispatch) dispatch(tr);
|
|
9794
9440
|
return true;
|
|
9795
9441
|
};
|
|
9796
|
-
const
|
|
9797
|
-
const
|
|
9798
|
-
if (
|
|
9799
|
-
|
|
9800
|
-
return Number.isNaN(parsed) ? 0 : parsed;
|
|
9801
|
-
};
|
|
9802
|
-
const resolveParentList = ($pos) => {
|
|
9803
|
-
if (!$pos) return null;
|
|
9804
|
-
for (let depth = $pos.depth; depth >= 0; depth--) {
|
|
9805
|
-
const node = $pos.node(depth);
|
|
9806
|
-
if (node?.type && LIST_NODE_NAMES.has(node.type.name)) {
|
|
9807
|
-
return node;
|
|
9808
|
-
}
|
|
9442
|
+
const increaseListIndent = () => ({ editor, tr, dispatch }) => {
|
|
9443
|
+
const handled = changeListLevel(1, editor, tr);
|
|
9444
|
+
if (handled && dispatch) {
|
|
9445
|
+
dispatch(tr);
|
|
9809
9446
|
}
|
|
9810
|
-
return
|
|
9447
|
+
return handled;
|
|
9811
9448
|
};
|
|
9812
|
-
const
|
|
9813
|
-
const
|
|
9814
|
-
|
|
9815
|
-
|
|
9816
|
-
return typeof fallbackPos === "number" ? [fallbackPos] : [];
|
|
9817
|
-
}
|
|
9818
|
-
const candidates = [];
|
|
9819
|
-
const { from: from2, to } = state.selection;
|
|
9820
|
-
doc2.nodesBetween(from2, to, (node, pos) => {
|
|
9821
|
-
if (node.type === listItemType) {
|
|
9822
|
-
const size = typeof node.nodeSize === "number" ? node.nodeSize : 0;
|
|
9823
|
-
candidates.push({ node, pos, end: pos + size });
|
|
9824
|
-
}
|
|
9825
|
-
});
|
|
9826
|
-
if (!candidates.length && typeof fallbackPos === "number") {
|
|
9827
|
-
return [fallbackPos];
|
|
9449
|
+
const decreaseListIndent = () => ({ editor, tr, dispatch }) => {
|
|
9450
|
+
const handled = changeListLevel(-1, editor, tr);
|
|
9451
|
+
if (handled && dispatch) {
|
|
9452
|
+
dispatch(tr);
|
|
9828
9453
|
}
|
|
9829
|
-
|
|
9830
|
-
return !candidates.some((other) => other.pos > pos && other.pos < end2);
|
|
9831
|
-
});
|
|
9832
|
-
const sorted = filtered.map(({ pos }) => pos).sort((a, b) => a - b);
|
|
9833
|
-
return sorted.filter((pos, index2) => index2 === 0 || pos !== sorted[index2 - 1]);
|
|
9454
|
+
return handled;
|
|
9834
9455
|
};
|
|
9835
|
-
const
|
|
9836
|
-
const { state } =
|
|
9837
|
-
const
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
|
|
9842
|
-
|
|
9843
|
-
|
|
9844
|
-
|
|
9845
|
-
|
|
9846
|
-
|
|
9847
|
-
|
|
9848
|
-
|
|
9849
|
-
validNodes.forEach(({ mappedPos, node }) => {
|
|
9850
|
-
const attrs = node.attrs || {};
|
|
9851
|
-
const currLevel = parseLevel(attrs.level);
|
|
9852
|
-
if (currLevel <= 0) {
|
|
9853
|
-
return;
|
|
9854
|
-
}
|
|
9855
|
-
const newLevel = currLevel - 1;
|
|
9856
|
-
const $pos = tr.doc ? tr.doc.resolve(mappedPos) : null;
|
|
9857
|
-
const parentListNode = resolveParentList($pos) || parentOrderedHelper?.node || parentBulletHelper?.node || parentOrderedHelper || parentBulletHelper;
|
|
9858
|
-
parentListsMap[mappedPos] = parentListNode;
|
|
9859
|
-
if (!parentListNode) {
|
|
9860
|
-
return;
|
|
9861
|
-
}
|
|
9862
|
-
const fallbackListId = parentListNode.attrs?.listId ?? null;
|
|
9863
|
-
let numId = fallbackListId ?? attrs.numId ?? null;
|
|
9864
|
-
let createdNewId = false;
|
|
9865
|
-
if (numId == null && ListHelpers.getNewListId) {
|
|
9866
|
-
numId = ListHelpers.getNewListId(editor);
|
|
9867
|
-
createdNewId = numId != null;
|
|
9868
|
-
}
|
|
9869
|
-
if (createdNewId && numId != null && ListHelpers.generateNewListDefinition) {
|
|
9870
|
-
ListHelpers.generateNewListDefinition({
|
|
9871
|
-
numId,
|
|
9872
|
-
listType: parentListNode.type,
|
|
9873
|
-
editor
|
|
9874
|
-
});
|
|
9456
|
+
const removeNumberingProperties = ({ checkType = "startParagraph" } = {}) => (props) => {
|
|
9457
|
+
const { tr, state, editor, dispatch } = props;
|
|
9458
|
+
const { node: paragraph, pos } = findParentNode(isList)(state.selection) || {};
|
|
9459
|
+
if (!paragraph) return false;
|
|
9460
|
+
if (checkType === "empty" && !isVisuallyEmptyParagraph(paragraph)) return false;
|
|
9461
|
+
if (checkType === "startParagraph") {
|
|
9462
|
+
const { $from, empty: empty2 } = state.selection;
|
|
9463
|
+
if ((!empty2 || $from.parentOffset !== 0) && !isVisuallyEmptyParagraph(paragraph)) return false;
|
|
9464
|
+
}
|
|
9465
|
+
const ilvl = paragraph.attrs.numberingProperties.ilvl;
|
|
9466
|
+
if (ilvl > 0) {
|
|
9467
|
+
const outdented = decreaseListIndent()(props);
|
|
9468
|
+
if (outdented) {
|
|
9469
|
+
tr.scrollIntoView();
|
|
9875
9470
|
}
|
|
9876
|
-
|
|
9877
|
-
|
|
9878
|
-
|
|
9879
|
-
|
|
9880
|
-
|
|
9881
|
-
|
|
9882
|
-
return Object.values(parentListsMap).length ? !Object.values(parentListsMap).every((pos) => !pos) : true;
|
|
9471
|
+
return outdented;
|
|
9472
|
+
} else {
|
|
9473
|
+
updateNumberingProperties(null, paragraph, pos, editor, tr);
|
|
9474
|
+
}
|
|
9475
|
+
if (dispatch) dispatch(tr);
|
|
9476
|
+
return true;
|
|
9883
9477
|
};
|
|
9884
9478
|
function isVisuallyEmptyParagraph(node) {
|
|
9885
9479
|
if (!node || node.type.name !== "paragraph") return false;
|
|
@@ -9896,7 +9490,7 @@ function isVisuallyEmptyParagraph(node) {
|
|
|
9896
9490
|
if (text.length > 0) return false;
|
|
9897
9491
|
let hasInlineLeaf = false;
|
|
9898
9492
|
node.descendants((n) => {
|
|
9899
|
-
if (n.isInline && n.isLeaf && n.type?.name !== "hardBreak") {
|
|
9493
|
+
if (n.isInline && n.isLeaf && n.type?.name !== "hardBreak" && n.type?.name !== "run") {
|
|
9900
9494
|
hasInlineLeaf = true;
|
|
9901
9495
|
return false;
|
|
9902
9496
|
}
|
|
@@ -9905,468 +9499,6 @@ function isVisuallyEmptyParagraph(node) {
|
|
|
9905
9499
|
if (hasInlineLeaf) return false;
|
|
9906
9500
|
return true;
|
|
9907
9501
|
}
|
|
9908
|
-
function tryOutdentOneLevel(props) {
|
|
9909
|
-
return decreaseListIndent()(props);
|
|
9910
|
-
}
|
|
9911
|
-
const splitListItem = () => (props) => {
|
|
9912
|
-
const { tr, state, dispatch } = props;
|
|
9913
|
-
const type = getNodeType("listItem", state.schema);
|
|
9914
|
-
const { $from, $to, empty: empty2 } = state.selection;
|
|
9915
|
-
tr.setMeta("updateListSync", true);
|
|
9916
|
-
const listItemPM = findParentNode((n) => n.type === type)(state.selection);
|
|
9917
|
-
if (!listItemPM) return false;
|
|
9918
|
-
const { node: listItemNode } = listItemPM;
|
|
9919
|
-
if (state.selection.node && state.selection.node.isBlock || $from.depth < 2 || !$from.sameParent($to)) {
|
|
9920
|
-
return false;
|
|
9921
|
-
}
|
|
9922
|
-
const paraPM = findParentNode((n) => n.type.name === "paragraph")(state.selection);
|
|
9923
|
-
if (!paraPM) return false;
|
|
9924
|
-
const originalParagraphNode = paraPM.node;
|
|
9925
|
-
const paraStart = paraPM.pos + 1;
|
|
9926
|
-
const listPM = findParentNode((n) => ["orderedList", "bulletList"].includes(n.type.name))(state.selection);
|
|
9927
|
-
if (!listPM) return false;
|
|
9928
|
-
const { node: parentListNode, pos: listStart } = listPM;
|
|
9929
|
-
const listEnd = listStart + parentListNode.nodeSize;
|
|
9930
|
-
let offsetInParagraph;
|
|
9931
|
-
if (empty2) {
|
|
9932
|
-
offsetInParagraph = state.selection.from - paraStart;
|
|
9933
|
-
} else {
|
|
9934
|
-
offsetInParagraph = $from.pos - paraStart;
|
|
9935
|
-
}
|
|
9936
|
-
const parentPara = $from.parent;
|
|
9937
|
-
const isEmptyPara = isVisuallyEmptyParagraph(parentPara);
|
|
9938
|
-
const atEndOfListItem = $from.node(-1).childCount === $from.indexAfter(-1);
|
|
9939
|
-
if (isEmptyPara && atEndOfListItem) {
|
|
9940
|
-
const currentLevel = typeof listItemNode?.attrs?.level === "number" ? listItemNode.attrs.level : 0;
|
|
9941
|
-
if (currentLevel > 0) {
|
|
9942
|
-
const outdented = tryOutdentOneLevel(props);
|
|
9943
|
-
if (outdented) {
|
|
9944
|
-
tr.scrollIntoView();
|
|
9945
|
-
if (dispatch) dispatch(tr);
|
|
9946
|
-
return true;
|
|
9947
|
-
}
|
|
9948
|
-
}
|
|
9949
|
-
return handleSplitInEmptyBlock(props, listItemPM);
|
|
9950
|
-
}
|
|
9951
|
-
if (isVisuallyEmptyParagraph(originalParagraphNode)) {
|
|
9952
|
-
const currentLevel = typeof listItemNode?.attrs?.level === "number" ? listItemNode.attrs.level : 0;
|
|
9953
|
-
if (currentLevel > 0) {
|
|
9954
|
-
const outdented = tryOutdentOneLevel(props);
|
|
9955
|
-
if (outdented) {
|
|
9956
|
-
tr.scrollIntoView();
|
|
9957
|
-
if (dispatch) dispatch(tr);
|
|
9958
|
-
return true;
|
|
9959
|
-
}
|
|
9960
|
-
}
|
|
9961
|
-
return handleSplitInEmptyBlock(props, listItemPM);
|
|
9962
|
-
}
|
|
9963
|
-
let paragraphContentToSplit = originalParagraphNode.content;
|
|
9964
|
-
if (!empty2) {
|
|
9965
|
-
const selectionStart = $from.pos - paraStart;
|
|
9966
|
-
const selectionEnd = $to.pos - paraStart;
|
|
9967
|
-
paragraphContentToSplit = originalParagraphNode.content.cut(0, selectionStart).append(originalParagraphNode.content.cut(selectionEnd));
|
|
9968
|
-
offsetInParagraph = selectionStart;
|
|
9969
|
-
}
|
|
9970
|
-
const beforeCursor = paragraphContentToSplit.cut(0, Math.max(0, offsetInParagraph));
|
|
9971
|
-
const afterCursor = paragraphContentToSplit.cut(Math.max(0, offsetInParagraph));
|
|
9972
|
-
const paragraphIndex = $from.index(-1);
|
|
9973
|
-
const listItemHasMultipleParagraphs = listItemNode.childCount > 1;
|
|
9974
|
-
let firstLI, secondLI;
|
|
9975
|
-
if (listItemHasMultipleParagraphs) {
|
|
9976
|
-
const contentBefore = [];
|
|
9977
|
-
for (let i = 0; i < paragraphIndex; i++) contentBefore.push(listItemNode.child(i));
|
|
9978
|
-
const contentAfter = [];
|
|
9979
|
-
for (let i = paragraphIndex + 1; i < listItemNode.childCount; i++) contentAfter.push(listItemNode.child(i));
|
|
9980
|
-
const firstParas = [
|
|
9981
|
-
...contentBefore,
|
|
9982
|
-
originalParagraphNode.type.create(originalParagraphNode.attrs, beforeCursor.size ? beforeCursor : null)
|
|
9983
|
-
].filter(Boolean);
|
|
9984
|
-
if (firstParas.length === 0) {
|
|
9985
|
-
firstParas.push(state.schema.nodes.paragraph.create(originalParagraphNode.attrs));
|
|
9986
|
-
}
|
|
9987
|
-
const secondParas = [
|
|
9988
|
-
originalParagraphNode.type.create(originalParagraphNode.attrs, afterCursor.size ? afterCursor : null),
|
|
9989
|
-
...contentAfter
|
|
9990
|
-
].filter(Boolean);
|
|
9991
|
-
if (secondParas.length === 0) {
|
|
9992
|
-
secondParas.push(state.schema.nodes.paragraph.create(originalParagraphNode.attrs));
|
|
9993
|
-
}
|
|
9994
|
-
firstLI = state.schema.nodes.listItem.create({ ...listItemNode.attrs }, Fragment.from(firstParas));
|
|
9995
|
-
secondLI = state.schema.nodes.listItem.create({ ...listItemNode.attrs }, Fragment.from(secondParas));
|
|
9996
|
-
} else {
|
|
9997
|
-
const firstParagraph = originalParagraphNode.type.create(
|
|
9998
|
-
originalParagraphNode.attrs,
|
|
9999
|
-
beforeCursor.size ? beforeCursor : null
|
|
10000
|
-
);
|
|
10001
|
-
const secondParagraph = originalParagraphNode.type.create(
|
|
10002
|
-
originalParagraphNode.attrs,
|
|
10003
|
-
afterCursor.size ? afterCursor : null
|
|
10004
|
-
);
|
|
10005
|
-
firstLI = state.schema.nodes.listItem.create({ ...listItemNode.attrs }, firstParagraph);
|
|
10006
|
-
secondLI = state.schema.nodes.listItem.create({ ...listItemNode.attrs }, secondParagraph);
|
|
10007
|
-
}
|
|
10008
|
-
if (!firstLI || !secondLI) return false;
|
|
10009
|
-
const ListType = parentListNode.type;
|
|
10010
|
-
const firstList = ListType.createAndFill(parentListNode.attrs, Fragment.from(firstLI));
|
|
10011
|
-
const secondList = ListType.createAndFill(parentListNode.attrs, Fragment.from(secondLI));
|
|
10012
|
-
if (!firstList || !secondList) return false;
|
|
10013
|
-
tr.replaceWith(listStart, listEnd, firstList);
|
|
10014
|
-
const insertAfterFirst = listStart + firstList.nodeSize;
|
|
10015
|
-
tr.insert(insertAfterFirst, secondList);
|
|
10016
|
-
const cursorPos = insertAfterFirst + 3;
|
|
10017
|
-
tr.setSelection(TextSelection.near(tr.doc.resolve(cursorPos), 1)).scrollIntoView();
|
|
10018
|
-
tr.setMeta("splitListItem", true);
|
|
10019
|
-
if (dispatch) dispatch(tr);
|
|
10020
|
-
return true;
|
|
10021
|
-
};
|
|
10022
|
-
const handleSplitInEmptyBlock = (props, currentListItem) => {
|
|
10023
|
-
const { state, editor, tr } = props;
|
|
10024
|
-
const { schema } = state;
|
|
10025
|
-
const { $from } = state.selection;
|
|
10026
|
-
const extensionAttrs = editor.extensionService.attributes;
|
|
10027
|
-
const listItemNode = currentListItem.node;
|
|
10028
|
-
const isEmptyParagraph = isVisuallyEmptyParagraph($from.parent);
|
|
10029
|
-
const listItemHasOtherContent = listItemNode.content.size > $from.parent.nodeSize;
|
|
10030
|
-
const isAtEndOfListItem = $from.indexAfter(-1) === $from.node(-1).childCount;
|
|
10031
|
-
if (isEmptyParagraph && listItemHasOtherContent && isAtEndOfListItem) {
|
|
10032
|
-
try {
|
|
10033
|
-
const listTypes2 = ["orderedList", "bulletList"];
|
|
10034
|
-
const parentList2 = findParentNode((n) => listTypes2.includes(n.type.name))(state.selection);
|
|
10035
|
-
if (!parentList2) return false;
|
|
10036
|
-
const newParagraphAttrs2 = Attribute.getSplittedAttributes(extensionAttrs, "paragraph", {});
|
|
10037
|
-
const newParagraph2 = schema.nodes.paragraph.create(newParagraphAttrs2);
|
|
10038
|
-
const newListItem = schema.nodes.listItem.create({ ...listItemNode.attrs }, newParagraph2);
|
|
10039
|
-
const ListType = parentList2.node.type;
|
|
10040
|
-
const newList = ListType.createAndFill(parentList2.node.attrs, Fragment.from(newListItem));
|
|
10041
|
-
if (!newList) return false;
|
|
10042
|
-
const insertPos = parentList2.pos + parentList2.node.nodeSize;
|
|
10043
|
-
tr.insert(insertPos, newList);
|
|
10044
|
-
const newPos2 = insertPos + 3;
|
|
10045
|
-
tr.setSelection(TextSelection.near(tr.doc.resolve(newPos2)));
|
|
10046
|
-
tr.scrollIntoView();
|
|
10047
|
-
return true;
|
|
10048
|
-
} catch (e) {
|
|
10049
|
-
console.error("Error creating new list item:", e);
|
|
10050
|
-
return false;
|
|
10051
|
-
}
|
|
10052
|
-
}
|
|
10053
|
-
if (isEmptyParagraph && listItemHasOtherContent && !isAtEndOfListItem) return false;
|
|
10054
|
-
const listTypes = ["orderedList", "bulletList"];
|
|
10055
|
-
const parentList = findParentNode((n) => listTypes.includes(n.type.name))(state.selection);
|
|
10056
|
-
if (!parentList) return false;
|
|
10057
|
-
const newParagraphAttrs = Attribute.getSplittedAttributes(extensionAttrs, "paragraph", {});
|
|
10058
|
-
let newParagraph = schema.nodes.paragraph.createAndFill(newParagraphAttrs);
|
|
10059
|
-
if (!newParagraph) newParagraph = schema.nodes.paragraph.create();
|
|
10060
|
-
const listStart = parentList.pos;
|
|
10061
|
-
const listEnd = parentList.pos + parentList.node.nodeSize;
|
|
10062
|
-
tr.replaceWith(listStart, listEnd, newParagraph);
|
|
10063
|
-
const newPos = listStart + 1;
|
|
10064
|
-
tr.setSelection(TextSelection.near(tr.doc.resolve(newPos)));
|
|
10065
|
-
tr.scrollIntoView();
|
|
10066
|
-
return true;
|
|
10067
|
-
};
|
|
10068
|
-
const sinkListItem = (typeOrName) => ({ state, dispatch }) => {
|
|
10069
|
-
const type = getNodeType(typeOrName, state.schema);
|
|
10070
|
-
return sinkListItem$1(type)(state, dispatch);
|
|
10071
|
-
};
|
|
10072
|
-
const liftListItem = (typeOrName) => ({ state, dispatch }) => {
|
|
10073
|
-
const type = getNodeType(typeOrName, state.schema);
|
|
10074
|
-
return liftListItem$1(type)(state, dispatch);
|
|
10075
|
-
};
|
|
10076
|
-
const deleteListItem = () => (props) => {
|
|
10077
|
-
const { tr, state } = props;
|
|
10078
|
-
const { selection } = state;
|
|
10079
|
-
tr.setMeta("updateListSync", true);
|
|
10080
|
-
if (!selection.empty) {
|
|
10081
|
-
const { from: from2, to } = selection;
|
|
10082
|
-
const fullySelectedBlocks = [];
|
|
10083
|
-
state.doc.nodesBetween(from2, to, (node, pos) => {
|
|
10084
|
-
if (node.isBlock && pos >= from2 && pos + node.nodeSize <= to) {
|
|
10085
|
-
fullySelectedBlocks.push({ pos, size: node.nodeSize });
|
|
10086
|
-
}
|
|
10087
|
-
});
|
|
10088
|
-
if (fullySelectedBlocks.length) {
|
|
10089
|
-
fullySelectedBlocks.sort((a, b) => b.pos - a.pos).forEach(({ pos, size }) => {
|
|
10090
|
-
tr.delete(pos, pos + size);
|
|
10091
|
-
});
|
|
10092
|
-
const $new = tr.doc.resolve(from2);
|
|
10093
|
-
tr.setSelection(TextSelection.near($new));
|
|
10094
|
-
return true;
|
|
10095
|
-
}
|
|
10096
|
-
return false;
|
|
10097
|
-
}
|
|
10098
|
-
const { $from } = state.selection;
|
|
10099
|
-
if ($from.parentOffset !== 0) return false;
|
|
10100
|
-
const currentListItem = findParentNode((n) => n.type.name === "listItem")(state.selection);
|
|
10101
|
-
if (!currentListItem) return false;
|
|
10102
|
-
const listTypes = ["orderedList", "bulletList"];
|
|
10103
|
-
const parentList = findParentNode((n) => listTypes.includes(n.type.name))(state.selection);
|
|
10104
|
-
if (!parentList) return false;
|
|
10105
|
-
const currentParagraphNode = findParentNode((n) => n.type.name === "paragraph")(state.selection);
|
|
10106
|
-
const paragraphNode = currentListItem.node.content.firstChild;
|
|
10107
|
-
if (paragraphNode !== currentParagraphNode.node) return false;
|
|
10108
|
-
const listFrom = parentList.pos;
|
|
10109
|
-
const listTo = listFrom + parentList.node.nodeSize;
|
|
10110
|
-
if (currentListItem.node.content.size === 0) {
|
|
10111
|
-
tr.delete(listFrom, listTo);
|
|
10112
|
-
return true;
|
|
10113
|
-
}
|
|
10114
|
-
const listItemContent = currentListItem.node.content;
|
|
10115
|
-
const nodes = [];
|
|
10116
|
-
listItemContent.forEach((child) => {
|
|
10117
|
-
nodes.push(child);
|
|
10118
|
-
});
|
|
10119
|
-
tr.replaceWith(listFrom, listTo, nodes);
|
|
10120
|
-
const $pos = tr.doc.resolve(listFrom + 1);
|
|
10121
|
-
tr.setSelection(TextSelection.near($pos));
|
|
10122
|
-
return true;
|
|
10123
|
-
};
|
|
10124
|
-
const increaseListIndent = (_targetPositions) => ({ editor, tr }) => {
|
|
10125
|
-
const { state } = editor;
|
|
10126
|
-
const currentItem = ListHelpers.getCurrentListItem && ListHelpers.getCurrentListItem(state) || findParentNode((n) => n.type && n.type.name === "listItem")(state.selection);
|
|
10127
|
-
const parentOrderedHelper = ListHelpers.getParentOrderedList && ListHelpers.getParentOrderedList(state);
|
|
10128
|
-
const parentBulletHelper = ListHelpers.getParentBulletList && ListHelpers.getParentBulletList(state);
|
|
10129
|
-
const targetPositions = _targetPositions || collectTargetListItemPositions(state, currentItem?.pos);
|
|
10130
|
-
if (!targetPositions.length) return false;
|
|
10131
|
-
let parentListsMap = {};
|
|
10132
|
-
const mappedNodes = targetPositions.map((originalPos) => {
|
|
10133
|
-
const mappedPos = tr.mapping ? tr.mapping.map(originalPos) : originalPos;
|
|
10134
|
-
const node = tr.doc && tr.doc.nodeAt(mappedPos) || (currentItem && originalPos === currentItem.pos ? currentItem.node : null);
|
|
10135
|
-
return { originalPos, mappedPos, node };
|
|
10136
|
-
});
|
|
10137
|
-
const validNodes = mappedNodes.filter(({ node }) => node && node.type.name === "listItem");
|
|
10138
|
-
validNodes.forEach(({ mappedPos, node }) => {
|
|
10139
|
-
const attrs = node.attrs || {};
|
|
10140
|
-
const currentLevel = parseLevel(attrs.level);
|
|
10141
|
-
const newLevel = currentLevel + 1;
|
|
10142
|
-
const $pos = tr.doc ? tr.doc.resolve(mappedPos) : null;
|
|
10143
|
-
const parentListNode = resolveParentList($pos) || parentOrderedHelper?.node || parentBulletHelper?.node || parentOrderedHelper || parentBulletHelper;
|
|
10144
|
-
parentListsMap[mappedPos] = parentListNode;
|
|
10145
|
-
if (!parentListNode) {
|
|
10146
|
-
return;
|
|
10147
|
-
}
|
|
10148
|
-
let numId = attrs.numId;
|
|
10149
|
-
if (numId == null) {
|
|
10150
|
-
const fallbackListId = parentListNode.attrs?.listId ?? null;
|
|
10151
|
-
numId = fallbackListId ?? (ListHelpers.getNewListId ? ListHelpers.getNewListId(editor) : null);
|
|
10152
|
-
if (numId != null && ListHelpers.generateNewListDefinition) {
|
|
10153
|
-
ListHelpers.generateNewListDefinition({
|
|
10154
|
-
numId,
|
|
10155
|
-
listType: parentListNode.type,
|
|
10156
|
-
editor
|
|
10157
|
-
});
|
|
10158
|
-
}
|
|
10159
|
-
}
|
|
10160
|
-
tr.setNodeMarkup(mappedPos, null, {
|
|
10161
|
-
...attrs,
|
|
10162
|
-
level: newLevel,
|
|
10163
|
-
numId
|
|
10164
|
-
});
|
|
10165
|
-
});
|
|
10166
|
-
return Object.values(parentListsMap).length ? !Object.values(parentListsMap).every((pos) => !pos) : true;
|
|
10167
|
-
};
|
|
10168
|
-
const isList = (n) => !!n && (n.type?.name === "orderedList" || n.type?.name === "bulletList");
|
|
10169
|
-
const findNodePosition = (doc2, targetNode) => {
|
|
10170
|
-
let nodePos = null;
|
|
10171
|
-
doc2.descendants((node, pos) => {
|
|
10172
|
-
if (node === targetNode) {
|
|
10173
|
-
nodePos = pos;
|
|
10174
|
-
return false;
|
|
10175
|
-
}
|
|
10176
|
-
return true;
|
|
10177
|
-
});
|
|
10178
|
-
return nodePos;
|
|
10179
|
-
};
|
|
10180
|
-
function getListContext(state) {
|
|
10181
|
-
const { $from } = state.selection;
|
|
10182
|
-
for (let d2 = $from.depth; d2 > 0; d2--) {
|
|
10183
|
-
const node = $from.node(d2 - 1);
|
|
10184
|
-
if (isList(node)) {
|
|
10185
|
-
const listDepth = d2 - 1;
|
|
10186
|
-
const listPos = $from.before(listDepth);
|
|
10187
|
-
const listNode = node;
|
|
10188
|
-
const liNode = listNode.firstChild || null;
|
|
10189
|
-
if (!liNode || liNode.type.name !== "listItem") return null;
|
|
10190
|
-
return { listDepth, listPos, listNode, liNode };
|
|
10191
|
-
}
|
|
10192
|
-
}
|
|
10193
|
-
return null;
|
|
10194
|
-
}
|
|
10195
|
-
const handleBackspaceNextToList = () => ({ state, dispatch, editor }) => {
|
|
10196
|
-
const { selection, doc: doc2, schema } = state;
|
|
10197
|
-
const { $from } = selection;
|
|
10198
|
-
if (!selection.empty) return false;
|
|
10199
|
-
if ($from.parent.type.name !== "paragraph") return false;
|
|
10200
|
-
const ctx = getListContext(state);
|
|
10201
|
-
if (ctx) {
|
|
10202
|
-
const { listPos, listNode, liNode } = ctx;
|
|
10203
|
-
const atStartOfParagraph = $from.parentOffset === 0;
|
|
10204
|
-
const itemIsEmpty = liNode.childCount > 0 ? liNode.firstChild?.content.size === 0 : true;
|
|
10205
|
-
if (!atStartOfParagraph && !itemIsEmpty) return false;
|
|
10206
|
-
const level = Number(liNode.attrs?.level ?? 0);
|
|
10207
|
-
if (level > 0) {
|
|
10208
|
-
const tr1 = state.tr.setMeta("updateListSync", true);
|
|
10209
|
-
const didOutdent = typeof decreaseListIndent === "function" && decreaseListIndent()({
|
|
10210
|
-
editor,
|
|
10211
|
-
state,
|
|
10212
|
-
tr: tr1,
|
|
10213
|
-
dispatch: (t) => dispatch && t && dispatch(t)
|
|
10214
|
-
});
|
|
10215
|
-
if (didOutdent) return true;
|
|
10216
|
-
const liPos = listPos + 1;
|
|
10217
|
-
const newLevel = Math.max(0, level - 1);
|
|
10218
|
-
const trFallback = state.tr.setMeta("updateListSync", true);
|
|
10219
|
-
trFallback.setNodeMarkup(liPos, null, { ...liNode.attrs, level: newLevel });
|
|
10220
|
-
dispatch(trFallback);
|
|
10221
|
-
return true;
|
|
10222
|
-
}
|
|
10223
|
-
const replacement = liNode && liNode.content && liNode.content.size > 0 ? liNode.content : Fragment.from(schema.nodes.paragraph.create());
|
|
10224
|
-
const from2 = listPos;
|
|
10225
|
-
const to = listPos + listNode.nodeSize;
|
|
10226
|
-
const tr2 = state.tr.setMeta("updateListSync", true);
|
|
10227
|
-
tr2.replaceWith(from2, to, replacement);
|
|
10228
|
-
const newPos = from2 + 1;
|
|
10229
|
-
tr2.setSelection(TextSelection.near(tr2.doc.resolve(newPos), 1)).scrollIntoView();
|
|
10230
|
-
dispatch(tr2);
|
|
10231
|
-
return true;
|
|
10232
|
-
}
|
|
10233
|
-
if ($from.parentOffset !== 0) return false;
|
|
10234
|
-
const parentDepth = $from.depth - 1;
|
|
10235
|
-
if (parentDepth < 0) return false;
|
|
10236
|
-
const container = $from.node(parentDepth);
|
|
10237
|
-
const idx = $from.index(parentDepth);
|
|
10238
|
-
if (idx === 0) return false;
|
|
10239
|
-
const beforeNode = container.child(idx - 1);
|
|
10240
|
-
if (!beforeNode || !isList(beforeNode)) return false;
|
|
10241
|
-
const listItem = beforeNode.lastChild;
|
|
10242
|
-
if (!listItem || listItem.type.name !== "listItem") return false;
|
|
10243
|
-
const targetPara = listItem.lastChild;
|
|
10244
|
-
if (!targetPara || targetPara.type.name !== "paragraph") return false;
|
|
10245
|
-
const paraStartPos = findNodePosition(doc2, targetPara);
|
|
10246
|
-
if (paraStartPos == null) return false;
|
|
10247
|
-
const inlineContent = Fragment.from($from.parent.content);
|
|
10248
|
-
const tr = state.tr.setMeta("updateListSync", true);
|
|
10249
|
-
const thisParaStart = $from.before();
|
|
10250
|
-
tr.delete(thisParaStart, thisParaStart + $from.parent.nodeSize);
|
|
10251
|
-
const insertPos = paraStartPos + 1 + targetPara.content.size;
|
|
10252
|
-
tr.insert(insertPos, inlineContent);
|
|
10253
|
-
tr.setSelection(TextSelection.near(tr.doc.resolve(insertPos), 1));
|
|
10254
|
-
dispatch(tr);
|
|
10255
|
-
return true;
|
|
10256
|
-
};
|
|
10257
|
-
function getParaCtx(state) {
|
|
10258
|
-
const { $from } = state.selection;
|
|
10259
|
-
for (let d2 = $from.depth; d2 >= 0; d2--) {
|
|
10260
|
-
const n = $from.node(d2);
|
|
10261
|
-
if (n.type.name === "paragraph") {
|
|
10262
|
-
const before = $from.before(d2);
|
|
10263
|
-
const endInside = before + 1 + n.content.size;
|
|
10264
|
-
return { para: n, paraDepth: d2, before, endInside };
|
|
10265
|
-
}
|
|
10266
|
-
}
|
|
10267
|
-
return null;
|
|
10268
|
-
}
|
|
10269
|
-
function atVisualParaEnd(state, ctx) {
|
|
10270
|
-
const { $from } = state.selection;
|
|
10271
|
-
const { para, paraDepth, endInside } = ctx;
|
|
10272
|
-
if ($from.parent.type.name === "paragraph" && $from.parentOffset === $from.parent.content.size) return true;
|
|
10273
|
-
if ($from.parent.type.name === "run" && $from.parentOffset === $from.parent.content.size) {
|
|
10274
|
-
const idxInPara = $from.index(paraDepth);
|
|
10275
|
-
return idxInPara === para.childCount - 1;
|
|
10276
|
-
}
|
|
10277
|
-
return $from.pos === endInside;
|
|
10278
|
-
}
|
|
10279
|
-
function getNextSiblingAtDepth(state, depth) {
|
|
10280
|
-
const pos = state.selection.$from.after(depth);
|
|
10281
|
-
if (pos == null) return { pos: null, next: null };
|
|
10282
|
-
const $pos = state.doc.resolve(pos);
|
|
10283
|
-
return { pos, next: $pos.nodeAfter || null };
|
|
10284
|
-
}
|
|
10285
|
-
const handleDeleteNextToList = () => ({ state, dispatch }) => {
|
|
10286
|
-
const { selection } = state;
|
|
10287
|
-
const { $from } = selection;
|
|
10288
|
-
if (!selection.empty) return false;
|
|
10289
|
-
const ctx = getParaCtx(state);
|
|
10290
|
-
if (!ctx) return false;
|
|
10291
|
-
const { paraDepth, endInside: paraEnd } = ctx;
|
|
10292
|
-
if (!atVisualParaEnd(state, ctx)) return false;
|
|
10293
|
-
const tr = state.tr;
|
|
10294
|
-
tr.setMeta("suppressAutoList", true);
|
|
10295
|
-
const insertAtParaEnd = (frag) => {
|
|
10296
|
-
const mapped = tr.mapping.map(paraEnd, 1);
|
|
10297
|
-
tr.insert(mapped, frag);
|
|
10298
|
-
return mapped;
|
|
10299
|
-
};
|
|
10300
|
-
let listItemDepth = -1;
|
|
10301
|
-
let listDepth = -1;
|
|
10302
|
-
for (let d2 = $from.depth; d2 > 0; d2--) {
|
|
10303
|
-
const maybeLI = $from.node(d2 - 1);
|
|
10304
|
-
if (maybeLI.type.name === "listItem") {
|
|
10305
|
-
listItemDepth = d2 - 1;
|
|
10306
|
-
if (d2 - 2 >= 0 && isList($from.node(d2 - 2))) listDepth = d2 - 2;
|
|
10307
|
-
break;
|
|
10308
|
-
}
|
|
10309
|
-
}
|
|
10310
|
-
if (listItemDepth !== -1 && listDepth !== -1) {
|
|
10311
|
-
const li = $from.node(listItemDepth);
|
|
10312
|
-
const paraIdxInLI = $from.index(listItemDepth + 1);
|
|
10313
|
-
if (paraIdxInLI < li.childCount - 1) return false;
|
|
10314
|
-
}
|
|
10315
|
-
const currentBlockDepth = listItemDepth !== -1 && listDepth !== -1 ? listDepth : paraDepth;
|
|
10316
|
-
const { pos: nextBeforePos, next: nextNode } = getNextSiblingAtDepth(state, currentBlockDepth);
|
|
10317
|
-
if (nextBeforePos == null || !nextNode) return false;
|
|
10318
|
-
const mergeParagraphAt = (beforePos) => {
|
|
10319
|
-
const livePara = tr.doc.resolve(beforePos).nodeAfter;
|
|
10320
|
-
if (!livePara || livePara.type.name !== "paragraph") return false;
|
|
10321
|
-
if (livePara.content.size === 0) {
|
|
10322
|
-
tr.delete(beforePos, beforePos + livePara.nodeSize);
|
|
10323
|
-
dispatch?.(tr);
|
|
10324
|
-
return true;
|
|
10325
|
-
}
|
|
10326
|
-
const ins = insertAtParaEnd(Fragment.from(livePara.content));
|
|
10327
|
-
const delFrom = tr.mapping.map(beforePos, 1);
|
|
10328
|
-
const delTo = tr.mapping.map(beforePos + livePara.nodeSize, 1);
|
|
10329
|
-
tr.delete(delFrom, delTo);
|
|
10330
|
-
const selPos = tr.mapping.map(ins + livePara.content.size, -1);
|
|
10331
|
-
tr.setSelection(TextSelection.near(tr.doc.resolve(selPos), -1)).scrollIntoView();
|
|
10332
|
-
dispatch?.(tr);
|
|
10333
|
-
return true;
|
|
10334
|
-
};
|
|
10335
|
-
const mergeListAt = (beforePos) => {
|
|
10336
|
-
const liveList = tr.doc.resolve(beforePos).nodeAfter;
|
|
10337
|
-
if (!liveList || !isList(liveList)) return true;
|
|
10338
|
-
const li = liveList.firstChild;
|
|
10339
|
-
if (!li || li.type.name !== "listItem" || li.childCount === 0) {
|
|
10340
|
-
tr.delete(beforePos, beforePos + liveList.nodeSize);
|
|
10341
|
-
dispatch?.(tr);
|
|
10342
|
-
return true;
|
|
10343
|
-
}
|
|
10344
|
-
let content = null;
|
|
10345
|
-
for (let i = 0; i < li.childCount; i++) {
|
|
10346
|
-
const ch = li.child(i);
|
|
10347
|
-
if (ch.type.name === "paragraph" && ch.content.size > 0) {
|
|
10348
|
-
content = ch.content;
|
|
10349
|
-
break;
|
|
10350
|
-
}
|
|
10351
|
-
}
|
|
10352
|
-
if (content) insertAtParaEnd(Fragment.from(content));
|
|
10353
|
-
const delFrom = tr.mapping.map(beforePos, 1);
|
|
10354
|
-
const delTo = tr.mapping.map(beforePos + liveList.nodeSize, 1);
|
|
10355
|
-
tr.delete(delFrom, delTo);
|
|
10356
|
-
const endPos = tr.mapping.map(paraEnd + (content ? content.size : 0), -1);
|
|
10357
|
-
tr.setSelection(TextSelection.near(tr.doc.resolve(endPos), -1)).scrollIntoView();
|
|
10358
|
-
dispatch?.(tr);
|
|
10359
|
-
return true;
|
|
10360
|
-
};
|
|
10361
|
-
if (nextNode.isTextblock) {
|
|
10362
|
-
const changed = mergeParagraphAt(nextBeforePos);
|
|
10363
|
-
return changed ? true : false;
|
|
10364
|
-
}
|
|
10365
|
-
if (isList(nextNode)) {
|
|
10366
|
-
return mergeListAt(nextBeforePos);
|
|
10367
|
-
}
|
|
10368
|
-
return false;
|
|
10369
|
-
};
|
|
10370
9502
|
const restoreSelection = () => ({ editor, state, tr }) => {
|
|
10371
9503
|
if (editor.options.lastSelection) {
|
|
10372
9504
|
const selectionTr = tr.setSelection(
|
|
@@ -10420,23 +9552,18 @@ const getSelectionMarks = () => ({ state, tr }) => {
|
|
|
10420
9552
|
};
|
|
10421
9553
|
const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
10422
9554
|
__proto__: null,
|
|
10423
|
-
|
|
9555
|
+
changeListLevel,
|
|
10424
9556
|
clearNodes,
|
|
10425
|
-
collectIntersectingTopLists,
|
|
10426
9557
|
command,
|
|
10427
9558
|
createParagraphNear,
|
|
10428
9559
|
decreaseListIndent,
|
|
10429
9560
|
defaultStyleDetector,
|
|
10430
|
-
deleteListItem,
|
|
10431
9561
|
deleteSelection,
|
|
10432
9562
|
exitCode,
|
|
10433
9563
|
first,
|
|
10434
9564
|
getEffectiveStyleId,
|
|
10435
|
-
getParaCtx,
|
|
10436
9565
|
getSelectionMarks,
|
|
10437
9566
|
getStyleIdFromMarks,
|
|
10438
|
-
handleBackspaceNextToList,
|
|
10439
|
-
handleDeleteNextToList,
|
|
10440
9567
|
increaseListIndent,
|
|
10441
9568
|
insertContent,
|
|
10442
9569
|
insertContentAt,
|
|
@@ -10449,11 +9576,9 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
10449
9576
|
joinForward,
|
|
10450
9577
|
joinUp,
|
|
10451
9578
|
liftEmptyBlock,
|
|
10452
|
-
liftListItem,
|
|
10453
9579
|
mapMarkToStyleKey,
|
|
10454
|
-
nearestListAt,
|
|
10455
9580
|
newlineInCode,
|
|
10456
|
-
|
|
9581
|
+
removeNumberingProperties,
|
|
10457
9582
|
resetAttributes,
|
|
10458
9583
|
restoreSelection,
|
|
10459
9584
|
selectAll,
|
|
@@ -10461,14 +9586,11 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
10461
9586
|
selectNodeForward,
|
|
10462
9587
|
selectTextblockEnd,
|
|
10463
9588
|
selectTextblockStart,
|
|
10464
|
-
setMappedSelectionSpan,
|
|
10465
9589
|
setMark,
|
|
10466
9590
|
setMeta,
|
|
10467
9591
|
setNode,
|
|
10468
9592
|
setTextSelection,
|
|
10469
|
-
sinkListItem,
|
|
10470
9593
|
splitBlock: splitBlock$1,
|
|
10471
|
-
splitListItem,
|
|
10472
9594
|
toggleList,
|
|
10473
9595
|
toggleMark,
|
|
10474
9596
|
toggleMarkCascade,
|
|
@@ -10477,7 +9599,7 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
10477
9599
|
unsetAllMarks,
|
|
10478
9600
|
unsetMark,
|
|
10479
9601
|
updateAttributes,
|
|
10480
|
-
|
|
9602
|
+
updateNumberingProperties
|
|
10481
9603
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
10482
9604
|
const Commands = Extension.create({
|
|
10483
9605
|
name: "commands",
|
|
@@ -10502,8 +9624,7 @@ const handleBackspace = (editor) => {
|
|
|
10502
9624
|
return false;
|
|
10503
9625
|
},
|
|
10504
9626
|
() => commands2.deleteSelection(),
|
|
10505
|
-
() => commands2.
|
|
10506
|
-
() => commands2.deleteListItem(),
|
|
9627
|
+
() => commands2.removeNumberingProperties(),
|
|
10507
9628
|
() => commands2.joinBackward(),
|
|
10508
9629
|
() => commands2.selectNodeBackward()
|
|
10509
9630
|
]);
|
|
@@ -10511,7 +9632,6 @@ const handleBackspace = (editor) => {
|
|
|
10511
9632
|
const handleDelete = (editor) => {
|
|
10512
9633
|
return editor.commands.first(({ commands: commands2 }) => [
|
|
10513
9634
|
() => commands2.deleteSelection(),
|
|
10514
|
-
() => commands2.handleDeleteNextToList(),
|
|
10515
9635
|
() => commands2.joinForward(),
|
|
10516
9636
|
() => commands2.selectNodeForward()
|
|
10517
9637
|
]);
|
|
@@ -11028,7 +10148,8 @@ const _ExtensionService = class _ExtensionService {
|
|
|
11028
10148
|
getPos,
|
|
11029
10149
|
decorations,
|
|
11030
10150
|
htmlAttributes,
|
|
11031
|
-
extension
|
|
10151
|
+
extension,
|
|
10152
|
+
extensionAttrs
|
|
11032
10153
|
});
|
|
11033
10154
|
};
|
|
11034
10155
|
return [extension.name, nodeview];
|
|
@@ -15081,7 +14202,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
15081
14202
|
{ default: remarkStringify },
|
|
15082
14203
|
{ default: remarkGfm }
|
|
15083
14204
|
] = await Promise.all([
|
|
15084
|
-
import("./index-
|
|
14205
|
+
import("./index-D9ggxe26.js"),
|
|
15085
14206
|
import("./index-DRCvimau.js"),
|
|
15086
14207
|
import("./index-C_x_N6Uh.js"),
|
|
15087
14208
|
import("./index-D_sWOSiG.js"),
|
|
@@ -15299,7 +14420,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
15299
14420
|
* @returns {Object | void} Migration results
|
|
15300
14421
|
*/
|
|
15301
14422
|
processCollaborationMigrations() {
|
|
15302
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.30.0-next.
|
|
14423
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.30.0-next.3");
|
|
15303
14424
|
if (!this.options.ydoc) return;
|
|
15304
14425
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
15305
14426
|
let docVersion = metaMap.get("version");
|
|
@@ -15404,7 +14525,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
15404
14525
|
if (!targetNode || !html) return;
|
|
15405
14526
|
const start2 = targetNode.pos;
|
|
15406
14527
|
const end2 = start2 + targetNode.node.nodeSize;
|
|
15407
|
-
const htmlNode = createDocFromHTML(html, this
|
|
14528
|
+
const htmlNode = createDocFromHTML(html, this);
|
|
15408
14529
|
tr.replaceWith(start2, end2, htmlNode);
|
|
15409
14530
|
dispatch(tr);
|
|
15410
14531
|
}
|
|
@@ -15779,14 +14900,14 @@ generatePmData_fn = function() {
|
|
|
15779
14900
|
doc2 = createDocument(this.converter, this.schema, this);
|
|
15780
14901
|
doc2 = __privateMethod(this, _Editor_instances, prepareDocumentForImport_fn).call(this, doc2);
|
|
15781
14902
|
if (this.options.markdown) {
|
|
15782
|
-
doc2 = createDocFromMarkdown(this.options.markdown, this
|
|
15783
|
-
} else if (this.options.html) doc2 = createDocFromHTML(this.options.html, this
|
|
14903
|
+
doc2 = createDocFromMarkdown(this.options.markdown, this, { isImport: true });
|
|
14904
|
+
} else if (this.options.html) doc2 = createDocFromHTML(this.options.html, this, { isImport: true });
|
|
15784
14905
|
else if (this.options.jsonOverride) doc2 = this.schema.nodeFromJSON(this.options.jsonOverride);
|
|
15785
14906
|
if (fragment) doc2 = yXmlFragmentToProseMirrorRootNode(fragment, this.schema);
|
|
15786
14907
|
}
|
|
15787
14908
|
} else if (mode === "text" || mode === "html") {
|
|
15788
14909
|
if (loadFromSchema) doc2 = this.schema.nodeFromJSON(content);
|
|
15789
|
-
else if (content) doc2 = createDocFromHTML(content, this
|
|
14910
|
+
else if (content) doc2 = createDocFromHTML(content, this);
|
|
15790
14911
|
else doc2 = this.schema.topNodeType.createAndFill();
|
|
15791
14912
|
}
|
|
15792
14913
|
} catch (err) {
|
|
@@ -18634,7 +17755,7 @@ const splitRun = () => (props) => {
|
|
|
18634
17755
|
const { $from, empty: empty2 } = state.selection;
|
|
18635
17756
|
if (!empty2) return false;
|
|
18636
17757
|
if ($from.parent.type.name !== "run") return false;
|
|
18637
|
-
const handled =
|
|
17758
|
+
const handled = splitBlockPatch(state, (transaction) => {
|
|
18638
17759
|
view.dispatch(transaction);
|
|
18639
17760
|
});
|
|
18640
17761
|
if (handled) {
|
|
@@ -18642,6 +17763,48 @@ const splitRun = () => (props) => {
|
|
|
18642
17763
|
}
|
|
18643
17764
|
return handled;
|
|
18644
17765
|
};
|
|
17766
|
+
function splitBlockPatch(state, dispatch) {
|
|
17767
|
+
let { $from } = state.selection;
|
|
17768
|
+
if (state.selection instanceof NodeSelection && state.selection.node.isBlock) {
|
|
17769
|
+
if (!$from.parentOffset || !canSplit(state.doc, $from.pos)) return false;
|
|
17770
|
+
if (dispatch) dispatch(state.tr.split($from.pos).scrollIntoView());
|
|
17771
|
+
return true;
|
|
17772
|
+
}
|
|
17773
|
+
if (!$from.depth) return false;
|
|
17774
|
+
let types = [];
|
|
17775
|
+
let splitDepth, deflt, atEnd = false, atStart = false;
|
|
17776
|
+
for (let d2 = $from.depth; ; d2--) {
|
|
17777
|
+
let node = $from.node(d2);
|
|
17778
|
+
if (node.isBlock) {
|
|
17779
|
+
atEnd = $from.end(d2) == $from.pos + ($from.depth - d2);
|
|
17780
|
+
atStart = $from.start(d2) == $from.pos - ($from.depth - d2);
|
|
17781
|
+
deflt = defaultBlockAt$1($from.node(d2 - 1).contentMatchAt($from.indexAfter(d2 - 1)));
|
|
17782
|
+
types.unshift(null);
|
|
17783
|
+
splitDepth = d2;
|
|
17784
|
+
break;
|
|
17785
|
+
} else {
|
|
17786
|
+
if (d2 == 1) return false;
|
|
17787
|
+
types.unshift(null);
|
|
17788
|
+
}
|
|
17789
|
+
}
|
|
17790
|
+
let tr = state.tr;
|
|
17791
|
+
if (state.selection instanceof TextSelection || state.selection instanceof AllSelection) tr.deleteSelection();
|
|
17792
|
+
let splitPos = tr.mapping.map($from.pos);
|
|
17793
|
+
let can = canSplit(tr.doc, splitPos, types.length, types);
|
|
17794
|
+
if (!can) {
|
|
17795
|
+
types[0] = deflt ? { type: deflt } : null;
|
|
17796
|
+
can = canSplit(tr.doc, splitPos, types.length, types);
|
|
17797
|
+
}
|
|
17798
|
+
if (!can) return false;
|
|
17799
|
+
tr.split(splitPos, types.length, types);
|
|
17800
|
+
if (!atEnd && atStart && $from.node(splitDepth).type != deflt) {
|
|
17801
|
+
let first2 = tr.mapping.map($from.before(splitDepth)), $first = tr.doc.resolve(first2);
|
|
17802
|
+
if (deflt && $from.node(splitDepth - 1).canReplaceWith($first.index(), $first.index() + 1, deflt))
|
|
17803
|
+
tr.setNodeMarkup(tr.mapping.map($from.before(splitDepth)), deflt);
|
|
17804
|
+
}
|
|
17805
|
+
if (dispatch) dispatch(tr.scrollIntoView());
|
|
17806
|
+
return true;
|
|
17807
|
+
}
|
|
18645
17808
|
const Run = OxmlNode.create({
|
|
18646
17809
|
name: "run",
|
|
18647
17810
|
oXmlName: "w:r",
|
|
@@ -18694,387 +17857,6 @@ const Run = OxmlNode.create({
|
|
|
18694
17857
|
return ["span", base2, 0];
|
|
18695
17858
|
}
|
|
18696
17859
|
});
|
|
18697
|
-
const inputRegex$1 = /^\s*([-+*])\s$/;
|
|
18698
|
-
const BulletList = Node$1.create({
|
|
18699
|
-
name: "bulletList",
|
|
18700
|
-
group: "block list",
|
|
18701
|
-
selectable: false,
|
|
18702
|
-
content() {
|
|
18703
|
-
return `${this.options.itemTypeName}+`;
|
|
18704
|
-
},
|
|
18705
|
-
addOptions() {
|
|
18706
|
-
return {
|
|
18707
|
-
itemTypeName: "listItem",
|
|
18708
|
-
htmlAttributes: {
|
|
18709
|
-
"aria-label": "Bullet list node"
|
|
18710
|
-
},
|
|
18711
|
-
keepMarks: true,
|
|
18712
|
-
keepAttributes: false
|
|
18713
|
-
};
|
|
18714
|
-
},
|
|
18715
|
-
parseDOM() {
|
|
18716
|
-
return [{ tag: "ul" }];
|
|
18717
|
-
},
|
|
18718
|
-
renderDOM({ htmlAttributes }) {
|
|
18719
|
-
const attributes = Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
|
|
18720
|
-
return ["ul", attributes, 0];
|
|
18721
|
-
},
|
|
18722
|
-
addAttributes() {
|
|
18723
|
-
return {
|
|
18724
|
-
"list-style-type": {
|
|
18725
|
-
default: "bullet",
|
|
18726
|
-
rendered: false
|
|
18727
|
-
},
|
|
18728
|
-
listId: {
|
|
18729
|
-
rendered: false
|
|
18730
|
-
},
|
|
18731
|
-
sdBlockId: {
|
|
18732
|
-
default: null,
|
|
18733
|
-
keepOnSplit: false,
|
|
18734
|
-
parseDOM: (elem) => elem.getAttribute("data-sd-block-id"),
|
|
18735
|
-
renderDOM: (attrs) => {
|
|
18736
|
-
return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
|
|
18737
|
-
}
|
|
18738
|
-
},
|
|
18739
|
-
attributes: {
|
|
18740
|
-
rendered: false,
|
|
18741
|
-
keepOnSplit: true
|
|
18742
|
-
}
|
|
18743
|
-
};
|
|
18744
|
-
},
|
|
18745
|
-
addCommands() {
|
|
18746
|
-
return {
|
|
18747
|
-
/**
|
|
18748
|
-
* Toggle a bullet list at the current selection
|
|
18749
|
-
* @category Command
|
|
18750
|
-
* @example
|
|
18751
|
-
* // Toggle bullet list on selected text
|
|
18752
|
-
* editor.commands.toggleBulletList()
|
|
18753
|
-
* @note Converts selected paragraphs to list items or removes list formatting
|
|
18754
|
-
*/
|
|
18755
|
-
toggleBulletList: () => (params2) => {
|
|
18756
|
-
return toggleList(this.type)(params2);
|
|
18757
|
-
}
|
|
18758
|
-
};
|
|
18759
|
-
},
|
|
18760
|
-
addShortcuts() {
|
|
18761
|
-
return {
|
|
18762
|
-
"Mod-Shift-8": () => {
|
|
18763
|
-
return this.editor.commands.toggleBulletList();
|
|
18764
|
-
}
|
|
18765
|
-
};
|
|
18766
|
-
},
|
|
18767
|
-
addInputRules() {
|
|
18768
|
-
return [
|
|
18769
|
-
new InputRule({
|
|
18770
|
-
match: inputRegex$1,
|
|
18771
|
-
handler: ({ state, range }) => {
|
|
18772
|
-
const $pos = state.selection.$from;
|
|
18773
|
-
const listItemType = state.schema.nodes.listItem;
|
|
18774
|
-
for (let depth = $pos.depth; depth >= 0; depth--) {
|
|
18775
|
-
if ($pos.node(depth).type === listItemType) {
|
|
18776
|
-
return null;
|
|
18777
|
-
}
|
|
18778
|
-
}
|
|
18779
|
-
const { tr } = state;
|
|
18780
|
-
tr.delete(range.from, range.to);
|
|
18781
|
-
ListHelpers.createNewList({
|
|
18782
|
-
listType: this.type,
|
|
18783
|
-
tr,
|
|
18784
|
-
editor: this.editor
|
|
18785
|
-
});
|
|
18786
|
-
}
|
|
18787
|
-
})
|
|
18788
|
-
];
|
|
18789
|
-
}
|
|
18790
|
-
});
|
|
18791
|
-
const inputRegex = /^(\d+)\.\s$/;
|
|
18792
|
-
const OrderedList = Node$1.create({
|
|
18793
|
-
name: "orderedList",
|
|
18794
|
-
group: "block list",
|
|
18795
|
-
selectable: false,
|
|
18796
|
-
content() {
|
|
18797
|
-
return `${this.options.itemTypeName}+`;
|
|
18798
|
-
},
|
|
18799
|
-
addOptions() {
|
|
18800
|
-
return {
|
|
18801
|
-
itemTypeName: "listItem",
|
|
18802
|
-
htmlAttributes: {
|
|
18803
|
-
"aria-label": "Ordered list node"
|
|
18804
|
-
},
|
|
18805
|
-
keepMarks: true,
|
|
18806
|
-
keepAttributes: false,
|
|
18807
|
-
listStyleTypes: ["decimal", "lowerAlpha", "lowerRoman"]
|
|
18808
|
-
};
|
|
18809
|
-
},
|
|
18810
|
-
addAttributes() {
|
|
18811
|
-
return {
|
|
18812
|
-
order: {
|
|
18813
|
-
default: 1,
|
|
18814
|
-
parseDOM: (element) => {
|
|
18815
|
-
return element.hasAttribute("start") ? parseInt(element.getAttribute("start") || "", 10) : 1;
|
|
18816
|
-
},
|
|
18817
|
-
renderDOM: (attrs) => {
|
|
18818
|
-
return {
|
|
18819
|
-
start: attrs.order
|
|
18820
|
-
};
|
|
18821
|
-
}
|
|
18822
|
-
},
|
|
18823
|
-
sdBlockId: {
|
|
18824
|
-
default: null,
|
|
18825
|
-
keepOnSplit: false,
|
|
18826
|
-
parseDOM: (elem) => elem.getAttribute("data-sd-block-id"),
|
|
18827
|
-
renderDOM: (attrs) => {
|
|
18828
|
-
return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
|
|
18829
|
-
}
|
|
18830
|
-
},
|
|
18831
|
-
syncId: {
|
|
18832
|
-
default: null,
|
|
18833
|
-
parseDOM: (elem) => elem.getAttribute("data-sync-id"),
|
|
18834
|
-
renderDOM: (attrs) => {
|
|
18835
|
-
if (!attrs.syncId) return {};
|
|
18836
|
-
return {
|
|
18837
|
-
"data-sync-id": attrs.syncId
|
|
18838
|
-
};
|
|
18839
|
-
}
|
|
18840
|
-
// rendered: false,
|
|
18841
|
-
},
|
|
18842
|
-
listId: {
|
|
18843
|
-
keepOnSplit: true,
|
|
18844
|
-
parseDOM: (elem) => elem.getAttribute("data-list-id"),
|
|
18845
|
-
renderDOM: (attrs) => {
|
|
18846
|
-
if (!attrs.listId) return {};
|
|
18847
|
-
return {
|
|
18848
|
-
"data-list-id": attrs.listId
|
|
18849
|
-
};
|
|
18850
|
-
}
|
|
18851
|
-
},
|
|
18852
|
-
"list-style-type": {
|
|
18853
|
-
default: "decimal",
|
|
18854
|
-
rendered: false
|
|
18855
|
-
},
|
|
18856
|
-
attributes: {
|
|
18857
|
-
rendered: false,
|
|
18858
|
-
keepOnSplit: true
|
|
18859
|
-
}
|
|
18860
|
-
};
|
|
18861
|
-
},
|
|
18862
|
-
parseDOM() {
|
|
18863
|
-
return [{ tag: "ol" }];
|
|
18864
|
-
},
|
|
18865
|
-
renderDOM({ htmlAttributes }) {
|
|
18866
|
-
const { start: start2, ...restAttributes } = htmlAttributes;
|
|
18867
|
-
return start2 === 1 ? ["ol", Attribute.mergeAttributes(this.options.htmlAttributes, restAttributes), 0] : ["ol", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
|
|
18868
|
-
},
|
|
18869
|
-
addCommands() {
|
|
18870
|
-
return {
|
|
18871
|
-
/**
|
|
18872
|
-
* Toggle ordered list formatting
|
|
18873
|
-
* @category Command
|
|
18874
|
-
* @example
|
|
18875
|
-
* editor.commands.toggleOrderedList()
|
|
18876
|
-
* @note Converts selection to ordered list or back to paragraphs
|
|
18877
|
-
*/
|
|
18878
|
-
toggleOrderedList: () => (params2) => {
|
|
18879
|
-
return toggleList(this.type)(params2);
|
|
18880
|
-
},
|
|
18881
|
-
/**
|
|
18882
|
-
* Restart list node numbering
|
|
18883
|
-
* @category Command
|
|
18884
|
-
* @param {Array} followingNodes - Nodes to restart
|
|
18885
|
-
* @param {number} pos - Starting position
|
|
18886
|
-
* @example
|
|
18887
|
-
* editor.commands.restartListNodes(nodes, position)
|
|
18888
|
-
* @note Resets list numbering for specified nodes
|
|
18889
|
-
*/
|
|
18890
|
-
restartListNodes: (followingNodes, pos) => ({ tr }) => {
|
|
18891
|
-
let currentNodePos = pos;
|
|
18892
|
-
const nodes = followingNodes.map((node) => {
|
|
18893
|
-
const resultNode = {
|
|
18894
|
-
node,
|
|
18895
|
-
pos: currentNodePos
|
|
18896
|
-
};
|
|
18897
|
-
currentNodePos += node.nodeSize;
|
|
18898
|
-
return resultNode;
|
|
18899
|
-
});
|
|
18900
|
-
nodes.forEach((item) => {
|
|
18901
|
-
const { pos: pos2 } = item;
|
|
18902
|
-
const newPos = tr.mapping.map(pos2);
|
|
18903
|
-
tr.setNodeMarkup(newPos, void 0, {});
|
|
18904
|
-
});
|
|
18905
|
-
return true;
|
|
18906
|
-
},
|
|
18907
|
-
/**
|
|
18908
|
-
* Update ordered list style type based on nesting level
|
|
18909
|
-
* @category Command
|
|
18910
|
-
* @example
|
|
18911
|
-
* editor.commands.updateOrderedListStyleType()
|
|
18912
|
-
* @note Cycles through decimal -> lowerAlpha -> lowerRoman based on depth
|
|
18913
|
-
*/
|
|
18914
|
-
updateOrderedListStyleType: () => ({ dispatch, tr }) => {
|
|
18915
|
-
let list = findParentNode((node) => node.type.name === this.name)(tr.selection);
|
|
18916
|
-
if (!list) {
|
|
18917
|
-
return true;
|
|
18918
|
-
}
|
|
18919
|
-
if (dispatch) {
|
|
18920
|
-
let listLevel = (list.depth - 1) / 2;
|
|
18921
|
-
let listStyleTypes = this.options.listStyleTypes;
|
|
18922
|
-
let listStyle = listStyleTypes[listLevel % listStyleTypes.length];
|
|
18923
|
-
let currentListStyle = list.node.attrs["list-style-type"];
|
|
18924
|
-
let nodeAtPos = tr.doc.nodeAt(list.pos);
|
|
18925
|
-
if (currentListStyle !== listStyle && nodeAtPos.eq(list.node)) {
|
|
18926
|
-
tr.setNodeMarkup(list.pos, void 0, {
|
|
18927
|
-
...list.node.attrs,
|
|
18928
|
-
...{
|
|
18929
|
-
"list-style-type": listStyle
|
|
18930
|
-
}
|
|
18931
|
-
});
|
|
18932
|
-
}
|
|
18933
|
-
}
|
|
18934
|
-
return true;
|
|
18935
|
-
}
|
|
18936
|
-
};
|
|
18937
|
-
},
|
|
18938
|
-
addShortcuts() {
|
|
18939
|
-
return {
|
|
18940
|
-
"Mod-Shift-7": () => {
|
|
18941
|
-
return this.editor.commands.toggleOrderedList();
|
|
18942
|
-
}
|
|
18943
|
-
};
|
|
18944
|
-
},
|
|
18945
|
-
addInputRules() {
|
|
18946
|
-
return [
|
|
18947
|
-
new InputRule({
|
|
18948
|
-
match: inputRegex,
|
|
18949
|
-
handler: ({ state, range }) => {
|
|
18950
|
-
const $pos = state.selection.$from;
|
|
18951
|
-
const listItemType = state.schema.nodes.listItem;
|
|
18952
|
-
for (let depth = $pos.depth; depth >= 0; depth--) {
|
|
18953
|
-
if ($pos.node(depth).type === listItemType) {
|
|
18954
|
-
return null;
|
|
18955
|
-
}
|
|
18956
|
-
}
|
|
18957
|
-
const { tr } = state;
|
|
18958
|
-
tr.delete(range.from, range.to);
|
|
18959
|
-
ListHelpers.createNewList({
|
|
18960
|
-
listType: this.type,
|
|
18961
|
-
tr,
|
|
18962
|
-
editor: this.editor
|
|
18963
|
-
});
|
|
18964
|
-
}
|
|
18965
|
-
})
|
|
18966
|
-
];
|
|
18967
|
-
}
|
|
18968
|
-
});
|
|
18969
|
-
const generateOrderedListIndex = ({ listLevel, lvlText, listNumberingType, customFormat }) => {
|
|
18970
|
-
const handler = listIndexMap[listNumberingType];
|
|
18971
|
-
return handler ? handler(listLevel, lvlText, customFormat) : null;
|
|
18972
|
-
};
|
|
18973
|
-
const handleDecimal = (path, lvlText) => generateNumbering(path, lvlText, String);
|
|
18974
|
-
const handleRoman = (path, lvlText) => generateNumbering(path, lvlText, intToRoman);
|
|
18975
|
-
const handleLowerRoman = (path, lvlText) => handleRoman(path, lvlText).toLowerCase();
|
|
18976
|
-
const handleLowerAlpha = (path, lvlText) => handleAlpha(path, lvlText).toLowerCase();
|
|
18977
|
-
const handleAlpha = (path, lvlText) => generateNumbering(path, lvlText, (p) => intToAlpha(p));
|
|
18978
|
-
const handleOrdinal = (path, lvlText) => generateNumbering(path, lvlText, ordinalFormatter);
|
|
18979
|
-
const handleCustom = (path, lvlText, customFormat) => generateFromCustom(path, lvlText, customFormat);
|
|
18980
|
-
const handleJapaneseCounting = (path, lvlText) => generateNumbering(path, lvlText, intToJapaneseCounting);
|
|
18981
|
-
const listIndexMap = {
|
|
18982
|
-
decimal: handleDecimal,
|
|
18983
|
-
lowerRoman: handleLowerRoman,
|
|
18984
|
-
upperRoman: handleRoman,
|
|
18985
|
-
lowerLetter: handleLowerAlpha,
|
|
18986
|
-
upperLetter: handleAlpha,
|
|
18987
|
-
ordinal: handleOrdinal,
|
|
18988
|
-
custom: handleCustom,
|
|
18989
|
-
japaneseCounting: handleJapaneseCounting
|
|
18990
|
-
};
|
|
18991
|
-
const createNumbering = (values, lvlText) => {
|
|
18992
|
-
return values.reduce((acc, value, index2) => {
|
|
18993
|
-
return value > 9 ? acc.replace(/^0/, "").replace(`%${index2 + 1}`, value) : acc.replace(`%${index2 + 1}`, value);
|
|
18994
|
-
}, lvlText);
|
|
18995
|
-
};
|
|
18996
|
-
const generateNumbering = (path, lvlText, formatter) => {
|
|
18997
|
-
const formattedValues = path.map(formatter);
|
|
18998
|
-
return createNumbering(formattedValues, lvlText);
|
|
18999
|
-
};
|
|
19000
|
-
const ordinalFormatter = (level) => {
|
|
19001
|
-
const suffixes = ["th", "st", "nd", "rd"];
|
|
19002
|
-
const value = level % 100;
|
|
19003
|
-
const suffix = suffixes[(value - 20) % 10] || suffixes[value] || suffixes[0];
|
|
19004
|
-
const p = level + suffix;
|
|
19005
|
-
return p;
|
|
19006
|
-
};
|
|
19007
|
-
const generateFromCustom = (path, lvlText, customFormat) => {
|
|
19008
|
-
if (customFormat !== "001, 002, 003, ...") return generateNumbering(path, lvlText, String);
|
|
19009
|
-
const match = customFormat.match(/(\d+)/);
|
|
19010
|
-
if (!match) throw new Error("Invalid format string: no numeric pattern found");
|
|
19011
|
-
const sample = match[1];
|
|
19012
|
-
const digitCount = sample.length;
|
|
19013
|
-
const index2 = path.pop();
|
|
19014
|
-
return String(index2).padStart(digitCount, "0");
|
|
19015
|
-
};
|
|
19016
|
-
const intToRoman = (num) => {
|
|
19017
|
-
const romanNumeralMap = [
|
|
19018
|
-
{ value: 1e3, numeral: "M" },
|
|
19019
|
-
{ value: 900, numeral: "CM" },
|
|
19020
|
-
{ value: 500, numeral: "D" },
|
|
19021
|
-
{ value: 400, numeral: "CD" },
|
|
19022
|
-
{ value: 100, numeral: "C" },
|
|
19023
|
-
{ value: 90, numeral: "XC" },
|
|
19024
|
-
{ value: 50, numeral: "L" },
|
|
19025
|
-
{ value: 40, numeral: "XL" },
|
|
19026
|
-
{ value: 10, numeral: "X" },
|
|
19027
|
-
{ value: 9, numeral: "IX" },
|
|
19028
|
-
{ value: 5, numeral: "V" },
|
|
19029
|
-
{ value: 4, numeral: "IV" },
|
|
19030
|
-
{ value: 1, numeral: "I" }
|
|
19031
|
-
];
|
|
19032
|
-
let result = "";
|
|
19033
|
-
for (const { value, numeral } of romanNumeralMap) {
|
|
19034
|
-
while (num >= value) {
|
|
19035
|
-
result += numeral;
|
|
19036
|
-
num -= value;
|
|
19037
|
-
}
|
|
19038
|
-
}
|
|
19039
|
-
return result;
|
|
19040
|
-
};
|
|
19041
|
-
const intToAlpha = (num) => {
|
|
19042
|
-
let result = "";
|
|
19043
|
-
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
19044
|
-
while (num > 0) {
|
|
19045
|
-
let index2 = (num - 1) % 26;
|
|
19046
|
-
result = alphabet[index2] + result;
|
|
19047
|
-
num = Math.floor((num - 1) / 26);
|
|
19048
|
-
}
|
|
19049
|
-
return result;
|
|
19050
|
-
};
|
|
19051
|
-
const intToJapaneseCounting = (num) => {
|
|
19052
|
-
const digits = ["", "一", "二", "三", "四", "五", "六", "七", "八", "九"];
|
|
19053
|
-
const units = ["", "十", "百", "千"];
|
|
19054
|
-
if (num === 0) return "零";
|
|
19055
|
-
if (num < 10) return digits[num];
|
|
19056
|
-
let result = "";
|
|
19057
|
-
let tempNum = num;
|
|
19058
|
-
let unitIndex = 0;
|
|
19059
|
-
while (tempNum > 0) {
|
|
19060
|
-
const digit = tempNum % 10;
|
|
19061
|
-
if (digit !== 0) {
|
|
19062
|
-
const digitStr = digit === 1 && unitIndex > 0 ? "" : digits[digit];
|
|
19063
|
-
result = digitStr + (unitIndex > 0 ? units[unitIndex] : "") + result;
|
|
19064
|
-
} else if (result && tempNum > 0) {
|
|
19065
|
-
if (!result.startsWith("零") && tempNum % 100 !== 0) {
|
|
19066
|
-
result = "零" + result;
|
|
19067
|
-
}
|
|
19068
|
-
}
|
|
19069
|
-
tempNum = Math.floor(tempNum / 10);
|
|
19070
|
-
unitIndex++;
|
|
19071
|
-
if (unitIndex > 3) break;
|
|
19072
|
-
}
|
|
19073
|
-
if (num >= 10 && num < 20) {
|
|
19074
|
-
result = result.replace(/^一十/, "十");
|
|
19075
|
-
}
|
|
19076
|
-
return result;
|
|
19077
|
-
};
|
|
19078
17860
|
const isKeyboardInvocation = (event) => {
|
|
19079
17861
|
return event.type === "contextmenu" && typeof event.detail === "number" && event.detail === 0 && (event.button === 0 || event.button === void 0) && event.clientX === 0 && event.clientY === 0;
|
|
19080
17862
|
};
|
|
@@ -19363,20 +18145,50 @@ const getLinkedStyle = (styleId, styles = []) => {
|
|
|
19363
18145
|
return { linkedStyle, basedOnStyle };
|
|
19364
18146
|
};
|
|
19365
18147
|
const getSpacingStyle = (spacing) => {
|
|
19366
|
-
const { lineSpaceBefore, lineSpaceAfter, line, lineRule } = spacing;
|
|
18148
|
+
const { lineSpaceBefore, lineSpaceAfter, line, lineRule, beforeAutoSpacing, afterAutoSpacing } = spacing;
|
|
19367
18149
|
const lineHeightResult = getLineHeightValueString(line, "", lineRule, true);
|
|
19368
18150
|
const lineHeightStyles = typeof lineHeightResult === "object" && lineHeightResult !== null ? lineHeightResult : {};
|
|
18151
|
+
const result = {};
|
|
18152
|
+
if (!beforeAutoSpacing) {
|
|
18153
|
+
result["margin-top"] = lineSpaceBefore + "px";
|
|
18154
|
+
}
|
|
18155
|
+
if (!afterAutoSpacing) {
|
|
18156
|
+
result["margin-bottom"] = lineSpaceAfter + "px";
|
|
18157
|
+
}
|
|
19369
18158
|
return {
|
|
19370
|
-
|
|
19371
|
-
"margin-bottom": lineSpaceAfter + "px",
|
|
18159
|
+
...result,
|
|
19372
18160
|
...lineHeightStyles
|
|
19373
18161
|
};
|
|
19374
18162
|
};
|
|
19375
|
-
const getSpacingStyleString = (spacing) => {
|
|
19376
|
-
|
|
18163
|
+
const getSpacingStyleString = (spacing, marks, isListItem) => {
|
|
18164
|
+
let { before, after, line, lineRule, beforeAutospacing, afterAutospacing } = spacing;
|
|
18165
|
+
line = twipsToLines(line);
|
|
18166
|
+
if (lineRule === "exact" && line) {
|
|
18167
|
+
line = String(line);
|
|
18168
|
+
}
|
|
18169
|
+
const textStyleMark = marks?.find((mark) => mark.type === "textStyle");
|
|
18170
|
+
const fontSize = textStyleMark?.attrs?.fontSize;
|
|
18171
|
+
before = twipsToPixels(before);
|
|
18172
|
+
if (beforeAutospacing) {
|
|
18173
|
+
if (fontSize) {
|
|
18174
|
+
before += halfPointToPixels(parseInt(fontSize) * 0.5);
|
|
18175
|
+
}
|
|
18176
|
+
if (isListItem) {
|
|
18177
|
+
before = 0;
|
|
18178
|
+
}
|
|
18179
|
+
}
|
|
18180
|
+
after = twipsToPixels(after);
|
|
18181
|
+
if (afterAutospacing) {
|
|
18182
|
+
if (fontSize) {
|
|
18183
|
+
after += halfPointToPixels(parseInt(fontSize) * 0.5);
|
|
18184
|
+
}
|
|
18185
|
+
if (isListItem) {
|
|
18186
|
+
after = 0;
|
|
18187
|
+
}
|
|
18188
|
+
}
|
|
19377
18189
|
return `
|
|
19378
|
-
${
|
|
19379
|
-
${
|
|
18190
|
+
${before ? `margin-top: ${before}px;` : ""}
|
|
18191
|
+
${after ? `margin-bottom: ${after}px;` : ""}
|
|
19380
18192
|
${line ? getLineHeightValueString(line, "") : ""}
|
|
19381
18193
|
`.trim();
|
|
19382
18194
|
};
|
|
@@ -19874,850 +18686,1047 @@ const LinkedStyles = Extension.create({
|
|
|
19874
18686
|
};
|
|
19875
18687
|
}
|
|
19876
18688
|
});
|
|
19877
|
-
|
|
19878
|
-
|
|
19879
|
-
|
|
19880
|
-
|
|
19881
|
-
|
|
19882
|
-
|
|
19883
|
-
|
|
19884
|
-
|
|
19885
|
-
|
|
19886
|
-
|
|
19887
|
-
|
|
19888
|
-
|
|
19889
|
-
|
|
19890
|
-
|
|
19891
|
-
|
|
19892
|
-
|
|
19893
|
-
|
|
19894
|
-
|
|
19895
|
-
|
|
19896
|
-
break;
|
|
19897
|
-
case "thick":
|
|
19898
|
-
add("text-decoration-thickness", THICK);
|
|
19899
|
-
break;
|
|
19900
|
-
case "dotted":
|
|
19901
|
-
add("text-decoration-style", "dotted");
|
|
19902
|
-
break;
|
|
19903
|
-
case "dash":
|
|
19904
|
-
case "dashed":
|
|
19905
|
-
add("text-decoration-style", "dashed");
|
|
19906
|
-
break;
|
|
19907
|
-
case "dotdash":
|
|
19908
|
-
case "dotdotdash":
|
|
19909
|
-
case "dashlong":
|
|
19910
|
-
case "dashlongheavy":
|
|
19911
|
-
if (approximate) {
|
|
19912
|
-
add("text-decoration-style", "dashed");
|
|
19913
|
-
if (lower.includes("heavy")) add("text-decoration-thickness", HEAVY);
|
|
18689
|
+
const getDefaultSpacing = () => ({
|
|
18690
|
+
after: null,
|
|
18691
|
+
before: null,
|
|
18692
|
+
line: null,
|
|
18693
|
+
lineRule: "auto"
|
|
18694
|
+
});
|
|
18695
|
+
const restartNumbering = ({ editor, tr, state, dispatch }) => {
|
|
18696
|
+
const { node: paragraph, pos } = findParentNode(isList)(state.selection) || {};
|
|
18697
|
+
if (!paragraph) return false;
|
|
18698
|
+
const allParagraphs = [{ node: paragraph, pos }];
|
|
18699
|
+
const startPos = pos + paragraph.nodeSize;
|
|
18700
|
+
const myNumId = paragraph.attrs.numberingProperties.numId;
|
|
18701
|
+
let stop = false;
|
|
18702
|
+
state.doc.nodesBetween(startPos, state.doc.content.size, (node, nodePos) => {
|
|
18703
|
+
if (node.type.name === "paragraph") {
|
|
18704
|
+
if (isList(node) && node.attrs.paragraphProperties?.numberingProperties?.numId === myNumId) {
|
|
18705
|
+
allParagraphs.push({ node, pos: nodePos });
|
|
18706
|
+
} else {
|
|
18707
|
+
stop = true;
|
|
19914
18708
|
}
|
|
19915
|
-
|
|
19916
|
-
|
|
19917
|
-
|
|
19918
|
-
|
|
19919
|
-
|
|
19920
|
-
|
|
19921
|
-
|
|
19922
|
-
|
|
19923
|
-
|
|
19924
|
-
|
|
19925
|
-
|
|
19926
|
-
|
|
19927
|
-
|
|
19928
|
-
|
|
19929
|
-
|
|
19930
|
-
|
|
19931
|
-
|
|
19932
|
-
|
|
19933
|
-
|
|
19934
|
-
|
|
18709
|
+
return false;
|
|
18710
|
+
}
|
|
18711
|
+
return !stop;
|
|
18712
|
+
});
|
|
18713
|
+
const { numberingType } = paragraph.attrs.listRendering || {};
|
|
18714
|
+
const listType = numberingType === "bullet" ? "bulletList" : "orderedList";
|
|
18715
|
+
const numId = ListHelpers.getNewListId(editor);
|
|
18716
|
+
ListHelpers.generateNewListDefinition({ numId: Number(numId), listType, editor });
|
|
18717
|
+
allParagraphs.forEach(({ node, pos: pos2 }) => {
|
|
18718
|
+
updateNumberingProperties(
|
|
18719
|
+
{
|
|
18720
|
+
...node.attrs.numberingProperties,
|
|
18721
|
+
numId: Number(numId)
|
|
18722
|
+
},
|
|
18723
|
+
node,
|
|
18724
|
+
pos2,
|
|
18725
|
+
editor,
|
|
18726
|
+
tr
|
|
18727
|
+
);
|
|
18728
|
+
});
|
|
18729
|
+
if (dispatch) dispatch(tr);
|
|
18730
|
+
return true;
|
|
18731
|
+
};
|
|
18732
|
+
const defaultTabDistance = 48;
|
|
18733
|
+
const defaultLineLength = 816;
|
|
18734
|
+
const getTabDecorations = (doc2, view, helpers2, from2 = 0, to = null) => {
|
|
18735
|
+
const decorations = [];
|
|
18736
|
+
const paragraphCache = /* @__PURE__ */ new Map();
|
|
18737
|
+
const coordCache = /* @__PURE__ */ new Map();
|
|
18738
|
+
const domPosCache = /* @__PURE__ */ new Map();
|
|
18739
|
+
const end2 = to ?? doc2.content.size;
|
|
18740
|
+
doc2.nodesBetween(from2, end2, (node, pos) => {
|
|
18741
|
+
if (node.type.name !== "tab") return;
|
|
18742
|
+
const $pos = doc2.resolve(pos);
|
|
18743
|
+
const paragraphContext = findParagraphContext($pos, paragraphCache, helpers2);
|
|
18744
|
+
if (!paragraphContext) return;
|
|
18745
|
+
const blockParent2 = $pos.node(paragraphContext.paragraphDepth);
|
|
18746
|
+
const style = calculateTabStyle(node.nodeSize, view, pos, blockParent2, paragraphContext, coordCache, domPosCache);
|
|
18747
|
+
if (style) {
|
|
18748
|
+
decorations.push(
|
|
18749
|
+
Decoration.node(pos, pos + node.nodeSize, {
|
|
18750
|
+
style
|
|
18751
|
+
})
|
|
18752
|
+
);
|
|
18753
|
+
}
|
|
18754
|
+
});
|
|
18755
|
+
return decorations;
|
|
18756
|
+
};
|
|
18757
|
+
function calculateTabStyle(nodeSize2, view, pos, blockParent2, paragraphContext, coordCache = null, domPosCache = null) {
|
|
18758
|
+
let extraStyles = "";
|
|
18759
|
+
try {
|
|
18760
|
+
const { tabStops, flattened, positionMap, startPos } = paragraphContext;
|
|
18761
|
+
if (paragraphContext.indentWidth === void 0) {
|
|
18762
|
+
paragraphContext.indentWidth = getIndentWidth(view, startPos, paragraphContext.indent, coordCache, domPosCache);
|
|
18763
|
+
}
|
|
18764
|
+
if (paragraphContext.tabHeight === void 0) {
|
|
18765
|
+
paragraphContext.tabHeight = calcTabHeight(blockParent2);
|
|
18766
|
+
}
|
|
18767
|
+
const indentWidth = paragraphContext.indentWidth;
|
|
18768
|
+
const hanging = twipsToPixels(Number(paragraphContext.indent.hanging) || 0);
|
|
18769
|
+
if (hanging > 0) {
|
|
18770
|
+
tabStops.unshift({ val: "start", pos: indentWidth + hanging });
|
|
18771
|
+
}
|
|
18772
|
+
const accumulatedTabWidth = paragraphContext.accumulatedTabWidth || 0;
|
|
18773
|
+
const currentWidth = indentWidth + measureRangeWidth(view, startPos + 1, pos, coordCache, domPosCache) + accumulatedTabWidth;
|
|
18774
|
+
let tabWidth;
|
|
18775
|
+
if (tabStops.length) {
|
|
18776
|
+
const tabStop = tabStops.find((stop) => stop.pos > currentWidth && stop.val !== "clear");
|
|
18777
|
+
if (tabStop) {
|
|
18778
|
+
tabWidth = tabStop.pos - currentWidth;
|
|
18779
|
+
let val = tabStop.val;
|
|
18780
|
+
const aliases = { left: "start", right: "end" };
|
|
18781
|
+
if (aliases[val]) val = aliases[val];
|
|
18782
|
+
if (val === "center" || val === "end" || val === "right") {
|
|
18783
|
+
const entryIndex = positionMap.get(pos);
|
|
18784
|
+
if (entryIndex === void 0) return;
|
|
18785
|
+
const nextTabIndex = findNextTabIndex(flattened, entryIndex + 1);
|
|
18786
|
+
const segmentStartPos = pos + nodeSize2;
|
|
18787
|
+
const segmentEndPos = nextTabIndex === -1 ? startPos + paragraphContext.paragraph.nodeSize - 1 : flattened[nextTabIndex].pos;
|
|
18788
|
+
const segmentWidth = measureRangeWidth(view, segmentStartPos, segmentEndPos, coordCache, domPosCache);
|
|
18789
|
+
tabWidth -= val === "center" ? segmentWidth / 2 : segmentWidth;
|
|
18790
|
+
} else if (val === "decimal" || val === "num") {
|
|
18791
|
+
const entryIndex = positionMap.get(pos);
|
|
18792
|
+
if (entryIndex === void 0) return;
|
|
18793
|
+
const breakChar = tabStop.decimalChar || ".";
|
|
18794
|
+
const decimalPos = findDecimalBreakPos(flattened, entryIndex + 1, breakChar);
|
|
18795
|
+
const integralWidth = decimalPos ? measureRangeWidth(view, pos + nodeSize2, decimalPos, coordCache, domPosCache) : measureRangeWidth(
|
|
18796
|
+
view,
|
|
18797
|
+
pos + nodeSize2,
|
|
18798
|
+
startPos + paragraphContext.paragraph.nodeSize - 1,
|
|
18799
|
+
coordCache,
|
|
18800
|
+
domPosCache
|
|
18801
|
+
);
|
|
18802
|
+
tabWidth -= integralWidth;
|
|
18803
|
+
}
|
|
18804
|
+
if (tabStop.leader) {
|
|
18805
|
+
const leaderStyles = {
|
|
18806
|
+
dot: "border-bottom: 1px dotted black;",
|
|
18807
|
+
heavy: "border-bottom: 2px solid black;",
|
|
18808
|
+
hyphen: "border-bottom: 1px solid black;",
|
|
18809
|
+
middleDot: "border-bottom: 1px dotted black; margin-bottom: 2px;",
|
|
18810
|
+
underscore: "border-bottom: 1px solid black;"
|
|
18811
|
+
};
|
|
18812
|
+
extraStyles += leaderStyles[tabStop.leader] || "";
|
|
18813
|
+
}
|
|
19935
18814
|
}
|
|
19936
|
-
|
|
18815
|
+
}
|
|
18816
|
+
if (!tabWidth || tabWidth < 1) {
|
|
18817
|
+
tabWidth = defaultTabDistance - currentWidth % defaultLineLength % defaultTabDistance;
|
|
18818
|
+
if (tabWidth === 0) tabWidth = defaultTabDistance;
|
|
18819
|
+
}
|
|
18820
|
+
const tabHeight = paragraphContext.tabHeight;
|
|
18821
|
+
paragraphContext.accumulatedTabWidth = accumulatedTabWidth + tabWidth;
|
|
18822
|
+
return `width: ${tabWidth}px; height: ${tabHeight}; ${extraStyles}`;
|
|
18823
|
+
} catch (error) {
|
|
18824
|
+
console.error("tab decoration error", error);
|
|
19937
18825
|
}
|
|
19938
|
-
if (color) add("text-decoration-color", color);
|
|
19939
|
-
return parts.join("; ");
|
|
19940
18826
|
}
|
|
19941
|
-
function
|
|
19942
|
-
|
|
19943
|
-
|
|
19944
|
-
|
|
19945
|
-
|
|
19946
|
-
|
|
19947
|
-
|
|
19948
|
-
|
|
19949
|
-
|
|
18827
|
+
function findParagraphContext($pos, cache, helpers2) {
|
|
18828
|
+
for (let depth = $pos.depth; depth >= 0; depth--) {
|
|
18829
|
+
const node = $pos.node(depth);
|
|
18830
|
+
if (node?.type?.name === "paragraph") {
|
|
18831
|
+
const startPos = $pos.start(depth);
|
|
18832
|
+
if (!cache.has(startPos)) {
|
|
18833
|
+
const paragraphContext = extractParagraphContext(node, startPos, helpers2, depth);
|
|
18834
|
+
cache.set(startPos, paragraphContext);
|
|
18835
|
+
}
|
|
18836
|
+
return cache.get(startPos);
|
|
18837
|
+
}
|
|
19950
18838
|
}
|
|
19951
|
-
|
|
18839
|
+
return null;
|
|
18840
|
+
}
|
|
18841
|
+
function extractParagraphContext(node, startPos, helpers2, depth = 0) {
|
|
18842
|
+
let tabStops = [];
|
|
18843
|
+
if (Array.isArray(node.attrs?.tabStops)) {
|
|
18844
|
+
tabStops = node.attrs.tabStops.map((stop) => {
|
|
18845
|
+
const ref2 = stop?.tab;
|
|
18846
|
+
if (!ref2) return stop || null;
|
|
18847
|
+
return {
|
|
18848
|
+
val: ref2.tabType || "start",
|
|
18849
|
+
pos: twipsToPixels(Number(ref2.pos) || 0),
|
|
18850
|
+
leader: ref2.leader
|
|
18851
|
+
};
|
|
18852
|
+
}).filter(Boolean);
|
|
18853
|
+
} else {
|
|
18854
|
+
const style = helpers2.linkedStyles.getStyleById(node.attrs?.styleId);
|
|
18855
|
+
if (Array.isArray(style?.definition?.styles?.tabStops)) {
|
|
18856
|
+
tabStops = style.definition.styles.tabStops;
|
|
18857
|
+
}
|
|
18858
|
+
}
|
|
18859
|
+
const { entries, positionMap } = flattenParagraph(node, startPos);
|
|
18860
|
+
return {
|
|
18861
|
+
paragraph: node,
|
|
18862
|
+
paragraphDepth: depth,
|
|
18863
|
+
startPos,
|
|
18864
|
+
indent: node.attrs?.indent || {},
|
|
18865
|
+
tabStops,
|
|
18866
|
+
flattened: entries,
|
|
18867
|
+
positionMap,
|
|
18868
|
+
// Store position map for O(1) lookups
|
|
18869
|
+
accumulatedTabWidth: 0
|
|
18870
|
+
};
|
|
18871
|
+
}
|
|
18872
|
+
function flattenParagraph(paragraph, paragraphStartPos) {
|
|
18873
|
+
const entries = [];
|
|
18874
|
+
const positionMap = /* @__PURE__ */ new Map();
|
|
18875
|
+
const walk = (node, basePos) => {
|
|
19952
18876
|
if (!node) return;
|
|
19953
|
-
|
|
19954
|
-
|
|
19955
|
-
|
|
19956
|
-
|
|
19957
|
-
seenMarks.add(mark);
|
|
19958
|
-
textStyleMarks.push(mark);
|
|
19959
|
-
}
|
|
18877
|
+
if (node.type?.name === "run") {
|
|
18878
|
+
node.forEach((child, offset2) => {
|
|
18879
|
+
const childPos = basePos + offset2 + 1;
|
|
18880
|
+
walk(child, childPos);
|
|
19960
18881
|
});
|
|
18882
|
+
return;
|
|
19961
18883
|
}
|
|
19962
|
-
|
|
19963
|
-
|
|
19964
|
-
}
|
|
18884
|
+
const pos = basePos - 1;
|
|
18885
|
+
const index2 = entries.length;
|
|
18886
|
+
entries.push({ node, pos });
|
|
18887
|
+
positionMap.set(pos, index2);
|
|
19965
18888
|
};
|
|
19966
|
-
|
|
19967
|
-
|
|
19968
|
-
|
|
19969
|
-
attrs.lineHeight = childNode.attrs.lineHeight;
|
|
19970
|
-
}
|
|
19971
|
-
collectMarks(childNode);
|
|
18889
|
+
paragraph.forEach((child, offset2) => {
|
|
18890
|
+
const childPos = paragraphStartPos + offset2 + 1;
|
|
18891
|
+
walk(child, childPos);
|
|
19972
18892
|
});
|
|
19973
|
-
return {
|
|
19974
|
-
marks: textStyleMarks,
|
|
19975
|
-
attrs
|
|
19976
|
-
};
|
|
19977
|
-
}
|
|
19978
|
-
function parseSizeFromRunProperties(listRunProperties) {
|
|
19979
|
-
const val = listRunProperties?.["w:val"] || listRunProperties?.["w:sz"];
|
|
19980
|
-
if (val == null) return null;
|
|
19981
|
-
const numeric = Number(val);
|
|
19982
|
-
if (Number.isNaN(numeric) || numeric <= 0) return null;
|
|
19983
|
-
const sizeInPoints = numeric / 2;
|
|
19984
|
-
return `${sizeInPoints}pt`;
|
|
19985
|
-
}
|
|
19986
|
-
function parseFontFamilyFromRunProperties(listRunProperties) {
|
|
19987
|
-
const ascii = listRunProperties?.["w:ascii"];
|
|
19988
|
-
const hAnsi = listRunProperties?.["w:hAnsi"];
|
|
19989
|
-
const eastAsia = listRunProperties?.["w:eastAsia"];
|
|
19990
|
-
return ascii || hAnsi || eastAsia || null;
|
|
19991
|
-
}
|
|
19992
|
-
const computedStylesCache = /* @__PURE__ */ new WeakMap();
|
|
19993
|
-
function clearComputedStyleCache(domNode) {
|
|
19994
|
-
if (domNode) {
|
|
19995
|
-
computedStylesCache.delete(domNode);
|
|
19996
|
-
}
|
|
18893
|
+
return { entries, positionMap };
|
|
19997
18894
|
}
|
|
19998
|
-
function
|
|
19999
|
-
|
|
20000
|
-
|
|
20001
|
-
|
|
20002
|
-
|
|
20003
|
-
fontFamily: view.dom.style?.fontFamily || null,
|
|
20004
|
-
lineHeight: view.dom.style?.lineHeight || null
|
|
20005
|
-
};
|
|
20006
|
-
if (inline.fontSize && inline.fontFamily && inline.lineHeight) return inline;
|
|
20007
|
-
if (computedStylesCache.has(view.dom)) {
|
|
20008
|
-
const cached = computedStylesCache.get(view.dom);
|
|
20009
|
-
return {
|
|
20010
|
-
fontSize: inline.fontSize || cached.fontSize,
|
|
20011
|
-
fontFamily: inline.fontFamily || cached.fontFamily,
|
|
20012
|
-
lineHeight: inline.lineHeight || cached.lineHeight
|
|
20013
|
-
};
|
|
20014
|
-
}
|
|
20015
|
-
const globalWindow = typeof window !== "undefined" ? window : void 0;
|
|
20016
|
-
if (globalWindow?.getComputedStyle) {
|
|
20017
|
-
const computed2 = globalWindow.getComputedStyle(view.dom);
|
|
20018
|
-
const computedStyles = {
|
|
20019
|
-
fontSize: computed2.fontSize,
|
|
20020
|
-
fontFamily: computed2.fontFamily,
|
|
20021
|
-
lineHeight: computed2.lineHeight
|
|
20022
|
-
};
|
|
20023
|
-
computedStylesCache.set(view.dom, computedStyles);
|
|
20024
|
-
return {
|
|
20025
|
-
fontSize: inline.fontSize || computedStyles.fontSize,
|
|
20026
|
-
fontFamily: inline.fontFamily || computedStyles.fontFamily,
|
|
20027
|
-
lineHeight: inline.lineHeight || computedStyles.lineHeight
|
|
20028
|
-
};
|
|
18895
|
+
function findNextTabIndex(flattened, fromIndex) {
|
|
18896
|
+
for (let i = fromIndex; i < flattened.length; i++) {
|
|
18897
|
+
if (flattened[i]?.node?.type?.name === "tab") {
|
|
18898
|
+
return i;
|
|
18899
|
+
}
|
|
20029
18900
|
}
|
|
20030
|
-
return
|
|
18901
|
+
return -1;
|
|
20031
18902
|
}
|
|
20032
|
-
function
|
|
20033
|
-
|
|
20034
|
-
|
|
20035
|
-
|
|
20036
|
-
if (
|
|
20037
|
-
|
|
20038
|
-
|
|
20039
|
-
if (
|
|
20040
|
-
|
|
20041
|
-
} else if (typeof view.getPos === "function") {
|
|
20042
|
-
viewPos = view.getPos();
|
|
18903
|
+
function findDecimalBreakPos(flattened, startIndex, breakChar) {
|
|
18904
|
+
for (let i = startIndex; i < flattened.length; i++) {
|
|
18905
|
+
const entry = flattened[i];
|
|
18906
|
+
if (!entry) break;
|
|
18907
|
+
if (entry.node.type?.name === "tab") break;
|
|
18908
|
+
if (entry.node.type?.name === "text") {
|
|
18909
|
+
const index2 = entry.node.text?.indexOf(breakChar);
|
|
18910
|
+
if (index2 !== void 0 && index2 !== -1) {
|
|
18911
|
+
return entry.pos + index2 + 1;
|
|
20043
18912
|
}
|
|
20044
|
-
} catch {
|
|
20045
|
-
return;
|
|
20046
|
-
}
|
|
20047
|
-
if (typeof viewPos !== "number") return;
|
|
20048
|
-
if (viewPos < pos) {
|
|
20049
|
-
if (!candidate || viewPos > candidate.pos) candidate = { view, pos: viewPos };
|
|
20050
|
-
}
|
|
20051
|
-
});
|
|
20052
|
-
return candidate?.view ?? null;
|
|
20053
|
-
}
|
|
20054
|
-
function findSiblingListItem({ editor, pos, direction }) {
|
|
20055
|
-
if (typeof pos !== "number" || !editor?.view) return null;
|
|
20056
|
-
const { state } = editor.view;
|
|
20057
|
-
const $pos = state.doc.resolve(pos);
|
|
20058
|
-
const parentDepth = $pos.depth - 1;
|
|
20059
|
-
if (parentDepth < 0) return null;
|
|
20060
|
-
const parent = $pos.node(parentDepth);
|
|
20061
|
-
if (!parent) return null;
|
|
20062
|
-
const indexInsideParent = $pos.index(parentDepth);
|
|
20063
|
-
const siblingIndex = indexInsideParent + direction;
|
|
20064
|
-
if (siblingIndex < 0 || siblingIndex >= parent.childCount) return null;
|
|
20065
|
-
const sibling = parent.child(siblingIndex);
|
|
20066
|
-
return sibling?.type?.name === "listItem" ? sibling : null;
|
|
20067
|
-
}
|
|
20068
|
-
function deriveFontStylesFromNode({ node, textStyleType, defaultFont, defaultSize, listRunProperties }) {
|
|
20069
|
-
const { marks: allMarks, attrs } = collectTextStyleMarks(node, textStyleType);
|
|
20070
|
-
const styleMarks = textStyleType ? allMarks.filter((m) => m.type === textStyleType) : [];
|
|
20071
|
-
const sizeMark = styleMarks.find((m) => m.attrs?.fontSize);
|
|
20072
|
-
const familyMark = styleMarks.find((m) => m.attrs?.fontFamily);
|
|
20073
|
-
let fontSize = defaultSize;
|
|
20074
|
-
if (sizeMark) {
|
|
20075
|
-
const [value, unit = "pt"] = parseSizeUnit(sizeMark.attrs.fontSize);
|
|
20076
|
-
if (!Number.isNaN(value)) {
|
|
20077
|
-
fontSize = `${value}${unit}`;
|
|
20078
|
-
}
|
|
20079
|
-
}
|
|
20080
|
-
let hasSize = Boolean(sizeMark);
|
|
20081
|
-
if (!hasSize && listRunProperties) {
|
|
20082
|
-
const sizeFromList = parseSizeFromRunProperties(listRunProperties);
|
|
20083
|
-
if (sizeFromList) {
|
|
20084
|
-
fontSize = sizeFromList;
|
|
20085
|
-
hasSize = true;
|
|
20086
|
-
}
|
|
20087
|
-
}
|
|
20088
|
-
let fontFamily = familyMark?.attrs?.fontFamily ?? defaultFont;
|
|
20089
|
-
let hasFamily = Boolean(familyMark);
|
|
20090
|
-
if (!hasFamily && listRunProperties) {
|
|
20091
|
-
const fontFromList = parseFontFamilyFromRunProperties(listRunProperties);
|
|
20092
|
-
if (fontFromList) {
|
|
20093
|
-
fontFamily = fontFromList;
|
|
20094
|
-
hasFamily = true;
|
|
20095
|
-
}
|
|
20096
|
-
}
|
|
20097
|
-
let lineHeight = attrs.lineHeight;
|
|
20098
|
-
const firstChild = node.firstChild;
|
|
20099
|
-
const hasOnlyOnePar = node.childCount === 1 && firstChild?.type?.name === "paragraph";
|
|
20100
|
-
if (hasOnlyOnePar) {
|
|
20101
|
-
const par = firstChild;
|
|
20102
|
-
const parFirstChild = par?.firstChild;
|
|
20103
|
-
if (par?.childCount === 1 && parFirstChild?.type?.name === "fieldAnnotation") {
|
|
20104
|
-
const aFontSize = parFirstChild.attrs?.fontSize;
|
|
20105
|
-
const aFontFamily = parFirstChild.attrs?.fontFamily;
|
|
20106
|
-
if (!sizeMark && aFontSize) fontSize = aFontSize;
|
|
20107
|
-
if (!familyMark && aFontFamily) fontFamily = aFontFamily;
|
|
20108
18913
|
}
|
|
20109
18914
|
}
|
|
20110
|
-
return
|
|
20111
|
-
fontSize,
|
|
20112
|
-
fontFamily,
|
|
20113
|
-
lineHeight,
|
|
20114
|
-
hasSize,
|
|
20115
|
-
hasFamily
|
|
20116
|
-
};
|
|
18915
|
+
return null;
|
|
20117
18916
|
}
|
|
20118
|
-
function
|
|
20119
|
-
|
|
20120
|
-
|
|
20121
|
-
|
|
20122
|
-
|
|
20123
|
-
|
|
20124
|
-
(
|
|
20125
|
-
(
|
|
20126
|
-
|
|
20127
|
-
|
|
20128
|
-
|
|
20129
|
-
|
|
20130
|
-
|
|
20131
|
-
|
|
20132
|
-
|
|
20133
|
-
|
|
18917
|
+
function measureRangeWidth(view, from2, to, coordCache = null, domPosCache = null) {
|
|
18918
|
+
if (!Number.isFinite(from2) || !Number.isFinite(to) || to <= from2) return 0;
|
|
18919
|
+
try {
|
|
18920
|
+
const range = document.createRange();
|
|
18921
|
+
const fromRef = getCachedDomAtPos(view, from2, domPosCache);
|
|
18922
|
+
const toRef = getCachedDomAtPos(view, to, domPosCache);
|
|
18923
|
+
range.setStart(fromRef.node, fromRef.offset);
|
|
18924
|
+
range.setEnd(toRef.node, toRef.offset);
|
|
18925
|
+
const rect = range.getBoundingClientRect();
|
|
18926
|
+
range.detach?.();
|
|
18927
|
+
return rect.width || 0;
|
|
18928
|
+
} catch {
|
|
18929
|
+
const startLeft = getLeftCoord(view, from2, coordCache, domPosCache);
|
|
18930
|
+
const endLeft = getLeftCoord(view, to, coordCache, domPosCache);
|
|
18931
|
+
if (startLeft == null || endLeft == null) return 0;
|
|
18932
|
+
return Math.max(0, endLeft - startLeft);
|
|
20134
18933
|
}
|
|
20135
|
-
const style = styleDeco?.type?.attrs?.style;
|
|
20136
|
-
const stylesArray = style?.split(";") || [];
|
|
20137
|
-
const fontSizeFromStyles = stylesArray.find((s2) => s2.includes("font-size"))?.split(":")[1]?.trim();
|
|
20138
|
-
const fontFamilyFromStyles = stylesArray.find((s2) => s2.includes("font-family"))?.split(":")[1]?.trim();
|
|
20139
|
-
return {
|
|
20140
|
-
font: fontFamilyFromStyles,
|
|
20141
|
-
size: fontSizeFromStyles
|
|
20142
|
-
};
|
|
20143
18934
|
}
|
|
20144
|
-
function
|
|
20145
|
-
const
|
|
20146
|
-
const
|
|
20147
|
-
|
|
20148
|
-
|
|
20149
|
-
|
|
20150
|
-
|
|
20151
|
-
defaultSize: defaults.size,
|
|
20152
|
-
listRunProperties: node.attrs?.listRunProperties
|
|
20153
|
-
});
|
|
20154
|
-
if ((!currentStyles.hasSize || !currentStyles.hasFamily || !currentStyles.lineHeight) && editor?.view) {
|
|
20155
|
-
const previousListItem = findSiblingListItem({ editor, pos, direction: -1 });
|
|
20156
|
-
if (previousListItem) {
|
|
20157
|
-
const previousStyles = deriveFontStylesFromNode({
|
|
20158
|
-
node: previousListItem,
|
|
20159
|
-
textStyleType,
|
|
20160
|
-
defaultFont: defaults.font,
|
|
20161
|
-
defaultSize: defaults.size,
|
|
20162
|
-
listRunProperties: previousListItem.attrs?.listRunProperties
|
|
20163
|
-
});
|
|
20164
|
-
if (!currentStyles.hasSize && previousStyles.fontSize) currentStyles.fontSize = previousStyles.fontSize;
|
|
20165
|
-
if (!currentStyles.hasFamily && previousStyles.fontFamily) currentStyles.fontFamily = previousStyles.fontFamily;
|
|
20166
|
-
if (!currentStyles.lineHeight && previousStyles.lineHeight) currentStyles.lineHeight = previousStyles.lineHeight;
|
|
18935
|
+
function getIndentWidth(view, paragraphStartPos, indentAttrs = {}, coordCache = null, domPosCache = null) {
|
|
18936
|
+
const marginLeft = getLeftCoord(view, paragraphStartPos, coordCache, domPosCache);
|
|
18937
|
+
const lineLeft = getLeftCoord(view, paragraphStartPos + 1, coordCache, domPosCache);
|
|
18938
|
+
if (marginLeft != null && lineLeft != null) {
|
|
18939
|
+
const diff = lineLeft - marginLeft;
|
|
18940
|
+
if (!Number.isNaN(diff) && Math.abs(diff) > 0.5) {
|
|
18941
|
+
return diff;
|
|
20167
18942
|
}
|
|
20168
18943
|
}
|
|
20169
|
-
|
|
20170
|
-
|
|
20171
|
-
|
|
20172
|
-
|
|
20173
|
-
|
|
20174
|
-
|
|
20175
|
-
|
|
20176
|
-
|
|
20177
|
-
|
|
20178
|
-
|
|
20179
|
-
|
|
20180
|
-
|
|
20181
|
-
|
|
20182
|
-
|
|
20183
|
-
if (!currentStyles.fontFamily && prevFamily) currentStyles.fontFamily = prevFamily;
|
|
20184
|
-
if (!currentStyles.lineHeight && prevLineHeight) currentStyles.lineHeight = prevLineHeight;
|
|
20185
|
-
}
|
|
18944
|
+
return calculateIndentFallback(indentAttrs);
|
|
18945
|
+
}
|
|
18946
|
+
function calculateIndentFallback(indentAttrs = {}) {
|
|
18947
|
+
if (!indentAttrs) return 0;
|
|
18948
|
+
const left2 = twipsToPixels(Number(indentAttrs.left) || 0);
|
|
18949
|
+
const firstLine = twipsToPixels(Number(indentAttrs.firstLine) || 0);
|
|
18950
|
+
const hanging = twipsToPixels(Number(indentAttrs.hanging) || 0);
|
|
18951
|
+
let textIndent = 0;
|
|
18952
|
+
if (firstLine && hanging) {
|
|
18953
|
+
textIndent = firstLine - hanging;
|
|
18954
|
+
} else if (firstLine) {
|
|
18955
|
+
textIndent = firstLine;
|
|
18956
|
+
} else if (hanging) {
|
|
18957
|
+
textIndent = -hanging;
|
|
20186
18958
|
}
|
|
20187
|
-
return
|
|
20188
|
-
|
|
20189
|
-
|
|
20190
|
-
lineHeight: currentStyles.lineHeight
|
|
20191
|
-
};
|
|
18959
|
+
if (textIndent) return left2 + textIndent;
|
|
18960
|
+
if (left2) return left2;
|
|
18961
|
+
return 0;
|
|
20192
18962
|
}
|
|
20193
|
-
|
|
20194
|
-
|
|
20195
|
-
|
|
20196
|
-
|
|
20197
|
-
|
|
20198
|
-
|
|
20199
|
-
|
|
20200
|
-
|
|
20201
|
-
|
|
20202
|
-
__privateAdd(this, _ListItemNodeView_instances);
|
|
20203
|
-
__publicField(this, "handleNumberingClick", () => {
|
|
20204
|
-
});
|
|
20205
|
-
this.node = node;
|
|
20206
|
-
this.editor = editor;
|
|
20207
|
-
this.decorations = decorations;
|
|
20208
|
-
this.view = editor.view;
|
|
20209
|
-
this._rawGetPos = getPos;
|
|
20210
|
-
this._pendingIndentRefresh = null;
|
|
20211
|
-
this.getPos = () => this.getResolvedPos();
|
|
20212
|
-
__privateMethod(this, _ListItemNodeView_instances, init_fn3).call(this);
|
|
20213
|
-
activeListItemNodeViews.add(this);
|
|
20214
|
-
}
|
|
20215
|
-
getResolvedPos() {
|
|
20216
|
-
if (typeof this._rawGetPos !== "function") return null;
|
|
18963
|
+
function getLeftCoord(view, pos, coordCache = null, domPosCache = null) {
|
|
18964
|
+
if (!Number.isFinite(pos)) return null;
|
|
18965
|
+
if (coordCache && coordCache.has(pos)) {
|
|
18966
|
+
return coordCache.get(pos);
|
|
18967
|
+
}
|
|
18968
|
+
let result = null;
|
|
18969
|
+
try {
|
|
18970
|
+
result = view.coordsAtPos(pos).left;
|
|
18971
|
+
} catch {
|
|
20217
18972
|
try {
|
|
20218
|
-
const
|
|
20219
|
-
|
|
18973
|
+
const ref2 = getCachedDomAtPos(view, pos, domPosCache);
|
|
18974
|
+
const range = document.createRange();
|
|
18975
|
+
range.setStart(ref2.node, ref2.offset);
|
|
18976
|
+
range.setEnd(ref2.node, ref2.offset);
|
|
18977
|
+
const rect = range.getBoundingClientRect();
|
|
18978
|
+
range.detach?.();
|
|
18979
|
+
result = rect.left;
|
|
20220
18980
|
} catch {
|
|
20221
|
-
|
|
18981
|
+
result = null;
|
|
20222
18982
|
}
|
|
20223
18983
|
}
|
|
20224
|
-
|
|
18984
|
+
if (coordCache) {
|
|
18985
|
+
coordCache.set(pos, result);
|
|
20225
18986
|
}
|
|
20226
|
-
|
|
20227
|
-
|
|
20228
|
-
|
|
20229
|
-
|
|
20230
|
-
|
|
20231
|
-
|
|
20232
|
-
|
|
18987
|
+
return result;
|
|
18988
|
+
}
|
|
18989
|
+
function getCachedDomAtPos(view, pos, domPosCache = null) {
|
|
18990
|
+
if (domPosCache && domPosCache.has(pos)) {
|
|
18991
|
+
return domPosCache.get(pos);
|
|
18992
|
+
}
|
|
18993
|
+
const result = view.domAtPos(pos);
|
|
18994
|
+
if (domPosCache) {
|
|
18995
|
+
domPosCache.set(pos, result);
|
|
18996
|
+
}
|
|
18997
|
+
return result;
|
|
18998
|
+
}
|
|
18999
|
+
function calcTabHeight(blockParent2) {
|
|
19000
|
+
const ptToPxRatio = 1.333;
|
|
19001
|
+
const defaultFontSize = 16;
|
|
19002
|
+
const defaultLineHeight = 1.1;
|
|
19003
|
+
const parentTextStyleMark = blockParent2.firstChild?.marks?.find((mark) => mark.type.name === "textStyle");
|
|
19004
|
+
const fontSize = parseInt(parentTextStyleMark?.attrs.fontSize) * ptToPxRatio || defaultFontSize;
|
|
19005
|
+
return `${fontSize * defaultLineHeight}px`;
|
|
19006
|
+
}
|
|
19007
|
+
class ParagraphNodeView {
|
|
19008
|
+
/**
|
|
19009
|
+
* @param {import('prosemirror-model').Node} node Current paragraph node.
|
|
19010
|
+
* @param {import('../../core/Editor').Editor} editor Editor instance providing schema/helpers.
|
|
19011
|
+
* @param {() => number} getPos Position getter provided by ProseMirror.
|
|
19012
|
+
* @param {import('prosemirror-view').Decoration[]} decorations Decorations applied to this node.
|
|
19013
|
+
* @param {Record<string, unknown>} extensionAttrs Extra attributes declared by the paragraph extension.
|
|
19014
|
+
*/
|
|
19015
|
+
constructor(node, editor, getPos, decorations, extensionAttrs) {
|
|
19016
|
+
__privateAdd(this, _ParagraphNodeView_instances);
|
|
19017
|
+
this.node = node;
|
|
19018
|
+
this.editor = editor;
|
|
19019
|
+
this.getPos = getPos;
|
|
19020
|
+
this.decorations = decorations;
|
|
19021
|
+
this.extensionAttrs = extensionAttrs;
|
|
19022
|
+
this._animationFrameRequest = null;
|
|
19023
|
+
this.dom = document.createElement("p");
|
|
19024
|
+
this.contentDOM = document.createElement("span");
|
|
19025
|
+
this.dom.appendChild(this.contentDOM);
|
|
19026
|
+
if (__privateMethod(this, _ParagraphNodeView_instances, checkIsList_fn).call(this)) {
|
|
19027
|
+
__privateMethod(this, _ParagraphNodeView_instances, initList_fn).call(this, node.attrs.listRendering);
|
|
19028
|
+
__privateMethod(this, _ParagraphNodeView_instances, scheduleAnimation_fn).call(this, () => {
|
|
19029
|
+
if (!__privateMethod(this, _ParagraphNodeView_instances, checkIsList_fn).call(this)) {
|
|
19030
|
+
return;
|
|
19031
|
+
}
|
|
19032
|
+
__privateMethod(this, _ParagraphNodeView_instances, updateListStyles_fn).call(this);
|
|
19033
|
+
});
|
|
20233
19034
|
}
|
|
20234
|
-
|
|
20235
|
-
this._pendingIndentRefresh = raf(() => {
|
|
20236
|
-
this._pendingIndentRefresh = null;
|
|
20237
|
-
__privateMethod(this, _ListItemNodeView_instances, applyIndentStyling_fn).call(this);
|
|
20238
|
-
});
|
|
19035
|
+
__privateMethod(this, _ParagraphNodeView_instances, updateHTMLAttributes_fn).call(this);
|
|
20239
19036
|
}
|
|
19037
|
+
/**
|
|
19038
|
+
* @param {import('prosemirror-model').Node} node
|
|
19039
|
+
* @param {import('prosemirror-view').Decoration[]} decorations
|
|
19040
|
+
*/
|
|
20240
19041
|
update(node, decorations) {
|
|
20241
|
-
const
|
|
19042
|
+
const oldAttrs = this.node.attrs;
|
|
19043
|
+
const newAttrs = node.attrs;
|
|
20242
19044
|
this.node = node;
|
|
20243
19045
|
this.decorations = decorations;
|
|
20244
|
-
|
|
20245
|
-
|
|
20246
|
-
if (stylingAttrsChanged) {
|
|
20247
|
-
clearComputedStyleCache(this.dom);
|
|
19046
|
+
if (JSON.stringify(oldAttrs) === JSON.stringify(newAttrs)) {
|
|
19047
|
+
return true;
|
|
20248
19048
|
}
|
|
20249
|
-
|
|
20250
|
-
|
|
20251
|
-
|
|
20252
|
-
|
|
20253
|
-
|
|
20254
|
-
|
|
19049
|
+
__privateMethod(this, _ParagraphNodeView_instances, updateHTMLAttributes_fn).call(this);
|
|
19050
|
+
if (!__privateMethod(this, _ParagraphNodeView_instances, checkIsList_fn).call(this)) {
|
|
19051
|
+
__privateMethod(this, _ParagraphNodeView_instances, removeList_fn).call(this);
|
|
19052
|
+
return true;
|
|
19053
|
+
}
|
|
19054
|
+
__privateMethod(this, _ParagraphNodeView_instances, initList_fn).call(this, node.attrs.listRendering);
|
|
19055
|
+
__privateMethod(this, _ParagraphNodeView_instances, scheduleAnimation_fn).call(this, () => {
|
|
19056
|
+
__privateMethod(this, _ParagraphNodeView_instances, initList_fn).call(this, node.attrs.listRendering);
|
|
19057
|
+
__privateMethod(this, _ParagraphNodeView_instances, updateListStyles_fn).call(this);
|
|
20255
19058
|
});
|
|
20256
|
-
|
|
20257
|
-
|
|
20258
|
-
|
|
20259
|
-
|
|
20260
|
-
|
|
20261
|
-
|
|
19059
|
+
return true;
|
|
19060
|
+
}
|
|
19061
|
+
/**
|
|
19062
|
+
* @param {MutationRecord} mutation
|
|
19063
|
+
*/
|
|
19064
|
+
ignoreMutation(mutation) {
|
|
19065
|
+
if (this.marker && (mutation.target === this.marker || this.marker.contains(mutation.target))) {
|
|
19066
|
+
return true;
|
|
19067
|
+
}
|
|
19068
|
+
if (this.separator && (mutation.target === this.separator || this.separator.contains(mutation.target))) {
|
|
19069
|
+
return true;
|
|
20262
19070
|
}
|
|
19071
|
+
if (mutation.type === "attributes" && mutation.target === this.dom && mutation.attributeName === "style") {
|
|
19072
|
+
return true;
|
|
19073
|
+
}
|
|
19074
|
+
return false;
|
|
20263
19075
|
}
|
|
20264
19076
|
destroy() {
|
|
20265
|
-
|
|
20266
|
-
this.numberingDOM.removeEventListener("click", this.handleNumberingClick);
|
|
20267
|
-
clearComputedStyleCache(this.dom);
|
|
20268
|
-
const caf = typeof globalThis !== "undefined" ? globalThis.cancelAnimationFrame : void 0;
|
|
20269
|
-
if (this._pendingIndentRefresh != null && typeof caf === "function") {
|
|
20270
|
-
caf(this._pendingIndentRefresh);
|
|
20271
|
-
}
|
|
20272
|
-
this._pendingIndentRefresh = null;
|
|
19077
|
+
__privateMethod(this, _ParagraphNodeView_instances, cancelScheduledAnimation_fn).call(this);
|
|
20273
19078
|
}
|
|
20274
19079
|
}
|
|
20275
|
-
|
|
20276
|
-
|
|
20277
|
-
const
|
|
20278
|
-
|
|
20279
|
-
|
|
20280
|
-
|
|
20281
|
-
|
|
20282
|
-
|
|
20283
|
-
listLevel,
|
|
20284
|
-
lvlText,
|
|
20285
|
-
listNumberingType,
|
|
20286
|
-
customFormat
|
|
20287
|
-
});
|
|
20288
|
-
} else {
|
|
20289
|
-
orderMarker = docxNumberingHelpers.normalizeLvlTextChar(lvlText);
|
|
19080
|
+
_ParagraphNodeView_instances = new WeakSet();
|
|
19081
|
+
updateHTMLAttributes_fn = function() {
|
|
19082
|
+
const htmlAttributes = Attribute.getAttributesToRender(this.node, this.extensionAttrs);
|
|
19083
|
+
htmlAttributes.style = htmlAttributes.style || "";
|
|
19084
|
+
for (const [key2, value] of Object.entries(htmlAttributes || {})) {
|
|
19085
|
+
if (value == null) {
|
|
19086
|
+
this.dom.removeAttribute(key2);
|
|
19087
|
+
continue;
|
|
20290
19088
|
}
|
|
19089
|
+
this.dom.setAttribute(key2, value);
|
|
20291
19090
|
}
|
|
20292
|
-
|
|
20293
|
-
|
|
20294
|
-
|
|
20295
|
-
|
|
20296
|
-
|
|
20297
|
-
|
|
20298
|
-
|
|
19091
|
+
};
|
|
19092
|
+
updateListStyles_fn = function() {
|
|
19093
|
+
let { suffix, justification } = this.node.attrs.listRendering;
|
|
19094
|
+
suffix = suffix ?? "tab";
|
|
19095
|
+
__privateMethod(this, _ParagraphNodeView_instances, calculateMarkerStyle_fn).call(this, justification);
|
|
19096
|
+
if (suffix === "tab") {
|
|
19097
|
+
__privateMethod(this, _ParagraphNodeView_instances, calculateTabSeparatorStyle_fn).call(this, justification, this.node.attrs.indent);
|
|
19098
|
+
} else {
|
|
19099
|
+
this.separator.textContent = suffix === "space" ? " " : "";
|
|
19100
|
+
}
|
|
19101
|
+
return true;
|
|
19102
|
+
};
|
|
19103
|
+
/**
|
|
19104
|
+
* @param {{ markerText: string, suffix?: string }} listRendering
|
|
19105
|
+
*/
|
|
19106
|
+
initList_fn = function(listRendering) {
|
|
19107
|
+
__privateMethod(this, _ParagraphNodeView_instances, createMarker_fn).call(this, listRendering.markerText);
|
|
19108
|
+
__privateMethod(this, _ParagraphNodeView_instances, createSeparator_fn).call(this, listRendering.suffix);
|
|
19109
|
+
};
|
|
19110
|
+
checkIsList_fn = function() {
|
|
19111
|
+
return isList(this.node);
|
|
19112
|
+
};
|
|
19113
|
+
/**
|
|
19114
|
+
* @param {string} markerText
|
|
19115
|
+
*/
|
|
19116
|
+
createMarker_fn = function(markerText) {
|
|
19117
|
+
if (!this.marker) {
|
|
19118
|
+
this.marker = document.createElement("span");
|
|
19119
|
+
}
|
|
19120
|
+
this.marker.contentEditable = "false";
|
|
19121
|
+
this.marker.className = "list-marker";
|
|
19122
|
+
this.dom.insertBefore(this.marker, this.contentDOM);
|
|
19123
|
+
this.marker.textContent = markerText;
|
|
19124
|
+
};
|
|
19125
|
+
/**
|
|
19126
|
+
* @param {'tab' | 'space' | 'nothing'} [suffix]
|
|
19127
|
+
*/
|
|
19128
|
+
createSeparator_fn = function(suffix) {
|
|
19129
|
+
if (suffix === "tab" || suffix == null) {
|
|
19130
|
+
if (this.separator == null || this.separator.tagName?.toLowerCase() !== "span") {
|
|
19131
|
+
this.separator?.parentNode?.removeChild(this.separator);
|
|
19132
|
+
this.separator = document.createElement("span");
|
|
19133
|
+
this.dom.insertBefore(this.separator, this.contentDOM);
|
|
19134
|
+
}
|
|
19135
|
+
this.separator.className = "sd-editor-tab";
|
|
19136
|
+
this.separator.contentEditable = "false";
|
|
19137
|
+
} else if (suffix === "space") {
|
|
19138
|
+
if (this.separator == null || this.separator.nodeType !== Node.TEXT_NODE) {
|
|
19139
|
+
this.separator?.parentNode?.removeChild(this.separator);
|
|
19140
|
+
this.separator = document.createTextNode(" ");
|
|
19141
|
+
this.dom.insertBefore(this.separator, this.contentDOM);
|
|
19142
|
+
}
|
|
19143
|
+
this.separator.textContent = " ";
|
|
19144
|
+
} else if (suffix === "nothing") {
|
|
19145
|
+
if (this.separator == null || this.separator.nodeType !== Node.TEXT_NODE) {
|
|
19146
|
+
this.separator?.parentNode?.removeChild(this.separator);
|
|
19147
|
+
this.separator = document.createTextNode("");
|
|
19148
|
+
this.dom.insertBefore(this.separator, this.contentDOM);
|
|
19149
|
+
}
|
|
19150
|
+
this.separator.textContent = "";
|
|
19151
|
+
}
|
|
19152
|
+
};
|
|
19153
|
+
/**
|
|
19154
|
+
* This is the logic behind the calculation:
|
|
19155
|
+
*
|
|
19156
|
+
* For left alignment:
|
|
19157
|
+
* - The tab character extends to the next tab stop
|
|
19158
|
+
*
|
|
19159
|
+
* For right alignment:
|
|
19160
|
+
* When: hanging is defined OR hanging is not defined and neither is firstLine
|
|
19161
|
+
* - The tab character extends to the hanging position only and never goes beyond it.
|
|
19162
|
+
*
|
|
19163
|
+
* When: firstLine is defined
|
|
19164
|
+
* - The tab character extends to the next tab stop
|
|
19165
|
+
*
|
|
19166
|
+
* For center alignment:
|
|
19167
|
+
* - The tab character extends to the next tab stop
|
|
19168
|
+
*/
|
|
19169
|
+
/**
|
|
19170
|
+
* @param {'left' | 'right' | 'center'} justification
|
|
19171
|
+
* @param {{ hanging?: number, firstLine?: number } | null} indent
|
|
19172
|
+
*/
|
|
19173
|
+
calculateTabSeparatorStyle_fn = function(justification, indent) {
|
|
19174
|
+
const markerWidth = this.marker.getBoundingClientRect().width;
|
|
19175
|
+
let tabStyle;
|
|
19176
|
+
let { paragraphContext, start: start2 } = __privateMethod(this, _ParagraphNodeView_instances, getParagraphContext_fn).call(this);
|
|
19177
|
+
if (justification === "right") {
|
|
19178
|
+
if (indent?.hanging || !indent?.hanging && !indent?.firstLine) {
|
|
19179
|
+
const hanging = indent?.hanging ? twipsToPixels(indent.hanging) : 0;
|
|
19180
|
+
tabStyle = `width: ${hanging}px;`;
|
|
19181
|
+
} else {
|
|
19182
|
+
const tabNode = this.editor.schema.nodes.tab.create(null);
|
|
19183
|
+
tabStyle = calculateTabStyle(tabNode.nodeSize, this.editor.view, start2, this.node, paragraphContext);
|
|
19184
|
+
}
|
|
19185
|
+
} else if (justification === "center") {
|
|
19186
|
+
paragraphContext.accumulatedTabWidth = markerWidth / 2;
|
|
19187
|
+
const tabNode = this.editor.schema.nodes.tab.create(null);
|
|
19188
|
+
tabStyle = calculateTabStyle(tabNode.nodeSize, this.editor.view, start2, this.node, paragraphContext);
|
|
19189
|
+
tabStyle += `margin-left: ${markerWidth / 2}px;`;
|
|
19190
|
+
} else {
|
|
19191
|
+
paragraphContext.accumulatedTabWidth = markerWidth;
|
|
19192
|
+
const tabNode = this.editor.schema.nodes.tab.create(null);
|
|
19193
|
+
tabStyle = calculateTabStyle(tabNode.nodeSize, this.editor.view, start2, this.node, paragraphContext);
|
|
19194
|
+
}
|
|
19195
|
+
this.separator.style.cssText = tabStyle;
|
|
19196
|
+
};
|
|
19197
|
+
/**
|
|
19198
|
+
* This is the logic behind the calculation:
|
|
19199
|
+
* For left alignment:
|
|
19200
|
+
* - The marker text STARTS at the left indent
|
|
19201
|
+
*
|
|
19202
|
+
* For right alignment:
|
|
19203
|
+
* - The marker text ENDS at the left indent
|
|
19204
|
+
*
|
|
19205
|
+
* For center alignment:
|
|
19206
|
+
* - The marker text is centered around the left indent (pulled back by half its width)
|
|
19207
|
+
*
|
|
19208
|
+
* The left/center/right alignment positioning uses the left indent (+ firstLine if present) as the anchor point.
|
|
19209
|
+
*/
|
|
19210
|
+
/**
|
|
19211
|
+
* @param {'left' | 'right' | 'center'} justification
|
|
19212
|
+
*/
|
|
19213
|
+
calculateMarkerStyle_fn = function(justification) {
|
|
19214
|
+
const runProperties = resolveRunProperties(
|
|
19215
|
+
{ docx: this.editor.converter.convertedXml, numbering: this.editor.converter.numbering },
|
|
19216
|
+
this.node.attrs.paragraphProperties.runProperties || {},
|
|
19217
|
+
{ ...this.node.attrs.paragraphProperties, numberingProperties: this.node.attrs.numberingProperties },
|
|
19218
|
+
true,
|
|
19219
|
+
Boolean(this.node.attrs.paragraphProperties.numberingProperties)
|
|
19220
|
+
);
|
|
19221
|
+
const style = encodeCSSFromRPr(runProperties, this.editor.converter.convertedXml);
|
|
19222
|
+
this.marker.style.cssText = Object.entries(style).map(([k2, v]) => `${k2}: ${v};`).join(" ");
|
|
19223
|
+
let markerStyle = {
|
|
19224
|
+
position: "",
|
|
19225
|
+
left: "",
|
|
19226
|
+
bottom: ""
|
|
19227
|
+
};
|
|
19228
|
+
let domStyle = {
|
|
19229
|
+
position: ""
|
|
19230
|
+
};
|
|
19231
|
+
const calculateTop = () => {
|
|
19232
|
+
let top2 = "0";
|
|
19233
|
+
if (globalThis) {
|
|
19234
|
+
const computedStyle = globalThis.getComputedStyle(this.dom);
|
|
19235
|
+
const markerComputedStyle = globalThis.getComputedStyle(this.marker);
|
|
19236
|
+
const lineHeight = parseFloat(computedStyle.lineHeight);
|
|
19237
|
+
const markerLineHeight = parseFloat(markerComputedStyle.lineHeight);
|
|
19238
|
+
top2 = `${lineHeight - markerLineHeight}px`;
|
|
19239
|
+
}
|
|
19240
|
+
return top2;
|
|
19241
|
+
};
|
|
19242
|
+
const rect = this.marker.getBoundingClientRect();
|
|
19243
|
+
const markerWidth = rect.width;
|
|
19244
|
+
if (justification === "right") {
|
|
19245
|
+
markerStyle.position = "absolute";
|
|
19246
|
+
markerStyle.left = `${-markerWidth}px`;
|
|
19247
|
+
markerStyle.top = calculateTop();
|
|
19248
|
+
domStyle.position = "relative";
|
|
19249
|
+
} else if (justification === "center") {
|
|
19250
|
+
markerStyle.position = "absolute";
|
|
19251
|
+
markerStyle.left = `${-markerWidth / 2}px`;
|
|
19252
|
+
markerStyle.top = calculateTop();
|
|
19253
|
+
domStyle.position = "relative";
|
|
19254
|
+
}
|
|
19255
|
+
Object.entries(markerStyle).forEach(([k2, v]) => {
|
|
19256
|
+
this.marker.style[k2] = v;
|
|
19257
|
+
});
|
|
19258
|
+
Object.entries(domStyle).forEach(([k2, v]) => {
|
|
19259
|
+
this.dom.style[k2] = v;
|
|
20299
19260
|
});
|
|
20300
|
-
this.dom = document.createElement("li");
|
|
20301
|
-
this.dom.className = "sd-editor-list-item-node-view";
|
|
20302
|
-
this.dom.style.fontSize = fontSize;
|
|
20303
|
-
this.dom.style.fontFamily = fontFamily ? fontFamily : "inherit";
|
|
20304
|
-
this.dom.style.lineHeight = lineHeight || "";
|
|
20305
|
-
this.dom.setAttribute("data-marker-type", orderMarker);
|
|
20306
|
-
this.dom.setAttribute("data-num-id", numId);
|
|
20307
|
-
this.dom.setAttribute("data-list-level", JSON.stringify(listLevel));
|
|
20308
|
-
this.dom.setAttribute("data-list-numbering-type", listNumberingType);
|
|
20309
|
-
this.dom.setAttribute("data-level", level);
|
|
20310
|
-
this.numberingDOM = document.createElement("span");
|
|
20311
|
-
this.numberingDOM.className = "sd-editor-list-item-numbering";
|
|
20312
|
-
this.numberingDOM.textContent = orderMarker;
|
|
20313
|
-
this.numberingDOM.setAttribute("contenteditable", "false");
|
|
20314
|
-
this.numberingDOM.addEventListener("click", this.handleNumberingClick);
|
|
20315
|
-
this.contentDOM = document.createElement("div");
|
|
20316
|
-
this.contentDOM.className = "sd-editor-list-item-content-dom";
|
|
20317
|
-
this.dom.appendChild(this.numberingDOM);
|
|
20318
|
-
this.dom.appendChild(this.contentDOM);
|
|
20319
|
-
this.refreshIndentStyling({ immediate: true });
|
|
20320
19261
|
};
|
|
20321
|
-
|
|
20322
|
-
|
|
20323
|
-
|
|
20324
|
-
|
|
20325
|
-
|
|
20326
|
-
|
|
20327
|
-
|
|
20328
|
-
|
|
20329
|
-
|
|
20330
|
-
|
|
20331
|
-
|
|
20332
|
-
|
|
20333
|
-
|
|
20334
|
-
|
|
20335
|
-
|
|
20336
|
-
|
|
20337
|
-
|
|
20338
|
-
|
|
19262
|
+
removeList_fn = function() {
|
|
19263
|
+
if (this.marker) {
|
|
19264
|
+
this.dom.removeChild(this.marker);
|
|
19265
|
+
this.marker = null;
|
|
19266
|
+
}
|
|
19267
|
+
if (this.separator) {
|
|
19268
|
+
this.dom.removeChild(this.separator);
|
|
19269
|
+
this.separator = null;
|
|
19270
|
+
}
|
|
19271
|
+
this.dom.style.position = "";
|
|
19272
|
+
};
|
|
19273
|
+
getParagraphContext_fn = function() {
|
|
19274
|
+
const $pos = this.editor.state.doc.resolve(this.getPos());
|
|
19275
|
+
const start2 = $pos.start($pos.depth + 1);
|
|
19276
|
+
const paragraphContext = extractParagraphContext(this.node, start2, this.editor.helpers);
|
|
19277
|
+
return { paragraphContext, start: start2 };
|
|
19278
|
+
};
|
|
19279
|
+
/**
|
|
19280
|
+
* @param {() => void} fn
|
|
19281
|
+
*/
|
|
19282
|
+
scheduleAnimation_fn = function(fn2) {
|
|
19283
|
+
if (typeof globalThis === "undefined") {
|
|
19284
|
+
return;
|
|
19285
|
+
}
|
|
19286
|
+
__privateMethod(this, _ParagraphNodeView_instances, cancelScheduledAnimation_fn).call(this);
|
|
19287
|
+
this._animationFrameRequest = globalThis.requestAnimationFrame(() => {
|
|
19288
|
+
fn2();
|
|
19289
|
+
this._animationFrameRequest = null;
|
|
19290
|
+
});
|
|
19291
|
+
};
|
|
19292
|
+
cancelScheduledAnimation_fn = function() {
|
|
19293
|
+
if (typeof globalThis === "undefined" || !this._animationFrameRequest) {
|
|
19294
|
+
return;
|
|
19295
|
+
}
|
|
19296
|
+
globalThis.cancelAnimationFrame(this._animationFrameRequest);
|
|
19297
|
+
this._animationFrameRequest = null;
|
|
19298
|
+
};
|
|
19299
|
+
function NumberingManager() {
|
|
19300
|
+
let countersMap = {};
|
|
19301
|
+
let abstractCountersMap = {};
|
|
19302
|
+
let abstractIdMap = {};
|
|
19303
|
+
const startsMap = {};
|
|
19304
|
+
let lastSeenMap = {};
|
|
19305
|
+
let pathCache = {};
|
|
19306
|
+
let cacheEnabled = false;
|
|
19307
|
+
return {
|
|
19308
|
+
/**
|
|
19309
|
+
* Persist the base start value and optional restart limit for a given
|
|
19310
|
+
* numId/level combination.
|
|
19311
|
+
*
|
|
19312
|
+
* @param {string | number} numId
|
|
19313
|
+
* @param {number} level
|
|
19314
|
+
* @param {number} startValue
|
|
19315
|
+
* @param {number} [restartValue]
|
|
19316
|
+
*/
|
|
19317
|
+
setStartSettings(numId, level, startValue, restartValue) {
|
|
19318
|
+
if (!startsMap[numId]) {
|
|
19319
|
+
startsMap[numId] = {};
|
|
19320
|
+
}
|
|
19321
|
+
if (!startsMap[numId][level]) {
|
|
19322
|
+
startsMap[numId][level] = {};
|
|
19323
|
+
}
|
|
19324
|
+
startsMap[numId][level].start = startValue;
|
|
19325
|
+
startsMap[numId][level].restart = restartValue;
|
|
19326
|
+
},
|
|
19327
|
+
/**
|
|
19328
|
+
* Record the computed counter for a specific node position. When caching is
|
|
19329
|
+
* enabled this also tracks the latest position to speed up lookups.
|
|
19330
|
+
*
|
|
19331
|
+
* @param {string | number} numId
|
|
19332
|
+
* @param {number} level
|
|
19333
|
+
* @param {number} pos
|
|
19334
|
+
* @param {number} value
|
|
19335
|
+
*/
|
|
19336
|
+
setCounter(numId, level, pos, value, abstractId) {
|
|
19337
|
+
if (!countersMap[numId]) {
|
|
19338
|
+
countersMap[numId] = {};
|
|
19339
|
+
}
|
|
19340
|
+
if (!countersMap[numId][level]) {
|
|
19341
|
+
countersMap[numId][level] = {};
|
|
19342
|
+
}
|
|
19343
|
+
countersMap[numId][level][pos] = value;
|
|
19344
|
+
abstractIdMap[numId] = abstractId;
|
|
19345
|
+
if (!abstractCountersMap[abstractId]) {
|
|
19346
|
+
abstractCountersMap[abstractId] = {};
|
|
19347
|
+
}
|
|
19348
|
+
if (!abstractCountersMap[abstractId][level]) {
|
|
19349
|
+
abstractCountersMap[abstractId][level] = {};
|
|
19350
|
+
}
|
|
19351
|
+
abstractCountersMap[abstractId][level][pos] = value;
|
|
19352
|
+
if (!cacheEnabled) {
|
|
19353
|
+
return;
|
|
19354
|
+
}
|
|
19355
|
+
if (!lastSeenMap[numId]) {
|
|
19356
|
+
lastSeenMap[numId] = {};
|
|
19357
|
+
}
|
|
19358
|
+
const lastSeen = lastSeenMap[numId][level];
|
|
19359
|
+
if (!lastSeen || pos > lastSeen.pos) {
|
|
19360
|
+
lastSeenMap[numId][level] = { pos, count: value };
|
|
19361
|
+
}
|
|
19362
|
+
},
|
|
19363
|
+
/**
|
|
19364
|
+
* Retrieve a previously stored counter for the provided position.
|
|
19365
|
+
*
|
|
19366
|
+
* @param {string | number} numId
|
|
19367
|
+
* @param {number} level
|
|
19368
|
+
* @param {number} pos
|
|
19369
|
+
* @returns {number | null}
|
|
19370
|
+
*/
|
|
19371
|
+
getCounter(numId, level, pos) {
|
|
19372
|
+
if (countersMap[numId] && countersMap[numId][level] && countersMap[numId][level][pos] != null) {
|
|
19373
|
+
return countersMap[numId][level][pos];
|
|
19374
|
+
}
|
|
19375
|
+
return null;
|
|
19376
|
+
},
|
|
19377
|
+
/**
|
|
19378
|
+
* Calculate the counter value that should be used for the given position,
|
|
19379
|
+
* respecting restart rules, ancestor usage, and cached history.
|
|
19380
|
+
*
|
|
19381
|
+
* @param {string | number} numId
|
|
19382
|
+
* @param {number} level
|
|
19383
|
+
* @param {number} pos
|
|
19384
|
+
* @returns {number}
|
|
19385
|
+
*/
|
|
19386
|
+
calculateCounter(numId, level, pos, abstractId) {
|
|
19387
|
+
abstractIdMap[numId] = abstractId;
|
|
19388
|
+
const restartSetting = startsMap?.[numId]?.[level]?.restart;
|
|
19389
|
+
const startValue = startsMap?.[numId]?.[level]?.start ?? 1;
|
|
19390
|
+
const levelData = countersMap?.[numId]?.[level] || {};
|
|
19391
|
+
let previousPos = null;
|
|
19392
|
+
let previousCount = startValue - 1;
|
|
19393
|
+
if (cacheEnabled) {
|
|
19394
|
+
const cachedLast = lastSeenMap?.[numId]?.[level];
|
|
19395
|
+
if (cachedLast && cachedLast.pos < pos) {
|
|
19396
|
+
previousPos = cachedLast.pos;
|
|
19397
|
+
previousCount = cachedLast.count;
|
|
19398
|
+
}
|
|
19399
|
+
}
|
|
19400
|
+
if (previousPos == null) {
|
|
19401
|
+
const fallbackPos = Object.keys(levelData).map((p) => parseInt(p)).filter((p) => p < pos).pop();
|
|
19402
|
+
if (fallbackPos != null) {
|
|
19403
|
+
previousPos = fallbackPos;
|
|
19404
|
+
previousCount = levelData[fallbackPos];
|
|
19405
|
+
}
|
|
19406
|
+
}
|
|
19407
|
+
if (restartSetting === 0) {
|
|
19408
|
+
return previousCount + 1;
|
|
19409
|
+
}
|
|
19410
|
+
if (previousPos == null) {
|
|
19411
|
+
return startValue;
|
|
19412
|
+
}
|
|
19413
|
+
const usedLevels = [];
|
|
19414
|
+
for (let lvl = 0; lvl < level; lvl++) {
|
|
19415
|
+
const levelData2 = abstractCountersMap?.[abstractId]?.[lvl] || {};
|
|
19416
|
+
const hasUsed = Object.keys(levelData2).map((p) => parseInt(p)).some((p) => p > previousPos && p < pos);
|
|
19417
|
+
if (hasUsed) {
|
|
19418
|
+
usedLevels.push(lvl);
|
|
19419
|
+
}
|
|
19420
|
+
}
|
|
19421
|
+
if (usedLevels.length === 0) {
|
|
19422
|
+
return previousCount + 1;
|
|
19423
|
+
}
|
|
19424
|
+
if (restartSetting == null) {
|
|
19425
|
+
return startValue;
|
|
19426
|
+
}
|
|
19427
|
+
const shouldRestart = usedLevels.some((lvl) => lvl <= restartSetting);
|
|
19428
|
+
if (shouldRestart) {
|
|
19429
|
+
return startValue;
|
|
19430
|
+
}
|
|
19431
|
+
return previousCount + 1;
|
|
19432
|
+
},
|
|
19433
|
+
/**
|
|
19434
|
+
* Resolve the counter values for every ancestor level preceding the given
|
|
19435
|
+
* position. All numbering definitions that have the same abstract id
|
|
19436
|
+
* are considered. Results are cached when cache mode is active.
|
|
19437
|
+
*
|
|
19438
|
+
* @param {string | number} numId
|
|
19439
|
+
* @param {number} level
|
|
19440
|
+
* @param {number} pos
|
|
19441
|
+
* @returns {number[]}
|
|
19442
|
+
*/
|
|
19443
|
+
getAncestorsPath(numId, level, pos) {
|
|
19444
|
+
if (cacheEnabled && pathCache?.[numId]?.[level]?.[pos]) {
|
|
19445
|
+
return pathCache[numId][level][pos];
|
|
19446
|
+
}
|
|
19447
|
+
const path = [];
|
|
19448
|
+
const abstractId = abstractIdMap[numId];
|
|
19449
|
+
for (let lvl = 0; lvl < level; lvl++) {
|
|
19450
|
+
const startCount = startsMap?.[numId]?.[lvl]?.start ?? 1;
|
|
19451
|
+
const levelData = abstractCountersMap?.[abstractId]?.[lvl] || {};
|
|
19452
|
+
if (levelData == null) {
|
|
19453
|
+
path.push(startCount);
|
|
19454
|
+
continue;
|
|
19455
|
+
}
|
|
19456
|
+
const previousPos = Object.keys(levelData).map((p) => parseInt(p)).filter((p) => p < pos).pop();
|
|
19457
|
+
if (previousPos == null) {
|
|
19458
|
+
path.push(startCount);
|
|
19459
|
+
} else {
|
|
19460
|
+
path.push(levelData[previousPos]);
|
|
19461
|
+
}
|
|
19462
|
+
}
|
|
19463
|
+
if (cacheEnabled) {
|
|
19464
|
+
if (!pathCache[numId]) {
|
|
19465
|
+
pathCache[numId] = {};
|
|
19466
|
+
}
|
|
19467
|
+
if (!pathCache[numId][level]) {
|
|
19468
|
+
pathCache[numId][level] = {};
|
|
19469
|
+
}
|
|
19470
|
+
pathCache[numId][level][pos] = path;
|
|
19471
|
+
}
|
|
19472
|
+
return path;
|
|
19473
|
+
},
|
|
19474
|
+
/**
|
|
19475
|
+
* Convenience helper that appends the current level counter on top of the
|
|
19476
|
+
* ancestor path.
|
|
19477
|
+
*
|
|
19478
|
+
* @param {string | number} numId
|
|
19479
|
+
* @param {number} level
|
|
19480
|
+
* @param {number} pos
|
|
19481
|
+
* @returns {number[]}
|
|
19482
|
+
*/
|
|
19483
|
+
calculatePath(numId, level, pos) {
|
|
19484
|
+
const path = this.getAncestorsPath(numId, level, pos);
|
|
19485
|
+
const myCount = this.getCounter(numId, level, pos);
|
|
19486
|
+
path.push(myCount);
|
|
19487
|
+
return path;
|
|
19488
|
+
},
|
|
19489
|
+
/**
|
|
19490
|
+
* Expose the internal counters map mainly for debugging and tests.
|
|
19491
|
+
*
|
|
19492
|
+
* @returns {Record<string, Record<string, Record<string, number>>>}
|
|
19493
|
+
*/
|
|
19494
|
+
getCountersMap() {
|
|
19495
|
+
return countersMap;
|
|
19496
|
+
},
|
|
19497
|
+
/**
|
|
19498
|
+
* Reset cached counter/path structures. Intended for internal use only.
|
|
19499
|
+
*/
|
|
19500
|
+
_clearCache() {
|
|
19501
|
+
lastSeenMap = {};
|
|
19502
|
+
pathCache = {};
|
|
19503
|
+
countersMap = {};
|
|
19504
|
+
abstractCountersMap = {};
|
|
19505
|
+
abstractIdMap = {};
|
|
19506
|
+
},
|
|
19507
|
+
/**
|
|
19508
|
+
* Enable cache-aware logic (used during document scans) and drop stale data.
|
|
19509
|
+
*/
|
|
19510
|
+
enableCache() {
|
|
19511
|
+
cacheEnabled = true;
|
|
19512
|
+
this._clearCache();
|
|
20339
19513
|
},
|
|
20340
|
-
|
|
20341
|
-
|
|
20342
|
-
|
|
20343
|
-
|
|
20344
|
-
|
|
20345
|
-
|
|
20346
|
-
} else if (minMarkerWidth > hanging) {
|
|
20347
|
-
const diff = minMarkerWidth - hanging;
|
|
20348
|
-
markerLeft -= diff;
|
|
20349
|
-
}
|
|
20350
|
-
this.contentDOM.style.marginLeft = `${contentLeft}px`;
|
|
20351
|
-
this.numberingDOM.style.left = `${markerLeft}px`;
|
|
20352
|
-
this.numberingDOM.style.width = "";
|
|
20353
|
-
this.numberingDOM.style.textAlign = "";
|
|
19514
|
+
/**
|
|
19515
|
+
* Disable cache-aware logic and clear residual cache entries.
|
|
19516
|
+
*/
|
|
19517
|
+
disableCache() {
|
|
19518
|
+
cacheEnabled = false;
|
|
19519
|
+
this._clearCache();
|
|
20354
19520
|
}
|
|
20355
19521
|
};
|
|
20356
|
-
|
|
20357
|
-
|
|
19522
|
+
}
|
|
19523
|
+
const generateOrderedListIndex = ({ listLevel, lvlText, listNumberingType, customFormat }) => {
|
|
19524
|
+
const handler = listIndexMap[listNumberingType];
|
|
19525
|
+
return handler ? handler(listLevel, lvlText, customFormat) : null;
|
|
20358
19526
|
};
|
|
20359
|
-
|
|
20360
|
-
|
|
20361
|
-
|
|
20362
|
-
|
|
20363
|
-
|
|
20364
|
-
|
|
20365
|
-
|
|
19527
|
+
const handleDecimal = (path, lvlText) => generateNumbering(path, lvlText, String);
|
|
19528
|
+
const handleRoman = (path, lvlText) => generateNumbering(path, lvlText, intToRoman);
|
|
19529
|
+
const handleLowerRoman = (path, lvlText) => handleRoman(path, lvlText).toLowerCase();
|
|
19530
|
+
const handleLowerAlpha = (path, lvlText) => handleAlpha(path, lvlText).toLowerCase();
|
|
19531
|
+
const handleAlpha = (path, lvlText) => generateNumbering(path, lvlText, (p) => intToAlpha(p));
|
|
19532
|
+
const handleOrdinal = (path, lvlText) => generateNumbering(path, lvlText, ordinalFormatter);
|
|
19533
|
+
const handleCustom = (path, lvlText, customFormat) => generateFromCustom(path, lvlText, customFormat);
|
|
19534
|
+
const handleJapaneseCounting = (path, lvlText) => generateNumbering(path, lvlText, intToJapaneseCounting);
|
|
19535
|
+
const listIndexMap = {
|
|
19536
|
+
decimal: handleDecimal,
|
|
19537
|
+
lowerRoman: handleLowerRoman,
|
|
19538
|
+
upperRoman: handleRoman,
|
|
19539
|
+
lowerLetter: handleLowerAlpha,
|
|
19540
|
+
upperLetter: handleAlpha,
|
|
19541
|
+
ordinal: handleOrdinal,
|
|
19542
|
+
custom: handleCustom,
|
|
19543
|
+
japaneseCounting: handleJapaneseCounting
|
|
19544
|
+
};
|
|
19545
|
+
const createNumbering = (values, lvlText) => {
|
|
19546
|
+
return values.reduce((acc, value, index2) => {
|
|
19547
|
+
return value > 9 ? acc.replace(/^0/, "").replace(`%${index2 + 1}`, value) : acc.replace(`%${index2 + 1}`, value);
|
|
19548
|
+
}, lvlText);
|
|
19549
|
+
};
|
|
19550
|
+
const generateNumbering = (path, lvlText, formatter) => {
|
|
19551
|
+
const formattedValues = path.map(formatter);
|
|
19552
|
+
return createNumbering(formattedValues, lvlText);
|
|
19553
|
+
};
|
|
19554
|
+
const ordinalFormatter = (level) => {
|
|
19555
|
+
const suffixes = ["th", "st", "nd", "rd"];
|
|
19556
|
+
const value = level % 100;
|
|
19557
|
+
const suffix = suffixes[(value - 20) % 10] || suffixes[value] || suffixes[0];
|
|
19558
|
+
const p = level + suffix;
|
|
19559
|
+
return p;
|
|
19560
|
+
};
|
|
19561
|
+
const generateFromCustom = (path, lvlText, customFormat) => {
|
|
19562
|
+
if (customFormat !== "001, 002, 003, ...") return generateNumbering(path, lvlText, String);
|
|
19563
|
+
const match = customFormat.match(/(\d+)/);
|
|
19564
|
+
if (!match) throw new Error("Invalid format string: no numeric pattern found");
|
|
19565
|
+
const sample = match[1];
|
|
19566
|
+
const digitCount = sample.length;
|
|
19567
|
+
const index2 = path.pop();
|
|
19568
|
+
return String(index2).padStart(digitCount, "0");
|
|
19569
|
+
};
|
|
19570
|
+
const intToRoman = (num) => {
|
|
19571
|
+
const romanNumeralMap = [
|
|
19572
|
+
{ value: 1e3, numeral: "M" },
|
|
19573
|
+
{ value: 900, numeral: "CM" },
|
|
19574
|
+
{ value: 500, numeral: "D" },
|
|
19575
|
+
{ value: 400, numeral: "CD" },
|
|
19576
|
+
{ value: 100, numeral: "C" },
|
|
19577
|
+
{ value: 90, numeral: "XC" },
|
|
19578
|
+
{ value: 50, numeral: "L" },
|
|
19579
|
+
{ value: 40, numeral: "XL" },
|
|
19580
|
+
{ value: 10, numeral: "X" },
|
|
19581
|
+
{ value: 9, numeral: "IX" },
|
|
19582
|
+
{ value: 5, numeral: "V" },
|
|
19583
|
+
{ value: 4, numeral: "IV" },
|
|
19584
|
+
{ value: 1, numeral: "I" }
|
|
19585
|
+
];
|
|
19586
|
+
let result = "";
|
|
19587
|
+
for (const { value, numeral } of romanNumeralMap) {
|
|
19588
|
+
while (num >= value) {
|
|
19589
|
+
result += numeral;
|
|
19590
|
+
num -= value;
|
|
20366
19591
|
}
|
|
20367
|
-
}
|
|
20368
|
-
}
|
|
20369
|
-
const getVisibleIndent = (stylePpr, numDefPpr, inlineIndent) => {
|
|
20370
|
-
const styleIndentTag = stylePpr?.elements?.find((el) => el.name === "w:ind") || {};
|
|
20371
|
-
const styleIndent = parseIndentElement(styleIndentTag);
|
|
20372
|
-
const numDefIndentTag = numDefPpr?.elements?.find((el) => el.name === "w:ind") || {};
|
|
20373
|
-
const numDefIndent = parseIndentElement(numDefIndentTag);
|
|
20374
|
-
const indent = combineIndents(styleIndent, numDefIndent);
|
|
20375
|
-
const result = combineIndents(indent, inlineIndent);
|
|
19592
|
+
}
|
|
20376
19593
|
return result;
|
|
20377
19594
|
};
|
|
20378
|
-
|
|
20379
|
-
|
|
20380
|
-
const
|
|
20381
|
-
|
|
20382
|
-
|
|
20383
|
-
|
|
20384
|
-
|
|
20385
|
-
|
|
20386
|
-
|
|
20387
|
-
|
|
20388
|
-
|
|
20389
|
-
|
|
20390
|
-
|
|
20391
|
-
|
|
20392
|
-
|
|
20393
|
-
|
|
20394
|
-
|
|
20395
|
-
|
|
20396
|
-
|
|
20397
|
-
|
|
19595
|
+
const intToAlpha = (num) => {
|
|
19596
|
+
let result = "";
|
|
19597
|
+
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
19598
|
+
while (num > 0) {
|
|
19599
|
+
let index2 = (num - 1) % 26;
|
|
19600
|
+
result = alphabet[index2] + result;
|
|
19601
|
+
num = Math.floor((num - 1) / 26);
|
|
19602
|
+
}
|
|
19603
|
+
return result;
|
|
19604
|
+
};
|
|
19605
|
+
const intToJapaneseCounting = (num) => {
|
|
19606
|
+
const digits = ["", "一", "二", "三", "四", "五", "六", "七", "八", "九"];
|
|
19607
|
+
const units = ["", "十", "百", "千"];
|
|
19608
|
+
if (num === 0) return "零";
|
|
19609
|
+
if (num < 10) return digits[num];
|
|
19610
|
+
let result = "";
|
|
19611
|
+
let tempNum = num;
|
|
19612
|
+
let unitIndex = 0;
|
|
19613
|
+
while (tempNum > 0) {
|
|
19614
|
+
const digit = tempNum % 10;
|
|
19615
|
+
if (digit !== 0) {
|
|
19616
|
+
const digitStr = digit === 1 && unitIndex > 0 ? "" : digits[digit];
|
|
19617
|
+
result = digitStr + (unitIndex > 0 ? units[unitIndex] : "") + result;
|
|
19618
|
+
} else if (result && tempNum > 0) {
|
|
19619
|
+
if (!result.startsWith("零") && tempNum % 100 !== 0) {
|
|
19620
|
+
result = "零" + result;
|
|
19621
|
+
}
|
|
19622
|
+
}
|
|
19623
|
+
tempNum = Math.floor(tempNum / 10);
|
|
19624
|
+
unitIndex++;
|
|
19625
|
+
if (unitIndex > 3) break;
|
|
19626
|
+
}
|
|
19627
|
+
if (num >= 10 && num < 20) {
|
|
19628
|
+
result = result.replace(/^一十/, "十");
|
|
19629
|
+
}
|
|
19630
|
+
return result;
|
|
19631
|
+
};
|
|
19632
|
+
function createNumberingPlugin(editor) {
|
|
19633
|
+
const numberingManager = NumberingManager();
|
|
19634
|
+
const applyStartSettingsFromDefinitions = (definitionsMap) => {
|
|
19635
|
+
Object.entries(definitionsMap || {}).forEach(([numId, levels]) => {
|
|
19636
|
+
Object.entries(levels || {}).forEach(([level, def]) => {
|
|
19637
|
+
const start2 = parseInt(def?.start) || 1;
|
|
19638
|
+
let restart = def?.restart;
|
|
19639
|
+
if (restart != null) {
|
|
19640
|
+
restart = parseInt(restart);
|
|
19641
|
+
}
|
|
19642
|
+
numberingManager.setStartSettings(numId, parseInt(level), start2, restart);
|
|
19643
|
+
});
|
|
19644
|
+
});
|
|
19645
|
+
};
|
|
19646
|
+
const refreshStartSettings = () => {
|
|
19647
|
+
const definitions = ListHelpers.getAllListDefinitions(editor);
|
|
19648
|
+
applyStartSettingsFromDefinitions(definitions);
|
|
19649
|
+
};
|
|
19650
|
+
refreshStartSettings();
|
|
19651
|
+
if (typeof editor?.on === "function") {
|
|
19652
|
+
editor.on("list-definitions-change", refreshStartSettings);
|
|
19653
|
+
if (typeof editor?.off === "function") {
|
|
19654
|
+
const cleanupListDefinitionListener = () => {
|
|
19655
|
+
editor.off("list-definitions-change", refreshStartSettings);
|
|
19656
|
+
editor.off?.("destroy", cleanupListDefinitionListener);
|
|
19657
|
+
};
|
|
19658
|
+
editor.on("destroy", cleanupListDefinitionListener);
|
|
19659
|
+
}
|
|
20398
19660
|
}
|
|
20399
|
-
}
|
|
20400
|
-
const orderedListSyncPluginKey = new PluginKey("orderedListSync");
|
|
20401
|
-
function orderedListSync(editor) {
|
|
20402
|
-
let hasInitialized = false;
|
|
20403
|
-
const docx = editor.converter.convertedXml;
|
|
20404
19661
|
return new Plugin({
|
|
20405
|
-
|
|
19662
|
+
name: "numberingPlugin",
|
|
19663
|
+
key: new PluginKey("numberingPlugin"),
|
|
19664
|
+
/**
|
|
19665
|
+
* Scan document changes and collect fresh numbering metadata for list
|
|
19666
|
+
* paragraphs. The incoming transactions are marked to avoid reprocessing.
|
|
19667
|
+
*
|
|
19668
|
+
* @param {import('prosemirror-state').Transaction[]} transactions
|
|
19669
|
+
* @param {import('prosemirror-state').EditorState} oldState
|
|
19670
|
+
* @param {import('prosemirror-state').EditorState} newState
|
|
19671
|
+
* @returns {import('prosemirror-state').Transaction | null}
|
|
19672
|
+
*/
|
|
20406
19673
|
appendTransaction(transactions, oldState, newState) {
|
|
20407
|
-
if (transactions.every((tr2) => tr2.getMeta("y-sync$"))) return null;
|
|
20408
|
-
const updateNodeViews = transactions.some((tr2) => tr2.getMeta("updatedListItemNodeViews"));
|
|
20409
|
-
if (updateNodeViews || !hasInitialized) {
|
|
20410
|
-
refreshAllListItemNodeViews();
|
|
20411
|
-
}
|
|
20412
19674
|
const isFromPlugin = transactions.some((tr2) => tr2.getMeta("orderedListSync"));
|
|
20413
|
-
|
|
20414
|
-
if (isFromPlugin || !docChanged) {
|
|
19675
|
+
if (isFromPlugin || !transactions.some((tr2) => tr2.docChanged)) {
|
|
20415
19676
|
return null;
|
|
20416
19677
|
}
|
|
20417
|
-
hasInitialized = true;
|
|
20418
19678
|
const tr = newState.tr;
|
|
20419
19679
|
tr.setMeta("orderedListSync", true);
|
|
20420
|
-
|
|
20421
|
-
const listInitialized = /* @__PURE__ */ new Map();
|
|
20422
|
-
const shouldProcess = transactions.some((tr2) => {
|
|
20423
|
-
if (tr2.getMeta("updateListSync")) return true;
|
|
20424
|
-
return tr2.steps.some((step) => {
|
|
20425
|
-
const stepJSON = step.toJSON();
|
|
20426
|
-
if (step.slice?.content) {
|
|
20427
|
-
let hasListItem = false;
|
|
20428
|
-
step.slice.content.descendants((node) => {
|
|
20429
|
-
if (node.type.name === "listItem") {
|
|
20430
|
-
hasListItem = true;
|
|
20431
|
-
return false;
|
|
20432
|
-
}
|
|
20433
|
-
});
|
|
20434
|
-
if (hasListItem) return true;
|
|
20435
|
-
}
|
|
20436
|
-
if (stepJSON && stepJSON.slice) {
|
|
20437
|
-
const jsonStr = JSON.stringify(stepJSON);
|
|
20438
|
-
if (jsonStr.includes('"listItem"')) return true;
|
|
20439
|
-
}
|
|
20440
|
-
return false;
|
|
20441
|
-
});
|
|
20442
|
-
});
|
|
20443
|
-
if (!shouldProcess) return null;
|
|
19680
|
+
numberingManager.enableCache();
|
|
20444
19681
|
newState.doc.descendants((node, pos) => {
|
|
20445
|
-
if (node.type.name !== "
|
|
20446
|
-
|
|
20447
|
-
const level = parseInt(attrLvl);
|
|
20448
|
-
const numId = parseInt(attrNumId);
|
|
20449
|
-
let {
|
|
20450
|
-
lvlText,
|
|
20451
|
-
customFormat,
|
|
20452
|
-
listNumberingType,
|
|
20453
|
-
start: numberingDefStart
|
|
20454
|
-
} = ListHelpers.getListDefinitionDetails({ numId, level, editor });
|
|
20455
|
-
const start2 = parseInt(numberingDefStart) || 1;
|
|
20456
|
-
if (!listMap.has(numId)) {
|
|
20457
|
-
const generatedLevels = {};
|
|
20458
|
-
const initialPath = docxNumberingHelpers.generateListPath(level, numId, styleId, generatedLevels, docx);
|
|
20459
|
-
listMap.set(numId, initialPath || []);
|
|
20460
|
-
listInitialized.set(numId, false);
|
|
20461
|
-
}
|
|
20462
|
-
let currentListLevels = [...listMap.get(numId)];
|
|
20463
|
-
if (!listInitialized.get(numId)) {
|
|
20464
|
-
listInitialized.set(numId, true);
|
|
20465
|
-
if (typeof start2 === "number") {
|
|
20466
|
-
while (currentListLevels.length <= level) {
|
|
20467
|
-
currentListLevels.push(0);
|
|
20468
|
-
}
|
|
20469
|
-
currentListLevels[level] = start2;
|
|
20470
|
-
for (let i = level + 1; i < currentListLevels.length; i++) {
|
|
20471
|
-
currentListLevels[i] = 0;
|
|
20472
|
-
}
|
|
20473
|
-
}
|
|
20474
|
-
} else {
|
|
20475
|
-
while (currentListLevels.length <= level) {
|
|
20476
|
-
currentListLevels.push(0);
|
|
20477
|
-
}
|
|
20478
|
-
currentListLevels[level] = (currentListLevels[level] || 0) + 1;
|
|
20479
|
-
for (let i = level + 1; i < currentListLevels.length; i++) {
|
|
20480
|
-
currentListLevels[i] = 0;
|
|
20481
|
-
}
|
|
19682
|
+
if (node.type.name !== "paragraph" || !node.attrs.numberingProperties) {
|
|
19683
|
+
return;
|
|
20482
19684
|
}
|
|
20483
|
-
|
|
20484
|
-
|
|
19685
|
+
const { numId, ilvl: level = 0 } = node.attrs.numberingProperties;
|
|
19686
|
+
const definitionDetails = ListHelpers.getListDefinitionDetails({ numId, level, editor });
|
|
19687
|
+
if (!definitionDetails || Object.keys(definitionDetails).length === 0) {
|
|
19688
|
+
tr.setNodeAttribute(pos, "listRendering", null);
|
|
19689
|
+
return;
|
|
20485
19690
|
}
|
|
20486
|
-
|
|
20487
|
-
|
|
20488
|
-
|
|
20489
|
-
|
|
20490
|
-
|
|
20491
|
-
|
|
20492
|
-
|
|
20493
|
-
|
|
20494
|
-
|
|
20495
|
-
|
|
20496
|
-
|
|
20497
|
-
|
|
19691
|
+
let { lvlText, customFormat, listNumberingType, suffix, justification, abstractId } = definitionDetails;
|
|
19692
|
+
let markerText = "";
|
|
19693
|
+
const count = numberingManager.calculateCounter(numId, level, pos, abstractId);
|
|
19694
|
+
numberingManager.setCounter(numId, level, pos, count, abstractId);
|
|
19695
|
+
const path = numberingManager.calculatePath(numId, level, pos);
|
|
19696
|
+
if (listNumberingType !== "bullet") {
|
|
19697
|
+
markerText = generateOrderedListIndex({
|
|
19698
|
+
listLevel: path,
|
|
19699
|
+
lvlText,
|
|
19700
|
+
listNumberingType,
|
|
19701
|
+
customFormat
|
|
19702
|
+
});
|
|
19703
|
+
} else {
|
|
19704
|
+
markerText = docxNumberingHelpers.normalizeLvlTextChar(lvlText);
|
|
19705
|
+
}
|
|
19706
|
+
if (JSON.stringify(node.attrs.listRendering) !== JSON.stringify({
|
|
19707
|
+
markerText,
|
|
19708
|
+
suffix,
|
|
19709
|
+
justification,
|
|
19710
|
+
path,
|
|
19711
|
+
numberingType: listNumberingType
|
|
19712
|
+
})) {
|
|
19713
|
+
tr.setNodeAttribute(pos, "listRendering", {
|
|
19714
|
+
markerText,
|
|
19715
|
+
suffix,
|
|
19716
|
+
justification,
|
|
19717
|
+
path,
|
|
19718
|
+
numberingType: listNumberingType
|
|
19719
|
+
});
|
|
20498
19720
|
}
|
|
19721
|
+
return false;
|
|
20499
19722
|
});
|
|
20500
|
-
|
|
19723
|
+
numberingManager.disableCache();
|
|
19724
|
+
return tr.docChanged ? tr : null;
|
|
20501
19725
|
}
|
|
20502
19726
|
});
|
|
20503
19727
|
}
|
|
20504
|
-
const
|
|
20505
|
-
|
|
20506
|
-
content: "paragraph* block*",
|
|
20507
|
-
defining: true,
|
|
20508
|
-
priority: 101,
|
|
20509
|
-
// to run listItem commands first
|
|
20510
|
-
addOptions() {
|
|
20511
|
-
return {
|
|
20512
|
-
htmlAttributes: {
|
|
20513
|
-
"aria-label": "List item node"
|
|
20514
|
-
},
|
|
20515
|
-
bulletListTypeName: "bulletList",
|
|
20516
|
-
orderedListTypeName: "orderedList"
|
|
20517
|
-
};
|
|
20518
|
-
},
|
|
20519
|
-
parseDOM() {
|
|
20520
|
-
return [{ tag: "li" }];
|
|
20521
|
-
},
|
|
20522
|
-
renderDOM({ htmlAttributes }) {
|
|
20523
|
-
return ["li", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
|
|
20524
|
-
},
|
|
20525
|
-
addPmPlugins() {
|
|
20526
|
-
return this.editor?.converter?.convertedXml ? [orderedListSync(this.editor)] : [];
|
|
20527
|
-
},
|
|
20528
|
-
/**
|
|
20529
|
-
* Important: The listItem node uses a custom node view.
|
|
20530
|
-
* Skip node view in headless mode for performance.
|
|
20531
|
-
* @returns {import('@core/NodeView.js').NodeView|null}
|
|
20532
|
-
*/
|
|
20533
|
-
addNodeView() {
|
|
20534
|
-
if (shouldSkipNodeView(this.editor)) return null;
|
|
20535
|
-
return ({ node, editor, getPos, decorations }) => {
|
|
20536
|
-
return new ListItemNodeView(node, getPos, decorations, editor);
|
|
20537
|
-
};
|
|
20538
|
-
},
|
|
20539
|
-
addAttributes() {
|
|
20540
|
-
return {
|
|
20541
|
-
// Virtual attribute.
|
|
20542
|
-
markerType: {
|
|
20543
|
-
default: null,
|
|
20544
|
-
renderDOM: (attrs) => {
|
|
20545
|
-
let { listLevel, listNumberingType, lvlText } = attrs;
|
|
20546
|
-
let hasListLevel = !!listLevel?.length;
|
|
20547
|
-
if (!hasListLevel || !lvlText) {
|
|
20548
|
-
return {};
|
|
20549
|
-
}
|
|
20550
|
-
let orderMarker = generateOrderedListIndex({
|
|
20551
|
-
listLevel,
|
|
20552
|
-
lvlText,
|
|
20553
|
-
listNumberingType
|
|
20554
|
-
});
|
|
20555
|
-
if (!orderMarker) return {};
|
|
20556
|
-
return {
|
|
20557
|
-
"data-marker-type": orderMarker
|
|
20558
|
-
};
|
|
20559
|
-
}
|
|
20560
|
-
},
|
|
20561
|
-
lvlText: {
|
|
20562
|
-
default: null,
|
|
20563
|
-
keepOnSplit: true,
|
|
20564
|
-
parseDOM: (elem) => elem.getAttribute("data-lvl-text"),
|
|
20565
|
-
renderDOM: (attrs) => {
|
|
20566
|
-
if (!attrs.lvlText) return {};
|
|
20567
|
-
return {
|
|
20568
|
-
"data-lvl-text": attrs.lvlText
|
|
20569
|
-
};
|
|
20570
|
-
}
|
|
20571
|
-
},
|
|
20572
|
-
listNumberingType: {
|
|
20573
|
-
default: null,
|
|
20574
|
-
keepOnSplit: true,
|
|
20575
|
-
parseDOM: (elem) => elem.getAttribute("data-num-fmt"),
|
|
20576
|
-
renderDOM: (attrs) => {
|
|
20577
|
-
if (!attrs.listNumberingType) return {};
|
|
20578
|
-
return {
|
|
20579
|
-
"data-num-fmt": attrs.listNumberingType
|
|
20580
|
-
};
|
|
20581
|
-
}
|
|
20582
|
-
},
|
|
20583
|
-
listLevel: {
|
|
20584
|
-
default: null,
|
|
20585
|
-
parseDOM: (elem) => {
|
|
20586
|
-
let listLevel = elem.getAttribute("data-list-level");
|
|
20587
|
-
try {
|
|
20588
|
-
listLevel = JSON.parse(listLevel);
|
|
20589
|
-
} catch {
|
|
20590
|
-
}
|
|
20591
|
-
return listLevel;
|
|
20592
|
-
},
|
|
20593
|
-
renderDOM: (attrs) => {
|
|
20594
|
-
if (!attrs.listLevel) return {};
|
|
20595
|
-
return {
|
|
20596
|
-
"data-list-level": JSON.stringify(attrs.listLevel)
|
|
20597
|
-
};
|
|
20598
|
-
}
|
|
20599
|
-
},
|
|
20600
|
-
// JC = justification. Expect left, right, center
|
|
20601
|
-
lvlJc: {
|
|
20602
|
-
keepOnSplit: true,
|
|
20603
|
-
default: null,
|
|
20604
|
-
rendered: false
|
|
20605
|
-
},
|
|
20606
|
-
// This will contain indentation and space info.
|
|
20607
|
-
// ie: w:left (left indent), w:hanging (hanging indent)
|
|
20608
|
-
listParagraphProperties: {
|
|
20609
|
-
keepOnSplit: true,
|
|
20610
|
-
default: null,
|
|
20611
|
-
rendered: false
|
|
20612
|
-
},
|
|
20613
|
-
// This will contain run properties for the list item
|
|
20614
|
-
listRunProperties: {
|
|
20615
|
-
keepOnSplit: true,
|
|
20616
|
-
default: null,
|
|
20617
|
-
rendered: false
|
|
20618
|
-
},
|
|
20619
|
-
numId: {
|
|
20620
|
-
keepOnSplit: true,
|
|
20621
|
-
default: null,
|
|
20622
|
-
parseDOM: (elem) => elem.getAttribute("data-num-id"),
|
|
20623
|
-
renderDOM: (attrs) => {
|
|
20624
|
-
if (!attrs.numId) return {};
|
|
20625
|
-
return {
|
|
20626
|
-
"data-num-id": attrs.numId
|
|
20627
|
-
};
|
|
20628
|
-
}
|
|
20629
|
-
},
|
|
20630
|
-
numPrType: {
|
|
20631
|
-
rendered: false,
|
|
20632
|
-
default: "inline",
|
|
20633
|
-
keepOnSplit: true
|
|
20634
|
-
},
|
|
20635
|
-
level: {
|
|
20636
|
-
parseDOM: (elem) => {
|
|
20637
|
-
return elem.getAttribute("data-level");
|
|
20638
|
-
},
|
|
20639
|
-
renderDOM: (attrs) => {
|
|
20640
|
-
if (attrs.level === void 0 || attrs.level === null) return {};
|
|
20641
|
-
return {
|
|
20642
|
-
"data-level": attrs.level
|
|
20643
|
-
};
|
|
20644
|
-
}
|
|
20645
|
-
},
|
|
20646
|
-
attributes: {
|
|
20647
|
-
keepOnSplit: true,
|
|
20648
|
-
rendered: false
|
|
20649
|
-
},
|
|
20650
|
-
spacing: {
|
|
20651
|
-
keepOnSplit: true,
|
|
20652
|
-
default: null,
|
|
20653
|
-
rendered: false
|
|
20654
|
-
},
|
|
20655
|
-
indent: {
|
|
20656
|
-
parseDOM: (elem) => JSON.parse(elem.getAttribute("data-indent")),
|
|
20657
|
-
keepOnSplit: true,
|
|
20658
|
-
default: null,
|
|
20659
|
-
rendered: false
|
|
20660
|
-
},
|
|
20661
|
-
markerStyle: {
|
|
20662
|
-
default: null,
|
|
20663
|
-
rendered: false,
|
|
20664
|
-
keepOnSplit: true
|
|
20665
|
-
},
|
|
20666
|
-
styleId: {
|
|
20667
|
-
rendered: false,
|
|
20668
|
-
keepOnSplit: true
|
|
20669
|
-
},
|
|
20670
|
-
customFormat: {
|
|
20671
|
-
default: null,
|
|
20672
|
-
rendered: false,
|
|
20673
|
-
keepOnSplit: true
|
|
20674
|
-
},
|
|
20675
|
-
importedFontFamily: {
|
|
20676
|
-
parseDOM: (elem) => elem.getAttribute("data-font-family"),
|
|
20677
|
-
renderDOM: (attrs) => {
|
|
20678
|
-
if (!attrs.importedFontFamily) return {};
|
|
20679
|
-
return {
|
|
20680
|
-
"data-font-family": attrs.importedFontFamily
|
|
20681
|
-
};
|
|
20682
|
-
}
|
|
20683
|
-
},
|
|
20684
|
-
importedFontSize: {
|
|
20685
|
-
parseDOM: (elem) => elem.getAttribute("data-font-size"),
|
|
20686
|
-
renderDOM: (attrs) => {
|
|
20687
|
-
if (!attrs.importedFontSize) return {};
|
|
20688
|
-
return {
|
|
20689
|
-
"data-font-size": attrs.importedFontSize
|
|
20690
|
-
};
|
|
20691
|
-
}
|
|
20692
|
-
}
|
|
20693
|
-
};
|
|
20694
|
-
},
|
|
20695
|
-
addShortcuts() {
|
|
20696
|
-
return {
|
|
20697
|
-
Enter: () => {
|
|
20698
|
-
return this.editor.commands.splitListItem();
|
|
20699
|
-
},
|
|
20700
|
-
"Shift-Enter": () => {
|
|
20701
|
-
return this.editor.commands.first(({ commands: commands2 }) => [
|
|
20702
|
-
() => commands2.createParagraphNear(),
|
|
20703
|
-
() => commands2.splitBlock()
|
|
20704
|
-
]);
|
|
20705
|
-
},
|
|
20706
|
-
Tab: () => {
|
|
20707
|
-
return this.editor.commands.first(({ commands: commands2 }) => [() => commands2.increaseListIndent()]);
|
|
20708
|
-
},
|
|
20709
|
-
"Shift-Tab": () => {
|
|
20710
|
-
return this.editor.commands.first(({ commands: commands2 }) => [() => commands2.decreaseListIndent()]);
|
|
20711
|
-
}
|
|
20712
|
-
};
|
|
20713
|
-
}
|
|
20714
|
-
});
|
|
20715
|
-
const getDefaultSpacing = () => ({
|
|
20716
|
-
lineSpaceAfter: 0,
|
|
20717
|
-
lineSpaceBefore: 0,
|
|
20718
|
-
line: 0,
|
|
20719
|
-
lineRule: null
|
|
20720
|
-
});
|
|
19728
|
+
const bulletInputRegex = /^\s*([-+*])\s$/;
|
|
19729
|
+
const orderedInputRegex = /^(\d+)\.\s$/;
|
|
20721
19730
|
const Paragraph = OxmlNode.create({
|
|
20722
19731
|
name: "paragraph",
|
|
20723
19732
|
oXmlName: "w:p",
|
|
@@ -20745,22 +19754,26 @@ const Paragraph = OxmlNode.create({
|
|
|
20745
19754
|
parseDOM: (element) => {
|
|
20746
19755
|
if (element && element.closest("[data-superdoc-import]")) {
|
|
20747
19756
|
return {
|
|
20748
|
-
|
|
20749
|
-
|
|
20750
|
-
line: 1.15,
|
|
19757
|
+
after: pixelsToTwips(11),
|
|
19758
|
+
before: 0,
|
|
19759
|
+
line: linesToTwips(1.15),
|
|
20751
19760
|
lineRule: "auto"
|
|
20752
19761
|
};
|
|
20753
19762
|
}
|
|
20754
19763
|
return void 0;
|
|
20755
19764
|
},
|
|
20756
19765
|
renderDOM: (attrs) => {
|
|
20757
|
-
const { spacing } = attrs;
|
|
20758
|
-
if (!spacing) return {};
|
|
19766
|
+
const { spacing, marksAttrs } = attrs;
|
|
19767
|
+
if (!spacing) return { style: null };
|
|
20759
19768
|
const spacingCopy = { ...spacing };
|
|
20760
19769
|
if (attrs.lineHeight) delete spacingCopy.line;
|
|
20761
|
-
const style = getSpacingStyleString(
|
|
19770
|
+
const style = getSpacingStyleString(
|
|
19771
|
+
spacingCopy,
|
|
19772
|
+
marksAttrs ?? [],
|
|
19773
|
+
Boolean(attrs.paragraphProperties?.numberingProperties)
|
|
19774
|
+
);
|
|
20762
19775
|
if (style) return { style };
|
|
20763
|
-
return {};
|
|
19776
|
+
return { style: null };
|
|
20764
19777
|
}
|
|
20765
19778
|
},
|
|
20766
19779
|
extraAttrs: {
|
|
@@ -20788,17 +19801,17 @@ const Paragraph = OxmlNode.create({
|
|
|
20788
19801
|
indent: {
|
|
20789
19802
|
default: null,
|
|
20790
19803
|
renderDOM: ({ indent }) => {
|
|
20791
|
-
if (!indent) return {};
|
|
19804
|
+
if (!indent) return { style: null };
|
|
20792
19805
|
const { left: left2, right: right2, firstLine, hanging } = indent;
|
|
20793
19806
|
if (indent && Object.values(indent).every((v) => v === 0)) {
|
|
20794
|
-
return {};
|
|
19807
|
+
return { style: null };
|
|
20795
19808
|
}
|
|
20796
19809
|
let style = "";
|
|
20797
|
-
if (left2) style += `margin-left: ${left2}px;`;
|
|
20798
|
-
if (right2) style += `margin-right: ${right2}px;`;
|
|
20799
|
-
if (firstLine && !hanging) style += `text-indent: ${firstLine}px;`;
|
|
20800
|
-
if (firstLine && hanging) style += `text-indent: ${firstLine - hanging}px;`;
|
|
20801
|
-
if (!firstLine && hanging) style += `text-indent: ${-hanging}px;`;
|
|
19810
|
+
if (left2) style += `margin-left: ${twipsToPixels(left2)}px;`;
|
|
19811
|
+
if (right2) style += `margin-right: ${twipsToPixels(right2)}px;`;
|
|
19812
|
+
if (firstLine && !hanging) style += `text-indent: ${twipsToPixels(firstLine)}px;`;
|
|
19813
|
+
if (firstLine && hanging) style += `text-indent: ${twipsToPixels(firstLine - hanging)}px;`;
|
|
19814
|
+
if (!firstLine && hanging) style += `text-indent: ${twipsToPixels(-hanging)}px;`;
|
|
20802
19815
|
return { style };
|
|
20803
19816
|
}
|
|
20804
19817
|
},
|
|
@@ -20817,12 +19830,16 @@ const Paragraph = OxmlNode.create({
|
|
|
20817
19830
|
sideOrder.forEach((side) => {
|
|
20818
19831
|
const b = borders[side];
|
|
20819
19832
|
if (!b) return;
|
|
20820
|
-
|
|
19833
|
+
if (["nil", "none", void 0, null].includes(b.val)) {
|
|
19834
|
+
style += `border-${side}: none;`;
|
|
19835
|
+
return;
|
|
19836
|
+
}
|
|
19837
|
+
const width = b.size != null ? `${eighthPointsToPixels(b.size)}px` : "1px";
|
|
20821
19838
|
const cssStyle = valToCss[b.val] || "solid";
|
|
20822
|
-
const color = b.color || "#000000"
|
|
19839
|
+
const color = !b.color || b.color === "auto" ? "#000000" : `#${b.color}`;
|
|
20823
19840
|
style += `border-${side}: ${width} ${cssStyle} ${color};`;
|
|
20824
19841
|
if (b.space != null && side === "bottom") {
|
|
20825
|
-
style += `padding-bottom: ${b.space}px;`;
|
|
19842
|
+
style += `padding-bottom: ${eighthPointsToPixels(b.space)}px;`;
|
|
20826
19843
|
}
|
|
20827
19844
|
});
|
|
20828
19845
|
return style ? { style } : {};
|
|
@@ -20854,19 +19871,37 @@ const Paragraph = OxmlNode.create({
|
|
|
20854
19871
|
paragraphProperties: { rendered: false },
|
|
20855
19872
|
dropcap: { rendered: false },
|
|
20856
19873
|
pageBreakSource: { rendered: false },
|
|
20857
|
-
|
|
20858
|
-
renderDOM: ({
|
|
20859
|
-
|
|
20860
|
-
if (!jc) return {};
|
|
19874
|
+
textAlign: {
|
|
19875
|
+
renderDOM: ({ textAlign }) => {
|
|
19876
|
+
if (!textAlign) return {};
|
|
20861
19877
|
let style = "";
|
|
20862
|
-
if (
|
|
20863
|
-
else if (
|
|
20864
|
-
else if (
|
|
20865
|
-
else if (
|
|
19878
|
+
if (textAlign === "left") style += "text-align: left;";
|
|
19879
|
+
else if (textAlign === "right") style += "text-align: right;";
|
|
19880
|
+
else if (textAlign === "center") style += "text-align: center;";
|
|
19881
|
+
else if (textAlign === "both") style += "text-align: justify;";
|
|
20866
19882
|
return { style };
|
|
20867
19883
|
}
|
|
20868
19884
|
},
|
|
20869
|
-
tabStops: { rendered: false }
|
|
19885
|
+
tabStops: { rendered: false },
|
|
19886
|
+
listRendering: {
|
|
19887
|
+
keepOnSplit: false,
|
|
19888
|
+
renderDOM: ({ listRendering }) => {
|
|
19889
|
+
return {
|
|
19890
|
+
"data-marker-type": listRendering?.markerText,
|
|
19891
|
+
"data-list-level": listRendering?.path ? JSON.stringify(listRendering.path) : null,
|
|
19892
|
+
"data-list-numbering-type": listRendering?.numberingType
|
|
19893
|
+
};
|
|
19894
|
+
}
|
|
19895
|
+
},
|
|
19896
|
+
numberingProperties: {
|
|
19897
|
+
keepOnSplit: true,
|
|
19898
|
+
renderDOM: ({ numberingProperties }) => {
|
|
19899
|
+
return {
|
|
19900
|
+
"data-num-id": numberingProperties?.numId,
|
|
19901
|
+
"data-level": numberingProperties?.ilvl
|
|
19902
|
+
};
|
|
19903
|
+
}
|
|
19904
|
+
}
|
|
20870
19905
|
};
|
|
20871
19906
|
},
|
|
20872
19907
|
parseDOM() {
|
|
@@ -20874,12 +19909,59 @@ const Paragraph = OxmlNode.create({
|
|
|
20874
19909
|
{
|
|
20875
19910
|
tag: "p",
|
|
20876
19911
|
getAttrs: (node) => {
|
|
20877
|
-
const
|
|
20878
|
-
|
|
19912
|
+
const numberingProperties = {};
|
|
19913
|
+
let indent, spacing;
|
|
19914
|
+
const { styleid: styleId, ...extraAttrs } = Array.from(node.attributes).reduce((acc, attr) => {
|
|
19915
|
+
if (attr.name === "data-num-id") {
|
|
19916
|
+
numberingProperties.numId = parseInt(attr.value);
|
|
19917
|
+
} else if (attr.name === "data-level") {
|
|
19918
|
+
numberingProperties.ilvl = parseInt(attr.value);
|
|
19919
|
+
} else if (attr.name === "data-indent") {
|
|
19920
|
+
try {
|
|
19921
|
+
indent = JSON.parse(attr.value);
|
|
19922
|
+
Object.keys(indent).forEach((key2) => {
|
|
19923
|
+
indent[key2] = Number(indent[key2]);
|
|
19924
|
+
});
|
|
19925
|
+
} catch {
|
|
19926
|
+
}
|
|
19927
|
+
} else if (attr.name === "data-spacing") {
|
|
19928
|
+
try {
|
|
19929
|
+
spacing = JSON.parse(attr.value);
|
|
19930
|
+
Object.keys(spacing).forEach((key2) => {
|
|
19931
|
+
spacing[key2] = Number(spacing[key2]);
|
|
19932
|
+
});
|
|
19933
|
+
} catch {
|
|
19934
|
+
}
|
|
19935
|
+
} else {
|
|
19936
|
+
acc[attr.name] = attr.value;
|
|
19937
|
+
}
|
|
20879
19938
|
return acc;
|
|
20880
19939
|
}, {});
|
|
19940
|
+
if (Object.keys(numberingProperties).length > 0) {
|
|
19941
|
+
const resolvedParagraphProperties = resolveParagraphProperties(
|
|
19942
|
+
{ docx: this.editor.converter.convertedXml, numbering: this.editor.converter.numbering },
|
|
19943
|
+
{ styleId, numberingProperties, indent, spacing },
|
|
19944
|
+
false,
|
|
19945
|
+
true
|
|
19946
|
+
);
|
|
19947
|
+
return {
|
|
19948
|
+
paragraphProperties: {
|
|
19949
|
+
numberingProperties,
|
|
19950
|
+
indent,
|
|
19951
|
+
spacing,
|
|
19952
|
+
styleId: styleId || null
|
|
19953
|
+
},
|
|
19954
|
+
indent: resolvedParagraphProperties.indent,
|
|
19955
|
+
spacing: resolvedParagraphProperties.spacing,
|
|
19956
|
+
numberingProperties,
|
|
19957
|
+
styleId: styleId || null,
|
|
19958
|
+
extraAttrs
|
|
19959
|
+
};
|
|
19960
|
+
}
|
|
20881
19961
|
return {
|
|
20882
|
-
styleId:
|
|
19962
|
+
styleId: styleId || null,
|
|
19963
|
+
indent,
|
|
19964
|
+
spacing,
|
|
20883
19965
|
extraAttrs
|
|
20884
19966
|
};
|
|
20885
19967
|
}
|
|
@@ -20907,6 +19989,101 @@ const Paragraph = OxmlNode.create({
|
|
|
20907
19989
|
renderDOM({ htmlAttributes }) {
|
|
20908
19990
|
return ["p", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
|
|
20909
19991
|
},
|
|
19992
|
+
addNodeView() {
|
|
19993
|
+
if (shouldSkipNodeView(this.editor)) return null;
|
|
19994
|
+
return ({ node, editor, getPos, decorations, extensionAttrs }) => {
|
|
19995
|
+
return new ParagraphNodeView(node, editor, getPos, decorations, extensionAttrs);
|
|
19996
|
+
};
|
|
19997
|
+
},
|
|
19998
|
+
addShortcuts() {
|
|
19999
|
+
return {
|
|
20000
|
+
"Mod-Shift-7": () => {
|
|
20001
|
+
return this.editor.commands.toggleOrderedList();
|
|
20002
|
+
},
|
|
20003
|
+
"Mod-Shift-8": () => {
|
|
20004
|
+
return this.editor.commands.toggleBulletList();
|
|
20005
|
+
},
|
|
20006
|
+
Enter: (params2) => {
|
|
20007
|
+
return removeNumberingProperties({ checkType: "empty" })({
|
|
20008
|
+
...params2,
|
|
20009
|
+
tr: this.editor.state.tr,
|
|
20010
|
+
state: this.editor.state,
|
|
20011
|
+
dispatch: this.editor.view.dispatch
|
|
20012
|
+
});
|
|
20013
|
+
},
|
|
20014
|
+
"Shift-Enter": () => {
|
|
20015
|
+
return this.editor.commands.first(({ commands: commands2 }) => [
|
|
20016
|
+
() => commands2.createParagraphNear(),
|
|
20017
|
+
splitBlock$1({
|
|
20018
|
+
attrsToRemoveOverride: ["paragraphProperties.numberingProperties", "listRendering", "numberingProperties"]
|
|
20019
|
+
})
|
|
20020
|
+
]);
|
|
20021
|
+
},
|
|
20022
|
+
Tab: () => {
|
|
20023
|
+
return this.editor.commands.first(({ commands: commands2 }) => [() => commands2.increaseListIndent()]);
|
|
20024
|
+
},
|
|
20025
|
+
"Shift-Tab": () => {
|
|
20026
|
+
return this.editor.commands.first(({ commands: commands2 }) => [() => commands2.decreaseListIndent()]);
|
|
20027
|
+
}
|
|
20028
|
+
};
|
|
20029
|
+
},
|
|
20030
|
+
addInputRules() {
|
|
20031
|
+
return [
|
|
20032
|
+
{ regex: orderedInputRegex, type: "orderedList" },
|
|
20033
|
+
{ regex: bulletInputRegex, type: "bulletList" }
|
|
20034
|
+
].map(
|
|
20035
|
+
({ regex, type }) => new InputRule({
|
|
20036
|
+
match: regex,
|
|
20037
|
+
handler: ({ state, range }) => {
|
|
20038
|
+
const parentListItem = findParentNode(isList)(state.selection);
|
|
20039
|
+
if (parentListItem) {
|
|
20040
|
+
return null;
|
|
20041
|
+
}
|
|
20042
|
+
const { tr } = state;
|
|
20043
|
+
tr.delete(range.from, range.to);
|
|
20044
|
+
ListHelpers.createNewList({
|
|
20045
|
+
listType: type,
|
|
20046
|
+
tr,
|
|
20047
|
+
editor: this.editor
|
|
20048
|
+
});
|
|
20049
|
+
}
|
|
20050
|
+
})
|
|
20051
|
+
);
|
|
20052
|
+
},
|
|
20053
|
+
addCommands() {
|
|
20054
|
+
return {
|
|
20055
|
+
/**
|
|
20056
|
+
* Toggle ordered list formatting
|
|
20057
|
+
* @category Command
|
|
20058
|
+
* @example
|
|
20059
|
+
* editor.commands.toggleOrderedList()
|
|
20060
|
+
* @note Converts selection to ordered list or back to paragraphs
|
|
20061
|
+
*/
|
|
20062
|
+
toggleOrderedList: () => (params2) => {
|
|
20063
|
+
return toggleList("orderedList")(params2);
|
|
20064
|
+
},
|
|
20065
|
+
/**
|
|
20066
|
+
* Toggle a bullet list at the current selection
|
|
20067
|
+
* @category Command
|
|
20068
|
+
* @example
|
|
20069
|
+
* // Toggle bullet list on selected text
|
|
20070
|
+
* editor.commands.toggleBulletList()
|
|
20071
|
+
* @note Converts selected paragraphs to list items or removes list formatting
|
|
20072
|
+
*/
|
|
20073
|
+
toggleBulletList: () => (params2) => {
|
|
20074
|
+
return toggleList("bulletList")(params2);
|
|
20075
|
+
},
|
|
20076
|
+
/**
|
|
20077
|
+
* Restart numbering for the current list
|
|
20078
|
+
* @category Command
|
|
20079
|
+
* @example
|
|
20080
|
+
* // Restart numbering for the current list item
|
|
20081
|
+
* editor.commands.restartNumbering()
|
|
20082
|
+
* @note Resets list numbering for the current list item and following items
|
|
20083
|
+
*/
|
|
20084
|
+
restartNumbering: () => restartNumbering
|
|
20085
|
+
};
|
|
20086
|
+
},
|
|
20910
20087
|
addPmPlugins() {
|
|
20911
20088
|
const { view } = this.editor;
|
|
20912
20089
|
const dropcapWidthCache = /* @__PURE__ */ new Map();
|
|
@@ -20980,7 +20157,8 @@ const Paragraph = OxmlNode.create({
|
|
|
20980
20157
|
}
|
|
20981
20158
|
}
|
|
20982
20159
|
});
|
|
20983
|
-
|
|
20160
|
+
const numberingPlugin = createNumberingPlugin(this.editor);
|
|
20161
|
+
return [dropcapPlugin, numberingPlugin];
|
|
20984
20162
|
}
|
|
20985
20163
|
});
|
|
20986
20164
|
const getDropcapDecorations = (state, view, widthCache) => {
|
|
@@ -21177,259 +20355,6 @@ const CommentsMark = Mark.create({
|
|
|
21177
20355
|
return [CommentMarkName, Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
21178
20356
|
}
|
|
21179
20357
|
});
|
|
21180
|
-
const defaultTabDistance = 48;
|
|
21181
|
-
const defaultLineLength = 816;
|
|
21182
|
-
const getTabDecorations = (doc2, view, helpers2, from2 = 0, to = null) => {
|
|
21183
|
-
const decorations = [];
|
|
21184
|
-
const paragraphCache = /* @__PURE__ */ new Map();
|
|
21185
|
-
const coordCache = /* @__PURE__ */ new Map();
|
|
21186
|
-
const domPosCache = /* @__PURE__ */ new Map();
|
|
21187
|
-
const end2 = to ?? doc2.content.size;
|
|
21188
|
-
doc2.nodesBetween(from2, end2, (node, pos) => {
|
|
21189
|
-
if (node.type.name !== "tab") return;
|
|
21190
|
-
let extraStyles = "";
|
|
21191
|
-
const $pos = doc2.resolve(pos);
|
|
21192
|
-
const paragraphContext = getParagraphContext($pos, paragraphCache, helpers2);
|
|
21193
|
-
if (!paragraphContext) return;
|
|
21194
|
-
try {
|
|
21195
|
-
const { tabStops, flattened, positionMap, startPos } = paragraphContext;
|
|
21196
|
-
const entryIndex = positionMap.get(pos);
|
|
21197
|
-
if (entryIndex === void 0) return;
|
|
21198
|
-
if (paragraphContext.indentWidth === void 0) {
|
|
21199
|
-
paragraphContext.indentWidth = getIndentWidth(view, startPos, paragraphContext.indent, coordCache, domPosCache);
|
|
21200
|
-
}
|
|
21201
|
-
if (paragraphContext.tabHeight === void 0) {
|
|
21202
|
-
paragraphContext.tabHeight = calcTabHeight($pos);
|
|
21203
|
-
}
|
|
21204
|
-
const indentWidth = paragraphContext.indentWidth;
|
|
21205
|
-
const accumulatedTabWidth = paragraphContext.accumulatedTabWidth || 0;
|
|
21206
|
-
const currentWidth = indentWidth + measureRangeWidth(view, startPos + 1, pos, coordCache, domPosCache) + accumulatedTabWidth;
|
|
21207
|
-
let tabWidth;
|
|
21208
|
-
if (tabStops.length) {
|
|
21209
|
-
const tabStop = tabStops.find((stop) => stop.pos > currentWidth && stop.val !== "clear");
|
|
21210
|
-
if (tabStop) {
|
|
21211
|
-
tabWidth = tabStop.pos - currentWidth;
|
|
21212
|
-
if (tabStop.val === "center" || tabStop.val === "end" || tabStop.val === "right") {
|
|
21213
|
-
const nextTabIndex = findNextTabIndex(flattened, entryIndex + 1);
|
|
21214
|
-
const segmentStartPos = pos + node.nodeSize;
|
|
21215
|
-
const segmentEndPos = nextTabIndex === -1 ? startPos + paragraphContext.paragraph.nodeSize - 1 : flattened[nextTabIndex].pos;
|
|
21216
|
-
const segmentWidth = measureRangeWidth(view, segmentStartPos, segmentEndPos, coordCache, domPosCache);
|
|
21217
|
-
tabWidth -= tabStop.val === "center" ? segmentWidth / 2 : segmentWidth;
|
|
21218
|
-
} else if (tabStop.val === "decimal" || tabStop.val === "num") {
|
|
21219
|
-
const breakChar = tabStop.decimalChar || ".";
|
|
21220
|
-
const decimalPos = findDecimalBreakPos(flattened, entryIndex + 1, breakChar);
|
|
21221
|
-
const integralWidth = decimalPos ? measureRangeWidth(view, pos + node.nodeSize, decimalPos, coordCache, domPosCache) : measureRangeWidth(
|
|
21222
|
-
view,
|
|
21223
|
-
pos + node.nodeSize,
|
|
21224
|
-
startPos + paragraphContext.paragraph.nodeSize - 1,
|
|
21225
|
-
coordCache,
|
|
21226
|
-
domPosCache
|
|
21227
|
-
);
|
|
21228
|
-
tabWidth -= integralWidth;
|
|
21229
|
-
}
|
|
21230
|
-
if (tabStop.leader) {
|
|
21231
|
-
const leaderStyles = {
|
|
21232
|
-
dot: "border-bottom: 1px dotted black;",
|
|
21233
|
-
heavy: "border-bottom: 2px solid black;",
|
|
21234
|
-
hyphen: "border-bottom: 1px solid black;",
|
|
21235
|
-
middleDot: "border-bottom: 1px dotted black; margin-bottom: 2px;",
|
|
21236
|
-
underscore: "border-bottom: 1px solid black;"
|
|
21237
|
-
};
|
|
21238
|
-
extraStyles += leaderStyles[tabStop.leader] || "";
|
|
21239
|
-
}
|
|
21240
|
-
}
|
|
21241
|
-
}
|
|
21242
|
-
if (!tabWidth || tabWidth < 1) {
|
|
21243
|
-
tabWidth = defaultTabDistance - currentWidth % defaultLineLength % defaultTabDistance;
|
|
21244
|
-
if (tabWidth === 0) tabWidth = defaultTabDistance;
|
|
21245
|
-
}
|
|
21246
|
-
const tabHeight = paragraphContext.tabHeight;
|
|
21247
|
-
decorations.push(
|
|
21248
|
-
Decoration.node(pos, pos + node.nodeSize, {
|
|
21249
|
-
style: `width: ${tabWidth}px; height: ${tabHeight};${extraStyles}`
|
|
21250
|
-
})
|
|
21251
|
-
);
|
|
21252
|
-
paragraphContext.accumulatedTabWidth = accumulatedTabWidth + tabWidth;
|
|
21253
|
-
} catch (error) {
|
|
21254
|
-
console.error("tab decoration error", error);
|
|
21255
|
-
}
|
|
21256
|
-
});
|
|
21257
|
-
return decorations;
|
|
21258
|
-
};
|
|
21259
|
-
function getParagraphContext($pos, cache, helpers2) {
|
|
21260
|
-
for (let depth = $pos.depth; depth >= 0; depth--) {
|
|
21261
|
-
const node = $pos.node(depth);
|
|
21262
|
-
if (node?.type?.name === "paragraph") {
|
|
21263
|
-
const startPos = $pos.start(depth);
|
|
21264
|
-
if (!cache.has(startPos)) {
|
|
21265
|
-
let tabStops = [];
|
|
21266
|
-
if (Array.isArray(node.attrs?.tabStops)) {
|
|
21267
|
-
tabStops = node.attrs.tabStops;
|
|
21268
|
-
} else {
|
|
21269
|
-
const style = helpers2.linkedStyles.getStyleById(node.attrs?.styleId);
|
|
21270
|
-
if (Array.isArray(style?.definition?.styles?.tabStops)) {
|
|
21271
|
-
tabStops = style.definition.styles.tabStops;
|
|
21272
|
-
}
|
|
21273
|
-
}
|
|
21274
|
-
const { entries, positionMap } = flattenParagraph(node, startPos);
|
|
21275
|
-
cache.set(startPos, {
|
|
21276
|
-
paragraph: node,
|
|
21277
|
-
paragraphDepth: depth,
|
|
21278
|
-
startPos,
|
|
21279
|
-
indent: node.attrs?.indent || {},
|
|
21280
|
-
tabStops,
|
|
21281
|
-
flattened: entries,
|
|
21282
|
-
positionMap,
|
|
21283
|
-
// Store position map for O(1) lookups
|
|
21284
|
-
accumulatedTabWidth: 0
|
|
21285
|
-
});
|
|
21286
|
-
}
|
|
21287
|
-
return cache.get(startPos);
|
|
21288
|
-
}
|
|
21289
|
-
}
|
|
21290
|
-
return null;
|
|
21291
|
-
}
|
|
21292
|
-
function flattenParagraph(paragraph, paragraphStartPos) {
|
|
21293
|
-
const entries = [];
|
|
21294
|
-
const positionMap = /* @__PURE__ */ new Map();
|
|
21295
|
-
const walk = (node, basePos) => {
|
|
21296
|
-
if (!node) return;
|
|
21297
|
-
if (node.type?.name === "run") {
|
|
21298
|
-
node.forEach((child, offset2) => {
|
|
21299
|
-
const childPos = basePos + offset2 + 1;
|
|
21300
|
-
walk(child, childPos);
|
|
21301
|
-
});
|
|
21302
|
-
return;
|
|
21303
|
-
}
|
|
21304
|
-
const pos = basePos - 1;
|
|
21305
|
-
const index2 = entries.length;
|
|
21306
|
-
entries.push({ node, pos });
|
|
21307
|
-
positionMap.set(pos, index2);
|
|
21308
|
-
};
|
|
21309
|
-
paragraph.forEach((child, offset2) => {
|
|
21310
|
-
const childPos = paragraphStartPos + offset2 + 1;
|
|
21311
|
-
walk(child, childPos);
|
|
21312
|
-
});
|
|
21313
|
-
return { entries, positionMap };
|
|
21314
|
-
}
|
|
21315
|
-
function findNextTabIndex(flattened, fromIndex) {
|
|
21316
|
-
for (let i = fromIndex; i < flattened.length; i++) {
|
|
21317
|
-
if (flattened[i]?.node?.type?.name === "tab") {
|
|
21318
|
-
return i;
|
|
21319
|
-
}
|
|
21320
|
-
}
|
|
21321
|
-
return -1;
|
|
21322
|
-
}
|
|
21323
|
-
function findDecimalBreakPos(flattened, startIndex, breakChar) {
|
|
21324
|
-
for (let i = startIndex; i < flattened.length; i++) {
|
|
21325
|
-
const entry = flattened[i];
|
|
21326
|
-
if (!entry) break;
|
|
21327
|
-
if (entry.node.type?.name === "tab") break;
|
|
21328
|
-
if (entry.node.type?.name === "text") {
|
|
21329
|
-
const index2 = entry.node.text?.indexOf(breakChar);
|
|
21330
|
-
if (index2 !== void 0 && index2 !== -1) {
|
|
21331
|
-
return entry.pos + index2 + 1;
|
|
21332
|
-
}
|
|
21333
|
-
}
|
|
21334
|
-
}
|
|
21335
|
-
return null;
|
|
21336
|
-
}
|
|
21337
|
-
function measureRangeWidth(view, from2, to, coordCache = null, domPosCache = null) {
|
|
21338
|
-
if (!Number.isFinite(from2) || !Number.isFinite(to) || to <= from2) return 0;
|
|
21339
|
-
try {
|
|
21340
|
-
const range = document.createRange();
|
|
21341
|
-
const fromRef = getCachedDomAtPos(view, from2, domPosCache);
|
|
21342
|
-
const toRef = getCachedDomAtPos(view, to, domPosCache);
|
|
21343
|
-
range.setStart(fromRef.node, fromRef.offset);
|
|
21344
|
-
range.setEnd(toRef.node, toRef.offset);
|
|
21345
|
-
const rect = range.getBoundingClientRect();
|
|
21346
|
-
range.detach?.();
|
|
21347
|
-
return rect.width || 0;
|
|
21348
|
-
} catch {
|
|
21349
|
-
const startLeft = getLeftCoord(view, from2, coordCache, domPosCache);
|
|
21350
|
-
const endLeft = getLeftCoord(view, to, coordCache, domPosCache);
|
|
21351
|
-
if (startLeft == null || endLeft == null) return 0;
|
|
21352
|
-
return Math.max(0, endLeft - startLeft);
|
|
21353
|
-
}
|
|
21354
|
-
}
|
|
21355
|
-
function getIndentWidth(view, paragraphStartPos, indentAttrs = {}, coordCache = null, domPosCache = null) {
|
|
21356
|
-
const marginLeft = getLeftCoord(view, paragraphStartPos, coordCache, domPosCache);
|
|
21357
|
-
const lineLeft = getLeftCoord(view, paragraphStartPos + 1, coordCache, domPosCache);
|
|
21358
|
-
if (marginLeft != null && lineLeft != null) {
|
|
21359
|
-
const diff = lineLeft - marginLeft;
|
|
21360
|
-
if (!Number.isNaN(diff) && Math.abs(diff) > 0.5) {
|
|
21361
|
-
return diff;
|
|
21362
|
-
}
|
|
21363
|
-
}
|
|
21364
|
-
return calculateIndentFallback(indentAttrs);
|
|
21365
|
-
}
|
|
21366
|
-
function calculateIndentFallback(indentAttrs = {}) {
|
|
21367
|
-
if (!indentAttrs) return 0;
|
|
21368
|
-
const left2 = Number(indentAttrs.left) || 0;
|
|
21369
|
-
const firstLine = Number(indentAttrs.firstLine) || 0;
|
|
21370
|
-
const hanging = Number(indentAttrs.hanging) || 0;
|
|
21371
|
-
let textIndent = 0;
|
|
21372
|
-
if (firstLine && hanging) {
|
|
21373
|
-
textIndent = firstLine - hanging;
|
|
21374
|
-
} else if (firstLine) {
|
|
21375
|
-
textIndent = firstLine;
|
|
21376
|
-
} else if (hanging) {
|
|
21377
|
-
textIndent = -hanging;
|
|
21378
|
-
} else if (typeof indentAttrs.textIndent === "string") {
|
|
21379
|
-
const match = indentAttrs.textIndent.match(/(-?\d*\.?\d+)in$/);
|
|
21380
|
-
if (match) {
|
|
21381
|
-
textIndent = Number(match[1]) * 96;
|
|
21382
|
-
}
|
|
21383
|
-
}
|
|
21384
|
-
if (textIndent) return left2 + textIndent;
|
|
21385
|
-
if (left2) return left2;
|
|
21386
|
-
return 0;
|
|
21387
|
-
}
|
|
21388
|
-
function getLeftCoord(view, pos, coordCache = null, domPosCache = null) {
|
|
21389
|
-
if (!Number.isFinite(pos)) return null;
|
|
21390
|
-
if (coordCache && coordCache.has(pos)) {
|
|
21391
|
-
return coordCache.get(pos);
|
|
21392
|
-
}
|
|
21393
|
-
let result = null;
|
|
21394
|
-
try {
|
|
21395
|
-
result = view.coordsAtPos(pos).left;
|
|
21396
|
-
} catch {
|
|
21397
|
-
try {
|
|
21398
|
-
const ref2 = getCachedDomAtPos(view, pos, domPosCache);
|
|
21399
|
-
const range = document.createRange();
|
|
21400
|
-
range.setStart(ref2.node, ref2.offset);
|
|
21401
|
-
range.setEnd(ref2.node, ref2.offset);
|
|
21402
|
-
const rect = range.getBoundingClientRect();
|
|
21403
|
-
range.detach?.();
|
|
21404
|
-
result = rect.left;
|
|
21405
|
-
} catch {
|
|
21406
|
-
result = null;
|
|
21407
|
-
}
|
|
21408
|
-
}
|
|
21409
|
-
if (coordCache) {
|
|
21410
|
-
coordCache.set(pos, result);
|
|
21411
|
-
}
|
|
21412
|
-
return result;
|
|
21413
|
-
}
|
|
21414
|
-
function getCachedDomAtPos(view, pos, domPosCache = null) {
|
|
21415
|
-
if (domPosCache && domPosCache.has(pos)) {
|
|
21416
|
-
return domPosCache.get(pos);
|
|
21417
|
-
}
|
|
21418
|
-
const result = view.domAtPos(pos);
|
|
21419
|
-
if (domPosCache) {
|
|
21420
|
-
domPosCache.set(pos, result);
|
|
21421
|
-
}
|
|
21422
|
-
return result;
|
|
21423
|
-
}
|
|
21424
|
-
function calcTabHeight(pos) {
|
|
21425
|
-
const ptToPxRatio = 1.333;
|
|
21426
|
-
const defaultFontSize = 16;
|
|
21427
|
-
const defaultLineHeight = 1.1;
|
|
21428
|
-
const blockParent2 = pos.node(1);
|
|
21429
|
-
const parentTextStyleMark = blockParent2.firstChild.marks.find((mark) => mark.type.name === "textStyle");
|
|
21430
|
-
const fontSize = parseInt(parentTextStyleMark?.attrs.fontSize) * ptToPxRatio || defaultFontSize;
|
|
21431
|
-
return `${fontSize * defaultLineHeight}px`;
|
|
21432
|
-
}
|
|
21433
20358
|
const TabNode = Node$1.create({
|
|
21434
20359
|
name: "tab",
|
|
21435
20360
|
group: "inline",
|
|
@@ -25781,42 +24706,60 @@ function toHex(color) {
|
|
|
25781
24706
|
};
|
|
25782
24707
|
return `#${hex(r2)}${hex(g)}${hex(b)}${a < 1 ? hex(Math.round(a * 255)) : ""}`;
|
|
25783
24708
|
}
|
|
24709
|
+
const summarizeListContent = (node, fieldsToDeleteSet) => {
|
|
24710
|
+
const summary = {
|
|
24711
|
+
totalFieldAnnotations: 0,
|
|
24712
|
+
deletableFieldAnnotations: 0,
|
|
24713
|
+
hasOtherInlineContent: false
|
|
24714
|
+
};
|
|
24715
|
+
if (typeof node?.descendants !== "function") {
|
|
24716
|
+
return summary;
|
|
24717
|
+
}
|
|
24718
|
+
node.descendants((child) => {
|
|
24719
|
+
if (!child) return true;
|
|
24720
|
+
if (child.type?.name === "fieldAnnotation") {
|
|
24721
|
+
summary.totalFieldAnnotations += 1;
|
|
24722
|
+
const fieldId = child.attrs?.fieldId;
|
|
24723
|
+
if (fieldId && fieldsToDeleteSet.has(fieldId)) {
|
|
24724
|
+
summary.deletableFieldAnnotations += 1;
|
|
24725
|
+
} else {
|
|
24726
|
+
summary.hasOtherInlineContent = true;
|
|
24727
|
+
}
|
|
24728
|
+
return false;
|
|
24729
|
+
}
|
|
24730
|
+
if (child.isText) {
|
|
24731
|
+
if (child.text?.trim()) {
|
|
24732
|
+
summary.hasOtherInlineContent = true;
|
|
24733
|
+
}
|
|
24734
|
+
return false;
|
|
24735
|
+
}
|
|
24736
|
+
if (child.isInline || child.isAtom) {
|
|
24737
|
+
summary.hasOtherInlineContent = true;
|
|
24738
|
+
return false;
|
|
24739
|
+
}
|
|
24740
|
+
return true;
|
|
24741
|
+
});
|
|
24742
|
+
return summary;
|
|
24743
|
+
};
|
|
25784
24744
|
const cleanUpListsWithAnnotations = (fieldsToDelete = []) => ({ dispatch, tr, state }) => {
|
|
25785
24745
|
if (!dispatch) return true;
|
|
25786
24746
|
if (!Array.isArray(fieldsToDelete)) fieldsToDelete = [fieldsToDelete];
|
|
24747
|
+
const fieldsToDeleteSet = new Set(fieldsToDelete);
|
|
25787
24748
|
const { doc: doc2 } = state;
|
|
25788
24749
|
const docxAnnotations = getAllFieldAnnotations(state) || [];
|
|
25789
24750
|
const nodesToDelete = [];
|
|
25790
24751
|
fieldsToDelete.forEach((fieldId) => {
|
|
25791
24752
|
const matched = docxAnnotations.find((a) => a.node.attrs.fieldId === fieldId);
|
|
25792
24753
|
if (!matched) return;
|
|
25793
|
-
const listItem = findParentNodeClosestToPos(doc2.resolve(matched.pos),
|
|
24754
|
+
const listItem = findParentNodeClosestToPos(doc2.resolve(matched.pos), isList);
|
|
25794
24755
|
if (!listItem) return;
|
|
25795
|
-
|
|
25796
|
-
|
|
25797
|
-
|
|
25798
|
-
|
|
25799
|
-
|
|
25800
|
-
|
|
25801
|
-
|
|
25802
|
-
let hasOtherNodes = false;
|
|
25803
|
-
listItem.node.children.forEach((child) => {
|
|
25804
|
-
const { type } = child;
|
|
25805
|
-
if (type.name !== "paragraph" && type.name !== "fieldAnnotation") return;
|
|
25806
|
-
child.children.forEach((inline) => {
|
|
25807
|
-
const isFieldToDelete = fieldsToDelete.includes(inline.attrs.fieldId);
|
|
25808
|
-
const isFieldType = inline.type.name === "fieldAnnotation";
|
|
25809
|
-
const isMatchingField = isFieldType && isFieldToDelete;
|
|
25810
|
-
if (!isFieldType && !isMatchingField) hasOtherNodes = true;
|
|
25811
|
-
if (isMatchingField) matchingNodesFound += 1;
|
|
25812
|
-
});
|
|
25813
|
-
});
|
|
25814
|
-
if (!hasOtherNodes && matchingNodesFound > 0) {
|
|
25815
|
-
remainingNodes -= matchingNodesFound;
|
|
25816
|
-
}
|
|
25817
|
-
if (remainingNodes > 0) {
|
|
25818
|
-
return;
|
|
25819
|
-
}
|
|
24756
|
+
const { totalFieldAnnotations, deletableFieldAnnotations, hasOtherInlineContent } = summarizeListContent(
|
|
24757
|
+
listItem.node,
|
|
24758
|
+
fieldsToDeleteSet
|
|
24759
|
+
);
|
|
24760
|
+
if (!totalFieldAnnotations) return;
|
|
24761
|
+
if (hasOtherInlineContent) return;
|
|
24762
|
+
if (totalFieldAnnotations !== deletableFieldAnnotations) return;
|
|
25820
24763
|
let { pos, node, depth } = listItem;
|
|
25821
24764
|
let $pos = doc2.resolve(pos);
|
|
25822
24765
|
while (depth > 0) {
|
|
@@ -31746,6 +30689,21 @@ const TextStyle = Mark.create({
|
|
|
31746
30689
|
if (!hasStyles || isAnnotation) return false;
|
|
31747
30690
|
return {};
|
|
31748
30691
|
}
|
|
30692
|
+
},
|
|
30693
|
+
{
|
|
30694
|
+
getAttrs: (node) => {
|
|
30695
|
+
const fontFamily = node.style.fontFamily?.replace(/['"]+/g, "");
|
|
30696
|
+
const fontSize = node.style.fontSize;
|
|
30697
|
+
const textTransform = node.style.textTransform;
|
|
30698
|
+
if (fontFamily || fontSize || textTransform) {
|
|
30699
|
+
return {
|
|
30700
|
+
fontFamily: fontFamily || null,
|
|
30701
|
+
fontSize: fontSize || null,
|
|
30702
|
+
textTransform: textTransform || null
|
|
30703
|
+
};
|
|
30704
|
+
}
|
|
30705
|
+
return false;
|
|
30706
|
+
}
|
|
31749
30707
|
}
|
|
31750
30708
|
];
|
|
31751
30709
|
},
|
|
@@ -31816,8 +30774,8 @@ const Bold = Mark.create({
|
|
|
31816
30774
|
value: {
|
|
31817
30775
|
default: null,
|
|
31818
30776
|
renderDOM: (attrs) => {
|
|
31819
|
-
if (
|
|
31820
|
-
if (attrs.value === "0") {
|
|
30777
|
+
if (attrs.value == null) return {};
|
|
30778
|
+
if (attrs.value === "0" || !attrs.value) {
|
|
31821
30779
|
return { style: "font-weight: normal" };
|
|
31822
30780
|
}
|
|
31823
30781
|
return {};
|
|
@@ -31894,8 +30852,8 @@ const Italic = Mark.create({
|
|
|
31894
30852
|
value: {
|
|
31895
30853
|
default: null,
|
|
31896
30854
|
renderDOM: (attrs) => {
|
|
31897
|
-
if (
|
|
31898
|
-
if (attrs.value === "0") return { style: "font-style: normal" };
|
|
30855
|
+
if (attrs.value == null) return {};
|
|
30856
|
+
if (attrs.value === "0" || !attrs.value) return { style: "font-style: normal" };
|
|
31899
30857
|
return {};
|
|
31900
30858
|
}
|
|
31901
30859
|
}
|
|
@@ -32114,7 +31072,7 @@ const Strike = Mark.create({
|
|
|
32114
31072
|
const merged = Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
|
|
32115
31073
|
const { value } = mark.attrs;
|
|
32116
31074
|
const { ...rest } = merged || {};
|
|
32117
|
-
if (value === "0") {
|
|
31075
|
+
if (value === "0" || value === false) {
|
|
32118
31076
|
return ["span", rest, 0];
|
|
32119
31077
|
}
|
|
32120
31078
|
return ["s", rest, 0];
|
|
@@ -32157,8 +31115,8 @@ const Strike = Mark.create({
|
|
|
32157
31115
|
value: {
|
|
32158
31116
|
default: null,
|
|
32159
31117
|
renderDOM: (attrs) => {
|
|
32160
|
-
if (
|
|
32161
|
-
if (attrs.value === "0") {
|
|
31118
|
+
if (attrs.value == null) return {};
|
|
31119
|
+
if (attrs.value === "0" || !attrs.value) {
|
|
32162
31120
|
return { style: "text-decoration: none" };
|
|
32163
31121
|
}
|
|
32164
31122
|
return {};
|
|
@@ -38529,7 +37487,6 @@ const NodeResizer = Extension.create({
|
|
|
38529
37487
|
const getRichTextExtensions = () => {
|
|
38530
37488
|
return [
|
|
38531
37489
|
Bold,
|
|
38532
|
-
BulletList,
|
|
38533
37490
|
Color,
|
|
38534
37491
|
Document,
|
|
38535
37492
|
FontFamily,
|
|
@@ -38537,10 +37494,8 @@ const getRichTextExtensions = () => {
|
|
|
38537
37494
|
History,
|
|
38538
37495
|
Heading,
|
|
38539
37496
|
Italic,
|
|
38540
|
-
ListItem,
|
|
38541
37497
|
LineHeight,
|
|
38542
37498
|
Link,
|
|
38543
|
-
OrderedList,
|
|
38544
37499
|
Paragraph,
|
|
38545
37500
|
Strike,
|
|
38546
37501
|
Text,
|
|
@@ -38572,7 +37527,6 @@ const getStarterExtensions = () => {
|
|
|
38572
37527
|
return [
|
|
38573
37528
|
Bold,
|
|
38574
37529
|
BlockNode,
|
|
38575
|
-
BulletList,
|
|
38576
37530
|
Color,
|
|
38577
37531
|
CommentRangeStart,
|
|
38578
37532
|
CommentRangeEnd,
|
|
@@ -38583,10 +37537,8 @@ const getStarterExtensions = () => {
|
|
|
38583
37537
|
History,
|
|
38584
37538
|
Heading,
|
|
38585
37539
|
Italic,
|
|
38586
|
-
ListItem,
|
|
38587
37540
|
LineHeight,
|
|
38588
37541
|
Link,
|
|
38589
|
-
OrderedList,
|
|
38590
37542
|
Paragraph,
|
|
38591
37543
|
LineBreak,
|
|
38592
37544
|
HardBreak,
|
|
@@ -38659,28 +37611,27 @@ export {
|
|
|
38659
37611
|
_export_sfc as _,
|
|
38660
37612
|
getQuickFormatList as a,
|
|
38661
37613
|
generateLinkedStyleString as b,
|
|
38662
|
-
|
|
38663
|
-
|
|
38664
|
-
|
|
38665
|
-
|
|
37614
|
+
getFileOpener as c,
|
|
37615
|
+
checkAndProcessImage as d,
|
|
37616
|
+
uploadAndInsertImage as e,
|
|
37617
|
+
collectTrackedChanges as f,
|
|
38666
37618
|
global as g,
|
|
38667
|
-
|
|
37619
|
+
undoDepth as h,
|
|
38668
37620
|
isTrackedChangeActionAllowed as i,
|
|
38669
|
-
|
|
38670
|
-
|
|
38671
|
-
|
|
38672
|
-
|
|
38673
|
-
|
|
38674
|
-
|
|
38675
|
-
|
|
38676
|
-
|
|
37621
|
+
redoDepth as j,
|
|
37622
|
+
collectTrackedChangesForContext as k,
|
|
37623
|
+
isHeadless as l,
|
|
37624
|
+
getStarterExtensions as m,
|
|
37625
|
+
getRichTextExtensions as n,
|
|
37626
|
+
Decoration as o,
|
|
37627
|
+
Extension as p,
|
|
37628
|
+
index$1 as q,
|
|
38677
37629
|
replaceSelectionWithImagePlaceholder as r,
|
|
38678
37630
|
shouldBypassContextMenu as s,
|
|
38679
|
-
index
|
|
37631
|
+
index as t,
|
|
38680
37632
|
useHighContrastMode as u,
|
|
38681
|
-
|
|
38682
|
-
|
|
38683
|
-
|
|
38684
|
-
yUndoPluginKey as y
|
|
38685
|
-
getAllowedImageDimensions as z
|
|
37633
|
+
AnnotatorHelpers as v,
|
|
37634
|
+
SectionHelpers as w,
|
|
37635
|
+
getAllowedImageDimensions as x,
|
|
37636
|
+
yUndoPluginKey as y
|
|
38686
37637
|
};
|