superdoc 0.31.0-next.1 → 0.31.0-next.10
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-DYfpBL2P.es.js → PdfViewer-Ck2UtdkO.es.js} +2 -2
- package/dist/chunks/{PdfViewer-CSZtzevK.cjs → PdfViewer-CxLHqmsp.cjs} +2 -2
- package/dist/chunks/{eventemitter3-hYlnBzSA.es.js → eventemitter3-BZXKb7j7.es.js} +1 -1
- package/dist/chunks/{eventemitter3-DmHNHvFX.cjs → eventemitter3-CFCpOk3d.cjs} +1 -1
- package/dist/chunks/{index-BiYSI2c3.es.js → index-S2kR904m.es.js} +6 -6
- package/dist/chunks/{index-0zP7LFOd-CQ5IRTwG.es.js → index-TPvf306Z-DLAdtd9g.es.js} +1 -1
- package/dist/chunks/{index-0zP7LFOd-PDPveafF.cjs → index-TPvf306Z-Dymhw354.cjs} +1 -1
- package/dist/chunks/{index-9j37gBmK.cjs → index-qZtf9OYt.cjs} +6 -6
- package/dist/chunks/{jszip-BP2FTbpi.cjs → jszip-B99MTu59.cjs} +1 -1
- package/dist/chunks/{jszip-jKrsZoMS.es.js → jszip-Duxs2YMV.es.js} +1 -1
- package/dist/chunks/{super-editor.es-BzhuUuJx.es.js → super-editor.es-CNPHD-mt.es.js} +2310 -1997
- package/dist/chunks/{super-editor.es-D8j9E-4h.cjs → super-editor.es-d0fSEchl.cjs} +2357 -2044
- package/dist/chunks/{vue-Cwv-wUpm.cjs → vue-ARQSyfaw.cjs} +2401 -2360
- package/dist/chunks/{vue-CKmzTNVs.es.js → vue-B5QAf5pA.es.js} +2401 -2360
- package/dist/chunks/xml-js-CVyfrKaV.es.js +2 -0
- package/dist/chunks/xml-js-DQa4Ye5C.cjs +3 -0
- package/dist/images/altText_add.svg +3 -0
- package/dist/images/altText_disclaimer.svg +3 -0
- package/dist/images/altText_done.svg +3 -0
- package/dist/images/altText_spinner.svg +30 -0
- package/dist/images/altText_warning.svg +3 -0
- package/dist/images/annotation-check.svg +11 -0
- package/dist/images/annotation-comment.svg +16 -0
- package/dist/images/annotation-help.svg +26 -0
- package/dist/images/annotation-insert.svg +10 -0
- package/dist/images/annotation-key.svg +11 -0
- package/dist/images/annotation-newparagraph.svg +11 -0
- package/dist/images/annotation-noicon.svg +7 -0
- package/dist/images/annotation-note.svg +42 -0
- package/dist/images/annotation-paperclip.svg +6 -0
- package/dist/images/annotation-paragraph.svg +16 -0
- package/dist/images/annotation-pushpin.svg +7 -0
- package/dist/images/cursor-editorFreeHighlight.svg +6 -0
- package/dist/images/cursor-editorFreeText.svg +3 -0
- package/dist/images/cursor-editorInk.svg +4 -0
- package/dist/images/cursor-editorTextHighlight.svg +8 -0
- package/dist/images/editor-toolbar-delete.svg +5 -0
- package/dist/images/loading-icon.gif +0 -0
- package/dist/images/messageBar_closingButton.svg +3 -0
- package/dist/images/messageBar_warning.svg +3 -0
- package/dist/images/toolbarButton-editorHighlight.svg +6 -0
- package/dist/images/toolbarButton-menuArrow.svg +3 -0
- package/dist/packages/superdoc/src/core/SuperDoc.d.ts +140 -52
- package/dist/packages/superdoc/src/core/SuperDoc.d.ts.map +1 -1
- package/dist/packages/superdoc/src/core/types/index.d.ts +140 -52
- package/dist/packages/superdoc/src/core/types/index.d.ts.map +1 -1
- package/dist/style.css +12 -9
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-B3mE6WPB.js → converter-CuN7BQ8r.js} +1452 -1348
- package/dist/super-editor/chunks/{docx-zipper-FgUekv4g.js → docx-zipper-DvU3g1QE.js} +1 -1
- package/dist/super-editor/chunks/{editor-B0PiO07g.js → editor-CJUnMzXV.js} +604 -459
- package/dist/super-editor/chunks/{index-0zP7LFOd.js → index-TPvf306Z.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-Bj9E8rmT.js → toolbar-_AUH-ukY.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- 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 +12 -9
- package/dist/super-editor/super-editor/src/core/Attribute.d.ts +75 -29
- package/dist/super-editor/super-editor/src/core/Attribute.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/CommandService.d.ts +1 -1
- package/dist/super-editor/super-editor/src/core/CommandService.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/Editor.d.ts +145 -673
- package/dist/super-editor/super-editor/src/core/Editor.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/EventEmitter.d.ts +23 -14
- package/dist/super-editor/super-editor/src/core/EventEmitter.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/Extension.d.ts +25 -11
- package/dist/super-editor/super-editor/src/core/Extension.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/ExtensionService.d.ts +1 -1
- package/dist/super-editor/super-editor/src/core/ExtensionService.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/Mark.d.ts +28 -12
- package/dist/super-editor/super-editor/src/core/Mark.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/Node.d.ts +87 -25
- package/dist/super-editor/super-editor/src/core/Node.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/OxmlNode.d.ts +20 -13
- package/dist/super-editor/super-editor/src/core/OxmlNode.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/Schema.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/commands/types/index.d.ts +11 -89
- package/dist/super-editor/super-editor/src/core/commands/types/index.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/extensions/commands.d.ts +1 -1
- package/dist/super-editor/super-editor/src/core/extensions/commands.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/extensions/editable.d.ts +1 -1
- package/dist/super-editor/super-editor/src/core/extensions/editable.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/extensions/editorFocus.d.ts +1 -1
- package/dist/super-editor/super-editor/src/core/extensions/editorFocus.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/extensions/keymap.d.ts +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/annotator.d.ts +3 -2
- package/dist/super-editor/super-editor/src/core/helpers/annotator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/helpers/getExtensionConfigField.d.ts +12 -5
- package/dist/super-editor/super-editor/src/core/helpers/getExtensionConfigField.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/helpers/isList.d.ts +1 -1
- package/dist/super-editor/super-editor/src/core/helpers/isList.d.ts.map +1 -1
- 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/index.d.ts +18 -13
- package/dist/super-editor/super-editor/src/core/index.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/schema-summary.d.ts +4 -0
- package/dist/super-editor/super-editor/src/core/schema-summary.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/exporter.d.ts +0 -48
- 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 +7 -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 +2 -1
- package/dist/super-editor/super-editor/src/core/super-converter/styles.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/autoPageNumberImporter.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/markImporter.d.ts +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/sd/autoPageNumber/autoPageNumber-translator.d.ts +8 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/sd/autoPageNumber/autoPageNumber-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/sd/autoPageNumber/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/sd/autoPageNumber/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/sd/totalPageNumber/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/sd/totalPageNumber/index.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/sd/totalPageNumber/totalPageNumber-translator.d.ts +8 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/sd/totalPageNumber/totalPageNumber-translator.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/generate-paragraph-properties.d.ts +8 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/generate-paragraph-properties.d.ts.map +1 -0
- 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/p/helpers/translate-paragraph-node.d.ts +8 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/translate-paragraph-node.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/convert-sdt-content-to-runs.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/convert-sdt-content-to-runs.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/translate-field-annotation.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/t/helpers/translate-text-node.d.ts +5 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/t/helpers/translate-text-node.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tbl/tbl-translator.d.ts +14 -10
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tbl/tbl-translator.d.ts.map +1 -1
- 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/tr/tr-translator.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/types/ChainedCommands.d.ts +118 -0
- package/dist/super-editor/super-editor/src/core/types/ChainedCommands.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/types/EditorConfig.d.ts +265 -0
- package/dist/super-editor/super-editor/src/core/types/EditorConfig.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/types/EditorEvents.d.ts +144 -0
- package/dist/super-editor/super-editor/src/core/types/EditorEvents.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/types/EditorSchema.d.ts +35 -0
- package/dist/super-editor/super-editor/src/core/types/EditorSchema.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/types/EditorTypes.d.ts +73 -0
- package/dist/super-editor/super-editor/src/core/types/EditorTypes.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/types/__tests__/command-types.d.ts +2 -0
- package/dist/super-editor/super-editor/src/core/types/__tests__/command-types.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/utilities/callOrGet.d.ts +6 -2
- package/dist/super-editor/super-editor/src/core/utilities/callOrGet.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/utilities/isIOS.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/ai/ai-marks.d.ts +8 -2
- package/dist/super-editor/super-editor/src/extensions/ai/ai-marks.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/ai/ai-nodes.d.ts +7 -1
- package/dist/super-editor/super-editor/src/extensions/ai/ai-nodes.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/ai/ai-plugin.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/ai/ai-plugin.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/block-node/block-node.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/block-node/block-node.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/bold/bold.d.ts +3 -1
- package/dist/super-editor/super-editor/src/extensions/bold/bold.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/bookmarks/bookmark-end.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/bookmarks/bookmark-end.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/bookmarks/bookmark-start.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/bookmarks/bookmark-start.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/collaboration/collaboration-helpers.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/collaboration/collaboration.d.ts +6 -1
- package/dist/super-editor/super-editor/src/extensions/collaboration/collaboration.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/collaboration-cursor/collaboration-cursor.d.ts +9 -1
- package/dist/super-editor/super-editor/src/extensions/collaboration-cursor/collaboration-cursor.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/color/color.d.ts +3 -1
- package/dist/super-editor/super-editor/src/extensions/color/color.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/comment/comment.d.ts +18 -3
- package/dist/super-editor/super-editor/src/extensions/comment/comment.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/comment/comments-marks.d.ts +5 -1
- package/dist/super-editor/super-editor/src/extensions/comment/comments-marks.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/comment/comments-plugin.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/comment/comments-plugin.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/content-block/content-block.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/content-block/content-block.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/custom-selection/custom-selection.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/custom-selection/custom-selection.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/document/document.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/document/document.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/dropcursor/dropcursor.d.ts +5 -1
- package/dist/super-editor/super-editor/src/extensions/dropcursor/dropcursor.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/field-annotation/field-annotation.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/field-annotation/field-annotation.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/font-family/font-family.d.ts +3 -1
- package/dist/super-editor/super-editor/src/extensions/font-family/font-family.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/font-size/font-size.d.ts +9 -1
- package/dist/super-editor/super-editor/src/extensions/font-size/font-size.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/format-commands/format-commands.d.ts +7 -1
- package/dist/super-editor/super-editor/src/extensions/format-commands/format-commands.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/gapcursor/gapcursor.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/gapcursor/gapcursor.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/heading/heading.d.ts +3 -1
- package/dist/super-editor/super-editor/src/extensions/heading/heading.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/highlight/highlight.d.ts +3 -1
- package/dist/super-editor/super-editor/src/extensions/highlight/highlight.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/history/history.d.ts +4 -1
- package/dist/super-editor/super-editor/src/extensions/history/history.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/image/image.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/image/image.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/index.d.ts +22 -2
- package/dist/super-editor/super-editor/src/extensions/index.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/italic/italic.d.ts +3 -1
- package/dist/super-editor/super-editor/src/extensions/italic/italic.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/line-break/line-break.d.ts +2 -2
- package/dist/super-editor/super-editor/src/extensions/line-break/line-break.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/line-height/line-height.d.ts +6 -1
- package/dist/super-editor/super-editor/src/extensions/line-height/line-height.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/link/link.d.ts +9 -1
- package/dist/super-editor/super-editor/src/extensions/link/link.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/linked-styles/helpers.d.ts +1 -0
- package/dist/super-editor/super-editor/src/extensions/linked-styles/helpers.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/linked-styles/linked-styles.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/linked-styles/linked-styles.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/linked-styles/plugin.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/mention/mention.d.ts +6 -1
- package/dist/super-editor/super-editor/src/extensions/mention/mention.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/noderesizer/noderesizer.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/noderesizer/noderesizer.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/page-number/page-number.d.ts +2 -2
- package/dist/super-editor/super-editor/src/extensions/page-number/page-number.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/page-reference/page-reference.d.ts +8 -1
- package/dist/super-editor/super-editor/src/extensions/page-reference/page-reference.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/pagination/pagination.d.ts +5 -1
- package/dist/super-editor/super-editor/src/extensions/pagination/pagination.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/paragraph/paragraph.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/paragraph/paragraph.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/placeholder/placeholder.d.ts +3 -1
- package/dist/super-editor/super-editor/src/extensions/placeholder/placeholder.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/popover-plugin/popover-plugin.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/popover-plugin/popover-plugin.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/run/run.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/run/run.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/search/search.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/search/search.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/shape-container/shape-container.d.ts +6 -1
- package/dist/super-editor/super-editor/src/extensions/shape-container/shape-container.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/shape-group/shape-group.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/shape-group/shape-group.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/shape-textbox/shape-textbox.d.ts +6 -1
- package/dist/super-editor/super-editor/src/extensions/shape-textbox/shape-textbox.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/slash-menu/slash-menu.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/slash-menu/slash-menu.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/strike/strike.d.ts +3 -1
- package/dist/super-editor/super-editor/src/extensions/strike/strike.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/structured-content/document-part-object.d.ts +6 -1
- package/dist/super-editor/super-editor/src/extensions/structured-content/document-part-object.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/structured-content/document-section.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/structured-content/document-section.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/structured-content/structured-content-block.d.ts +6 -1
- package/dist/super-editor/super-editor/src/extensions/structured-content/structured-content-block.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/structured-content/structured-content-commands.d.ts +9 -3
- package/dist/super-editor/super-editor/src/extensions/structured-content/structured-content-commands.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/structured-content/structured-content.d.ts +6 -1
- package/dist/super-editor/super-editor/src/extensions/structured-content/structured-content.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentByGroup.d.ts +19 -0
- package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentByGroup.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/index.d.ts +2 -0
- package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/tagUtils.d.ts +53 -0
- package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/tagUtils.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/extensions/tab/tab.d.ts +6 -1
- package/dist/super-editor/super-editor/src/extensions/tab/tab.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/table/TableView.d.ts +7 -1
- package/dist/super-editor/super-editor/src/extensions/table/TableView.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/table/table.d.ts +19 -1
- package/dist/super-editor/super-editor/src/extensions/table/table.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/table-cell/table-cell.d.ts +5 -1
- package/dist/super-editor/super-editor/src/extensions/table-cell/table-cell.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/table-header/table-header.d.ts +5 -1
- package/dist/super-editor/super-editor/src/extensions/table-header/table-header.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/table-of-contents/table-of-contents.d.ts +6 -1
- package/dist/super-editor/super-editor/src/extensions/table-of-contents/table-of-contents.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/table-row/table-row.d.ts +5 -1
- package/dist/super-editor/super-editor/src/extensions/table-row/table-row.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/text/text.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/text/text.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/text-align/text-align.d.ts +4 -1
- package/dist/super-editor/super-editor/src/extensions/text-align/text-align.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/text-indent/text-indent.d.ts +7 -1
- package/dist/super-editor/super-editor/src/extensions/text-indent/text-indent.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/text-style/text-style.d.ts +3 -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/text-transform/text-transform.d.ts +3 -1
- package/dist/super-editor/super-editor/src/extensions/text-transform/text-transform.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/track-changes/permission-helpers.d.ts +140 -52
- package/dist/super-editor/super-editor/src/extensions/track-changes/permission-helpers.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/track-changes/track-changes.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/track-changes/track-changes.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/track-changes/track-delete.d.ts +5 -1
- package/dist/super-editor/super-editor/src/extensions/track-changes/track-delete.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/track-changes/track-format.d.ts +5 -1
- package/dist/super-editor/super-editor/src/extensions/track-changes/track-format.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/track-changes/track-insert.d.ts +5 -1
- package/dist/super-editor/super-editor/src/extensions/track-changes/track-insert.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/track-changes/trackChangesHelpers/trackedTransaction.d.ts +5 -1
- package/dist/super-editor/super-editor/src/extensions/track-changes/trackChangesHelpers/trackedTransaction.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/types/formatting-commands.d.ts +40 -0
- package/dist/super-editor/super-editor/src/extensions/types/formatting-commands.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/extensions/types/history-link-table-commands.d.ts +57 -0
- package/dist/super-editor/super-editor/src/extensions/types/history-link-table-commands.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/extensions/types/specialized-commands.d.ts +83 -0
- package/dist/super-editor/super-editor/src/extensions/types/specialized-commands.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/extensions/underline/underline.d.ts +3 -1
- package/dist/super-editor/super-editor/src/extensions/underline/underline.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/vector-shape/vector-shape.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/vector-shape/vector-shape.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/tests/export/export-helpers/export-helpers.d.ts +1 -1
- package/dist/super-editor/super-editor/src/tests/export/export-helpers/export-helpers.d.ts.map +1 -1
- package/dist/super-editor/super-editor.es.js +7 -7
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +2 -2
- package/dist/super-editor.es.js +2 -2
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +2699 -2346
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/xml-js-BSDu25I7.cjs +0 -3
- package/dist/chunks/xml-js-CBrRls0f.es.js +0 -2
|
@@ -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, _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;
|
|
12
|
+
var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, isElementNode_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, getPluginKeyName_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 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
|
|
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 convertSizeToCSS, ay as SelectionRange, az as Transform, aA as isInTable$1, aB as generateDocxRandomId, aC as insertNewRelationship, aD as inchesToPixels } from "./converter-CuN7BQ8r.js";
|
|
16
|
+
import { D as DocxZipper } from "./docx-zipper-DvU3g1QE.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() {
|
|
@@ -7646,15 +7646,10 @@ const yUndoPlugin = ({ protectedNodes = defaultProtectedNodes, trackedOrigins =
|
|
|
7646
7646
|
});
|
|
7647
7647
|
class Extension {
|
|
7648
7648
|
constructor(config) {
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
__publicField(this, "options");
|
|
7652
|
-
__publicField(this, "storage");
|
|
7653
|
-
__publicField(this, "config", {
|
|
7654
|
-
name: this.name
|
|
7655
|
-
});
|
|
7649
|
+
this.type = "extension";
|
|
7650
|
+
this.name = "extension";
|
|
7656
7651
|
this.config = {
|
|
7657
|
-
|
|
7652
|
+
name: this.name,
|
|
7658
7653
|
...config
|
|
7659
7654
|
};
|
|
7660
7655
|
this.name = this.config.name;
|
|
@@ -7663,7 +7658,9 @@ class Extension {
|
|
|
7663
7658
|
getExtensionConfigField(this, "addOptions", {
|
|
7664
7659
|
name: this.name
|
|
7665
7660
|
})
|
|
7666
|
-
);
|
|
7661
|
+
) || {};
|
|
7662
|
+
} else {
|
|
7663
|
+
this.options = {};
|
|
7667
7664
|
}
|
|
7668
7665
|
this.storage = callOrGet(
|
|
7669
7666
|
getExtensionConfigField(this, "addStorage", {
|
|
@@ -7674,10 +7671,10 @@ class Extension {
|
|
|
7674
7671
|
}
|
|
7675
7672
|
/**
|
|
7676
7673
|
* Static method for creating an extension.
|
|
7677
|
-
* @param
|
|
7674
|
+
* @param config Configuration for the extension.
|
|
7678
7675
|
*/
|
|
7679
|
-
static create(
|
|
7680
|
-
return new Extension(
|
|
7676
|
+
static create(config) {
|
|
7677
|
+
return new Extension(config);
|
|
7681
7678
|
}
|
|
7682
7679
|
}
|
|
7683
7680
|
const History = Extension.create({
|
|
@@ -7744,30 +7741,11 @@ const createUndoPlugin = () => {
|
|
|
7744
7741
|
return yUndoPluginInstance;
|
|
7745
7742
|
};
|
|
7746
7743
|
let Node$1 = class Node2 {
|
|
7747
|
-
/**
|
|
7748
|
-
* @param {import('./types/index.js').EditorNodeConfig} config
|
|
7749
|
-
*/
|
|
7750
7744
|
constructor(config) {
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
/** @type {string} */
|
|
7754
|
-
__publicField(this, "name", "node");
|
|
7755
|
-
/** @type {import('./types/index.js').EditorNodeOptions} */
|
|
7756
|
-
__publicField(this, "options");
|
|
7757
|
-
/** @type {string} */
|
|
7758
|
-
__publicField(this, "group");
|
|
7759
|
-
/** @type {boolean} */
|
|
7760
|
-
__publicField(this, "atom");
|
|
7761
|
-
/** @type {import('./Editor.js').Editor} */
|
|
7762
|
-
__publicField(this, "editor");
|
|
7763
|
-
/** @type {import('./types/index.js').EditorNodeStorage} */
|
|
7764
|
-
__publicField(this, "storage");
|
|
7765
|
-
/** @type {import('./types/index.js').EditorNodeConfig} */
|
|
7766
|
-
__publicField(this, "config", {
|
|
7767
|
-
name: this.name
|
|
7768
|
-
});
|
|
7745
|
+
this.type = "node";
|
|
7746
|
+
this.name = "node";
|
|
7769
7747
|
this.config = {
|
|
7770
|
-
|
|
7748
|
+
name: this.name,
|
|
7771
7749
|
...config
|
|
7772
7750
|
};
|
|
7773
7751
|
this.name = this.config.name;
|
|
@@ -7777,7 +7755,9 @@ let Node$1 = class Node2 {
|
|
|
7777
7755
|
getExtensionConfigField(this, "addOptions", {
|
|
7778
7756
|
name: this.name
|
|
7779
7757
|
})
|
|
7780
|
-
);
|
|
7758
|
+
) || {};
|
|
7759
|
+
} else {
|
|
7760
|
+
this.options = {};
|
|
7781
7761
|
}
|
|
7782
7762
|
this.storage = callOrGet(
|
|
7783
7763
|
getExtensionConfigField(this, "addStorage", {
|
|
@@ -7788,9 +7768,8 @@ let Node$1 = class Node2 {
|
|
|
7788
7768
|
}
|
|
7789
7769
|
/**
|
|
7790
7770
|
* Factory method to construct a new Node extension.
|
|
7791
|
-
*
|
|
7792
|
-
* @
|
|
7793
|
-
* @returns {Node} A new Node instance.
|
|
7771
|
+
* @param config - The node configuration.
|
|
7772
|
+
* @returns A new Node instance.
|
|
7794
7773
|
*/
|
|
7795
7774
|
static create(config) {
|
|
7796
7775
|
return new Node2(config);
|
|
@@ -7798,16 +7777,10 @@ let Node$1 = class Node2 {
|
|
|
7798
7777
|
};
|
|
7799
7778
|
class Mark {
|
|
7800
7779
|
constructor(config) {
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
__publicField(this, "options");
|
|
7804
|
-
__publicField(this, "storage");
|
|
7805
|
-
__publicField(this, "isExternal");
|
|
7806
|
-
__publicField(this, "config", {
|
|
7807
|
-
name: this.name
|
|
7808
|
-
});
|
|
7780
|
+
this.type = "mark";
|
|
7781
|
+
this.name = "mark";
|
|
7809
7782
|
this.config = {
|
|
7810
|
-
|
|
7783
|
+
name: this.name,
|
|
7811
7784
|
...config
|
|
7812
7785
|
};
|
|
7813
7786
|
this.name = this.config.name;
|
|
@@ -7817,7 +7790,9 @@ class Mark {
|
|
|
7817
7790
|
getExtensionConfigField(this, "addOptions", {
|
|
7818
7791
|
name: this.name
|
|
7819
7792
|
})
|
|
7820
|
-
);
|
|
7793
|
+
) || {};
|
|
7794
|
+
} else {
|
|
7795
|
+
this.options = {};
|
|
7821
7796
|
}
|
|
7822
7797
|
this.storage = callOrGet(
|
|
7823
7798
|
getExtensionConfigField(this, "addStorage", {
|
|
@@ -7828,10 +7803,10 @@ class Mark {
|
|
|
7828
7803
|
}
|
|
7829
7804
|
/**
|
|
7830
7805
|
* Static method for creating Mark extension.
|
|
7831
|
-
* @param
|
|
7806
|
+
* @param config Configuration for the mark.
|
|
7832
7807
|
*/
|
|
7833
|
-
static create(
|
|
7834
|
-
return new Mark(
|
|
7808
|
+
static create(config) {
|
|
7809
|
+
return new Mark(config);
|
|
7835
7810
|
}
|
|
7836
7811
|
}
|
|
7837
7812
|
class Attribute {
|
|
@@ -7923,8 +7898,10 @@ class Attribute {
|
|
|
7923
7898
|
continue;
|
|
7924
7899
|
}
|
|
7925
7900
|
if (key2 === "class") {
|
|
7926
|
-
const
|
|
7927
|
-
const
|
|
7901
|
+
const valueStr = typeof value === "string" ? value : String(value);
|
|
7902
|
+
const existingStr = typeof mergedAttributes[key2] === "string" ? mergedAttributes[key2] : String(mergedAttributes[key2] || "");
|
|
7903
|
+
const valueClasses = valueStr ? valueStr.split(" ") : [];
|
|
7904
|
+
const existingClasses = existingStr ? existingStr.split(" ") : [];
|
|
7928
7905
|
const insertClasses = valueClasses.filter((value2) => !existingClasses.includes(value2));
|
|
7929
7906
|
mergedAttributes[key2] = [...existingClasses, ...insertClasses].join(" ");
|
|
7930
7907
|
} else if (key2 === "style") {
|
|
@@ -8028,7 +8005,11 @@ getGlobalAttributes_fn = function(extensions, defaultAttribute) {
|
|
|
8028
8005
|
options: extension.options,
|
|
8029
8006
|
storage: extension.storage
|
|
8030
8007
|
};
|
|
8031
|
-
const addGlobalAttributes = getExtensionConfigField(
|
|
8008
|
+
const addGlobalAttributes = getExtensionConfigField(
|
|
8009
|
+
extension,
|
|
8010
|
+
"addGlobalAttributes",
|
|
8011
|
+
context
|
|
8012
|
+
);
|
|
8032
8013
|
if (!addGlobalAttributes) continue;
|
|
8033
8014
|
const globalAttributes = addGlobalAttributes();
|
|
8034
8015
|
for (const globalAttr of globalAttributes) {
|
|
@@ -8048,7 +8029,11 @@ getNodeAndMarksAttributes_fn = function(extensions, defaultAttribute) {
|
|
|
8048
8029
|
options: extension.options,
|
|
8049
8030
|
storage: extension.storage
|
|
8050
8031
|
};
|
|
8051
|
-
const addAttributes = getExtensionConfigField(
|
|
8032
|
+
const addAttributes = getExtensionConfigField(
|
|
8033
|
+
extension,
|
|
8034
|
+
"addAttributes",
|
|
8035
|
+
context
|
|
8036
|
+
);
|
|
8052
8037
|
if (!addAttributes) continue;
|
|
8053
8038
|
const attributes = addAttributes();
|
|
8054
8039
|
for (const [name, attribute] of Object.entries(attributes)) {
|
|
@@ -8068,6 +8053,9 @@ getNodeAndMarksAttributes_fn = function(extensions, defaultAttribute) {
|
|
|
8068
8053
|
}
|
|
8069
8054
|
return extensionAttributes;
|
|
8070
8055
|
};
|
|
8056
|
+
isElementNode_fn = function(node) {
|
|
8057
|
+
return Boolean(node) && typeof node.getAttribute === "function";
|
|
8058
|
+
};
|
|
8071
8059
|
__privateAdd(Attribute, _Attribute_static);
|
|
8072
8060
|
const _Schema = class _Schema {
|
|
8073
8061
|
/**
|
|
@@ -8120,6 +8108,7 @@ createNodesSchema_fn = function(nodeExtensions, attributes, editor) {
|
|
|
8120
8108
|
code: callOrGet(getExtensionConfigField(extension, "code", context)),
|
|
8121
8109
|
defining: callOrGet(getExtensionConfigField(extension, "defining", context)),
|
|
8122
8110
|
isolating: callOrGet(getExtensionConfigField(extension, "isolating", context)),
|
|
8111
|
+
summary: getExtensionConfigField(extension, "summary", context),
|
|
8123
8112
|
attrs,
|
|
8124
8113
|
...additionalNodeFields
|
|
8125
8114
|
});
|
|
@@ -8193,20 +8182,14 @@ createMarksSchema_fn = function(markExtensions, attributes, editor) {
|
|
|
8193
8182
|
__privateAdd(_Schema, _Schema_static);
|
|
8194
8183
|
let Schema = _Schema;
|
|
8195
8184
|
class OxmlNode extends Node$1 {
|
|
8196
|
-
/**
|
|
8197
|
-
* @param {import('./types/index.js').OxmlNodeConfig} config
|
|
8198
|
-
*/
|
|
8199
8185
|
constructor(config) {
|
|
8200
8186
|
super(config);
|
|
8201
|
-
/** @type {string} */
|
|
8202
|
-
__publicField(this, "oXmlName");
|
|
8203
8187
|
this.oXmlName = config.oXmlName;
|
|
8204
8188
|
}
|
|
8205
8189
|
/**
|
|
8206
8190
|
* Factory method to construct a new OxmlNode instance.
|
|
8207
|
-
*
|
|
8208
|
-
* @
|
|
8209
|
-
* @returns {OxmlNode} A new OxmlNode instance.
|
|
8191
|
+
* @param config - The OXML node configuration.
|
|
8192
|
+
* @returns A new OxmlNode instance.
|
|
8210
8193
|
*/
|
|
8211
8194
|
static create(config) {
|
|
8212
8195
|
return new OxmlNode(config);
|
|
@@ -9719,8 +9702,8 @@ class EventEmitter {
|
|
|
9719
9702
|
}
|
|
9720
9703
|
/**
|
|
9721
9704
|
* Subscribe to the event.
|
|
9722
|
-
* @param
|
|
9723
|
-
* @param
|
|
9705
|
+
* @param name Event name.
|
|
9706
|
+
* @param fn Callback.
|
|
9724
9707
|
* @returns {void}
|
|
9725
9708
|
*/
|
|
9726
9709
|
on(name, fn2) {
|
|
@@ -9730,8 +9713,8 @@ class EventEmitter {
|
|
|
9730
9713
|
}
|
|
9731
9714
|
/**
|
|
9732
9715
|
* Emit event.
|
|
9733
|
-
* @param
|
|
9734
|
-
* @param
|
|
9716
|
+
* @param name Event name.
|
|
9717
|
+
* @param args Arguments to pass to each listener.
|
|
9735
9718
|
* @returns {void}
|
|
9736
9719
|
*/
|
|
9737
9720
|
emit(name, ...args) {
|
|
@@ -9744,8 +9727,8 @@ class EventEmitter {
|
|
|
9744
9727
|
/**
|
|
9745
9728
|
* Remove a specific callback from event
|
|
9746
9729
|
* or all event subscriptions.
|
|
9747
|
-
* @param
|
|
9748
|
-
* @param
|
|
9730
|
+
* @param name Event name.
|
|
9731
|
+
* @param fn Callback.
|
|
9749
9732
|
* @returns {void}
|
|
9750
9733
|
*/
|
|
9751
9734
|
off(name, fn2) {
|
|
@@ -9762,8 +9745,8 @@ class EventEmitter {
|
|
|
9762
9745
|
}
|
|
9763
9746
|
/**
|
|
9764
9747
|
* Subscribe to an event that will be called only once.
|
|
9765
|
-
* @param
|
|
9766
|
-
* @param
|
|
9748
|
+
* @param name Event name.
|
|
9749
|
+
* @param fn Callback.
|
|
9767
9750
|
* @returns {void}
|
|
9768
9751
|
*/
|
|
9769
9752
|
once(name, fn2) {
|
|
@@ -10783,39 +10766,44 @@ const getHighlightColor = ({ activeThreadId, threadId, isInternal, editor }) =>
|
|
|
10783
10766
|
return `${color}${alpha}`;
|
|
10784
10767
|
};
|
|
10785
10768
|
const updateYdocDocxData = async (editor, ydoc) => {
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
|
|
10789
|
-
|
|
10790
|
-
|
|
10791
|
-
|
|
10792
|
-
|
|
10793
|
-
|
|
10794
|
-
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
|
|
10798
|
-
|
|
10799
|
-
|
|
10800
|
-
docx
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
|
|
10806
|
-
docx.
|
|
10807
|
-
|
|
10808
|
-
|
|
10809
|
-
|
|
10810
|
-
|
|
10769
|
+
try {
|
|
10770
|
+
ydoc = ydoc || editor?.options?.ydoc;
|
|
10771
|
+
if (!ydoc) return;
|
|
10772
|
+
if (!editor || editor.isDestroyed) return;
|
|
10773
|
+
const metaMap = ydoc.getMap("meta");
|
|
10774
|
+
const docxValue = metaMap.get("docx");
|
|
10775
|
+
let docx = [];
|
|
10776
|
+
if (Array.isArray(docxValue)) {
|
|
10777
|
+
docx = [...docxValue];
|
|
10778
|
+
} else if (docxValue && typeof docxValue.toArray === "function") {
|
|
10779
|
+
docx = docxValue.toArray();
|
|
10780
|
+
} else if (docxValue && typeof docxValue[Symbol.iterator] === "function") {
|
|
10781
|
+
docx = Array.from(docxValue);
|
|
10782
|
+
}
|
|
10783
|
+
if (!docx.length && Array.isArray(editor.options.content)) {
|
|
10784
|
+
docx = [...editor.options.content];
|
|
10785
|
+
}
|
|
10786
|
+
const newXml = await editor.exportDocx({ getUpdatedDocs: true });
|
|
10787
|
+
if (!newXml || typeof newXml !== "object") return;
|
|
10788
|
+
Object.keys(newXml).forEach((key2) => {
|
|
10789
|
+
const fileIndex = docx.findIndex((item) => item.name === key2);
|
|
10790
|
+
if (fileIndex > -1) {
|
|
10791
|
+
docx.splice(fileIndex, 1);
|
|
10792
|
+
}
|
|
10793
|
+
docx.push({
|
|
10794
|
+
name: key2,
|
|
10795
|
+
content: newXml[key2]
|
|
10796
|
+
});
|
|
10811
10797
|
});
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
)
|
|
10798
|
+
ydoc.transact(
|
|
10799
|
+
() => {
|
|
10800
|
+
metaMap.set("docx", docx);
|
|
10801
|
+
},
|
|
10802
|
+
{ event: "docx-update", user: editor.options.user }
|
|
10803
|
+
);
|
|
10804
|
+
} catch (error) {
|
|
10805
|
+
console.warn("[collaboration] Failed to update Ydoc docx data", error);
|
|
10806
|
+
}
|
|
10819
10807
|
};
|
|
10820
10808
|
const STYLE_ISOLATION_CLASS = "sd-editor-scoped";
|
|
10821
10809
|
const applyStyleIsolationClass = (target) => {
|
|
@@ -13514,50 +13502,82 @@ const getLevel = (node) => {
|
|
|
13514
13502
|
const lvl = node.getAttribute("data-level");
|
|
13515
13503
|
return lvl ? parseInt(lvl, 10) : 0;
|
|
13516
13504
|
};
|
|
13505
|
+
const summaryVersion = "0.31.0-next.10";
|
|
13506
|
+
const nodeKeys = [
|
|
13507
|
+
"group",
|
|
13508
|
+
"content",
|
|
13509
|
+
"marks",
|
|
13510
|
+
"inline",
|
|
13511
|
+
"atom",
|
|
13512
|
+
"defining",
|
|
13513
|
+
"code",
|
|
13514
|
+
"tableRole",
|
|
13515
|
+
"summary"
|
|
13516
|
+
];
|
|
13517
|
+
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
13518
|
+
function mapAttributes(attrs) {
|
|
13519
|
+
if (!attrs) return {};
|
|
13520
|
+
return Object.fromEntries(
|
|
13521
|
+
Object.entries(attrs).map(([name, attrSpec]) => {
|
|
13522
|
+
const defaultValue = attrSpec?.default;
|
|
13523
|
+
return [
|
|
13524
|
+
name,
|
|
13525
|
+
{
|
|
13526
|
+
default: defaultValue ?? null,
|
|
13527
|
+
required: defaultValue === void 0
|
|
13528
|
+
}
|
|
13529
|
+
];
|
|
13530
|
+
})
|
|
13531
|
+
);
|
|
13532
|
+
}
|
|
13533
|
+
function pickSpecFields(spec, keys2) {
|
|
13534
|
+
return Object.fromEntries(keys2.map((key2) => [key2, spec[key2]]).filter(([, value]) => value !== void 0));
|
|
13535
|
+
}
|
|
13536
|
+
function buildSchemaSummary(schema, schemaVersion) {
|
|
13537
|
+
if (!schema || typeof schema !== "object") {
|
|
13538
|
+
throw new Error("Invalid schema: schema must be a valid ProseMirror Schema object.");
|
|
13539
|
+
}
|
|
13540
|
+
const resolvedSchemaVersion = schemaVersion || "current";
|
|
13541
|
+
const nodes = [];
|
|
13542
|
+
schema.spec.nodes.forEach((name, spec) => {
|
|
13543
|
+
nodes.push({
|
|
13544
|
+
name,
|
|
13545
|
+
attrs: mapAttributes(spec.attrs),
|
|
13546
|
+
...pickSpecFields(spec, nodeKeys)
|
|
13547
|
+
});
|
|
13548
|
+
});
|
|
13549
|
+
const marks = [];
|
|
13550
|
+
schema.spec.marks.forEach((name, spec) => {
|
|
13551
|
+
marks.push({
|
|
13552
|
+
name,
|
|
13553
|
+
attrs: mapAttributes(spec.attrs),
|
|
13554
|
+
...pickSpecFields(spec, markKeys)
|
|
13555
|
+
});
|
|
13556
|
+
});
|
|
13557
|
+
return {
|
|
13558
|
+
version: summaryVersion,
|
|
13559
|
+
schemaVersion: resolvedSchemaVersion,
|
|
13560
|
+
topNode: schema.topNodeType?.name,
|
|
13561
|
+
nodes,
|
|
13562
|
+
marks
|
|
13563
|
+
};
|
|
13564
|
+
}
|
|
13517
13565
|
const _Editor = class _Editor extends EventEmitter {
|
|
13518
13566
|
/**
|
|
13519
13567
|
* Create a new Editor instance
|
|
13520
|
-
* @param
|
|
13568
|
+
* @param options - Editor configuration options
|
|
13521
13569
|
*/
|
|
13522
13570
|
constructor(options) {
|
|
13523
13571
|
super();
|
|
13524
13572
|
__privateAdd(this, _Editor_instances);
|
|
13525
13573
|
/**
|
|
13526
13574
|
* Command service for handling editor commands
|
|
13527
|
-
* @type {CommandService}
|
|
13528
13575
|
*/
|
|
13529
13576
|
__privateAdd(this, _commandService);
|
|
13530
|
-
|
|
13531
|
-
|
|
13532
|
-
|
|
13533
|
-
|
|
13534
|
-
__publicField(this, "extensionService");
|
|
13535
|
-
/**
|
|
13536
|
-
* Storage for extension data
|
|
13537
|
-
* @type {Object}
|
|
13538
|
-
*/
|
|
13539
|
-
__publicField(this, "extensionStorage", {});
|
|
13540
|
-
/**
|
|
13541
|
-
* ProseMirror schema for the editor
|
|
13542
|
-
* @type {Object}
|
|
13543
|
-
*/
|
|
13544
|
-
__publicField(this, "schema");
|
|
13545
|
-
/**
|
|
13546
|
-
* ProseMirror view instance
|
|
13547
|
-
* @type {Object}
|
|
13548
|
-
*/
|
|
13549
|
-
__publicField(this, "view");
|
|
13550
|
-
/**
|
|
13551
|
-
* Whether the editor currently has focus
|
|
13552
|
-
* @type {boolean}
|
|
13553
|
-
*/
|
|
13554
|
-
__publicField(this, "isFocused", false);
|
|
13555
|
-
/**
|
|
13556
|
-
* All the embedded fonts that were imported by the Editor
|
|
13557
|
-
* @type {string[]}
|
|
13558
|
-
*/
|
|
13559
|
-
__publicField(this, "fontsImported", []);
|
|
13560
|
-
__publicField(this, "options", {
|
|
13577
|
+
this.extensionStorage = {};
|
|
13578
|
+
this.isFocused = false;
|
|
13579
|
+
this.fontsImported = [];
|
|
13580
|
+
this.options = {
|
|
13561
13581
|
element: null,
|
|
13562
13582
|
selector: null,
|
|
13563
13583
|
isHeadless: false,
|
|
@@ -13590,11 +13610,15 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13590
13610
|
annotations: false,
|
|
13591
13611
|
isInternal: false,
|
|
13592
13612
|
externalExtensions: [],
|
|
13613
|
+
isChildEditor: false,
|
|
13593
13614
|
numbering: {},
|
|
13594
13615
|
isHeaderOrFooter: false,
|
|
13616
|
+
pagination: null,
|
|
13595
13617
|
lastSelection: null,
|
|
13596
13618
|
suppressDefaultDocxStyles: false,
|
|
13597
13619
|
jsonOverride: null,
|
|
13620
|
+
loadFromSchema: false,
|
|
13621
|
+
fragment: null,
|
|
13598
13622
|
onBeforeCreate: () => null,
|
|
13599
13623
|
onCreate: () => null,
|
|
13600
13624
|
onUpdate: () => null,
|
|
@@ -13626,15 +13650,20 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13626
13650
|
customUpdatedFiles: {},
|
|
13627
13651
|
isHeaderFooterChanged: false,
|
|
13628
13652
|
isCustomXmlChanged: false,
|
|
13653
|
+
ydoc: null,
|
|
13654
|
+
collaborationProvider: null,
|
|
13655
|
+
collaborationIsReady: false,
|
|
13656
|
+
shouldLoadComments: false,
|
|
13657
|
+
replacedFile: false,
|
|
13629
13658
|
focusTarget: null,
|
|
13630
13659
|
permissionResolver: null,
|
|
13631
13660
|
// header/footer editors may have parent(main) editor set
|
|
13632
13661
|
parentEditor: null
|
|
13633
|
-
}
|
|
13662
|
+
};
|
|
13634
13663
|
__privateMethod(this, _Editor_instances, initContainerElement_fn).call(this, options);
|
|
13635
13664
|
__privateMethod(this, _Editor_instances, checkHeadless_fn).call(this, options);
|
|
13636
13665
|
this.setOptions(options);
|
|
13637
|
-
|
|
13666
|
+
const modes = {
|
|
13638
13667
|
docx: () => __privateMethod(this, _Editor_instances, init_fn).call(this),
|
|
13639
13668
|
text: () => __privateMethod(this, _Editor_instances, initRichText_fn).call(this),
|
|
13640
13669
|
html: () => __privateMethod(this, _Editor_instances, initRichText_fn).call(this),
|
|
@@ -13642,14 +13671,13 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13642
13671
|
console.log("Not implemented.");
|
|
13643
13672
|
}
|
|
13644
13673
|
};
|
|
13645
|
-
|
|
13674
|
+
const initMode = modes[this.options.mode] ?? modes.default;
|
|
13646
13675
|
const { setHighContrastMode } = useHighContrastMode();
|
|
13647
13676
|
this.setHighContrastMode = setHighContrastMode;
|
|
13648
13677
|
initMode();
|
|
13649
13678
|
}
|
|
13650
13679
|
/**
|
|
13651
13680
|
* Getter which indicates if any changes happen in Editor
|
|
13652
|
-
* @returns {boolean}
|
|
13653
13681
|
*/
|
|
13654
13682
|
get docChanged() {
|
|
13655
13683
|
return this.options.isHeaderFooterChanged || this.options.isCustomXmlChanged || !this.options.initialState.doc.eq(this.state.doc);
|
|
@@ -13665,97 +13693,84 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13665
13693
|
if (this.view) {
|
|
13666
13694
|
this.view.destroy();
|
|
13667
13695
|
}
|
|
13668
|
-
this.view =
|
|
13696
|
+
this.view = void 0;
|
|
13669
13697
|
}
|
|
13670
13698
|
/**
|
|
13671
13699
|
* Set the toolbar for this editor
|
|
13672
|
-
* @param {Object} toolbar - The toolbar instance
|
|
13673
|
-
* @returns {void}
|
|
13674
13700
|
*/
|
|
13675
13701
|
setToolbar(toolbar) {
|
|
13676
13702
|
this.toolbar = toolbar;
|
|
13677
13703
|
}
|
|
13678
13704
|
/**
|
|
13679
13705
|
* Focus the editor.
|
|
13680
|
-
* @returns {void}
|
|
13681
13706
|
*/
|
|
13682
13707
|
focus() {
|
|
13683
13708
|
this.view?.focus();
|
|
13684
13709
|
}
|
|
13685
13710
|
/**
|
|
13686
13711
|
* Get the editor state
|
|
13687
|
-
* @returns {Object} ProseMirror state
|
|
13688
13712
|
*/
|
|
13689
13713
|
get state() {
|
|
13690
13714
|
return this.view?.state;
|
|
13691
13715
|
}
|
|
13692
13716
|
/**
|
|
13693
13717
|
* Get the editor storage.
|
|
13694
|
-
* @returns {Object} Editor storage object
|
|
13695
13718
|
*/
|
|
13696
13719
|
get storage() {
|
|
13697
13720
|
return this.extensionStorage;
|
|
13698
13721
|
}
|
|
13699
13722
|
/**
|
|
13700
13723
|
* Get object of registered commands.
|
|
13701
|
-
* @returns {import('./commands/types/index.js').EditorCommands} Commands object
|
|
13702
13724
|
*/
|
|
13703
13725
|
get commands() {
|
|
13704
13726
|
return __privateGet(this, _commandService)?.commands;
|
|
13705
13727
|
}
|
|
13706
13728
|
/**
|
|
13707
13729
|
* Get extension helpers.
|
|
13708
|
-
* @returns {EditorHelpers} Object with helper methods for extensions
|
|
13709
13730
|
*/
|
|
13710
13731
|
get helpers() {
|
|
13711
13732
|
return this.extensionService.helpers;
|
|
13712
13733
|
}
|
|
13713
13734
|
/**
|
|
13714
13735
|
* Check if the editor is editable.
|
|
13715
|
-
* @returns {boolean}
|
|
13716
13736
|
*/
|
|
13717
13737
|
get isEditable() {
|
|
13718
13738
|
return Boolean(this.options.editable && this.view && this.view.editable);
|
|
13719
13739
|
}
|
|
13720
13740
|
/**
|
|
13721
13741
|
* Check if editor is destroyed.
|
|
13722
|
-
* @returns {boolean}
|
|
13723
13742
|
*/
|
|
13724
13743
|
get isDestroyed() {
|
|
13725
13744
|
return this.view?.isDestroyed ?? true;
|
|
13726
13745
|
}
|
|
13727
13746
|
/**
|
|
13728
13747
|
* Get the editor element
|
|
13729
|
-
* @returns {HTMLElement} The editor element
|
|
13730
13748
|
*/
|
|
13731
13749
|
get element() {
|
|
13732
13750
|
return this.options.element;
|
|
13733
13751
|
}
|
|
13734
13752
|
/**
|
|
13735
13753
|
* Get possible users of the editor.
|
|
13736
|
-
* @returns {Array.<User>} List of users
|
|
13737
13754
|
*/
|
|
13738
13755
|
get users() {
|
|
13739
13756
|
return this.options.users;
|
|
13740
13757
|
}
|
|
13741
13758
|
/**
|
|
13742
13759
|
* Create a chain of commands to call multiple commands at once.
|
|
13743
|
-
* @returns {Object} Command chain
|
|
13744
13760
|
*/
|
|
13745
13761
|
chain() {
|
|
13746
13762
|
return __privateGet(this, _commandService).chain();
|
|
13747
13763
|
}
|
|
13748
13764
|
/**
|
|
13749
13765
|
* Check if a command or a chain of commands can be executed. Without executing it.
|
|
13750
|
-
* @returns {Object} Object with methods to check command availability
|
|
13751
13766
|
*/
|
|
13752
13767
|
can() {
|
|
13753
13768
|
return __privateGet(this, _commandService).can();
|
|
13754
13769
|
}
|
|
13755
13770
|
/**
|
|
13756
13771
|
* Set the document mode
|
|
13757
|
-
* @param
|
|
13758
|
-
* @param
|
|
13772
|
+
* @param documentMode - The document mode ('editing', 'viewing', 'suggesting')
|
|
13773
|
+
* @param caller - Calling context
|
|
13759
13774
|
*/
|
|
13760
13775
|
setDocumentMode(documentMode, caller) {
|
|
13761
13776
|
if (this.options.isHeaderOrFooter || this.options.isChildEditor) return;
|
|
@@ -13799,7 +13814,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13799
13814
|
}
|
|
13800
13815
|
/**
|
|
13801
13816
|
* Export the yjs binary from the current state.
|
|
13802
|
-
* @returns {Promise<Uint8Array>} The exported yjs binary
|
|
13803
13817
|
*/
|
|
13804
13818
|
async generateCollaborationUpdate() {
|
|
13805
13819
|
return await generateCollaborationData(this);
|
|
@@ -13808,11 +13822,10 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13808
13822
|
* Initialize data for collaborative editing
|
|
13809
13823
|
* If we are replacing data and have a valid provider, listen for synced event
|
|
13810
13824
|
* so that we can initialize the data
|
|
13811
|
-
* @returns {void}
|
|
13812
13825
|
*/
|
|
13813
13826
|
initializeCollaborationData() {
|
|
13814
13827
|
if (!this.options.isNewFile || !this.options.collaborationProvider) return;
|
|
13815
|
-
const
|
|
13828
|
+
const provider = this.options.collaborationProvider;
|
|
13816
13829
|
const postSyncInit = () => {
|
|
13817
13830
|
provider.off("synced", postSyncInit);
|
|
13818
13831
|
__privateMethod(this, _Editor_instances, insertNewFileData_fn).call(this);
|
|
@@ -13824,8 +13837,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13824
13837
|
* Replace content of editor that was created with loadFromSchema option
|
|
13825
13838
|
* Used to replace content of other header/footer when one of it was edited
|
|
13826
13839
|
*
|
|
13827
|
-
* @param
|
|
13828
|
-
* @returns {void}
|
|
13840
|
+
* @param content - new editor content json (retrieved from editor.getUpdatedJson)
|
|
13829
13841
|
*/
|
|
13830
13842
|
replaceContent(content) {
|
|
13831
13843
|
this.setOptions({
|
|
@@ -13842,8 +13854,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13842
13854
|
}
|
|
13843
13855
|
/**
|
|
13844
13856
|
* Set editor options and update state.
|
|
13845
|
-
* @param {EditorOptions} options - Editor options
|
|
13846
|
-
* @returns {void}
|
|
13847
13857
|
*/
|
|
13848
13858
|
setOptions(options = {}) {
|
|
13849
13859
|
this.options = {
|
|
@@ -13863,9 +13873,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13863
13873
|
}
|
|
13864
13874
|
/**
|
|
13865
13875
|
* Set whether the editor is editable
|
|
13866
|
-
* @param {boolean} [editable=true] - Whether the editor is editable
|
|
13867
|
-
* @param {boolean} [emitUpdate=true] - Whether to emit an update event
|
|
13868
|
-
* @returns {void}
|
|
13869
13876
|
*/
|
|
13870
13877
|
setEditable(editable = true, emitUpdate = true) {
|
|
13871
13878
|
this.setOptions({ editable });
|
|
@@ -13877,7 +13884,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13877
13884
|
* Register PM plugin.
|
|
13878
13885
|
* @param plugin PM plugin.
|
|
13879
13886
|
* @param handlePlugins Optional function for handling plugin merge.
|
|
13880
|
-
* @returns {void}
|
|
13881
13887
|
*/
|
|
13882
13888
|
registerPlugin(plugin, handlePlugins) {
|
|
13883
13889
|
if (!this.state?.plugins) return;
|
|
@@ -13887,25 +13893,21 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13887
13893
|
}
|
|
13888
13894
|
/**
|
|
13889
13895
|
* Unregister a PM plugin
|
|
13890
|
-
* @param {string|Object} nameOrPluginKey - Plugin name or plugin instance
|
|
13891
|
-
* @returns {void}
|
|
13892
13896
|
*/
|
|
13893
13897
|
unregisterPlugin(nameOrPluginKey) {
|
|
13894
13898
|
if (this.isDestroyed) return;
|
|
13895
|
-
const name = typeof nameOrPluginKey === "string" ? `${nameOrPluginKey}$` : nameOrPluginKey
|
|
13899
|
+
const name = typeof nameOrPluginKey === "string" ? `${nameOrPluginKey}$` : nameOrPluginKey?.key ?? "";
|
|
13896
13900
|
const state = this.state.reconfigure({
|
|
13897
|
-
plugins: this.state.plugins.filter((plugin) => !plugin.
|
|
13901
|
+
plugins: this.state.plugins.filter((plugin) => !__privateMethod(this, _Editor_instances, getPluginKeyName_fn).call(this, plugin).startsWith(name))
|
|
13898
13902
|
});
|
|
13899
13903
|
this.view.updateState(state);
|
|
13900
13904
|
}
|
|
13901
13905
|
/**
|
|
13902
13906
|
* Load the data from DOCX to be used in the schema.
|
|
13903
13907
|
* Expects a DOCX file.
|
|
13904
|
-
* @
|
|
13905
|
-
* @
|
|
13906
|
-
* @
|
|
13907
|
-
* @param {boolean} [isNode=false] - Whether the method is being called in a Node.js environment
|
|
13908
|
-
* @returns {Promise<Array>} - A promise that resolves to an array containing:
|
|
13908
|
+
* @param fileSource - The DOCX file to load (File/Blob in browser, Buffer in Node.js)
|
|
13909
|
+
* @param isNode - Whether the method is being called in a Node.js environment
|
|
13910
|
+
* @returns A promise that resolves to an array containing:
|
|
13909
13911
|
* - [0] xmlFiles - Array of XML files extracted from the DOCX
|
|
13910
13912
|
* - [1] mediaFiles - Object containing media files with URLs (browser only)
|
|
13911
13913
|
* - [2] mediaFiles - Object containing media files with base64 data
|
|
@@ -13920,33 +13922,22 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13920
13922
|
}
|
|
13921
13923
|
/**
|
|
13922
13924
|
* Get the document version
|
|
13923
|
-
* @static
|
|
13924
|
-
* @param {Object} doc - Document object
|
|
13925
|
-
* @returns {string} Document version
|
|
13926
13925
|
*/
|
|
13927
13926
|
static getDocumentVersion(doc2) {
|
|
13928
13927
|
return SuperConverter.getStoredSuperdocVersion(doc2);
|
|
13929
13928
|
}
|
|
13930
13929
|
/**
|
|
13931
13930
|
* Set the document version
|
|
13932
|
-
* @static
|
|
13933
|
-
* @param {Object} doc - Document object
|
|
13934
|
-
* @param {string} version - New version
|
|
13935
|
-
* @returns {string} The set version
|
|
13936
13931
|
*/
|
|
13937
13932
|
static setDocumentVersion(doc2, version2) {
|
|
13938
13933
|
return SuperConverter.setStoredSuperdocVersion(doc2, version2);
|
|
13939
13934
|
}
|
|
13940
13935
|
/**
|
|
13941
13936
|
* Get the document GUID
|
|
13942
|
-
* @static
|
|
13943
|
-
* @param {Object} doc - Document object
|
|
13944
|
-
* @returns {string|null} Document GUID
|
|
13945
13937
|
*/
|
|
13946
13938
|
static getDocumentGuid(doc2) {
|
|
13947
13939
|
return SuperConverter.extractDocumentGuid(doc2);
|
|
13948
13940
|
}
|
|
13949
|
-
// Deprecated
|
|
13950
13941
|
/**
|
|
13951
13942
|
* @deprecated use setDocumentVersion instead
|
|
13952
13943
|
*/
|
|
@@ -13954,9 +13945,55 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13954
13945
|
console.warn("updateDocumentVersion is deprecated, use setDocumentVersion instead");
|
|
13955
13946
|
return _Editor.setDocumentVersion(doc2, version2);
|
|
13956
13947
|
}
|
|
13948
|
+
/**
|
|
13949
|
+
* Generates a schema summary for the current runtime schema.
|
|
13950
|
+
*/
|
|
13951
|
+
async getSchemaSummaryJSON() {
|
|
13952
|
+
if (!this.schema) {
|
|
13953
|
+
throw new Error("Schema is not initialized.");
|
|
13954
|
+
}
|
|
13955
|
+
const schemaVersion = this.converter?.getSuperdocVersion?.() || "current";
|
|
13956
|
+
const suppressedNames = new Set(
|
|
13957
|
+
(this.extensionService?.extensions || []).filter((ext) => {
|
|
13958
|
+
const config = ext?.config;
|
|
13959
|
+
const suppressFlag = config?.excludeFromSummaryJSON;
|
|
13960
|
+
return Boolean(suppressFlag);
|
|
13961
|
+
}).map((ext) => ext.name)
|
|
13962
|
+
);
|
|
13963
|
+
const summary = buildSchemaSummary(this.schema, schemaVersion);
|
|
13964
|
+
if (!suppressedNames.size) {
|
|
13965
|
+
return summary;
|
|
13966
|
+
}
|
|
13967
|
+
return {
|
|
13968
|
+
...summary,
|
|
13969
|
+
nodes: summary.nodes.filter((node) => !suppressedNames.has(node.name)),
|
|
13970
|
+
marks: summary.marks.filter((mark) => !suppressedNames.has(mark.name))
|
|
13971
|
+
};
|
|
13972
|
+
}
|
|
13973
|
+
/**
|
|
13974
|
+
* Validates a ProseMirror JSON document against the current schema.
|
|
13975
|
+
*/
|
|
13976
|
+
validateJSON(doc2) {
|
|
13977
|
+
if (!this.schema) {
|
|
13978
|
+
throw new Error("Schema is not initialized.");
|
|
13979
|
+
}
|
|
13980
|
+
const topNodeName = this.schema.topNodeType?.name || "doc";
|
|
13981
|
+
const normalizedDoc = Array.isArray(doc2) ? { type: topNodeName, content: doc2 } : doc2 && typeof doc2 === "object" && doc2.type ? doc2.type === topNodeName || doc2.type === "doc" ? doc2 : { type: topNodeName, content: [doc2] } : (() => {
|
|
13982
|
+
throw new Error("Invalid document shape: expected a node object or an array of node objects.");
|
|
13983
|
+
})();
|
|
13984
|
+
try {
|
|
13985
|
+
return this.schema.nodeFromJSON(normalizedDoc);
|
|
13986
|
+
} catch (error) {
|
|
13987
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
13988
|
+
const validationError = new Error(`Invalid document for current schema: ${detail}`);
|
|
13989
|
+
if (error instanceof Error) {
|
|
13990
|
+
validationError.cause = error;
|
|
13991
|
+
}
|
|
13992
|
+
throw validationError;
|
|
13993
|
+
}
|
|
13994
|
+
}
|
|
13957
13995
|
/**
|
|
13958
13996
|
* Creates all node views.
|
|
13959
|
-
* @returns {void}
|
|
13960
13997
|
*/
|
|
13961
13998
|
createNodeViews() {
|
|
13962
13999
|
this.view.setProps({
|
|
@@ -13965,7 +14002,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13965
14002
|
}
|
|
13966
14003
|
/**
|
|
13967
14004
|
* Get the maximum content size
|
|
13968
|
-
* @returns {Object} Size object with width and height
|
|
13969
14005
|
*/
|
|
13970
14006
|
getMaxContentSize() {
|
|
13971
14007
|
if (!this.converter) return {};
|
|
@@ -13989,7 +14025,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13989
14025
|
return;
|
|
13990
14026
|
}
|
|
13991
14027
|
proseMirror.setAttribute("role", "document");
|
|
13992
|
-
proseMirror.setAttribute("aria-multiline", true);
|
|
14028
|
+
proseMirror.setAttribute("aria-multiline", "true");
|
|
13993
14029
|
proseMirror.setAttribute("aria-label", "Main content area, start typing to enter text.");
|
|
13994
14030
|
proseMirror.setAttribute("aria-description", "");
|
|
13995
14031
|
proseMirror.classList.remove("view-mode");
|
|
@@ -14020,7 +14056,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14020
14056
|
element.style.touchAction = "auto";
|
|
14021
14057
|
element.style.webkitOverflowScrolling = "touch";
|
|
14022
14058
|
const defaultLineHeight = 1.2;
|
|
14023
|
-
proseMirror.style.lineHeight = defaultLineHeight;
|
|
14059
|
+
proseMirror.style.lineHeight = String(defaultLineHeight);
|
|
14024
14060
|
if (!hasPaginationEnabled) {
|
|
14025
14061
|
proseMirror.style.paddingTop = "1in";
|
|
14026
14062
|
proseMirror.style.paddingBottom = "1in";
|
|
@@ -14034,8 +14070,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14034
14070
|
* Get page size and margins from the converter.
|
|
14035
14071
|
* Set document default font and font size.
|
|
14036
14072
|
*
|
|
14037
|
-
* @param
|
|
14038
|
-
* @returns {void}
|
|
14073
|
+
* @param element - The DOM element to apply styles to
|
|
14039
14074
|
*/
|
|
14040
14075
|
initDefaultStyles(element = this.element, isPaginationEnabled = true) {
|
|
14041
14076
|
if (this.options.isHeadless || this.options.suppressDefaultDocxStyles) return;
|
|
@@ -14046,9 +14081,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14046
14081
|
/**
|
|
14047
14082
|
* Initializes responsive styles for mobile devices.
|
|
14048
14083
|
* Sets up scaling based on viewport width and handles orientation changes.
|
|
14049
|
-
*
|
|
14050
|
-
* @param {HTMLElement|void} element - The DOM element to apply mobile styles to
|
|
14051
|
-
* @returns {void}
|
|
14052
14084
|
*/
|
|
14053
14085
|
initMobileStyles(element) {
|
|
14054
14086
|
if (!element) {
|
|
@@ -14083,30 +14115,28 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14083
14115
|
};
|
|
14084
14116
|
if ("orientation" in screen && "addEventListener" in screen.orientation) {
|
|
14085
14117
|
screen.orientation.addEventListener("change", handleResize);
|
|
14086
|
-
} else
|
|
14087
|
-
window.matchMedia("(orientation: portrait)")
|
|
14088
|
-
|
|
14089
|
-
|
|
14090
|
-
|
|
14118
|
+
} else {
|
|
14119
|
+
const mediaQueryList = typeof window.matchMedia === "function" ? window.matchMedia("(orientation: portrait)") : null;
|
|
14120
|
+
if (mediaQueryList?.addEventListener) {
|
|
14121
|
+
mediaQueryList.addEventListener("change", handleResize);
|
|
14122
|
+
}
|
|
14091
14123
|
}
|
|
14124
|
+
window.addEventListener("resize", () => handleResize);
|
|
14092
14125
|
}
|
|
14093
14126
|
/**
|
|
14094
14127
|
* Get document identifier for telemetry (async - may generate hash)
|
|
14095
|
-
* @returns {Promise<string>} GUID for modified docs, hash for unmodified
|
|
14096
14128
|
*/
|
|
14097
14129
|
async getDocumentIdentifier() {
|
|
14098
14130
|
return await this.converter?.getDocumentIdentifier() || null;
|
|
14099
14131
|
}
|
|
14100
14132
|
/**
|
|
14101
14133
|
* Get permanent document GUID (sync - only for modified documents)
|
|
14102
|
-
* @returns {string|null} GUID or null if document hasn't been modified
|
|
14103
14134
|
*/
|
|
14104
14135
|
getDocumentGuid() {
|
|
14105
14136
|
return this.converter?.documentGuid || null;
|
|
14106
14137
|
}
|
|
14107
14138
|
/**
|
|
14108
14139
|
* Check if document has been modified
|
|
14109
|
-
* @returns {boolean}
|
|
14110
14140
|
*/
|
|
14111
14141
|
isDocumentModified() {
|
|
14112
14142
|
return this.converter?.documentModified || false;
|
|
@@ -14122,14 +14152,15 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14122
14152
|
version: this.converter?.getSuperdocVersion()
|
|
14123
14153
|
};
|
|
14124
14154
|
}
|
|
14125
|
-
|
|
14155
|
+
/**
|
|
14156
|
+
* @deprecated use getDocumentGuid instead
|
|
14157
|
+
*/
|
|
14126
14158
|
getDocumentId() {
|
|
14127
14159
|
console.warn("getDocumentId is deprecated, use getDocumentGuid instead");
|
|
14128
14160
|
return this.getDocumentGuid();
|
|
14129
14161
|
}
|
|
14130
14162
|
/**
|
|
14131
14163
|
* Get attrs of the currently selected node or mark.
|
|
14132
|
-
* @param {String} nameOrType
|
|
14133
14164
|
* @example
|
|
14134
14165
|
* editor.getAttributes('textStyle').color
|
|
14135
14166
|
*/
|
|
@@ -14138,9 +14169,8 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14138
14169
|
}
|
|
14139
14170
|
/**
|
|
14140
14171
|
* Returns if the currently selected node or mark is active.
|
|
14141
|
-
* @param
|
|
14142
|
-
* @param
|
|
14143
|
-
* @returns {Boolean} Whether the node or mark is active with the specified attributes
|
|
14172
|
+
* @param nameOrAttributes - The name of the node/mark or an attributes object
|
|
14173
|
+
* @param attributesOrUndefined - Optional attributes to check when first parameter is a name
|
|
14144
14174
|
* @example
|
|
14145
14175
|
* editor.isActive('bold')
|
|
14146
14176
|
* editor.isActive('textStyle', { color: 'purple' })
|
|
@@ -14153,18 +14183,12 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14153
14183
|
}
|
|
14154
14184
|
/**
|
|
14155
14185
|
* Get the editor content as JSON
|
|
14156
|
-
* @returns {Object} Editor content as JSON
|
|
14157
14186
|
*/
|
|
14158
14187
|
getJSON() {
|
|
14159
14188
|
return this.state.doc.toJSON();
|
|
14160
14189
|
}
|
|
14161
14190
|
/**
|
|
14162
14191
|
* Get document metadata including GUID, modification status, and version
|
|
14163
|
-
* @returns {{
|
|
14164
|
-
* documentGuid: string | null,
|
|
14165
|
-
* isModified: boolean,
|
|
14166
|
-
* version: string | null
|
|
14167
|
-
* }} Document metadata
|
|
14168
14192
|
*/
|
|
14169
14193
|
getMetadata() {
|
|
14170
14194
|
return {
|
|
@@ -14175,9 +14199,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14175
14199
|
}
|
|
14176
14200
|
/**
|
|
14177
14201
|
* Get the editor content as HTML
|
|
14178
|
-
* @param {Object} options - Options for the HTML serializer
|
|
14179
|
-
* @param {boolean} [options.unflattenLists] - Whether to unflatten lists in the HTML
|
|
14180
|
-
* @returns {string} Editor content as HTML
|
|
14181
14202
|
*/
|
|
14182
14203
|
getHTML({ unflattenLists = false } = {}) {
|
|
14183
14204
|
const tempDocument = document.implementation.createHTMLDocument();
|
|
@@ -14192,7 +14213,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14192
14213
|
}
|
|
14193
14214
|
/**
|
|
14194
14215
|
* Get the editor content as Markdown
|
|
14195
|
-
* @returns {Promise<string>} Editor content as Markdown
|
|
14196
14216
|
*/
|
|
14197
14217
|
async getMarkdown() {
|
|
14198
14218
|
const [
|
|
@@ -14202,7 +14222,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14202
14222
|
{ default: remarkStringify },
|
|
14203
14223
|
{ default: remarkGfm }
|
|
14204
14224
|
] = await Promise.all([
|
|
14205
|
-
import("./index-
|
|
14225
|
+
import("./index-TPvf306Z.js"),
|
|
14206
14226
|
import("./index-DRCvimau.js"),
|
|
14207
14227
|
import("./index-C_x_N6Uh.js"),
|
|
14208
14228
|
import("./index-D_sWOSiG.js"),
|
|
@@ -14217,7 +14237,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14217
14237
|
}
|
|
14218
14238
|
/**
|
|
14219
14239
|
* Get the document version from the converter
|
|
14220
|
-
* @returns {string|null} The SuperDoc version stored in the document
|
|
14221
14240
|
*/
|
|
14222
14241
|
getDocumentVersion() {
|
|
14223
14242
|
return this.converter?.getSuperdocVersion() || null;
|
|
@@ -14226,25 +14245,18 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14226
14245
|
* Create a child editor linked to this editor.
|
|
14227
14246
|
* This is useful for creating header/footer editors that are linked to the main editor.
|
|
14228
14247
|
* Or paragraph fields that rely on the same underlying document and list defintions
|
|
14229
|
-
* @param {EditorOptions} options - Options for the child editor
|
|
14230
|
-
* @returns {Editor} A new child editor instance linked to this editor
|
|
14231
14248
|
*/
|
|
14232
14249
|
createChildEditor(options) {
|
|
14233
14250
|
return createLinkedChildEditor(this, options);
|
|
14234
14251
|
}
|
|
14235
14252
|
/**
|
|
14236
14253
|
* Get page styles
|
|
14237
|
-
* @returns {Object} Page styles
|
|
14238
14254
|
*/
|
|
14239
14255
|
getPageStyles() {
|
|
14240
14256
|
return this.converter?.pageStyles || {};
|
|
14241
14257
|
}
|
|
14242
14258
|
/**
|
|
14243
14259
|
* Update page styles
|
|
14244
|
-
*
|
|
14245
|
-
* @param {Object} param0
|
|
14246
|
-
* @param {Object} param0.pageMargins The new page margins
|
|
14247
|
-
* @returns {void}
|
|
14248
14260
|
*/
|
|
14249
14261
|
updatePageStyle({ pageMargins }) {
|
|
14250
14262
|
if (!this.converter) return;
|
|
@@ -14270,13 +14282,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14270
14282
|
}
|
|
14271
14283
|
/**
|
|
14272
14284
|
* Export the editor document to DOCX.
|
|
14273
|
-
* @async
|
|
14274
|
-
* @param {Object} options - The export options
|
|
14275
|
-
* @param {boolean} [options.isFinalDoc=false] - Whether this is the final document version
|
|
14276
|
-
* @param {string} [options.commentsType] - The type of comments to include
|
|
14277
|
-
* @param {Array} [options.comments=[]] - Array of comments to include in the document
|
|
14278
|
-
* @param {boolean} [options.getUpdatedDocs=false] - When set to true return only updated docx files
|
|
14279
|
-
* @returns {Promise<Blob|ArrayBuffer|Object>} The exported DOCX file or updated docx files
|
|
14280
14285
|
*/
|
|
14281
14286
|
async exportDocx({
|
|
14282
14287
|
isFinalDoc = false,
|
|
@@ -14311,8 +14316,9 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14311
14316
|
const updatedHeadersFooters = {};
|
|
14312
14317
|
Object.entries(this.converter.convertedXml).forEach(([name, json2]) => {
|
|
14313
14318
|
if (name.includes("header") || name.includes("footer")) {
|
|
14314
|
-
const
|
|
14315
|
-
|
|
14319
|
+
const jsonObj = json2;
|
|
14320
|
+
const resultXml = this.converter.schemaToXml(jsonObj.elements?.[0]);
|
|
14321
|
+
updatedHeadersFooters[name] = String(resultXml.replace(/\[\[sdspace\]\]/g, ""));
|
|
14316
14322
|
}
|
|
14317
14323
|
});
|
|
14318
14324
|
const numberingData = this.converter.convertedXml["word/numbering.xml"];
|
|
@@ -14366,19 +14372,19 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14366
14372
|
fonts: this.options.fonts,
|
|
14367
14373
|
isHeadless: this.options.isHeadless
|
|
14368
14374
|
});
|
|
14369
|
-
this.options.telemetry?.trackUsage("document_export", {
|
|
14375
|
+
this.options.telemetry?.trackUsage?.("document_export", {
|
|
14370
14376
|
documentType: "docx",
|
|
14371
14377
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
14372
14378
|
});
|
|
14373
14379
|
return result;
|
|
14374
14380
|
} catch (error) {
|
|
14375
|
-
|
|
14376
|
-
|
|
14381
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
14382
|
+
this.emit("exception", { error: err, editor: this });
|
|
14383
|
+
console.error(err);
|
|
14377
14384
|
}
|
|
14378
14385
|
}
|
|
14379
14386
|
/**
|
|
14380
14387
|
* Destroy the editor and clean up resources
|
|
14381
|
-
* @returns {void}
|
|
14382
14388
|
*/
|
|
14383
14389
|
destroy() {
|
|
14384
14390
|
this.emit("destroy");
|
|
@@ -14393,34 +14399,31 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14393
14399
|
const footerEditors = this.converter?.footerEditors ?? [];
|
|
14394
14400
|
if (!headerEditors.length && !footerEditors.length) return;
|
|
14395
14401
|
const editors = [...headerEditors, ...footerEditors].filter(Boolean);
|
|
14396
|
-
for (
|
|
14402
|
+
for (const editorData of editors) {
|
|
14397
14403
|
editorData?.editor?.destroy?.();
|
|
14398
14404
|
}
|
|
14399
14405
|
if (headerEditors.length) headerEditors.length = 0;
|
|
14400
14406
|
if (footerEditors.length) footerEditors.length = 0;
|
|
14401
14407
|
} catch (error) {
|
|
14402
|
-
|
|
14403
|
-
|
|
14408
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
14409
|
+
this.emit("exception", { error: err, editor: this });
|
|
14410
|
+
console.error(err);
|
|
14404
14411
|
}
|
|
14405
14412
|
}
|
|
14406
14413
|
/**
|
|
14407
14414
|
* Check if migrations are needed for the data
|
|
14408
|
-
* @static
|
|
14409
|
-
* @param {Object} data - Document data
|
|
14410
|
-
* @returns {boolean} Whether migrations are needed
|
|
14411
14415
|
*/
|
|
14412
14416
|
static checkIfMigrationsNeeded() {
|
|
14413
|
-
const dataVersion = version
|
|
14417
|
+
const dataVersion = version ?? "initial";
|
|
14414
14418
|
const migrations = getNecessaryMigrations(dataVersion) || [];
|
|
14415
14419
|
console.debug("[checkVersionMigrations] Migrations needed:", dataVersion, migrations.length);
|
|
14416
14420
|
return migrations.length > 0;
|
|
14417
14421
|
}
|
|
14418
14422
|
/**
|
|
14419
14423
|
* Process collaboration migrations
|
|
14420
|
-
* @returns {Object | void} Migration results
|
|
14421
14424
|
*/
|
|
14422
14425
|
processCollaborationMigrations() {
|
|
14423
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.31.0-next.
|
|
14426
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.31.0-next.10");
|
|
14424
14427
|
if (!this.options.ydoc) return;
|
|
14425
14428
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
14426
14429
|
let docVersion = metaMap.get("version");
|
|
@@ -14428,10 +14431,10 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14428
14431
|
console.debug("[checkVersionMigrations] Document version", docVersion);
|
|
14429
14432
|
const migrations = getNecessaryMigrations(docVersion) || [];
|
|
14430
14433
|
const plugins = this.state.plugins;
|
|
14431
|
-
const syncPlugin = plugins.find((
|
|
14434
|
+
const syncPlugin = plugins.find((plugin) => __privateMethod(this, _Editor_instances, getPluginKeyName_fn).call(this, plugin).startsWith("y-sync"));
|
|
14432
14435
|
if (!syncPlugin) return this.options.ydoc;
|
|
14433
14436
|
let hasRunMigrations = false;
|
|
14434
|
-
for (
|
|
14437
|
+
for (const migration of migrations) {
|
|
14435
14438
|
console.debug("🏃♂️ Running migration", migration.name);
|
|
14436
14439
|
const result = migration(this);
|
|
14437
14440
|
if (!result) throw new Error("Migration failed at " + migration.name);
|
|
@@ -14443,9 +14446,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14443
14446
|
}
|
|
14444
14447
|
/**
|
|
14445
14448
|
* Replace the current file
|
|
14446
|
-
* @async
|
|
14447
|
-
* @param {Object} newFile - New file data
|
|
14448
|
-
* @returns {Promise<void>}
|
|
14449
14449
|
*/
|
|
14450
14450
|
async replaceFile(newFile) {
|
|
14451
14451
|
this.setOptions({ annotations: true });
|
|
@@ -14456,15 +14456,15 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14456
14456
|
media,
|
|
14457
14457
|
mediaFiles,
|
|
14458
14458
|
fonts,
|
|
14459
|
-
isNewFile: true
|
|
14460
|
-
shouldLoadComments: true,
|
|
14461
|
-
replacedFile: true
|
|
14459
|
+
isNewFile: true
|
|
14462
14460
|
});
|
|
14461
|
+
this.options.shouldLoadComments = true;
|
|
14462
|
+
this.options.replacedFile = true;
|
|
14463
14463
|
__privateMethod(this, _Editor_instances, createConverter_fn).call(this);
|
|
14464
14464
|
__privateMethod(this, _Editor_instances, initMedia_fn).call(this);
|
|
14465
14465
|
this.initDefaultStyles();
|
|
14466
14466
|
if (this.options.ydoc && this.options.collaborationProvider) {
|
|
14467
|
-
updateYdocDocxData(this);
|
|
14467
|
+
updateYdocDocxData(this, this.options.ydoc);
|
|
14468
14468
|
this.initializeCollaborationData();
|
|
14469
14469
|
} else {
|
|
14470
14470
|
__privateMethod(this, _Editor_instances, insertNewFileData_fn).call(this);
|
|
@@ -14476,9 +14476,8 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14476
14476
|
}
|
|
14477
14477
|
/**
|
|
14478
14478
|
* Get internal docx file content
|
|
14479
|
-
* @param
|
|
14480
|
-
* @param
|
|
14481
|
-
* @returns {Object|String} - file content
|
|
14479
|
+
* @param name - File name
|
|
14480
|
+
* @param type - type of result (json, string)
|
|
14482
14481
|
*/
|
|
14483
14482
|
getInternalXmlFile(name, type = "json") {
|
|
14484
14483
|
if (!this.converter.convertedXml[name]) {
|
|
@@ -14492,8 +14491,8 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14492
14491
|
}
|
|
14493
14492
|
/**
|
|
14494
14493
|
* Update internal docx file content
|
|
14495
|
-
* @param
|
|
14496
|
-
* @param
|
|
14494
|
+
* @param name - File name
|
|
14495
|
+
* @param updatedContent - new file content
|
|
14497
14496
|
*/
|
|
14498
14497
|
updateInternalXmlFile(name, updatedContent) {
|
|
14499
14498
|
if (typeof updatedContent === "string") {
|
|
@@ -14506,8 +14505,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14506
14505
|
}
|
|
14507
14506
|
/**
|
|
14508
14507
|
* Get all nodes of a specific type
|
|
14509
|
-
* @param {string} type - Node type
|
|
14510
|
-
* @returns {Array} Array of nodes
|
|
14511
14508
|
*/
|
|
14512
14509
|
getNodesOfType(type) {
|
|
14513
14510
|
const { findChildren: findChildren2 } = helpers;
|
|
@@ -14515,9 +14512,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14515
14512
|
}
|
|
14516
14513
|
/**
|
|
14517
14514
|
* Replace a node with HTML content
|
|
14518
|
-
* @param {Object} targetNode - The node to replace
|
|
14519
|
-
* @param {string} html - HTML content to replace with
|
|
14520
|
-
* @returns {void}
|
|
14521
14515
|
*/
|
|
14522
14516
|
replaceNodeWithHTML(targetNode, html) {
|
|
14523
14517
|
const { tr } = this.state;
|
|
@@ -14534,9 +14528,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14534
14528
|
* pre-process the document as needed prior to running in the annotator.
|
|
14535
14529
|
*
|
|
14536
14530
|
* Currently this is only used for table generation but additional pre-processing can be done here.
|
|
14537
|
-
*
|
|
14538
|
-
* @param {FieldValue[]} annotationValues
|
|
14539
|
-
* @returns {void}
|
|
14540
14531
|
*/
|
|
14541
14532
|
prepareForAnnotations(annotationValues = []) {
|
|
14542
14533
|
const { tr } = this.state;
|
|
@@ -14545,8 +14536,8 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14545
14536
|
}
|
|
14546
14537
|
/**
|
|
14547
14538
|
* Migrate paragraph fields to lists V2 structure if necessary.
|
|
14548
|
-
* @param
|
|
14549
|
-
* @returns
|
|
14539
|
+
* @param annotationValues - List of field values to migrate.
|
|
14540
|
+
* @returns Returns a promise that resolves to the migrated values
|
|
14550
14541
|
*/
|
|
14551
14542
|
async migrateParagraphFields(annotationValues = []) {
|
|
14552
14543
|
if (!Array.isArray(annotationValues) || !annotationValues.length) return annotationValues;
|
|
@@ -14555,10 +14546,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14555
14546
|
}
|
|
14556
14547
|
/**
|
|
14557
14548
|
* Annotate the document with the given annotation values.
|
|
14558
|
-
*
|
|
14559
|
-
* @param {FieldValue[]} annotationValues List of field values to apply.
|
|
14560
|
-
* @param {String[]} hiddenIds List of field ids to remove from the document.
|
|
14561
|
-
* @returns {void}
|
|
14562
14549
|
*/
|
|
14563
14550
|
annotate(annotationValues = [], hiddenIds = [], removeEmptyFields = false) {
|
|
14564
14551
|
const { state, view, schema } = this;
|
|
@@ -14577,10 +14564,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14577
14564
|
/**
|
|
14578
14565
|
* Preview annotations in the editor. It stores a copy of the original state.
|
|
14579
14566
|
* This can be reverted via closePreview()
|
|
14580
|
-
*
|
|
14581
|
-
* @param {Object[]} annotationValues
|
|
14582
|
-
* @param {string[]} hiddenIds
|
|
14583
|
-
* @returns {void}
|
|
14584
14567
|
*/
|
|
14585
14568
|
previewAnnotations(annotationValues = [], hiddenIds = []) {
|
|
14586
14569
|
this.originalState = this.view.state;
|
|
@@ -14588,8 +14571,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14588
14571
|
}
|
|
14589
14572
|
/**
|
|
14590
14573
|
* If there is a preview active, this will revert the editor to the original state.
|
|
14591
|
-
*
|
|
14592
|
-
* @returns {void}
|
|
14593
14574
|
*/
|
|
14594
14575
|
closePreview() {
|
|
14595
14576
|
if (!this.originalState) return;
|
|
@@ -14600,8 +14581,6 @@ _commandService = new WeakMap();
|
|
|
14600
14581
|
_Editor_instances = new WeakSet();
|
|
14601
14582
|
/**
|
|
14602
14583
|
* Initialize the container element for the editor
|
|
14603
|
-
* @param {EditorOptions} options - Editor options
|
|
14604
|
-
* @returns {void}
|
|
14605
14584
|
*/
|
|
14606
14585
|
initContainerElement_fn = function(options) {
|
|
14607
14586
|
if (!options.element && options.selector) {
|
|
@@ -14625,7 +14604,6 @@ initContainerElement_fn = function(options) {
|
|
|
14625
14604
|
};
|
|
14626
14605
|
/**
|
|
14627
14606
|
* Initialize the editor with the given options
|
|
14628
|
-
* @returns {void}
|
|
14629
14607
|
*/
|
|
14630
14608
|
init_fn = function() {
|
|
14631
14609
|
__privateMethod(this, _Editor_instances, createExtensionService_fn).call(this);
|
|
@@ -14644,7 +14622,7 @@ init_fn = function() {
|
|
|
14644
14622
|
this.on("update", this.options.onUpdate);
|
|
14645
14623
|
this.on("selectionUpdate", this.options.onSelectionUpdate);
|
|
14646
14624
|
this.on("transaction", this.options.onTransaction);
|
|
14647
|
-
this.on("focus", __privateMethod(this, _Editor_instances, onFocus_fn));
|
|
14625
|
+
this.on("focus", __privateMethod(this, _Editor_instances, onFocus_fn).bind(this));
|
|
14648
14626
|
this.on("blur", this.options.onBlur);
|
|
14649
14627
|
this.on("destroy", this.options.onDestroy);
|
|
14650
14628
|
this.on("trackedChangesUpdate", this.options.onTrackedChangesUpdate);
|
|
@@ -14652,7 +14630,7 @@ init_fn = function() {
|
|
|
14652
14630
|
this.on("commentClick", this.options.onCommentClicked);
|
|
14653
14631
|
this.on("commentsUpdate", this.options.onCommentsUpdate);
|
|
14654
14632
|
this.on("locked", this.options.onDocumentLocked);
|
|
14655
|
-
this.on("collaborationReady", __privateMethod(this, _Editor_instances, onCollaborationReady_fn));
|
|
14633
|
+
this.on("collaborationReady", __privateMethod(this, _Editor_instances, onCollaborationReady_fn).bind(this));
|
|
14656
14634
|
this.on("paginationUpdate", this.options.onPaginationUpdate);
|
|
14657
14635
|
this.on("comment-positions", this.options.onCommentLocationsUpdate);
|
|
14658
14636
|
this.on("list-definitions-change", this.options.onListDefinitionsChange);
|
|
@@ -14682,8 +14660,6 @@ init_fn = function() {
|
|
|
14682
14660
|
};
|
|
14683
14661
|
/**
|
|
14684
14662
|
* Initialize the editor in rich text mode
|
|
14685
|
-
* @param {EditorOptions} options - Editor options
|
|
14686
|
-
* @returns {void}
|
|
14687
14663
|
*/
|
|
14688
14664
|
initRichText_fn = function() {
|
|
14689
14665
|
if (!this.options.extensions || !this.options.extensions.length) {
|
|
@@ -14700,7 +14676,7 @@ initRichText_fn = function() {
|
|
|
14700
14676
|
this.on("update", this.options.onUpdate);
|
|
14701
14677
|
this.on("selectionUpdate", this.options.onSelectionUpdate);
|
|
14702
14678
|
this.on("transaction", this.options.onTransaction);
|
|
14703
|
-
this.on("focus", __privateMethod(this, _Editor_instances, onFocus_fn));
|
|
14679
|
+
this.on("focus", __privateMethod(this, _Editor_instances, onFocus_fn).bind(this));
|
|
14704
14680
|
this.on("blur", this.options.onBlur);
|
|
14705
14681
|
this.on("destroy", this.options.onDestroy);
|
|
14706
14682
|
this.on("commentsLoaded", this.options.onCommentsLoaded);
|
|
@@ -14709,11 +14685,7 @@ initRichText_fn = function() {
|
|
|
14709
14685
|
this.on("list-definitions-change", this.options.onListDefinitionsChange);
|
|
14710
14686
|
};
|
|
14711
14687
|
/**
|
|
14712
|
-
*
|
|
14713
|
-
* @param {Object} param0
|
|
14714
|
-
* @param {Object} param0.editor
|
|
14715
|
-
* @param {Object} param0.event
|
|
14716
|
-
* @returns {void}
|
|
14688
|
+
* Handle focus event
|
|
14717
14689
|
*/
|
|
14718
14690
|
onFocus_fn = function({ editor, event }) {
|
|
14719
14691
|
this.toolbar?.setActiveEditor(editor);
|
|
@@ -14721,13 +14693,15 @@ onFocus_fn = function({ editor, event }) {
|
|
|
14721
14693
|
};
|
|
14722
14694
|
/**
|
|
14723
14695
|
* Check if the editor should run in headless mode
|
|
14724
|
-
* @param {EditorOptions} options - Editor options
|
|
14725
|
-
* @returns {void}
|
|
14726
14696
|
*/
|
|
14727
14697
|
checkHeadless_fn = function(options) {
|
|
14728
14698
|
if (!options.isHeadless) return;
|
|
14729
14699
|
if (typeof navigator === "undefined") {
|
|
14730
|
-
|
|
14700
|
+
const minimalNavigator = {
|
|
14701
|
+
platform: "node",
|
|
14702
|
+
userAgent: "Node.js"
|
|
14703
|
+
};
|
|
14704
|
+
global.navigator = minimalNavigator;
|
|
14731
14705
|
}
|
|
14732
14706
|
if (options.mockDocument) {
|
|
14733
14707
|
global.document = options.mockDocument;
|
|
@@ -14753,10 +14727,6 @@ registerCopyHandler_fn = function() {
|
|
|
14753
14727
|
* Replace the current document with new data. Necessary for initializing a new collaboration file,
|
|
14754
14728
|
* since we need to insert the data only after the provider has synced.
|
|
14755
14729
|
*/
|
|
14756
|
-
/**
|
|
14757
|
-
* Insert data for a new file
|
|
14758
|
-
* @returns {void}
|
|
14759
|
-
*/
|
|
14760
14730
|
insertNewFileData_fn = function() {
|
|
14761
14731
|
if (!this.options.isNewFile) return;
|
|
14762
14732
|
this.options.isNewFile = false;
|
|
@@ -14768,34 +14738,36 @@ insertNewFileData_fn = function() {
|
|
|
14768
14738
|
__privateMethod(this, _Editor_instances, initComments_fn).call(this);
|
|
14769
14739
|
}, 50);
|
|
14770
14740
|
};
|
|
14741
|
+
/**
|
|
14742
|
+
* Safely resolve the plugin key string for a plugin instance.
|
|
14743
|
+
*/
|
|
14744
|
+
getPluginKeyName_fn = function(plugin) {
|
|
14745
|
+
const pluginKey = plugin.key;
|
|
14746
|
+
return typeof pluginKey?.key === "string" ? pluginKey.key : "";
|
|
14747
|
+
};
|
|
14771
14748
|
/**
|
|
14772
14749
|
* Creates extension service.
|
|
14773
|
-
* @returns {void}
|
|
14774
14750
|
*/
|
|
14775
14751
|
createExtensionService_fn = function() {
|
|
14776
14752
|
const allowedExtensions = ["extension", "node", "mark"];
|
|
14777
14753
|
const coreExtensions = [Editable, Commands, EditorFocus, Keymap];
|
|
14778
14754
|
const externalExtensions = this.options.externalExtensions || [];
|
|
14779
|
-
const allExtensions = [...coreExtensions, ...this.options.extensions].filter(
|
|
14780
|
-
|
|
14781
|
-
|
|
14755
|
+
const allExtensions = [...coreExtensions, ...this.options.extensions].filter((extension) => {
|
|
14756
|
+
const extensionType = typeof extension?.type === "string" ? extension.type : void 0;
|
|
14757
|
+
return extensionType ? allowedExtensions.includes(extensionType) : false;
|
|
14758
|
+
});
|
|
14782
14759
|
this.extensionService = ExtensionService.create(allExtensions, externalExtensions, this);
|
|
14783
14760
|
};
|
|
14784
14761
|
/**
|
|
14785
14762
|
* Creates a command service.
|
|
14786
|
-
* @returns {void}
|
|
14787
14763
|
*/
|
|
14788
14764
|
createCommandService_fn = function() {
|
|
14789
14765
|
__privateSet(this, _commandService, CommandService.create({
|
|
14790
14766
|
editor: this
|
|
14791
14767
|
}));
|
|
14792
14768
|
};
|
|
14793
|
-
/**
|
|
14794
|
-
* Creates a SuperConverter.
|
|
14795
|
-
*/
|
|
14796
14769
|
/**
|
|
14797
14770
|
* Create the document converter as this.converter.
|
|
14798
|
-
* @returns {void}
|
|
14799
14771
|
*/
|
|
14800
14772
|
createConverter_fn = function() {
|
|
14801
14773
|
if (this.options.converter) {
|
|
@@ -14814,11 +14786,13 @@ createConverter_fn = function() {
|
|
|
14814
14786
|
};
|
|
14815
14787
|
/**
|
|
14816
14788
|
* Initialize media.
|
|
14817
|
-
* @returns {void}
|
|
14818
14789
|
*/
|
|
14819
14790
|
initMedia_fn = function() {
|
|
14820
14791
|
if (this.options.isChildEditor) return;
|
|
14821
|
-
if (!this.options.ydoc)
|
|
14792
|
+
if (!this.options.ydoc) {
|
|
14793
|
+
this.storage.image.media = this.options.mediaFiles;
|
|
14794
|
+
return;
|
|
14795
|
+
}
|
|
14822
14796
|
const mediaMap = this.options.ydoc.getMap("media");
|
|
14823
14797
|
if (this.options.isNewFile) {
|
|
14824
14798
|
Object.entries(this.options.mediaFiles).forEach(([key2, value]) => {
|
|
@@ -14831,7 +14805,6 @@ initMedia_fn = function() {
|
|
|
14831
14805
|
};
|
|
14832
14806
|
/**
|
|
14833
14807
|
* Initialize fonts
|
|
14834
|
-
* @returns {void}
|
|
14835
14808
|
*/
|
|
14836
14809
|
initFonts_fn = function() {
|
|
14837
14810
|
const results = this.converter.getFontFaceImportString();
|
|
@@ -14852,10 +14825,11 @@ checkFonts_fn = async function() {
|
|
|
14852
14825
|
try {
|
|
14853
14826
|
const fontsUsedInDocument = this.converter.getDocumentFonts();
|
|
14854
14827
|
const unsupportedFonts = __privateMethod(this, _Editor_instances, determineUnsupportedFonts_fn).call(this, fontsUsedInDocument);
|
|
14855
|
-
|
|
14828
|
+
const payload = {
|
|
14856
14829
|
documentFonts: fontsUsedInDocument,
|
|
14857
14830
|
unsupportedFonts
|
|
14858
|
-
}
|
|
14831
|
+
};
|
|
14832
|
+
this.emit("fonts-resolved", payload);
|
|
14859
14833
|
} catch {
|
|
14860
14834
|
console.warn("[SuperDoc] Could not determine document fonts and unsupported fonts");
|
|
14861
14835
|
}
|
|
@@ -14866,8 +14840,8 @@ checkFonts_fn = async function() {
|
|
|
14866
14840
|
* Fonts are considered unsupported if they cannot be rendered
|
|
14867
14841
|
* and are not already imported in the document via @font-face.
|
|
14868
14842
|
*
|
|
14869
|
-
* @param
|
|
14870
|
-
* @returns
|
|
14843
|
+
* @param fonts - Array of font family names used in the document.
|
|
14844
|
+
* @returns Array of unsupported font family names.
|
|
14871
14845
|
*/
|
|
14872
14846
|
determineUnsupportedFonts_fn = function(fonts) {
|
|
14873
14847
|
const unsupportedFonts = fonts.filter((font) => {
|
|
@@ -14879,21 +14853,20 @@ determineUnsupportedFonts_fn = function(fonts) {
|
|
|
14879
14853
|
};
|
|
14880
14854
|
/**
|
|
14881
14855
|
* Creates document PM schema.
|
|
14882
|
-
* @returns {void}
|
|
14883
14856
|
*/
|
|
14884
14857
|
createSchema_fn = function() {
|
|
14885
14858
|
this.schema = this.extensionService.schema;
|
|
14886
14859
|
};
|
|
14887
14860
|
/**
|
|
14888
14861
|
* Generate ProseMirror data from file
|
|
14889
|
-
* @returns {Object} ProseMirror data
|
|
14890
14862
|
*/
|
|
14891
14863
|
generatePmData_fn = function() {
|
|
14892
14864
|
let doc2;
|
|
14893
14865
|
try {
|
|
14894
|
-
const { mode,
|
|
14866
|
+
const { mode, content, fragment, loadFromSchema } = this.options;
|
|
14867
|
+
const hasJsonContent = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14895
14868
|
if (mode === "docx") {
|
|
14896
|
-
if (loadFromSchema) {
|
|
14869
|
+
if (loadFromSchema && hasJsonContent(content)) {
|
|
14897
14870
|
doc2 = this.schema.nodeFromJSON(content);
|
|
14898
14871
|
doc2 = __privateMethod(this, _Editor_instances, prepareDocumentForImport_fn).call(this, doc2);
|
|
14899
14872
|
} else {
|
|
@@ -14906,22 +14879,22 @@ generatePmData_fn = function() {
|
|
|
14906
14879
|
if (fragment) doc2 = yXmlFragmentToProseMirrorRootNode(fragment, this.schema);
|
|
14907
14880
|
}
|
|
14908
14881
|
} else if (mode === "text" || mode === "html") {
|
|
14909
|
-
if (loadFromSchema) doc2 = this.schema.nodeFromJSON(content);
|
|
14910
|
-
else if (content) doc2 = createDocFromHTML(content, this);
|
|
14882
|
+
if (loadFromSchema && hasJsonContent(content)) doc2 = this.schema.nodeFromJSON(content);
|
|
14883
|
+
else if (typeof content === "string") doc2 = createDocFromHTML(content, this);
|
|
14911
14884
|
else doc2 = this.schema.topNodeType.createAndFill();
|
|
14912
14885
|
}
|
|
14913
14886
|
} catch (err) {
|
|
14914
14887
|
console.error(err);
|
|
14915
|
-
|
|
14888
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
14889
|
+
this.emit("contentError", { editor: this, error });
|
|
14916
14890
|
}
|
|
14917
14891
|
return doc2;
|
|
14918
14892
|
};
|
|
14919
14893
|
/**
|
|
14920
14894
|
* Create the PM editor view
|
|
14921
|
-
* @returns {void}
|
|
14922
14895
|
*/
|
|
14923
14896
|
createView_fn = function(element) {
|
|
14924
|
-
|
|
14897
|
+
const doc2 = __privateMethod(this, _Editor_instances, generatePmData_fn).call(this);
|
|
14925
14898
|
const state = { schema: this.schema };
|
|
14926
14899
|
if (!this.options.ydoc) state.doc = doc2;
|
|
14927
14900
|
this.options.initialState = EditorState.create(state);
|
|
@@ -14930,13 +14903,14 @@ createView_fn = function(element) {
|
|
|
14930
14903
|
dispatchTransaction: __privateMethod(this, _Editor_instances, dispatchTransaction_fn).bind(this),
|
|
14931
14904
|
state: this.options.initialState,
|
|
14932
14905
|
handleClick: __privateMethod(this, _Editor_instances, handleNodeSelection_fn).bind(this),
|
|
14933
|
-
handleDoubleClick:
|
|
14906
|
+
handleDoubleClick: (view, pos, event) => {
|
|
14934
14907
|
if (this.options.documentMode !== "editing") return;
|
|
14935
14908
|
if (!isHeadless(this)) {
|
|
14936
14909
|
const isHeader = hasSomeParentWithClass(event.target, "pagination-section-header");
|
|
14937
14910
|
const isFooter = hasSomeParentWithClass(event.target, "pagination-section-footer");
|
|
14938
14911
|
if (isHeader || isFooter) {
|
|
14939
|
-
const
|
|
14912
|
+
const EventConstructor = event.constructor;
|
|
14913
|
+
const eventClone = new EventConstructor(event.type);
|
|
14940
14914
|
event.target.dispatchEvent(eventClone);
|
|
14941
14915
|
if (this.options.isHeaderOrFooter && this.options.editable) setWordSelection(view, pos);
|
|
14942
14916
|
return;
|
|
@@ -14954,7 +14928,7 @@ createView_fn = function(element) {
|
|
|
14954
14928
|
const pm = this.view?.dom || this.options.element?.querySelector?.(".ProseMirror");
|
|
14955
14929
|
if (pm) {
|
|
14956
14930
|
pm.classList.remove("header-footer-edit");
|
|
14957
|
-
pm.setAttribute("aria-readonly", false);
|
|
14931
|
+
pm.setAttribute("aria-readonly", "false");
|
|
14958
14932
|
}
|
|
14959
14933
|
}
|
|
14960
14934
|
setWordSelection(view, pos);
|
|
@@ -14965,16 +14939,11 @@ createView_fn = function(element) {
|
|
|
14965
14939
|
});
|
|
14966
14940
|
this.view.updateState(newState);
|
|
14967
14941
|
this.createNodeViews();
|
|
14968
|
-
this.options.telemetry?.
|
|
14942
|
+
this.options.telemetry?.trackUsage?.("editor_initialized", {});
|
|
14969
14943
|
};
|
|
14970
14944
|
/**
|
|
14971
14945
|
* Handler called when collaboration is ready.
|
|
14972
14946
|
* Initializes pagination and comments if not a new file.
|
|
14973
|
-
*
|
|
14974
|
-
* @param {Object} params - Collaboration parameters
|
|
14975
|
-
* @param {Editor} params.editor - The editor instance
|
|
14976
|
-
* @param {Object} params.ydoc - The Yjs document
|
|
14977
|
-
* @returns {void}
|
|
14978
14947
|
*/
|
|
14979
14948
|
onCollaborationReady_fn = function({ editor, ydoc }) {
|
|
14980
14949
|
if (this.options.collaborationIsReady) return;
|
|
@@ -14992,19 +14961,22 @@ onCollaborationReady_fn = function({ editor, ydoc }) {
|
|
|
14992
14961
|
if (!this.options.isNewFile) {
|
|
14993
14962
|
__privateMethod(this, _Editor_instances, initPagination_fn).call(this);
|
|
14994
14963
|
__privateMethod(this, _Editor_instances, initComments_fn).call(this);
|
|
14995
|
-
updateYdocDocxData(this);
|
|
14964
|
+
updateYdocDocxData(this, this.options.ydoc);
|
|
14996
14965
|
}
|
|
14997
14966
|
};
|
|
14998
14967
|
/**
|
|
14999
14968
|
* Initialize comments plugin
|
|
15000
|
-
* @returns {void}
|
|
15001
14969
|
*/
|
|
15002
14970
|
initComments_fn = function() {
|
|
15003
14971
|
if (!this.options.isCommentsEnabled) return;
|
|
15004
14972
|
if (this.options.isHeadless) return;
|
|
15005
14973
|
if (!this.options.shouldLoadComments) return;
|
|
15006
14974
|
const replacedFile = this.options.replacedFile;
|
|
15007
|
-
this.emit("commentsLoaded", {
|
|
14975
|
+
this.emit("commentsLoaded", {
|
|
14976
|
+
editor: this,
|
|
14977
|
+
replacedFile,
|
|
14978
|
+
comments: this.converter.comments || []
|
|
14979
|
+
});
|
|
15008
14980
|
setTimeout(() => {
|
|
15009
14981
|
this.options.replacedFile = false;
|
|
15010
14982
|
const { state, dispatch } = this.view;
|
|
@@ -15027,7 +14999,6 @@ initPagination_fn = async function() {
|
|
|
15027
14999
|
};
|
|
15028
15000
|
/**
|
|
15029
15001
|
* Dispatch a transaction to update the editor state
|
|
15030
|
-
* @param {Object} transaction - ProseMirror transaction
|
|
15031
15002
|
*/
|
|
15032
15003
|
dispatchTransaction_fn = function(transaction) {
|
|
15033
15004
|
if (this.isDestroyed) return;
|
|
@@ -15106,8 +15077,8 @@ handleNodeSelection_fn = function(view, pos) {
|
|
|
15106
15077
|
/**
|
|
15107
15078
|
* Perform any post conversion pre prosemirror import processing.
|
|
15108
15079
|
* Comments are processed here.
|
|
15109
|
-
* @param
|
|
15110
|
-
* @returns
|
|
15080
|
+
* @param doc The prosemirror document
|
|
15081
|
+
* @returns The updated prosemirror document
|
|
15111
15082
|
*/
|
|
15112
15083
|
prepareDocumentForImport_fn = function(doc2) {
|
|
15113
15084
|
const newState = EditorState.create({
|
|
@@ -15122,7 +15093,7 @@ prepareDocumentForImport_fn = function(doc2) {
|
|
|
15122
15093
|
/**
|
|
15123
15094
|
* Prepare the document for export. Any necessary pre-export processing to the state
|
|
15124
15095
|
* can happen here.
|
|
15125
|
-
* @returns
|
|
15096
|
+
* @returns The updated document in JSON
|
|
15126
15097
|
*/
|
|
15127
15098
|
prepareDocumentForExport_fn = function(comments = []) {
|
|
15128
15099
|
const newState = EditorState.create({
|
|
@@ -15137,22 +15108,21 @@ prepareDocumentForExport_fn = function(comments = []) {
|
|
|
15137
15108
|
};
|
|
15138
15109
|
/**
|
|
15139
15110
|
* Destroy collaboration provider and ydoc
|
|
15140
|
-
* @returns {void}
|
|
15141
15111
|
*/
|
|
15142
15112
|
endCollaboration_fn = function() {
|
|
15143
15113
|
if (!this.options.ydoc) return;
|
|
15144
15114
|
try {
|
|
15145
15115
|
console.debug("🔗 [super-editor] Ending collaboration");
|
|
15146
|
-
|
|
15147
|
-
|
|
15116
|
+
this.options.collaborationProvider?.disconnect?.();
|
|
15117
|
+
this.options.ydoc.destroy();
|
|
15148
15118
|
} catch (error) {
|
|
15149
|
-
|
|
15150
|
-
|
|
15119
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
15120
|
+
this.emit("exception", { error: err, editor: this });
|
|
15121
|
+
console.error(err);
|
|
15151
15122
|
}
|
|
15152
15123
|
};
|
|
15153
15124
|
/**
|
|
15154
15125
|
* Run the SuperValidator's active document validation to check and fix potential known issues.
|
|
15155
|
-
* @returns {void}
|
|
15156
15126
|
*/
|
|
15157
15127
|
validateDocumentInit_fn = function() {
|
|
15158
15128
|
if (this.options.isHeaderOrFooter || this.options.isChildEditor) return;
|
|
@@ -15161,7 +15131,6 @@ validateDocumentInit_fn = function() {
|
|
|
15161
15131
|
};
|
|
15162
15132
|
/**
|
|
15163
15133
|
* Run the SuperValidator's on document upon export to check and fix potential known issues.
|
|
15164
|
-
* @returns {void}
|
|
15165
15134
|
*/
|
|
15166
15135
|
validateDocumentExport_fn = function() {
|
|
15167
15136
|
if (this.options.isHeaderOrFooter || this.options.isChildEditor) return;
|
|
@@ -16155,6 +16124,7 @@ const AiMark = Mark.create({
|
|
|
16155
16124
|
name: AiMarkName,
|
|
16156
16125
|
group: "ai",
|
|
16157
16126
|
inclusive: false,
|
|
16127
|
+
excludeFromSummaryJSON: true,
|
|
16158
16128
|
addOptions() {
|
|
16159
16129
|
return {
|
|
16160
16130
|
htmlAttributes: { class: "sd-ai-highlight" }
|
|
@@ -16181,6 +16151,7 @@ const AiAnimationMark = Mark.create({
|
|
|
16181
16151
|
inclusive: false,
|
|
16182
16152
|
spanning: false,
|
|
16183
16153
|
excludes: AiAnimationMarkName,
|
|
16154
|
+
excludeFromSummaryJSON: true,
|
|
16184
16155
|
addOptions() {
|
|
16185
16156
|
return {
|
|
16186
16157
|
htmlAttributes: {}
|
|
@@ -16212,6 +16183,7 @@ const AiAnimationMark = Mark.create({
|
|
|
16212
16183
|
const dotsLoader = "data:image/svg+xml,%3csvg%20fill='hsla(278,%2077.40%25,%2020.80%25,%200.65)'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='4'%20cy='12'%20r='0'%3e%3canimate%20begin='0;spinner_z0Or.end'%20attributeName='r'%20calcMode='spline'%20dur='0.5s'%20keySplines='.36,.6,.31,1'%20values='0;3'%20fill='freeze'/%3e%3canimate%20begin='spinner_OLMs.end'%20attributeName='cx'%20calcMode='spline'%20dur='0.5s'%20keySplines='.36,.6,.31,1'%20values='4;12'%20fill='freeze'/%3e%3canimate%20begin='spinner_UHR2.end'%20attributeName='cx'%20calcMode='spline'%20dur='0.5s'%20keySplines='.36,.6,.31,1'%20values='12;20'%20fill='freeze'/%3e%3canimate%20id='spinner_lo66'%20begin='spinner_Aguh.end'%20attributeName='r'%20calcMode='spline'%20dur='0.5s'%20keySplines='.36,.6,.31,1'%20values='3;0'%20fill='freeze'/%3e%3canimate%20id='spinner_z0Or'%20begin='spinner_lo66.end'%20attributeName='cx'%20dur='0.001s'%20values='20;4'%20fill='freeze'/%3e%3c/circle%3e%3ccircle%20cx='4'%20cy='12'%20r='3'%3e%3canimate%20begin='0;spinner_z0Or.end'%20attributeName='cx'%20calcMode='spline'%20dur='0.5s'%20keySplines='.36,.6,.31,1'%20values='4;12'%20fill='freeze'/%3e%3canimate%20begin='spinner_OLMs.end'%20attributeName='cx'%20calcMode='spline'%20dur='0.5s'%20keySplines='.36,.6,.31,1'%20values='12;20'%20fill='freeze'/%3e%3canimate%20id='spinner_JsnR'%20begin='spinner_UHR2.end'%20attributeName='r'%20calcMode='spline'%20dur='0.5s'%20keySplines='.36,.6,.31,1'%20values='3;0'%20fill='freeze'/%3e%3canimate%20id='spinner_Aguh'%20begin='spinner_JsnR.end'%20attributeName='cx'%20dur='0.001s'%20values='20;4'%20fill='freeze'/%3e%3canimate%20begin='spinner_Aguh.end'%20attributeName='r'%20calcMode='spline'%20dur='0.5s'%20keySplines='.36,.6,.31,1'%20values='0;3'%20fill='freeze'/%3e%3c/circle%3e%3ccircle%20cx='12'%20cy='12'%20r='3'%3e%3canimate%20begin='0;spinner_z0Or.end'%20attributeName='cx'%20calcMode='spline'%20dur='0.5s'%20keySplines='.36,.6,.31,1'%20values='12;20'%20fill='freeze'/%3e%3canimate%20id='spinner_hSjk'%20begin='spinner_OLMs.end'%20attributeName='r'%20calcMode='spline'%20dur='0.5s'%20keySplines='.36,.6,.31,1'%20values='3;0'%20fill='freeze'/%3e%3canimate%20id='spinner_UHR2'%20begin='spinner_hSjk.end'%20attributeName='cx'%20dur='0.001s'%20values='20;4'%20fill='freeze'/%3e%3canimate%20begin='spinner_UHR2.end'%20attributeName='r'%20calcMode='spline'%20dur='0.5s'%20keySplines='.36,.6,.31,1'%20values='0;3'%20fill='freeze'/%3e%3canimate%20begin='spinner_Aguh.end'%20attributeName='cx'%20calcMode='spline'%20dur='0.5s'%20keySplines='.36,.6,.31,1'%20values='4;12'%20fill='freeze'/%3e%3c/circle%3e%3ccircle%20cx='20'%20cy='12'%20r='3'%3e%3canimate%20id='spinner_4v5M'%20begin='0;spinner_z0Or.end'%20attributeName='r'%20calcMode='spline'%20dur='0.5s'%20keySplines='.36,.6,.31,1'%20values='3;0'%20fill='freeze'/%3e%3canimate%20id='spinner_OLMs'%20begin='spinner_4v5M.end'%20attributeName='cx'%20dur='0.001s'%20values='20;4'%20fill='freeze'/%3e%3canimate%20begin='spinner_OLMs.end'%20attributeName='r'%20calcMode='spline'%20dur='0.5s'%20keySplines='.36,.6,.31,1'%20values='0;3'%20fill='freeze'/%3e%3canimate%20begin='spinner_UHR2.end'%20attributeName='cx'%20calcMode='spline'%20dur='0.5s'%20keySplines='.36,.6,.31,1'%20values='4;12'%20fill='freeze'/%3e%3canimate%20begin='spinner_Aguh.end'%20attributeName='cx'%20calcMode='spline'%20dur='0.5s'%20keySplines='.36,.6,.31,1'%20values='12;20'%20fill='freeze'/%3e%3c/circle%3e%3c/svg%3e";
|
|
16213
16184
|
const AiLoaderNode = Node$1.create({
|
|
16214
16185
|
name: AiLoaderNodeName,
|
|
16186
|
+
excludeFromSummaryJSON: true,
|
|
16215
16187
|
group: "inline",
|
|
16216
16188
|
inline: true,
|
|
16217
16189
|
atom: true,
|
|
@@ -16951,6 +16923,46 @@ function getStructuredContentTagsById(idOrIds, state) {
|
|
|
16951
16923
|
});
|
|
16952
16924
|
return result;
|
|
16953
16925
|
}
|
|
16926
|
+
function createTagObject(tagData) {
|
|
16927
|
+
if (!tagData || typeof tagData !== "object") {
|
|
16928
|
+
return null;
|
|
16929
|
+
}
|
|
16930
|
+
return JSON.stringify(tagData);
|
|
16931
|
+
}
|
|
16932
|
+
function parseTagObject(tag) {
|
|
16933
|
+
if (typeof tag !== "string" || !tag.startsWith("{")) {
|
|
16934
|
+
return null;
|
|
16935
|
+
}
|
|
16936
|
+
try {
|
|
16937
|
+
const parsed = JSON.parse(tag);
|
|
16938
|
+
return parsed && typeof parsed === "object" ? parsed : null;
|
|
16939
|
+
} catch {
|
|
16940
|
+
return null;
|
|
16941
|
+
}
|
|
16942
|
+
}
|
|
16943
|
+
function hasGroup(tag) {
|
|
16944
|
+
const parsed = parseTagObject(tag);
|
|
16945
|
+
return parsed !== null && typeof parsed.group === "string";
|
|
16946
|
+
}
|
|
16947
|
+
function getGroup(tag) {
|
|
16948
|
+
const parsed = parseTagObject(tag);
|
|
16949
|
+
return parsed && typeof parsed.group === "string" ? parsed.group : null;
|
|
16950
|
+
}
|
|
16951
|
+
function getStructuredContentByGroup(groupOrGroups, state) {
|
|
16952
|
+
const searchGroups = Array.isArray(groupOrGroups) ? groupOrGroups : [groupOrGroups];
|
|
16953
|
+
const result = findChildren$5(state.doc, (node) => {
|
|
16954
|
+
const isStructuredContent = ["structuredContent", "structuredContentBlock"].includes(node.type.name);
|
|
16955
|
+
if (!isStructuredContent) {
|
|
16956
|
+
return false;
|
|
16957
|
+
}
|
|
16958
|
+
const nodeGroup = getGroup(node.attrs.tag);
|
|
16959
|
+
if (!nodeGroup) {
|
|
16960
|
+
return false;
|
|
16961
|
+
}
|
|
16962
|
+
return searchGroups.includes(nodeGroup);
|
|
16963
|
+
});
|
|
16964
|
+
return result;
|
|
16965
|
+
}
|
|
16954
16966
|
function getStructuredContentTags(state) {
|
|
16955
16967
|
const result = findChildren$5(state.doc, (node) => {
|
|
16956
16968
|
return node.type.name === "structuredContent" || node.type.name === "structuredContentBlock";
|
|
@@ -16983,11 +16995,16 @@ function getStructuredContentTablesById(id, state) {
|
|
|
16983
16995
|
}
|
|
16984
16996
|
const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
16985
16997
|
__proto__: null,
|
|
16998
|
+
createTagObject,
|
|
16999
|
+
getGroup,
|
|
16986
17000
|
getStructuredContentBlockTags,
|
|
17001
|
+
getStructuredContentByGroup,
|
|
16987
17002
|
getStructuredContentInlineTags,
|
|
16988
17003
|
getStructuredContentTablesById,
|
|
16989
17004
|
getStructuredContentTags,
|
|
16990
|
-
getStructuredContentTagsById
|
|
17005
|
+
getStructuredContentTagsById,
|
|
17006
|
+
hasGroup,
|
|
17007
|
+
parseTagObject
|
|
16991
17008
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
16992
17009
|
const STRUCTURED_CONTENT_NAMES = ["structuredContent", "structuredContentBlock"];
|
|
16993
17010
|
const StructuredContentCommands = Extension.create({
|
|
@@ -16999,6 +17016,16 @@ const StructuredContentCommands = Extension.create({
|
|
|
16999
17016
|
* @category Command
|
|
17000
17017
|
* @param {StructuredContentInlineInsert} options
|
|
17001
17018
|
* @example
|
|
17019
|
+
* // With group for linking multiple fields
|
|
17020
|
+
* editor.commands.insertStructuredContentInline({
|
|
17021
|
+
* attrs: {
|
|
17022
|
+
* group: 'customer-info',
|
|
17023
|
+
* alias: 'Customer Name',
|
|
17024
|
+
* },
|
|
17025
|
+
* text: 'John Doe',
|
|
17026
|
+
* });
|
|
17027
|
+
*
|
|
17028
|
+
* // No group
|
|
17002
17029
|
* editor.commands.insertStructuredContentInline({
|
|
17003
17030
|
* attrs: {
|
|
17004
17031
|
* id: '123',
|
|
@@ -17027,12 +17054,17 @@ const StructuredContentCommands = Extension.create({
|
|
|
17027
17054
|
if (!content) {
|
|
17028
17055
|
content = schema.text(" ");
|
|
17029
17056
|
}
|
|
17057
|
+
let tag = options.attrs?.tag || "inline_text_sdt";
|
|
17058
|
+
if (options.attrs?.group) {
|
|
17059
|
+
tag = createTagObject({ group: options.attrs.group });
|
|
17060
|
+
}
|
|
17030
17061
|
const attrs = {
|
|
17031
|
-
...options.attrs,
|
|
17032
17062
|
id: options.attrs?.id || generateRandomSigned32BitIntStrId(),
|
|
17033
|
-
tag
|
|
17034
|
-
alias: options.attrs?.alias || "Structured content"
|
|
17063
|
+
tag,
|
|
17064
|
+
alias: options.attrs?.alias || "Structured content",
|
|
17065
|
+
...options.attrs
|
|
17035
17066
|
};
|
|
17067
|
+
delete attrs.group;
|
|
17036
17068
|
const node = schema.nodes.structuredContent.create(attrs, content, null);
|
|
17037
17069
|
const parent = findParentNode((node2) => node2.type.name === "structuredContent")(state.selection);
|
|
17038
17070
|
if (parent) {
|
|
@@ -17048,14 +17080,22 @@ const StructuredContentCommands = Extension.create({
|
|
|
17048
17080
|
* @category Command
|
|
17049
17081
|
* @param {StructuredContentBlockInsert} options
|
|
17050
17082
|
* @example
|
|
17083
|
+
* // With group for linking multiple fields
|
|
17084
|
+
* editor.commands.insertStructuredContentBlock({
|
|
17085
|
+
* attrs: {
|
|
17086
|
+
* group: 'terms-section',
|
|
17087
|
+
* alias: 'Terms & Conditions',
|
|
17088
|
+
* },
|
|
17089
|
+
* html: '<p>Legal content...</p>',
|
|
17090
|
+
* });
|
|
17091
|
+
*
|
|
17092
|
+
* // No group
|
|
17051
17093
|
* editor.commands.insertStructuredContentBlock({
|
|
17052
17094
|
* attrs: {
|
|
17053
17095
|
* id: '456',
|
|
17054
17096
|
* alias: 'Terms & Conditions',
|
|
17055
17097
|
* },
|
|
17056
17098
|
* json: { type: 'paragraph', content: [{ type: 'text', text: 'Legal content...' }] }
|
|
17057
|
-
* // or
|
|
17058
|
-
* html: '<p>Legal content...</p>',
|
|
17059
17099
|
* });
|
|
17060
17100
|
*/
|
|
17061
17101
|
insertStructuredContentBlock: (options = {}) => ({ editor, dispatch, state, tr }) => {
|
|
@@ -17078,12 +17118,17 @@ const StructuredContentCommands = Extension.create({
|
|
|
17078
17118
|
if (!content) {
|
|
17079
17119
|
content = schema.nodeFromJSON({ type: "paragraph", content: [] });
|
|
17080
17120
|
}
|
|
17121
|
+
let tag = options.attrs?.tag || "block_table_sdt";
|
|
17122
|
+
if (options.attrs?.group) {
|
|
17123
|
+
tag = createTagObject({ group: options.attrs.group });
|
|
17124
|
+
}
|
|
17081
17125
|
const attrs = {
|
|
17082
|
-
...options.attrs,
|
|
17083
17126
|
id: options.attrs?.id || generateRandomSigned32BitIntStrId(),
|
|
17084
|
-
tag
|
|
17085
|
-
alias: options.attrs?.alias || "Structured content"
|
|
17127
|
+
tag,
|
|
17128
|
+
alias: options.attrs?.alias || "Structured content",
|
|
17129
|
+
...options.attrs
|
|
17086
17130
|
};
|
|
17131
|
+
delete attrs.group;
|
|
17087
17132
|
const node = schema.nodes.structuredContentBlock.create(attrs, content, null);
|
|
17088
17133
|
const parent = findParentNode((node2) => node2.type.name === "structuredContentBlock")(state.selection);
|
|
17089
17134
|
if (parent) {
|
|
@@ -17213,6 +17258,85 @@ const StructuredContentCommands = Extension.create({
|
|
|
17213
17258
|
}
|
|
17214
17259
|
return true;
|
|
17215
17260
|
},
|
|
17261
|
+
/**
|
|
17262
|
+
* Updates all structured content fields that share the same group identifier.
|
|
17263
|
+
* Groups allow linking multiple fields together for batch operations.
|
|
17264
|
+
* @category Command
|
|
17265
|
+
* @param {string} group - Group identifier shared by multiple fields
|
|
17266
|
+
* @param {StructuredContentUpdate} options
|
|
17267
|
+
* @example
|
|
17268
|
+
* // Update all fields in the customer-info group
|
|
17269
|
+
* editor.commands.updateStructuredContentByGroup('customer-info', { text: 'Jane Doe' });
|
|
17270
|
+
*
|
|
17271
|
+
* // Update block content in a group
|
|
17272
|
+
* editor.commands.updateStructuredContentByGroup('terms-section', {
|
|
17273
|
+
* html: '<p>Updated terms...</p>'
|
|
17274
|
+
* });
|
|
17275
|
+
*/
|
|
17276
|
+
updateStructuredContentByGroup: (group, options = {}) => ({ editor, dispatch, state, tr }) => {
|
|
17277
|
+
const structuredContentTags = getStructuredContentByGroup(group, state);
|
|
17278
|
+
if (!structuredContentTags.length) {
|
|
17279
|
+
return true;
|
|
17280
|
+
}
|
|
17281
|
+
const { schema } = editor;
|
|
17282
|
+
if (dispatch) {
|
|
17283
|
+
structuredContentTags.forEach((structuredContent) => {
|
|
17284
|
+
const { pos, node } = structuredContent;
|
|
17285
|
+
const posFrom = tr.mapping.map(pos);
|
|
17286
|
+
const posTo = tr.mapping.map(pos + node.nodeSize);
|
|
17287
|
+
let content = null;
|
|
17288
|
+
if (options.text) {
|
|
17289
|
+
content = schema.text(options.text);
|
|
17290
|
+
}
|
|
17291
|
+
if (options.html) {
|
|
17292
|
+
const html = htmlHandler(options.html, editor);
|
|
17293
|
+
const doc2 = DOMParser$1.fromSchema(schema).parse(html);
|
|
17294
|
+
content = doc2.content;
|
|
17295
|
+
}
|
|
17296
|
+
if (options.json) {
|
|
17297
|
+
content = schema.nodeFromJSON(options.json);
|
|
17298
|
+
}
|
|
17299
|
+
if (!content) {
|
|
17300
|
+
content = node.content;
|
|
17301
|
+
}
|
|
17302
|
+
const updatedNode = node.type.create({ ...node.attrs, ...options.attrs }, content, node.marks);
|
|
17303
|
+
const currentNode = tr.doc.nodeAt(posFrom);
|
|
17304
|
+
if (currentNode && node.eq(currentNode)) {
|
|
17305
|
+
tr.replaceWith(posFrom, posTo, updatedNode);
|
|
17306
|
+
}
|
|
17307
|
+
});
|
|
17308
|
+
}
|
|
17309
|
+
return true;
|
|
17310
|
+
},
|
|
17311
|
+
/**
|
|
17312
|
+
* Removes all structured content fields that share the same group identifier.
|
|
17313
|
+
* @category Command
|
|
17314
|
+
* @param {string | string[]} groupOrGroups - Single group or array of groups
|
|
17315
|
+
* @example
|
|
17316
|
+
* // Delete all fields in a group
|
|
17317
|
+
* editor.commands.deleteStructuredContentByGroup('customer-info');
|
|
17318
|
+
*
|
|
17319
|
+
* // Delete multiple groups
|
|
17320
|
+
* editor.commands.deleteStructuredContentByGroup(['header', 'footer']);
|
|
17321
|
+
*/
|
|
17322
|
+
deleteStructuredContentByGroup: (groupOrGroups) => ({ dispatch, state, tr }) => {
|
|
17323
|
+
const structuredContentTags = getStructuredContentByGroup(groupOrGroups, state);
|
|
17324
|
+
if (!structuredContentTags.length) {
|
|
17325
|
+
return true;
|
|
17326
|
+
}
|
|
17327
|
+
if (dispatch) {
|
|
17328
|
+
structuredContentTags.forEach((structuredContent) => {
|
|
17329
|
+
const { pos, node } = structuredContent;
|
|
17330
|
+
const posFrom = tr.mapping.map(pos);
|
|
17331
|
+
const posTo = tr.mapping.map(pos + node.nodeSize);
|
|
17332
|
+
const currentNode = tr.doc.nodeAt(posFrom);
|
|
17333
|
+
if (currentNode && node.eq(currentNode)) {
|
|
17334
|
+
tr.delete(posFrom, posTo);
|
|
17335
|
+
}
|
|
17336
|
+
});
|
|
17337
|
+
}
|
|
17338
|
+
return true;
|
|
17339
|
+
},
|
|
17216
17340
|
/**
|
|
17217
17341
|
* Append multiple rows to the end of a table inside a structured content block.
|
|
17218
17342
|
* Each inner array represents the cell values for one new row.
|
|
@@ -17444,6 +17568,7 @@ const DocumentSection = Node$1.create({
|
|
|
17444
17568
|
return new DocumentSectionView(node, getPos, decorations, editor);
|
|
17445
17569
|
};
|
|
17446
17570
|
},
|
|
17571
|
+
// @ts-expect-error - Command signatures will be fixed in TS migration
|
|
17447
17572
|
addCommands() {
|
|
17448
17573
|
return {
|
|
17449
17574
|
/**
|
|
@@ -17646,6 +17771,7 @@ const DocumentPartObject = Node$1.create({
|
|
|
17646
17771
|
group: "block",
|
|
17647
17772
|
content: "block*",
|
|
17648
17773
|
isolating: true,
|
|
17774
|
+
excludeFromSummaryJSON: true,
|
|
17649
17775
|
addOptions() {
|
|
17650
17776
|
return {
|
|
17651
17777
|
htmlAttributes: {
|
|
@@ -17701,6 +17827,7 @@ const Document = Node$1.create({
|
|
|
17701
17827
|
}
|
|
17702
17828
|
};
|
|
17703
17829
|
},
|
|
17830
|
+
// @ts-expect-error - Command signatures will be fixed in TS migration
|
|
17704
17831
|
addCommands() {
|
|
17705
17832
|
return {
|
|
17706
17833
|
/**
|
|
@@ -17838,6 +17965,7 @@ const Run = OxmlNode.create({
|
|
|
17838
17965
|
}
|
|
17839
17966
|
};
|
|
17840
17967
|
},
|
|
17968
|
+
// @ts-expect-error - Command signatures will be fixed in TS migration
|
|
17841
17969
|
addCommands() {
|
|
17842
17970
|
return {
|
|
17843
17971
|
splitRun
|
|
@@ -18358,7 +18486,7 @@ const applyLinkedStyleToTransaction = (tr, editor, style) => {
|
|
|
18358
18486
|
let selection = tr.selection;
|
|
18359
18487
|
const state = editor.state;
|
|
18360
18488
|
const focusState = CustomSelectionPluginKey.getState(state);
|
|
18361
|
-
if (selection.empty && focusState?.preservedSelection) {
|
|
18489
|
+
if (selection.empty && focusState?.preservedSelection && !focusState?.preservedSelection.empty) {
|
|
18362
18490
|
selection = focusState.preservedSelection;
|
|
18363
18491
|
tr.setSelection(selection);
|
|
18364
18492
|
} else if (selection.empty && editor.options.lastSelection) {
|
|
@@ -18425,6 +18553,31 @@ const applyLinkedStyleToTransaction = (tr, editor, style) => {
|
|
|
18425
18553
|
});
|
|
18426
18554
|
return true;
|
|
18427
18555
|
};
|
|
18556
|
+
const stepInsertsTextIntoStyledParagraph = (tr, oldEditorState, step, stepIndex) => {
|
|
18557
|
+
if (!step.slice || step.slice.size === 0 || typeof step.from !== "number") {
|
|
18558
|
+
return false;
|
|
18559
|
+
}
|
|
18560
|
+
let insertsText = false;
|
|
18561
|
+
step.slice.content.descendants((node) => {
|
|
18562
|
+
if (node.type?.name === "text" && node.text?.length) {
|
|
18563
|
+
insertsText = true;
|
|
18564
|
+
return false;
|
|
18565
|
+
}
|
|
18566
|
+
return true;
|
|
18567
|
+
});
|
|
18568
|
+
if (!insertsText) return false;
|
|
18569
|
+
const docBeforeStep = tr.docs?.[stepIndex] || oldEditorState.doc;
|
|
18570
|
+
if (!docBeforeStep) return false;
|
|
18571
|
+
const resolvedPos = Math.min(step.from, docBeforeStep.content.size);
|
|
18572
|
+
const $pos = docBeforeStep.resolve(resolvedPos);
|
|
18573
|
+
for (let depth = $pos.depth; depth >= 0; depth--) {
|
|
18574
|
+
const node = $pos.node(depth);
|
|
18575
|
+
if (node?.type?.name === "paragraph") {
|
|
18576
|
+
return Boolean(node.attrs?.styleId);
|
|
18577
|
+
}
|
|
18578
|
+
}
|
|
18579
|
+
return false;
|
|
18580
|
+
};
|
|
18428
18581
|
const LinkedStylesPluginKey = new PluginKey("linkedStyles");
|
|
18429
18582
|
const createLinkedStylesPlugin = (editor) => {
|
|
18430
18583
|
return new Plugin({
|
|
@@ -18458,7 +18611,7 @@ const createLinkedStylesPlugin = (editor) => {
|
|
|
18458
18611
|
if (tr.docChanged) {
|
|
18459
18612
|
let mightAffectStyles = false;
|
|
18460
18613
|
const styleRelatedMarks = /* @__PURE__ */ new Set(["textStyle", "bold", "italic", "underline", "strike"]);
|
|
18461
|
-
tr.steps.forEach((step) => {
|
|
18614
|
+
tr.steps.forEach((step, index2) => {
|
|
18462
18615
|
if (step.slice) {
|
|
18463
18616
|
step.slice.content.descendants((node) => {
|
|
18464
18617
|
if (node.attrs?.styleId) {
|
|
@@ -18479,6 +18632,9 @@ const createLinkedStylesPlugin = (editor) => {
|
|
|
18479
18632
|
mightAffectStyles = true;
|
|
18480
18633
|
}
|
|
18481
18634
|
}
|
|
18635
|
+
if (!mightAffectStyles && stepInsertsTextIntoStyledParagraph(tr, oldEditorState, step, index2)) {
|
|
18636
|
+
mightAffectStyles = true;
|
|
18637
|
+
}
|
|
18482
18638
|
});
|
|
18483
18639
|
if (mightAffectStyles) {
|
|
18484
18640
|
const styles = LinkedStylesPluginKey.getState(editor.state).styles;
|
|
@@ -19757,6 +19913,7 @@ const Paragraph = OxmlNode.create({
|
|
|
19757
19913
|
group: "block",
|
|
19758
19914
|
content: "inline*",
|
|
19759
19915
|
inline: false,
|
|
19916
|
+
summary: "The paragraph node mirrors MS Word w:p paragraphs, and also represents lists in the schema.",
|
|
19760
19917
|
addOptions() {
|
|
19761
19918
|
return {
|
|
19762
19919
|
headingLevels: [1, 2, 3, 4, 5, 6],
|
|
@@ -19877,6 +20034,8 @@ const Paragraph = OxmlNode.create({
|
|
|
19877
20034
|
}
|
|
19878
20035
|
},
|
|
19879
20036
|
styleId: {
|
|
20037
|
+
default: null,
|
|
20038
|
+
keepOnSplit: false,
|
|
19880
20039
|
renderDOM: (attrs) => {
|
|
19881
20040
|
if (!attrs.styleId) return {};
|
|
19882
20041
|
return { styleid: attrs.styleId };
|
|
@@ -20420,6 +20579,9 @@ const TabNode = Node$1.create({
|
|
|
20420
20579
|
};
|
|
20421
20580
|
},
|
|
20422
20581
|
addPmPlugins() {
|
|
20582
|
+
if (isHeadless(this.editor)) {
|
|
20583
|
+
return [];
|
|
20584
|
+
}
|
|
20423
20585
|
const { view, helpers: helpers2 } = this.editor;
|
|
20424
20586
|
const mergeRanges2 = (ranges) => {
|
|
20425
20587
|
if (ranges.length === 0) return [];
|
|
@@ -20537,6 +20699,7 @@ const LineBreak = Node$1.create({
|
|
|
20537
20699
|
clear: { rendered: false }
|
|
20538
20700
|
};
|
|
20539
20701
|
},
|
|
20702
|
+
// @ts-expect-error - Command signatures will be fixed in TS migration
|
|
20540
20703
|
addCommands() {
|
|
20541
20704
|
return {
|
|
20542
20705
|
/**
|
|
@@ -20599,6 +20762,7 @@ const HardBreak = Node$1.create({
|
|
|
20599
20762
|
renderDOM({ htmlAttributes }) {
|
|
20600
20763
|
return ["span", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
20601
20764
|
},
|
|
20765
|
+
// @ts-expect-error - Command signatures will be fixed in TS migration
|
|
20602
20766
|
addCommands() {
|
|
20603
20767
|
return {
|
|
20604
20768
|
/**
|
|
@@ -20617,15 +20781,6 @@ const HardBreak = Node$1.create({
|
|
|
20617
20781
|
};
|
|
20618
20782
|
}
|
|
20619
20783
|
});
|
|
20620
|
-
const getColStyleDeclaration = (minWidth, width) => {
|
|
20621
|
-
if (width != null) {
|
|
20622
|
-
const numericWidth = Number(width);
|
|
20623
|
-
if (Number.isFinite(numericWidth) && numericWidth >= 0) {
|
|
20624
|
-
return ["width", `${numericWidth}px`];
|
|
20625
|
-
}
|
|
20626
|
-
}
|
|
20627
|
-
return ["min-width", `${minWidth}px`];
|
|
20628
|
-
};
|
|
20629
20784
|
const createTableView = ({ editor }) => {
|
|
20630
20785
|
return class TableView {
|
|
20631
20786
|
constructor(node, cellMinWidth) {
|
|
@@ -20644,7 +20799,7 @@ const createTableView = ({ editor }) => {
|
|
|
20644
20799
|
this.table = this.dom.appendChild(document.createElement("table"));
|
|
20645
20800
|
this.colgroup = this.table.appendChild(document.createElement("colgroup"));
|
|
20646
20801
|
updateTable(this.editor, this.node, this.table);
|
|
20647
|
-
updateColumns(node, this.colgroup, this.table
|
|
20802
|
+
updateColumns(node, this.colgroup, this.table);
|
|
20648
20803
|
this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
20649
20804
|
setTimeout(() => {
|
|
20650
20805
|
updateTableWrapper(this.dom, this.table);
|
|
@@ -20656,7 +20811,7 @@ const createTableView = ({ editor }) => {
|
|
|
20656
20811
|
}
|
|
20657
20812
|
this.node = node;
|
|
20658
20813
|
updateTable(this.editor, node, this.table);
|
|
20659
|
-
updateColumns(node, this.colgroup, this.table, this.cellMinWidth
|
|
20814
|
+
updateColumns(node, this.colgroup, this.table, this.cellMinWidth);
|
|
20660
20815
|
updateTableWrapper(this.dom, this.table);
|
|
20661
20816
|
return true;
|
|
20662
20817
|
}
|
|
@@ -20669,43 +20824,20 @@ const createTableView = ({ editor }) => {
|
|
|
20669
20824
|
}
|
|
20670
20825
|
};
|
|
20671
20826
|
};
|
|
20672
|
-
function updateColumns(node, colgroup, table, cellMinWidth
|
|
20827
|
+
function updateColumns(node, colgroup, table, cellMinWidth) {
|
|
20673
20828
|
const gridColumns = Array.isArray(node.attrs?.grid) && node.attrs.grid.length ? node.attrs.grid.map((col) => twipsToPixels(col.col)) : null;
|
|
20674
20829
|
const totalColumns = gridColumns?.length ?? null;
|
|
20675
|
-
const pageBody = table.closest(".page__body");
|
|
20676
|
-
const wrapper = table.parentElement;
|
|
20677
|
-
let availableWidth = pageBody?.getBoundingClientRect?.().width;
|
|
20678
|
-
if (!availableWidth && wrapper) {
|
|
20679
|
-
availableWidth = wrapper.getBoundingClientRect().width;
|
|
20680
|
-
}
|
|
20681
|
-
if (typeof availableWidth === "number" && !Number.isNaN(availableWidth)) {
|
|
20682
|
-
availableWidth = Math.max(availableWidth - 2, 0);
|
|
20683
|
-
} else {
|
|
20684
|
-
availableWidth = null;
|
|
20685
|
-
}
|
|
20686
|
-
const pageStyles = editor?.converter?.pageStyles;
|
|
20687
|
-
if (pageStyles?.pageSize?.width) {
|
|
20688
|
-
const toNumber = (v) => typeof v === "number" ? v : parseFloat(v) || 0;
|
|
20689
|
-
const pageWidth = toNumber(pageStyles.pageSize.width);
|
|
20690
|
-
const marginLeft = toNumber(pageStyles.pageMargins?.left);
|
|
20691
|
-
const marginRight = toNumber(pageStyles.pageMargins?.right);
|
|
20692
|
-
const pageAvailableWidthPx = Math.max((pageWidth - marginLeft - marginRight) * PIXELS_PER_INCH, 0);
|
|
20693
|
-
if (pageAvailableWidthPx > 0) {
|
|
20694
|
-
availableWidth = availableWidth ? Math.min(availableWidth, pageAvailableWidthPx) : pageAvailableWidthPx;
|
|
20695
|
-
}
|
|
20696
|
-
}
|
|
20697
20830
|
const resolveColumnWidth = (colIndex2, colwidthValue) => {
|
|
20698
|
-
if (overrideCol === colIndex2) return overrideValue;
|
|
20699
20831
|
if (colwidthValue != null) return colwidthValue;
|
|
20700
20832
|
if (gridColumns && gridColumns[colIndex2] != null) return gridColumns[colIndex2];
|
|
20701
20833
|
return null;
|
|
20702
20834
|
};
|
|
20703
20835
|
const widths = [];
|
|
20704
|
-
const
|
|
20836
|
+
const firstRow = node.firstChild;
|
|
20705
20837
|
let colIndex = 0;
|
|
20706
|
-
if (
|
|
20707
|
-
for (let i = 0; i <
|
|
20708
|
-
const child =
|
|
20838
|
+
if (firstRow !== null) {
|
|
20839
|
+
for (let i = 0; i < firstRow.childCount; i++) {
|
|
20840
|
+
const child = firstRow.child(i);
|
|
20709
20841
|
const { colspan, colwidth } = child.attrs;
|
|
20710
20842
|
for (let span = 0; span < colspan; span += 1, colIndex += 1) {
|
|
20711
20843
|
widths.push(resolveColumnWidth(colIndex, colwidth && colwidth[span]));
|
|
@@ -20725,49 +20857,41 @@ function updateColumns(node, colgroup, table, cellMinWidth, overrideCol, overrid
|
|
|
20725
20857
|
if (numericWidth < 1) return 0;
|
|
20726
20858
|
return numericWidth;
|
|
20727
20859
|
});
|
|
20728
|
-
const
|
|
20729
|
-
|
|
20730
|
-
|
|
20731
|
-
|
|
20732
|
-
|
|
20733
|
-
let
|
|
20734
|
-
let hasUndefinedWidth = false;
|
|
20735
|
-
let dom = colgroup.firstChild;
|
|
20860
|
+
const tableWidthCSS = convertSizeToCSS(
|
|
20861
|
+
// TODO: why is tableWidth undefined in src/tests/import-export/font-default-styles.test.js?
|
|
20862
|
+
node.attrs.tableProperties.tableWidth?.value ?? null,
|
|
20863
|
+
node.attrs.tableProperties.tableWidth?.type ?? "auto"
|
|
20864
|
+
);
|
|
20865
|
+
let colElement = colgroup.firstChild;
|
|
20736
20866
|
normalizedWidths.forEach((width) => {
|
|
20737
|
-
|
|
20738
|
-
|
|
20739
|
-
scaledWidth = scaledWidth * scale;
|
|
20740
|
-
}
|
|
20741
|
-
const [propKey, propVal] = getColStyleDeclaration(cellMinWidth, scaledWidth);
|
|
20742
|
-
if (scaledWidth == null) {
|
|
20743
|
-
totalWidth += cellMinWidth;
|
|
20744
|
-
hasUndefinedWidth = true;
|
|
20745
|
-
} else {
|
|
20746
|
-
totalWidth += scaledWidth;
|
|
20747
|
-
}
|
|
20748
|
-
if (!dom) {
|
|
20749
|
-
const colElement = document.createElement("col");
|
|
20750
|
-
colElement.style.setProperty(propKey, propVal);
|
|
20867
|
+
if (!colElement) {
|
|
20868
|
+
colElement = document.createElement("col");
|
|
20751
20869
|
colgroup.appendChild(colElement);
|
|
20752
|
-
} else {
|
|
20753
|
-
dom.style.setProperty(propKey, propVal);
|
|
20754
|
-
dom = dom.nextSibling;
|
|
20755
20870
|
}
|
|
20871
|
+
colElement.style.width = width !== null && width !== void 0 ? `${width}px` : null;
|
|
20872
|
+
colElement = colElement.nextSibling;
|
|
20756
20873
|
});
|
|
20757
|
-
while (
|
|
20758
|
-
const next =
|
|
20759
|
-
|
|
20760
|
-
|
|
20761
|
-
}
|
|
20762
|
-
|
|
20763
|
-
|
|
20764
|
-
|
|
20765
|
-
|
|
20874
|
+
while (colElement) {
|
|
20875
|
+
const next = colElement.nextSibling;
|
|
20876
|
+
colElement.parentNode?.removeChild(colElement);
|
|
20877
|
+
colElement = next;
|
|
20878
|
+
}
|
|
20879
|
+
const tableIndent = convertSizeToCSS(
|
|
20880
|
+
node.attrs.tableProperties.tableIndent?.value ?? 0,
|
|
20881
|
+
node.attrs.tableProperties.tableIndent?.type ?? "dxa"
|
|
20882
|
+
);
|
|
20883
|
+
const firstRowFirstCellPaddingLeftPx = firstRow?.firstChild?.attrs?.cellMargins?.left ?? 0;
|
|
20884
|
+
const firstRowLastCellPaddingRightPx = firstRow?.lastChild?.attrs?.cellMargins?.right ?? 0;
|
|
20885
|
+
table.style.marginLeft = `${-firstRowFirstCellPaddingLeftPx}px`;
|
|
20886
|
+
if (tableIndent !== null) {
|
|
20887
|
+
table.style.marginLeft = tableIndent;
|
|
20888
|
+
}
|
|
20889
|
+
if (node.attrs.tableProperties.tableWidth?.type === "pct") {
|
|
20890
|
+
const padding = firstRowFirstCellPaddingLeftPx + firstRowLastCellPaddingRightPx;
|
|
20891
|
+
table.style.maxWidth = table.style.width = `calc(${tableWidthCSS} + ${padding}px)`;
|
|
20766
20892
|
} else {
|
|
20767
|
-
table.style.width =
|
|
20768
|
-
table.style.minWidth = `${totalWidth}px`;
|
|
20893
|
+
table.style.maxWidth = table.style.width = tableWidthCSS;
|
|
20769
20894
|
}
|
|
20770
|
-
table.style.maxWidth = "100%";
|
|
20771
20895
|
}
|
|
20772
20896
|
function updateTable(editor, node, table) {
|
|
20773
20897
|
const allExtensionsAttrs = editor.extensionService.attributes;
|
|
@@ -20845,6 +20969,15 @@ const createTable = (schema, rowsCount, colsCount, withHeaderRow, cellContent =
|
|
|
20845
20969
|
const tableBorders = createTableBorders();
|
|
20846
20970
|
return types.table.createChecked({ borders: tableBorders }, rows);
|
|
20847
20971
|
};
|
|
20972
|
+
const getColStyleDeclaration = (minWidth, width) => {
|
|
20973
|
+
if (width != null) {
|
|
20974
|
+
const numericWidth = Number(width);
|
|
20975
|
+
if (Number.isFinite(numericWidth) && numericWidth >= 0) {
|
|
20976
|
+
return ["width", `${numericWidth}px`];
|
|
20977
|
+
}
|
|
20978
|
+
}
|
|
20979
|
+
return ["min-width", `${minWidth}px`];
|
|
20980
|
+
};
|
|
20848
20981
|
const MIN_MEANINGFUL_WIDTH_PX = 1;
|
|
20849
20982
|
const createColGroup = (node, cellMinWidth, overrideCol, overrideValue) => {
|
|
20850
20983
|
let totalWidth = 0;
|
|
@@ -23211,15 +23344,6 @@ const Table = Node$1.create({
|
|
|
23211
23344
|
},
|
|
23212
23345
|
addAttributes() {
|
|
23213
23346
|
return {
|
|
23214
|
-
/* tableWidth: {
|
|
23215
|
-
renderDOM: ({ tableWidth }) => {
|
|
23216
|
-
if (!tableWidth) return {};
|
|
23217
|
-
const { width, type = 'auto' } = tableWidth;
|
|
23218
|
-
return {
|
|
23219
|
-
style: `width: ${width}px`
|
|
23220
|
-
};
|
|
23221
|
-
},
|
|
23222
|
-
}, */
|
|
23223
23347
|
/**
|
|
23224
23348
|
* @private
|
|
23225
23349
|
* @category Attribute
|
|
@@ -23323,7 +23447,12 @@ const Table = Node$1.create({
|
|
|
23323
23447
|
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 371-483
|
|
23324
23448
|
*/
|
|
23325
23449
|
tableProperties: {
|
|
23326
|
-
default:
|
|
23450
|
+
default: {
|
|
23451
|
+
tableWidth: {
|
|
23452
|
+
value: null,
|
|
23453
|
+
type: "auto"
|
|
23454
|
+
}
|
|
23455
|
+
},
|
|
23327
23456
|
rendered: false
|
|
23328
23457
|
},
|
|
23329
23458
|
/**
|
|
@@ -23345,9 +23474,9 @@ const Table = Node$1.create({
|
|
|
23345
23474
|
const attrs = Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes, {
|
|
23346
23475
|
style: tableWidth ? `width: ${tableWidth}` : `min-width: ${tableMinWidth}`
|
|
23347
23476
|
});
|
|
23348
|
-
|
|
23349
|
-
return table;
|
|
23477
|
+
return ["table", attrs, colgroup, ["tbody", 0]];
|
|
23350
23478
|
},
|
|
23479
|
+
// @ts-expect-error - Command signatures will be fixed in TS migration
|
|
23351
23480
|
addCommands() {
|
|
23352
23481
|
return {
|
|
23353
23482
|
/**
|
|
@@ -23869,9 +23998,13 @@ const Table = Node$1.create({
|
|
|
23869
23998
|
return [
|
|
23870
23999
|
...resizable ? [
|
|
23871
24000
|
columnResizing({
|
|
24001
|
+
// @ts-expect-error - Options types will be fixed in TS migration
|
|
23872
24002
|
handleWidth: this.options.handleWidth,
|
|
24003
|
+
// @ts-expect-error - Options types will be fixed in TS migration
|
|
23873
24004
|
cellMinWidth: this.options.cellMinWidth,
|
|
24005
|
+
// @ts-expect-error - Options types will be fixed in TS migration
|
|
23874
24006
|
defaultCellMinWidth: this.options.cellMinWidth,
|
|
24007
|
+
// @ts-expect-error - Options types will be fixed in TS migration
|
|
23875
24008
|
lastColumnResizable: this.options.lastColumnResizable,
|
|
23876
24009
|
View: createTableView({
|
|
23877
24010
|
editor: this.editor
|
|
@@ -23879,6 +24012,7 @@ const Table = Node$1.create({
|
|
|
23879
24012
|
})
|
|
23880
24013
|
] : [],
|
|
23881
24014
|
tableEditing({
|
|
24015
|
+
// @ts-expect-error - Options types will be fixed in TS migration
|
|
23882
24016
|
allowTableNodeSelection: this.options.allowTableNodeSelection
|
|
23883
24017
|
})
|
|
23884
24018
|
];
|
|
@@ -23941,6 +24075,7 @@ const TableHeader = Node$1.create({
|
|
|
23941
24075
|
renderDOM: (attrs) => {
|
|
23942
24076
|
if (!attrs.colwidth) return {};
|
|
23943
24077
|
return {
|
|
24078
|
+
// @ts-expect-error - colwidth is known to be an array at runtime
|
|
23944
24079
|
"data-colwidth": attrs.colwidth.join(",")
|
|
23945
24080
|
};
|
|
23946
24081
|
}
|
|
@@ -24064,6 +24199,7 @@ const TableCell = Node$1.create({
|
|
|
24064
24199
|
renderDOM: (attrs) => {
|
|
24065
24200
|
if (!attrs.colwidth) return {};
|
|
24066
24201
|
return {
|
|
24202
|
+
// @ts-expect-error - colwidth is known to be an array at runtime
|
|
24067
24203
|
"data-colwidth": attrs.colwidth.join(",")
|
|
24068
24204
|
};
|
|
24069
24205
|
}
|
|
@@ -24084,12 +24220,14 @@ const TableCell = Node$1.create({
|
|
|
24084
24220
|
}
|
|
24085
24221
|
},
|
|
24086
24222
|
cellMargins: {
|
|
24087
|
-
renderDOM({ cellMargins }) {
|
|
24223
|
+
renderDOM({ cellMargins, borders }) {
|
|
24088
24224
|
if (!cellMargins) return {};
|
|
24089
24225
|
const sides2 = ["top", "right", "bottom", "left"];
|
|
24090
24226
|
const style = sides2.map((side) => {
|
|
24091
|
-
const margin = cellMargins?.[side];
|
|
24092
|
-
|
|
24227
|
+
const margin = cellMargins?.[side] ?? 0;
|
|
24228
|
+
const border = borders?.[side];
|
|
24229
|
+
const borderSize = border && border.val !== "none" ? Math.ceil(border.size) : 0;
|
|
24230
|
+
if (margin) return `padding-${side}: ${Math.max(0, margin - borderSize)}px;`;
|
|
24093
24231
|
return "";
|
|
24094
24232
|
}).join(" ");
|
|
24095
24233
|
return { style };
|
|
@@ -27159,6 +27297,7 @@ const BookmarkStart = Node$1.create({
|
|
|
27159
27297
|
renderDOM({ htmlAttributes }) {
|
|
27160
27298
|
return ["a", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
27161
27299
|
},
|
|
27300
|
+
// @ts-expect-error - Command signatures will be fixed in TS migration
|
|
27162
27301
|
addCommands() {
|
|
27163
27302
|
return {
|
|
27164
27303
|
/**
|
|
@@ -27262,6 +27401,7 @@ const BookmarkEnd = Node$1.create({
|
|
|
27262
27401
|
renderDOM({ htmlAttributes }) {
|
|
27263
27402
|
return ["span", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
27264
27403
|
},
|
|
27404
|
+
// @ts-expect-error - Command signatures will be fixed in TS migration
|
|
27265
27405
|
addCommands() {
|
|
27266
27406
|
return {
|
|
27267
27407
|
/**
|
|
@@ -27287,6 +27427,7 @@ const Mention = Node$1.create({
|
|
|
27287
27427
|
group: "inline",
|
|
27288
27428
|
inline: true,
|
|
27289
27429
|
selectable: false,
|
|
27430
|
+
excludeFromSummaryJSON: true,
|
|
27290
27431
|
atom: true,
|
|
27291
27432
|
addOptions() {
|
|
27292
27433
|
return {
|
|
@@ -27767,8 +27908,10 @@ const ContentBlock = Node$1.create({
|
|
|
27767
27908
|
if (size.top) style += `top: ${size.top}px; `;
|
|
27768
27909
|
if (size.left) style += `left: ${size.left}px; `;
|
|
27769
27910
|
if (size.width) style += `width: ${size.width.toString().endsWith("%") ? size.width : `${size.width}px`}; `;
|
|
27770
|
-
if (size.height)
|
|
27771
|
-
|
|
27911
|
+
if (size.height) {
|
|
27912
|
+
const heightValue = size.height.toString().endsWith("%") ? size.height : `${size.height}px`;
|
|
27913
|
+
style += `height: ${heightValue}; `;
|
|
27914
|
+
}
|
|
27772
27915
|
return { style };
|
|
27773
27916
|
}
|
|
27774
27917
|
},
|
|
@@ -27799,6 +27942,7 @@ const ContentBlock = Node$1.create({
|
|
|
27799
27942
|
renderDOM({ htmlAttributes }) {
|
|
27800
27943
|
return ["div", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes, { "data-type": this.name })];
|
|
27801
27944
|
},
|
|
27945
|
+
// @ts-expect-error - Command signatures will be fixed in TS migration
|
|
27802
27946
|
addCommands() {
|
|
27803
27947
|
return {
|
|
27804
27948
|
/**
|
|
@@ -37123,6 +37267,7 @@ function setSearchState(tr, query, range = null) {
|
|
|
37123
37267
|
}
|
|
37124
37268
|
const isRegExp = (value) => Object.prototype.toString.call(value) === "[object RegExp]";
|
|
37125
37269
|
const Search = Extension.create({
|
|
37270
|
+
// @ts-expect-error - Storage type mismatch will be fixed in TS migration
|
|
37126
37271
|
addStorage() {
|
|
37127
37272
|
return {
|
|
37128
37273
|
/**
|