@harbour-enterprises/superdoc 0.20.0-next.9 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{PdfViewer-BqGjx7hC.cjs → PdfViewer--8KwZWwP.cjs} +1 -1
- package/dist/chunks/{PdfViewer-BZlsmhsJ.es.js → PdfViewer-SpPk10jl.es.js} +1 -1
- package/dist/chunks/{index-4GToG3C3.es.js → index-BjLjS5O9.es.js} +3 -3
- package/dist/chunks/{index-DPzgGSfg.cjs → index-yRUOdLmp.cjs} +3 -3
- package/dist/chunks/{super-editor.es-BkxUKZfn.cjs → super-editor.es-CuNhawtn.cjs} +2505 -3347
- package/dist/chunks/{super-editor.es-DqX3Ipsk.es.js → super-editor.es-D24_Ox1u.es.js} +2505 -3347
- package/dist/core/SuperDoc.d.ts.map +1 -1
- package/dist/style.css +0 -38
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-C6YOTAXG.js → converter-Cg4SgA5y.js} +1119 -1659
- package/dist/super-editor/chunks/{docx-zipper-CSiwWpmr.js → docx-zipper-CDX2fnxb.js} +2 -2
- package/dist/super-editor/chunks/{editor-chVid4VD.js → editor-MKuu81v8.js} +1048 -1339
- package/dist/super-editor/chunks/{toolbar-ancqgN0p.js → toolbar-CpQ7L2K-.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/src/core/helpers/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/exporter.d.ts +1 -7
- package/dist/super-editor/src/core/super-converter/helpers.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v2/importer/imageImporter.d.ts +1 -1
- package/dist/super-editor/src/core/super-converter/v2/importer/tableImporter.d.ts +22 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/utils.d.ts +3 -10
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/w-p-helpers.d.ts +1 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tc/helpers/legacy-handle-table-cell-node.d.ts +1 -1
- package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +1 -11
- package/dist/super-editor/src/extensions/block-node/block-node.d.ts +5 -30
- package/dist/super-editor/src/extensions/bold/bold.d.ts +0 -20
- package/dist/super-editor/src/extensions/bullet-list/bullet-list.d.ts +0 -12
- package/dist/super-editor/src/extensions/color/color.d.ts +0 -26
- package/dist/super-editor/src/extensions/content-block/content-block.d.ts +0 -30
- package/dist/super-editor/src/extensions/custom-selection/custom-selection.d.ts +0 -16
- package/dist/super-editor/src/extensions/document/document.d.ts +0 -26
- package/dist/super-editor/src/extensions/dropcursor/dropcursor.d.ts +0 -26
- package/dist/super-editor/src/extensions/font-family/font-family.d.ts +0 -29
- package/dist/super-editor/src/extensions/font-size/font-size.d.ts +0 -21
- package/dist/super-editor/src/extensions/format-commands/format-commands.d.ts +0 -9
- package/dist/super-editor/src/extensions/gapcursor/gapcursor.d.ts +0 -9
- package/dist/super-editor/src/extensions/heading/heading.d.ts +6 -12
- package/dist/super-editor/src/extensions/highlight/highlight.d.ts +0 -20
- package/dist/super-editor/src/extensions/history/history.d.ts +15 -7
- package/dist/super-editor/src/extensions/image/image.d.ts +0 -78
- package/dist/super-editor/src/extensions/image/imageHelpers/imagePlaceholderPlugin.d.ts +5 -0
- package/dist/super-editor/src/extensions/image/imageHelpers/index.d.ts +1 -3
- package/dist/super-editor/src/extensions/image/imageHelpers/processUploadedImage.d.ts +2 -2
- package/dist/super-editor/src/extensions/image/imageHelpers/startImageUpload.d.ts +23 -18
- package/dist/super-editor/src/extensions/italic/italic.d.ts +0 -10
- package/dist/super-editor/src/extensions/line-break/line-break.d.ts +0 -43
- package/dist/super-editor/src/extensions/line-height/line-height.d.ts +0 -22
- package/dist/super-editor/src/extensions/link/link.d.ts +25 -53
- package/dist/super-editor/src/extensions/linked-styles/linked-styles.d.ts +0 -9
- package/dist/super-editor/src/extensions/list-item/list-item.d.ts +0 -48
- package/dist/super-editor/src/extensions/mention/mention.d.ts +0 -26
- package/dist/super-editor/src/extensions/noderesizer/noderesizer.d.ts +0 -14
- package/dist/super-editor/src/extensions/ordered-list/ordered-list.d.ts +0 -35
- package/dist/super-editor/src/extensions/page-number/page-number.d.ts +0 -52
- package/dist/super-editor/src/extensions/paragraph/paragraph.d.ts +0 -49
- package/dist/super-editor/src/extensions/placeholder/placeholder.d.ts +0 -15
- package/dist/super-editor/src/extensions/popover-plugin/popover-plugin.d.ts +0 -9
- package/dist/super-editor/src/extensions/run-item/run-item.d.ts +0 -24
- package/dist/super-editor/src/extensions/search/search.d.ts +2 -11
- package/dist/super-editor/src/extensions/shape-container/shape-container.d.ts +0 -29
- package/dist/super-editor/src/extensions/shape-textbox/shape-textbox.d.ts +0 -26
- package/dist/super-editor/src/extensions/slash-menu/slash-menu.d.ts +0 -9
- package/dist/super-editor/src/extensions/strike/strike.d.ts +0 -10
- package/dist/super-editor/src/extensions/structured-content/document-section.d.ts +27 -46
- package/dist/super-editor/src/extensions/structured-content/structured-content-block.d.ts +1 -29
- package/dist/super-editor/src/extensions/structured-content/structured-content.d.ts +1 -29
- package/dist/super-editor/src/extensions/tab/tab.d.ts +0 -25
- package/dist/super-editor/src/extensions/table/table.d.ts +55 -376
- package/dist/super-editor/src/extensions/table-cell/table-cell.d.ts +0 -41
- package/dist/super-editor/src/extensions/table-header/table-header.d.ts +0 -22
- package/dist/super-editor/src/extensions/table-row/table-row.d.ts +0 -28
- package/dist/super-editor/src/extensions/text/text.d.ts +0 -14
- package/dist/super-editor/src/extensions/text-align/text-align.d.ts +0 -22
- package/dist/super-editor/src/extensions/text-indent/text-indent.d.ts +10 -19
- package/dist/super-editor/src/extensions/text-style/text-style.d.ts +0 -20
- package/dist/super-editor/src/extensions/text-transform/text-transform.d.ts +0 -20
- package/dist/super-editor/src/extensions/underline/underline.d.ts +0 -25
- package/dist/super-editor/style.css +0 -38
- package/dist/super-editor/super-editor.es.js +55 -65
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +3134 -3976
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/super-editor/src/core/helpers/updateDOMAttributes.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/export-helpers/pre-process-vertical-merge-cells.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/helpers/mediaHelpers.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bidiVisual/bidiVisual-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bidiVisual/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/bottom-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/marginBottom-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/drawing/drawing-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/drawing/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/end-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/marginEnd-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/gridCol/gridCol-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/gridCol/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideH/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideH/insideH-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideV/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideV/insideV-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/left-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/marginLeft-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/marginRight-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/right-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/shd/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/shd/shd-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/marginStart-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/start-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tbl/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tbl/tbl-translator.d.ts +0 -28
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblBorders/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblBorders/tblBorders-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCaption/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCaption/tblCaption-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCellMar/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCellMar/tblCellMar-translator.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblDescription/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblDescription/tblDescription-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-helpers.d.ts +0 -5
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-translator.d.ts +0 -5
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblInd/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblInd/tblInd-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLayout/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLayout/tblLayout-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLook/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLook/tblLook-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblOverlap/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblOverlap/tblOverlap-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblPr/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblPr/tblPr-translator.d.ts +0 -5
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyle/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyle/tblStyle-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleColBandSize/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleColBandSize/tblStyleColBandSize-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleRowBandSize/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleRowBandSize/tblStyleRowBandSize-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblW/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblW/tblW-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblpPr/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblpPr/tblpPr-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/marginTop-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/top-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/anchor-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/helpers/handle-anchor-node.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/helpers/translate-anchor-node.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/decode-image-node-helpers.d.ts +0 -18
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/encode-image-node-helpers.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/helpers/handle-inline-node.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/helpers/translate-inline-node.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/inline-translator.d.ts +0 -6
- package/dist/super-editor/src/extensions/image/imageHelpers/fileNameUtils.d.ts +0 -3
- package/dist/super-editor/src/extensions/image/imageHelpers/handleBase64.d.ts +0 -1
- package/dist/super-editor/src/extensions/image/imageHelpers/handleUrl.d.ts +0 -2
- package/dist/super-editor/src/extensions/image/imageHelpers/imageRegistrationPlugin.d.ts +0 -11
- package/dist/super-editor/src/extensions/image/imageHelpers/rotation.d.ts +0 -4
- package/dist/super-editor/src/extensions/structured-content/StructuredContentBlockView.d.ts +0 -9
- package/dist/super-editor/src/extensions/structured-content/StructuredContentInlineView.d.ts +0 -9
- package/dist/super-editor/src/extensions/structured-content/StructuredContentViewBase.d.ts +0 -24
- package/dist/super-editor/src/tests/helpers/editor-test-utils.d.ts +0 -14
|
@@ -2,8 +2,8 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __typeError = (msg) => {
|
|
3
3
|
throw TypeError(msg);
|
|
4
4
|
};
|
|
5
|
-
var __defNormalProp = (obj,
|
|
6
|
-
var __publicField = (obj,
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
7
|
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
8
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
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);
|
|
@@ -12,9 +12,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
12
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, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_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, _ListItemNodeView_instances, init_fn2, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _DocumentSectionView_instances, init_fn3, addToolTip_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 ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as InputRule, ah as kebabCase, ai as findParentNodeClosestToPos, aj as getListItemStyleDefinitions, ak as docxNumberigHelpers, al as parseIndentElement, am as combineIndents, an as StepMap, ao as
|
|
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 ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as InputRule, ah as kebabCase, ai as findParentNodeClosestToPos, aj as getListItemStyleDefinitions, ak as docxNumberigHelpers, al as parseIndentElement, am as combineIndents, an as StepMap, ao as getColStyleDeclaration, ap as SelectionRange, aq as Transform, ar as isInTable$1, as as createColGroup, at as generateDocxRandomId, au as insertNewRelationship, av as htmlHandler } from "./converter-Cg4SgA5y.js";
|
|
16
16
|
import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
|
|
17
|
-
import { D as DocxZipper } from "./docx-zipper-
|
|
17
|
+
import { D as DocxZipper } from "./docx-zipper-CDX2fnxb.js";
|
|
18
18
|
var GOOD_LEAF_SIZE = 200;
|
|
19
19
|
var RopeSequence = function RopeSequence2() {
|
|
20
20
|
};
|
|
@@ -662,11 +662,11 @@ function hasBlockDesc(dom) {
|
|
|
662
662
|
const selectionCollapsed = function(domSel) {
|
|
663
663
|
return domSel.focusNode && isEquivalentPosition(domSel.focusNode, domSel.focusOffset, domSel.anchorNode, domSel.anchorOffset);
|
|
664
664
|
};
|
|
665
|
-
function keyEvent(keyCode,
|
|
665
|
+
function keyEvent(keyCode, key) {
|
|
666
666
|
let event = document.createEvent("Event");
|
|
667
667
|
event.initEvent("keydown", true, true);
|
|
668
668
|
event.keyCode = keyCode;
|
|
669
|
-
event.key = event.code =
|
|
669
|
+
event.key = event.code = key;
|
|
670
670
|
return event;
|
|
671
671
|
}
|
|
672
672
|
function deepActiveElement(doc2) {
|
|
@@ -1872,18 +1872,17 @@ class NodeViewDesc extends ViewDesc {
|
|
|
1872
1872
|
}
|
|
1873
1873
|
// Mark this node as being the selected node.
|
|
1874
1874
|
selectNode() {
|
|
1875
|
-
if (this.nodeDOM.nodeType == 1)
|
|
1875
|
+
if (this.nodeDOM.nodeType == 1)
|
|
1876
1876
|
this.nodeDOM.classList.add("ProseMirror-selectednode");
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
}
|
|
1877
|
+
if (this.contentDOM || !this.node.type.spec.draggable)
|
|
1878
|
+
this.dom.draggable = true;
|
|
1880
1879
|
}
|
|
1881
1880
|
// Remove selected node marking from this node.
|
|
1882
1881
|
deselectNode() {
|
|
1883
1882
|
if (this.nodeDOM.nodeType == 1) {
|
|
1884
1883
|
this.nodeDOM.classList.remove("ProseMirror-selectednode");
|
|
1885
1884
|
if (this.contentDOM || !this.node.type.spec.draggable)
|
|
1886
|
-
this.
|
|
1885
|
+
this.dom.removeAttribute("draggable");
|
|
1887
1886
|
}
|
|
1888
1887
|
}
|
|
1889
1888
|
get domAtom() {
|
|
@@ -3543,7 +3542,7 @@ class MouseDown {
|
|
|
3543
3542
|
}
|
|
3544
3543
|
const target = flushed ? null : event.target;
|
|
3545
3544
|
const targetDesc = target ? view.docView.nearestDesc(target, true) : null;
|
|
3546
|
-
this.target = targetDesc && targetDesc.
|
|
3545
|
+
this.target = targetDesc && targetDesc.dom.nodeType == 1 ? targetDesc.dom : null;
|
|
3547
3546
|
let { selection } = view.state;
|
|
3548
3547
|
if (event.button == 0 && targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos)
|
|
3549
3548
|
this.mightDrag = {
|
|
@@ -5914,9 +5913,9 @@ const writeAny = (encoder, data) => {
|
|
|
5914
5913
|
const keys2 = Object.keys(data);
|
|
5915
5914
|
writeVarUint(encoder, keys2.length);
|
|
5916
5915
|
for (let i = 0; i < keys2.length; i++) {
|
|
5917
|
-
const
|
|
5918
|
-
writeVarString(encoder,
|
|
5919
|
-
writeAny(encoder, data[
|
|
5916
|
+
const key = keys2[i];
|
|
5917
|
+
writeVarString(encoder, key);
|
|
5918
|
+
writeAny(encoder, data[key]);
|
|
5920
5919
|
}
|
|
5921
5920
|
}
|
|
5922
5921
|
break;
|
|
@@ -5935,17 +5934,17 @@ const unexpectedCase = () => {
|
|
|
5935
5934
|
throw create$1("Unexpected case");
|
|
5936
5935
|
};
|
|
5937
5936
|
const create = () => /* @__PURE__ */ new Map();
|
|
5938
|
-
const setIfUndefined = (map2,
|
|
5939
|
-
let set = map2.get(
|
|
5937
|
+
const setIfUndefined = (map2, key, createT) => {
|
|
5938
|
+
let set = map2.get(key);
|
|
5940
5939
|
if (set === void 0) {
|
|
5941
|
-
map2.set(
|
|
5940
|
+
map2.set(key, set = createT());
|
|
5942
5941
|
}
|
|
5943
5942
|
return set;
|
|
5944
5943
|
};
|
|
5945
5944
|
const keys = Object.keys;
|
|
5946
5945
|
const every = (obj, f) => {
|
|
5947
|
-
for (const
|
|
5948
|
-
if (!f(obj[
|
|
5946
|
+
for (const key in obj) {
|
|
5947
|
+
if (!f(obj[key], key)) {
|
|
5949
5948
|
return false;
|
|
5950
5949
|
}
|
|
5951
5950
|
}
|
|
@@ -6001,14 +6000,14 @@ class VarStoragePolyfill {
|
|
|
6001
6000
|
* @param {string} key
|
|
6002
6001
|
* @param {any} newValue
|
|
6003
6002
|
*/
|
|
6004
|
-
setItem(
|
|
6005
|
-
this.map.set(
|
|
6003
|
+
setItem(key, newValue) {
|
|
6004
|
+
this.map.set(key, newValue);
|
|
6006
6005
|
}
|
|
6007
6006
|
/**
|
|
6008
6007
|
* @param {string} key
|
|
6009
6008
|
*/
|
|
6010
|
-
getItem(
|
|
6011
|
-
return this.map.get(
|
|
6009
|
+
getItem(key) {
|
|
6010
|
+
return this.map.get(key);
|
|
6012
6011
|
}
|
|
6013
6012
|
}
|
|
6014
6013
|
let _localStorage = new VarStoragePolyfill();
|
|
@@ -6051,9 +6050,9 @@ const computeParams = () => {
|
|
|
6051
6050
|
params = create();
|
|
6052
6051
|
(location.search || "?").slice(1).split("&").forEach((kv) => {
|
|
6053
6052
|
if (kv.length !== 0) {
|
|
6054
|
-
const [
|
|
6055
|
-
params.set(`--${fromCamelCase(
|
|
6056
|
-
params.set(`-${fromCamelCase(
|
|
6053
|
+
const [key, value] = kv.split("=");
|
|
6054
|
+
params.set(`--${fromCamelCase(key, "-")}`, value);
|
|
6055
|
+
params.set(`-${fromCamelCase(key, "-")}`, value);
|
|
6057
6056
|
}
|
|
6058
6057
|
});
|
|
6059
6058
|
} else {
|
|
@@ -6336,8 +6335,8 @@ const ySyncPlugin = (yXmlFragment, {
|
|
|
6336
6335
|
const change = tr.getMeta(ySyncPluginKey);
|
|
6337
6336
|
if (change !== void 0) {
|
|
6338
6337
|
pluginState = Object.assign({}, pluginState);
|
|
6339
|
-
for (const
|
|
6340
|
-
pluginState[
|
|
6338
|
+
for (const key in change) {
|
|
6339
|
+
pluginState[key] = change[key];
|
|
6341
6340
|
}
|
|
6342
6341
|
}
|
|
6343
6342
|
pluginState.addToHistory = tr.getMeta("addToHistory") !== false;
|
|
@@ -6609,7 +6608,7 @@ class ProsemirrorBinding {
|
|
|
6609
6608
|
snapshot = Y.snapshot(historyDoc);
|
|
6610
6609
|
if (historyType._item === null) {
|
|
6611
6610
|
const rootKey = Array.from(this.doc.share.keys()).find(
|
|
6612
|
-
(
|
|
6611
|
+
(key) => this.doc.share.get(key) === this.type
|
|
6613
6612
|
);
|
|
6614
6613
|
historyType = historyDoc.getXmlFragment(rootKey);
|
|
6615
6614
|
} else {
|
|
@@ -6898,10 +6897,10 @@ const createTypeFromTextNodes = (nodes, meta) => {
|
|
|
6898
6897
|
};
|
|
6899
6898
|
const createTypeFromElementNode = (node, meta) => {
|
|
6900
6899
|
const type = new Y.XmlElement(node.type.name);
|
|
6901
|
-
for (const
|
|
6902
|
-
const val = node.attrs[
|
|
6903
|
-
if (val !== null &&
|
|
6904
|
-
type.setAttribute(
|
|
6900
|
+
for (const key in node.attrs) {
|
|
6901
|
+
const val = node.attrs[key];
|
|
6902
|
+
if (val !== null && key !== "ychange") {
|
|
6903
|
+
type.setAttribute(key, val);
|
|
6905
6904
|
}
|
|
6906
6905
|
}
|
|
6907
6906
|
type.insert(
|
|
@@ -6916,13 +6915,13 @@ const createTypeFromElementNode = (node, meta) => {
|
|
|
6916
6915
|
const createTypeFromTextOrElementNode = (node, meta) => node instanceof Array ? createTypeFromTextNodes(node, meta) : createTypeFromElementNode(node, meta);
|
|
6917
6916
|
const isObject = (val) => typeof val === "object" && val !== null;
|
|
6918
6917
|
const equalAttrs = (pattrs, yattrs) => {
|
|
6919
|
-
const keys2 = Object.keys(pattrs).filter((
|
|
6920
|
-
let eq = keys2.length === (yattrs == null ? 0 : Object.keys(yattrs).filter((
|
|
6918
|
+
const keys2 = Object.keys(pattrs).filter((key) => pattrs[key] !== null);
|
|
6919
|
+
let eq = keys2.length === (yattrs == null ? 0 : Object.keys(yattrs).filter((key) => yattrs[key] !== null).length);
|
|
6921
6920
|
for (let i = 0; i < keys2.length && eq; i++) {
|
|
6922
|
-
const
|
|
6923
|
-
const l = pattrs[
|
|
6924
|
-
const r2 = yattrs[
|
|
6925
|
-
eq =
|
|
6921
|
+
const key = keys2[i];
|
|
6922
|
+
const l = pattrs[key];
|
|
6923
|
+
const r2 = yattrs[key];
|
|
6924
|
+
eq = key === "ychange" || l === r2 || isObject(l) && isObject(r2) && equalAttrs(l, r2);
|
|
6926
6925
|
}
|
|
6927
6926
|
return eq;
|
|
6928
6927
|
};
|
|
@@ -7069,18 +7068,18 @@ const updateYFragment = (y, yDomFragment, pNode, meta) => {
|
|
|
7069
7068
|
if (yDomFragment instanceof Y.XmlElement) {
|
|
7070
7069
|
const yDomAttrs = yDomFragment.getAttributes();
|
|
7071
7070
|
const pAttrs = pNode.attrs;
|
|
7072
|
-
for (const
|
|
7073
|
-
if (pAttrs[
|
|
7074
|
-
if (yDomAttrs[
|
|
7075
|
-
yDomFragment.setAttribute(
|
|
7071
|
+
for (const key in pAttrs) {
|
|
7072
|
+
if (pAttrs[key] !== null) {
|
|
7073
|
+
if (yDomAttrs[key] !== pAttrs[key] && key !== "ychange") {
|
|
7074
|
+
yDomFragment.setAttribute(key, pAttrs[key]);
|
|
7076
7075
|
}
|
|
7077
7076
|
} else {
|
|
7078
|
-
yDomFragment.removeAttribute(
|
|
7077
|
+
yDomFragment.removeAttribute(key);
|
|
7079
7078
|
}
|
|
7080
7079
|
}
|
|
7081
|
-
for (const
|
|
7082
|
-
if (pAttrs[
|
|
7083
|
-
yDomFragment.removeAttribute(
|
|
7080
|
+
for (const key in yDomAttrs) {
|
|
7081
|
+
if (pAttrs[key] === void 0) {
|
|
7082
|
+
yDomFragment.removeAttribute(key);
|
|
7084
7083
|
}
|
|
7085
7084
|
}
|
|
7086
7085
|
}
|
|
@@ -7211,19 +7210,19 @@ const updateMetas = () => {
|
|
|
7211
7210
|
const tr = view.state.tr;
|
|
7212
7211
|
const syncState = ySyncPluginKey.getState(view.state);
|
|
7213
7212
|
if (syncState && syncState.binding && !syncState.binding.isDestroyed) {
|
|
7214
|
-
metas.forEach((val,
|
|
7215
|
-
tr.setMeta(
|
|
7213
|
+
metas.forEach((val, key) => {
|
|
7214
|
+
tr.setMeta(key, val);
|
|
7216
7215
|
});
|
|
7217
7216
|
view.dispatch(tr);
|
|
7218
7217
|
}
|
|
7219
7218
|
});
|
|
7220
7219
|
};
|
|
7221
|
-
const setMeta$1 = (view,
|
|
7220
|
+
const setMeta$1 = (view, key, value) => {
|
|
7222
7221
|
if (!viewsToUpdate) {
|
|
7223
7222
|
viewsToUpdate = /* @__PURE__ */ new Map();
|
|
7224
7223
|
timeout(0, updateMetas);
|
|
7225
7224
|
}
|
|
7226
|
-
setIfUndefined(viewsToUpdate, view, create).set(
|
|
7225
|
+
setIfUndefined(viewsToUpdate, view, create).set(key, value);
|
|
7227
7226
|
};
|
|
7228
7227
|
const absolutePositionToRelativePosition = (pos, type, mapping) => {
|
|
7229
7228
|
if (pos === 0) {
|
|
@@ -7683,6 +7682,12 @@ const History = Extension.create({
|
|
|
7683
7682
|
name: "history",
|
|
7684
7683
|
addOptions() {
|
|
7685
7684
|
return {
|
|
7685
|
+
/**
|
|
7686
|
+
* @typedef {Object} HistoryOptions
|
|
7687
|
+
* @category Options
|
|
7688
|
+
* @property {number} [depth=100] - Maximum undo/redo steps to remember
|
|
7689
|
+
* @property {number} [newGroupDelay=500] - Milliseconds to wait before starting a new history group
|
|
7690
|
+
*/
|
|
7686
7691
|
depth: 100,
|
|
7687
7692
|
newGroupDelay: 500
|
|
7688
7693
|
};
|
|
@@ -7701,8 +7706,9 @@ const History = Extension.create({
|
|
|
7701
7706
|
/**
|
|
7702
7707
|
* Undo the last action
|
|
7703
7708
|
* @category Command
|
|
7709
|
+
* @returns {Function} Command function
|
|
7704
7710
|
* @example
|
|
7705
|
-
*
|
|
7711
|
+
* undo()
|
|
7706
7712
|
* @note Groups changes within the newGroupDelay window
|
|
7707
7713
|
*/
|
|
7708
7714
|
undo: () => ({ state, dispatch, tr }) => {
|
|
@@ -7716,8 +7722,9 @@ const History = Extension.create({
|
|
|
7716
7722
|
/**
|
|
7717
7723
|
* Redo the last undone action
|
|
7718
7724
|
* @category Command
|
|
7725
|
+
* @returns {Function} Command function
|
|
7719
7726
|
* @example
|
|
7720
|
-
*
|
|
7727
|
+
* redo()
|
|
7721
7728
|
* @note Only available after an undo action
|
|
7722
7729
|
*/
|
|
7723
7730
|
redo: () => ({ state, dispatch, tr }) => {
|
|
@@ -7915,21 +7922,21 @@ class Attribute {
|
|
|
7915
7922
|
let attrs = {};
|
|
7916
7923
|
for (const item of items) {
|
|
7917
7924
|
const mergedAttributes = { ...attrs };
|
|
7918
|
-
for (const [
|
|
7919
|
-
const exists = mergedAttributes[
|
|
7925
|
+
for (const [key, value] of Object.entries(item)) {
|
|
7926
|
+
const exists = mergedAttributes[key];
|
|
7920
7927
|
if (!exists) {
|
|
7921
|
-
mergedAttributes[
|
|
7928
|
+
mergedAttributes[key] = value;
|
|
7922
7929
|
continue;
|
|
7923
7930
|
}
|
|
7924
|
-
if (
|
|
7931
|
+
if (key === "class") {
|
|
7925
7932
|
const valueClasses = value ? value.split(" ") : [];
|
|
7926
|
-
const existingClasses = mergedAttributes[
|
|
7933
|
+
const existingClasses = mergedAttributes[key] ? mergedAttributes[key].split(" ") : [];
|
|
7927
7934
|
const insertClasses = valueClasses.filter((value2) => !existingClasses.includes(value2));
|
|
7928
|
-
mergedAttributes[
|
|
7929
|
-
} else if (
|
|
7930
|
-
mergedAttributes[
|
|
7935
|
+
mergedAttributes[key] = [...existingClasses, ...insertClasses].join(" ");
|
|
7936
|
+
} else if (key === "style") {
|
|
7937
|
+
mergedAttributes[key] = [mergedAttributes[key], value].join("; ");
|
|
7931
7938
|
} else {
|
|
7932
|
-
mergedAttributes[
|
|
7939
|
+
mergedAttributes[key] = value;
|
|
7933
7940
|
}
|
|
7934
7941
|
}
|
|
7935
7942
|
attrs = mergedAttributes;
|
|
@@ -8239,8 +8246,8 @@ const insertTabNode = () => ({ tr, state, dispatch }) => {
|
|
|
8239
8246
|
if (dispatch) dispatch(tr);
|
|
8240
8247
|
return true;
|
|
8241
8248
|
};
|
|
8242
|
-
const setMeta = (
|
|
8243
|
-
tr.setMeta(
|
|
8249
|
+
const setMeta = (key, value) => ({ tr }) => {
|
|
8250
|
+
tr.setMeta(key, value);
|
|
8244
8251
|
return true;
|
|
8245
8252
|
};
|
|
8246
8253
|
const ensureMarks = (state, splittableMarks) => {
|
|
@@ -11368,14 +11375,14 @@ const updateYdocDocxData = async (editor, ydoc) => {
|
|
|
11368
11375
|
const metaMap = ydoc.getMap("meta");
|
|
11369
11376
|
const docx = [...metaMap.get("docx")];
|
|
11370
11377
|
const newXml = await editor.exportDocx({ getUpdatedDocs: true });
|
|
11371
|
-
Object.keys(newXml).forEach((
|
|
11372
|
-
const fileIndex = docx.findIndex((item) => item.name ===
|
|
11378
|
+
Object.keys(newXml).forEach((key) => {
|
|
11379
|
+
const fileIndex = docx.findIndex((item) => item.name === key);
|
|
11373
11380
|
if (fileIndex > -1) {
|
|
11374
11381
|
docx.splice(fileIndex, 1);
|
|
11375
11382
|
}
|
|
11376
11383
|
docx.push({
|
|
11377
|
-
name:
|
|
11378
|
-
content: newXml[
|
|
11384
|
+
name: key,
|
|
11385
|
+
content: newXml[key]
|
|
11379
11386
|
});
|
|
11380
11387
|
});
|
|
11381
11388
|
ydoc.transact(
|
|
@@ -11391,8 +11398,8 @@ const initPaginationData = async (editor) => {
|
|
|
11391
11398
|
const sectionData = { headers: {}, footers: {} };
|
|
11392
11399
|
const headerIds = editor.converter.headerIds.ids;
|
|
11393
11400
|
const footerIds = editor.converter.footerIds.ids;
|
|
11394
|
-
for (let
|
|
11395
|
-
const sectionId = headerIds[
|
|
11401
|
+
for (let key in headerIds) {
|
|
11402
|
+
const sectionId = headerIds[key];
|
|
11396
11403
|
if (!sectionId) continue;
|
|
11397
11404
|
const dataForThisSection = editor.converter.headers[sectionId];
|
|
11398
11405
|
if (!sectionData.headers[sectionId]) sectionData.headers[sectionId] = {};
|
|
@@ -11402,8 +11409,8 @@ const initPaginationData = async (editor) => {
|
|
|
11402
11409
|
sectionData.headers[sectionId].sectionEditor = sectionEditor;
|
|
11403
11410
|
sectionData.headers[sectionId].sectionContainer = sectionContainer;
|
|
11404
11411
|
}
|
|
11405
|
-
for (let
|
|
11406
|
-
const sectionId = footerIds[
|
|
11412
|
+
for (let key in footerIds) {
|
|
11413
|
+
const sectionId = footerIds[key];
|
|
11407
11414
|
if (!sectionId) continue;
|
|
11408
11415
|
const dataForThisSection = editor.converter.footers[sectionId];
|
|
11409
11416
|
if (!sectionData.headers[sectionId]) sectionData.footers[sectionId] = {};
|
|
@@ -12472,16 +12479,16 @@ const generateTableIfNecessary = ({ tableNode, annotationValues, tr, state }) =>
|
|
|
12472
12479
|
if (rowsToGenerate <= 1) return;
|
|
12473
12480
|
const validateAttributes = (attrs) => {
|
|
12474
12481
|
const cleaned = {};
|
|
12475
|
-
for (const [
|
|
12482
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
12476
12483
|
if (value !== void 0 && value !== null) {
|
|
12477
|
-
if (
|
|
12478
|
-
cleaned[
|
|
12479
|
-
} else if (
|
|
12480
|
-
cleaned[
|
|
12484
|
+
if (key === "displayLabel") {
|
|
12485
|
+
cleaned[key] = String(value);
|
|
12486
|
+
} else if (key === "rawHtml" || key === "linkUrl" || key === "imageSrc") {
|
|
12487
|
+
cleaned[key] = String(value);
|
|
12481
12488
|
} else if (typeof value === "string" && value.length > 0) {
|
|
12482
|
-
cleaned[
|
|
12489
|
+
cleaned[key] = value;
|
|
12483
12490
|
} else if (typeof value !== "string") {
|
|
12484
|
-
cleaned[
|
|
12491
|
+
cleaned[key] = value;
|
|
12485
12492
|
}
|
|
12486
12493
|
}
|
|
12487
12494
|
}
|
|
@@ -12759,10 +12766,10 @@ const Collaboration = Extension.create({
|
|
|
12759
12766
|
this.options.fragment = fragment;
|
|
12760
12767
|
const metaMap = this.options.ydoc.getMap("media");
|
|
12761
12768
|
metaMap.observe((event) => {
|
|
12762
|
-
event.changes.keys.forEach((_,
|
|
12763
|
-
if (!(
|
|
12764
|
-
const fileData = metaMap.get(
|
|
12765
|
-
this.editor.storage.image.media[
|
|
12769
|
+
event.changes.keys.forEach((_, key) => {
|
|
12770
|
+
if (!(key in this.editor.storage.image.media)) {
|
|
12771
|
+
const fileData = metaMap.get(key);
|
|
12772
|
+
this.editor.storage.image.media[key] = fileData;
|
|
12766
12773
|
}
|
|
12767
12774
|
});
|
|
12768
12775
|
});
|
|
@@ -12782,8 +12789,8 @@ const initializeMetaMap = (ydoc, editor) => {
|
|
|
12782
12789
|
metaMap.set("docx", editor.options.content);
|
|
12783
12790
|
metaMap.set("fonts", editor.options.fonts);
|
|
12784
12791
|
const mediaMap = ydoc.getMap("media");
|
|
12785
|
-
Object.entries(editor.options.mediaFiles).forEach(([
|
|
12786
|
-
mediaMap.set(
|
|
12792
|
+
Object.entries(editor.options.mediaFiles).forEach(([key, value]) => {
|
|
12793
|
+
mediaMap.set(key, value);
|
|
12787
12794
|
});
|
|
12788
12795
|
};
|
|
12789
12796
|
const checkDocxChanged = (transaction) => {
|
|
@@ -13545,8 +13552,8 @@ function processRelationships(root, convertedXml, results) {
|
|
|
13545
13552
|
};
|
|
13546
13553
|
const seenIds = /* @__PURE__ */ new Set();
|
|
13547
13554
|
const filtered = [];
|
|
13548
|
-
function extractStringAttr(attrs,
|
|
13549
|
-
return typeof attrs[
|
|
13555
|
+
function extractStringAttr(attrs, key) {
|
|
13556
|
+
return typeof attrs[key] === "string" ? attrs[key].trim() : "";
|
|
13550
13557
|
}
|
|
13551
13558
|
for (const rel of root.elements) {
|
|
13552
13559
|
rel.attributes = rel.attributes || {};
|
|
@@ -13768,10 +13775,10 @@ class SuperValidator {
|
|
|
13768
13775
|
this.logger.debug("Document analysis:", documentAnalysis);
|
|
13769
13776
|
let hasModifiedDocument = false;
|
|
13770
13777
|
const validationResults = [];
|
|
13771
|
-
Object.entries(__privateGet(this, _stateValidators)).forEach(([
|
|
13772
|
-
this.logger.debug(`🕵 Validating with ${
|
|
13778
|
+
Object.entries(__privateGet(this, _stateValidators)).forEach(([key, validator]) => {
|
|
13779
|
+
this.logger.debug(`🕵 Validating with ${key}...`);
|
|
13773
13780
|
const { results, modified } = validator(tr, documentAnalysis);
|
|
13774
|
-
validationResults.push({ key
|
|
13781
|
+
validationResults.push({ key, results });
|
|
13775
13782
|
hasModifiedDocument = hasModifiedDocument || modified;
|
|
13776
13783
|
});
|
|
13777
13784
|
if (!this.dryRun) dispatch(tr);
|
|
@@ -13788,10 +13795,10 @@ class SuperValidator {
|
|
|
13788
13795
|
const { dispatch } = __privateGet(this, _editor).view;
|
|
13789
13796
|
let hasModifiedDocument = false;
|
|
13790
13797
|
const validationResults = [];
|
|
13791
|
-
Object.entries(__privateGet(this, _xmlValidators)).forEach(([
|
|
13792
|
-
this.logger.debug(`🕵 Validating export with ${
|
|
13798
|
+
Object.entries(__privateGet(this, _xmlValidators)).forEach(([key, validator]) => {
|
|
13799
|
+
this.logger.debug(`🕵 Validating export with ${key}...`);
|
|
13793
13800
|
const { results, modified } = validator();
|
|
13794
|
-
validationResults.push({ key
|
|
13801
|
+
validationResults.push({ key, results });
|
|
13795
13802
|
hasModifiedDocument = hasModifiedDocument || modified;
|
|
13796
13803
|
});
|
|
13797
13804
|
if (!this.dryRun && hasModifiedDocument) dispatch(tr);
|
|
@@ -13815,11 +13822,11 @@ initializeValidators_fn = function() {
|
|
|
13815
13822
|
const requiredMarks = /* @__PURE__ */ new Set();
|
|
13816
13823
|
const initializeValidatorSet = (validatorFactories) => {
|
|
13817
13824
|
return Object.fromEntries(
|
|
13818
|
-
Object.entries(validatorFactories).map(([
|
|
13819
|
-
const validatorLogger = this.logger.withPrefix(
|
|
13825
|
+
Object.entries(validatorFactories).map(([key, factory]) => {
|
|
13826
|
+
const validatorLogger = this.logger.withPrefix(key);
|
|
13820
13827
|
const validator = factory({ editor: __privateGet(this, _editor), logger: validatorLogger });
|
|
13821
13828
|
__privateMethod(this, _SuperValidator_instances, collectValidatorRequirements_fn).call(this, validator, requiredNodes, requiredMarks);
|
|
13822
|
-
return [
|
|
13829
|
+
return [key, validator];
|
|
13823
13830
|
})
|
|
13824
13831
|
);
|
|
13825
13832
|
};
|
|
@@ -14697,7 +14704,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14697
14704
|
return result;
|
|
14698
14705
|
} catch (error) {
|
|
14699
14706
|
this.emit("exception", { error, editor: this });
|
|
14700
|
-
console.error(error);
|
|
14701
14707
|
}
|
|
14702
14708
|
}
|
|
14703
14709
|
/**
|
|
@@ -14721,7 +14727,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14721
14727
|
this.converter.footerEditors.length = 0;
|
|
14722
14728
|
} catch (error) {
|
|
14723
14729
|
this.emit("exception", { error, editor: this });
|
|
14724
|
-
console.error(error);
|
|
14725
14730
|
}
|
|
14726
14731
|
}
|
|
14727
14732
|
/**
|
|
@@ -14741,7 +14746,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14741
14746
|
* @returns {Object | void} Migration results
|
|
14742
14747
|
*/
|
|
14743
14748
|
processCollaborationMigrations() {
|
|
14744
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.
|
|
14749
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.19.0");
|
|
14745
14750
|
if (!this.options.ydoc) return;
|
|
14746
14751
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
14747
14752
|
let docVersion = metaMap.get("version");
|
|
@@ -14977,9 +14982,7 @@ init_fn = function() {
|
|
|
14977
14982
|
this.initializeCollaborationData();
|
|
14978
14983
|
this.initDefaultStyles();
|
|
14979
14984
|
}
|
|
14980
|
-
if (!this.options.ydoc
|
|
14981
|
-
this.migrateListsToV2();
|
|
14982
|
-
}
|
|
14985
|
+
if (!this.options.ydoc) this.migrateListsToV2();
|
|
14983
14986
|
this.setDocumentMode(this.options.documentMode);
|
|
14984
14987
|
if (!this.options.ydoc) {
|
|
14985
14988
|
if (!this.options.isChildEditor) {
|
|
@@ -15143,8 +15146,8 @@ initMedia_fn = function() {
|
|
|
15143
15146
|
if (!this.options.ydoc) return this.storage.image.media = this.options.mediaFiles;
|
|
15144
15147
|
const mediaMap = this.options.ydoc.getMap("media");
|
|
15145
15148
|
if (this.options.isNewFile) {
|
|
15146
|
-
Object.entries(this.options.mediaFiles).forEach(([
|
|
15147
|
-
mediaMap.set(
|
|
15149
|
+
Object.entries(this.options.mediaFiles).forEach(([key, value]) => {
|
|
15150
|
+
mediaMap.set(key, value);
|
|
15148
15151
|
});
|
|
15149
15152
|
this.storage.image.media = this.options.mediaFiles;
|
|
15150
15153
|
} else {
|
|
@@ -15419,7 +15422,6 @@ endCollaboration_fn = function() {
|
|
|
15419
15422
|
if (this.options.ydoc) this.options.ydoc.destroy();
|
|
15420
15423
|
} catch (error) {
|
|
15421
15424
|
this.emit("exception", { error, editor: this });
|
|
15422
|
-
console.error(error);
|
|
15423
15425
|
}
|
|
15424
15426
|
};
|
|
15425
15427
|
/**
|
|
@@ -15454,6 +15456,11 @@ const Color = Extension.create({
|
|
|
15454
15456
|
name: "color",
|
|
15455
15457
|
addOptions() {
|
|
15456
15458
|
return {
|
|
15459
|
+
/**
|
|
15460
|
+
* @typedef {Object} ColorOptions
|
|
15461
|
+
* @category Options
|
|
15462
|
+
* @property {string[]} [types=['textStyle']] - Mark types to add color support to
|
|
15463
|
+
*/
|
|
15457
15464
|
types: ["textStyle"]
|
|
15458
15465
|
};
|
|
15459
15466
|
},
|
|
@@ -15462,6 +15469,10 @@ const Color = Extension.create({
|
|
|
15462
15469
|
{
|
|
15463
15470
|
types: this.options.types,
|
|
15464
15471
|
attributes: {
|
|
15472
|
+
/**
|
|
15473
|
+
* @category Attribute
|
|
15474
|
+
* @param {ColorValue} [color] - Text color value
|
|
15475
|
+
*/
|
|
15465
15476
|
color: {
|
|
15466
15477
|
default: null,
|
|
15467
15478
|
parseDOM: (el) => el.style.color?.replace(/['"]+/g, ""),
|
|
@@ -15480,17 +15491,16 @@ const Color = Extension.create({
|
|
|
15480
15491
|
* Set text color
|
|
15481
15492
|
* @category Command
|
|
15482
15493
|
* @param {ColorValue} color - Color value to apply
|
|
15494
|
+
* @returns {Function} Command function
|
|
15483
15495
|
* @example
|
|
15484
15496
|
* // Set to red using hex
|
|
15485
|
-
*
|
|
15497
|
+
* setColor('#ff0000')
|
|
15486
15498
|
*
|
|
15487
|
-
* @example
|
|
15488
15499
|
* // Set using rgb
|
|
15489
|
-
*
|
|
15500
|
+
* setColor('rgb(255, 0, 0)')
|
|
15490
15501
|
*
|
|
15491
|
-
* @example
|
|
15492
15502
|
* // Set using named color
|
|
15493
|
-
*
|
|
15503
|
+
* setColor('blue')
|
|
15494
15504
|
* @note Preserves other text styling attributes
|
|
15495
15505
|
*/
|
|
15496
15506
|
setColor: (color) => ({ chain }) => {
|
|
@@ -15499,8 +15509,9 @@ const Color = Extension.create({
|
|
|
15499
15509
|
/**
|
|
15500
15510
|
* Remove text color
|
|
15501
15511
|
* @category Command
|
|
15512
|
+
* @returns {Function} Command function
|
|
15502
15513
|
* @example
|
|
15503
|
-
*
|
|
15514
|
+
* unsetColor()
|
|
15504
15515
|
* @note Removes color while preserving other text styles
|
|
15505
15516
|
*/
|
|
15506
15517
|
unsetColor: () => ({ chain }) => {
|
|
@@ -15513,6 +15524,11 @@ const FontFamily = Extension.create({
|
|
|
15513
15524
|
name: "fontFamily",
|
|
15514
15525
|
addOptions() {
|
|
15515
15526
|
return {
|
|
15527
|
+
/**
|
|
15528
|
+
* @typedef {Object} FontFamilyOptions
|
|
15529
|
+
* @category Options
|
|
15530
|
+
* @property {string[]} [types=['textStyle']] - Mark types to add font family support to
|
|
15531
|
+
*/
|
|
15516
15532
|
types: ["textStyle"]
|
|
15517
15533
|
};
|
|
15518
15534
|
},
|
|
@@ -15521,6 +15537,10 @@ const FontFamily = Extension.create({
|
|
|
15521
15537
|
{
|
|
15522
15538
|
types: this.options.types,
|
|
15523
15539
|
attributes: {
|
|
15540
|
+
/**
|
|
15541
|
+
* @category Attribute
|
|
15542
|
+
* @param {FontFamilyValue} [fontFamily] - Font family for text
|
|
15543
|
+
*/
|
|
15524
15544
|
fontFamily: {
|
|
15525
15545
|
default: null,
|
|
15526
15546
|
parseDOM: (el) => el.style.fontFamily?.replace(/['"]+/g, ""),
|
|
@@ -15539,13 +15559,13 @@ const FontFamily = Extension.create({
|
|
|
15539
15559
|
* Set font family
|
|
15540
15560
|
* @category Command
|
|
15541
15561
|
* @param {FontFamilyValue} fontFamily - Font family to apply
|
|
15562
|
+
* @returns {Function} Command function
|
|
15542
15563
|
* @example
|
|
15543
15564
|
* // Set to Arial
|
|
15544
|
-
*
|
|
15565
|
+
* setFontFamily('Arial')
|
|
15545
15566
|
*
|
|
15546
|
-
* @example
|
|
15547
15567
|
* // Set to serif font
|
|
15548
|
-
*
|
|
15568
|
+
* setFontFamily('Georgia, serif')
|
|
15549
15569
|
* @note Preserves other text styling attributes
|
|
15550
15570
|
*/
|
|
15551
15571
|
setFontFamily: (fontFamily) => ({ chain }) => {
|
|
@@ -15554,8 +15574,9 @@ const FontFamily = Extension.create({
|
|
|
15554
15574
|
/**
|
|
15555
15575
|
* Remove font family
|
|
15556
15576
|
* @category Command
|
|
15577
|
+
* @returns {Function} Command function
|
|
15557
15578
|
* @example
|
|
15558
|
-
*
|
|
15579
|
+
* unsetFontFamily()
|
|
15559
15580
|
* @note Reverts to default document font
|
|
15560
15581
|
*/
|
|
15561
15582
|
unsetFontFamily: () => ({ chain }) => {
|
|
@@ -15568,6 +15589,12 @@ const FontSize = Extension.create({
|
|
|
15568
15589
|
name: "fontSize",
|
|
15569
15590
|
addOptions() {
|
|
15570
15591
|
return {
|
|
15592
|
+
/**
|
|
15593
|
+
* @typedef {Object} FontSizeOptions
|
|
15594
|
+
* @category Options
|
|
15595
|
+
* @property {string[]} [types=['textStyle', 'tableCell']] - Node/mark types to add font size support to
|
|
15596
|
+
* @property {FontSizeDefaults} [defaults] - Default size configuration
|
|
15597
|
+
*/
|
|
15571
15598
|
types: ["textStyle", "tableCell"],
|
|
15572
15599
|
defaults: {
|
|
15573
15600
|
value: 12,
|
|
@@ -15582,6 +15609,10 @@ const FontSize = Extension.create({
|
|
|
15582
15609
|
{
|
|
15583
15610
|
types: this.options.types,
|
|
15584
15611
|
attributes: {
|
|
15612
|
+
/**
|
|
15613
|
+
* @category Attribute
|
|
15614
|
+
* @param {FontSizeValue} [fontSize] - Font size with unit
|
|
15615
|
+
*/
|
|
15585
15616
|
fontSize: {
|
|
15586
15617
|
default: null,
|
|
15587
15618
|
parseDOM: (el) => el.style.fontSize,
|
|
@@ -15603,10 +15634,16 @@ const FontSize = Extension.create({
|
|
|
15603
15634
|
* Set font size
|
|
15604
15635
|
* @category Command
|
|
15605
15636
|
* @param {FontSizeValue} fontSize - Size to apply (with optional unit)
|
|
15637
|
+
* @returns {Function} Command function
|
|
15606
15638
|
* @example
|
|
15607
|
-
*
|
|
15608
|
-
*
|
|
15609
|
-
*
|
|
15639
|
+
* // Set to 14pt
|
|
15640
|
+
* setFontSize('14pt')
|
|
15641
|
+
*
|
|
15642
|
+
* // Set to 18px
|
|
15643
|
+
* setFontSize('18px')
|
|
15644
|
+
*
|
|
15645
|
+
* // Set without unit (uses default)
|
|
15646
|
+
* setFontSize(16)
|
|
15610
15647
|
* @note Automatically clamps to min/max values
|
|
15611
15648
|
*/
|
|
15612
15649
|
setFontSize: (fontSize) => ({ chain }) => {
|
|
@@ -15628,8 +15665,9 @@ const FontSize = Extension.create({
|
|
|
15628
15665
|
/**
|
|
15629
15666
|
* Remove font size
|
|
15630
15667
|
* @category Command
|
|
15668
|
+
* @returns {Function} Command function
|
|
15631
15669
|
* @example
|
|
15632
|
-
*
|
|
15670
|
+
* unsetFontSize()
|
|
15633
15671
|
* @note Reverts to default document size
|
|
15634
15672
|
*/
|
|
15635
15673
|
unsetFontSize: () => ({ chain }) => {
|
|
@@ -15679,9 +15717,13 @@ const TextAlign = Extension.create({
|
|
|
15679
15717
|
* Set text alignment
|
|
15680
15718
|
* @category Command
|
|
15681
15719
|
* @param {string} alignment - Alignment value (left, center, right, justify)
|
|
15720
|
+
* @returns {Function} Command function
|
|
15682
15721
|
* @example
|
|
15683
|
-
*
|
|
15684
|
-
*
|
|
15722
|
+
* // Set to center
|
|
15723
|
+
* setTextAlign('center')
|
|
15724
|
+
*
|
|
15725
|
+
* // Set to justify
|
|
15726
|
+
* setTextAlign('justify')
|
|
15685
15727
|
* @note Applies to all configured node types (heading, paragraph by default)
|
|
15686
15728
|
*/
|
|
15687
15729
|
setTextAlign: (alignment) => ({ commands: commands2 }) => {
|
|
@@ -15692,8 +15734,9 @@ const TextAlign = Extension.create({
|
|
|
15692
15734
|
/**
|
|
15693
15735
|
* Remove text alignment (reset to default)
|
|
15694
15736
|
* @category Command
|
|
15737
|
+
* @returns {Function} Command function
|
|
15695
15738
|
* @example
|
|
15696
|
-
*
|
|
15739
|
+
* unsetTextAlign()
|
|
15697
15740
|
* @note Resets alignment to the default value
|
|
15698
15741
|
*/
|
|
15699
15742
|
unsetTextAlign: () => ({ commands: commands2 }) => {
|
|
@@ -15834,6 +15877,13 @@ const LineHeight = Extension.create({
|
|
|
15834
15877
|
name: "lineHeight",
|
|
15835
15878
|
addOptions() {
|
|
15836
15879
|
return {
|
|
15880
|
+
/**
|
|
15881
|
+
* @typedef {Object} LineHeightOptions
|
|
15882
|
+
* @category Options
|
|
15883
|
+
* @property {string[]} [types=['heading', 'paragraph']] - Block types to add line height support to
|
|
15884
|
+
* @property {Object} [defaults] - Default configuration
|
|
15885
|
+
* @property {string} [defaults.unit=''] - Default unit for line height values
|
|
15886
|
+
*/
|
|
15837
15887
|
types: ["heading", "paragraph"],
|
|
15838
15888
|
defaults: {
|
|
15839
15889
|
unit: ""
|
|
@@ -15845,6 +15895,10 @@ const LineHeight = Extension.create({
|
|
|
15845
15895
|
{
|
|
15846
15896
|
types: this.options.types,
|
|
15847
15897
|
attributes: {
|
|
15898
|
+
/**
|
|
15899
|
+
* @category Attribute
|
|
15900
|
+
* @param {LineHeightValue} [lineHeight] - Line height value
|
|
15901
|
+
*/
|
|
15848
15902
|
lineHeight: {
|
|
15849
15903
|
default: null,
|
|
15850
15904
|
parseDOM: (el) => el.style.lineHeight,
|
|
@@ -15870,10 +15924,16 @@ const LineHeight = Extension.create({
|
|
|
15870
15924
|
* Set line height for blocks
|
|
15871
15925
|
* @category Command
|
|
15872
15926
|
* @param {LineHeightValue} lineHeight - Line height to apply
|
|
15927
|
+
* @returns {Function} Command function
|
|
15873
15928
|
* @example
|
|
15874
|
-
*
|
|
15875
|
-
*
|
|
15876
|
-
*
|
|
15929
|
+
* // Set to 1.5x spacing
|
|
15930
|
+
* setLineHeight(1.5)
|
|
15931
|
+
*
|
|
15932
|
+
* // Set to 24px spacing
|
|
15933
|
+
* setLineHeight('24px')
|
|
15934
|
+
*
|
|
15935
|
+
* // Set to double spacing
|
|
15936
|
+
* setLineHeight(2)
|
|
15877
15937
|
* @note Applies to paragraphs and headings
|
|
15878
15938
|
*/
|
|
15879
15939
|
setLineHeight: (lineHeight) => ({ commands: commands2 }) => {
|
|
@@ -15883,8 +15943,9 @@ const LineHeight = Extension.create({
|
|
|
15883
15943
|
/**
|
|
15884
15944
|
* Remove line height
|
|
15885
15945
|
* @category Command
|
|
15946
|
+
* @returns {Function} Command function
|
|
15886
15947
|
* @example
|
|
15887
|
-
*
|
|
15948
|
+
* unsetLineHeight()
|
|
15888
15949
|
* @note Reverts to default line spacing
|
|
15889
15950
|
*/
|
|
15890
15951
|
unsetLineHeight: () => ({ commands: commands2 }) => {
|
|
@@ -15912,8 +15973,9 @@ const FormatCommands = Extension.create({
|
|
|
15912
15973
|
/**
|
|
15913
15974
|
* Clear all formatting (nodes and marks)
|
|
15914
15975
|
* @category Command
|
|
15976
|
+
* @returns {Function} Command function
|
|
15915
15977
|
* @example
|
|
15916
|
-
*
|
|
15978
|
+
* clearFormat()
|
|
15917
15979
|
* @note Removes all marks and resets nodes to default paragraph
|
|
15918
15980
|
*/
|
|
15919
15981
|
clearFormat: () => ({ chain }) => {
|
|
@@ -15922,8 +15984,9 @@ const FormatCommands = Extension.create({
|
|
|
15922
15984
|
/**
|
|
15923
15985
|
* Clear only mark formatting
|
|
15924
15986
|
* @category Command
|
|
15987
|
+
* @returns {Function} Command function
|
|
15925
15988
|
* @example
|
|
15926
|
-
*
|
|
15989
|
+
* clearMarksFormat()
|
|
15927
15990
|
* @note Removes bold, italic, underline, colors, etc. but preserves block structure
|
|
15928
15991
|
*/
|
|
15929
15992
|
clearMarksFormat: () => ({ chain }) => {
|
|
@@ -15932,8 +15995,9 @@ const FormatCommands = Extension.create({
|
|
|
15932
15995
|
/**
|
|
15933
15996
|
* Clear only node formatting
|
|
15934
15997
|
* @category Command
|
|
15998
|
+
* @returns {Function} Command function
|
|
15935
15999
|
* @example
|
|
15936
|
-
*
|
|
16000
|
+
* clearNodesFormat()
|
|
15937
16001
|
* @note Converts headings, lists, etc. to paragraphs but preserves text marks
|
|
15938
16002
|
*/
|
|
15939
16003
|
clearNodesFormat: () => ({ chain }) => {
|
|
@@ -15942,8 +16006,13 @@ const FormatCommands = Extension.create({
|
|
|
15942
16006
|
/**
|
|
15943
16007
|
* Copy format from selection or apply copied format
|
|
15944
16008
|
* @category Command
|
|
16009
|
+
* @returns {Function} Command function
|
|
15945
16010
|
* @example
|
|
15946
|
-
*
|
|
16011
|
+
* // First call: copy format from selection
|
|
16012
|
+
* copyFormat()
|
|
16013
|
+
*
|
|
16014
|
+
* // Second call: apply copied format to new selection
|
|
16015
|
+
* copyFormat()
|
|
15947
16016
|
* @note Works like format painter - first click copies, second click applies
|
|
15948
16017
|
*/
|
|
15949
16018
|
copyFormat: () => ({ chain }) => {
|
|
@@ -15962,11 +16031,11 @@ const FormatCommands = Extension.create({
|
|
|
15962
16031
|
const { type, attrs } = mark;
|
|
15963
16032
|
const { name } = type;
|
|
15964
16033
|
if (name === "textStyle") {
|
|
15965
|
-
Object.keys(attrs).forEach((
|
|
15966
|
-
if (!attrs[
|
|
16034
|
+
Object.keys(attrs).forEach((key) => {
|
|
16035
|
+
if (!attrs[key]) return;
|
|
15967
16036
|
const attributes = {};
|
|
15968
|
-
attributes[
|
|
15969
|
-
processedMarks.push({ name:
|
|
16037
|
+
attributes[key] = attrs[key];
|
|
16038
|
+
processedMarks.push({ name: key, attrs: attributes });
|
|
15970
16039
|
});
|
|
15971
16040
|
} else {
|
|
15972
16041
|
processedMarks.push({ name, attrs });
|
|
@@ -15981,13 +16050,13 @@ const FormatCommands = Extension.create({
|
|
|
15981
16050
|
fontFamily: ["setFontFamily", "unsetFontFamily"]
|
|
15982
16051
|
};
|
|
15983
16052
|
let result = chain();
|
|
15984
|
-
Object.keys(marksToCommands).forEach((
|
|
15985
|
-
const [setCommand, unsetCommand, defaultParam] = marksToCommands[
|
|
15986
|
-
const markToApply = processedMarks.find((mark) => mark.name ===
|
|
15987
|
-
const hasEmptyAttrs = markToApply?.attrs && markToApply?.attrs[
|
|
16053
|
+
Object.keys(marksToCommands).forEach((key) => {
|
|
16054
|
+
const [setCommand, unsetCommand, defaultParam] = marksToCommands[key];
|
|
16055
|
+
const markToApply = processedMarks.find((mark) => mark.name === key);
|
|
16056
|
+
const hasEmptyAttrs = markToApply?.attrs && markToApply?.attrs[key];
|
|
15988
16057
|
let cmd = {};
|
|
15989
16058
|
if (!markToApply && !hasEmptyAttrs) cmd = { command: unsetCommand, argument: defaultParam };
|
|
15990
|
-
else cmd = { command: setCommand, argument: markToApply.attrs[
|
|
16059
|
+
else cmd = { command: setCommand, argument: markToApply.attrs[key] || defaultParam };
|
|
15991
16060
|
result = result[cmd.command](cmd.argument);
|
|
15992
16061
|
});
|
|
15993
16062
|
this.storage.storedStyle = null;
|
|
@@ -16356,9 +16425,6 @@ function drawGapCursor(state) {
|
|
|
16356
16425
|
}
|
|
16357
16426
|
const Gapcursor = Extension.create({
|
|
16358
16427
|
name: "gapCursor",
|
|
16359
|
-
addOptions() {
|
|
16360
|
-
return {};
|
|
16361
|
-
},
|
|
16362
16428
|
addPmPlugins() {
|
|
16363
16429
|
return [gapCursor()];
|
|
16364
16430
|
},
|
|
@@ -16699,9 +16765,6 @@ function getCursorPositionRelativeToContainer(view, eventLocation) {
|
|
|
16699
16765
|
const SlashMenuPluginKey = new PluginKey("slashMenu");
|
|
16700
16766
|
const SlashMenu = Extension.create({
|
|
16701
16767
|
name: "slashMenu",
|
|
16702
|
-
addOptions() {
|
|
16703
|
-
return {};
|
|
16704
|
-
},
|
|
16705
16768
|
addPmPlugins() {
|
|
16706
16769
|
if (this.editor.options?.disableContextMenu) {
|
|
16707
16770
|
return [];
|
|
@@ -16839,6 +16902,11 @@ const Document = Node$1.create({
|
|
|
16839
16902
|
},
|
|
16840
16903
|
addAttributes() {
|
|
16841
16904
|
return {
|
|
16905
|
+
/**
|
|
16906
|
+
* @private
|
|
16907
|
+
* @category Attribute
|
|
16908
|
+
* @param {Object} [attributes] - Internal document attributes
|
|
16909
|
+
*/
|
|
16842
16910
|
attributes: {
|
|
16843
16911
|
rendered: false,
|
|
16844
16912
|
"aria-label": "Document node"
|
|
@@ -16850,10 +16918,10 @@ const Document = Node$1.create({
|
|
|
16850
16918
|
/**
|
|
16851
16919
|
* Get document statistics
|
|
16852
16920
|
* @category Command
|
|
16921
|
+
* @returns {Function} Command function
|
|
16853
16922
|
* @example
|
|
16854
16923
|
* // Get word and character count
|
|
16855
|
-
*
|
|
16856
|
-
* console.log(`${stats.words} words, ${stats.characters} characters`)
|
|
16924
|
+
* getDocumentStats()
|
|
16857
16925
|
* @note Returns word count, character count, and paragraph count
|
|
16858
16926
|
*/
|
|
16859
16927
|
getDocumentStats: () => ({ editor }) => {
|
|
@@ -16870,8 +16938,9 @@ const Document = Node$1.create({
|
|
|
16870
16938
|
/**
|
|
16871
16939
|
* Clear entire document
|
|
16872
16940
|
* @category Command
|
|
16941
|
+
* @returns {Function} Command function
|
|
16873
16942
|
* @example
|
|
16874
|
-
*
|
|
16943
|
+
* clearDocument()
|
|
16875
16944
|
* @note Replaces all content with an empty paragraph
|
|
16876
16945
|
*/
|
|
16877
16946
|
clearDocument: () => ({ commands: commands2 }) => {
|
|
@@ -16883,19 +16952,13 @@ const Document = Node$1.create({
|
|
|
16883
16952
|
const Text = Node$1.create({
|
|
16884
16953
|
name: "text",
|
|
16885
16954
|
group: "inline",
|
|
16886
|
-
inline: true
|
|
16887
|
-
addOptions() {
|
|
16888
|
-
return {};
|
|
16889
|
-
}
|
|
16955
|
+
inline: true
|
|
16890
16956
|
});
|
|
16891
16957
|
const RunItem = Node$1.create({
|
|
16892
16958
|
name: "run",
|
|
16893
16959
|
group: "inline",
|
|
16894
16960
|
content: "text*",
|
|
16895
16961
|
inline: true,
|
|
16896
|
-
addOptions() {
|
|
16897
|
-
return {};
|
|
16898
|
-
},
|
|
16899
16962
|
parseDOM() {
|
|
16900
16963
|
return [{ tag: "run" }];
|
|
16901
16964
|
},
|
|
@@ -16921,6 +16984,14 @@ const BulletList = Node$1.create({
|
|
|
16921
16984
|
},
|
|
16922
16985
|
addOptions() {
|
|
16923
16986
|
return {
|
|
16987
|
+
/**
|
|
16988
|
+
* @typedef {Object} BulletListOptions
|
|
16989
|
+
* @category Options
|
|
16990
|
+
* @property {string} [itemTypeName='listItem'] - Name of the list item node type
|
|
16991
|
+
* @property {Object} [htmlAttributes] - HTML attributes for the ul element
|
|
16992
|
+
* @property {boolean} [keepMarks=true] - Whether to preserve marks when splitting
|
|
16993
|
+
* @property {boolean} [keepAttributes=false] - Whether to preserve attributes when splitting
|
|
16994
|
+
*/
|
|
16924
16995
|
itemTypeName: "listItem",
|
|
16925
16996
|
htmlAttributes: {
|
|
16926
16997
|
"aria-label": "Bullet list node"
|
|
@@ -16938,13 +17009,27 @@ const BulletList = Node$1.create({
|
|
|
16938
17009
|
},
|
|
16939
17010
|
addAttributes() {
|
|
16940
17011
|
return {
|
|
17012
|
+
/**
|
|
17013
|
+
* @category Attribute
|
|
17014
|
+
* @param {string} [list-style-type='bullet'] - List style type for this list
|
|
17015
|
+
*/
|
|
16941
17016
|
"list-style-type": {
|
|
16942
17017
|
default: "bullet",
|
|
16943
17018
|
rendered: false
|
|
16944
17019
|
},
|
|
17020
|
+
/**
|
|
17021
|
+
* @private
|
|
17022
|
+
* @category Attribute
|
|
17023
|
+
* @param {string} [listId] - Internal list identifier for numbering
|
|
17024
|
+
*/
|
|
16945
17025
|
listId: {
|
|
16946
17026
|
rendered: false
|
|
16947
17027
|
},
|
|
17028
|
+
/**
|
|
17029
|
+
* @private
|
|
17030
|
+
* @category Attribute
|
|
17031
|
+
* @param {string} [sdBlockId] - Internal block tracking ID
|
|
17032
|
+
*/
|
|
16948
17033
|
sdBlockId: {
|
|
16949
17034
|
default: null,
|
|
16950
17035
|
keepOnSplit: false,
|
|
@@ -16953,6 +17038,11 @@ const BulletList = Node$1.create({
|
|
|
16953
17038
|
return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
|
|
16954
17039
|
}
|
|
16955
17040
|
},
|
|
17041
|
+
/**
|
|
17042
|
+
* @private
|
|
17043
|
+
* @category Attribute
|
|
17044
|
+
* @param {Object} [attributes] - Additional attributes for the list
|
|
17045
|
+
*/
|
|
16956
17046
|
attributes: {
|
|
16957
17047
|
rendered: false,
|
|
16958
17048
|
keepOnSplit: true
|
|
@@ -16964,9 +17054,10 @@ const BulletList = Node$1.create({
|
|
|
16964
17054
|
/**
|
|
16965
17055
|
* Toggle a bullet list at the current selection
|
|
16966
17056
|
* @category Command
|
|
17057
|
+
* @returns {Function} Command function
|
|
16967
17058
|
* @example
|
|
16968
17059
|
* // Toggle bullet list on selected text
|
|
16969
|
-
*
|
|
17060
|
+
* toggleBulletList()
|
|
16970
17061
|
* @note Converts selected paragraphs to list items or removes list formatting
|
|
16971
17062
|
*/
|
|
16972
17063
|
toggleBulletList: () => (params2) => {
|
|
@@ -17085,25 +17176,9 @@ const OrderedList = Node$1.create({
|
|
|
17085
17176
|
},
|
|
17086
17177
|
addCommands() {
|
|
17087
17178
|
return {
|
|
17088
|
-
/**
|
|
17089
|
-
* Toggle ordered list formatting
|
|
17090
|
-
* @category Command
|
|
17091
|
-
* @example
|
|
17092
|
-
* editor.commands.toggleOrderedList()
|
|
17093
|
-
* @note Converts selection to ordered list or back to paragraphs
|
|
17094
|
-
*/
|
|
17095
17179
|
toggleOrderedList: () => (params2) => {
|
|
17096
17180
|
return toggleList(this.type)(params2);
|
|
17097
17181
|
},
|
|
17098
|
-
/**
|
|
17099
|
-
* Restart list node numbering
|
|
17100
|
-
* @category Command
|
|
17101
|
-
* @param {Array} followingNodes - Nodes to restart
|
|
17102
|
-
* @param {number} pos - Starting position
|
|
17103
|
-
* @example
|
|
17104
|
-
* editor.commands.restartListNodes(nodes, position)
|
|
17105
|
-
* @note Resets list numbering for specified nodes
|
|
17106
|
-
*/
|
|
17107
17182
|
restartListNodes: (followingNodes, pos) => ({ tr }) => {
|
|
17108
17183
|
let currentNodePos = pos;
|
|
17109
17184
|
const nodes = followingNodes.map((node) => {
|
|
@@ -17122,11 +17197,8 @@ const OrderedList = Node$1.create({
|
|
|
17122
17197
|
return true;
|
|
17123
17198
|
},
|
|
17124
17199
|
/**
|
|
17125
|
-
*
|
|
17126
|
-
* @
|
|
17127
|
-
* @example
|
|
17128
|
-
* editor.commands.updateOrderedListStyleType()
|
|
17129
|
-
* @note Cycles through decimal -> lowerAlpha -> lowerRoman based on depth
|
|
17200
|
+
* Updates ordered list style type when sink or lift `listItem`.
|
|
17201
|
+
* @example 1,2,3 -> a,b,c -> i,ii,iii -> 1,2,3 -> etc
|
|
17130
17202
|
*/
|
|
17131
17203
|
updateOrderedListStyleType: () => ({ dispatch, tr }) => {
|
|
17132
17204
|
let list = findParentNode((node) => node.type.name === this.name)(tr.selection);
|
|
@@ -17403,7 +17475,7 @@ const CustomSelection = Extension.create({
|
|
|
17403
17475
|
* @returns {Function} Command function
|
|
17404
17476
|
* @example
|
|
17405
17477
|
* // Restore selection after toolbar interaction
|
|
17406
|
-
*
|
|
17478
|
+
* restorePreservedSelection()
|
|
17407
17479
|
* @note Used internally to maintain selection when interacting with toolbar
|
|
17408
17480
|
*/
|
|
17409
17481
|
restorePreservedSelection: () => ({ tr, state }) => {
|
|
@@ -17488,7 +17560,7 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
|
|
|
17488
17560
|
resultStyles["text-transform"] = basedOnDefinitionStyles["text-transform"];
|
|
17489
17561
|
}
|
|
17490
17562
|
Object.entries(resultStyles).forEach(([k, value]) => {
|
|
17491
|
-
const
|
|
17563
|
+
const key = kebabCase(k);
|
|
17492
17564
|
const flattenedMarks = [];
|
|
17493
17565
|
node?.marks?.forEach((n) => {
|
|
17494
17566
|
if (n.type.name === "textStyle") {
|
|
@@ -17499,46 +17571,46 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
|
|
|
17499
17571
|
});
|
|
17500
17572
|
return;
|
|
17501
17573
|
}
|
|
17502
|
-
flattenedMarks.push({ key: n.type.name, value: n.attrs[
|
|
17574
|
+
flattenedMarks.push({ key: n.type.name, value: n.attrs[key] });
|
|
17503
17575
|
});
|
|
17504
|
-
const mark = flattenedMarks.find((n) => n.key ===
|
|
17576
|
+
const mark = flattenedMarks.find((n) => n.key === key);
|
|
17505
17577
|
const hasParentIndent = Object.keys(parent?.attrs?.indent || {});
|
|
17506
17578
|
const hasParentSpacing = Object.keys(parent?.attrs?.spacing || {});
|
|
17507
17579
|
const listTypes = ["orderedList", "listItem"];
|
|
17508
17580
|
if (!mark) {
|
|
17509
|
-
if (
|
|
17581
|
+
if (key === "spacing" && includeSpacing && !hasParentSpacing) {
|
|
17510
17582
|
const space = getSpacingStyle(value);
|
|
17511
17583
|
Object.entries(space).forEach(([k2, v]) => {
|
|
17512
17584
|
markValue[k2] = v;
|
|
17513
17585
|
});
|
|
17514
|
-
} else if (
|
|
17586
|
+
} else if (key === "indent" && includeSpacing && !hasParentIndent) {
|
|
17515
17587
|
const { leftIndent, rightIndent, firstLine } = value;
|
|
17516
17588
|
if (leftIndent) markValue["margin-left"] = leftIndent + "px";
|
|
17517
17589
|
if (rightIndent) markValue["margin-right"] = rightIndent + "px";
|
|
17518
17590
|
if (firstLine) markValue["text-indent"] = firstLine + "px";
|
|
17519
|
-
} else if (
|
|
17591
|
+
} else if (key === "bold" && node) {
|
|
17520
17592
|
const val = value?.value;
|
|
17521
17593
|
if (!listTypes.includes(node.type.name) && val !== "0") {
|
|
17522
17594
|
markValue["font-weight"] = "bold";
|
|
17523
17595
|
}
|
|
17524
|
-
} else if (
|
|
17596
|
+
} else if (key === "text-transform" && node) {
|
|
17525
17597
|
if (!listTypes.includes(node.type.name)) {
|
|
17526
|
-
markValue[
|
|
17598
|
+
markValue[key] = value;
|
|
17527
17599
|
}
|
|
17528
|
-
} else if (
|
|
17600
|
+
} else if (key === "font-size" && node) {
|
|
17529
17601
|
if (!listTypes.includes(node.type.name)) {
|
|
17530
|
-
markValue[
|
|
17602
|
+
markValue[key] = value;
|
|
17531
17603
|
}
|
|
17532
|
-
} else if (
|
|
17604
|
+
} else if (key === "color" && node) {
|
|
17533
17605
|
if (!listTypes.includes(node.type.name)) {
|
|
17534
|
-
markValue[
|
|
17606
|
+
markValue[key] = value;
|
|
17535
17607
|
}
|
|
17536
17608
|
} else if (typeof value === "string") {
|
|
17537
|
-
markValue[
|
|
17609
|
+
markValue[key] = value;
|
|
17538
17610
|
}
|
|
17539
17611
|
}
|
|
17540
17612
|
});
|
|
17541
|
-
const final = Object.entries(markValue).map(([
|
|
17613
|
+
const final = Object.entries(markValue).map(([key, value]) => `${key}: ${value}`).join(";");
|
|
17542
17614
|
return final;
|
|
17543
17615
|
};
|
|
17544
17616
|
const applyLinkedStyleToTransaction = (tr, editor, style) => {
|
|
@@ -17692,9 +17764,6 @@ const LinkedStyles = Extension.create({
|
|
|
17692
17764
|
name: "linkedStyles",
|
|
17693
17765
|
priority: 1,
|
|
17694
17766
|
// We need this plugin to run before the list plugins
|
|
17695
|
-
addOptions() {
|
|
17696
|
-
return {};
|
|
17697
|
-
},
|
|
17698
17767
|
addPmPlugins() {
|
|
17699
17768
|
return [createLinkedStylesPlugin(this.editor)];
|
|
17700
17769
|
},
|
|
@@ -17703,10 +17772,11 @@ const LinkedStyles = Extension.create({
|
|
|
17703
17772
|
/**
|
|
17704
17773
|
* Apply a linked style to the selected paragraphs
|
|
17705
17774
|
* @category Command
|
|
17706
|
-
* @param {
|
|
17775
|
+
* @param {Object} style - The style object to apply
|
|
17776
|
+
* @returns {Function} Command function
|
|
17707
17777
|
* @example
|
|
17708
17778
|
* const style = editor.helpers.linkedStyles.getStyleById('Heading1');
|
|
17709
|
-
*
|
|
17779
|
+
* setLinkedStyle(style);
|
|
17710
17780
|
* @note Clears existing formatting when applying a style
|
|
17711
17781
|
* @note Works with custom selection preservation
|
|
17712
17782
|
*/
|
|
@@ -17717,12 +17787,16 @@ const LinkedStyles = Extension.create({
|
|
|
17717
17787
|
/**
|
|
17718
17788
|
* Toggle a linked style on the current selection
|
|
17719
17789
|
* @category Command
|
|
17720
|
-
* @param {
|
|
17790
|
+
* @param {Object} style - The linked style to apply (with id property)
|
|
17721
17791
|
* @param {string|null} [nodeType=null] - Node type to restrict toggle to (e.g., 'paragraph')
|
|
17792
|
+
* @returns {Function} Command function
|
|
17722
17793
|
* @example
|
|
17794
|
+
* // Toggle a heading style
|
|
17723
17795
|
* const style = editor.helpers.linkedStyles.getStyleById('Heading1');
|
|
17724
|
-
*
|
|
17725
|
-
*
|
|
17796
|
+
* toggleLinkedStyle(style)
|
|
17797
|
+
*
|
|
17798
|
+
* // Toggle only on paragraph nodes
|
|
17799
|
+
* toggleLinkedStyle(style, 'paragraph')
|
|
17726
17800
|
* @note If selection is empty, returns false
|
|
17727
17801
|
* @note Removes style if already applied, applies it if not
|
|
17728
17802
|
*/
|
|
@@ -17750,9 +17824,13 @@ const LinkedStyles = Extension.create({
|
|
|
17750
17824
|
* Apply a linked style by its ID
|
|
17751
17825
|
* @category Command
|
|
17752
17826
|
* @param {string} styleId - The style ID to apply (e.g., 'Heading1')
|
|
17827
|
+
* @returns {Function} Command function
|
|
17753
17828
|
* @example
|
|
17754
|
-
*
|
|
17755
|
-
*
|
|
17829
|
+
* // Apply a heading style
|
|
17830
|
+
* setStyleById('Heading1')
|
|
17831
|
+
*
|
|
17832
|
+
* // Apply a normal style
|
|
17833
|
+
* setStyleById('Normal')
|
|
17756
17834
|
* @note Looks up the style from loaded Word styles
|
|
17757
17835
|
*/
|
|
17758
17836
|
setStyleById: (styleId) => (params2) => {
|
|
@@ -18227,7 +18305,7 @@ function orderedListSync(editor) {
|
|
|
18227
18305
|
listNumberingType,
|
|
18228
18306
|
customFormat
|
|
18229
18307
|
};
|
|
18230
|
-
const keysChanged = Object.keys(updatedAttrs).some((
|
|
18308
|
+
const keysChanged = Object.keys(updatedAttrs).some((key) => node.attrs[key] !== updatedAttrs[key]);
|
|
18231
18309
|
if (keysChanged) {
|
|
18232
18310
|
tr.setNodeMarkup(pos, void 0, updatedAttrs);
|
|
18233
18311
|
}
|
|
@@ -18460,6 +18538,12 @@ const Paragraph = OxmlNode.create({
|
|
|
18460
18538
|
inline: false,
|
|
18461
18539
|
addOptions() {
|
|
18462
18540
|
return {
|
|
18541
|
+
/**
|
|
18542
|
+
* @typedef {Object} HeadingOptions
|
|
18543
|
+
* @category Options
|
|
18544
|
+
* @property {number[]} [headingLevels=[1,2,3,4,5,6]] - Supported heading levels
|
|
18545
|
+
* @property {Object} [htmlAttributes] - HTML attributes for paragraph elements
|
|
18546
|
+
*/
|
|
18463
18547
|
headingLevels: [1, 2, 3, 4, 5, 6],
|
|
18464
18548
|
htmlAttributes: {}
|
|
18465
18549
|
};
|
|
@@ -18691,6 +18775,11 @@ const Heading = Extension.create({
|
|
|
18691
18775
|
name: "heading",
|
|
18692
18776
|
addOptions() {
|
|
18693
18777
|
return {
|
|
18778
|
+
/**
|
|
18779
|
+
* @typedef {Object} HeadingOptions
|
|
18780
|
+
* @category Options
|
|
18781
|
+
* @property {number[]} [levels=[1,2,3,4,5,6]] - Supported heading levels
|
|
18782
|
+
*/
|
|
18694
18783
|
levels: [1, 2, 3, 4, 5, 6]
|
|
18695
18784
|
};
|
|
18696
18785
|
},
|
|
@@ -18700,8 +18789,10 @@ const Heading = Extension.create({
|
|
|
18700
18789
|
* Set a heading with specified level
|
|
18701
18790
|
* @category Command
|
|
18702
18791
|
* @param {HeadingAttributes} attributes - Heading attributes including level
|
|
18792
|
+
* @returns {Function} Command function
|
|
18703
18793
|
* @example
|
|
18704
|
-
*
|
|
18794
|
+
* // Set heading level 2
|
|
18795
|
+
* setHeading({ level: 2 })
|
|
18705
18796
|
* @note Converts current block to heading
|
|
18706
18797
|
*/
|
|
18707
18798
|
setHeading: (attributes) => ({ commands: commands2 }) => {
|
|
@@ -18713,9 +18804,13 @@ const Heading = Extension.create({
|
|
|
18713
18804
|
* Toggle between heading and paragraph
|
|
18714
18805
|
* @category Command
|
|
18715
18806
|
* @param {HeadingAttributes} attributes - Heading attributes including level
|
|
18807
|
+
* @returns {Function} Command function
|
|
18716
18808
|
* @example
|
|
18717
|
-
*
|
|
18718
|
-
*
|
|
18809
|
+
* // Toggle heading level 1
|
|
18810
|
+
* toggleHeading({ level: 1 })
|
|
18811
|
+
*
|
|
18812
|
+
* // Toggle heading level 3
|
|
18813
|
+
* toggleHeading({ level: 3 })
|
|
18719
18814
|
* @note Switches between heading and paragraph for the same level
|
|
18720
18815
|
*/
|
|
18721
18816
|
toggleHeading: (attributes) => ({ commands: commands2 }) => {
|
|
@@ -19120,9 +19215,6 @@ const LineBreak = Node$1.create({
|
|
|
19120
19215
|
selectable: false,
|
|
19121
19216
|
content: "",
|
|
19122
19217
|
atom: true,
|
|
19123
|
-
addOptions() {
|
|
19124
|
-
return {};
|
|
19125
|
-
},
|
|
19126
19218
|
parseDOM() {
|
|
19127
19219
|
return [{ tag: "br" }];
|
|
19128
19220
|
},
|
|
@@ -19131,7 +19223,17 @@ const LineBreak = Node$1.create({
|
|
|
19131
19223
|
},
|
|
19132
19224
|
addAttributes() {
|
|
19133
19225
|
return {
|
|
19226
|
+
/**
|
|
19227
|
+
* @private
|
|
19228
|
+
* @category Attribute
|
|
19229
|
+
* @param {string} [lineBreakType] - Type of line break - passthrough in this node
|
|
19230
|
+
*/
|
|
19134
19231
|
lineBreakType: { rendered: false },
|
|
19232
|
+
/**
|
|
19233
|
+
* @private
|
|
19234
|
+
* @category Attribute
|
|
19235
|
+
* @param {string} [clear] - Clear attribute - passthrough in this node
|
|
19236
|
+
*/
|
|
19135
19237
|
clear: { rendered: false }
|
|
19136
19238
|
};
|
|
19137
19239
|
},
|
|
@@ -19140,8 +19242,9 @@ const LineBreak = Node$1.create({
|
|
|
19140
19242
|
/**
|
|
19141
19243
|
* Insert a line break
|
|
19142
19244
|
* @category Command
|
|
19245
|
+
* @returns {Function} Command function
|
|
19143
19246
|
* @example
|
|
19144
|
-
*
|
|
19247
|
+
* insertLineBreak()
|
|
19145
19248
|
* @note Creates a soft break within the same paragraph
|
|
19146
19249
|
*/
|
|
19147
19250
|
insertLineBreak: () => ({ commands: commands2 }) => {
|
|
@@ -19158,6 +19261,11 @@ const HardBreak = Node$1.create({
|
|
|
19158
19261
|
atom: true,
|
|
19159
19262
|
addOptions() {
|
|
19160
19263
|
return {
|
|
19264
|
+
/**
|
|
19265
|
+
* @typedef {Object} HardBreakOptions
|
|
19266
|
+
* @category Options
|
|
19267
|
+
* @property {Object} [htmlAttributes] - HTML attributes for the break element
|
|
19268
|
+
*/
|
|
19161
19269
|
htmlAttributes: {
|
|
19162
19270
|
contentEditable: "false",
|
|
19163
19271
|
lineBreakType: "page",
|
|
@@ -19168,15 +19276,35 @@ const HardBreak = Node$1.create({
|
|
|
19168
19276
|
},
|
|
19169
19277
|
addAttributes() {
|
|
19170
19278
|
return {
|
|
19279
|
+
/**
|
|
19280
|
+
* @private
|
|
19281
|
+
* @category Attribute
|
|
19282
|
+
* @param {string} [pageBreakSource] - Source of the page break
|
|
19283
|
+
*/
|
|
19171
19284
|
pageBreakSource: {
|
|
19172
19285
|
rendered: false,
|
|
19173
19286
|
default: null
|
|
19174
19287
|
},
|
|
19288
|
+
/**
|
|
19289
|
+
* @private
|
|
19290
|
+
* @category Attribute
|
|
19291
|
+
* @param {string} [pageBreakType] - Type of page break
|
|
19292
|
+
*/
|
|
19175
19293
|
pageBreakType: {
|
|
19176
19294
|
default: null,
|
|
19177
19295
|
rendered: false
|
|
19178
19296
|
},
|
|
19297
|
+
/**
|
|
19298
|
+
* @private
|
|
19299
|
+
* @category Attribute
|
|
19300
|
+
* @param {string} [lineBreakType] - Type of line break - passthrough in this node
|
|
19301
|
+
*/
|
|
19179
19302
|
lineBreakType: { rendered: false },
|
|
19303
|
+
/**
|
|
19304
|
+
* @private
|
|
19305
|
+
* @category Attribute
|
|
19306
|
+
* @param {string} [clear] - Clear attribute - passthrough in this node
|
|
19307
|
+
*/
|
|
19180
19308
|
clear: { rendered: false }
|
|
19181
19309
|
};
|
|
19182
19310
|
},
|
|
@@ -19202,8 +19330,9 @@ const HardBreak = Node$1.create({
|
|
|
19202
19330
|
/**
|
|
19203
19331
|
* Insert a page break
|
|
19204
19332
|
* @category Command
|
|
19333
|
+
* @returns {Function} Command function
|
|
19205
19334
|
* @example
|
|
19206
|
-
*
|
|
19335
|
+
* insertPageBreak()
|
|
19207
19336
|
* @note Forces content to start on a new page when printed
|
|
19208
19337
|
*/
|
|
19209
19338
|
insertPageBreak: () => ({ commands: commands2 }) => {
|
|
@@ -19215,12 +19344,6 @@ const HardBreak = Node$1.create({
|
|
|
19215
19344
|
};
|
|
19216
19345
|
}
|
|
19217
19346
|
});
|
|
19218
|
-
const getColStyleDeclaration = (minWidth, width) => {
|
|
19219
|
-
if (width) {
|
|
19220
|
-
return ["width", `${Math.max(width, minWidth)}px`];
|
|
19221
|
-
}
|
|
19222
|
-
return ["min-width", `${minWidth}px`];
|
|
19223
|
-
};
|
|
19224
19347
|
const createTableView = ({ editor }) => {
|
|
19225
19348
|
return class TableView {
|
|
19226
19349
|
constructor(node, cellMinWidth) {
|
|
@@ -19309,11 +19432,11 @@ function updateTable(editor, node, table) {
|
|
|
19309
19432
|
const allExtensionsAttrs = editor.extensionService.attributes;
|
|
19310
19433
|
const tableExtensionAttrs = allExtensionsAttrs.filter((e) => e.type === "table");
|
|
19311
19434
|
const htmlAttributes = Attribute.getAttributesToRender(node, tableExtensionAttrs);
|
|
19312
|
-
Object.entries(htmlAttributes).forEach(([
|
|
19313
|
-
if (
|
|
19435
|
+
Object.entries(htmlAttributes).forEach(([key, value]) => {
|
|
19436
|
+
if (key === "style") {
|
|
19314
19437
|
table.style.cssText = value;
|
|
19315
19438
|
} else {
|
|
19316
|
-
table.setAttribute(
|
|
19439
|
+
table.setAttribute(key, value);
|
|
19317
19440
|
}
|
|
19318
19441
|
});
|
|
19319
19442
|
}
|
|
@@ -19381,55 +19504,26 @@ const createTable = (schema, rowsCount, colsCount, withHeaderRow, cellContent =
|
|
|
19381
19504
|
const tableBorders = createTableBorders();
|
|
19382
19505
|
return types.table.createChecked({ borders: tableBorders }, rows);
|
|
19383
19506
|
};
|
|
19384
|
-
const createColGroup = (node, cellMinWidth, overrideCol, overrideValue) => {
|
|
19385
|
-
let totalWidth = 0;
|
|
19386
|
-
let fixedWidth = true;
|
|
19387
|
-
const cols = [];
|
|
19388
|
-
const colsValues = [];
|
|
19389
|
-
const row = node.firstChild;
|
|
19390
|
-
if (!row) return {};
|
|
19391
|
-
for (let i = 0, col = 0; i < row.childCount; i++) {
|
|
19392
|
-
const { colspan, colwidth } = row.child(i).attrs;
|
|
19393
|
-
for (let j = 0; j < colspan; j++, col++) {
|
|
19394
|
-
const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j];
|
|
19395
|
-
totalWidth += hasWidth || cellMinWidth;
|
|
19396
|
-
if (!hasWidth) fixedWidth = false;
|
|
19397
|
-
const [prop, value] = getColStyleDeclaration(cellMinWidth, hasWidth);
|
|
19398
|
-
cols.push(["col", { style: `${prop}: ${value}` }]);
|
|
19399
|
-
colsValues.push(parseInt(value, 10));
|
|
19400
|
-
}
|
|
19401
|
-
}
|
|
19402
|
-
const tableWidth = fixedWidth ? `${totalWidth}px` : "";
|
|
19403
|
-
const tableMinWidth = fixedWidth ? "" : `${totalWidth}px`;
|
|
19404
|
-
const colgroup = ["colgroup", {}, ...cols];
|
|
19405
|
-
const colgroupValues = [...colsValues];
|
|
19406
|
-
return {
|
|
19407
|
-
colgroup,
|
|
19408
|
-
tableWidth,
|
|
19409
|
-
tableMinWidth,
|
|
19410
|
-
colgroupValues
|
|
19411
|
-
};
|
|
19412
|
-
};
|
|
19413
19507
|
var readFromCache;
|
|
19414
19508
|
var addToCache;
|
|
19415
19509
|
if (typeof WeakMap != "undefined") {
|
|
19416
19510
|
let cache = /* @__PURE__ */ new WeakMap();
|
|
19417
|
-
readFromCache = (
|
|
19418
|
-
addToCache = (
|
|
19419
|
-
cache.set(
|
|
19511
|
+
readFromCache = (key) => cache.get(key);
|
|
19512
|
+
addToCache = (key, value) => {
|
|
19513
|
+
cache.set(key, value);
|
|
19420
19514
|
return value;
|
|
19421
19515
|
};
|
|
19422
19516
|
} else {
|
|
19423
19517
|
const cache = [];
|
|
19424
19518
|
const cacheSize = 10;
|
|
19425
19519
|
let cachePos = 0;
|
|
19426
|
-
readFromCache = (
|
|
19520
|
+
readFromCache = (key) => {
|
|
19427
19521
|
for (let i = 0; i < cache.length; i += 2)
|
|
19428
|
-
if (cache[i] ==
|
|
19522
|
+
if (cache[i] == key) return cache[i + 1];
|
|
19429
19523
|
};
|
|
19430
|
-
addToCache = (
|
|
19524
|
+
addToCache = (key, value) => {
|
|
19431
19525
|
if (cachePos == cacheSize) cachePos = 0;
|
|
19432
|
-
cache[cachePos++] =
|
|
19526
|
+
cache[cachePos++] = key;
|
|
19433
19527
|
return cache[cachePos++] = value;
|
|
19434
19528
|
};
|
|
19435
19529
|
}
|
|
@@ -21593,6 +21687,17 @@ const Table = Node$1.create({
|
|
|
21593
21687
|
group: "block",
|
|
21594
21688
|
isolating: true,
|
|
21595
21689
|
tableRole: "table",
|
|
21690
|
+
/**
|
|
21691
|
+
* Table extension options
|
|
21692
|
+
* @category Options
|
|
21693
|
+
* @typedef {Object} TableOptions
|
|
21694
|
+
* @property {Object} [htmlAttributes={'aria-label': 'Table node'}] - Default HTML attributes for all tables
|
|
21695
|
+
* @property {boolean} [resizable=true] - Enable column resizing functionality
|
|
21696
|
+
* @property {number} [handleWidth=5] - Width of resize handles in pixels
|
|
21697
|
+
* @property {number} [cellMinWidth=10] - Minimum cell width constraint in pixels
|
|
21698
|
+
* @property {boolean} [lastColumnResizable=true] - Allow resizing of the last column
|
|
21699
|
+
* @property {boolean} [allowTableNodeSelection=false] - Enable selecting the entire table node
|
|
21700
|
+
*/
|
|
21596
21701
|
addOptions() {
|
|
21597
21702
|
return {
|
|
21598
21703
|
htmlAttributes: {
|
|
@@ -21652,8 +21757,8 @@ const Table = Node$1.create({
|
|
|
21652
21757
|
default: {},
|
|
21653
21758
|
renderDOM({ borders }) {
|
|
21654
21759
|
if (!borders) return {};
|
|
21655
|
-
const style = Object.entries(borders).reduce((acc, [
|
|
21656
|
-
return `${acc}border-${
|
|
21760
|
+
const style = Object.entries(borders).reduce((acc, [key, { size, color }]) => {
|
|
21761
|
+
return `${acc}border-${key}: ${Math.ceil(size)}px solid ${color || "black"};`;
|
|
21657
21762
|
}, "");
|
|
21658
21763
|
return {
|
|
21659
21764
|
style
|
|
@@ -21712,24 +21817,6 @@ const Table = Node$1.create({
|
|
|
21712
21817
|
tableCellSpacing: {
|
|
21713
21818
|
default: null,
|
|
21714
21819
|
rendered: false
|
|
21715
|
-
},
|
|
21716
|
-
/**
|
|
21717
|
-
* @category Attribute
|
|
21718
|
-
* @param {TableProperties} [tableProperties] - Properties for the table.
|
|
21719
|
-
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 371-483
|
|
21720
|
-
*/
|
|
21721
|
-
tableProperties: {
|
|
21722
|
-
default: null,
|
|
21723
|
-
rendered: false
|
|
21724
|
-
},
|
|
21725
|
-
/**
|
|
21726
|
-
* @category Attribute
|
|
21727
|
-
* @param {TableGrid} [grid] - Grid definition for the table
|
|
21728
|
-
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 432
|
|
21729
|
-
*/
|
|
21730
|
-
grid: {
|
|
21731
|
-
default: null,
|
|
21732
|
-
rendered: false
|
|
21733
21820
|
}
|
|
21734
21821
|
};
|
|
21735
21822
|
},
|
|
@@ -21750,9 +21837,14 @@ const Table = Node$1.create({
|
|
|
21750
21837
|
* Insert a new table into the document
|
|
21751
21838
|
* @category Command
|
|
21752
21839
|
* @param {TableConfig} [config] - Table configuration options
|
|
21840
|
+
* @returns {Function} Command
|
|
21753
21841
|
* @example
|
|
21754
|
-
*
|
|
21755
|
-
*
|
|
21842
|
+
* // Using default values
|
|
21843
|
+
* insertTable() // Creates 3x3 table without header
|
|
21844
|
+
*
|
|
21845
|
+
* // Using custom values
|
|
21846
|
+
* insertTable({ rows: 3, cols: 3, withHeaderRow: true })
|
|
21847
|
+
*
|
|
21756
21848
|
*/
|
|
21757
21849
|
insertTable: ({ rows = 3, cols = 3, withHeaderRow = false } = {}) => ({ tr, dispatch, editor }) => {
|
|
21758
21850
|
const node = createTable(editor.schema, rows, cols, withHeaderRow);
|
|
@@ -21765,8 +21857,9 @@ const Table = Node$1.create({
|
|
|
21765
21857
|
/**
|
|
21766
21858
|
* Delete the entire table containing the cursor
|
|
21767
21859
|
* @category Command
|
|
21860
|
+
* @returns {Function} Command
|
|
21768
21861
|
* @example
|
|
21769
|
-
*
|
|
21862
|
+
* deleteTable()
|
|
21770
21863
|
*/
|
|
21771
21864
|
deleteTable: () => ({ state, dispatch }) => {
|
|
21772
21865
|
return deleteTable(state, dispatch);
|
|
@@ -21774,8 +21867,9 @@ const Table = Node$1.create({
|
|
|
21774
21867
|
/**
|
|
21775
21868
|
* Add a column before the current column
|
|
21776
21869
|
* @category Command
|
|
21870
|
+
* @returns {Function} Command
|
|
21777
21871
|
* @example
|
|
21778
|
-
*
|
|
21872
|
+
* addColumnBefore()
|
|
21779
21873
|
* @note Preserves cell attributes from current column
|
|
21780
21874
|
*/
|
|
21781
21875
|
addColumnBefore: () => ({ state, dispatch, chain }) => {
|
|
@@ -22152,9 +22246,10 @@ const Table = Node$1.create({
|
|
|
22152
22246
|
* Set background color for selected cells
|
|
22153
22247
|
* @category Command
|
|
22154
22248
|
* @param {string} value - Color value (hex with or without #)
|
|
22249
|
+
* @returns {Function} Command
|
|
22155
22250
|
* @example
|
|
22156
|
-
*
|
|
22157
|
-
*
|
|
22251
|
+
* setCellBackground('#ff0000')
|
|
22252
|
+
* setCellBackground('ff0000')
|
|
22158
22253
|
*/
|
|
22159
22254
|
setCellBackground: (value) => ({ editor, commands: commands2, dispatch }) => {
|
|
22160
22255
|
const { selection } = editor.state;
|
|
@@ -22280,12 +22375,24 @@ const TableHeader = Node$1.create({
|
|
|
22280
22375
|
},
|
|
22281
22376
|
addAttributes() {
|
|
22282
22377
|
return {
|
|
22378
|
+
/**
|
|
22379
|
+
* @category Attribute
|
|
22380
|
+
* @param {number} [colspan=1] - Number of columns this header spans
|
|
22381
|
+
*/
|
|
22283
22382
|
colspan: {
|
|
22284
22383
|
default: 1
|
|
22285
22384
|
},
|
|
22385
|
+
/**
|
|
22386
|
+
* @category Attribute
|
|
22387
|
+
* @param {number} [rowspan=1] - Number of rows this header spans
|
|
22388
|
+
*/
|
|
22286
22389
|
rowspan: {
|
|
22287
22390
|
default: 1
|
|
22288
22391
|
},
|
|
22392
|
+
/**
|
|
22393
|
+
* @category Attribute
|
|
22394
|
+
* @param {number[]} [colwidth] - Column widths array in pixels
|
|
22395
|
+
*/
|
|
22289
22396
|
colwidth: {
|
|
22290
22397
|
default: null,
|
|
22291
22398
|
parseDOM: (element) => {
|
|
@@ -22322,6 +22429,10 @@ const TableRow = Node$1.create({
|
|
|
22322
22429
|
},
|
|
22323
22430
|
addAttributes() {
|
|
22324
22431
|
return {
|
|
22432
|
+
/**
|
|
22433
|
+
* @category Attribute
|
|
22434
|
+
* @param {number} [rowHeight] - Fixed row height in pixels
|
|
22435
|
+
*/
|
|
22325
22436
|
rowHeight: {
|
|
22326
22437
|
renderDOM({ rowHeight }) {
|
|
22327
22438
|
if (!rowHeight) return {};
|
|
@@ -22329,6 +22440,11 @@ const TableRow = Node$1.create({
|
|
|
22329
22440
|
return { style };
|
|
22330
22441
|
}
|
|
22331
22442
|
},
|
|
22443
|
+
/**
|
|
22444
|
+
* Indicates that this row should not be split across pages when paginating/exporting.
|
|
22445
|
+
* @category Attribute
|
|
22446
|
+
* @param {boolean} [cantSplit]
|
|
22447
|
+
*/
|
|
22332
22448
|
cantSplit: {
|
|
22333
22449
|
default: false,
|
|
22334
22450
|
parseDOM() {
|
|
@@ -22340,30 +22456,44 @@ const TableRow = Node$1.create({
|
|
|
22340
22456
|
}
|
|
22341
22457
|
},
|
|
22342
22458
|
/**
|
|
22459
|
+
* @category Attribute
|
|
22460
|
+
* @param {TableRowProperties} [tableRowProperties] - Properties for the table row.
|
|
22343
22461
|
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 377-482
|
|
22344
22462
|
*/
|
|
22345
22463
|
tableRowProperties: { rendered: false },
|
|
22346
22464
|
/**
|
|
22465
|
+
* @category Attribute
|
|
22466
|
+
* @param {string} [rsidDel] - Unique identifier used to track the editing session when the row was deleted from the main document.
|
|
22347
22467
|
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 472
|
|
22348
22468
|
*/
|
|
22349
22469
|
rsidDel: { rendered: false },
|
|
22350
22470
|
/**
|
|
22471
|
+
* @category Attribute
|
|
22472
|
+
* @param {string} [rsidR] - Unique identifier used to track the editing session when the table row was added to the main document.
|
|
22351
22473
|
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 472
|
|
22352
22474
|
*/
|
|
22353
22475
|
rsidR: { rendered: false },
|
|
22354
22476
|
/**
|
|
22477
|
+
* @category Attribute
|
|
22478
|
+
* @param {string} [rsidRPr] - Unique identifier used to track the editing session when the glyph character representing the table row mark was last modified in the main document.
|
|
22355
22479
|
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 473
|
|
22356
22480
|
*/
|
|
22357
22481
|
rsidRPr: { rendered: false },
|
|
22358
22482
|
/**
|
|
22483
|
+
* @category Attribute
|
|
22484
|
+
* @param {string} [rsidTr] - Unique identifier used to track the editing session when the table row's properties were last modified in this document.
|
|
22359
22485
|
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 473
|
|
22360
22486
|
*/
|
|
22361
22487
|
rsidTr: { rendered: false },
|
|
22362
22488
|
/**
|
|
22489
|
+
* @category Attribute
|
|
22490
|
+
* @param {string} [paraId] - A randomly generated unique identifier for the table row.
|
|
22363
22491
|
* @see {@link https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/a0e7d2e2-2246-44c6-96e8-1cf009823615}
|
|
22364
22492
|
*/
|
|
22365
22493
|
paraId: { rendered: false },
|
|
22366
22494
|
/**
|
|
22495
|
+
* @category Attribute
|
|
22496
|
+
* @param {string} [textId] - A randomly generated unique identifier for the text of the table row.
|
|
22367
22497
|
* @see {@link https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/b7eeddec-7c50-47fb-88b6-1feec3ed832c}
|
|
22368
22498
|
*/
|
|
22369
22499
|
textId: { rendered: false }
|
|
@@ -22390,12 +22520,24 @@ const TableCell = Node$1.create({
|
|
|
22390
22520
|
},
|
|
22391
22521
|
addAttributes() {
|
|
22392
22522
|
return {
|
|
22523
|
+
/**
|
|
22524
|
+
* @category Attribute
|
|
22525
|
+
* @param {number} [colspan=1] - Number of columns this cell spans
|
|
22526
|
+
*/
|
|
22393
22527
|
colspan: {
|
|
22394
22528
|
default: 1
|
|
22395
22529
|
},
|
|
22530
|
+
/**
|
|
22531
|
+
* @category Attribute
|
|
22532
|
+
* @param {number} [rowspan=1] - Number of rows this cell spans
|
|
22533
|
+
*/
|
|
22396
22534
|
rowspan: {
|
|
22397
22535
|
default: 1
|
|
22398
22536
|
},
|
|
22537
|
+
/**
|
|
22538
|
+
* @category Attribute
|
|
22539
|
+
* @param {number[]} [colwidth=[100]] - Column widths array in pixels
|
|
22540
|
+
*/
|
|
22399
22541
|
colwidth: {
|
|
22400
22542
|
default: [100],
|
|
22401
22543
|
parseDOM: (elem) => {
|
|
@@ -22410,6 +22552,10 @@ const TableCell = Node$1.create({
|
|
|
22410
22552
|
};
|
|
22411
22553
|
}
|
|
22412
22554
|
},
|
|
22555
|
+
/**
|
|
22556
|
+
* @category Attribute
|
|
22557
|
+
* @param {CellBackground} [background] - Cell background color configuration
|
|
22558
|
+
*/
|
|
22413
22559
|
background: {
|
|
22414
22560
|
renderDOM({ background }) {
|
|
22415
22561
|
if (!background) return {};
|
|
@@ -22418,6 +22564,10 @@ const TableCell = Node$1.create({
|
|
|
22418
22564
|
return { style };
|
|
22419
22565
|
}
|
|
22420
22566
|
},
|
|
22567
|
+
/**
|
|
22568
|
+
* @category Attribute
|
|
22569
|
+
* @param {string} [verticalAlign] - Vertical content alignment (top, middle, bottom)
|
|
22570
|
+
*/
|
|
22421
22571
|
verticalAlign: {
|
|
22422
22572
|
renderDOM({ verticalAlign }) {
|
|
22423
22573
|
if (!verticalAlign) return {};
|
|
@@ -22425,6 +22575,10 @@ const TableCell = Node$1.create({
|
|
|
22425
22575
|
return { style };
|
|
22426
22576
|
}
|
|
22427
22577
|
},
|
|
22578
|
+
/**
|
|
22579
|
+
* @category Attribute
|
|
22580
|
+
* @param {CellMargins} [cellMargins] - Internal cell padding
|
|
22581
|
+
*/
|
|
22428
22582
|
cellMargins: {
|
|
22429
22583
|
renderDOM({ cellMargins }) {
|
|
22430
22584
|
if (!cellMargins) return {};
|
|
@@ -22437,6 +22591,10 @@ const TableCell = Node$1.create({
|
|
|
22437
22591
|
return { style };
|
|
22438
22592
|
}
|
|
22439
22593
|
},
|
|
22594
|
+
/**
|
|
22595
|
+
* @category Attribute
|
|
22596
|
+
* @param {CellBorders} [borders] - Cell border configuration
|
|
22597
|
+
*/
|
|
22440
22598
|
borders: {
|
|
22441
22599
|
default: () => createCellBorders(),
|
|
22442
22600
|
renderDOM({ borders }) {
|
|
@@ -22451,10 +22609,20 @@ const TableCell = Node$1.create({
|
|
|
22451
22609
|
return { style };
|
|
22452
22610
|
}
|
|
22453
22611
|
},
|
|
22612
|
+
/**
|
|
22613
|
+
* @private
|
|
22614
|
+
* @category Attribute
|
|
22615
|
+
* @param {string} [widthType='auto'] - Internal width type
|
|
22616
|
+
*/
|
|
22454
22617
|
widthType: {
|
|
22455
22618
|
default: "auto",
|
|
22456
22619
|
rendered: false
|
|
22457
22620
|
},
|
|
22621
|
+
/**
|
|
22622
|
+
* @private
|
|
22623
|
+
* @category Attribute
|
|
22624
|
+
* @param {string} [widthUnit='px'] - Internal width unit
|
|
22625
|
+
*/
|
|
22458
22626
|
widthUnit: {
|
|
22459
22627
|
default: "px",
|
|
22460
22628
|
rendered: false
|
|
@@ -22705,11 +22873,11 @@ createAnnotation_fn = function({ displayLabel } = {}) {
|
|
|
22705
22873
|
let mergedAttrs = Attribute.mergeAttributes(this.htmlAttributes, {
|
|
22706
22874
|
style: omitHighlight ? "" : annotationStyle
|
|
22707
22875
|
});
|
|
22708
|
-
for (let [
|
|
22709
|
-
if (
|
|
22876
|
+
for (let [key, value] of Object.entries(mergedAttrs)) {
|
|
22877
|
+
if (key === "style") {
|
|
22710
22878
|
annotation.style.cssText = value;
|
|
22711
22879
|
} else {
|
|
22712
|
-
annotation.setAttribute(
|
|
22880
|
+
annotation.setAttribute(key, value);
|
|
22713
22881
|
}
|
|
22714
22882
|
}
|
|
22715
22883
|
return {
|
|
@@ -22883,13 +23051,13 @@ function hash$2(str) {
|
|
|
22883
23051
|
}
|
|
22884
23052
|
const colorToInt = (x) => parseInt(x.replace(/_/g, ""), 36);
|
|
22885
23053
|
const compressedColorMap = "1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm".split(" ").reduce((acc, next) => {
|
|
22886
|
-
const
|
|
23054
|
+
const key = colorToInt(next.substring(0, 3));
|
|
22887
23055
|
const hex = colorToInt(next.substring(3)).toString(16);
|
|
22888
23056
|
let prefix = "";
|
|
22889
23057
|
for (let i = 0; i < 6 - hex.length; i++) {
|
|
22890
23058
|
prefix += "0";
|
|
22891
23059
|
}
|
|
22892
|
-
acc[
|
|
23060
|
+
acc[key] = `${prefix}${hex}`;
|
|
22893
23061
|
return acc;
|
|
22894
23062
|
}, {});
|
|
22895
23063
|
function nameToHex(color) {
|
|
@@ -24005,552 +24173,41 @@ function getFormatAttrsFromMarks(marks) {
|
|
|
24005
24173
|
}
|
|
24006
24174
|
return formatAttrs;
|
|
24007
24175
|
}
|
|
24008
|
-
const
|
|
24009
|
-
|
|
24010
|
-
|
|
24011
|
-
|
|
24012
|
-
|
|
24013
|
-
|
|
24014
|
-
|
|
24015
|
-
|
|
24016
|
-
|
|
24017
|
-
|
|
24018
|
-
|
|
24019
|
-
|
|
24020
|
-
|
|
24021
|
-
|
|
24022
|
-
|
|
24023
|
-
|
|
24024
|
-
|
|
24025
|
-
|
|
24026
|
-
|
|
24027
|
-
|
|
24028
|
-
|
|
24029
|
-
|
|
24030
|
-
|
|
24031
|
-
|
|
24032
|
-
|
|
24033
|
-
|
|
24034
|
-
try {
|
|
24035
|
-
const response = await fetch(url, {
|
|
24036
|
-
mode: "cors",
|
|
24037
|
-
credentials: "omit",
|
|
24038
|
-
headers: {
|
|
24039
|
-
// Add common headers that might help with CORS
|
|
24040
|
-
Accept: "image/*,*/*;q=0.8"
|
|
24041
|
-
}
|
|
24042
|
-
});
|
|
24043
|
-
if (!response.ok) {
|
|
24044
|
-
console.warn(`Failed to fetch image from ${url}: ${response.status} ${response.statusText}`);
|
|
24045
|
-
return null;
|
|
24046
|
-
}
|
|
24047
|
-
const blob = await response.blob();
|
|
24048
|
-
const finalFilename = filename || extractFilenameFromUrl(url);
|
|
24049
|
-
const finalMimeType = mimeType || response.headers.get("content-type") || blob.type || "image/jpeg";
|
|
24050
|
-
return new File([blob], finalFilename, { type: finalMimeType });
|
|
24051
|
-
} catch (error) {
|
|
24052
|
-
if (isCorsError(error)) {
|
|
24053
|
-
console.warn(`CORS policy prevents accessing image from ${url}:`, error.message);
|
|
24054
|
-
return null;
|
|
24055
|
-
}
|
|
24056
|
-
console.error(`Error fetching image from ${url}:`, error);
|
|
24057
|
-
return null;
|
|
24058
|
-
}
|
|
24059
|
-
};
|
|
24060
|
-
const isCorsError = (error) => {
|
|
24061
|
-
const errorMessage = error.message.toLowerCase();
|
|
24062
|
-
const errorName = error.name.toLowerCase();
|
|
24063
|
-
return errorName.includes("cors") || errorMessage.includes("cors") || errorMessage.includes("cross-origin") || errorMessage.includes("access-control") || errorMessage.includes("network error") || // Often indicates CORS in browsers
|
|
24064
|
-
errorMessage.includes("failed to fetch");
|
|
24065
|
-
};
|
|
24066
|
-
const extractFilenameFromUrl = (url) => {
|
|
24067
|
-
try {
|
|
24068
|
-
const urlObj = new URL(url);
|
|
24069
|
-
const pathname = urlObj.pathname;
|
|
24070
|
-
const filename = pathname.split("/").pop();
|
|
24071
|
-
if (filename && !filename.includes(".")) {
|
|
24072
|
-
return `${filename}.jpg`;
|
|
24073
|
-
}
|
|
24074
|
-
return filename || "image.jpg";
|
|
24075
|
-
} catch {
|
|
24076
|
-
return "image.jpg";
|
|
24077
|
-
}
|
|
24078
|
-
};
|
|
24079
|
-
const validateUrlAccessibility = async (url) => {
|
|
24080
|
-
try {
|
|
24081
|
-
const response = await fetch(url, {
|
|
24082
|
-
method: "HEAD",
|
|
24083
|
-
mode: "cors",
|
|
24084
|
-
credentials: "omit"
|
|
24085
|
-
});
|
|
24086
|
-
return response.ok;
|
|
24087
|
-
} catch {
|
|
24088
|
-
return false;
|
|
24089
|
-
}
|
|
24090
|
-
};
|
|
24091
|
-
const handleImageUpload = (file) => {
|
|
24092
|
-
return new Promise((resolve, reject) => {
|
|
24093
|
-
let reader = new FileReader();
|
|
24094
|
-
reader.onload = (event) => {
|
|
24095
|
-
resolve(event.target.result);
|
|
24096
|
-
};
|
|
24097
|
-
reader.onerror = reject;
|
|
24098
|
-
setTimeout(() => reader.readAsDataURL(file), 250);
|
|
24099
|
-
});
|
|
24100
|
-
};
|
|
24101
|
-
const processUploadedImage = (fileData, getMaxContentSize) => {
|
|
24102
|
-
return new Promise((resolve, reject) => {
|
|
24103
|
-
const img = new window.Image();
|
|
24104
|
-
img.onload = () => {
|
|
24105
|
-
const canvas = document.createElement("canvas");
|
|
24106
|
-
const { width: logicalWidth, height: logicalHeight } = getAllowedImageDimensions(
|
|
24107
|
-
img.width,
|
|
24108
|
-
img.height,
|
|
24109
|
-
getMaxContentSize
|
|
24110
|
-
);
|
|
24111
|
-
canvas.width = img.width;
|
|
24112
|
-
canvas.height = img.height;
|
|
24113
|
-
const ctx = canvas.getContext("2d");
|
|
24114
|
-
if (ctx) {
|
|
24115
|
-
ctx.imageSmoothingEnabled = true;
|
|
24116
|
-
try {
|
|
24117
|
-
ctx.imageSmoothingQuality = "high";
|
|
24118
|
-
} catch {
|
|
24119
|
-
}
|
|
24120
|
-
}
|
|
24121
|
-
ctx.drawImage(img, 0, 0, img.width, img.height);
|
|
24122
|
-
const dpr = typeof window !== "undefined" && window.devicePixelRatio ? window.devicePixelRatio : 1;
|
|
24123
|
-
const targetPixelWidth = Math.round(logicalWidth * dpr);
|
|
24124
|
-
const targetPixelHeight = Math.round(logicalHeight * dpr);
|
|
24125
|
-
const finalTargetWidth = Math.min(targetPixelWidth, img.width);
|
|
24126
|
-
const finalTargetHeight = Math.min(targetPixelHeight, img.height);
|
|
24127
|
-
const resizeNeeded = finalTargetWidth !== img.width || finalTargetHeight !== img.height;
|
|
24128
|
-
if (resizeNeeded) {
|
|
24129
|
-
multiStepResize(canvas, finalTargetWidth, finalTargetHeight);
|
|
24130
|
-
}
|
|
24131
|
-
if (typeof fileData === "string") {
|
|
24132
|
-
const resizedBase64 = canvas.toDataURL();
|
|
24133
|
-
resolve(resizedBase64);
|
|
24134
|
-
} else {
|
|
24135
|
-
canvas.toBlob((blob) => {
|
|
24136
|
-
const updatedFile = new File([blob], fileData.name, {
|
|
24137
|
-
type: fileData.type,
|
|
24138
|
-
lastModified: Date.now()
|
|
24139
|
-
});
|
|
24140
|
-
resolve({ file: updatedFile, width: logicalWidth, height: logicalHeight });
|
|
24141
|
-
});
|
|
24142
|
-
}
|
|
24143
|
-
};
|
|
24144
|
-
img.onerror = (error) => reject(error);
|
|
24145
|
-
img.src = typeof fileData === "string" ? fileData : URL.createObjectURL(fileData);
|
|
24146
|
-
});
|
|
24147
|
-
};
|
|
24148
|
-
const getAllowedImageDimensions = (width, height, getMaxContentSize) => {
|
|
24149
|
-
const { width: maxWidth, height: maxHeight } = getMaxContentSize();
|
|
24150
|
-
if (!maxWidth || !maxHeight) return { width, height };
|
|
24151
|
-
let adjustedWidth = width;
|
|
24152
|
-
let adjustedHeight = height;
|
|
24153
|
-
const aspectRatio = width / height;
|
|
24154
|
-
if (height > maxHeight) {
|
|
24155
|
-
adjustedHeight = maxHeight;
|
|
24156
|
-
adjustedWidth = Math.round(maxHeight * aspectRatio);
|
|
24157
|
-
}
|
|
24158
|
-
if (adjustedWidth > maxWidth) {
|
|
24159
|
-
adjustedWidth = maxWidth;
|
|
24160
|
-
adjustedHeight = Math.round(maxWidth / aspectRatio);
|
|
24161
|
-
}
|
|
24162
|
-
return { width: adjustedWidth, height: adjustedHeight };
|
|
24163
|
-
};
|
|
24164
|
-
function resample_high_quality(canvas, width, height, resize_canvas) {
|
|
24165
|
-
var width_source = canvas.width;
|
|
24166
|
-
var height_source = canvas.height;
|
|
24167
|
-
width = Math.round(width);
|
|
24168
|
-
height = Math.round(height);
|
|
24169
|
-
var ratio_w = width_source / width;
|
|
24170
|
-
var ratio_h = height_source / height;
|
|
24171
|
-
var ratio_w_half = Math.ceil(ratio_w / 2);
|
|
24172
|
-
var ratio_h_half = Math.ceil(ratio_h / 2);
|
|
24173
|
-
var ctx = canvas.getContext("2d");
|
|
24174
|
-
var img = ctx.getImageData(0, 0, width_source, height_source);
|
|
24175
|
-
var img2 = ctx.createImageData(width, height);
|
|
24176
|
-
var data = img.data;
|
|
24177
|
-
var data2 = img2.data;
|
|
24178
|
-
for (var j = 0; j < height; j++) {
|
|
24179
|
-
for (var i = 0; i < width; i++) {
|
|
24180
|
-
var x2 = (i + j * width) * 4;
|
|
24181
|
-
var weight = 0;
|
|
24182
|
-
var weights = 0;
|
|
24183
|
-
var weights_alpha = 0;
|
|
24184
|
-
var gx_r = 0;
|
|
24185
|
-
var gx_g = 0;
|
|
24186
|
-
var gx_b = 0;
|
|
24187
|
-
var gx_a = 0;
|
|
24188
|
-
var center_y = (j + 0.5) * ratio_h;
|
|
24189
|
-
var yy_start = Math.floor(j * ratio_h);
|
|
24190
|
-
var yy_stop = Math.ceil((j + 1) * ratio_h);
|
|
24191
|
-
for (var yy = yy_start; yy < yy_stop; yy++) {
|
|
24192
|
-
var dy = Math.abs(center_y - (yy + 0.5)) / ratio_h_half;
|
|
24193
|
-
var center_x = (i + 0.5) * ratio_w;
|
|
24194
|
-
var w0 = dy * dy;
|
|
24195
|
-
var xx_start = Math.floor(i * ratio_w);
|
|
24196
|
-
var xx_stop = Math.ceil((i + 1) * ratio_w);
|
|
24197
|
-
for (var xx = xx_start; xx < xx_stop; xx++) {
|
|
24198
|
-
var dx = Math.abs(center_x - (xx + 0.5)) / ratio_w_half;
|
|
24199
|
-
var w = Math.sqrt(w0 + dx * dx);
|
|
24200
|
-
if (w >= 1) {
|
|
24201
|
-
continue;
|
|
24202
|
-
}
|
|
24203
|
-
weight = 2 * w * w * w - 3 * w * w + 1;
|
|
24204
|
-
var pos_x = 4 * (xx + yy * width_source);
|
|
24205
|
-
gx_a += weight * data[pos_x + 3];
|
|
24206
|
-
weights_alpha += weight;
|
|
24207
|
-
if (data[pos_x + 3] < 255) weight = weight * data[pos_x + 3] / 250;
|
|
24208
|
-
gx_r += weight * data[pos_x];
|
|
24209
|
-
gx_g += weight * data[pos_x + 1];
|
|
24210
|
-
gx_b += weight * data[pos_x + 2];
|
|
24211
|
-
weights += weight;
|
|
24212
|
-
}
|
|
24213
|
-
}
|
|
24214
|
-
data2[x2] = gx_r / weights;
|
|
24215
|
-
data2[x2 + 1] = gx_g / weights;
|
|
24216
|
-
data2[x2 + 2] = gx_b / weights;
|
|
24217
|
-
data2[x2 + 3] = gx_a / weights_alpha;
|
|
24218
|
-
}
|
|
24219
|
-
}
|
|
24220
|
-
{
|
|
24221
|
-
canvas.width = width;
|
|
24222
|
-
canvas.height = height;
|
|
24223
|
-
}
|
|
24224
|
-
ctx.putImageData(img2, 0, 0);
|
|
24225
|
-
}
|
|
24226
|
-
function multiStepResize(canvas, width, height) {
|
|
24227
|
-
let oc = document.createElement("canvas");
|
|
24228
|
-
let octx = oc.getContext("2d");
|
|
24229
|
-
let ctx = canvas.getContext("2d");
|
|
24230
|
-
let steps = Math.ceil(Math.log(canvas.width / width) / Math.log(2));
|
|
24231
|
-
steps = Math.max(steps, 1);
|
|
24232
|
-
let stepWidth = width * Math.pow(2, steps - 1);
|
|
24233
|
-
let stepHeight = height * Math.pow(2, steps - 1);
|
|
24234
|
-
let currentWidth = canvas.width;
|
|
24235
|
-
let currentHeight = canvas.height;
|
|
24236
|
-
oc.width = currentWidth;
|
|
24237
|
-
oc.height = currentHeight;
|
|
24238
|
-
octx.drawImage(canvas, 0, 0);
|
|
24239
|
-
while (steps > 0) {
|
|
24240
|
-
stepWidth = Math.max(stepWidth, width);
|
|
24241
|
-
stepHeight = Math.max(stepHeight, height);
|
|
24242
|
-
canvas.width = stepWidth;
|
|
24243
|
-
canvas.height = stepHeight;
|
|
24244
|
-
ctx.drawImage(oc, 0, 0, currentWidth, currentHeight, 0, 0, stepWidth, stepHeight);
|
|
24245
|
-
currentWidth = stepWidth;
|
|
24246
|
-
currentHeight = stepHeight;
|
|
24247
|
-
oc.width = currentWidth;
|
|
24248
|
-
oc.height = currentHeight;
|
|
24249
|
-
octx.drawImage(canvas, 0, 0);
|
|
24250
|
-
stepWidth = Math.round(stepWidth / 2);
|
|
24251
|
-
stepHeight = Math.round(stepHeight / 2);
|
|
24252
|
-
steps--;
|
|
24253
|
-
}
|
|
24254
|
-
resample_high_quality(canvas, width, height);
|
|
24255
|
-
}
|
|
24256
|
-
const FALLBACK_NAME = "image";
|
|
24257
|
-
const stripDiacritics = (value) => value.normalize("NFKD").replace(/[\u0300-\u036f]/g, "");
|
|
24258
|
-
const sanitizeSegment = (segment, { allowDots = false } = {}) => {
|
|
24259
|
-
if (!segment) return "";
|
|
24260
|
-
const normalized = stripDiacritics(segment).replace(/[\s\u2000-\u206f]+/g, "_").replace(/[\\/]+/g, "_");
|
|
24261
|
-
const allowedPattern = allowDots ? /[^0-9A-Za-z._-]+/g : /[^0-9A-Za-z_-]+/g;
|
|
24262
|
-
let sanitized = normalized.replace(allowedPattern, "_");
|
|
24263
|
-
sanitized = sanitized.replace(/_+/g, "_");
|
|
24264
|
-
sanitized = sanitized.replace(/^[_.-]+/, "");
|
|
24265
|
-
sanitized = sanitized.replace(/[_-]+$/, "");
|
|
24266
|
-
return sanitized;
|
|
24267
|
-
};
|
|
24268
|
-
const splitFileName = (name) => {
|
|
24269
|
-
const trimmed = name?.trim?.() ?? "";
|
|
24270
|
-
const lastDot = trimmed.lastIndexOf(".");
|
|
24271
|
-
if (lastDot <= 0 || lastDot === trimmed.length - 1) {
|
|
24272
|
-
return { base: trimmed, ext: "" };
|
|
24273
|
-
}
|
|
24274
|
-
return {
|
|
24275
|
-
base: trimmed.slice(0, lastDot),
|
|
24276
|
-
ext: trimmed.slice(lastDot + 1)
|
|
24277
|
-
};
|
|
24278
|
-
};
|
|
24279
|
-
const sanitizeImageFileName = (inputName) => {
|
|
24280
|
-
const { base: base2, ext } = splitFileName(inputName || "");
|
|
24281
|
-
const sanitizedBase = sanitizeSegment(base2, { allowDots: true }) || FALLBACK_NAME;
|
|
24282
|
-
const sanitizedExt = sanitizeSegment(ext, { allowDots: false }).toLowerCase();
|
|
24283
|
-
if (!sanitizedExt) return sanitizedBase;
|
|
24284
|
-
return `${sanitizedBase}.${sanitizedExt}`;
|
|
24285
|
-
};
|
|
24286
|
-
const ensureUniqueFileName = (preferredName, existingNames = /* @__PURE__ */ new Set()) => {
|
|
24287
|
-
const sanitized = sanitizeImageFileName(preferredName);
|
|
24288
|
-
if (!existingNames || typeof existingNames.has !== "function") {
|
|
24289
|
-
return sanitized;
|
|
24290
|
-
}
|
|
24291
|
-
const existingSet = /* @__PURE__ */ new Set();
|
|
24292
|
-
existingNames.forEach((name) => existingSet.add(sanitizeImageFileName(name)));
|
|
24293
|
-
if (!existingSet.has(sanitized)) {
|
|
24294
|
-
return sanitized;
|
|
24295
|
-
}
|
|
24296
|
-
const { base: base2, ext } = splitFileName(sanitized);
|
|
24297
|
-
let counter = 1;
|
|
24298
|
-
let candidate = sanitized;
|
|
24299
|
-
const suffix = () => `${base2}-${counter}${ext ? `.${ext}` : ""}`;
|
|
24300
|
-
while (existingSet.has(candidate)) {
|
|
24301
|
-
candidate = suffix();
|
|
24302
|
-
counter += 1;
|
|
24303
|
-
}
|
|
24304
|
-
return candidate;
|
|
24305
|
-
};
|
|
24306
|
-
const buildMediaPath = (fileName) => `word/media/${fileName}`;
|
|
24307
|
-
const fileTooLarge = (file) => {
|
|
24308
|
-
let fileSizeMb = Number((file.size / (1024 * 1024)).toFixed(4));
|
|
24309
|
-
if (fileSizeMb > 5) {
|
|
24310
|
-
window.alert("Image size must be less than 5MB");
|
|
24311
|
-
return true;
|
|
24312
|
-
}
|
|
24313
|
-
return false;
|
|
24314
|
-
};
|
|
24315
|
-
const checkAndProcessImage = async ({ getMaxContentSize, file }) => {
|
|
24316
|
-
if (fileTooLarge(file)) {
|
|
24317
|
-
return { file: null, size: { width: 0, height: 0 } };
|
|
24318
|
-
}
|
|
24319
|
-
try {
|
|
24320
|
-
const processedImageResult = await processUploadedImage(file, getMaxContentSize);
|
|
24321
|
-
const process = processedImageResult;
|
|
24322
|
-
return { file: process.file, size: { width: process.width, height: process.height } };
|
|
24323
|
-
} catch (err) {
|
|
24324
|
-
console.warn("Error processing image:", err);
|
|
24325
|
-
return { file: null, size: { width: 0, height: 0 } };
|
|
24326
|
-
}
|
|
24327
|
-
};
|
|
24328
|
-
function replaceSelectionWithImagePlaceholder({ editorOptions, view, id }) {
|
|
24329
|
-
let { tr } = view.state;
|
|
24330
|
-
let { selection } = tr;
|
|
24331
|
-
if (editorOptions.isHeaderOrFooter) {
|
|
24332
|
-
selection = editorOptions.lastSelection;
|
|
24333
|
-
}
|
|
24334
|
-
if (!selection.empty && !editorOptions.isHeaderOrFooter) {
|
|
24335
|
-
tr.deleteSelection();
|
|
24336
|
-
}
|
|
24337
|
-
tr = addImagePlaceholder(view.state, tr, id, selection.from);
|
|
24338
|
-
view.dispatch(tr);
|
|
24339
|
-
}
|
|
24340
|
-
const generateUniqueDocPrId = (editor) => {
|
|
24341
|
-
const existingIds = /* @__PURE__ */ new Set();
|
|
24342
|
-
editor?.state?.doc?.descendants((node) => {
|
|
24343
|
-
if (node.type.name === "image" && node.attrs.id !== void 0 && node.attrs.id !== null) {
|
|
24344
|
-
existingIds.add(String(node.attrs.id));
|
|
24345
|
-
}
|
|
24346
|
-
});
|
|
24347
|
-
let candidate;
|
|
24348
|
-
do {
|
|
24349
|
-
const hex = generateDocxRandomId();
|
|
24350
|
-
candidate = String(parseInt(hex, 16));
|
|
24351
|
-
} while (!candidate || existingIds.has(candidate));
|
|
24352
|
-
return candidate;
|
|
24353
|
-
};
|
|
24354
|
-
async function uploadAndInsertImage({ editor, view, file, size, id }) {
|
|
24355
|
-
const imageUploadHandler = typeof editor.options.handleImageUpload === "function" ? editor.options.handleImageUpload : handleImageUpload;
|
|
24356
|
-
const placeholderId = id;
|
|
24357
|
-
try {
|
|
24358
|
-
const existingFileNames = new Set(Object.keys(editor.storage.image.media ?? {}).map((key2) => key2.split("/").pop()));
|
|
24359
|
-
const uniqueFileName = ensureUniqueFileName(file.name, existingFileNames);
|
|
24360
|
-
const normalizedFile = uniqueFileName === file.name ? file : new File([file], uniqueFileName, {
|
|
24361
|
-
type: file.type,
|
|
24362
|
-
lastModified: file.lastModified ?? Date.now()
|
|
24363
|
-
});
|
|
24364
|
-
let url = await imageUploadHandler(normalizedFile);
|
|
24365
|
-
let placeholderPos = findPlaceholder(view.state, placeholderId);
|
|
24366
|
-
if (placeholderPos == null) {
|
|
24367
|
-
return;
|
|
24368
|
-
}
|
|
24369
|
-
const mediaPath = buildMediaPath(uniqueFileName);
|
|
24370
|
-
const docPrId = generateUniqueDocPrId(editor);
|
|
24371
|
-
let rId = null;
|
|
24372
|
-
if (editor.options.mode === "docx") {
|
|
24373
|
-
const [, path] = mediaPath.split("word/");
|
|
24374
|
-
const id2 = addImageRelationship({ editor, path });
|
|
24375
|
-
if (id2) rId = id2;
|
|
24376
|
-
}
|
|
24377
|
-
let imageNode = view.state.schema.nodes.image.create({
|
|
24378
|
-
src: mediaPath,
|
|
24379
|
-
size,
|
|
24380
|
-
id: docPrId,
|
|
24381
|
-
rId
|
|
24382
|
-
});
|
|
24383
|
-
editor.storage.image.media = Object.assign(editor.storage.image.media, { [mediaPath]: url });
|
|
24384
|
-
if (editor.options.ydoc && typeof editor.commands.addImageToCollaboration === "function") {
|
|
24385
|
-
editor.commands.addImageToCollaboration({ mediaPath, fileData: url });
|
|
24386
|
-
}
|
|
24387
|
-
let tr = view.state.tr;
|
|
24388
|
-
tr.replaceWith(placeholderPos, placeholderPos, imageNode);
|
|
24389
|
-
tr = removeImagePlaceholder(view.state, tr, placeholderId);
|
|
24390
|
-
view.dispatch(tr);
|
|
24391
|
-
} catch {
|
|
24392
|
-
const tr = removeImagePlaceholder(view.state, view.state.tr, placeholderId);
|
|
24393
|
-
view.dispatch(tr);
|
|
24394
|
-
}
|
|
24395
|
-
}
|
|
24396
|
-
function addImageRelationship({ editor, path }) {
|
|
24397
|
-
const target = path;
|
|
24398
|
-
const type = "image";
|
|
24399
|
-
try {
|
|
24400
|
-
const id = insertNewRelationship(target, type, editor);
|
|
24401
|
-
return id;
|
|
24402
|
-
} catch {
|
|
24403
|
-
return null;
|
|
24404
|
-
}
|
|
24405
|
-
}
|
|
24406
|
-
const key = new PluginKey("ImageRegistration");
|
|
24407
|
-
const ImageRegistrationPlugin = ({ editor }) => {
|
|
24408
|
-
const { view } = editor;
|
|
24409
|
-
return new Plugin({
|
|
24410
|
-
key,
|
|
24411
|
-
state: {
|
|
24412
|
-
init() {
|
|
24413
|
-
return { set: DecorationSet.empty };
|
|
24414
|
-
},
|
|
24415
|
-
apply(tr, { set }) {
|
|
24416
|
-
const meta = tr.getMeta(key);
|
|
24417
|
-
if (meta) {
|
|
24418
|
-
set = meta.set;
|
|
24419
|
-
return { set };
|
|
24420
|
-
}
|
|
24421
|
-
set = set.map(tr.mapping, tr.doc);
|
|
24422
|
-
return { set };
|
|
24423
|
-
}
|
|
24424
|
-
},
|
|
24425
|
-
appendTransaction: (trs, _oldState, state) => {
|
|
24426
|
-
let foundImages = [];
|
|
24427
|
-
trs.forEach((tr2) => {
|
|
24428
|
-
if (tr2.docChanged) {
|
|
24429
|
-
tr2.steps.forEach((step, index2) => {
|
|
24430
|
-
const stepMap = step.getMap();
|
|
24431
|
-
foundImages = foundImages.map(({ node, pos, id }) => {
|
|
24432
|
-
const mappedPos = stepMap.map(pos, -1);
|
|
24433
|
-
return { node, pos: mappedPos, id };
|
|
24434
|
-
});
|
|
24435
|
-
if (step instanceof ReplaceStep || step instanceof ReplaceAroundStep$1) {
|
|
24436
|
-
(tr2.docs[index2 + 1] || tr2.doc).nodesBetween(
|
|
24437
|
-
stepMap.map(step.from, -1),
|
|
24438
|
-
stepMap.map(step.to, 1),
|
|
24439
|
-
(node, pos) => {
|
|
24440
|
-
if (node.type.name === "image" && !node.attrs.src.startsWith("word/media")) {
|
|
24441
|
-
const id = {};
|
|
24442
|
-
foundImages.push({ node, pos, id });
|
|
24443
|
-
} else {
|
|
24444
|
-
return true;
|
|
24445
|
-
}
|
|
24446
|
-
}
|
|
24447
|
-
);
|
|
24448
|
-
}
|
|
24449
|
-
});
|
|
24450
|
-
}
|
|
24451
|
-
});
|
|
24452
|
-
if (!foundImages || foundImages.length === 0) {
|
|
24453
|
-
return null;
|
|
24454
|
-
}
|
|
24455
|
-
registerImages(foundImages, editor, view);
|
|
24456
|
-
const tr = state.tr;
|
|
24457
|
-
let { set } = key.getState(state);
|
|
24458
|
-
foundImages.slice().sort((a, b) => a.pos - b.pos).forEach(({ pos, id }) => {
|
|
24459
|
-
let deco = Decoration.widget(pos, () => document.createElement("placeholder"), {
|
|
24460
|
-
side: -1,
|
|
24461
|
-
id
|
|
24462
|
-
});
|
|
24463
|
-
set = set.add(tr.doc, [deco]);
|
|
24464
|
-
});
|
|
24465
|
-
foundImages.slice().sort((a, b) => b.pos - a.pos).forEach(({ node, pos }) => {
|
|
24466
|
-
tr.delete(pos, pos + node.nodeSize);
|
|
24467
|
-
});
|
|
24468
|
-
set = set.map(tr.mapping, tr.doc);
|
|
24469
|
-
tr.setMeta(key, { set });
|
|
24470
|
-
return tr;
|
|
24471
|
-
},
|
|
24472
|
-
props: {
|
|
24473
|
-
decorations(state) {
|
|
24474
|
-
let { set } = key.getState(state);
|
|
24475
|
-
return set;
|
|
24176
|
+
const ImagePlaceholderPluginKey = new PluginKey("ImagePlaceholder");
|
|
24177
|
+
const ImagePlaceholderPlugin = () => {
|
|
24178
|
+
return new Plugin({
|
|
24179
|
+
key: ImagePlaceholderPluginKey,
|
|
24180
|
+
state: {
|
|
24181
|
+
init() {
|
|
24182
|
+
return DecorationSet.empty;
|
|
24183
|
+
},
|
|
24184
|
+
apply(tr, set) {
|
|
24185
|
+
set = set.map(tr.mapping, tr.doc);
|
|
24186
|
+
let action = tr.getMeta(ImagePlaceholderPluginKey);
|
|
24187
|
+
if (action?.type === "add") {
|
|
24188
|
+
let widget = document.createElement("placeholder");
|
|
24189
|
+
let deco = Decoration.widget(action.pos, widget, {
|
|
24190
|
+
id: action.id
|
|
24191
|
+
});
|
|
24192
|
+
set = set.add(tr.doc, [deco]);
|
|
24193
|
+
} else if (action?.type === "remove") {
|
|
24194
|
+
set = set.remove(set.find(null, null, (spec) => spec.id == action.id));
|
|
24195
|
+
}
|
|
24196
|
+
return set;
|
|
24197
|
+
}
|
|
24198
|
+
},
|
|
24199
|
+
props: {
|
|
24200
|
+
decorations(state) {
|
|
24201
|
+
return this.getState(state);
|
|
24476
24202
|
}
|
|
24477
24203
|
}
|
|
24478
24204
|
});
|
|
24479
24205
|
};
|
|
24480
24206
|
const findPlaceholder = (state, id) => {
|
|
24481
|
-
let
|
|
24482
|
-
let found =
|
|
24207
|
+
let decos = ImagePlaceholderPluginKey.getState(state);
|
|
24208
|
+
let found = decos?.find(null, null, (spec) => spec.id === id);
|
|
24483
24209
|
return found?.length ? found[0].from : null;
|
|
24484
24210
|
};
|
|
24485
|
-
const removeImagePlaceholder = (state, tr, id) => {
|
|
24486
|
-
let { set } = key.getState(state);
|
|
24487
|
-
set = set.map(tr.mapping, tr.doc);
|
|
24488
|
-
set = set.remove(set.find(null, null, (spec) => spec.id == id));
|
|
24489
|
-
return tr.setMeta(key, { set, type: "remove" });
|
|
24490
|
-
};
|
|
24491
|
-
const addImagePlaceholder = (state, tr, id, pos) => {
|
|
24492
|
-
let { set } = key.getState(state);
|
|
24493
|
-
set = set.map(tr.mapping, tr.doc);
|
|
24494
|
-
let deco = Decoration.widget(pos, () => document.createElement("placeholder"), {
|
|
24495
|
-
id
|
|
24496
|
-
});
|
|
24497
|
-
set = set.add(tr.doc, [deco]);
|
|
24498
|
-
return tr.setMeta(key, { set, type: "add" });
|
|
24499
|
-
};
|
|
24500
|
-
const getImageRegistrationMetaType = (tr) => {
|
|
24501
|
-
const meta = tr.getMeta(key);
|
|
24502
|
-
if (meta && meta.type) {
|
|
24503
|
-
return meta.type;
|
|
24504
|
-
}
|
|
24505
|
-
return null;
|
|
24506
|
-
};
|
|
24507
|
-
const registerImages = async (foundImages, editor, view) => {
|
|
24508
|
-
foundImages.forEach(async (image) => {
|
|
24509
|
-
const src = image.node.attrs.src;
|
|
24510
|
-
const id = image.id;
|
|
24511
|
-
let file = null;
|
|
24512
|
-
if (src.startsWith("http")) {
|
|
24513
|
-
const isAccessible = await validateUrlAccessibility(src);
|
|
24514
|
-
if (isAccessible) {
|
|
24515
|
-
file = await urlToFile(src);
|
|
24516
|
-
} else {
|
|
24517
|
-
console.warn(`Image URL ${src} is not accessible due to CORS or other restrictions. Using original URL.`);
|
|
24518
|
-
const tr = view.state.tr;
|
|
24519
|
-
removeImagePlaceholder(view.state, tr, id);
|
|
24520
|
-
view.dispatch(tr);
|
|
24521
|
-
return;
|
|
24522
|
-
}
|
|
24523
|
-
} else if (src.startsWith("data:")) {
|
|
24524
|
-
file = base64ToFile(src);
|
|
24525
|
-
} else {
|
|
24526
|
-
console.error(`Unsupported image source: ${src}`);
|
|
24527
|
-
}
|
|
24528
|
-
if (!file) {
|
|
24529
|
-
const tr = view.state.tr;
|
|
24530
|
-
removeImagePlaceholder(view.state, tr, id);
|
|
24531
|
-
view.dispatch(tr);
|
|
24532
|
-
return;
|
|
24533
|
-
}
|
|
24534
|
-
try {
|
|
24535
|
-
const process = await checkAndProcessImage({
|
|
24536
|
-
getMaxContentSize: () => editor.getMaxContentSize(),
|
|
24537
|
-
file
|
|
24538
|
-
});
|
|
24539
|
-
if (!process.file) {
|
|
24540
|
-
const tr = view.state.tr;
|
|
24541
|
-
removeImagePlaceholder(view.state, tr, id);
|
|
24542
|
-
view.dispatch(tr);
|
|
24543
|
-
return;
|
|
24544
|
-
}
|
|
24545
|
-
await uploadAndInsertImage({ editor, view, file: process.file, size: process.size, id });
|
|
24546
|
-
} catch (error) {
|
|
24547
|
-
console.error(`Error processing image from ${src}:`, error);
|
|
24548
|
-
const tr = view.state.tr;
|
|
24549
|
-
removeImagePlaceholder(view.state, tr, id);
|
|
24550
|
-
view.dispatch(tr);
|
|
24551
|
-
}
|
|
24552
|
-
});
|
|
24553
|
-
};
|
|
24554
24211
|
const ImagePositionPluginKey = new PluginKey("ImagePosition");
|
|
24555
24212
|
const ImagePositionPlugin = ({ editor }) => {
|
|
24556
24213
|
const { view } = editor;
|
|
@@ -24657,19 +24314,6 @@ const findPreviousDomNodeWithClass = (view, pos, className) => {
|
|
|
24657
24314
|
}
|
|
24658
24315
|
return null;
|
|
24659
24316
|
};
|
|
24660
|
-
const getRotationMargins = (w, h, angleDegrees) => {
|
|
24661
|
-
const rad = angleDegrees * (Math.PI / 180);
|
|
24662
|
-
const cos = Math.abs(Math.cos(rad));
|
|
24663
|
-
const sin = Math.abs(Math.sin(rad));
|
|
24664
|
-
const boundingWidth = w * cos + h * sin;
|
|
24665
|
-
const boundingHeight = w * sin + h * cos;
|
|
24666
|
-
const marginLeftRight = Math.round(Math.max(0, (boundingWidth - w) / 2));
|
|
24667
|
-
const marginTopBottom = Math.round(Math.max(0, (boundingHeight - h) / 2));
|
|
24668
|
-
return {
|
|
24669
|
-
horizontal: marginLeftRight,
|
|
24670
|
-
vertical: marginTopBottom
|
|
24671
|
-
};
|
|
24672
|
-
};
|
|
24673
24317
|
const Image = Node$1.create({
|
|
24674
24318
|
name: "image",
|
|
24675
24319
|
group: "inline",
|
|
@@ -24691,6 +24335,10 @@ const Image = Node$1.create({
|
|
|
24691
24335
|
},
|
|
24692
24336
|
addAttributes() {
|
|
24693
24337
|
return {
|
|
24338
|
+
/**
|
|
24339
|
+
* @category Attribute
|
|
24340
|
+
* @param {string} [src] - Image source URL or path
|
|
24341
|
+
*/
|
|
24694
24342
|
src: {
|
|
24695
24343
|
default: null,
|
|
24696
24344
|
renderDOM: ({ src }) => {
|
|
@@ -24699,75 +24347,95 @@ const Image = Node$1.create({
|
|
|
24699
24347
|
};
|
|
24700
24348
|
}
|
|
24701
24349
|
},
|
|
24350
|
+
/**
|
|
24351
|
+
* @category Attribute
|
|
24352
|
+
* @param {string} [alt='Uploaded picture'] - Alternative text for accessibility
|
|
24353
|
+
*/
|
|
24702
24354
|
alt: {
|
|
24703
24355
|
default: "Uploaded picture"
|
|
24704
24356
|
},
|
|
24357
|
+
/**
|
|
24358
|
+
* @category Attribute
|
|
24359
|
+
* @param {string} [id] - Image element ID
|
|
24360
|
+
* @private
|
|
24361
|
+
*/
|
|
24705
24362
|
id: { rendered: false },
|
|
24363
|
+
/**
|
|
24364
|
+
* @category Attribute
|
|
24365
|
+
* @param {string} [title] - Image title/tooltip text
|
|
24366
|
+
*/
|
|
24706
24367
|
title: {
|
|
24707
24368
|
default: null
|
|
24708
24369
|
},
|
|
24370
|
+
/**
|
|
24371
|
+
* @category Attribute
|
|
24372
|
+
* @param {string} [rId] - Relationship ID for Word export
|
|
24373
|
+
* @private
|
|
24374
|
+
*/
|
|
24709
24375
|
rId: {
|
|
24710
24376
|
default: null,
|
|
24711
24377
|
rendered: false
|
|
24712
24378
|
},
|
|
24379
|
+
/**
|
|
24380
|
+
* @category Attribute
|
|
24381
|
+
* @param {Object} [originalPadding] - Original padding values from Word import
|
|
24382
|
+
* @private
|
|
24383
|
+
*/
|
|
24713
24384
|
originalPadding: {
|
|
24714
24385
|
default: null,
|
|
24715
24386
|
rendered: false
|
|
24716
24387
|
},
|
|
24388
|
+
/**
|
|
24389
|
+
* @category Attribute
|
|
24390
|
+
* @param {Object} [originalAttributes] - Original attributes from Word import
|
|
24391
|
+
* @private
|
|
24392
|
+
*/
|
|
24717
24393
|
originalAttributes: { rendered: false },
|
|
24394
|
+
/**
|
|
24395
|
+
* @category Attribute
|
|
24396
|
+
* @param {boolean} [wrapTopAndBottom] - Wrap text above and below image
|
|
24397
|
+
* @private
|
|
24398
|
+
*/
|
|
24718
24399
|
wrapTopAndBottom: { rendered: false },
|
|
24400
|
+
/**
|
|
24401
|
+
* @category Attribute
|
|
24402
|
+
* @param {Object} [anchorData] - Anchor positioning data for Word
|
|
24403
|
+
* @private
|
|
24404
|
+
*/
|
|
24719
24405
|
anchorData: {
|
|
24720
24406
|
default: null,
|
|
24721
24407
|
rendered: false
|
|
24722
24408
|
},
|
|
24723
|
-
isAnchor: { rendered: false },
|
|
24724
24409
|
/**
|
|
24725
24410
|
* @category Attribute
|
|
24726
|
-
* @param {
|
|
24727
|
-
* @param {number} [transformData.rotation] - Turn angle in degrees
|
|
24728
|
-
* @param {boolean} [transformData.verticalFlip] - Whether to flip vertically
|
|
24729
|
-
* @param {boolean} [transformData.horizontalFlip] - Whether to flip horizontally
|
|
24730
|
-
* @param {Object} [transformData.sizeExtension] - Size extension for image due to transformation
|
|
24731
|
-
* @param {number} [transformData.sizeExtension.left] - Left size extension for image
|
|
24732
|
-
* @param {number} [transformData.sizeExtension.top] - Top size extension for image
|
|
24733
|
-
* @param {number} [transformData.sizeExtension.right] - Right size extension for image
|
|
24734
|
-
* @param {number} [transformData.sizeExtension.bottom] - Bottom size extension for image
|
|
24735
|
-
*
|
|
24411
|
+
* @param {boolean} [isAnchor] - Whether image is anchored
|
|
24736
24412
|
* @private
|
|
24737
24413
|
*/
|
|
24738
|
-
|
|
24739
|
-
default: {},
|
|
24740
|
-
renderDOM: ({ transformData }) => {
|
|
24741
|
-
let style = "";
|
|
24742
|
-
if (transformData?.rotation) {
|
|
24743
|
-
style += `rotate(${Math.round(transformData.rotation)}deg) `;
|
|
24744
|
-
}
|
|
24745
|
-
if (transformData?.verticalFlip) {
|
|
24746
|
-
style += "scaleY(-1) ";
|
|
24747
|
-
}
|
|
24748
|
-
if (transformData?.horizontalFlip) {
|
|
24749
|
-
style += "scaleX(-1) ";
|
|
24750
|
-
}
|
|
24751
|
-
style = style.trim();
|
|
24752
|
-
if (style.length > 0) {
|
|
24753
|
-
return { style: `transform: ${style};` };
|
|
24754
|
-
}
|
|
24755
|
-
return;
|
|
24756
|
-
}
|
|
24757
|
-
},
|
|
24414
|
+
isAnchor: { rendered: false },
|
|
24758
24415
|
/**
|
|
24759
24416
|
* @category Attribute
|
|
24760
24417
|
* @param {boolean} [simplePos] - Simple positioning flag
|
|
24761
24418
|
* @private
|
|
24762
24419
|
*/
|
|
24763
24420
|
simplePos: { rendered: false },
|
|
24421
|
+
/**
|
|
24422
|
+
* @category Attribute
|
|
24423
|
+
* @param {string} [wrapText] - Text wrapping style
|
|
24424
|
+
* @private
|
|
24425
|
+
*/
|
|
24764
24426
|
wrapText: { rendered: false },
|
|
24765
24427
|
extension: { rendered: false },
|
|
24428
|
+
/**
|
|
24429
|
+
* @category Attribute
|
|
24430
|
+
* @param {Object} [size] - Image dimensions
|
|
24431
|
+
* @param {number} [size.width] - Width in pixels
|
|
24432
|
+
* @param {number} [size.height] - Height in pixels
|
|
24433
|
+
*/
|
|
24766
24434
|
size: {
|
|
24767
24435
|
default: {},
|
|
24768
24436
|
renderDOM: ({ size, extension }) => {
|
|
24769
24437
|
let style = "";
|
|
24770
|
-
|
|
24438
|
+
const { width, height } = size ?? {};
|
|
24771
24439
|
if (width) style += `width: ${width}px;`;
|
|
24772
24440
|
if (height && ["emf", "wmf"].includes(extension))
|
|
24773
24441
|
style += `height: ${height}px; border: 1px solid black; position: absolute;`;
|
|
@@ -24775,58 +24443,51 @@ const Image = Node$1.create({
|
|
|
24775
24443
|
return { style };
|
|
24776
24444
|
}
|
|
24777
24445
|
},
|
|
24446
|
+
/**
|
|
24447
|
+
* @category Attribute
|
|
24448
|
+
* @param {Object} [padding] - Image padding/margins
|
|
24449
|
+
* @param {number} [padding.left] - Left padding in pixels
|
|
24450
|
+
* @param {number} [padding.top] - Top padding in pixels
|
|
24451
|
+
* @param {number} [padding.bottom] - Bottom padding in pixels
|
|
24452
|
+
* @param {number} [padding.right] - Right padding in pixels
|
|
24453
|
+
*/
|
|
24778
24454
|
padding: {
|
|
24779
24455
|
default: {},
|
|
24780
|
-
renderDOM: ({
|
|
24781
|
-
|
|
24782
|
-
const { rotation } = transformData ?? {};
|
|
24783
|
-
const { height, width } = size ?? {};
|
|
24784
|
-
if (rotation && height && width) {
|
|
24785
|
-
const { horizontal, vertical } = getRotationMargins(width, height, rotation);
|
|
24786
|
-
left2 += horizontal;
|
|
24787
|
-
right2 += horizontal;
|
|
24788
|
-
top2 += vertical;
|
|
24789
|
-
bottom2 += vertical;
|
|
24790
|
-
}
|
|
24456
|
+
renderDOM: ({ padding, marginOffset }) => {
|
|
24457
|
+
const { left: left2 = 0, top: top2 = 0, bottom: bottom2 = 0, right: right2 = 0 } = padding ?? {};
|
|
24791
24458
|
let style = "";
|
|
24792
|
-
if (left2 && marginOffset?.left
|
|
24793
|
-
if (top2 && marginOffset?.top
|
|
24459
|
+
if (left2 && !marginOffset?.left) style += `margin-left: ${left2}px;`;
|
|
24460
|
+
if (top2 && !marginOffset?.top) style += `margin-top: ${top2}px;`;
|
|
24794
24461
|
if (bottom2) style += `margin-bottom: ${bottom2}px;`;
|
|
24795
24462
|
if (right2) style += `margin-right: ${right2}px;`;
|
|
24796
24463
|
return { style };
|
|
24797
24464
|
}
|
|
24798
24465
|
},
|
|
24466
|
+
/**
|
|
24467
|
+
* @category Attribute
|
|
24468
|
+
* @param {Object} [marginOffset] - Margin offset for anchored images
|
|
24469
|
+
* @param {number} [marginOffset.left] - Left margin offset
|
|
24470
|
+
* @param {number} [marginOffset.top] - Top margin offset
|
|
24471
|
+
*/
|
|
24799
24472
|
marginOffset: {
|
|
24800
24473
|
default: {},
|
|
24801
|
-
renderDOM: ({ marginOffset, anchorData
|
|
24802
|
-
const hasAnchorData = Boolean(anchorData);
|
|
24803
|
-
const hasMarginOffsets = marginOffset?.left != null || marginOffset?.top != null;
|
|
24804
|
-
if (!hasAnchorData && !hasMarginOffsets) return {};
|
|
24474
|
+
renderDOM: ({ marginOffset, anchorData }) => {
|
|
24805
24475
|
const relativeFromPageV = anchorData?.vRelativeFrom === "page";
|
|
24806
24476
|
const maxMarginV = 500;
|
|
24807
|
-
const
|
|
24808
|
-
const baseTop = marginOffset?.top ?? 0;
|
|
24809
|
-
let rotationLeft = 0;
|
|
24810
|
-
let rotationTop = 0;
|
|
24811
|
-
const { rotation } = transformData ?? {};
|
|
24812
|
-
const { height, width } = size ?? {};
|
|
24813
|
-
if (rotation && height && width) {
|
|
24814
|
-
const { horizontal, vertical } = getRotationMargins(width, height, rotation);
|
|
24815
|
-
rotationLeft = horizontal;
|
|
24816
|
-
rotationTop = vertical;
|
|
24817
|
-
}
|
|
24818
|
-
const left2 = baseLeft + rotationLeft;
|
|
24819
|
-
const top2 = baseTop + rotationTop;
|
|
24477
|
+
const { left: left2 = 0, top: top2 = 0 } = marginOffset ?? {};
|
|
24820
24478
|
let style = "";
|
|
24821
24479
|
if (left2) style += `margin-left: ${left2}px;`;
|
|
24822
24480
|
if (top2) {
|
|
24823
24481
|
if (relativeFromPageV && top2 >= maxMarginV) style += `margin-top: ${maxMarginV}px;`;
|
|
24824
24482
|
else style += `margin-top: ${top2}px;`;
|
|
24825
24483
|
}
|
|
24826
|
-
if (!style) return {};
|
|
24827
24484
|
return { style };
|
|
24828
24485
|
}
|
|
24829
24486
|
},
|
|
24487
|
+
/**
|
|
24488
|
+
* @category Attribute
|
|
24489
|
+
* @param {string} [style] - Custom inline CSS styles
|
|
24490
|
+
*/
|
|
24830
24491
|
style: {
|
|
24831
24492
|
default: null,
|
|
24832
24493
|
rendered: true,
|
|
@@ -24852,10 +24513,18 @@ const Image = Node$1.create({
|
|
|
24852
24513
|
/**
|
|
24853
24514
|
* Insert an image at the current position
|
|
24854
24515
|
* @category Command
|
|
24855
|
-
* @param {
|
|
24516
|
+
* @param {Object} options - Image attributes
|
|
24517
|
+
* @param {string} options.src - Image source URL or data URI
|
|
24518
|
+
* @param {string} [options.alt] - Alternative text
|
|
24519
|
+
* @param {string} [options.title] - Image title
|
|
24520
|
+
* @param {Object} [options.size] - Image dimensions
|
|
24521
|
+
* @returns {Function} Command function
|
|
24856
24522
|
* @example
|
|
24857
|
-
*
|
|
24858
|
-
*
|
|
24523
|
+
* // Insert an image from a URL
|
|
24524
|
+
* setImage({ src: 'https://example.com/image.jpg' })
|
|
24525
|
+
*
|
|
24526
|
+
* // Insert a base64 encoded image
|
|
24527
|
+
* setImage({
|
|
24859
24528
|
* src: 'data:image/png;base64,...',
|
|
24860
24529
|
* alt: 'Company logo',
|
|
24861
24530
|
* size: { width: 200 }
|
|
@@ -24871,31 +24540,272 @@ const Image = Node$1.create({
|
|
|
24871
24540
|
};
|
|
24872
24541
|
},
|
|
24873
24542
|
addPmPlugins() {
|
|
24874
|
-
return [
|
|
24543
|
+
return [ImagePlaceholderPlugin(), ImagePositionPlugin({ editor: this.editor })];
|
|
24544
|
+
}
|
|
24545
|
+
});
|
|
24546
|
+
const ACCEPT_IMAGE_TYPES = [".jpg", ".jpeg", ".png", "image/jpeg", "image/png"];
|
|
24547
|
+
const getFileOpener = () => {
|
|
24548
|
+
let fileInput = document.createElement("input");
|
|
24549
|
+
fileInput.type = "file";
|
|
24550
|
+
let acceptTypes = ACCEPT_IMAGE_TYPES;
|
|
24551
|
+
fileInput.accept = acceptTypes.join(",");
|
|
24552
|
+
const openFile = () => {
|
|
24553
|
+
return new Promise((resolve, reject) => {
|
|
24554
|
+
fileInput.onchange = async () => {
|
|
24555
|
+
const files = fileInput.files;
|
|
24556
|
+
if (!files) return resolve(null);
|
|
24557
|
+
const file = files.item(0);
|
|
24558
|
+
if (!file) return resolve(null);
|
|
24559
|
+
return resolve({ file });
|
|
24560
|
+
};
|
|
24561
|
+
fileInput.oncancel = () => resolve(null);
|
|
24562
|
+
fileInput.onerror = reject;
|
|
24563
|
+
fileInput.click();
|
|
24564
|
+
});
|
|
24565
|
+
};
|
|
24566
|
+
return openFile;
|
|
24567
|
+
};
|
|
24568
|
+
const handleImageUpload = (file) => {
|
|
24569
|
+
return new Promise((resolve, reject) => {
|
|
24570
|
+
let reader = new FileReader();
|
|
24571
|
+
reader.onload = (event) => {
|
|
24572
|
+
resolve(event.target.result);
|
|
24573
|
+
};
|
|
24574
|
+
reader.onerror = reject;
|
|
24575
|
+
setTimeout(() => reader.readAsDataURL(file), 250);
|
|
24576
|
+
});
|
|
24577
|
+
};
|
|
24578
|
+
const processUploadedImage = (fileData, editor) => {
|
|
24579
|
+
return new Promise((resolve, reject) => {
|
|
24580
|
+
const img = new window.Image();
|
|
24581
|
+
img.onload = () => {
|
|
24582
|
+
const canvas = document.createElement("canvas");
|
|
24583
|
+
const { width: logicalWidth, height: logicalHeight } = getAllowedImageDimensions(img.width, img.height, editor);
|
|
24584
|
+
canvas.width = img.width;
|
|
24585
|
+
canvas.height = img.height;
|
|
24586
|
+
const ctx = canvas.getContext("2d");
|
|
24587
|
+
if (ctx) {
|
|
24588
|
+
ctx.imageSmoothingEnabled = true;
|
|
24589
|
+
try {
|
|
24590
|
+
ctx.imageSmoothingQuality = "high";
|
|
24591
|
+
} catch {
|
|
24592
|
+
}
|
|
24593
|
+
}
|
|
24594
|
+
ctx.drawImage(img, 0, 0, img.width, img.height);
|
|
24595
|
+
const dpr = typeof window !== "undefined" && window.devicePixelRatio ? window.devicePixelRatio : 1;
|
|
24596
|
+
const targetPixelWidth = Math.round(logicalWidth * dpr);
|
|
24597
|
+
const targetPixelHeight = Math.round(logicalHeight * dpr);
|
|
24598
|
+
const finalTargetWidth = Math.min(targetPixelWidth, img.width);
|
|
24599
|
+
const finalTargetHeight = Math.min(targetPixelHeight, img.height);
|
|
24600
|
+
const resizeNeeded = finalTargetWidth !== img.width || finalTargetHeight !== img.height;
|
|
24601
|
+
if (resizeNeeded) {
|
|
24602
|
+
multiStepResize(canvas, finalTargetWidth, finalTargetHeight);
|
|
24603
|
+
}
|
|
24604
|
+
if (typeof fileData === "string") {
|
|
24605
|
+
const resizedBase64 = canvas.toDataURL();
|
|
24606
|
+
resolve(resizedBase64);
|
|
24607
|
+
} else {
|
|
24608
|
+
canvas.toBlob((blob) => {
|
|
24609
|
+
const updatedFile = new File([blob], fileData.name, {
|
|
24610
|
+
type: fileData.type,
|
|
24611
|
+
lastModified: Date.now()
|
|
24612
|
+
});
|
|
24613
|
+
resolve({ file: updatedFile, width: logicalWidth, height: logicalHeight });
|
|
24614
|
+
});
|
|
24615
|
+
}
|
|
24616
|
+
};
|
|
24617
|
+
img.onerror = (error) => reject(error);
|
|
24618
|
+
img.src = typeof fileData === "string" ? fileData : URL.createObjectURL(fileData);
|
|
24619
|
+
});
|
|
24620
|
+
};
|
|
24621
|
+
const getAllowedImageDimensions = (width, height, editor) => {
|
|
24622
|
+
const { width: maxWidth, height: maxHeight } = editor.getMaxContentSize();
|
|
24623
|
+
if (!maxWidth || !maxHeight) return { width, height };
|
|
24624
|
+
let adjustedWidth = width;
|
|
24625
|
+
let adjustedHeight = height;
|
|
24626
|
+
const aspectRatio = width / height;
|
|
24627
|
+
if (height > maxHeight) {
|
|
24628
|
+
adjustedHeight = maxHeight;
|
|
24629
|
+
adjustedWidth = Math.round(maxHeight * aspectRatio);
|
|
24630
|
+
}
|
|
24631
|
+
if (adjustedWidth > maxWidth) {
|
|
24632
|
+
adjustedWidth = maxWidth;
|
|
24633
|
+
adjustedHeight = Math.round(maxWidth / aspectRatio);
|
|
24634
|
+
}
|
|
24635
|
+
return { width: adjustedWidth, height: adjustedHeight };
|
|
24636
|
+
};
|
|
24637
|
+
function resample_high_quality(canvas, width, height, resize_canvas) {
|
|
24638
|
+
var width_source = canvas.width;
|
|
24639
|
+
var height_source = canvas.height;
|
|
24640
|
+
width = Math.round(width);
|
|
24641
|
+
height = Math.round(height);
|
|
24642
|
+
var ratio_w = width_source / width;
|
|
24643
|
+
var ratio_h = height_source / height;
|
|
24644
|
+
var ratio_w_half = Math.ceil(ratio_w / 2);
|
|
24645
|
+
var ratio_h_half = Math.ceil(ratio_h / 2);
|
|
24646
|
+
var ctx = canvas.getContext("2d");
|
|
24647
|
+
var img = ctx.getImageData(0, 0, width_source, height_source);
|
|
24648
|
+
var img2 = ctx.createImageData(width, height);
|
|
24649
|
+
var data = img.data;
|
|
24650
|
+
var data2 = img2.data;
|
|
24651
|
+
for (var j = 0; j < height; j++) {
|
|
24652
|
+
for (var i = 0; i < width; i++) {
|
|
24653
|
+
var x2 = (i + j * width) * 4;
|
|
24654
|
+
var weight = 0;
|
|
24655
|
+
var weights = 0;
|
|
24656
|
+
var weights_alpha = 0;
|
|
24657
|
+
var gx_r = 0;
|
|
24658
|
+
var gx_g = 0;
|
|
24659
|
+
var gx_b = 0;
|
|
24660
|
+
var gx_a = 0;
|
|
24661
|
+
var center_y = (j + 0.5) * ratio_h;
|
|
24662
|
+
var yy_start = Math.floor(j * ratio_h);
|
|
24663
|
+
var yy_stop = Math.ceil((j + 1) * ratio_h);
|
|
24664
|
+
for (var yy = yy_start; yy < yy_stop; yy++) {
|
|
24665
|
+
var dy = Math.abs(center_y - (yy + 0.5)) / ratio_h_half;
|
|
24666
|
+
var center_x = (i + 0.5) * ratio_w;
|
|
24667
|
+
var w0 = dy * dy;
|
|
24668
|
+
var xx_start = Math.floor(i * ratio_w);
|
|
24669
|
+
var xx_stop = Math.ceil((i + 1) * ratio_w);
|
|
24670
|
+
for (var xx = xx_start; xx < xx_stop; xx++) {
|
|
24671
|
+
var dx = Math.abs(center_x - (xx + 0.5)) / ratio_w_half;
|
|
24672
|
+
var w = Math.sqrt(w0 + dx * dx);
|
|
24673
|
+
if (w >= 1) {
|
|
24674
|
+
continue;
|
|
24675
|
+
}
|
|
24676
|
+
weight = 2 * w * w * w - 3 * w * w + 1;
|
|
24677
|
+
var pos_x = 4 * (xx + yy * width_source);
|
|
24678
|
+
gx_a += weight * data[pos_x + 3];
|
|
24679
|
+
weights_alpha += weight;
|
|
24680
|
+
if (data[pos_x + 3] < 255) weight = weight * data[pos_x + 3] / 250;
|
|
24681
|
+
gx_r += weight * data[pos_x];
|
|
24682
|
+
gx_g += weight * data[pos_x + 1];
|
|
24683
|
+
gx_b += weight * data[pos_x + 2];
|
|
24684
|
+
weights += weight;
|
|
24685
|
+
}
|
|
24686
|
+
}
|
|
24687
|
+
data2[x2] = gx_r / weights;
|
|
24688
|
+
data2[x2 + 1] = gx_g / weights;
|
|
24689
|
+
data2[x2 + 2] = gx_b / weights;
|
|
24690
|
+
data2[x2 + 3] = gx_a / weights_alpha;
|
|
24691
|
+
}
|
|
24692
|
+
}
|
|
24693
|
+
{
|
|
24694
|
+
canvas.width = width;
|
|
24695
|
+
canvas.height = height;
|
|
24696
|
+
}
|
|
24697
|
+
ctx.putImageData(img2, 0, 0);
|
|
24698
|
+
}
|
|
24699
|
+
function multiStepResize(canvas, targetWidth, targetHeight) {
|
|
24700
|
+
const originalWidth = canvas.width;
|
|
24701
|
+
const originalHeight = canvas.height;
|
|
24702
|
+
const scaleX = targetWidth / originalWidth;
|
|
24703
|
+
const scaleY = targetHeight / originalHeight;
|
|
24704
|
+
const scaleFactor = Math.min(scaleX, scaleY);
|
|
24705
|
+
if (scaleFactor < 0.5) {
|
|
24706
|
+
let currentWidth = originalWidth;
|
|
24707
|
+
let currentHeight = originalHeight;
|
|
24708
|
+
while (currentWidth > targetWidth * 2 || currentHeight > targetHeight * 2) {
|
|
24709
|
+
const nextWidth = Math.round(currentWidth / 2);
|
|
24710
|
+
const nextHeight = Math.round(currentHeight / 2);
|
|
24711
|
+
resample_high_quality(canvas, nextWidth, nextHeight);
|
|
24712
|
+
currentWidth = nextWidth;
|
|
24713
|
+
currentHeight = nextHeight;
|
|
24714
|
+
}
|
|
24715
|
+
if (currentWidth !== targetWidth || currentHeight !== targetHeight) {
|
|
24716
|
+
resample_high_quality(canvas, targetWidth, targetHeight);
|
|
24717
|
+
}
|
|
24718
|
+
} else {
|
|
24719
|
+
resample_high_quality(canvas, targetWidth, targetHeight);
|
|
24720
|
+
}
|
|
24721
|
+
}
|
|
24722
|
+
const startImageUpload = async ({ editor, view, file }) => {
|
|
24723
|
+
const imageUploadHandler = typeof editor.options.handleImageUpload === "function" ? editor.options.handleImageUpload : handleImageUpload;
|
|
24724
|
+
let fileSizeMb = Number((file.size / (1024 * 1024)).toFixed(4));
|
|
24725
|
+
if (fileSizeMb > 5) {
|
|
24726
|
+
window.alert("Image size must be less than 5MB");
|
|
24727
|
+
return;
|
|
24875
24728
|
}
|
|
24876
|
-
|
|
24877
|
-
|
|
24878
|
-
|
|
24879
|
-
|
|
24880
|
-
|
|
24881
|
-
|
|
24882
|
-
|
|
24883
|
-
|
|
24884
|
-
|
|
24885
|
-
|
|
24886
|
-
|
|
24887
|
-
|
|
24888
|
-
|
|
24889
|
-
|
|
24890
|
-
|
|
24891
|
-
|
|
24892
|
-
|
|
24893
|
-
|
|
24894
|
-
|
|
24895
|
-
});
|
|
24896
|
-
};
|
|
24897
|
-
return openFile;
|
|
24729
|
+
let width;
|
|
24730
|
+
let height;
|
|
24731
|
+
try {
|
|
24732
|
+
const processedImageResult = await processUploadedImage(file, editor);
|
|
24733
|
+
width = processedImageResult.width;
|
|
24734
|
+
height = processedImageResult.height;
|
|
24735
|
+
file = processedImageResult.file;
|
|
24736
|
+
} catch (err) {
|
|
24737
|
+
console.warn("Error processing image:", err);
|
|
24738
|
+
editor.emit("exception", { error: err, editor });
|
|
24739
|
+
return;
|
|
24740
|
+
}
|
|
24741
|
+
await uploadImage({
|
|
24742
|
+
editor,
|
|
24743
|
+
view,
|
|
24744
|
+
file,
|
|
24745
|
+
size: { width, height },
|
|
24746
|
+
uploadHandler: imageUploadHandler
|
|
24747
|
+
});
|
|
24898
24748
|
};
|
|
24749
|
+
async function uploadImage({ editor, view, file, size, uploadHandler }) {
|
|
24750
|
+
let id = {};
|
|
24751
|
+
let { tr, schema } = view.state;
|
|
24752
|
+
let { selection } = tr;
|
|
24753
|
+
if (editor.options.isHeaderOrFooter) {
|
|
24754
|
+
selection = editor.options.lastSelection;
|
|
24755
|
+
}
|
|
24756
|
+
if (!selection.empty && !editor.options.isHeaderOrFooter) {
|
|
24757
|
+
tr.deleteSelection();
|
|
24758
|
+
}
|
|
24759
|
+
let imageMeta = {
|
|
24760
|
+
type: "add",
|
|
24761
|
+
pos: selection.from,
|
|
24762
|
+
id
|
|
24763
|
+
};
|
|
24764
|
+
tr.setMeta(ImagePlaceholderPluginKey, imageMeta);
|
|
24765
|
+
view.dispatch(tr);
|
|
24766
|
+
try {
|
|
24767
|
+
let url = await uploadHandler(file);
|
|
24768
|
+
let fileName = file.name.replace(" ", "_");
|
|
24769
|
+
let placeholderPos = findPlaceholder(view.state, id);
|
|
24770
|
+
if (placeholderPos == null) {
|
|
24771
|
+
return;
|
|
24772
|
+
}
|
|
24773
|
+
let removeMeta = { type: "remove", id };
|
|
24774
|
+
let mediaPath = `word/media/${fileName}`;
|
|
24775
|
+
let rId = null;
|
|
24776
|
+
if (editor.options.mode === "docx") {
|
|
24777
|
+
const [, path] = mediaPath.split("word/");
|
|
24778
|
+
const imageid = addImageRelationship({ editor, path });
|
|
24779
|
+
if (imageid) rId = imageid;
|
|
24780
|
+
}
|
|
24781
|
+
let imageNode = schema.nodes.image.create({
|
|
24782
|
+
src: mediaPath,
|
|
24783
|
+
size,
|
|
24784
|
+
rId
|
|
24785
|
+
});
|
|
24786
|
+
editor.storage.image.media = Object.assign(editor.storage.image.media, { [mediaPath]: url });
|
|
24787
|
+
if (editor.options.ydoc) {
|
|
24788
|
+
editor.commands.addImageToCollaboration({ mediaPath, fileData: url });
|
|
24789
|
+
}
|
|
24790
|
+
view.dispatch(
|
|
24791
|
+
view.state.tr.replaceWith(placeholderPos, placeholderPos, imageNode).setMeta(ImagePlaceholderPluginKey, removeMeta)
|
|
24792
|
+
);
|
|
24793
|
+
} catch (error) {
|
|
24794
|
+
let removeMeta = { type: "remove", id };
|
|
24795
|
+
view.dispatch(tr.setMeta(ImagePlaceholderPluginKey, removeMeta));
|
|
24796
|
+
editor.emit("exception", { error, editor });
|
|
24797
|
+
}
|
|
24798
|
+
}
|
|
24799
|
+
function addImageRelationship({ editor, path }) {
|
|
24800
|
+
const target = path;
|
|
24801
|
+
const type = "image";
|
|
24802
|
+
try {
|
|
24803
|
+
const relationshipId = insertNewRelationship(target, type, editor);
|
|
24804
|
+
return relationshipId;
|
|
24805
|
+
} catch {
|
|
24806
|
+
return null;
|
|
24807
|
+
}
|
|
24808
|
+
}
|
|
24899
24809
|
const BookmarkStart = Node$1.create({
|
|
24900
24810
|
name: "bookmarkStart",
|
|
24901
24811
|
group: "inline",
|
|
@@ -25072,14 +24982,6 @@ const PageNumber = Node$1.create({
|
|
|
25072
24982
|
},
|
|
25073
24983
|
addCommands() {
|
|
25074
24984
|
return {
|
|
25075
|
-
/**
|
|
25076
|
-
* Insert an automatic page number
|
|
25077
|
-
* @category Command
|
|
25078
|
-
* @returns {Function} Command function
|
|
25079
|
-
* @example
|
|
25080
|
-
* editor.commands.addAutoPageNumber()
|
|
25081
|
-
* @note Only works in header/footer contexts
|
|
25082
|
-
*/
|
|
25083
24985
|
addAutoPageNumber: () => ({ tr, dispatch, state, editor }) => {
|
|
25084
24986
|
const { options } = editor;
|
|
25085
24987
|
if (!options.isHeaderOrFooter) return false;
|
|
@@ -25142,14 +25044,6 @@ const TotalPageCount = Node$1.create({
|
|
|
25142
25044
|
},
|
|
25143
25045
|
addCommands() {
|
|
25144
25046
|
return {
|
|
25145
|
-
/**
|
|
25146
|
-
* Insert total page count
|
|
25147
|
-
* @category Command
|
|
25148
|
-
* @returns {Function} Command function
|
|
25149
|
-
* @example
|
|
25150
|
-
* editor.commands.addTotalPageCount()
|
|
25151
|
-
* @note Only works in header/footer contexts
|
|
25152
|
-
*/
|
|
25153
25047
|
addTotalPageCount: () => ({ tr, dispatch, state, editor }) => {
|
|
25154
25048
|
const { options } = editor;
|
|
25155
25049
|
if (!options.isHeaderOrFooter) return false;
|
|
@@ -25226,8 +25120,8 @@ renderDom_fn = function(node, htmlAttributes) {
|
|
|
25226
25120
|
__privateMethod(this, _AutoPageNumberNodeView_instances, scheduleUpdateNodeStyle_fn).call(this, currentPos, marks);
|
|
25227
25121
|
Object.assign(nodeContent.style, styles);
|
|
25228
25122
|
nodeContent.appendChild(content);
|
|
25229
|
-
Object.entries(htmlAttributes).forEach(([
|
|
25230
|
-
if (value) nodeContent.setAttribute(
|
|
25123
|
+
Object.entries(htmlAttributes).forEach(([key, value]) => {
|
|
25124
|
+
if (value) nodeContent.setAttribute(key, value);
|
|
25231
25125
|
});
|
|
25232
25126
|
return nodeContent;
|
|
25233
25127
|
};
|
|
@@ -25293,8 +25187,8 @@ const processMarks = (marks) => {
|
|
|
25293
25187
|
break;
|
|
25294
25188
|
default:
|
|
25295
25189
|
if (attrs?.style) {
|
|
25296
|
-
Object.entries(attrs.style).forEach(([
|
|
25297
|
-
styles[
|
|
25190
|
+
Object.entries(attrs.style).forEach(([key, value]) => {
|
|
25191
|
+
styles[key] = value;
|
|
25298
25192
|
});
|
|
25299
25193
|
}
|
|
25300
25194
|
break;
|
|
@@ -25416,6 +25310,11 @@ const ContentBlock = Node$1.create({
|
|
|
25416
25310
|
inline: true,
|
|
25417
25311
|
addOptions() {
|
|
25418
25312
|
return {
|
|
25313
|
+
/**
|
|
25314
|
+
* @typedef {Object} ContentBlockOptions
|
|
25315
|
+
* @category Options
|
|
25316
|
+
* @property {Object} [htmlAttributes] - HTML attributes for the block element
|
|
25317
|
+
*/
|
|
25419
25318
|
htmlAttributes: {
|
|
25420
25319
|
contenteditable: false
|
|
25421
25320
|
}
|
|
@@ -25423,6 +25322,10 @@ const ContentBlock = Node$1.create({
|
|
|
25423
25322
|
},
|
|
25424
25323
|
addAttributes() {
|
|
25425
25324
|
return {
|
|
25325
|
+
/**
|
|
25326
|
+
* @category Attribute
|
|
25327
|
+
* @param {boolean} [horizontalRule=false] - Whether this block is a horizontal rule
|
|
25328
|
+
*/
|
|
25426
25329
|
horizontalRule: {
|
|
25427
25330
|
default: false,
|
|
25428
25331
|
renderDOM: ({ horizontalRule }) => {
|
|
@@ -25430,6 +25333,10 @@ const ContentBlock = Node$1.create({
|
|
|
25430
25333
|
return { "data-horizontal-rule": "true" };
|
|
25431
25334
|
}
|
|
25432
25335
|
},
|
|
25336
|
+
/**
|
|
25337
|
+
* @category Attribute
|
|
25338
|
+
* @param {ContentBlockSize} [size] - Size and position of the content block
|
|
25339
|
+
*/
|
|
25433
25340
|
size: {
|
|
25434
25341
|
default: null,
|
|
25435
25342
|
renderDOM: ({ size }) => {
|
|
@@ -25443,6 +25350,10 @@ const ContentBlock = Node$1.create({
|
|
|
25443
25350
|
return { style };
|
|
25444
25351
|
}
|
|
25445
25352
|
},
|
|
25353
|
+
/**
|
|
25354
|
+
* @category Attribute
|
|
25355
|
+
* @param {string} [background] - Background color for the block
|
|
25356
|
+
*/
|
|
25446
25357
|
background: {
|
|
25447
25358
|
default: null,
|
|
25448
25359
|
renderDOM: (attrs) => {
|
|
@@ -25452,9 +25363,19 @@ const ContentBlock = Node$1.create({
|
|
|
25452
25363
|
};
|
|
25453
25364
|
}
|
|
25454
25365
|
},
|
|
25366
|
+
/**
|
|
25367
|
+
* @private
|
|
25368
|
+
* @category Attribute
|
|
25369
|
+
* @param {Object} [drawingContent] - Internal drawing data
|
|
25370
|
+
*/
|
|
25455
25371
|
drawingContent: {
|
|
25456
25372
|
rendered: false
|
|
25457
25373
|
},
|
|
25374
|
+
/**
|
|
25375
|
+
* @private
|
|
25376
|
+
* @category Attribute
|
|
25377
|
+
* @param {Object} [attributes] - Additional internal attributes
|
|
25378
|
+
*/
|
|
25458
25379
|
attributes: {
|
|
25459
25380
|
rendered: false
|
|
25460
25381
|
}
|
|
@@ -25475,8 +25396,9 @@ const ContentBlock = Node$1.create({
|
|
|
25475
25396
|
/**
|
|
25476
25397
|
* Insert a horizontal rule
|
|
25477
25398
|
* @category Command
|
|
25399
|
+
* @returns {Function} Command function
|
|
25478
25400
|
* @example
|
|
25479
|
-
*
|
|
25401
|
+
* insertHorizontalRule()
|
|
25480
25402
|
* @note Creates a visual separator between content sections
|
|
25481
25403
|
*/
|
|
25482
25404
|
insertHorizontalRule: () => ({ commands: commands2 }) => {
|
|
@@ -25493,13 +25415,13 @@ const ContentBlock = Node$1.create({
|
|
|
25493
25415
|
* Insert a content block
|
|
25494
25416
|
* @category Command
|
|
25495
25417
|
* @param {ContentBlockConfig} config - Block configuration
|
|
25418
|
+
* @returns {Function} Command function
|
|
25496
25419
|
* @example
|
|
25497
25420
|
* // Insert a spacer block
|
|
25498
|
-
*
|
|
25421
|
+
* insertContentBlock({ size: { height: 20 } })
|
|
25499
25422
|
*
|
|
25500
|
-
* @example
|
|
25501
25423
|
* // Insert a colored divider
|
|
25502
|
-
*
|
|
25424
|
+
* insertContentBlock({
|
|
25503
25425
|
* size: { width: '50%', height: 3 },
|
|
25504
25426
|
* background: '#3b82f6'
|
|
25505
25427
|
* })
|
|
@@ -25514,353 +25436,69 @@ const ContentBlock = Node$1.create({
|
|
|
25514
25436
|
};
|
|
25515
25437
|
}
|
|
25516
25438
|
});
|
|
25517
|
-
class StructuredContentViewBase {
|
|
25518
|
-
constructor(props) {
|
|
25519
|
-
__publicField(this, "node");
|
|
25520
|
-
__publicField(this, "view");
|
|
25521
|
-
__publicField(this, "getPos");
|
|
25522
|
-
__publicField(this, "decorations");
|
|
25523
|
-
__publicField(this, "innerDecorations");
|
|
25524
|
-
__publicField(this, "editor");
|
|
25525
|
-
__publicField(this, "extension");
|
|
25526
|
-
__publicField(this, "htmlAttributes");
|
|
25527
|
-
__publicField(this, "root");
|
|
25528
|
-
__publicField(this, "isDragging", false);
|
|
25529
|
-
this.node = props.node;
|
|
25530
|
-
this.view = props.editor.view;
|
|
25531
|
-
this.getPos = props.getPos;
|
|
25532
|
-
this.decorations = props.decorations;
|
|
25533
|
-
this.innerDecorations = props.innerDecorations;
|
|
25534
|
-
this.editor = props.editor;
|
|
25535
|
-
this.extension = props.extension;
|
|
25536
|
-
this.htmlAttributes = props.htmlAttributes;
|
|
25537
|
-
this.mount(props);
|
|
25538
|
-
}
|
|
25539
|
-
mount() {
|
|
25540
|
-
return;
|
|
25541
|
-
}
|
|
25542
|
-
get dom() {
|
|
25543
|
-
return this.root;
|
|
25544
|
-
}
|
|
25545
|
-
get contentDOM() {
|
|
25546
|
-
return null;
|
|
25547
|
-
}
|
|
25548
|
-
update(node, decorations, innerDecorations) {
|
|
25549
|
-
if (node.type !== this.node.type) {
|
|
25550
|
-
return false;
|
|
25551
|
-
}
|
|
25552
|
-
this.node = node;
|
|
25553
|
-
this.decorations = decorations;
|
|
25554
|
-
this.innerDecorations = innerDecorations;
|
|
25555
|
-
this.updateHTMLAttributes();
|
|
25556
|
-
return true;
|
|
25557
|
-
}
|
|
25558
|
-
stopEvent(event) {
|
|
25559
|
-
if (!this.dom) return false;
|
|
25560
|
-
const target = event.target;
|
|
25561
|
-
const isInElement = this.dom.contains(target) && !this.contentDOM?.contains(target);
|
|
25562
|
-
if (!isInElement) return false;
|
|
25563
|
-
const isDragEvent = event.type.startsWith("drag");
|
|
25564
|
-
const isDropEvent = event.type === "drop";
|
|
25565
|
-
const isInput = ["INPUT", "BUTTON", "SELECT", "TEXTAREA"].includes(target.tagName) || target.isContentEditable;
|
|
25566
|
-
if (isInput && !isDropEvent && !isDragEvent) return true;
|
|
25567
|
-
const { isEditable } = this.editor;
|
|
25568
|
-
const { isDragging } = this;
|
|
25569
|
-
const isDraggable = !!this.node.type.spec.draggable;
|
|
25570
|
-
const isSelectable = NodeSelection.isSelectable(this.node);
|
|
25571
|
-
const isCopyEvent = event.type === "copy";
|
|
25572
|
-
const isPasteEvent = event.type === "paste";
|
|
25573
|
-
const isCutEvent = event.type === "cut";
|
|
25574
|
-
const isClickEvent = event.type === "mousedown";
|
|
25575
|
-
if (!isDraggable && isSelectable && isDragEvent && event.target === this.dom) {
|
|
25576
|
-
event.preventDefault();
|
|
25577
|
-
}
|
|
25578
|
-
if (isDraggable && isDragEvent && !isDragging && event.target === this.dom) {
|
|
25579
|
-
event.preventDefault();
|
|
25580
|
-
return false;
|
|
25581
|
-
}
|
|
25582
|
-
if (isDraggable && isEditable && !isDragging && isClickEvent) {
|
|
25583
|
-
const dragHandle = target.closest("[data-drag-handle]");
|
|
25584
|
-
const isValidDragHandle = dragHandle && (this.dom === dragHandle || this.dom.contains(dragHandle));
|
|
25585
|
-
if (isValidDragHandle) {
|
|
25586
|
-
this.isDragging = true;
|
|
25587
|
-
document.addEventListener(
|
|
25588
|
-
"dragend",
|
|
25589
|
-
() => {
|
|
25590
|
-
this.isDragging = false;
|
|
25591
|
-
},
|
|
25592
|
-
{ once: true }
|
|
25593
|
-
);
|
|
25594
|
-
document.addEventListener(
|
|
25595
|
-
"drop",
|
|
25596
|
-
() => {
|
|
25597
|
-
this.isDragging = false;
|
|
25598
|
-
},
|
|
25599
|
-
{ once: true }
|
|
25600
|
-
);
|
|
25601
|
-
document.addEventListener(
|
|
25602
|
-
"mouseup",
|
|
25603
|
-
() => {
|
|
25604
|
-
this.isDragging = false;
|
|
25605
|
-
},
|
|
25606
|
-
{ once: true }
|
|
25607
|
-
);
|
|
25608
|
-
}
|
|
25609
|
-
}
|
|
25610
|
-
if (isDragging || isDropEvent || isCopyEvent || isPasteEvent || isCutEvent || isClickEvent && isSelectable) {
|
|
25611
|
-
return false;
|
|
25612
|
-
}
|
|
25613
|
-
return true;
|
|
25614
|
-
}
|
|
25615
|
-
ignoreMutation(mutation) {
|
|
25616
|
-
if (!this.dom || !this.contentDOM) return true;
|
|
25617
|
-
if (this.node.isLeaf || this.node.isAtom) return true;
|
|
25618
|
-
if (mutation.type === "selection") return false;
|
|
25619
|
-
if (this.contentDOM === mutation.target && mutation.type === "attributes") return true;
|
|
25620
|
-
if (this.contentDOM.contains(mutation.target)) return false;
|
|
25621
|
-
return true;
|
|
25622
|
-
}
|
|
25623
|
-
destroy() {
|
|
25624
|
-
this.dom.remove();
|
|
25625
|
-
this.contentDOM?.remove();
|
|
25626
|
-
}
|
|
25627
|
-
updateAttributes(attrs) {
|
|
25628
|
-
const pos = this.getPos();
|
|
25629
|
-
if (typeof pos !== "number") {
|
|
25630
|
-
return;
|
|
25631
|
-
}
|
|
25632
|
-
return this.view.dispatch(
|
|
25633
|
-
this.view.state.tr.setNodeMarkup(pos, void 0, {
|
|
25634
|
-
...this.node.attrs,
|
|
25635
|
-
...attrs
|
|
25636
|
-
})
|
|
25637
|
-
);
|
|
25638
|
-
}
|
|
25639
|
-
updateHTMLAttributes() {
|
|
25640
|
-
const { extensionService } = this.editor;
|
|
25641
|
-
const { attributes } = extensionService;
|
|
25642
|
-
const extensionAttrs = attributes.filter((i) => i.type === this.node.type.name);
|
|
25643
|
-
this.htmlAttributes = Attribute.getAttributesToRender(this.node, extensionAttrs);
|
|
25644
|
-
}
|
|
25645
|
-
createDragHandle() {
|
|
25646
|
-
const dragHandle = document.createElement("span");
|
|
25647
|
-
dragHandle.classList.add("sd-structured-content-draggable");
|
|
25648
|
-
dragHandle.draggable = true;
|
|
25649
|
-
dragHandle.contentEditable = "false";
|
|
25650
|
-
dragHandle.dataset.dragHandle = "";
|
|
25651
|
-
const textElement = document.createElement("span");
|
|
25652
|
-
textElement.textContent = "Structured content";
|
|
25653
|
-
dragHandle.append(textElement);
|
|
25654
|
-
return dragHandle;
|
|
25655
|
-
}
|
|
25656
|
-
onDragStart(event) {
|
|
25657
|
-
const { view } = this.editor;
|
|
25658
|
-
const target = event.target;
|
|
25659
|
-
const dragHandle = target.nodeType === 3 ? target.parentElement?.closest("[data-drag-handle]") : target.closest("[data-drag-handle]");
|
|
25660
|
-
if (!this.dom || this.contentDOM?.contains(target) || !dragHandle) {
|
|
25661
|
-
return;
|
|
25662
|
-
}
|
|
25663
|
-
let x = 0;
|
|
25664
|
-
let y = 0;
|
|
25665
|
-
if (this.dom !== dragHandle) {
|
|
25666
|
-
const domBox = this.dom.getBoundingClientRect();
|
|
25667
|
-
const handleBox = dragHandle.getBoundingClientRect();
|
|
25668
|
-
const offsetX = event.offsetX ?? event.nativeEvent?.offsetX;
|
|
25669
|
-
const offsetY = event.offsetY ?? event.nativeEvent?.offsetY;
|
|
25670
|
-
x = handleBox.x - domBox.x + offsetX;
|
|
25671
|
-
y = handleBox.y - domBox.y + offsetY;
|
|
25672
|
-
}
|
|
25673
|
-
event.dataTransfer?.setDragImage(this.dom, x, y);
|
|
25674
|
-
const pos = this.getPos();
|
|
25675
|
-
if (typeof pos !== "number") {
|
|
25676
|
-
return;
|
|
25677
|
-
}
|
|
25678
|
-
const selection = NodeSelection.create(view.state.doc, pos);
|
|
25679
|
-
const transaction = view.state.tr.setSelection(selection);
|
|
25680
|
-
view.dispatch(transaction);
|
|
25681
|
-
}
|
|
25682
|
-
}
|
|
25683
|
-
class StructuredContentInlineView extends StructuredContentViewBase {
|
|
25684
|
-
constructor(props) {
|
|
25685
|
-
super(props);
|
|
25686
|
-
}
|
|
25687
|
-
mount() {
|
|
25688
|
-
this.buildView();
|
|
25689
|
-
}
|
|
25690
|
-
get contentDOM() {
|
|
25691
|
-
const contentElement = this.dom?.querySelector(`.${structuredContentInnerClass$1}`);
|
|
25692
|
-
return contentElement || null;
|
|
25693
|
-
}
|
|
25694
|
-
createElement() {
|
|
25695
|
-
const element = document.createElement("span");
|
|
25696
|
-
element.classList.add(structuredContentClass$1);
|
|
25697
|
-
element.setAttribute("data-structured-content", "");
|
|
25698
|
-
const contentElement = document.createElement("span");
|
|
25699
|
-
contentElement.classList.add(structuredContentInnerClass$1);
|
|
25700
|
-
element.append(contentElement);
|
|
25701
|
-
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
25702
|
-
updateDOMAttributes(element, { ...domAttrs });
|
|
25703
|
-
return { element, contentElement };
|
|
25704
|
-
}
|
|
25705
|
-
buildView() {
|
|
25706
|
-
const { element } = this.createElement();
|
|
25707
|
-
const dragHandle = this.createDragHandle();
|
|
25708
|
-
element.prepend(dragHandle);
|
|
25709
|
-
element.addEventListener("dragstart", (e) => this.onDragStart(e));
|
|
25710
|
-
this.root = element;
|
|
25711
|
-
}
|
|
25712
|
-
updateView() {
|
|
25713
|
-
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
25714
|
-
updateDOMAttributes(this.dom, { ...domAttrs });
|
|
25715
|
-
}
|
|
25716
|
-
update(node, decorations, innerDecorations) {
|
|
25717
|
-
const result = super.update(node, decorations, innerDecorations);
|
|
25718
|
-
if (!result) return false;
|
|
25719
|
-
this.updateView();
|
|
25720
|
-
return true;
|
|
25721
|
-
}
|
|
25722
|
-
}
|
|
25723
|
-
const structuredContentClass$1 = "sd-structured-content";
|
|
25724
|
-
const structuredContentInnerClass$1 = "sd-structured-content__content";
|
|
25725
25439
|
const StructuredContent = Node$1.create({
|
|
25726
25440
|
name: "structuredContent",
|
|
25727
|
-
group: "inline
|
|
25441
|
+
group: "inline",
|
|
25728
25442
|
inline: true,
|
|
25729
25443
|
content: "inline*",
|
|
25730
|
-
isolating: true,
|
|
25731
|
-
atom: false,
|
|
25732
|
-
// false - has editable content.
|
|
25733
|
-
draggable: true,
|
|
25734
25444
|
addOptions() {
|
|
25735
25445
|
return {
|
|
25446
|
+
structuredContentClass: "sd-structured-content-tag",
|
|
25736
25447
|
htmlAttributes: {
|
|
25737
|
-
class: structuredContentClass$1,
|
|
25738
25448
|
"aria-label": "Structured content node"
|
|
25739
25449
|
}
|
|
25740
25450
|
};
|
|
25741
25451
|
},
|
|
25742
25452
|
addAttributes() {
|
|
25743
25453
|
return {
|
|
25744
|
-
id: {
|
|
25745
|
-
default: null,
|
|
25746
|
-
parseDOM: (elem) => elem.getAttribute("data-id"),
|
|
25747
|
-
renderDOM: (attrs) => {
|
|
25748
|
-
if (!attrs.id) return {};
|
|
25749
|
-
return { "data-id": attrs.id };
|
|
25750
|
-
}
|
|
25751
|
-
},
|
|
25752
25454
|
sdtPr: {
|
|
25753
25455
|
rendered: false
|
|
25754
25456
|
}
|
|
25755
25457
|
};
|
|
25756
25458
|
},
|
|
25757
25459
|
parseDOM() {
|
|
25758
|
-
return [{ tag:
|
|
25460
|
+
return [{ tag: `span.${this.options.structuredContentClass}` }];
|
|
25759
25461
|
},
|
|
25760
25462
|
renderDOM({ htmlAttributes }) {
|
|
25761
25463
|
return [
|
|
25762
25464
|
"span",
|
|
25763
25465
|
Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes, {
|
|
25764
|
-
|
|
25466
|
+
class: this.options.structuredContentClass
|
|
25765
25467
|
}),
|
|
25766
25468
|
0
|
|
25767
25469
|
];
|
|
25768
|
-
},
|
|
25769
|
-
addNodeView() {
|
|
25770
|
-
return (props) => {
|
|
25771
|
-
return new StructuredContentInlineView({ ...props });
|
|
25772
|
-
};
|
|
25773
25470
|
}
|
|
25774
25471
|
});
|
|
25775
|
-
class StructuredContentBlockView extends StructuredContentViewBase {
|
|
25776
|
-
constructor(props) {
|
|
25777
|
-
super(props);
|
|
25778
|
-
}
|
|
25779
|
-
mount() {
|
|
25780
|
-
this.buildView();
|
|
25781
|
-
}
|
|
25782
|
-
get contentDOM() {
|
|
25783
|
-
const contentElement = this.dom?.querySelector(`.${structuredContentInnerClass}`);
|
|
25784
|
-
return contentElement || null;
|
|
25785
|
-
}
|
|
25786
|
-
createElement() {
|
|
25787
|
-
const element = document.createElement("div");
|
|
25788
|
-
element.classList.add(structuredContentClass);
|
|
25789
|
-
element.setAttribute("data-structured-content-block", "");
|
|
25790
|
-
const contentElement = document.createElement("div");
|
|
25791
|
-
contentElement.classList.add(structuredContentInnerClass);
|
|
25792
|
-
element.append(contentElement);
|
|
25793
|
-
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
25794
|
-
updateDOMAttributes(element, { ...domAttrs });
|
|
25795
|
-
return { element, contentElement };
|
|
25796
|
-
}
|
|
25797
|
-
buildView() {
|
|
25798
|
-
const { element } = this.createElement();
|
|
25799
|
-
const dragHandle = this.createDragHandle();
|
|
25800
|
-
element.prepend(dragHandle);
|
|
25801
|
-
element.addEventListener("dragstart", (e) => this.onDragStart(e));
|
|
25802
|
-
this.root = element;
|
|
25803
|
-
}
|
|
25804
|
-
updateView() {
|
|
25805
|
-
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
25806
|
-
updateDOMAttributes(this.dom, { ...domAttrs });
|
|
25807
|
-
}
|
|
25808
|
-
update(node, decorations, innerDecorations) {
|
|
25809
|
-
const result = super.update(node, decorations, innerDecorations);
|
|
25810
|
-
if (!result) return false;
|
|
25811
|
-
this.updateView();
|
|
25812
|
-
return true;
|
|
25813
|
-
}
|
|
25814
|
-
}
|
|
25815
|
-
const structuredContentClass = "sd-structured-content-block";
|
|
25816
|
-
const structuredContentInnerClass = "sd-structured-content-block__content";
|
|
25817
25472
|
const StructuredContentBlock = Node$1.create({
|
|
25818
25473
|
name: "structuredContentBlock",
|
|
25819
|
-
group: "block
|
|
25474
|
+
group: "block",
|
|
25820
25475
|
content: "block*",
|
|
25821
|
-
isolating: true,
|
|
25822
|
-
atom: false,
|
|
25823
|
-
// false - has editable content.
|
|
25824
|
-
draggable: true,
|
|
25825
25476
|
addOptions() {
|
|
25826
25477
|
return {
|
|
25478
|
+
structuredContentClass: "sd-structured-content-block-tag",
|
|
25827
25479
|
htmlAttributes: {
|
|
25828
|
-
class: structuredContentClass,
|
|
25829
25480
|
"aria-label": "Structured content block node"
|
|
25830
25481
|
}
|
|
25831
25482
|
};
|
|
25832
25483
|
},
|
|
25833
25484
|
addAttributes() {
|
|
25834
25485
|
return {
|
|
25835
|
-
id: {
|
|
25836
|
-
default: null,
|
|
25837
|
-
parseDOM: (elem) => elem.getAttribute("data-id"),
|
|
25838
|
-
renderDOM: (attrs) => {
|
|
25839
|
-
if (!attrs.id) return {};
|
|
25840
|
-
return { "data-id": attrs.id };
|
|
25841
|
-
}
|
|
25842
|
-
},
|
|
25843
25486
|
sdtPr: {
|
|
25844
25487
|
rendered: false
|
|
25845
25488
|
}
|
|
25846
25489
|
};
|
|
25847
25490
|
},
|
|
25848
25491
|
parseDOM() {
|
|
25849
|
-
return [{ tag:
|
|
25492
|
+
return [{ tag: `div.${this.options.structuredContentClass}` }];
|
|
25850
25493
|
},
|
|
25851
25494
|
renderDOM({ htmlAttributes }) {
|
|
25852
25495
|
return [
|
|
25853
25496
|
"div",
|
|
25854
25497
|
Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes, {
|
|
25855
|
-
|
|
25498
|
+
class: this.options.structuredContentClass
|
|
25856
25499
|
}),
|
|
25857
25500
|
0
|
|
25858
25501
|
];
|
|
25859
|
-
},
|
|
25860
|
-
addNodeView() {
|
|
25861
|
-
return (props) => {
|
|
25862
|
-
return new StructuredContentBlockView({ ...props });
|
|
25863
|
-
};
|
|
25864
25502
|
}
|
|
25865
25503
|
});
|
|
25866
25504
|
class DocumentSectionView {
|
|
@@ -26027,7 +25665,16 @@ const DocumentSection = Node$1.create({
|
|
|
26027
25665
|
},
|
|
26028
25666
|
addAttributes() {
|
|
26029
25667
|
return {
|
|
25668
|
+
/**
|
|
25669
|
+
* @category Attribute
|
|
25670
|
+
* @param {number} [id] - Unique section identifier
|
|
25671
|
+
*/
|
|
26030
25672
|
id: {},
|
|
25673
|
+
/**
|
|
25674
|
+
* @private
|
|
25675
|
+
* @category Attribute
|
|
25676
|
+
* @param {string} [sdBlockId] - Internal block tracking
|
|
25677
|
+
*/
|
|
26031
25678
|
sdBlockId: {
|
|
26032
25679
|
default: null,
|
|
26033
25680
|
keepOnSplit: false,
|
|
@@ -26036,9 +25683,25 @@ const DocumentSection = Node$1.create({
|
|
|
26036
25683
|
return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
|
|
26037
25684
|
}
|
|
26038
25685
|
},
|
|
25686
|
+
/**
|
|
25687
|
+
* @category Attribute
|
|
25688
|
+
* @param {string} [title] - Section display label
|
|
25689
|
+
*/
|
|
26039
25690
|
title: {},
|
|
25691
|
+
/**
|
|
25692
|
+
* @category Attribute
|
|
25693
|
+
* @param {string} [description] - Section metadata
|
|
25694
|
+
*/
|
|
26040
25695
|
description: {},
|
|
25696
|
+
/**
|
|
25697
|
+
* @category Attribute
|
|
25698
|
+
* @param {string} [sectionType] - Business classification (e.g., 'legal', 'pricing')
|
|
25699
|
+
*/
|
|
26041
25700
|
sectionType: {},
|
|
25701
|
+
/**
|
|
25702
|
+
* @category Attribute
|
|
25703
|
+
* @param {boolean} [isLocked=false] - Lock state preventing edits
|
|
25704
|
+
*/
|
|
26042
25705
|
isLocked: { default: false }
|
|
26043
25706
|
};
|
|
26044
25707
|
},
|
|
@@ -26053,9 +25716,10 @@ const DocumentSection = Node$1.create({
|
|
|
26053
25716
|
* Create a lockable content section
|
|
26054
25717
|
* @category Command
|
|
26055
25718
|
* @param {SectionCreate} [options={}] - Section configuration
|
|
25719
|
+
* @returns {Function} Command - true if created, false if position invalid
|
|
26056
25720
|
* @example
|
|
26057
|
-
*
|
|
26058
|
-
* id: 1,
|
|
25721
|
+
* createDocumentSection({
|
|
25722
|
+
* id: 'legal-1',
|
|
26059
25723
|
* title: 'Terms & Conditions',
|
|
26060
25724
|
* isLocked: true,
|
|
26061
25725
|
* html: '<p>Legal content...</p>'
|
|
@@ -26136,8 +25800,9 @@ const DocumentSection = Node$1.create({
|
|
|
26136
25800
|
/**
|
|
26137
25801
|
* Remove section wrapper at cursor, preserving its content
|
|
26138
25802
|
* @category Command
|
|
25803
|
+
* @returns {Function} Command - true if removed, false if no section at position
|
|
26139
25804
|
* @example
|
|
26140
|
-
*
|
|
25805
|
+
* removeSectionAtSelection()
|
|
26141
25806
|
* @note Content stays in document, only section wrapper is removed
|
|
26142
25807
|
*/
|
|
26143
25808
|
removeSectionAtSelection: () => ({ tr, dispatch }) => {
|
|
@@ -26163,8 +25828,9 @@ const DocumentSection = Node$1.create({
|
|
|
26163
25828
|
* Delete section and all its content
|
|
26164
25829
|
* @category Command
|
|
26165
25830
|
* @param {number} id - Section to delete
|
|
25831
|
+
* @returns {Function} Command - true if deleted, false if ID doesn't exist
|
|
26166
25832
|
* @example
|
|
26167
|
-
*
|
|
25833
|
+
* removeSectionById(123)
|
|
26168
25834
|
*/
|
|
26169
25835
|
removeSectionById: (id) => ({ tr, dispatch }) => {
|
|
26170
25836
|
const sections = SectionHelpers.getAllSections(this.editor);
|
|
@@ -26184,8 +25850,9 @@ const DocumentSection = Node$1.create({
|
|
|
26184
25850
|
* Lock section against edits
|
|
26185
25851
|
* @category Command
|
|
26186
25852
|
* @param {number} id - Section to lock
|
|
25853
|
+
* @returns {Function} Command - true if locked, false if ID doesn't exist
|
|
26187
25854
|
* @example
|
|
26188
|
-
*
|
|
25855
|
+
* lockSectionById(123)
|
|
26189
25856
|
*/
|
|
26190
25857
|
lockSectionById: (id) => ({ tr, dispatch }) => {
|
|
26191
25858
|
const sections = SectionHelpers.getAllSections(this.editor);
|
|
@@ -26202,10 +25869,16 @@ const DocumentSection = Node$1.create({
|
|
|
26202
25869
|
* Modify section attributes or content
|
|
26203
25870
|
* @category Command
|
|
26204
25871
|
* @param {SectionUpdate} options - Changes to apply
|
|
25872
|
+
* @returns {Function} Command - true if updated, false if ID doesn't exist
|
|
26205
25873
|
* @example
|
|
26206
|
-
*
|
|
26207
|
-
*
|
|
26208
|
-
*
|
|
25874
|
+
* // Toggle lock
|
|
25875
|
+
* updateSectionById({ id: 123, attrs: { isLocked: false } })
|
|
25876
|
+
*
|
|
25877
|
+
* // Replace content
|
|
25878
|
+
* updateSectionById({ id: 123, html: '<p>New content</p>' })
|
|
25879
|
+
*
|
|
25880
|
+
* // Both
|
|
25881
|
+
* updateSectionById({
|
|
26209
25882
|
* id: 123,
|
|
26210
25883
|
* html: '<p>Updated</p>',
|
|
26211
25884
|
* attrs: { title: 'New Title' }
|
|
@@ -26255,10 +25928,11 @@ const BlockNode = Extension.create({
|
|
|
26255
25928
|
* Replace a block node by its ID with new content
|
|
26256
25929
|
* @category Command
|
|
26257
25930
|
* @param {string} id - The sdBlockId of the node to replace
|
|
26258
|
-
* @param {
|
|
25931
|
+
* @param {Object} contentNode - The replacement ProseMirror node
|
|
25932
|
+
* @returns {Function} Command function
|
|
26259
25933
|
* @example
|
|
26260
25934
|
* const newParagraph = editor.schema.nodes.paragraph.create({}, editor.schema.text('New content'))
|
|
26261
|
-
*
|
|
25935
|
+
* replaceBlockNodeById('block-123', newParagraph)
|
|
26262
25936
|
* @note The replacement node should have the same type as the original
|
|
26263
25937
|
*/
|
|
26264
25938
|
replaceBlockNodeById: (id, contentNode) => ({ dispatch, tr }) => {
|
|
@@ -26281,8 +25955,9 @@ const BlockNode = Extension.create({
|
|
|
26281
25955
|
* Delete a block node by its ID
|
|
26282
25956
|
* @category Command
|
|
26283
25957
|
* @param {string} id - The sdBlockId of the node to delete
|
|
25958
|
+
* @returns {Function} Command function
|
|
26284
25959
|
* @example
|
|
26285
|
-
*
|
|
25960
|
+
* deleteBlockNodeById('block-123')
|
|
26286
25961
|
* @note Completely removes the node from the document
|
|
26287
25962
|
*/
|
|
26288
25963
|
deleteBlockNodeById: (id) => ({ dispatch, tr }) => {
|
|
@@ -26306,10 +25981,11 @@ const BlockNode = Extension.create({
|
|
|
26306
25981
|
* @category Command
|
|
26307
25982
|
* @param {string} id - The sdBlockId of the node to update
|
|
26308
25983
|
* @param {Object} attrs - Attributes to update
|
|
25984
|
+
* @returns {Function} Command function
|
|
26309
25985
|
* @example
|
|
26310
|
-
*
|
|
25986
|
+
* updateBlockNodeAttributes('block-123', { textAlign: 'center' })
|
|
26311
25987
|
* @example
|
|
26312
|
-
*
|
|
25988
|
+
* updateBlockNodeAttributes('block-123', { indent: { left: 20 } })
|
|
26313
25989
|
* @note Merges new attributes with existing ones
|
|
26314
25990
|
*/
|
|
26315
25991
|
updateBlockNodeAttributes: (id, attrs = {}) => ({ dispatch, tr }) => {
|
|
@@ -26403,7 +26079,7 @@ const BlockNode = Extension.create({
|
|
|
26403
26079
|
key: BlockNodePluginKey,
|
|
26404
26080
|
appendTransaction: (transactions, _oldState, newState) => {
|
|
26405
26081
|
if (hasInitialized && !transactions.some((tr2) => tr2.docChanged)) return null;
|
|
26406
|
-
if (hasInitialized && !checkForNewBlockNodesInTrs(
|
|
26082
|
+
if (hasInitialized && !checkForNewBlockNodesInTrs(transactions)) return null;
|
|
26407
26083
|
const { tr } = newState;
|
|
26408
26084
|
let changed = false;
|
|
26409
26085
|
newState.doc.descendants((node, pos) => {
|
|
@@ -26482,8 +26158,9 @@ const TextStyle = Mark.create({
|
|
|
26482
26158
|
/**
|
|
26483
26159
|
* Remove empty text style marks
|
|
26484
26160
|
* @category Command
|
|
26161
|
+
* @returns {Function} Command function - Removes mark if no attributes present
|
|
26485
26162
|
* @example
|
|
26486
|
-
*
|
|
26163
|
+
* removeEmptyTextStyle()
|
|
26487
26164
|
* @note Cleanup utility to prevent empty span elements
|
|
26488
26165
|
* @note Automatically checks if any style attributes exist before removal
|
|
26489
26166
|
*/
|
|
@@ -26505,6 +26182,10 @@ const Bold = Mark.create({
|
|
|
26505
26182
|
},
|
|
26506
26183
|
addAttributes() {
|
|
26507
26184
|
return {
|
|
26185
|
+
/**
|
|
26186
|
+
* @category Attribute
|
|
26187
|
+
* @param {string} [value] - Bold weight value ('0' renders as normal)
|
|
26188
|
+
*/
|
|
26508
26189
|
value: {
|
|
26509
26190
|
default: null,
|
|
26510
26191
|
renderDOM: (attrs) => {
|
|
@@ -26533,23 +26214,26 @@ const Bold = Mark.create({
|
|
|
26533
26214
|
/**
|
|
26534
26215
|
* Apply bold formatting
|
|
26535
26216
|
* @category Command
|
|
26217
|
+
* @returns {Function} Command
|
|
26536
26218
|
* @example
|
|
26537
|
-
*
|
|
26219
|
+
* setBold()
|
|
26538
26220
|
* @note '0' renders as normal weight
|
|
26539
26221
|
*/
|
|
26540
26222
|
setBold: () => ({ commands: commands2 }) => commands2.setMark(this.name),
|
|
26541
26223
|
/**
|
|
26542
26224
|
* Remove bold formatting
|
|
26543
26225
|
* @category Command
|
|
26226
|
+
* @returns {Function} Command
|
|
26544
26227
|
* @example
|
|
26545
|
-
*
|
|
26228
|
+
* unsetBold()
|
|
26546
26229
|
*/
|
|
26547
26230
|
unsetBold: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
|
|
26548
26231
|
/**
|
|
26549
26232
|
* Toggle bold formatting
|
|
26550
26233
|
* @category Command
|
|
26234
|
+
* @returns {Function} Command
|
|
26551
26235
|
* @example
|
|
26552
|
-
*
|
|
26236
|
+
* toggleBold()
|
|
26553
26237
|
*/
|
|
26554
26238
|
toggleBold: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
|
|
26555
26239
|
};
|
|
@@ -26584,22 +26268,25 @@ const Italic = Mark.create({
|
|
|
26584
26268
|
/**
|
|
26585
26269
|
* Apply italic formatting
|
|
26586
26270
|
* @category Command
|
|
26271
|
+
* @returns {Function} Command
|
|
26587
26272
|
* @example
|
|
26588
|
-
*
|
|
26273
|
+
* setItalic()
|
|
26589
26274
|
*/
|
|
26590
26275
|
setItalic: () => ({ commands: commands2 }) => commands2.setMark(this.name),
|
|
26591
26276
|
/**
|
|
26592
26277
|
* Remove italic formatting
|
|
26593
26278
|
* @category Command
|
|
26279
|
+
* @returns {Function} Command
|
|
26594
26280
|
* @example
|
|
26595
|
-
*
|
|
26281
|
+
* unsetItalic()
|
|
26596
26282
|
*/
|
|
26597
26283
|
unsetItalic: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
|
|
26598
26284
|
/**
|
|
26599
26285
|
* Toggle italic formatting
|
|
26600
26286
|
* @category Command
|
|
26287
|
+
* @returns {Function} Command
|
|
26601
26288
|
* @example
|
|
26602
|
-
*
|
|
26289
|
+
* toggleItalic()
|
|
26603
26290
|
*/
|
|
26604
26291
|
toggleItalic: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
|
|
26605
26292
|
};
|
|
@@ -26683,6 +26370,10 @@ const Highlight = Mark.create({
|
|
|
26683
26370
|
},
|
|
26684
26371
|
addAttributes() {
|
|
26685
26372
|
return {
|
|
26373
|
+
/**
|
|
26374
|
+
* @category Attribute
|
|
26375
|
+
* @param {string} [color] - Background color (CSS color value)
|
|
26376
|
+
*/
|
|
26686
26377
|
color: {
|
|
26687
26378
|
default: null,
|
|
26688
26379
|
parseDOM: (element) => element.getAttribute("data-color") || element.style.backgroundColor,
|
|
@@ -26710,23 +26401,26 @@ const Highlight = Mark.create({
|
|
|
26710
26401
|
* Apply highlight with specified color
|
|
26711
26402
|
* @category Command
|
|
26712
26403
|
* @param {string} color - CSS color value
|
|
26404
|
+
* @returns {Function} Command
|
|
26713
26405
|
* @example
|
|
26714
|
-
*
|
|
26715
|
-
*
|
|
26406
|
+
* setHighlight('#FFEB3B')
|
|
26407
|
+
* setHighlight('rgba(255, 235, 59, 0.5)')
|
|
26716
26408
|
*/
|
|
26717
26409
|
setHighlight: (color) => ({ commands: commands2 }) => commands2.setMark(this.name, { color }),
|
|
26718
26410
|
/**
|
|
26719
26411
|
* Remove highlight formatting
|
|
26720
26412
|
* @category Command
|
|
26413
|
+
* @returns {Function} Command
|
|
26721
26414
|
* @example
|
|
26722
|
-
*
|
|
26415
|
+
* unsetHighlight()
|
|
26723
26416
|
*/
|
|
26724
26417
|
unsetHighlight: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
|
|
26725
26418
|
/**
|
|
26726
26419
|
* Toggle highlight formatting
|
|
26727
26420
|
* @category Command
|
|
26421
|
+
* @returns {Function} Command
|
|
26728
26422
|
* @example
|
|
26729
|
-
*
|
|
26423
|
+
* toggleHighlight()
|
|
26730
26424
|
*/
|
|
26731
26425
|
toggleHighlight: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
|
|
26732
26426
|
};
|
|
@@ -26759,8 +26453,9 @@ const Strike = Mark.create({
|
|
|
26759
26453
|
/**
|
|
26760
26454
|
* Apply strikethrough formatting
|
|
26761
26455
|
* @category Command
|
|
26456
|
+
* @returns {Function} Command
|
|
26762
26457
|
* @example
|
|
26763
|
-
*
|
|
26458
|
+
* setStrike()
|
|
26764
26459
|
*/
|
|
26765
26460
|
setStrike: () => ({ commands: commands2 }) => {
|
|
26766
26461
|
return commands2.setMark(this.name);
|
|
@@ -26768,8 +26463,9 @@ const Strike = Mark.create({
|
|
|
26768
26463
|
/**
|
|
26769
26464
|
* Remove strikethrough formatting
|
|
26770
26465
|
* @category Command
|
|
26466
|
+
* @returns {Function} Command
|
|
26771
26467
|
* @example
|
|
26772
|
-
*
|
|
26468
|
+
* unsetStrike()
|
|
26773
26469
|
*/
|
|
26774
26470
|
unsetStrike: () => ({ commands: commands2 }) => {
|
|
26775
26471
|
return commands2.unsetMark(this.name);
|
|
@@ -26777,8 +26473,9 @@ const Strike = Mark.create({
|
|
|
26777
26473
|
/**
|
|
26778
26474
|
* Toggle strikethrough formatting
|
|
26779
26475
|
* @category Command
|
|
26476
|
+
* @returns {Function} Command
|
|
26780
26477
|
* @example
|
|
26781
|
-
*
|
|
26478
|
+
* toggleStrike()
|
|
26782
26479
|
*/
|
|
26783
26480
|
toggleStrike: () => ({ commands: commands2 }) => {
|
|
26784
26481
|
return commands2.toggleMark(this.name);
|
|
@@ -26798,6 +26495,11 @@ const Link = Mark.create({
|
|
|
26798
26495
|
inclusive: false,
|
|
26799
26496
|
addOptions() {
|
|
26800
26497
|
return {
|
|
26498
|
+
/**
|
|
26499
|
+
* Allowed URL protocols
|
|
26500
|
+
* @type {string[]}
|
|
26501
|
+
* @default ['http', 'https']
|
|
26502
|
+
*/
|
|
26801
26503
|
protocols: ["http", "https"],
|
|
26802
26504
|
htmlAttributes: {
|
|
26803
26505
|
target: null,
|
|
@@ -26896,10 +26598,16 @@ const Link = Mark.create({
|
|
|
26896
26598
|
/**
|
|
26897
26599
|
* Create or update a link
|
|
26898
26600
|
* @category Command
|
|
26899
|
-
* @param {
|
|
26601
|
+
* @param {Object} options - Link configuration
|
|
26602
|
+
* @param {string} [options.href] - URL for the link
|
|
26603
|
+
* @param {string} [options.text] - Display text (uses selection if omitted)
|
|
26604
|
+
* @returns {Function} Command - Creates link with underline
|
|
26900
26605
|
* @example
|
|
26901
|
-
*
|
|
26902
|
-
*
|
|
26606
|
+
* // Link selected text
|
|
26607
|
+
* setLink({ href: 'https://example.com' })
|
|
26608
|
+
*
|
|
26609
|
+
* // Link with custom text
|
|
26610
|
+
* setLink({
|
|
26903
26611
|
* href: 'https://example.com',
|
|
26904
26612
|
* text: 'Visit Example'
|
|
26905
26613
|
* })
|
|
@@ -26951,8 +26659,9 @@ const Link = Mark.create({
|
|
|
26951
26659
|
/**
|
|
26952
26660
|
* Remove link and associated formatting
|
|
26953
26661
|
* @category Command
|
|
26662
|
+
* @returns {Function} Command - Removes link, underline, and color
|
|
26954
26663
|
* @example
|
|
26955
|
-
*
|
|
26664
|
+
* unsetLink()
|
|
26956
26665
|
* @note Also removes underline and text color
|
|
26957
26666
|
*/
|
|
26958
26667
|
unsetLink: () => ({ chain }) => {
|
|
@@ -26961,10 +26670,16 @@ const Link = Mark.create({
|
|
|
26961
26670
|
/**
|
|
26962
26671
|
* Toggle link on selection
|
|
26963
26672
|
* @category Command
|
|
26964
|
-
* @param {
|
|
26673
|
+
* @param {Object} [options] - Link configuration
|
|
26674
|
+
* @param {string} [options.href] - URL for the link
|
|
26675
|
+
* @param {string} [options.text] - Display text
|
|
26676
|
+
* @returns {Function} Command - Creates link if href provided, removes otherwise
|
|
26965
26677
|
* @example
|
|
26966
|
-
*
|
|
26967
|
-
*
|
|
26678
|
+
* // Add link
|
|
26679
|
+
* toggleLink({ href: 'https://example.com' })
|
|
26680
|
+
*
|
|
26681
|
+
* // Remove link
|
|
26682
|
+
* toggleLink()
|
|
26968
26683
|
*/
|
|
26969
26684
|
toggleLink: ({ href, text } = {}) => ({ commands: commands2 }) => {
|
|
26970
26685
|
if (!href) return commands2.unsetLink();
|
|
@@ -27851,8 +27566,8 @@ function mergePaddingObject(paddingObject) {
|
|
|
27851
27566
|
return Object.assign({}, getFreshSideObject(), paddingObject);
|
|
27852
27567
|
}
|
|
27853
27568
|
function expandToHashMap(value, keys2) {
|
|
27854
|
-
return keys2.reduce(function(hashMap,
|
|
27855
|
-
hashMap[
|
|
27569
|
+
return keys2.reduce(function(hashMap, key) {
|
|
27570
|
+
hashMap[key] = value;
|
|
27856
27571
|
return hashMap;
|
|
27857
27572
|
}, {});
|
|
27858
27573
|
}
|
|
@@ -28308,10 +28023,10 @@ function detectOverflow$1(state, options) {
|
|
|
28308
28023
|
var offsetData = state.modifiersData.offset;
|
|
28309
28024
|
if (elementContext === popper && offsetData) {
|
|
28310
28025
|
var offset2 = offsetData[placement];
|
|
28311
|
-
Object.keys(overflowOffsets).forEach(function(
|
|
28312
|
-
var multiply = [right, bottom].indexOf(
|
|
28313
|
-
var axis = [top, bottom].indexOf(
|
|
28314
|
-
overflowOffsets[
|
|
28026
|
+
Object.keys(overflowOffsets).forEach(function(key) {
|
|
28027
|
+
var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
|
|
28028
|
+
var axis = [top, bottom].indexOf(key) >= 0 ? "y" : "x";
|
|
28029
|
+
overflowOffsets[key] += offset2[axis] * multiply;
|
|
28315
28030
|
});
|
|
28316
28031
|
}
|
|
28317
28032
|
return overflowOffsets;
|
|
@@ -28758,8 +28473,8 @@ function mergeByName(modifiers2) {
|
|
|
28758
28473
|
}) : current;
|
|
28759
28474
|
return merged2;
|
|
28760
28475
|
}, {});
|
|
28761
|
-
return Object.keys(merged).map(function(
|
|
28762
|
-
return merged[
|
|
28476
|
+
return Object.keys(merged).map(function(key) {
|
|
28477
|
+
return merged[key];
|
|
28763
28478
|
});
|
|
28764
28479
|
}
|
|
28765
28480
|
var DEFAULT_OPTIONS = {
|
|
@@ -28916,8 +28631,8 @@ var TOUCH_OPTIONS = {
|
|
|
28916
28631
|
var TIPPY_DEFAULT_APPEND_TO = function TIPPY_DEFAULT_APPEND_TO2() {
|
|
28917
28632
|
return document.body;
|
|
28918
28633
|
};
|
|
28919
|
-
function hasOwnProperty(obj,
|
|
28920
|
-
return {}.hasOwnProperty.call(obj,
|
|
28634
|
+
function hasOwnProperty(obj, key) {
|
|
28635
|
+
return {}.hasOwnProperty.call(obj, key);
|
|
28921
28636
|
}
|
|
28922
28637
|
function getValueAtIndexOrReturn(value, index2, defaultValue) {
|
|
28923
28638
|
if (Array.isArray(value)) {
|
|
@@ -28947,8 +28662,8 @@ function debounce(fn2, ms) {
|
|
|
28947
28662
|
}
|
|
28948
28663
|
function removeProperties(obj, keys2) {
|
|
28949
28664
|
var clone = Object.assign({}, obj);
|
|
28950
|
-
keys2.forEach(function(
|
|
28951
|
-
delete clone[
|
|
28665
|
+
keys2.forEach(function(key) {
|
|
28666
|
+
delete clone[key];
|
|
28952
28667
|
});
|
|
28953
28668
|
return clone;
|
|
28954
28669
|
}
|
|
@@ -28975,9 +28690,9 @@ function arrayFrom(value) {
|
|
|
28975
28690
|
return [].slice.call(value);
|
|
28976
28691
|
}
|
|
28977
28692
|
function removeUndefinedProps(obj) {
|
|
28978
|
-
return Object.keys(obj).reduce(function(acc,
|
|
28979
|
-
if (obj[
|
|
28980
|
-
acc[
|
|
28693
|
+
return Object.keys(obj).reduce(function(acc, key) {
|
|
28694
|
+
if (obj[key] !== void 0) {
|
|
28695
|
+
acc[key] = obj[key];
|
|
28981
28696
|
}
|
|
28982
28697
|
return acc;
|
|
28983
28698
|
}, {});
|
|
@@ -29229,8 +28944,8 @@ var setDefaultProps = function setDefaultProps2(partialProps) {
|
|
|
29229
28944
|
validateProps(partialProps, []);
|
|
29230
28945
|
}
|
|
29231
28946
|
var keys2 = Object.keys(partialProps);
|
|
29232
|
-
keys2.forEach(function(
|
|
29233
|
-
defaultProps[
|
|
28947
|
+
keys2.forEach(function(key) {
|
|
28948
|
+
defaultProps[key] = partialProps[key];
|
|
29234
28949
|
});
|
|
29235
28950
|
};
|
|
29236
28951
|
function getExtendedPassedProps(passedProps) {
|
|
@@ -29249,18 +28964,18 @@ function getDataAttributeProps(reference2, plugins) {
|
|
|
29249
28964
|
var propKeys = plugins ? Object.keys(getExtendedPassedProps(Object.assign({}, defaultProps, {
|
|
29250
28965
|
plugins
|
|
29251
28966
|
}))) : defaultKeys;
|
|
29252
|
-
var props = propKeys.reduce(function(acc,
|
|
29253
|
-
var valueAsString = (reference2.getAttribute("data-tippy-" +
|
|
28967
|
+
var props = propKeys.reduce(function(acc, key) {
|
|
28968
|
+
var valueAsString = (reference2.getAttribute("data-tippy-" + key) || "").trim();
|
|
29254
28969
|
if (!valueAsString) {
|
|
29255
28970
|
return acc;
|
|
29256
28971
|
}
|
|
29257
|
-
if (
|
|
29258
|
-
acc[
|
|
28972
|
+
if (key === "content") {
|
|
28973
|
+
acc[key] = valueAsString;
|
|
29259
28974
|
} else {
|
|
29260
28975
|
try {
|
|
29261
|
-
acc[
|
|
28976
|
+
acc[key] = JSON.parse(valueAsString);
|
|
29262
28977
|
} catch (e) {
|
|
29263
|
-
acc[
|
|
28978
|
+
acc[key] = valueAsString;
|
|
29264
28979
|
}
|
|
29265
28980
|
}
|
|
29266
28981
|
return acc;
|
|
@@ -30184,8 +29899,8 @@ tippy.setDefaultProps({
|
|
|
30184
29899
|
});
|
|
30185
29900
|
const _export_sfc = (sfc, props) => {
|
|
30186
29901
|
const target = sfc.__vccOpts || sfc;
|
|
30187
|
-
for (const [
|
|
30188
|
-
target[
|
|
29902
|
+
for (const [key, val] of props) {
|
|
29903
|
+
target[key] = val;
|
|
30189
29904
|
}
|
|
30190
29905
|
return target;
|
|
30191
29906
|
};
|
|
@@ -30281,9 +29996,6 @@ const Mentions = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-b
|
|
|
30281
29996
|
const popoverPluginKey = new PluginKey("popoverPlugin");
|
|
30282
29997
|
const PopoverPlugin = Extension.create({
|
|
30283
29998
|
name: "popoverPlugin",
|
|
30284
|
-
addOptions() {
|
|
30285
|
-
return {};
|
|
30286
|
-
},
|
|
30287
29999
|
addPmPlugins() {
|
|
30288
30000
|
const popover = new Plugin({
|
|
30289
30001
|
key: popoverPluginKey,
|
|
@@ -31580,9 +31292,9 @@ const Pagination = Extension.create({
|
|
|
31580
31292
|
if (syncMeta && syncMeta.isChangeOrigin || listSyncMeta) {
|
|
31581
31293
|
return { ...oldState };
|
|
31582
31294
|
}
|
|
31583
|
-
const
|
|
31584
|
-
if (
|
|
31585
|
-
if (
|
|
31295
|
+
const imagePluginTransaction = tr.getMeta(ImagePlaceholderPluginKey);
|
|
31296
|
+
if (imagePluginTransaction) {
|
|
31297
|
+
if (imagePluginTransaction.type === "remove") {
|
|
31586
31298
|
onImageLoad(editor);
|
|
31587
31299
|
}
|
|
31588
31300
|
return { ...oldState };
|
|
@@ -32511,11 +32223,12 @@ const Search = Extension.create({
|
|
|
32511
32223
|
addCommands() {
|
|
32512
32224
|
return {
|
|
32513
32225
|
/**
|
|
32514
|
-
*
|
|
32226
|
+
* Navigates to the first search match
|
|
32515
32227
|
* @category Command
|
|
32228
|
+
* @returns {Function} - Command function
|
|
32516
32229
|
* @example
|
|
32517
|
-
*
|
|
32518
|
-
* @note Scrolls
|
|
32230
|
+
* goToFirstMatch()
|
|
32231
|
+
* @note Scrolls Editor to the first match of called search().
|
|
32519
32232
|
*/
|
|
32520
32233
|
goToFirstMatch: () => (
|
|
32521
32234
|
/** @returns {boolean} */
|
|
@@ -32531,13 +32244,13 @@ const Search = Extension.create({
|
|
|
32531
32244
|
}
|
|
32532
32245
|
),
|
|
32533
32246
|
/**
|
|
32534
|
-
*
|
|
32247
|
+
* Searches for the string match in Editor content
|
|
32535
32248
|
* @category Command
|
|
32536
32249
|
* @param {String|RegExp} patternInput - Search string or pattern
|
|
32250
|
+
* @returns {Function} - Command function that returns matches
|
|
32537
32251
|
* @example
|
|
32538
|
-
*
|
|
32539
|
-
*
|
|
32540
|
-
* @note Returns array of SearchMatch objects with positions and IDs
|
|
32252
|
+
* search('test string')
|
|
32253
|
+
* @note Searches for the test string in the Editor content and returns an array of matches
|
|
32541
32254
|
*/
|
|
32542
32255
|
search: (patternInput) => (
|
|
32543
32256
|
/** @returns {SearchMatch[]} */
|
|
@@ -32580,13 +32293,14 @@ const Search = Extension.create({
|
|
|
32580
32293
|
}
|
|
32581
32294
|
),
|
|
32582
32295
|
/**
|
|
32583
|
-
*
|
|
32296
|
+
* Navigates to the selected match
|
|
32584
32297
|
* @category Command
|
|
32585
|
-
* @param {SearchMatch} match
|
|
32298
|
+
* @param {SearchMatch} match Match at specific index
|
|
32299
|
+
* @returns {Function} - Command function
|
|
32586
32300
|
* @example
|
|
32587
|
-
* const
|
|
32588
|
-
*
|
|
32589
|
-
* @note Scrolls to match and
|
|
32301
|
+
* const searchResult = search('test string')
|
|
32302
|
+
* goToSearchResult(searchResult[3])
|
|
32303
|
+
* @note Scrolls Editor to the fourth match of called search() and sets selection on it.
|
|
32590
32304
|
*/
|
|
32591
32305
|
goToSearchResult: (match) => (
|
|
32592
32306
|
/** @returns {boolean} */
|
|
@@ -32848,9 +32562,6 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
|
|
|
32848
32562
|
};
|
|
32849
32563
|
const NodeResizer = Extension.create({
|
|
32850
32564
|
name: "nodeResizer",
|
|
32851
|
-
addOptions() {
|
|
32852
|
-
return {};
|
|
32853
|
-
},
|
|
32854
32565
|
addPmPlugins() {
|
|
32855
32566
|
const isHeadless = this.editor.options.isHeadless;
|
|
32856
32567
|
const hasDocument = typeof document !== "undefined";
|
|
@@ -32984,20 +32695,18 @@ export {
|
|
|
32984
32695
|
getQuickFormatList as a,
|
|
32985
32696
|
generateLinkedStyleString as b,
|
|
32986
32697
|
getFileOpener as c,
|
|
32987
|
-
|
|
32988
|
-
|
|
32989
|
-
|
|
32698
|
+
undoDepth as d,
|
|
32699
|
+
getStarterExtensions as e,
|
|
32700
|
+
getRichTextExtensions as f,
|
|
32990
32701
|
global as g,
|
|
32991
|
-
|
|
32992
|
-
|
|
32993
|
-
|
|
32994
|
-
|
|
32995
|
-
|
|
32996
|
-
|
|
32997
|
-
|
|
32998
|
-
|
|
32999
|
-
getAllowedImageDimensions as p,
|
|
33000
|
-
replaceSelectionWithImagePlaceholder as r,
|
|
32702
|
+
Extension as h,
|
|
32703
|
+
index$1 as i,
|
|
32704
|
+
index as j,
|
|
32705
|
+
AnnotatorHelpers as k,
|
|
32706
|
+
SectionHelpers as l,
|
|
32707
|
+
getAllowedImageDimensions as m,
|
|
32708
|
+
redoDepth as r,
|
|
32709
|
+
startImageUpload as s,
|
|
33001
32710
|
useHighContrastMode as u,
|
|
33002
32711
|
yUndoPluginKey as y
|
|
33003
32712
|
};
|