@harbour-enterprises/superdoc 0.20.0-next.14 → 0.20.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/chunks/{PdfViewer-D-erp24R.cjs → PdfViewer-B6adMXJl.cjs} +1 -1
- package/dist/chunks/{PdfViewer-_NPRPRHl.es.js → PdfViewer-_tL5RYr9.es.js} +1 -1
- package/dist/chunks/{index-dMbV_syB.es.js → index-DwXeHvLq.es.js} +3 -3
- package/dist/chunks/{index-duHcNiwD.cjs → index-mjjKSLDT.cjs} +3 -3
- package/dist/chunks/{super-editor.es-BKurmwFy.es.js → super-editor.es-CPrd1wq8.es.js} +2520 -3569
- package/dist/chunks/{super-editor.es-ly_a915J.cjs → super-editor.es-DJHyk0Zs.cjs} +2520 -3569
- 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-Brf9NxwA.js → converter-KHB8spG5.js} +1151 -1825
- package/dist/super-editor/chunks/{docx-zipper-Dld3TtPb.js → docx-zipper-B-vl4ISA.js} +1 -1
- package/dist/super-editor/chunks/{editor-N0dhAC41.js → editor-Df2sUgT0.js} +1020 -1384
- package/dist/super-editor/chunks/{toolbar-CXinz1gO.js → toolbar-C6JoUIM_.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/bookmarkNodeImporter.d.ts +0 -5
- 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 -4
- 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/bookmarks/index.d.ts +1 -2
- 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/index.d.ts +1 -2
- 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 +3149 -4198
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +4 -7
- package/dist/super-editor/src/core/helpers/updateDOMAttributes.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v2/importer/bookmarkEndImporter.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v2/importer/bookmarkStartImporter.d.ts +0 -6
- 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/bookmark-end/attributes/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-end/attributes/w-displaced-by-custom-xml.d.ts +0 -4
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-end/attributes/w-id.d.ts +0 -4
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-end/bookmark-end-translator.d.ts +0 -7
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-end/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/attributes/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/attributes/w-col-first.d.ts +0 -4
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/attributes/w-col-last.d.ts +0 -4
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/attributes/w-displaced-by-custom-xml.d.ts +0 -4
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/attributes/w-id.d.ts +0 -4
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/attributes/w-name.d.ts +0 -4
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/bookmark-start-translator.d.ts +0 -7
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bookmark-start/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/bookmarks/bookmark-end.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
- /package/dist/super-editor/src/extensions/bookmarks/{bookmark-start.d.ts → bookmarks.d.ts} +0 -0
|
@@ -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-KHB8spG5.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-B-vl4ISA.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) {
|
|
@@ -5914,9 +5914,9 @@ const writeAny = (encoder, data) => {
|
|
|
5914
5914
|
const keys2 = Object.keys(data);
|
|
5915
5915
|
writeVarUint(encoder, keys2.length);
|
|
5916
5916
|
for (let i = 0; i < keys2.length; i++) {
|
|
5917
|
-
const
|
|
5918
|
-
writeVarString(encoder,
|
|
5919
|
-
writeAny(encoder, data[
|
|
5917
|
+
const key = keys2[i];
|
|
5918
|
+
writeVarString(encoder, key);
|
|
5919
|
+
writeAny(encoder, data[key]);
|
|
5920
5920
|
}
|
|
5921
5921
|
}
|
|
5922
5922
|
break;
|
|
@@ -5935,17 +5935,17 @@ const unexpectedCase = () => {
|
|
|
5935
5935
|
throw create$1("Unexpected case");
|
|
5936
5936
|
};
|
|
5937
5937
|
const create = () => /* @__PURE__ */ new Map();
|
|
5938
|
-
const setIfUndefined = (map2,
|
|
5939
|
-
let set = map2.get(
|
|
5938
|
+
const setIfUndefined = (map2, key, createT) => {
|
|
5939
|
+
let set = map2.get(key);
|
|
5940
5940
|
if (set === void 0) {
|
|
5941
|
-
map2.set(
|
|
5941
|
+
map2.set(key, set = createT());
|
|
5942
5942
|
}
|
|
5943
5943
|
return set;
|
|
5944
5944
|
};
|
|
5945
5945
|
const keys = Object.keys;
|
|
5946
5946
|
const every = (obj, f) => {
|
|
5947
|
-
for (const
|
|
5948
|
-
if (!f(obj[
|
|
5947
|
+
for (const key in obj) {
|
|
5948
|
+
if (!f(obj[key], key)) {
|
|
5949
5949
|
return false;
|
|
5950
5950
|
}
|
|
5951
5951
|
}
|
|
@@ -6001,14 +6001,14 @@ class VarStoragePolyfill {
|
|
|
6001
6001
|
* @param {string} key
|
|
6002
6002
|
* @param {any} newValue
|
|
6003
6003
|
*/
|
|
6004
|
-
setItem(
|
|
6005
|
-
this.map.set(
|
|
6004
|
+
setItem(key, newValue) {
|
|
6005
|
+
this.map.set(key, newValue);
|
|
6006
6006
|
}
|
|
6007
6007
|
/**
|
|
6008
6008
|
* @param {string} key
|
|
6009
6009
|
*/
|
|
6010
|
-
getItem(
|
|
6011
|
-
return this.map.get(
|
|
6010
|
+
getItem(key) {
|
|
6011
|
+
return this.map.get(key);
|
|
6012
6012
|
}
|
|
6013
6013
|
}
|
|
6014
6014
|
let _localStorage = new VarStoragePolyfill();
|
|
@@ -6051,9 +6051,9 @@ const computeParams = () => {
|
|
|
6051
6051
|
params = create();
|
|
6052
6052
|
(location.search || "?").slice(1).split("&").forEach((kv) => {
|
|
6053
6053
|
if (kv.length !== 0) {
|
|
6054
|
-
const [
|
|
6055
|
-
params.set(`--${fromCamelCase(
|
|
6056
|
-
params.set(`-${fromCamelCase(
|
|
6054
|
+
const [key, value] = kv.split("=");
|
|
6055
|
+
params.set(`--${fromCamelCase(key, "-")}`, value);
|
|
6056
|
+
params.set(`-${fromCamelCase(key, "-")}`, value);
|
|
6057
6057
|
}
|
|
6058
6058
|
});
|
|
6059
6059
|
} else {
|
|
@@ -6336,8 +6336,8 @@ const ySyncPlugin = (yXmlFragment, {
|
|
|
6336
6336
|
const change = tr.getMeta(ySyncPluginKey);
|
|
6337
6337
|
if (change !== void 0) {
|
|
6338
6338
|
pluginState = Object.assign({}, pluginState);
|
|
6339
|
-
for (const
|
|
6340
|
-
pluginState[
|
|
6339
|
+
for (const key in change) {
|
|
6340
|
+
pluginState[key] = change[key];
|
|
6341
6341
|
}
|
|
6342
6342
|
}
|
|
6343
6343
|
pluginState.addToHistory = tr.getMeta("addToHistory") !== false;
|
|
@@ -6609,7 +6609,7 @@ class ProsemirrorBinding {
|
|
|
6609
6609
|
snapshot = Y.snapshot(historyDoc);
|
|
6610
6610
|
if (historyType._item === null) {
|
|
6611
6611
|
const rootKey = Array.from(this.doc.share.keys()).find(
|
|
6612
|
-
(
|
|
6612
|
+
(key) => this.doc.share.get(key) === this.type
|
|
6613
6613
|
);
|
|
6614
6614
|
historyType = historyDoc.getXmlFragment(rootKey);
|
|
6615
6615
|
} else {
|
|
@@ -6898,10 +6898,10 @@ const createTypeFromTextNodes = (nodes, meta) => {
|
|
|
6898
6898
|
};
|
|
6899
6899
|
const createTypeFromElementNode = (node, meta) => {
|
|
6900
6900
|
const type = new Y.XmlElement(node.type.name);
|
|
6901
|
-
for (const
|
|
6902
|
-
const val = node.attrs[
|
|
6903
|
-
if (val !== null &&
|
|
6904
|
-
type.setAttribute(
|
|
6901
|
+
for (const key in node.attrs) {
|
|
6902
|
+
const val = node.attrs[key];
|
|
6903
|
+
if (val !== null && key !== "ychange") {
|
|
6904
|
+
type.setAttribute(key, val);
|
|
6905
6905
|
}
|
|
6906
6906
|
}
|
|
6907
6907
|
type.insert(
|
|
@@ -6916,13 +6916,13 @@ const createTypeFromElementNode = (node, meta) => {
|
|
|
6916
6916
|
const createTypeFromTextOrElementNode = (node, meta) => node instanceof Array ? createTypeFromTextNodes(node, meta) : createTypeFromElementNode(node, meta);
|
|
6917
6917
|
const isObject = (val) => typeof val === "object" && val !== null;
|
|
6918
6918
|
const equalAttrs = (pattrs, yattrs) => {
|
|
6919
|
-
const keys2 = Object.keys(pattrs).filter((
|
|
6920
|
-
let eq = keys2.length === (yattrs == null ? 0 : Object.keys(yattrs).filter((
|
|
6919
|
+
const keys2 = Object.keys(pattrs).filter((key) => pattrs[key] !== null);
|
|
6920
|
+
let eq = keys2.length === (yattrs == null ? 0 : Object.keys(yattrs).filter((key) => yattrs[key] !== null).length);
|
|
6921
6921
|
for (let i = 0; i < keys2.length && eq; i++) {
|
|
6922
|
-
const
|
|
6923
|
-
const l = pattrs[
|
|
6924
|
-
const r2 = yattrs[
|
|
6925
|
-
eq =
|
|
6922
|
+
const key = keys2[i];
|
|
6923
|
+
const l = pattrs[key];
|
|
6924
|
+
const r2 = yattrs[key];
|
|
6925
|
+
eq = key === "ychange" || l === r2 || isObject(l) && isObject(r2) && equalAttrs(l, r2);
|
|
6926
6926
|
}
|
|
6927
6927
|
return eq;
|
|
6928
6928
|
};
|
|
@@ -7069,18 +7069,18 @@ const updateYFragment = (y, yDomFragment, pNode, meta) => {
|
|
|
7069
7069
|
if (yDomFragment instanceof Y.XmlElement) {
|
|
7070
7070
|
const yDomAttrs = yDomFragment.getAttributes();
|
|
7071
7071
|
const pAttrs = pNode.attrs;
|
|
7072
|
-
for (const
|
|
7073
|
-
if (pAttrs[
|
|
7074
|
-
if (yDomAttrs[
|
|
7075
|
-
yDomFragment.setAttribute(
|
|
7072
|
+
for (const key in pAttrs) {
|
|
7073
|
+
if (pAttrs[key] !== null) {
|
|
7074
|
+
if (yDomAttrs[key] !== pAttrs[key] && key !== "ychange") {
|
|
7075
|
+
yDomFragment.setAttribute(key, pAttrs[key]);
|
|
7076
7076
|
}
|
|
7077
7077
|
} else {
|
|
7078
|
-
yDomFragment.removeAttribute(
|
|
7078
|
+
yDomFragment.removeAttribute(key);
|
|
7079
7079
|
}
|
|
7080
7080
|
}
|
|
7081
|
-
for (const
|
|
7082
|
-
if (pAttrs[
|
|
7083
|
-
yDomFragment.removeAttribute(
|
|
7081
|
+
for (const key in yDomAttrs) {
|
|
7082
|
+
if (pAttrs[key] === void 0) {
|
|
7083
|
+
yDomFragment.removeAttribute(key);
|
|
7084
7084
|
}
|
|
7085
7085
|
}
|
|
7086
7086
|
}
|
|
@@ -7211,19 +7211,19 @@ const updateMetas = () => {
|
|
|
7211
7211
|
const tr = view.state.tr;
|
|
7212
7212
|
const syncState = ySyncPluginKey.getState(view.state);
|
|
7213
7213
|
if (syncState && syncState.binding && !syncState.binding.isDestroyed) {
|
|
7214
|
-
metas.forEach((val,
|
|
7215
|
-
tr.setMeta(
|
|
7214
|
+
metas.forEach((val, key) => {
|
|
7215
|
+
tr.setMeta(key, val);
|
|
7216
7216
|
});
|
|
7217
7217
|
view.dispatch(tr);
|
|
7218
7218
|
}
|
|
7219
7219
|
});
|
|
7220
7220
|
};
|
|
7221
|
-
const setMeta$1 = (view,
|
|
7221
|
+
const setMeta$1 = (view, key, value) => {
|
|
7222
7222
|
if (!viewsToUpdate) {
|
|
7223
7223
|
viewsToUpdate = /* @__PURE__ */ new Map();
|
|
7224
7224
|
timeout(0, updateMetas);
|
|
7225
7225
|
}
|
|
7226
|
-
setIfUndefined(viewsToUpdate, view, create).set(
|
|
7226
|
+
setIfUndefined(viewsToUpdate, view, create).set(key, value);
|
|
7227
7227
|
};
|
|
7228
7228
|
const absolutePositionToRelativePosition = (pos, type, mapping) => {
|
|
7229
7229
|
if (pos === 0) {
|
|
@@ -7683,6 +7683,12 @@ const History = Extension.create({
|
|
|
7683
7683
|
name: "history",
|
|
7684
7684
|
addOptions() {
|
|
7685
7685
|
return {
|
|
7686
|
+
/**
|
|
7687
|
+
* @typedef {Object} HistoryOptions
|
|
7688
|
+
* @category Options
|
|
7689
|
+
* @property {number} [depth=100] - Maximum undo/redo steps to remember
|
|
7690
|
+
* @property {number} [newGroupDelay=500] - Milliseconds to wait before starting a new history group
|
|
7691
|
+
*/
|
|
7686
7692
|
depth: 100,
|
|
7687
7693
|
newGroupDelay: 500
|
|
7688
7694
|
};
|
|
@@ -7701,8 +7707,9 @@ const History = Extension.create({
|
|
|
7701
7707
|
/**
|
|
7702
7708
|
* Undo the last action
|
|
7703
7709
|
* @category Command
|
|
7710
|
+
* @returns {Function} Command function
|
|
7704
7711
|
* @example
|
|
7705
|
-
*
|
|
7712
|
+
* undo()
|
|
7706
7713
|
* @note Groups changes within the newGroupDelay window
|
|
7707
7714
|
*/
|
|
7708
7715
|
undo: () => ({ state, dispatch, tr }) => {
|
|
@@ -7716,8 +7723,9 @@ const History = Extension.create({
|
|
|
7716
7723
|
/**
|
|
7717
7724
|
* Redo the last undone action
|
|
7718
7725
|
* @category Command
|
|
7726
|
+
* @returns {Function} Command function
|
|
7719
7727
|
* @example
|
|
7720
|
-
*
|
|
7728
|
+
* redo()
|
|
7721
7729
|
* @note Only available after an undo action
|
|
7722
7730
|
*/
|
|
7723
7731
|
redo: () => ({ state, dispatch, tr }) => {
|
|
@@ -7915,21 +7923,21 @@ class Attribute {
|
|
|
7915
7923
|
let attrs = {};
|
|
7916
7924
|
for (const item of items) {
|
|
7917
7925
|
const mergedAttributes = { ...attrs };
|
|
7918
|
-
for (const [
|
|
7919
|
-
const exists = mergedAttributes[
|
|
7926
|
+
for (const [key, value] of Object.entries(item)) {
|
|
7927
|
+
const exists = mergedAttributes[key];
|
|
7920
7928
|
if (!exists) {
|
|
7921
|
-
mergedAttributes[
|
|
7929
|
+
mergedAttributes[key] = value;
|
|
7922
7930
|
continue;
|
|
7923
7931
|
}
|
|
7924
|
-
if (
|
|
7932
|
+
if (key === "class") {
|
|
7925
7933
|
const valueClasses = value ? value.split(" ") : [];
|
|
7926
|
-
const existingClasses = mergedAttributes[
|
|
7934
|
+
const existingClasses = mergedAttributes[key] ? mergedAttributes[key].split(" ") : [];
|
|
7927
7935
|
const insertClasses = valueClasses.filter((value2) => !existingClasses.includes(value2));
|
|
7928
|
-
mergedAttributes[
|
|
7929
|
-
} else if (
|
|
7930
|
-
mergedAttributes[
|
|
7936
|
+
mergedAttributes[key] = [...existingClasses, ...insertClasses].join(" ");
|
|
7937
|
+
} else if (key === "style") {
|
|
7938
|
+
mergedAttributes[key] = [mergedAttributes[key], value].join("; ");
|
|
7931
7939
|
} else {
|
|
7932
|
-
mergedAttributes[
|
|
7940
|
+
mergedAttributes[key] = value;
|
|
7933
7941
|
}
|
|
7934
7942
|
}
|
|
7935
7943
|
attrs = mergedAttributes;
|
|
@@ -8239,8 +8247,8 @@ const insertTabNode = () => ({ tr, state, dispatch }) => {
|
|
|
8239
8247
|
if (dispatch) dispatch(tr);
|
|
8240
8248
|
return true;
|
|
8241
8249
|
};
|
|
8242
|
-
const setMeta = (
|
|
8243
|
-
tr.setMeta(
|
|
8250
|
+
const setMeta = (key, value) => ({ tr }) => {
|
|
8251
|
+
tr.setMeta(key, value);
|
|
8244
8252
|
return true;
|
|
8245
8253
|
};
|
|
8246
8254
|
const ensureMarks = (state, splittableMarks) => {
|
|
@@ -11368,14 +11376,14 @@ const updateYdocDocxData = async (editor, ydoc) => {
|
|
|
11368
11376
|
const metaMap = ydoc.getMap("meta");
|
|
11369
11377
|
const docx = [...metaMap.get("docx")];
|
|
11370
11378
|
const newXml = await editor.exportDocx({ getUpdatedDocs: true });
|
|
11371
|
-
Object.keys(newXml).forEach((
|
|
11372
|
-
const fileIndex = docx.findIndex((item) => item.name ===
|
|
11379
|
+
Object.keys(newXml).forEach((key) => {
|
|
11380
|
+
const fileIndex = docx.findIndex((item) => item.name === key);
|
|
11373
11381
|
if (fileIndex > -1) {
|
|
11374
11382
|
docx.splice(fileIndex, 1);
|
|
11375
11383
|
}
|
|
11376
11384
|
docx.push({
|
|
11377
|
-
name:
|
|
11378
|
-
content: newXml[
|
|
11385
|
+
name: key,
|
|
11386
|
+
content: newXml[key]
|
|
11379
11387
|
});
|
|
11380
11388
|
});
|
|
11381
11389
|
ydoc.transact(
|
|
@@ -11391,8 +11399,8 @@ const initPaginationData = async (editor) => {
|
|
|
11391
11399
|
const sectionData = { headers: {}, footers: {} };
|
|
11392
11400
|
const headerIds = editor.converter.headerIds.ids;
|
|
11393
11401
|
const footerIds = editor.converter.footerIds.ids;
|
|
11394
|
-
for (let
|
|
11395
|
-
const sectionId = headerIds[
|
|
11402
|
+
for (let key in headerIds) {
|
|
11403
|
+
const sectionId = headerIds[key];
|
|
11396
11404
|
if (!sectionId) continue;
|
|
11397
11405
|
const dataForThisSection = editor.converter.headers[sectionId];
|
|
11398
11406
|
if (!sectionData.headers[sectionId]) sectionData.headers[sectionId] = {};
|
|
@@ -11402,8 +11410,8 @@ const initPaginationData = async (editor) => {
|
|
|
11402
11410
|
sectionData.headers[sectionId].sectionEditor = sectionEditor;
|
|
11403
11411
|
sectionData.headers[sectionId].sectionContainer = sectionContainer;
|
|
11404
11412
|
}
|
|
11405
|
-
for (let
|
|
11406
|
-
const sectionId = footerIds[
|
|
11413
|
+
for (let key in footerIds) {
|
|
11414
|
+
const sectionId = footerIds[key];
|
|
11407
11415
|
if (!sectionId) continue;
|
|
11408
11416
|
const dataForThisSection = editor.converter.footers[sectionId];
|
|
11409
11417
|
if (!sectionData.headers[sectionId]) sectionData.footers[sectionId] = {};
|
|
@@ -12472,16 +12480,16 @@ const generateTableIfNecessary = ({ tableNode, annotationValues, tr, state }) =>
|
|
|
12472
12480
|
if (rowsToGenerate <= 1) return;
|
|
12473
12481
|
const validateAttributes = (attrs) => {
|
|
12474
12482
|
const cleaned = {};
|
|
12475
|
-
for (const [
|
|
12483
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
12476
12484
|
if (value !== void 0 && value !== null) {
|
|
12477
|
-
if (
|
|
12478
|
-
cleaned[
|
|
12479
|
-
} else if (
|
|
12480
|
-
cleaned[
|
|
12485
|
+
if (key === "displayLabel") {
|
|
12486
|
+
cleaned[key] = String(value);
|
|
12487
|
+
} else if (key === "rawHtml" || key === "linkUrl" || key === "imageSrc") {
|
|
12488
|
+
cleaned[key] = String(value);
|
|
12481
12489
|
} else if (typeof value === "string" && value.length > 0) {
|
|
12482
|
-
cleaned[
|
|
12490
|
+
cleaned[key] = value;
|
|
12483
12491
|
} else if (typeof value !== "string") {
|
|
12484
|
-
cleaned[
|
|
12492
|
+
cleaned[key] = value;
|
|
12485
12493
|
}
|
|
12486
12494
|
}
|
|
12487
12495
|
}
|
|
@@ -12759,10 +12767,10 @@ const Collaboration = Extension.create({
|
|
|
12759
12767
|
this.options.fragment = fragment;
|
|
12760
12768
|
const metaMap = this.options.ydoc.getMap("media");
|
|
12761
12769
|
metaMap.observe((event) => {
|
|
12762
|
-
event.changes.keys.forEach((_,
|
|
12763
|
-
if (!(
|
|
12764
|
-
const fileData = metaMap.get(
|
|
12765
|
-
this.editor.storage.image.media[
|
|
12770
|
+
event.changes.keys.forEach((_, key) => {
|
|
12771
|
+
if (!(key in this.editor.storage.image.media)) {
|
|
12772
|
+
const fileData = metaMap.get(key);
|
|
12773
|
+
this.editor.storage.image.media[key] = fileData;
|
|
12766
12774
|
}
|
|
12767
12775
|
});
|
|
12768
12776
|
});
|
|
@@ -12782,8 +12790,8 @@ const initializeMetaMap = (ydoc, editor) => {
|
|
|
12782
12790
|
metaMap.set("docx", editor.options.content);
|
|
12783
12791
|
metaMap.set("fonts", editor.options.fonts);
|
|
12784
12792
|
const mediaMap = ydoc.getMap("media");
|
|
12785
|
-
Object.entries(editor.options.mediaFiles).forEach(([
|
|
12786
|
-
mediaMap.set(
|
|
12793
|
+
Object.entries(editor.options.mediaFiles).forEach(([key, value]) => {
|
|
12794
|
+
mediaMap.set(key, value);
|
|
12787
12795
|
});
|
|
12788
12796
|
};
|
|
12789
12797
|
const checkDocxChanged = (transaction) => {
|
|
@@ -13545,8 +13553,8 @@ function processRelationships(root, convertedXml, results) {
|
|
|
13545
13553
|
};
|
|
13546
13554
|
const seenIds = /* @__PURE__ */ new Set();
|
|
13547
13555
|
const filtered = [];
|
|
13548
|
-
function extractStringAttr(attrs,
|
|
13549
|
-
return typeof attrs[
|
|
13556
|
+
function extractStringAttr(attrs, key) {
|
|
13557
|
+
return typeof attrs[key] === "string" ? attrs[key].trim() : "";
|
|
13550
13558
|
}
|
|
13551
13559
|
for (const rel of root.elements) {
|
|
13552
13560
|
rel.attributes = rel.attributes || {};
|
|
@@ -13768,10 +13776,10 @@ class SuperValidator {
|
|
|
13768
13776
|
this.logger.debug("Document analysis:", documentAnalysis);
|
|
13769
13777
|
let hasModifiedDocument = false;
|
|
13770
13778
|
const validationResults = [];
|
|
13771
|
-
Object.entries(__privateGet(this, _stateValidators)).forEach(([
|
|
13772
|
-
this.logger.debug(`🕵 Validating with ${
|
|
13779
|
+
Object.entries(__privateGet(this, _stateValidators)).forEach(([key, validator]) => {
|
|
13780
|
+
this.logger.debug(`🕵 Validating with ${key}...`);
|
|
13773
13781
|
const { results, modified } = validator(tr, documentAnalysis);
|
|
13774
|
-
validationResults.push({ key
|
|
13782
|
+
validationResults.push({ key, results });
|
|
13775
13783
|
hasModifiedDocument = hasModifiedDocument || modified;
|
|
13776
13784
|
});
|
|
13777
13785
|
if (!this.dryRun) dispatch(tr);
|
|
@@ -13788,10 +13796,10 @@ class SuperValidator {
|
|
|
13788
13796
|
const { dispatch } = __privateGet(this, _editor).view;
|
|
13789
13797
|
let hasModifiedDocument = false;
|
|
13790
13798
|
const validationResults = [];
|
|
13791
|
-
Object.entries(__privateGet(this, _xmlValidators)).forEach(([
|
|
13792
|
-
this.logger.debug(`🕵 Validating export with ${
|
|
13799
|
+
Object.entries(__privateGet(this, _xmlValidators)).forEach(([key, validator]) => {
|
|
13800
|
+
this.logger.debug(`🕵 Validating export with ${key}...`);
|
|
13793
13801
|
const { results, modified } = validator();
|
|
13794
|
-
validationResults.push({ key
|
|
13802
|
+
validationResults.push({ key, results });
|
|
13795
13803
|
hasModifiedDocument = hasModifiedDocument || modified;
|
|
13796
13804
|
});
|
|
13797
13805
|
if (!this.dryRun && hasModifiedDocument) dispatch(tr);
|
|
@@ -13815,11 +13823,11 @@ initializeValidators_fn = function() {
|
|
|
13815
13823
|
const requiredMarks = /* @__PURE__ */ new Set();
|
|
13816
13824
|
const initializeValidatorSet = (validatorFactories) => {
|
|
13817
13825
|
return Object.fromEntries(
|
|
13818
|
-
Object.entries(validatorFactories).map(([
|
|
13819
|
-
const validatorLogger = this.logger.withPrefix(
|
|
13826
|
+
Object.entries(validatorFactories).map(([key, factory]) => {
|
|
13827
|
+
const validatorLogger = this.logger.withPrefix(key);
|
|
13820
13828
|
const validator = factory({ editor: __privateGet(this, _editor), logger: validatorLogger });
|
|
13821
13829
|
__privateMethod(this, _SuperValidator_instances, collectValidatorRequirements_fn).call(this, validator, requiredNodes, requiredMarks);
|
|
13822
|
-
return [
|
|
13830
|
+
return [key, validator];
|
|
13823
13831
|
})
|
|
13824
13832
|
);
|
|
13825
13833
|
};
|
|
@@ -14697,7 +14705,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14697
14705
|
return result;
|
|
14698
14706
|
} catch (error) {
|
|
14699
14707
|
this.emit("exception", { error, editor: this });
|
|
14700
|
-
console.error(error);
|
|
14701
14708
|
}
|
|
14702
14709
|
}
|
|
14703
14710
|
/**
|
|
@@ -14721,7 +14728,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14721
14728
|
this.converter.footerEditors.length = 0;
|
|
14722
14729
|
} catch (error) {
|
|
14723
14730
|
this.emit("exception", { error, editor: this });
|
|
14724
|
-
console.error(error);
|
|
14725
14731
|
}
|
|
14726
14732
|
}
|
|
14727
14733
|
/**
|
|
@@ -14741,7 +14747,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14741
14747
|
* @returns {Object | void} Migration results
|
|
14742
14748
|
*/
|
|
14743
14749
|
processCollaborationMigrations() {
|
|
14744
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.20.0
|
|
14750
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.20.0");
|
|
14745
14751
|
if (!this.options.ydoc) return;
|
|
14746
14752
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
14747
14753
|
let docVersion = metaMap.get("version");
|
|
@@ -15143,8 +15149,8 @@ initMedia_fn = function() {
|
|
|
15143
15149
|
if (!this.options.ydoc) return this.storage.image.media = this.options.mediaFiles;
|
|
15144
15150
|
const mediaMap = this.options.ydoc.getMap("media");
|
|
15145
15151
|
if (this.options.isNewFile) {
|
|
15146
|
-
Object.entries(this.options.mediaFiles).forEach(([
|
|
15147
|
-
mediaMap.set(
|
|
15152
|
+
Object.entries(this.options.mediaFiles).forEach(([key, value]) => {
|
|
15153
|
+
mediaMap.set(key, value);
|
|
15148
15154
|
});
|
|
15149
15155
|
this.storage.image.media = this.options.mediaFiles;
|
|
15150
15156
|
} else {
|
|
@@ -15419,7 +15425,6 @@ endCollaboration_fn = function() {
|
|
|
15419
15425
|
if (this.options.ydoc) this.options.ydoc.destroy();
|
|
15420
15426
|
} catch (error) {
|
|
15421
15427
|
this.emit("exception", { error, editor: this });
|
|
15422
|
-
console.error(error);
|
|
15423
15428
|
}
|
|
15424
15429
|
};
|
|
15425
15430
|
/**
|
|
@@ -15454,6 +15459,11 @@ const Color = Extension.create({
|
|
|
15454
15459
|
name: "color",
|
|
15455
15460
|
addOptions() {
|
|
15456
15461
|
return {
|
|
15462
|
+
/**
|
|
15463
|
+
* @typedef {Object} ColorOptions
|
|
15464
|
+
* @category Options
|
|
15465
|
+
* @property {string[]} [types=['textStyle']] - Mark types to add color support to
|
|
15466
|
+
*/
|
|
15457
15467
|
types: ["textStyle"]
|
|
15458
15468
|
};
|
|
15459
15469
|
},
|
|
@@ -15462,6 +15472,10 @@ const Color = Extension.create({
|
|
|
15462
15472
|
{
|
|
15463
15473
|
types: this.options.types,
|
|
15464
15474
|
attributes: {
|
|
15475
|
+
/**
|
|
15476
|
+
* @category Attribute
|
|
15477
|
+
* @param {ColorValue} [color] - Text color value
|
|
15478
|
+
*/
|
|
15465
15479
|
color: {
|
|
15466
15480
|
default: null,
|
|
15467
15481
|
parseDOM: (el) => el.style.color?.replace(/['"]+/g, ""),
|
|
@@ -15480,17 +15494,16 @@ const Color = Extension.create({
|
|
|
15480
15494
|
* Set text color
|
|
15481
15495
|
* @category Command
|
|
15482
15496
|
* @param {ColorValue} color - Color value to apply
|
|
15497
|
+
* @returns {Function} Command function
|
|
15483
15498
|
* @example
|
|
15484
15499
|
* // Set to red using hex
|
|
15485
|
-
*
|
|
15500
|
+
* setColor('#ff0000')
|
|
15486
15501
|
*
|
|
15487
|
-
* @example
|
|
15488
15502
|
* // Set using rgb
|
|
15489
|
-
*
|
|
15503
|
+
* setColor('rgb(255, 0, 0)')
|
|
15490
15504
|
*
|
|
15491
|
-
* @example
|
|
15492
15505
|
* // Set using named color
|
|
15493
|
-
*
|
|
15506
|
+
* setColor('blue')
|
|
15494
15507
|
* @note Preserves other text styling attributes
|
|
15495
15508
|
*/
|
|
15496
15509
|
setColor: (color) => ({ chain }) => {
|
|
@@ -15499,8 +15512,9 @@ const Color = Extension.create({
|
|
|
15499
15512
|
/**
|
|
15500
15513
|
* Remove text color
|
|
15501
15514
|
* @category Command
|
|
15515
|
+
* @returns {Function} Command function
|
|
15502
15516
|
* @example
|
|
15503
|
-
*
|
|
15517
|
+
* unsetColor()
|
|
15504
15518
|
* @note Removes color while preserving other text styles
|
|
15505
15519
|
*/
|
|
15506
15520
|
unsetColor: () => ({ chain }) => {
|
|
@@ -15513,6 +15527,11 @@ const FontFamily = Extension.create({
|
|
|
15513
15527
|
name: "fontFamily",
|
|
15514
15528
|
addOptions() {
|
|
15515
15529
|
return {
|
|
15530
|
+
/**
|
|
15531
|
+
* @typedef {Object} FontFamilyOptions
|
|
15532
|
+
* @category Options
|
|
15533
|
+
* @property {string[]} [types=['textStyle']] - Mark types to add font family support to
|
|
15534
|
+
*/
|
|
15516
15535
|
types: ["textStyle"]
|
|
15517
15536
|
};
|
|
15518
15537
|
},
|
|
@@ -15521,6 +15540,10 @@ const FontFamily = Extension.create({
|
|
|
15521
15540
|
{
|
|
15522
15541
|
types: this.options.types,
|
|
15523
15542
|
attributes: {
|
|
15543
|
+
/**
|
|
15544
|
+
* @category Attribute
|
|
15545
|
+
* @param {FontFamilyValue} [fontFamily] - Font family for text
|
|
15546
|
+
*/
|
|
15524
15547
|
fontFamily: {
|
|
15525
15548
|
default: null,
|
|
15526
15549
|
parseDOM: (el) => el.style.fontFamily?.replace(/['"]+/g, ""),
|
|
@@ -15539,13 +15562,13 @@ const FontFamily = Extension.create({
|
|
|
15539
15562
|
* Set font family
|
|
15540
15563
|
* @category Command
|
|
15541
15564
|
* @param {FontFamilyValue} fontFamily - Font family to apply
|
|
15565
|
+
* @returns {Function} Command function
|
|
15542
15566
|
* @example
|
|
15543
15567
|
* // Set to Arial
|
|
15544
|
-
*
|
|
15568
|
+
* setFontFamily('Arial')
|
|
15545
15569
|
*
|
|
15546
|
-
* @example
|
|
15547
15570
|
* // Set to serif font
|
|
15548
|
-
*
|
|
15571
|
+
* setFontFamily('Georgia, serif')
|
|
15549
15572
|
* @note Preserves other text styling attributes
|
|
15550
15573
|
*/
|
|
15551
15574
|
setFontFamily: (fontFamily) => ({ chain }) => {
|
|
@@ -15554,8 +15577,9 @@ const FontFamily = Extension.create({
|
|
|
15554
15577
|
/**
|
|
15555
15578
|
* Remove font family
|
|
15556
15579
|
* @category Command
|
|
15580
|
+
* @returns {Function} Command function
|
|
15557
15581
|
* @example
|
|
15558
|
-
*
|
|
15582
|
+
* unsetFontFamily()
|
|
15559
15583
|
* @note Reverts to default document font
|
|
15560
15584
|
*/
|
|
15561
15585
|
unsetFontFamily: () => ({ chain }) => {
|
|
@@ -15568,6 +15592,12 @@ const FontSize = Extension.create({
|
|
|
15568
15592
|
name: "fontSize",
|
|
15569
15593
|
addOptions() {
|
|
15570
15594
|
return {
|
|
15595
|
+
/**
|
|
15596
|
+
* @typedef {Object} FontSizeOptions
|
|
15597
|
+
* @category Options
|
|
15598
|
+
* @property {string[]} [types=['textStyle', 'tableCell']] - Node/mark types to add font size support to
|
|
15599
|
+
* @property {FontSizeDefaults} [defaults] - Default size configuration
|
|
15600
|
+
*/
|
|
15571
15601
|
types: ["textStyle", "tableCell"],
|
|
15572
15602
|
defaults: {
|
|
15573
15603
|
value: 12,
|
|
@@ -15582,6 +15612,10 @@ const FontSize = Extension.create({
|
|
|
15582
15612
|
{
|
|
15583
15613
|
types: this.options.types,
|
|
15584
15614
|
attributes: {
|
|
15615
|
+
/**
|
|
15616
|
+
* @category Attribute
|
|
15617
|
+
* @param {FontSizeValue} [fontSize] - Font size with unit
|
|
15618
|
+
*/
|
|
15585
15619
|
fontSize: {
|
|
15586
15620
|
default: null,
|
|
15587
15621
|
parseDOM: (el) => el.style.fontSize,
|
|
@@ -15603,10 +15637,16 @@ const FontSize = Extension.create({
|
|
|
15603
15637
|
* Set font size
|
|
15604
15638
|
* @category Command
|
|
15605
15639
|
* @param {FontSizeValue} fontSize - Size to apply (with optional unit)
|
|
15640
|
+
* @returns {Function} Command function
|
|
15606
15641
|
* @example
|
|
15607
|
-
*
|
|
15608
|
-
*
|
|
15609
|
-
*
|
|
15642
|
+
* // Set to 14pt
|
|
15643
|
+
* setFontSize('14pt')
|
|
15644
|
+
*
|
|
15645
|
+
* // Set to 18px
|
|
15646
|
+
* setFontSize('18px')
|
|
15647
|
+
*
|
|
15648
|
+
* // Set without unit (uses default)
|
|
15649
|
+
* setFontSize(16)
|
|
15610
15650
|
* @note Automatically clamps to min/max values
|
|
15611
15651
|
*/
|
|
15612
15652
|
setFontSize: (fontSize) => ({ chain }) => {
|
|
@@ -15628,8 +15668,9 @@ const FontSize = Extension.create({
|
|
|
15628
15668
|
/**
|
|
15629
15669
|
* Remove font size
|
|
15630
15670
|
* @category Command
|
|
15671
|
+
* @returns {Function} Command function
|
|
15631
15672
|
* @example
|
|
15632
|
-
*
|
|
15673
|
+
* unsetFontSize()
|
|
15633
15674
|
* @note Reverts to default document size
|
|
15634
15675
|
*/
|
|
15635
15676
|
unsetFontSize: () => ({ chain }) => {
|
|
@@ -15679,9 +15720,13 @@ const TextAlign = Extension.create({
|
|
|
15679
15720
|
* Set text alignment
|
|
15680
15721
|
* @category Command
|
|
15681
15722
|
* @param {string} alignment - Alignment value (left, center, right, justify)
|
|
15723
|
+
* @returns {Function} Command function
|
|
15682
15724
|
* @example
|
|
15683
|
-
*
|
|
15684
|
-
*
|
|
15725
|
+
* // Set to center
|
|
15726
|
+
* setTextAlign('center')
|
|
15727
|
+
*
|
|
15728
|
+
* // Set to justify
|
|
15729
|
+
* setTextAlign('justify')
|
|
15685
15730
|
* @note Applies to all configured node types (heading, paragraph by default)
|
|
15686
15731
|
*/
|
|
15687
15732
|
setTextAlign: (alignment) => ({ commands: commands2 }) => {
|
|
@@ -15692,8 +15737,9 @@ const TextAlign = Extension.create({
|
|
|
15692
15737
|
/**
|
|
15693
15738
|
* Remove text alignment (reset to default)
|
|
15694
15739
|
* @category Command
|
|
15740
|
+
* @returns {Function} Command function
|
|
15695
15741
|
* @example
|
|
15696
|
-
*
|
|
15742
|
+
* unsetTextAlign()
|
|
15697
15743
|
* @note Resets alignment to the default value
|
|
15698
15744
|
*/
|
|
15699
15745
|
unsetTextAlign: () => ({ commands: commands2 }) => {
|
|
@@ -15834,6 +15880,13 @@ const LineHeight = Extension.create({
|
|
|
15834
15880
|
name: "lineHeight",
|
|
15835
15881
|
addOptions() {
|
|
15836
15882
|
return {
|
|
15883
|
+
/**
|
|
15884
|
+
* @typedef {Object} LineHeightOptions
|
|
15885
|
+
* @category Options
|
|
15886
|
+
* @property {string[]} [types=['heading', 'paragraph']] - Block types to add line height support to
|
|
15887
|
+
* @property {Object} [defaults] - Default configuration
|
|
15888
|
+
* @property {string} [defaults.unit=''] - Default unit for line height values
|
|
15889
|
+
*/
|
|
15837
15890
|
types: ["heading", "paragraph"],
|
|
15838
15891
|
defaults: {
|
|
15839
15892
|
unit: ""
|
|
@@ -15845,6 +15898,10 @@ const LineHeight = Extension.create({
|
|
|
15845
15898
|
{
|
|
15846
15899
|
types: this.options.types,
|
|
15847
15900
|
attributes: {
|
|
15901
|
+
/**
|
|
15902
|
+
* @category Attribute
|
|
15903
|
+
* @param {LineHeightValue} [lineHeight] - Line height value
|
|
15904
|
+
*/
|
|
15848
15905
|
lineHeight: {
|
|
15849
15906
|
default: null,
|
|
15850
15907
|
parseDOM: (el) => el.style.lineHeight,
|
|
@@ -15870,10 +15927,16 @@ const LineHeight = Extension.create({
|
|
|
15870
15927
|
* Set line height for blocks
|
|
15871
15928
|
* @category Command
|
|
15872
15929
|
* @param {LineHeightValue} lineHeight - Line height to apply
|
|
15930
|
+
* @returns {Function} Command function
|
|
15873
15931
|
* @example
|
|
15874
|
-
*
|
|
15875
|
-
*
|
|
15876
|
-
*
|
|
15932
|
+
* // Set to 1.5x spacing
|
|
15933
|
+
* setLineHeight(1.5)
|
|
15934
|
+
*
|
|
15935
|
+
* // Set to 24px spacing
|
|
15936
|
+
* setLineHeight('24px')
|
|
15937
|
+
*
|
|
15938
|
+
* // Set to double spacing
|
|
15939
|
+
* setLineHeight(2)
|
|
15877
15940
|
* @note Applies to paragraphs and headings
|
|
15878
15941
|
*/
|
|
15879
15942
|
setLineHeight: (lineHeight) => ({ commands: commands2 }) => {
|
|
@@ -15883,8 +15946,9 @@ const LineHeight = Extension.create({
|
|
|
15883
15946
|
/**
|
|
15884
15947
|
* Remove line height
|
|
15885
15948
|
* @category Command
|
|
15949
|
+
* @returns {Function} Command function
|
|
15886
15950
|
* @example
|
|
15887
|
-
*
|
|
15951
|
+
* unsetLineHeight()
|
|
15888
15952
|
* @note Reverts to default line spacing
|
|
15889
15953
|
*/
|
|
15890
15954
|
unsetLineHeight: () => ({ commands: commands2 }) => {
|
|
@@ -15912,8 +15976,9 @@ const FormatCommands = Extension.create({
|
|
|
15912
15976
|
/**
|
|
15913
15977
|
* Clear all formatting (nodes and marks)
|
|
15914
15978
|
* @category Command
|
|
15979
|
+
* @returns {Function} Command function
|
|
15915
15980
|
* @example
|
|
15916
|
-
*
|
|
15981
|
+
* clearFormat()
|
|
15917
15982
|
* @note Removes all marks and resets nodes to default paragraph
|
|
15918
15983
|
*/
|
|
15919
15984
|
clearFormat: () => ({ chain }) => {
|
|
@@ -15922,8 +15987,9 @@ const FormatCommands = Extension.create({
|
|
|
15922
15987
|
/**
|
|
15923
15988
|
* Clear only mark formatting
|
|
15924
15989
|
* @category Command
|
|
15990
|
+
* @returns {Function} Command function
|
|
15925
15991
|
* @example
|
|
15926
|
-
*
|
|
15992
|
+
* clearMarksFormat()
|
|
15927
15993
|
* @note Removes bold, italic, underline, colors, etc. but preserves block structure
|
|
15928
15994
|
*/
|
|
15929
15995
|
clearMarksFormat: () => ({ chain }) => {
|
|
@@ -15932,8 +15998,9 @@ const FormatCommands = Extension.create({
|
|
|
15932
15998
|
/**
|
|
15933
15999
|
* Clear only node formatting
|
|
15934
16000
|
* @category Command
|
|
16001
|
+
* @returns {Function} Command function
|
|
15935
16002
|
* @example
|
|
15936
|
-
*
|
|
16003
|
+
* clearNodesFormat()
|
|
15937
16004
|
* @note Converts headings, lists, etc. to paragraphs but preserves text marks
|
|
15938
16005
|
*/
|
|
15939
16006
|
clearNodesFormat: () => ({ chain }) => {
|
|
@@ -15942,8 +16009,13 @@ const FormatCommands = Extension.create({
|
|
|
15942
16009
|
/**
|
|
15943
16010
|
* Copy format from selection or apply copied format
|
|
15944
16011
|
* @category Command
|
|
16012
|
+
* @returns {Function} Command function
|
|
15945
16013
|
* @example
|
|
15946
|
-
*
|
|
16014
|
+
* // First call: copy format from selection
|
|
16015
|
+
* copyFormat()
|
|
16016
|
+
*
|
|
16017
|
+
* // Second call: apply copied format to new selection
|
|
16018
|
+
* copyFormat()
|
|
15947
16019
|
* @note Works like format painter - first click copies, second click applies
|
|
15948
16020
|
*/
|
|
15949
16021
|
copyFormat: () => ({ chain }) => {
|
|
@@ -15962,11 +16034,11 @@ const FormatCommands = Extension.create({
|
|
|
15962
16034
|
const { type, attrs } = mark;
|
|
15963
16035
|
const { name } = type;
|
|
15964
16036
|
if (name === "textStyle") {
|
|
15965
|
-
Object.keys(attrs).forEach((
|
|
15966
|
-
if (!attrs[
|
|
16037
|
+
Object.keys(attrs).forEach((key) => {
|
|
16038
|
+
if (!attrs[key]) return;
|
|
15967
16039
|
const attributes = {};
|
|
15968
|
-
attributes[
|
|
15969
|
-
processedMarks.push({ name:
|
|
16040
|
+
attributes[key] = attrs[key];
|
|
16041
|
+
processedMarks.push({ name: key, attrs: attributes });
|
|
15970
16042
|
});
|
|
15971
16043
|
} else {
|
|
15972
16044
|
processedMarks.push({ name, attrs });
|
|
@@ -15981,13 +16053,13 @@ const FormatCommands = Extension.create({
|
|
|
15981
16053
|
fontFamily: ["setFontFamily", "unsetFontFamily"]
|
|
15982
16054
|
};
|
|
15983
16055
|
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[
|
|
16056
|
+
Object.keys(marksToCommands).forEach((key) => {
|
|
16057
|
+
const [setCommand, unsetCommand, defaultParam] = marksToCommands[key];
|
|
16058
|
+
const markToApply = processedMarks.find((mark) => mark.name === key);
|
|
16059
|
+
const hasEmptyAttrs = markToApply?.attrs && markToApply?.attrs[key];
|
|
15988
16060
|
let cmd = {};
|
|
15989
16061
|
if (!markToApply && !hasEmptyAttrs) cmd = { command: unsetCommand, argument: defaultParam };
|
|
15990
|
-
else cmd = { command: setCommand, argument: markToApply.attrs[
|
|
16062
|
+
else cmd = { command: setCommand, argument: markToApply.attrs[key] || defaultParam };
|
|
15991
16063
|
result = result[cmd.command](cmd.argument);
|
|
15992
16064
|
});
|
|
15993
16065
|
this.storage.storedStyle = null;
|
|
@@ -16356,9 +16428,6 @@ function drawGapCursor(state) {
|
|
|
16356
16428
|
}
|
|
16357
16429
|
const Gapcursor = Extension.create({
|
|
16358
16430
|
name: "gapCursor",
|
|
16359
|
-
addOptions() {
|
|
16360
|
-
return {};
|
|
16361
|
-
},
|
|
16362
16431
|
addPmPlugins() {
|
|
16363
16432
|
return [gapCursor()];
|
|
16364
16433
|
},
|
|
@@ -16699,9 +16768,6 @@ function getCursorPositionRelativeToContainer(view, eventLocation) {
|
|
|
16699
16768
|
const SlashMenuPluginKey = new PluginKey("slashMenu");
|
|
16700
16769
|
const SlashMenu = Extension.create({
|
|
16701
16770
|
name: "slashMenu",
|
|
16702
|
-
addOptions() {
|
|
16703
|
-
return {};
|
|
16704
|
-
},
|
|
16705
16771
|
addPmPlugins() {
|
|
16706
16772
|
if (this.editor.options?.disableContextMenu) {
|
|
16707
16773
|
return [];
|
|
@@ -16839,6 +16905,11 @@ const Document = Node$1.create({
|
|
|
16839
16905
|
},
|
|
16840
16906
|
addAttributes() {
|
|
16841
16907
|
return {
|
|
16908
|
+
/**
|
|
16909
|
+
* @private
|
|
16910
|
+
* @category Attribute
|
|
16911
|
+
* @param {Object} [attributes] - Internal document attributes
|
|
16912
|
+
*/
|
|
16842
16913
|
attributes: {
|
|
16843
16914
|
rendered: false,
|
|
16844
16915
|
"aria-label": "Document node"
|
|
@@ -16850,10 +16921,10 @@ const Document = Node$1.create({
|
|
|
16850
16921
|
/**
|
|
16851
16922
|
* Get document statistics
|
|
16852
16923
|
* @category Command
|
|
16924
|
+
* @returns {Function} Command function
|
|
16853
16925
|
* @example
|
|
16854
16926
|
* // Get word and character count
|
|
16855
|
-
*
|
|
16856
|
-
* console.log(`${stats.words} words, ${stats.characters} characters`)
|
|
16927
|
+
* getDocumentStats()
|
|
16857
16928
|
* @note Returns word count, character count, and paragraph count
|
|
16858
16929
|
*/
|
|
16859
16930
|
getDocumentStats: () => ({ editor }) => {
|
|
@@ -16870,8 +16941,9 @@ const Document = Node$1.create({
|
|
|
16870
16941
|
/**
|
|
16871
16942
|
* Clear entire document
|
|
16872
16943
|
* @category Command
|
|
16944
|
+
* @returns {Function} Command function
|
|
16873
16945
|
* @example
|
|
16874
|
-
*
|
|
16946
|
+
* clearDocument()
|
|
16875
16947
|
* @note Replaces all content with an empty paragraph
|
|
16876
16948
|
*/
|
|
16877
16949
|
clearDocument: () => ({ commands: commands2 }) => {
|
|
@@ -16883,19 +16955,13 @@ const Document = Node$1.create({
|
|
|
16883
16955
|
const Text = Node$1.create({
|
|
16884
16956
|
name: "text",
|
|
16885
16957
|
group: "inline",
|
|
16886
|
-
inline: true
|
|
16887
|
-
addOptions() {
|
|
16888
|
-
return {};
|
|
16889
|
-
}
|
|
16958
|
+
inline: true
|
|
16890
16959
|
});
|
|
16891
16960
|
const RunItem = Node$1.create({
|
|
16892
16961
|
name: "run",
|
|
16893
16962
|
group: "inline",
|
|
16894
16963
|
content: "text*",
|
|
16895
16964
|
inline: true,
|
|
16896
|
-
addOptions() {
|
|
16897
|
-
return {};
|
|
16898
|
-
},
|
|
16899
16965
|
parseDOM() {
|
|
16900
16966
|
return [{ tag: "run" }];
|
|
16901
16967
|
},
|
|
@@ -16921,6 +16987,14 @@ const BulletList = Node$1.create({
|
|
|
16921
16987
|
},
|
|
16922
16988
|
addOptions() {
|
|
16923
16989
|
return {
|
|
16990
|
+
/**
|
|
16991
|
+
* @typedef {Object} BulletListOptions
|
|
16992
|
+
* @category Options
|
|
16993
|
+
* @property {string} [itemTypeName='listItem'] - Name of the list item node type
|
|
16994
|
+
* @property {Object} [htmlAttributes] - HTML attributes for the ul element
|
|
16995
|
+
* @property {boolean} [keepMarks=true] - Whether to preserve marks when splitting
|
|
16996
|
+
* @property {boolean} [keepAttributes=false] - Whether to preserve attributes when splitting
|
|
16997
|
+
*/
|
|
16924
16998
|
itemTypeName: "listItem",
|
|
16925
16999
|
htmlAttributes: {
|
|
16926
17000
|
"aria-label": "Bullet list node"
|
|
@@ -16938,13 +17012,27 @@ const BulletList = Node$1.create({
|
|
|
16938
17012
|
},
|
|
16939
17013
|
addAttributes() {
|
|
16940
17014
|
return {
|
|
17015
|
+
/**
|
|
17016
|
+
* @category Attribute
|
|
17017
|
+
* @param {string} [list-style-type='bullet'] - List style type for this list
|
|
17018
|
+
*/
|
|
16941
17019
|
"list-style-type": {
|
|
16942
17020
|
default: "bullet",
|
|
16943
17021
|
rendered: false
|
|
16944
17022
|
},
|
|
17023
|
+
/**
|
|
17024
|
+
* @private
|
|
17025
|
+
* @category Attribute
|
|
17026
|
+
* @param {string} [listId] - Internal list identifier for numbering
|
|
17027
|
+
*/
|
|
16945
17028
|
listId: {
|
|
16946
17029
|
rendered: false
|
|
16947
17030
|
},
|
|
17031
|
+
/**
|
|
17032
|
+
* @private
|
|
17033
|
+
* @category Attribute
|
|
17034
|
+
* @param {string} [sdBlockId] - Internal block tracking ID
|
|
17035
|
+
*/
|
|
16948
17036
|
sdBlockId: {
|
|
16949
17037
|
default: null,
|
|
16950
17038
|
keepOnSplit: false,
|
|
@@ -16953,6 +17041,11 @@ const BulletList = Node$1.create({
|
|
|
16953
17041
|
return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
|
|
16954
17042
|
}
|
|
16955
17043
|
},
|
|
17044
|
+
/**
|
|
17045
|
+
* @private
|
|
17046
|
+
* @category Attribute
|
|
17047
|
+
* @param {Object} [attributes] - Additional attributes for the list
|
|
17048
|
+
*/
|
|
16956
17049
|
attributes: {
|
|
16957
17050
|
rendered: false,
|
|
16958
17051
|
keepOnSplit: true
|
|
@@ -16964,9 +17057,10 @@ const BulletList = Node$1.create({
|
|
|
16964
17057
|
/**
|
|
16965
17058
|
* Toggle a bullet list at the current selection
|
|
16966
17059
|
* @category Command
|
|
17060
|
+
* @returns {Function} Command function
|
|
16967
17061
|
* @example
|
|
16968
17062
|
* // Toggle bullet list on selected text
|
|
16969
|
-
*
|
|
17063
|
+
* toggleBulletList()
|
|
16970
17064
|
* @note Converts selected paragraphs to list items or removes list formatting
|
|
16971
17065
|
*/
|
|
16972
17066
|
toggleBulletList: () => (params2) => {
|
|
@@ -17085,25 +17179,9 @@ const OrderedList = Node$1.create({
|
|
|
17085
17179
|
},
|
|
17086
17180
|
addCommands() {
|
|
17087
17181
|
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
17182
|
toggleOrderedList: () => (params2) => {
|
|
17096
17183
|
return toggleList(this.type)(params2);
|
|
17097
17184
|
},
|
|
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
17185
|
restartListNodes: (followingNodes, pos) => ({ tr }) => {
|
|
17108
17186
|
let currentNodePos = pos;
|
|
17109
17187
|
const nodes = followingNodes.map((node) => {
|
|
@@ -17122,11 +17200,8 @@ const OrderedList = Node$1.create({
|
|
|
17122
17200
|
return true;
|
|
17123
17201
|
},
|
|
17124
17202
|
/**
|
|
17125
|
-
*
|
|
17126
|
-
* @
|
|
17127
|
-
* @example
|
|
17128
|
-
* editor.commands.updateOrderedListStyleType()
|
|
17129
|
-
* @note Cycles through decimal -> lowerAlpha -> lowerRoman based on depth
|
|
17203
|
+
* Updates ordered list style type when sink or lift `listItem`.
|
|
17204
|
+
* @example 1,2,3 -> a,b,c -> i,ii,iii -> 1,2,3 -> etc
|
|
17130
17205
|
*/
|
|
17131
17206
|
updateOrderedListStyleType: () => ({ dispatch, tr }) => {
|
|
17132
17207
|
let list = findParentNode((node) => node.type.name === this.name)(tr.selection);
|
|
@@ -17403,7 +17478,7 @@ const CustomSelection = Extension.create({
|
|
|
17403
17478
|
* @returns {Function} Command function
|
|
17404
17479
|
* @example
|
|
17405
17480
|
* // Restore selection after toolbar interaction
|
|
17406
|
-
*
|
|
17481
|
+
* restorePreservedSelection()
|
|
17407
17482
|
* @note Used internally to maintain selection when interacting with toolbar
|
|
17408
17483
|
*/
|
|
17409
17484
|
restorePreservedSelection: () => ({ tr, state }) => {
|
|
@@ -17488,7 +17563,7 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
|
|
|
17488
17563
|
resultStyles["text-transform"] = basedOnDefinitionStyles["text-transform"];
|
|
17489
17564
|
}
|
|
17490
17565
|
Object.entries(resultStyles).forEach(([k, value]) => {
|
|
17491
|
-
const
|
|
17566
|
+
const key = kebabCase(k);
|
|
17492
17567
|
const flattenedMarks = [];
|
|
17493
17568
|
node?.marks?.forEach((n) => {
|
|
17494
17569
|
if (n.type.name === "textStyle") {
|
|
@@ -17499,46 +17574,46 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
|
|
|
17499
17574
|
});
|
|
17500
17575
|
return;
|
|
17501
17576
|
}
|
|
17502
|
-
flattenedMarks.push({ key: n.type.name, value: n.attrs[
|
|
17577
|
+
flattenedMarks.push({ key: n.type.name, value: n.attrs[key] });
|
|
17503
17578
|
});
|
|
17504
|
-
const mark = flattenedMarks.find((n) => n.key ===
|
|
17579
|
+
const mark = flattenedMarks.find((n) => n.key === key);
|
|
17505
17580
|
const hasParentIndent = Object.keys(parent?.attrs?.indent || {});
|
|
17506
17581
|
const hasParentSpacing = Object.keys(parent?.attrs?.spacing || {});
|
|
17507
17582
|
const listTypes = ["orderedList", "listItem"];
|
|
17508
17583
|
if (!mark) {
|
|
17509
|
-
if (
|
|
17584
|
+
if (key === "spacing" && includeSpacing && !hasParentSpacing) {
|
|
17510
17585
|
const space = getSpacingStyle(value);
|
|
17511
17586
|
Object.entries(space).forEach(([k2, v]) => {
|
|
17512
17587
|
markValue[k2] = v;
|
|
17513
17588
|
});
|
|
17514
|
-
} else if (
|
|
17589
|
+
} else if (key === "indent" && includeSpacing && !hasParentIndent) {
|
|
17515
17590
|
const { leftIndent, rightIndent, firstLine } = value;
|
|
17516
17591
|
if (leftIndent) markValue["margin-left"] = leftIndent + "px";
|
|
17517
17592
|
if (rightIndent) markValue["margin-right"] = rightIndent + "px";
|
|
17518
17593
|
if (firstLine) markValue["text-indent"] = firstLine + "px";
|
|
17519
|
-
} else if (
|
|
17594
|
+
} else if (key === "bold" && node) {
|
|
17520
17595
|
const val = value?.value;
|
|
17521
17596
|
if (!listTypes.includes(node.type.name) && val !== "0") {
|
|
17522
17597
|
markValue["font-weight"] = "bold";
|
|
17523
17598
|
}
|
|
17524
|
-
} else if (
|
|
17599
|
+
} else if (key === "text-transform" && node) {
|
|
17525
17600
|
if (!listTypes.includes(node.type.name)) {
|
|
17526
|
-
markValue[
|
|
17601
|
+
markValue[key] = value;
|
|
17527
17602
|
}
|
|
17528
|
-
} else if (
|
|
17603
|
+
} else if (key === "font-size" && node) {
|
|
17529
17604
|
if (!listTypes.includes(node.type.name)) {
|
|
17530
|
-
markValue[
|
|
17605
|
+
markValue[key] = value;
|
|
17531
17606
|
}
|
|
17532
|
-
} else if (
|
|
17607
|
+
} else if (key === "color" && node) {
|
|
17533
17608
|
if (!listTypes.includes(node.type.name)) {
|
|
17534
|
-
markValue[
|
|
17609
|
+
markValue[key] = value;
|
|
17535
17610
|
}
|
|
17536
17611
|
} else if (typeof value === "string") {
|
|
17537
|
-
markValue[
|
|
17612
|
+
markValue[key] = value;
|
|
17538
17613
|
}
|
|
17539
17614
|
}
|
|
17540
17615
|
});
|
|
17541
|
-
const final = Object.entries(markValue).map(([
|
|
17616
|
+
const final = Object.entries(markValue).map(([key, value]) => `${key}: ${value}`).join(";");
|
|
17542
17617
|
return final;
|
|
17543
17618
|
};
|
|
17544
17619
|
const applyLinkedStyleToTransaction = (tr, editor, style) => {
|
|
@@ -17692,9 +17767,6 @@ const LinkedStyles = Extension.create({
|
|
|
17692
17767
|
name: "linkedStyles",
|
|
17693
17768
|
priority: 1,
|
|
17694
17769
|
// We need this plugin to run before the list plugins
|
|
17695
|
-
addOptions() {
|
|
17696
|
-
return {};
|
|
17697
|
-
},
|
|
17698
17770
|
addPmPlugins() {
|
|
17699
17771
|
return [createLinkedStylesPlugin(this.editor)];
|
|
17700
17772
|
},
|
|
@@ -17703,10 +17775,11 @@ const LinkedStyles = Extension.create({
|
|
|
17703
17775
|
/**
|
|
17704
17776
|
* Apply a linked style to the selected paragraphs
|
|
17705
17777
|
* @category Command
|
|
17706
|
-
* @param {
|
|
17778
|
+
* @param {Object} style - The style object to apply
|
|
17779
|
+
* @returns {Function} Command function
|
|
17707
17780
|
* @example
|
|
17708
17781
|
* const style = editor.helpers.linkedStyles.getStyleById('Heading1');
|
|
17709
|
-
*
|
|
17782
|
+
* setLinkedStyle(style);
|
|
17710
17783
|
* @note Clears existing formatting when applying a style
|
|
17711
17784
|
* @note Works with custom selection preservation
|
|
17712
17785
|
*/
|
|
@@ -17717,12 +17790,16 @@ const LinkedStyles = Extension.create({
|
|
|
17717
17790
|
/**
|
|
17718
17791
|
* Toggle a linked style on the current selection
|
|
17719
17792
|
* @category Command
|
|
17720
|
-
* @param {
|
|
17793
|
+
* @param {Object} style - The linked style to apply (with id property)
|
|
17721
17794
|
* @param {string|null} [nodeType=null] - Node type to restrict toggle to (e.g., 'paragraph')
|
|
17795
|
+
* @returns {Function} Command function
|
|
17722
17796
|
* @example
|
|
17797
|
+
* // Toggle a heading style
|
|
17723
17798
|
* const style = editor.helpers.linkedStyles.getStyleById('Heading1');
|
|
17724
|
-
*
|
|
17725
|
-
*
|
|
17799
|
+
* toggleLinkedStyle(style)
|
|
17800
|
+
*
|
|
17801
|
+
* // Toggle only on paragraph nodes
|
|
17802
|
+
* toggleLinkedStyle(style, 'paragraph')
|
|
17726
17803
|
* @note If selection is empty, returns false
|
|
17727
17804
|
* @note Removes style if already applied, applies it if not
|
|
17728
17805
|
*/
|
|
@@ -17750,9 +17827,13 @@ const LinkedStyles = Extension.create({
|
|
|
17750
17827
|
* Apply a linked style by its ID
|
|
17751
17828
|
* @category Command
|
|
17752
17829
|
* @param {string} styleId - The style ID to apply (e.g., 'Heading1')
|
|
17830
|
+
* @returns {Function} Command function
|
|
17753
17831
|
* @example
|
|
17754
|
-
*
|
|
17755
|
-
*
|
|
17832
|
+
* // Apply a heading style
|
|
17833
|
+
* setStyleById('Heading1')
|
|
17834
|
+
*
|
|
17835
|
+
* // Apply a normal style
|
|
17836
|
+
* setStyleById('Normal')
|
|
17756
17837
|
* @note Looks up the style from loaded Word styles
|
|
17757
17838
|
*/
|
|
17758
17839
|
setStyleById: (styleId) => (params2) => {
|
|
@@ -18227,7 +18308,7 @@ function orderedListSync(editor) {
|
|
|
18227
18308
|
listNumberingType,
|
|
18228
18309
|
customFormat
|
|
18229
18310
|
};
|
|
18230
|
-
const keysChanged = Object.keys(updatedAttrs).some((
|
|
18311
|
+
const keysChanged = Object.keys(updatedAttrs).some((key) => node.attrs[key] !== updatedAttrs[key]);
|
|
18231
18312
|
if (keysChanged) {
|
|
18232
18313
|
tr.setNodeMarkup(pos, void 0, updatedAttrs);
|
|
18233
18314
|
}
|
|
@@ -18460,6 +18541,12 @@ const Paragraph = OxmlNode.create({
|
|
|
18460
18541
|
inline: false,
|
|
18461
18542
|
addOptions() {
|
|
18462
18543
|
return {
|
|
18544
|
+
/**
|
|
18545
|
+
* @typedef {Object} HeadingOptions
|
|
18546
|
+
* @category Options
|
|
18547
|
+
* @property {number[]} [headingLevels=[1,2,3,4,5,6]] - Supported heading levels
|
|
18548
|
+
* @property {Object} [htmlAttributes] - HTML attributes for paragraph elements
|
|
18549
|
+
*/
|
|
18463
18550
|
headingLevels: [1, 2, 3, 4, 5, 6],
|
|
18464
18551
|
htmlAttributes: {}
|
|
18465
18552
|
};
|
|
@@ -18691,6 +18778,11 @@ const Heading = Extension.create({
|
|
|
18691
18778
|
name: "heading",
|
|
18692
18779
|
addOptions() {
|
|
18693
18780
|
return {
|
|
18781
|
+
/**
|
|
18782
|
+
* @typedef {Object} HeadingOptions
|
|
18783
|
+
* @category Options
|
|
18784
|
+
* @property {number[]} [levels=[1,2,3,4,5,6]] - Supported heading levels
|
|
18785
|
+
*/
|
|
18694
18786
|
levels: [1, 2, 3, 4, 5, 6]
|
|
18695
18787
|
};
|
|
18696
18788
|
},
|
|
@@ -18700,8 +18792,10 @@ const Heading = Extension.create({
|
|
|
18700
18792
|
* Set a heading with specified level
|
|
18701
18793
|
* @category Command
|
|
18702
18794
|
* @param {HeadingAttributes} attributes - Heading attributes including level
|
|
18795
|
+
* @returns {Function} Command function
|
|
18703
18796
|
* @example
|
|
18704
|
-
*
|
|
18797
|
+
* // Set heading level 2
|
|
18798
|
+
* setHeading({ level: 2 })
|
|
18705
18799
|
* @note Converts current block to heading
|
|
18706
18800
|
*/
|
|
18707
18801
|
setHeading: (attributes) => ({ commands: commands2 }) => {
|
|
@@ -18713,9 +18807,13 @@ const Heading = Extension.create({
|
|
|
18713
18807
|
* Toggle between heading and paragraph
|
|
18714
18808
|
* @category Command
|
|
18715
18809
|
* @param {HeadingAttributes} attributes - Heading attributes including level
|
|
18810
|
+
* @returns {Function} Command function
|
|
18716
18811
|
* @example
|
|
18717
|
-
*
|
|
18718
|
-
*
|
|
18812
|
+
* // Toggle heading level 1
|
|
18813
|
+
* toggleHeading({ level: 1 })
|
|
18814
|
+
*
|
|
18815
|
+
* // Toggle heading level 3
|
|
18816
|
+
* toggleHeading({ level: 3 })
|
|
18719
18817
|
* @note Switches between heading and paragraph for the same level
|
|
18720
18818
|
*/
|
|
18721
18819
|
toggleHeading: (attributes) => ({ commands: commands2 }) => {
|
|
@@ -19120,9 +19218,6 @@ const LineBreak = Node$1.create({
|
|
|
19120
19218
|
selectable: false,
|
|
19121
19219
|
content: "",
|
|
19122
19220
|
atom: true,
|
|
19123
|
-
addOptions() {
|
|
19124
|
-
return {};
|
|
19125
|
-
},
|
|
19126
19221
|
parseDOM() {
|
|
19127
19222
|
return [{ tag: "br" }];
|
|
19128
19223
|
},
|
|
@@ -19131,7 +19226,17 @@ const LineBreak = Node$1.create({
|
|
|
19131
19226
|
},
|
|
19132
19227
|
addAttributes() {
|
|
19133
19228
|
return {
|
|
19229
|
+
/**
|
|
19230
|
+
* @private
|
|
19231
|
+
* @category Attribute
|
|
19232
|
+
* @param {string} [lineBreakType] - Type of line break - passthrough in this node
|
|
19233
|
+
*/
|
|
19134
19234
|
lineBreakType: { rendered: false },
|
|
19235
|
+
/**
|
|
19236
|
+
* @private
|
|
19237
|
+
* @category Attribute
|
|
19238
|
+
* @param {string} [clear] - Clear attribute - passthrough in this node
|
|
19239
|
+
*/
|
|
19135
19240
|
clear: { rendered: false }
|
|
19136
19241
|
};
|
|
19137
19242
|
},
|
|
@@ -19140,8 +19245,9 @@ const LineBreak = Node$1.create({
|
|
|
19140
19245
|
/**
|
|
19141
19246
|
* Insert a line break
|
|
19142
19247
|
* @category Command
|
|
19248
|
+
* @returns {Function} Command function
|
|
19143
19249
|
* @example
|
|
19144
|
-
*
|
|
19250
|
+
* insertLineBreak()
|
|
19145
19251
|
* @note Creates a soft break within the same paragraph
|
|
19146
19252
|
*/
|
|
19147
19253
|
insertLineBreak: () => ({ commands: commands2 }) => {
|
|
@@ -19158,6 +19264,11 @@ const HardBreak = Node$1.create({
|
|
|
19158
19264
|
atom: true,
|
|
19159
19265
|
addOptions() {
|
|
19160
19266
|
return {
|
|
19267
|
+
/**
|
|
19268
|
+
* @typedef {Object} HardBreakOptions
|
|
19269
|
+
* @category Options
|
|
19270
|
+
* @property {Object} [htmlAttributes] - HTML attributes for the break element
|
|
19271
|
+
*/
|
|
19161
19272
|
htmlAttributes: {
|
|
19162
19273
|
contentEditable: "false",
|
|
19163
19274
|
lineBreakType: "page",
|
|
@@ -19168,15 +19279,35 @@ const HardBreak = Node$1.create({
|
|
|
19168
19279
|
},
|
|
19169
19280
|
addAttributes() {
|
|
19170
19281
|
return {
|
|
19282
|
+
/**
|
|
19283
|
+
* @private
|
|
19284
|
+
* @category Attribute
|
|
19285
|
+
* @param {string} [pageBreakSource] - Source of the page break
|
|
19286
|
+
*/
|
|
19171
19287
|
pageBreakSource: {
|
|
19172
19288
|
rendered: false,
|
|
19173
19289
|
default: null
|
|
19174
19290
|
},
|
|
19291
|
+
/**
|
|
19292
|
+
* @private
|
|
19293
|
+
* @category Attribute
|
|
19294
|
+
* @param {string} [pageBreakType] - Type of page break
|
|
19295
|
+
*/
|
|
19175
19296
|
pageBreakType: {
|
|
19176
19297
|
default: null,
|
|
19177
19298
|
rendered: false
|
|
19178
19299
|
},
|
|
19300
|
+
/**
|
|
19301
|
+
* @private
|
|
19302
|
+
* @category Attribute
|
|
19303
|
+
* @param {string} [lineBreakType] - Type of line break - passthrough in this node
|
|
19304
|
+
*/
|
|
19179
19305
|
lineBreakType: { rendered: false },
|
|
19306
|
+
/**
|
|
19307
|
+
* @private
|
|
19308
|
+
* @category Attribute
|
|
19309
|
+
* @param {string} [clear] - Clear attribute - passthrough in this node
|
|
19310
|
+
*/
|
|
19180
19311
|
clear: { rendered: false }
|
|
19181
19312
|
};
|
|
19182
19313
|
},
|
|
@@ -19202,8 +19333,9 @@ const HardBreak = Node$1.create({
|
|
|
19202
19333
|
/**
|
|
19203
19334
|
* Insert a page break
|
|
19204
19335
|
* @category Command
|
|
19336
|
+
* @returns {Function} Command function
|
|
19205
19337
|
* @example
|
|
19206
|
-
*
|
|
19338
|
+
* insertPageBreak()
|
|
19207
19339
|
* @note Forces content to start on a new page when printed
|
|
19208
19340
|
*/
|
|
19209
19341
|
insertPageBreak: () => ({ commands: commands2 }) => {
|
|
@@ -19215,12 +19347,6 @@ const HardBreak = Node$1.create({
|
|
|
19215
19347
|
};
|
|
19216
19348
|
}
|
|
19217
19349
|
});
|
|
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
19350
|
const createTableView = ({ editor }) => {
|
|
19225
19351
|
return class TableView {
|
|
19226
19352
|
constructor(node, cellMinWidth) {
|
|
@@ -19309,11 +19435,11 @@ function updateTable(editor, node, table) {
|
|
|
19309
19435
|
const allExtensionsAttrs = editor.extensionService.attributes;
|
|
19310
19436
|
const tableExtensionAttrs = allExtensionsAttrs.filter((e) => e.type === "table");
|
|
19311
19437
|
const htmlAttributes = Attribute.getAttributesToRender(node, tableExtensionAttrs);
|
|
19312
|
-
Object.entries(htmlAttributes).forEach(([
|
|
19313
|
-
if (
|
|
19438
|
+
Object.entries(htmlAttributes).forEach(([key, value]) => {
|
|
19439
|
+
if (key === "style") {
|
|
19314
19440
|
table.style.cssText = value;
|
|
19315
19441
|
} else {
|
|
19316
|
-
table.setAttribute(
|
|
19442
|
+
table.setAttribute(key, value);
|
|
19317
19443
|
}
|
|
19318
19444
|
});
|
|
19319
19445
|
}
|
|
@@ -19381,55 +19507,26 @@ const createTable = (schema, rowsCount, colsCount, withHeaderRow, cellContent =
|
|
|
19381
19507
|
const tableBorders = createTableBorders();
|
|
19382
19508
|
return types.table.createChecked({ borders: tableBorders }, rows);
|
|
19383
19509
|
};
|
|
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
19510
|
var readFromCache;
|
|
19414
19511
|
var addToCache;
|
|
19415
19512
|
if (typeof WeakMap != "undefined") {
|
|
19416
19513
|
let cache = /* @__PURE__ */ new WeakMap();
|
|
19417
|
-
readFromCache = (
|
|
19418
|
-
addToCache = (
|
|
19419
|
-
cache.set(
|
|
19514
|
+
readFromCache = (key) => cache.get(key);
|
|
19515
|
+
addToCache = (key, value) => {
|
|
19516
|
+
cache.set(key, value);
|
|
19420
19517
|
return value;
|
|
19421
19518
|
};
|
|
19422
19519
|
} else {
|
|
19423
19520
|
const cache = [];
|
|
19424
19521
|
const cacheSize = 10;
|
|
19425
19522
|
let cachePos = 0;
|
|
19426
|
-
readFromCache = (
|
|
19523
|
+
readFromCache = (key) => {
|
|
19427
19524
|
for (let i = 0; i < cache.length; i += 2)
|
|
19428
|
-
if (cache[i] ==
|
|
19525
|
+
if (cache[i] == key) return cache[i + 1];
|
|
19429
19526
|
};
|
|
19430
|
-
addToCache = (
|
|
19527
|
+
addToCache = (key, value) => {
|
|
19431
19528
|
if (cachePos == cacheSize) cachePos = 0;
|
|
19432
|
-
cache[cachePos++] =
|
|
19529
|
+
cache[cachePos++] = key;
|
|
19433
19530
|
return cache[cachePos++] = value;
|
|
19434
19531
|
};
|
|
19435
19532
|
}
|
|
@@ -21593,6 +21690,17 @@ const Table = Node$1.create({
|
|
|
21593
21690
|
group: "block",
|
|
21594
21691
|
isolating: true,
|
|
21595
21692
|
tableRole: "table",
|
|
21693
|
+
/**
|
|
21694
|
+
* Table extension options
|
|
21695
|
+
* @category Options
|
|
21696
|
+
* @typedef {Object} TableOptions
|
|
21697
|
+
* @property {Object} [htmlAttributes={'aria-label': 'Table node'}] - Default HTML attributes for all tables
|
|
21698
|
+
* @property {boolean} [resizable=true] - Enable column resizing functionality
|
|
21699
|
+
* @property {number} [handleWidth=5] - Width of resize handles in pixels
|
|
21700
|
+
* @property {number} [cellMinWidth=10] - Minimum cell width constraint in pixels
|
|
21701
|
+
* @property {boolean} [lastColumnResizable=true] - Allow resizing of the last column
|
|
21702
|
+
* @property {boolean} [allowTableNodeSelection=false] - Enable selecting the entire table node
|
|
21703
|
+
*/
|
|
21596
21704
|
addOptions() {
|
|
21597
21705
|
return {
|
|
21598
21706
|
htmlAttributes: {
|
|
@@ -21652,8 +21760,8 @@ const Table = Node$1.create({
|
|
|
21652
21760
|
default: {},
|
|
21653
21761
|
renderDOM({ borders }) {
|
|
21654
21762
|
if (!borders) return {};
|
|
21655
|
-
const style = Object.entries(borders).reduce((acc, [
|
|
21656
|
-
return `${acc}border-${
|
|
21763
|
+
const style = Object.entries(borders).reduce((acc, [key, { size, color }]) => {
|
|
21764
|
+
return `${acc}border-${key}: ${Math.ceil(size)}px solid ${color || "black"};`;
|
|
21657
21765
|
}, "");
|
|
21658
21766
|
return {
|
|
21659
21767
|
style
|
|
@@ -21712,24 +21820,6 @@ const Table = Node$1.create({
|
|
|
21712
21820
|
tableCellSpacing: {
|
|
21713
21821
|
default: null,
|
|
21714
21822
|
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
21823
|
}
|
|
21734
21824
|
};
|
|
21735
21825
|
},
|
|
@@ -21750,9 +21840,14 @@ const Table = Node$1.create({
|
|
|
21750
21840
|
* Insert a new table into the document
|
|
21751
21841
|
* @category Command
|
|
21752
21842
|
* @param {TableConfig} [config] - Table configuration options
|
|
21843
|
+
* @returns {Function} Command
|
|
21753
21844
|
* @example
|
|
21754
|
-
*
|
|
21755
|
-
*
|
|
21845
|
+
* // Using default values
|
|
21846
|
+
* insertTable() // Creates 3x3 table without header
|
|
21847
|
+
*
|
|
21848
|
+
* // Using custom values
|
|
21849
|
+
* insertTable({ rows: 3, cols: 3, withHeaderRow: true })
|
|
21850
|
+
*
|
|
21756
21851
|
*/
|
|
21757
21852
|
insertTable: ({ rows = 3, cols = 3, withHeaderRow = false } = {}) => ({ tr, dispatch, editor }) => {
|
|
21758
21853
|
const node = createTable(editor.schema, rows, cols, withHeaderRow);
|
|
@@ -21765,8 +21860,9 @@ const Table = Node$1.create({
|
|
|
21765
21860
|
/**
|
|
21766
21861
|
* Delete the entire table containing the cursor
|
|
21767
21862
|
* @category Command
|
|
21863
|
+
* @returns {Function} Command
|
|
21768
21864
|
* @example
|
|
21769
|
-
*
|
|
21865
|
+
* deleteTable()
|
|
21770
21866
|
*/
|
|
21771
21867
|
deleteTable: () => ({ state, dispatch }) => {
|
|
21772
21868
|
return deleteTable(state, dispatch);
|
|
@@ -21774,8 +21870,9 @@ const Table = Node$1.create({
|
|
|
21774
21870
|
/**
|
|
21775
21871
|
* Add a column before the current column
|
|
21776
21872
|
* @category Command
|
|
21873
|
+
* @returns {Function} Command
|
|
21777
21874
|
* @example
|
|
21778
|
-
*
|
|
21875
|
+
* addColumnBefore()
|
|
21779
21876
|
* @note Preserves cell attributes from current column
|
|
21780
21877
|
*/
|
|
21781
21878
|
addColumnBefore: () => ({ state, dispatch, chain }) => {
|
|
@@ -22152,9 +22249,10 @@ const Table = Node$1.create({
|
|
|
22152
22249
|
* Set background color for selected cells
|
|
22153
22250
|
* @category Command
|
|
22154
22251
|
* @param {string} value - Color value (hex with or without #)
|
|
22252
|
+
* @returns {Function} Command
|
|
22155
22253
|
* @example
|
|
22156
|
-
*
|
|
22157
|
-
*
|
|
22254
|
+
* setCellBackground('#ff0000')
|
|
22255
|
+
* setCellBackground('ff0000')
|
|
22158
22256
|
*/
|
|
22159
22257
|
setCellBackground: (value) => ({ editor, commands: commands2, dispatch }) => {
|
|
22160
22258
|
const { selection } = editor.state;
|
|
@@ -22280,12 +22378,24 @@ const TableHeader = Node$1.create({
|
|
|
22280
22378
|
},
|
|
22281
22379
|
addAttributes() {
|
|
22282
22380
|
return {
|
|
22381
|
+
/**
|
|
22382
|
+
* @category Attribute
|
|
22383
|
+
* @param {number} [colspan=1] - Number of columns this header spans
|
|
22384
|
+
*/
|
|
22283
22385
|
colspan: {
|
|
22284
22386
|
default: 1
|
|
22285
22387
|
},
|
|
22388
|
+
/**
|
|
22389
|
+
* @category Attribute
|
|
22390
|
+
* @param {number} [rowspan=1] - Number of rows this header spans
|
|
22391
|
+
*/
|
|
22286
22392
|
rowspan: {
|
|
22287
22393
|
default: 1
|
|
22288
22394
|
},
|
|
22395
|
+
/**
|
|
22396
|
+
* @category Attribute
|
|
22397
|
+
* @param {number[]} [colwidth] - Column widths array in pixels
|
|
22398
|
+
*/
|
|
22289
22399
|
colwidth: {
|
|
22290
22400
|
default: null,
|
|
22291
22401
|
parseDOM: (element) => {
|
|
@@ -22322,6 +22432,10 @@ const TableRow = Node$1.create({
|
|
|
22322
22432
|
},
|
|
22323
22433
|
addAttributes() {
|
|
22324
22434
|
return {
|
|
22435
|
+
/**
|
|
22436
|
+
* @category Attribute
|
|
22437
|
+
* @param {number} [rowHeight] - Fixed row height in pixels
|
|
22438
|
+
*/
|
|
22325
22439
|
rowHeight: {
|
|
22326
22440
|
renderDOM({ rowHeight }) {
|
|
22327
22441
|
if (!rowHeight) return {};
|
|
@@ -22329,6 +22443,11 @@ const TableRow = Node$1.create({
|
|
|
22329
22443
|
return { style };
|
|
22330
22444
|
}
|
|
22331
22445
|
},
|
|
22446
|
+
/**
|
|
22447
|
+
* Indicates that this row should not be split across pages when paginating/exporting.
|
|
22448
|
+
* @category Attribute
|
|
22449
|
+
* @param {boolean} [cantSplit]
|
|
22450
|
+
*/
|
|
22332
22451
|
cantSplit: {
|
|
22333
22452
|
default: false,
|
|
22334
22453
|
parseDOM() {
|
|
@@ -22340,30 +22459,44 @@ const TableRow = Node$1.create({
|
|
|
22340
22459
|
}
|
|
22341
22460
|
},
|
|
22342
22461
|
/**
|
|
22462
|
+
* @category Attribute
|
|
22463
|
+
* @param {TableRowProperties} [tableRowProperties] - Properties for the table row.
|
|
22343
22464
|
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 377-482
|
|
22344
22465
|
*/
|
|
22345
22466
|
tableRowProperties: { rendered: false },
|
|
22346
22467
|
/**
|
|
22468
|
+
* @category Attribute
|
|
22469
|
+
* @param {string} [rsidDel] - Unique identifier used to track the editing session when the row was deleted from the main document.
|
|
22347
22470
|
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 472
|
|
22348
22471
|
*/
|
|
22349
22472
|
rsidDel: { rendered: false },
|
|
22350
22473
|
/**
|
|
22474
|
+
* @category Attribute
|
|
22475
|
+
* @param {string} [rsidR] - Unique identifier used to track the editing session when the table row was added to the main document.
|
|
22351
22476
|
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 472
|
|
22352
22477
|
*/
|
|
22353
22478
|
rsidR: { rendered: false },
|
|
22354
22479
|
/**
|
|
22480
|
+
* @category Attribute
|
|
22481
|
+
* @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
22482
|
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 473
|
|
22356
22483
|
*/
|
|
22357
22484
|
rsidRPr: { rendered: false },
|
|
22358
22485
|
/**
|
|
22486
|
+
* @category Attribute
|
|
22487
|
+
* @param {string} [rsidTr] - Unique identifier used to track the editing session when the table row's properties were last modified in this document.
|
|
22359
22488
|
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 473
|
|
22360
22489
|
*/
|
|
22361
22490
|
rsidTr: { rendered: false },
|
|
22362
22491
|
/**
|
|
22492
|
+
* @category Attribute
|
|
22493
|
+
* @param {string} [paraId] - A randomly generated unique identifier for the table row.
|
|
22363
22494
|
* @see {@link https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/a0e7d2e2-2246-44c6-96e8-1cf009823615}
|
|
22364
22495
|
*/
|
|
22365
22496
|
paraId: { rendered: false },
|
|
22366
22497
|
/**
|
|
22498
|
+
* @category Attribute
|
|
22499
|
+
* @param {string} [textId] - A randomly generated unique identifier for the text of the table row.
|
|
22367
22500
|
* @see {@link https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/b7eeddec-7c50-47fb-88b6-1feec3ed832c}
|
|
22368
22501
|
*/
|
|
22369
22502
|
textId: { rendered: false }
|
|
@@ -22390,12 +22523,24 @@ const TableCell = Node$1.create({
|
|
|
22390
22523
|
},
|
|
22391
22524
|
addAttributes() {
|
|
22392
22525
|
return {
|
|
22526
|
+
/**
|
|
22527
|
+
* @category Attribute
|
|
22528
|
+
* @param {number} [colspan=1] - Number of columns this cell spans
|
|
22529
|
+
*/
|
|
22393
22530
|
colspan: {
|
|
22394
22531
|
default: 1
|
|
22395
22532
|
},
|
|
22533
|
+
/**
|
|
22534
|
+
* @category Attribute
|
|
22535
|
+
* @param {number} [rowspan=1] - Number of rows this cell spans
|
|
22536
|
+
*/
|
|
22396
22537
|
rowspan: {
|
|
22397
22538
|
default: 1
|
|
22398
22539
|
},
|
|
22540
|
+
/**
|
|
22541
|
+
* @category Attribute
|
|
22542
|
+
* @param {number[]} [colwidth=[100]] - Column widths array in pixels
|
|
22543
|
+
*/
|
|
22399
22544
|
colwidth: {
|
|
22400
22545
|
default: [100],
|
|
22401
22546
|
parseDOM: (elem) => {
|
|
@@ -22410,6 +22555,10 @@ const TableCell = Node$1.create({
|
|
|
22410
22555
|
};
|
|
22411
22556
|
}
|
|
22412
22557
|
},
|
|
22558
|
+
/**
|
|
22559
|
+
* @category Attribute
|
|
22560
|
+
* @param {CellBackground} [background] - Cell background color configuration
|
|
22561
|
+
*/
|
|
22413
22562
|
background: {
|
|
22414
22563
|
renderDOM({ background }) {
|
|
22415
22564
|
if (!background) return {};
|
|
@@ -22418,6 +22567,10 @@ const TableCell = Node$1.create({
|
|
|
22418
22567
|
return { style };
|
|
22419
22568
|
}
|
|
22420
22569
|
},
|
|
22570
|
+
/**
|
|
22571
|
+
* @category Attribute
|
|
22572
|
+
* @param {string} [verticalAlign] - Vertical content alignment (top, middle, bottom)
|
|
22573
|
+
*/
|
|
22421
22574
|
verticalAlign: {
|
|
22422
22575
|
renderDOM({ verticalAlign }) {
|
|
22423
22576
|
if (!verticalAlign) return {};
|
|
@@ -22425,6 +22578,10 @@ const TableCell = Node$1.create({
|
|
|
22425
22578
|
return { style };
|
|
22426
22579
|
}
|
|
22427
22580
|
},
|
|
22581
|
+
/**
|
|
22582
|
+
* @category Attribute
|
|
22583
|
+
* @param {CellMargins} [cellMargins] - Internal cell padding
|
|
22584
|
+
*/
|
|
22428
22585
|
cellMargins: {
|
|
22429
22586
|
renderDOM({ cellMargins }) {
|
|
22430
22587
|
if (!cellMargins) return {};
|
|
@@ -22437,6 +22594,10 @@ const TableCell = Node$1.create({
|
|
|
22437
22594
|
return { style };
|
|
22438
22595
|
}
|
|
22439
22596
|
},
|
|
22597
|
+
/**
|
|
22598
|
+
* @category Attribute
|
|
22599
|
+
* @param {CellBorders} [borders] - Cell border configuration
|
|
22600
|
+
*/
|
|
22440
22601
|
borders: {
|
|
22441
22602
|
default: () => createCellBorders(),
|
|
22442
22603
|
renderDOM({ borders }) {
|
|
@@ -22451,10 +22612,20 @@ const TableCell = Node$1.create({
|
|
|
22451
22612
|
return { style };
|
|
22452
22613
|
}
|
|
22453
22614
|
},
|
|
22615
|
+
/**
|
|
22616
|
+
* @private
|
|
22617
|
+
* @category Attribute
|
|
22618
|
+
* @param {string} [widthType='auto'] - Internal width type
|
|
22619
|
+
*/
|
|
22454
22620
|
widthType: {
|
|
22455
22621
|
default: "auto",
|
|
22456
22622
|
rendered: false
|
|
22457
22623
|
},
|
|
22624
|
+
/**
|
|
22625
|
+
* @private
|
|
22626
|
+
* @category Attribute
|
|
22627
|
+
* @param {string} [widthUnit='px'] - Internal width unit
|
|
22628
|
+
*/
|
|
22458
22629
|
widthUnit: {
|
|
22459
22630
|
default: "px",
|
|
22460
22631
|
rendered: false
|
|
@@ -22705,11 +22876,11 @@ createAnnotation_fn = function({ displayLabel } = {}) {
|
|
|
22705
22876
|
let mergedAttrs = Attribute.mergeAttributes(this.htmlAttributes, {
|
|
22706
22877
|
style: omitHighlight ? "" : annotationStyle
|
|
22707
22878
|
});
|
|
22708
|
-
for (let [
|
|
22709
|
-
if (
|
|
22879
|
+
for (let [key, value] of Object.entries(mergedAttrs)) {
|
|
22880
|
+
if (key === "style") {
|
|
22710
22881
|
annotation.style.cssText = value;
|
|
22711
22882
|
} else {
|
|
22712
|
-
annotation.setAttribute(
|
|
22883
|
+
annotation.setAttribute(key, value);
|
|
22713
22884
|
}
|
|
22714
22885
|
}
|
|
22715
22886
|
return {
|
|
@@ -22883,13 +23054,13 @@ function hash$2(str) {
|
|
|
22883
23054
|
}
|
|
22884
23055
|
const colorToInt = (x) => parseInt(x.replace(/_/g, ""), 36);
|
|
22885
23056
|
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
|
|
23057
|
+
const key = colorToInt(next.substring(0, 3));
|
|
22887
23058
|
const hex = colorToInt(next.substring(3)).toString(16);
|
|
22888
23059
|
let prefix = "";
|
|
22889
23060
|
for (let i = 0; i < 6 - hex.length; i++) {
|
|
22890
23061
|
prefix += "0";
|
|
22891
23062
|
}
|
|
22892
|
-
acc[
|
|
23063
|
+
acc[key] = `${prefix}${hex}`;
|
|
22893
23064
|
return acc;
|
|
22894
23065
|
}, {});
|
|
22895
23066
|
function nameToHex(color) {
|
|
@@ -24005,552 +24176,41 @@ function getFormatAttrsFromMarks(marks) {
|
|
|
24005
24176
|
}
|
|
24006
24177
|
return formatAttrs;
|
|
24007
24178
|
}
|
|
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;
|
|
24179
|
+
const ImagePlaceholderPluginKey = new PluginKey("ImagePlaceholder");
|
|
24180
|
+
const ImagePlaceholderPlugin = () => {
|
|
24181
|
+
return new Plugin({
|
|
24182
|
+
key: ImagePlaceholderPluginKey,
|
|
24183
|
+
state: {
|
|
24184
|
+
init() {
|
|
24185
|
+
return DecorationSet.empty;
|
|
24186
|
+
},
|
|
24187
|
+
apply(tr, set) {
|
|
24188
|
+
set = set.map(tr.mapping, tr.doc);
|
|
24189
|
+
let action = tr.getMeta(ImagePlaceholderPluginKey);
|
|
24190
|
+
if (action?.type === "add") {
|
|
24191
|
+
let widget = document.createElement("placeholder");
|
|
24192
|
+
let deco = Decoration.widget(action.pos, widget, {
|
|
24193
|
+
id: action.id
|
|
24194
|
+
});
|
|
24195
|
+
set = set.add(tr.doc, [deco]);
|
|
24196
|
+
} else if (action?.type === "remove") {
|
|
24197
|
+
set = set.remove(set.find(null, null, (spec) => spec.id == action.id));
|
|
24198
|
+
}
|
|
24199
|
+
return set;
|
|
24200
|
+
}
|
|
24201
|
+
},
|
|
24202
|
+
props: {
|
|
24203
|
+
decorations(state) {
|
|
24204
|
+
return this.getState(state);
|
|
24476
24205
|
}
|
|
24477
24206
|
}
|
|
24478
24207
|
});
|
|
24479
24208
|
};
|
|
24480
24209
|
const findPlaceholder = (state, id) => {
|
|
24481
|
-
let
|
|
24482
|
-
let found =
|
|
24210
|
+
let decos = ImagePlaceholderPluginKey.getState(state);
|
|
24211
|
+
let found = decos?.find(null, null, (spec) => spec.id === id);
|
|
24483
24212
|
return found?.length ? found[0].from : null;
|
|
24484
24213
|
};
|
|
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
24214
|
const ImagePositionPluginKey = new PluginKey("ImagePosition");
|
|
24555
24215
|
const ImagePositionPlugin = ({ editor }) => {
|
|
24556
24216
|
const { view } = editor;
|
|
@@ -24657,19 +24317,6 @@ const findPreviousDomNodeWithClass = (view, pos, className) => {
|
|
|
24657
24317
|
}
|
|
24658
24318
|
return null;
|
|
24659
24319
|
};
|
|
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
24320
|
const Image = Node$1.create({
|
|
24674
24321
|
name: "image",
|
|
24675
24322
|
group: "inline",
|
|
@@ -24691,6 +24338,10 @@ const Image = Node$1.create({
|
|
|
24691
24338
|
},
|
|
24692
24339
|
addAttributes() {
|
|
24693
24340
|
return {
|
|
24341
|
+
/**
|
|
24342
|
+
* @category Attribute
|
|
24343
|
+
* @param {string} [src] - Image source URL or path
|
|
24344
|
+
*/
|
|
24694
24345
|
src: {
|
|
24695
24346
|
default: null,
|
|
24696
24347
|
renderDOM: ({ src }) => {
|
|
@@ -24699,75 +24350,95 @@ const Image = Node$1.create({
|
|
|
24699
24350
|
};
|
|
24700
24351
|
}
|
|
24701
24352
|
},
|
|
24353
|
+
/**
|
|
24354
|
+
* @category Attribute
|
|
24355
|
+
* @param {string} [alt='Uploaded picture'] - Alternative text for accessibility
|
|
24356
|
+
*/
|
|
24702
24357
|
alt: {
|
|
24703
24358
|
default: "Uploaded picture"
|
|
24704
24359
|
},
|
|
24360
|
+
/**
|
|
24361
|
+
* @category Attribute
|
|
24362
|
+
* @param {string} [id] - Image element ID
|
|
24363
|
+
* @private
|
|
24364
|
+
*/
|
|
24705
24365
|
id: { rendered: false },
|
|
24366
|
+
/**
|
|
24367
|
+
* @category Attribute
|
|
24368
|
+
* @param {string} [title] - Image title/tooltip text
|
|
24369
|
+
*/
|
|
24706
24370
|
title: {
|
|
24707
24371
|
default: null
|
|
24708
24372
|
},
|
|
24373
|
+
/**
|
|
24374
|
+
* @category Attribute
|
|
24375
|
+
* @param {string} [rId] - Relationship ID for Word export
|
|
24376
|
+
* @private
|
|
24377
|
+
*/
|
|
24709
24378
|
rId: {
|
|
24710
24379
|
default: null,
|
|
24711
24380
|
rendered: false
|
|
24712
24381
|
},
|
|
24382
|
+
/**
|
|
24383
|
+
* @category Attribute
|
|
24384
|
+
* @param {Object} [originalPadding] - Original padding values from Word import
|
|
24385
|
+
* @private
|
|
24386
|
+
*/
|
|
24713
24387
|
originalPadding: {
|
|
24714
24388
|
default: null,
|
|
24715
24389
|
rendered: false
|
|
24716
24390
|
},
|
|
24391
|
+
/**
|
|
24392
|
+
* @category Attribute
|
|
24393
|
+
* @param {Object} [originalAttributes] - Original attributes from Word import
|
|
24394
|
+
* @private
|
|
24395
|
+
*/
|
|
24717
24396
|
originalAttributes: { rendered: false },
|
|
24397
|
+
/**
|
|
24398
|
+
* @category Attribute
|
|
24399
|
+
* @param {boolean} [wrapTopAndBottom] - Wrap text above and below image
|
|
24400
|
+
* @private
|
|
24401
|
+
*/
|
|
24718
24402
|
wrapTopAndBottom: { rendered: false },
|
|
24403
|
+
/**
|
|
24404
|
+
* @category Attribute
|
|
24405
|
+
* @param {Object} [anchorData] - Anchor positioning data for Word
|
|
24406
|
+
* @private
|
|
24407
|
+
*/
|
|
24719
24408
|
anchorData: {
|
|
24720
24409
|
default: null,
|
|
24721
24410
|
rendered: false
|
|
24722
24411
|
},
|
|
24723
|
-
isAnchor: { rendered: false },
|
|
24724
24412
|
/**
|
|
24725
24413
|
* @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
|
-
*
|
|
24414
|
+
* @param {boolean} [isAnchor] - Whether image is anchored
|
|
24736
24415
|
* @private
|
|
24737
24416
|
*/
|
|
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
|
-
},
|
|
24417
|
+
isAnchor: { rendered: false },
|
|
24758
24418
|
/**
|
|
24759
24419
|
* @category Attribute
|
|
24760
24420
|
* @param {boolean} [simplePos] - Simple positioning flag
|
|
24761
24421
|
* @private
|
|
24762
24422
|
*/
|
|
24763
24423
|
simplePos: { rendered: false },
|
|
24424
|
+
/**
|
|
24425
|
+
* @category Attribute
|
|
24426
|
+
* @param {string} [wrapText] - Text wrapping style
|
|
24427
|
+
* @private
|
|
24428
|
+
*/
|
|
24764
24429
|
wrapText: { rendered: false },
|
|
24765
24430
|
extension: { rendered: false },
|
|
24431
|
+
/**
|
|
24432
|
+
* @category Attribute
|
|
24433
|
+
* @param {Object} [size] - Image dimensions
|
|
24434
|
+
* @param {number} [size.width] - Width in pixels
|
|
24435
|
+
* @param {number} [size.height] - Height in pixels
|
|
24436
|
+
*/
|
|
24766
24437
|
size: {
|
|
24767
24438
|
default: {},
|
|
24768
24439
|
renderDOM: ({ size, extension }) => {
|
|
24769
24440
|
let style = "";
|
|
24770
|
-
|
|
24441
|
+
const { width, height } = size ?? {};
|
|
24771
24442
|
if (width) style += `width: ${width}px;`;
|
|
24772
24443
|
if (height && ["emf", "wmf"].includes(extension))
|
|
24773
24444
|
style += `height: ${height}px; border: 1px solid black; position: absolute;`;
|
|
@@ -24775,58 +24446,51 @@ const Image = Node$1.create({
|
|
|
24775
24446
|
return { style };
|
|
24776
24447
|
}
|
|
24777
24448
|
},
|
|
24449
|
+
/**
|
|
24450
|
+
* @category Attribute
|
|
24451
|
+
* @param {Object} [padding] - Image padding/margins
|
|
24452
|
+
* @param {number} [padding.left] - Left padding in pixels
|
|
24453
|
+
* @param {number} [padding.top] - Top padding in pixels
|
|
24454
|
+
* @param {number} [padding.bottom] - Bottom padding in pixels
|
|
24455
|
+
* @param {number} [padding.right] - Right padding in pixels
|
|
24456
|
+
*/
|
|
24778
24457
|
padding: {
|
|
24779
24458
|
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
|
-
}
|
|
24459
|
+
renderDOM: ({ padding, marginOffset }) => {
|
|
24460
|
+
const { left: left2 = 0, top: top2 = 0, bottom: bottom2 = 0, right: right2 = 0 } = padding ?? {};
|
|
24791
24461
|
let style = "";
|
|
24792
|
-
if (left2 && marginOffset?.left
|
|
24793
|
-
if (top2 && marginOffset?.top
|
|
24462
|
+
if (left2 && !marginOffset?.left) style += `margin-left: ${left2}px;`;
|
|
24463
|
+
if (top2 && !marginOffset?.top) style += `margin-top: ${top2}px;`;
|
|
24794
24464
|
if (bottom2) style += `margin-bottom: ${bottom2}px;`;
|
|
24795
24465
|
if (right2) style += `margin-right: ${right2}px;`;
|
|
24796
24466
|
return { style };
|
|
24797
24467
|
}
|
|
24798
24468
|
},
|
|
24469
|
+
/**
|
|
24470
|
+
* @category Attribute
|
|
24471
|
+
* @param {Object} [marginOffset] - Margin offset for anchored images
|
|
24472
|
+
* @param {number} [marginOffset.left] - Left margin offset
|
|
24473
|
+
* @param {number} [marginOffset.top] - Top margin offset
|
|
24474
|
+
*/
|
|
24799
24475
|
marginOffset: {
|
|
24800
24476
|
default: {},
|
|
24801
|
-
renderDOM: ({ marginOffset, anchorData
|
|
24802
|
-
const hasAnchorData = Boolean(anchorData);
|
|
24803
|
-
const hasMarginOffsets = marginOffset?.left != null || marginOffset?.top != null;
|
|
24804
|
-
if (!hasAnchorData && !hasMarginOffsets) return {};
|
|
24477
|
+
renderDOM: ({ marginOffset, anchorData }) => {
|
|
24805
24478
|
const relativeFromPageV = anchorData?.vRelativeFrom === "page";
|
|
24806
24479
|
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;
|
|
24480
|
+
const { left: left2 = 0, top: top2 = 0 } = marginOffset ?? {};
|
|
24820
24481
|
let style = "";
|
|
24821
24482
|
if (left2) style += `margin-left: ${left2}px;`;
|
|
24822
24483
|
if (top2) {
|
|
24823
24484
|
if (relativeFromPageV && top2 >= maxMarginV) style += `margin-top: ${maxMarginV}px;`;
|
|
24824
24485
|
else style += `margin-top: ${top2}px;`;
|
|
24825
24486
|
}
|
|
24826
|
-
if (!style) return {};
|
|
24827
24487
|
return { style };
|
|
24828
24488
|
}
|
|
24829
24489
|
},
|
|
24490
|
+
/**
|
|
24491
|
+
* @category Attribute
|
|
24492
|
+
* @param {string} [style] - Custom inline CSS styles
|
|
24493
|
+
*/
|
|
24830
24494
|
style: {
|
|
24831
24495
|
default: null,
|
|
24832
24496
|
rendered: true,
|
|
@@ -24852,10 +24516,18 @@ const Image = Node$1.create({
|
|
|
24852
24516
|
/**
|
|
24853
24517
|
* Insert an image at the current position
|
|
24854
24518
|
* @category Command
|
|
24855
|
-
* @param {
|
|
24519
|
+
* @param {Object} options - Image attributes
|
|
24520
|
+
* @param {string} options.src - Image source URL or data URI
|
|
24521
|
+
* @param {string} [options.alt] - Alternative text
|
|
24522
|
+
* @param {string} [options.title] - Image title
|
|
24523
|
+
* @param {Object} [options.size] - Image dimensions
|
|
24524
|
+
* @returns {Function} Command function
|
|
24856
24525
|
* @example
|
|
24857
|
-
*
|
|
24858
|
-
*
|
|
24526
|
+
* // Insert an image from a URL
|
|
24527
|
+
* setImage({ src: 'https://example.com/image.jpg' })
|
|
24528
|
+
*
|
|
24529
|
+
* // Insert a base64 encoded image
|
|
24530
|
+
* setImage({
|
|
24859
24531
|
* src: 'data:image/png;base64,...',
|
|
24860
24532
|
* alt: 'Company logo',
|
|
24861
24533
|
* size: { width: 200 }
|
|
@@ -24871,7 +24543,7 @@ const Image = Node$1.create({
|
|
|
24871
24543
|
};
|
|
24872
24544
|
},
|
|
24873
24545
|
addPmPlugins() {
|
|
24874
|
-
return [
|
|
24546
|
+
return [ImagePlaceholderPlugin(), ImagePositionPlugin({ editor: this.editor })];
|
|
24875
24547
|
}
|
|
24876
24548
|
});
|
|
24877
24549
|
const ACCEPT_IMAGE_TYPES = [".jpg", ".jpeg", ".png", "image/jpeg", "image/png"];
|
|
@@ -24896,6 +24568,247 @@ const getFileOpener = () => {
|
|
|
24896
24568
|
};
|
|
24897
24569
|
return openFile;
|
|
24898
24570
|
};
|
|
24571
|
+
const handleImageUpload = (file) => {
|
|
24572
|
+
return new Promise((resolve, reject) => {
|
|
24573
|
+
let reader = new FileReader();
|
|
24574
|
+
reader.onload = (event) => {
|
|
24575
|
+
resolve(event.target.result);
|
|
24576
|
+
};
|
|
24577
|
+
reader.onerror = reject;
|
|
24578
|
+
setTimeout(() => reader.readAsDataURL(file), 250);
|
|
24579
|
+
});
|
|
24580
|
+
};
|
|
24581
|
+
const processUploadedImage = (fileData, editor) => {
|
|
24582
|
+
return new Promise((resolve, reject) => {
|
|
24583
|
+
const img = new window.Image();
|
|
24584
|
+
img.onload = () => {
|
|
24585
|
+
const canvas = document.createElement("canvas");
|
|
24586
|
+
const { width: logicalWidth, height: logicalHeight } = getAllowedImageDimensions(img.width, img.height, editor);
|
|
24587
|
+
canvas.width = img.width;
|
|
24588
|
+
canvas.height = img.height;
|
|
24589
|
+
const ctx = canvas.getContext("2d");
|
|
24590
|
+
if (ctx) {
|
|
24591
|
+
ctx.imageSmoothingEnabled = true;
|
|
24592
|
+
try {
|
|
24593
|
+
ctx.imageSmoothingQuality = "high";
|
|
24594
|
+
} catch {
|
|
24595
|
+
}
|
|
24596
|
+
}
|
|
24597
|
+
ctx.drawImage(img, 0, 0, img.width, img.height);
|
|
24598
|
+
const dpr = typeof window !== "undefined" && window.devicePixelRatio ? window.devicePixelRatio : 1;
|
|
24599
|
+
const targetPixelWidth = Math.round(logicalWidth * dpr);
|
|
24600
|
+
const targetPixelHeight = Math.round(logicalHeight * dpr);
|
|
24601
|
+
const finalTargetWidth = Math.min(targetPixelWidth, img.width);
|
|
24602
|
+
const finalTargetHeight = Math.min(targetPixelHeight, img.height);
|
|
24603
|
+
const resizeNeeded = finalTargetWidth !== img.width || finalTargetHeight !== img.height;
|
|
24604
|
+
if (resizeNeeded) {
|
|
24605
|
+
multiStepResize(canvas, finalTargetWidth, finalTargetHeight);
|
|
24606
|
+
}
|
|
24607
|
+
if (typeof fileData === "string") {
|
|
24608
|
+
const resizedBase64 = canvas.toDataURL();
|
|
24609
|
+
resolve(resizedBase64);
|
|
24610
|
+
} else {
|
|
24611
|
+
canvas.toBlob((blob) => {
|
|
24612
|
+
const updatedFile = new File([blob], fileData.name, {
|
|
24613
|
+
type: fileData.type,
|
|
24614
|
+
lastModified: Date.now()
|
|
24615
|
+
});
|
|
24616
|
+
resolve({ file: updatedFile, width: logicalWidth, height: logicalHeight });
|
|
24617
|
+
});
|
|
24618
|
+
}
|
|
24619
|
+
};
|
|
24620
|
+
img.onerror = (error) => reject(error);
|
|
24621
|
+
img.src = typeof fileData === "string" ? fileData : URL.createObjectURL(fileData);
|
|
24622
|
+
});
|
|
24623
|
+
};
|
|
24624
|
+
const getAllowedImageDimensions = (width, height, editor) => {
|
|
24625
|
+
const { width: maxWidth, height: maxHeight } = editor.getMaxContentSize();
|
|
24626
|
+
if (!maxWidth || !maxHeight) return { width, height };
|
|
24627
|
+
let adjustedWidth = width;
|
|
24628
|
+
let adjustedHeight = height;
|
|
24629
|
+
const aspectRatio = width / height;
|
|
24630
|
+
if (height > maxHeight) {
|
|
24631
|
+
adjustedHeight = maxHeight;
|
|
24632
|
+
adjustedWidth = Math.round(maxHeight * aspectRatio);
|
|
24633
|
+
}
|
|
24634
|
+
if (adjustedWidth > maxWidth) {
|
|
24635
|
+
adjustedWidth = maxWidth;
|
|
24636
|
+
adjustedHeight = Math.round(maxWidth / aspectRatio);
|
|
24637
|
+
}
|
|
24638
|
+
return { width: adjustedWidth, height: adjustedHeight };
|
|
24639
|
+
};
|
|
24640
|
+
function resample_high_quality(canvas, width, height, resize_canvas) {
|
|
24641
|
+
var width_source = canvas.width;
|
|
24642
|
+
var height_source = canvas.height;
|
|
24643
|
+
width = Math.round(width);
|
|
24644
|
+
height = Math.round(height);
|
|
24645
|
+
var ratio_w = width_source / width;
|
|
24646
|
+
var ratio_h = height_source / height;
|
|
24647
|
+
var ratio_w_half = Math.ceil(ratio_w / 2);
|
|
24648
|
+
var ratio_h_half = Math.ceil(ratio_h / 2);
|
|
24649
|
+
var ctx = canvas.getContext("2d");
|
|
24650
|
+
var img = ctx.getImageData(0, 0, width_source, height_source);
|
|
24651
|
+
var img2 = ctx.createImageData(width, height);
|
|
24652
|
+
var data = img.data;
|
|
24653
|
+
var data2 = img2.data;
|
|
24654
|
+
for (var j = 0; j < height; j++) {
|
|
24655
|
+
for (var i = 0; i < width; i++) {
|
|
24656
|
+
var x2 = (i + j * width) * 4;
|
|
24657
|
+
var weight = 0;
|
|
24658
|
+
var weights = 0;
|
|
24659
|
+
var weights_alpha = 0;
|
|
24660
|
+
var gx_r = 0;
|
|
24661
|
+
var gx_g = 0;
|
|
24662
|
+
var gx_b = 0;
|
|
24663
|
+
var gx_a = 0;
|
|
24664
|
+
var center_y = (j + 0.5) * ratio_h;
|
|
24665
|
+
var yy_start = Math.floor(j * ratio_h);
|
|
24666
|
+
var yy_stop = Math.ceil((j + 1) * ratio_h);
|
|
24667
|
+
for (var yy = yy_start; yy < yy_stop; yy++) {
|
|
24668
|
+
var dy = Math.abs(center_y - (yy + 0.5)) / ratio_h_half;
|
|
24669
|
+
var center_x = (i + 0.5) * ratio_w;
|
|
24670
|
+
var w0 = dy * dy;
|
|
24671
|
+
var xx_start = Math.floor(i * ratio_w);
|
|
24672
|
+
var xx_stop = Math.ceil((i + 1) * ratio_w);
|
|
24673
|
+
for (var xx = xx_start; xx < xx_stop; xx++) {
|
|
24674
|
+
var dx = Math.abs(center_x - (xx + 0.5)) / ratio_w_half;
|
|
24675
|
+
var w = Math.sqrt(w0 + dx * dx);
|
|
24676
|
+
if (w >= 1) {
|
|
24677
|
+
continue;
|
|
24678
|
+
}
|
|
24679
|
+
weight = 2 * w * w * w - 3 * w * w + 1;
|
|
24680
|
+
var pos_x = 4 * (xx + yy * width_source);
|
|
24681
|
+
gx_a += weight * data[pos_x + 3];
|
|
24682
|
+
weights_alpha += weight;
|
|
24683
|
+
if (data[pos_x + 3] < 255) weight = weight * data[pos_x + 3] / 250;
|
|
24684
|
+
gx_r += weight * data[pos_x];
|
|
24685
|
+
gx_g += weight * data[pos_x + 1];
|
|
24686
|
+
gx_b += weight * data[pos_x + 2];
|
|
24687
|
+
weights += weight;
|
|
24688
|
+
}
|
|
24689
|
+
}
|
|
24690
|
+
data2[x2] = gx_r / weights;
|
|
24691
|
+
data2[x2 + 1] = gx_g / weights;
|
|
24692
|
+
data2[x2 + 2] = gx_b / weights;
|
|
24693
|
+
data2[x2 + 3] = gx_a / weights_alpha;
|
|
24694
|
+
}
|
|
24695
|
+
}
|
|
24696
|
+
{
|
|
24697
|
+
canvas.width = width;
|
|
24698
|
+
canvas.height = height;
|
|
24699
|
+
}
|
|
24700
|
+
ctx.putImageData(img2, 0, 0);
|
|
24701
|
+
}
|
|
24702
|
+
function multiStepResize(canvas, targetWidth, targetHeight) {
|
|
24703
|
+
const originalWidth = canvas.width;
|
|
24704
|
+
const originalHeight = canvas.height;
|
|
24705
|
+
const scaleX = targetWidth / originalWidth;
|
|
24706
|
+
const scaleY = targetHeight / originalHeight;
|
|
24707
|
+
const scaleFactor = Math.min(scaleX, scaleY);
|
|
24708
|
+
if (scaleFactor < 0.5) {
|
|
24709
|
+
let currentWidth = originalWidth;
|
|
24710
|
+
let currentHeight = originalHeight;
|
|
24711
|
+
while (currentWidth > targetWidth * 2 || currentHeight > targetHeight * 2) {
|
|
24712
|
+
const nextWidth = Math.round(currentWidth / 2);
|
|
24713
|
+
const nextHeight = Math.round(currentHeight / 2);
|
|
24714
|
+
resample_high_quality(canvas, nextWidth, nextHeight);
|
|
24715
|
+
currentWidth = nextWidth;
|
|
24716
|
+
currentHeight = nextHeight;
|
|
24717
|
+
}
|
|
24718
|
+
if (currentWidth !== targetWidth || currentHeight !== targetHeight) {
|
|
24719
|
+
resample_high_quality(canvas, targetWidth, targetHeight);
|
|
24720
|
+
}
|
|
24721
|
+
} else {
|
|
24722
|
+
resample_high_quality(canvas, targetWidth, targetHeight);
|
|
24723
|
+
}
|
|
24724
|
+
}
|
|
24725
|
+
const startImageUpload = async ({ editor, view, file }) => {
|
|
24726
|
+
const imageUploadHandler = typeof editor.options.handleImageUpload === "function" ? editor.options.handleImageUpload : handleImageUpload;
|
|
24727
|
+
let fileSizeMb = Number((file.size / (1024 * 1024)).toFixed(4));
|
|
24728
|
+
if (fileSizeMb > 5) {
|
|
24729
|
+
window.alert("Image size must be less than 5MB");
|
|
24730
|
+
return;
|
|
24731
|
+
}
|
|
24732
|
+
let width;
|
|
24733
|
+
let height;
|
|
24734
|
+
try {
|
|
24735
|
+
const processedImageResult = await processUploadedImage(file, editor);
|
|
24736
|
+
width = processedImageResult.width;
|
|
24737
|
+
height = processedImageResult.height;
|
|
24738
|
+
file = processedImageResult.file;
|
|
24739
|
+
} catch (err) {
|
|
24740
|
+
console.warn("Error processing image:", err);
|
|
24741
|
+
editor.emit("exception", { error: err, editor });
|
|
24742
|
+
return;
|
|
24743
|
+
}
|
|
24744
|
+
await uploadImage({
|
|
24745
|
+
editor,
|
|
24746
|
+
view,
|
|
24747
|
+
file,
|
|
24748
|
+
size: { width, height },
|
|
24749
|
+
uploadHandler: imageUploadHandler
|
|
24750
|
+
});
|
|
24751
|
+
};
|
|
24752
|
+
async function uploadImage({ editor, view, file, size, uploadHandler }) {
|
|
24753
|
+
let id = {};
|
|
24754
|
+
let { tr, schema } = view.state;
|
|
24755
|
+
let { selection } = tr;
|
|
24756
|
+
if (editor.options.isHeaderOrFooter) {
|
|
24757
|
+
selection = editor.options.lastSelection;
|
|
24758
|
+
}
|
|
24759
|
+
if (!selection.empty && !editor.options.isHeaderOrFooter) {
|
|
24760
|
+
tr.deleteSelection();
|
|
24761
|
+
}
|
|
24762
|
+
let imageMeta = {
|
|
24763
|
+
type: "add",
|
|
24764
|
+
pos: selection.from,
|
|
24765
|
+
id
|
|
24766
|
+
};
|
|
24767
|
+
tr.setMeta(ImagePlaceholderPluginKey, imageMeta);
|
|
24768
|
+
view.dispatch(tr);
|
|
24769
|
+
try {
|
|
24770
|
+
let url = await uploadHandler(file);
|
|
24771
|
+
let fileName = file.name.replace(" ", "_");
|
|
24772
|
+
let placeholderPos = findPlaceholder(view.state, id);
|
|
24773
|
+
if (placeholderPos == null) {
|
|
24774
|
+
return;
|
|
24775
|
+
}
|
|
24776
|
+
let removeMeta = { type: "remove", id };
|
|
24777
|
+
let mediaPath = `word/media/${fileName}`;
|
|
24778
|
+
let rId = null;
|
|
24779
|
+
if (editor.options.mode === "docx") {
|
|
24780
|
+
const [, path] = mediaPath.split("word/");
|
|
24781
|
+
const imageid = addImageRelationship({ editor, path });
|
|
24782
|
+
if (imageid) rId = imageid;
|
|
24783
|
+
}
|
|
24784
|
+
let imageNode = schema.nodes.image.create({
|
|
24785
|
+
src: mediaPath,
|
|
24786
|
+
size,
|
|
24787
|
+
rId
|
|
24788
|
+
});
|
|
24789
|
+
editor.storage.image.media = Object.assign(editor.storage.image.media, { [mediaPath]: url });
|
|
24790
|
+
if (editor.options.ydoc) {
|
|
24791
|
+
editor.commands.addImageToCollaboration({ mediaPath, fileData: url });
|
|
24792
|
+
}
|
|
24793
|
+
view.dispatch(
|
|
24794
|
+
view.state.tr.replaceWith(placeholderPos, placeholderPos, imageNode).setMeta(ImagePlaceholderPluginKey, removeMeta)
|
|
24795
|
+
);
|
|
24796
|
+
} catch (error) {
|
|
24797
|
+
let removeMeta = { type: "remove", id };
|
|
24798
|
+
view.dispatch(tr.setMeta(ImagePlaceholderPluginKey, removeMeta));
|
|
24799
|
+
editor.emit("exception", { error, editor });
|
|
24800
|
+
}
|
|
24801
|
+
}
|
|
24802
|
+
function addImageRelationship({ editor, path }) {
|
|
24803
|
+
const target = path;
|
|
24804
|
+
const type = "image";
|
|
24805
|
+
try {
|
|
24806
|
+
const relationshipId = insertNewRelationship(target, type, editor);
|
|
24807
|
+
return relationshipId;
|
|
24808
|
+
} catch {
|
|
24809
|
+
return null;
|
|
24810
|
+
}
|
|
24811
|
+
}
|
|
24899
24812
|
const BookmarkStart = Node$1.create({
|
|
24900
24813
|
name: "bookmarkStart",
|
|
24901
24814
|
group: "inline",
|
|
@@ -24992,81 +24905,6 @@ const BookmarkStart = Node$1.create({
|
|
|
24992
24905
|
};
|
|
24993
24906
|
}
|
|
24994
24907
|
});
|
|
24995
|
-
const BookmarkEnd = Node$1.create({
|
|
24996
|
-
name: "bookmarkEnd",
|
|
24997
|
-
group: "inline",
|
|
24998
|
-
inline: true,
|
|
24999
|
-
atom: true,
|
|
25000
|
-
addOptions() {
|
|
25001
|
-
return {
|
|
25002
|
-
/**
|
|
25003
|
-
* @typedef {Object} BookmarkEndOptions
|
|
25004
|
-
* @category Options
|
|
25005
|
-
* @property {Object} [htmlAttributes] - HTML attributes for the bookmark end element
|
|
25006
|
-
*/
|
|
25007
|
-
htmlAttributes: {
|
|
25008
|
-
style: "height: 0; width: 0; display: none;",
|
|
25009
|
-
"aria-label": "Bookmark end node",
|
|
25010
|
-
role: "none"
|
|
25011
|
-
}
|
|
25012
|
-
};
|
|
25013
|
-
},
|
|
25014
|
-
addAttributes() {
|
|
25015
|
-
return {
|
|
25016
|
-
/**
|
|
25017
|
-
* @category Attribute
|
|
25018
|
-
* @param {string} [id] - Unique identifier matching the corresponding bookmarkStart
|
|
25019
|
-
*/
|
|
25020
|
-
id: {
|
|
25021
|
-
default: null,
|
|
25022
|
-
renderDOM: ({ id }) => {
|
|
25023
|
-
if (id) return { "data-bookmark-end-id": id };
|
|
25024
|
-
return {};
|
|
25025
|
-
}
|
|
25026
|
-
},
|
|
25027
|
-
/**
|
|
25028
|
-
* @category Attribute
|
|
25029
|
-
* @param {string} [displacedByCustomXml] - Indicates if bookmark was displaced by custom XML
|
|
25030
|
-
*/
|
|
25031
|
-
displacedByCustomXml: {
|
|
25032
|
-
default: null,
|
|
25033
|
-
renderDOM: ({ displacedByCustomXml }) => {
|
|
25034
|
-
if (displacedByCustomXml) return { "data-displaced-by-custom-xml": displacedByCustomXml };
|
|
25035
|
-
return {};
|
|
25036
|
-
}
|
|
25037
|
-
},
|
|
25038
|
-
// Pass-through attributes that may not be used in rendering but should be preserved
|
|
25039
|
-
colFirst: {
|
|
25040
|
-
default: null
|
|
25041
|
-
},
|
|
25042
|
-
colLast: {
|
|
25043
|
-
default: null
|
|
25044
|
-
}
|
|
25045
|
-
};
|
|
25046
|
-
},
|
|
25047
|
-
renderDOM({ htmlAttributes }) {
|
|
25048
|
-
return ["span", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
25049
|
-
},
|
|
25050
|
-
addCommands() {
|
|
25051
|
-
return {
|
|
25052
|
-
/**
|
|
25053
|
-
* Insert a bookmark end marker at the current position
|
|
25054
|
-
* @category Command
|
|
25055
|
-
* @param {string} id - The bookmark ID to match with bookmarkStart
|
|
25056
|
-
* @returns {Function} Command function
|
|
25057
|
-
* @example
|
|
25058
|
-
* // Insert bookmark end
|
|
25059
|
-
* insertBookmarkEnd('bookmark-001')
|
|
25060
|
-
*/
|
|
25061
|
-
insertBookmarkEnd: (id) => ({ commands: commands2 }) => {
|
|
25062
|
-
return commands2.insertContent({
|
|
25063
|
-
type: this.name,
|
|
25064
|
-
attrs: { id }
|
|
25065
|
-
});
|
|
25066
|
-
}
|
|
25067
|
-
};
|
|
25068
|
-
}
|
|
25069
|
-
});
|
|
25070
24908
|
const Mention = Node$1.create({
|
|
25071
24909
|
name: "mention",
|
|
25072
24910
|
group: "inline",
|
|
@@ -25147,14 +24985,6 @@ const PageNumber = Node$1.create({
|
|
|
25147
24985
|
},
|
|
25148
24986
|
addCommands() {
|
|
25149
24987
|
return {
|
|
25150
|
-
/**
|
|
25151
|
-
* Insert an automatic page number
|
|
25152
|
-
* @category Command
|
|
25153
|
-
* @returns {Function} Command function
|
|
25154
|
-
* @example
|
|
25155
|
-
* editor.commands.addAutoPageNumber()
|
|
25156
|
-
* @note Only works in header/footer contexts
|
|
25157
|
-
*/
|
|
25158
24988
|
addAutoPageNumber: () => ({ tr, dispatch, state, editor }) => {
|
|
25159
24989
|
const { options } = editor;
|
|
25160
24990
|
if (!options.isHeaderOrFooter) return false;
|
|
@@ -25217,14 +25047,6 @@ const TotalPageCount = Node$1.create({
|
|
|
25217
25047
|
},
|
|
25218
25048
|
addCommands() {
|
|
25219
25049
|
return {
|
|
25220
|
-
/**
|
|
25221
|
-
* Insert total page count
|
|
25222
|
-
* @category Command
|
|
25223
|
-
* @returns {Function} Command function
|
|
25224
|
-
* @example
|
|
25225
|
-
* editor.commands.addTotalPageCount()
|
|
25226
|
-
* @note Only works in header/footer contexts
|
|
25227
|
-
*/
|
|
25228
25050
|
addTotalPageCount: () => ({ tr, dispatch, state, editor }) => {
|
|
25229
25051
|
const { options } = editor;
|
|
25230
25052
|
if (!options.isHeaderOrFooter) return false;
|
|
@@ -25301,8 +25123,8 @@ renderDom_fn = function(node, htmlAttributes) {
|
|
|
25301
25123
|
__privateMethod(this, _AutoPageNumberNodeView_instances, scheduleUpdateNodeStyle_fn).call(this, currentPos, marks);
|
|
25302
25124
|
Object.assign(nodeContent.style, styles);
|
|
25303
25125
|
nodeContent.appendChild(content);
|
|
25304
|
-
Object.entries(htmlAttributes).forEach(([
|
|
25305
|
-
if (value) nodeContent.setAttribute(
|
|
25126
|
+
Object.entries(htmlAttributes).forEach(([key, value]) => {
|
|
25127
|
+
if (value) nodeContent.setAttribute(key, value);
|
|
25306
25128
|
});
|
|
25307
25129
|
return nodeContent;
|
|
25308
25130
|
};
|
|
@@ -25368,8 +25190,8 @@ const processMarks = (marks) => {
|
|
|
25368
25190
|
break;
|
|
25369
25191
|
default:
|
|
25370
25192
|
if (attrs?.style) {
|
|
25371
|
-
Object.entries(attrs.style).forEach(([
|
|
25372
|
-
styles[
|
|
25193
|
+
Object.entries(attrs.style).forEach(([key, value]) => {
|
|
25194
|
+
styles[key] = value;
|
|
25373
25195
|
});
|
|
25374
25196
|
}
|
|
25375
25197
|
break;
|
|
@@ -25491,6 +25313,11 @@ const ContentBlock = Node$1.create({
|
|
|
25491
25313
|
inline: true,
|
|
25492
25314
|
addOptions() {
|
|
25493
25315
|
return {
|
|
25316
|
+
/**
|
|
25317
|
+
* @typedef {Object} ContentBlockOptions
|
|
25318
|
+
* @category Options
|
|
25319
|
+
* @property {Object} [htmlAttributes] - HTML attributes for the block element
|
|
25320
|
+
*/
|
|
25494
25321
|
htmlAttributes: {
|
|
25495
25322
|
contenteditable: false
|
|
25496
25323
|
}
|
|
@@ -25498,6 +25325,10 @@ const ContentBlock = Node$1.create({
|
|
|
25498
25325
|
},
|
|
25499
25326
|
addAttributes() {
|
|
25500
25327
|
return {
|
|
25328
|
+
/**
|
|
25329
|
+
* @category Attribute
|
|
25330
|
+
* @param {boolean} [horizontalRule=false] - Whether this block is a horizontal rule
|
|
25331
|
+
*/
|
|
25501
25332
|
horizontalRule: {
|
|
25502
25333
|
default: false,
|
|
25503
25334
|
renderDOM: ({ horizontalRule }) => {
|
|
@@ -25505,6 +25336,10 @@ const ContentBlock = Node$1.create({
|
|
|
25505
25336
|
return { "data-horizontal-rule": "true" };
|
|
25506
25337
|
}
|
|
25507
25338
|
},
|
|
25339
|
+
/**
|
|
25340
|
+
* @category Attribute
|
|
25341
|
+
* @param {ContentBlockSize} [size] - Size and position of the content block
|
|
25342
|
+
*/
|
|
25508
25343
|
size: {
|
|
25509
25344
|
default: null,
|
|
25510
25345
|
renderDOM: ({ size }) => {
|
|
@@ -25518,6 +25353,10 @@ const ContentBlock = Node$1.create({
|
|
|
25518
25353
|
return { style };
|
|
25519
25354
|
}
|
|
25520
25355
|
},
|
|
25356
|
+
/**
|
|
25357
|
+
* @category Attribute
|
|
25358
|
+
* @param {string} [background] - Background color for the block
|
|
25359
|
+
*/
|
|
25521
25360
|
background: {
|
|
25522
25361
|
default: null,
|
|
25523
25362
|
renderDOM: (attrs) => {
|
|
@@ -25527,9 +25366,19 @@ const ContentBlock = Node$1.create({
|
|
|
25527
25366
|
};
|
|
25528
25367
|
}
|
|
25529
25368
|
},
|
|
25369
|
+
/**
|
|
25370
|
+
* @private
|
|
25371
|
+
* @category Attribute
|
|
25372
|
+
* @param {Object} [drawingContent] - Internal drawing data
|
|
25373
|
+
*/
|
|
25530
25374
|
drawingContent: {
|
|
25531
25375
|
rendered: false
|
|
25532
25376
|
},
|
|
25377
|
+
/**
|
|
25378
|
+
* @private
|
|
25379
|
+
* @category Attribute
|
|
25380
|
+
* @param {Object} [attributes] - Additional internal attributes
|
|
25381
|
+
*/
|
|
25533
25382
|
attributes: {
|
|
25534
25383
|
rendered: false
|
|
25535
25384
|
}
|
|
@@ -25550,8 +25399,9 @@ const ContentBlock = Node$1.create({
|
|
|
25550
25399
|
/**
|
|
25551
25400
|
* Insert a horizontal rule
|
|
25552
25401
|
* @category Command
|
|
25402
|
+
* @returns {Function} Command function
|
|
25553
25403
|
* @example
|
|
25554
|
-
*
|
|
25404
|
+
* insertHorizontalRule()
|
|
25555
25405
|
* @note Creates a visual separator between content sections
|
|
25556
25406
|
*/
|
|
25557
25407
|
insertHorizontalRule: () => ({ commands: commands2 }) => {
|
|
@@ -25568,13 +25418,13 @@ const ContentBlock = Node$1.create({
|
|
|
25568
25418
|
* Insert a content block
|
|
25569
25419
|
* @category Command
|
|
25570
25420
|
* @param {ContentBlockConfig} config - Block configuration
|
|
25421
|
+
* @returns {Function} Command function
|
|
25571
25422
|
* @example
|
|
25572
25423
|
* // Insert a spacer block
|
|
25573
|
-
*
|
|
25424
|
+
* insertContentBlock({ size: { height: 20 } })
|
|
25574
25425
|
*
|
|
25575
|
-
* @example
|
|
25576
25426
|
* // Insert a colored divider
|
|
25577
|
-
*
|
|
25427
|
+
* insertContentBlock({
|
|
25578
25428
|
* size: { width: '50%', height: 3 },
|
|
25579
25429
|
* background: '#3b82f6'
|
|
25580
25430
|
* })
|
|
@@ -25589,353 +25439,69 @@ const ContentBlock = Node$1.create({
|
|
|
25589
25439
|
};
|
|
25590
25440
|
}
|
|
25591
25441
|
});
|
|
25592
|
-
class StructuredContentViewBase {
|
|
25593
|
-
constructor(props) {
|
|
25594
|
-
__publicField(this, "node");
|
|
25595
|
-
__publicField(this, "view");
|
|
25596
|
-
__publicField(this, "getPos");
|
|
25597
|
-
__publicField(this, "decorations");
|
|
25598
|
-
__publicField(this, "innerDecorations");
|
|
25599
|
-
__publicField(this, "editor");
|
|
25600
|
-
__publicField(this, "extension");
|
|
25601
|
-
__publicField(this, "htmlAttributes");
|
|
25602
|
-
__publicField(this, "root");
|
|
25603
|
-
__publicField(this, "isDragging", false);
|
|
25604
|
-
this.node = props.node;
|
|
25605
|
-
this.view = props.editor.view;
|
|
25606
|
-
this.getPos = props.getPos;
|
|
25607
|
-
this.decorations = props.decorations;
|
|
25608
|
-
this.innerDecorations = props.innerDecorations;
|
|
25609
|
-
this.editor = props.editor;
|
|
25610
|
-
this.extension = props.extension;
|
|
25611
|
-
this.htmlAttributes = props.htmlAttributes;
|
|
25612
|
-
this.mount(props);
|
|
25613
|
-
}
|
|
25614
|
-
mount() {
|
|
25615
|
-
return;
|
|
25616
|
-
}
|
|
25617
|
-
get dom() {
|
|
25618
|
-
return this.root;
|
|
25619
|
-
}
|
|
25620
|
-
get contentDOM() {
|
|
25621
|
-
return null;
|
|
25622
|
-
}
|
|
25623
|
-
update(node, decorations, innerDecorations) {
|
|
25624
|
-
if (node.type !== this.node.type) {
|
|
25625
|
-
return false;
|
|
25626
|
-
}
|
|
25627
|
-
this.node = node;
|
|
25628
|
-
this.decorations = decorations;
|
|
25629
|
-
this.innerDecorations = innerDecorations;
|
|
25630
|
-
this.updateHTMLAttributes();
|
|
25631
|
-
return true;
|
|
25632
|
-
}
|
|
25633
|
-
stopEvent(event) {
|
|
25634
|
-
if (!this.dom) return false;
|
|
25635
|
-
const target = event.target;
|
|
25636
|
-
const isInElement = this.dom.contains(target) && !this.contentDOM?.contains(target);
|
|
25637
|
-
if (!isInElement) return false;
|
|
25638
|
-
const isDragEvent = event.type.startsWith("drag");
|
|
25639
|
-
const isDropEvent = event.type === "drop";
|
|
25640
|
-
const isInput = ["INPUT", "BUTTON", "SELECT", "TEXTAREA"].includes(target.tagName) || target.isContentEditable;
|
|
25641
|
-
if (isInput && !isDropEvent && !isDragEvent) return true;
|
|
25642
|
-
const { isEditable } = this.editor;
|
|
25643
|
-
const { isDragging } = this;
|
|
25644
|
-
const isDraggable = !!this.node.type.spec.draggable;
|
|
25645
|
-
const isSelectable = NodeSelection.isSelectable(this.node);
|
|
25646
|
-
const isCopyEvent = event.type === "copy";
|
|
25647
|
-
const isPasteEvent = event.type === "paste";
|
|
25648
|
-
const isCutEvent = event.type === "cut";
|
|
25649
|
-
const isClickEvent = event.type === "mousedown";
|
|
25650
|
-
if (!isDraggable && isSelectable && isDragEvent && event.target === this.dom) {
|
|
25651
|
-
event.preventDefault();
|
|
25652
|
-
}
|
|
25653
|
-
if (isDraggable && isDragEvent && !isDragging && event.target === this.dom) {
|
|
25654
|
-
event.preventDefault();
|
|
25655
|
-
return false;
|
|
25656
|
-
}
|
|
25657
|
-
if (isDraggable && isEditable && !isDragging && isClickEvent) {
|
|
25658
|
-
const dragHandle = target.closest("[data-drag-handle]");
|
|
25659
|
-
const isValidDragHandle = dragHandle && (this.dom === dragHandle || this.dom.contains(dragHandle));
|
|
25660
|
-
if (isValidDragHandle) {
|
|
25661
|
-
this.isDragging = true;
|
|
25662
|
-
document.addEventListener(
|
|
25663
|
-
"dragend",
|
|
25664
|
-
() => {
|
|
25665
|
-
this.isDragging = false;
|
|
25666
|
-
},
|
|
25667
|
-
{ once: true }
|
|
25668
|
-
);
|
|
25669
|
-
document.addEventListener(
|
|
25670
|
-
"drop",
|
|
25671
|
-
() => {
|
|
25672
|
-
this.isDragging = false;
|
|
25673
|
-
},
|
|
25674
|
-
{ once: true }
|
|
25675
|
-
);
|
|
25676
|
-
document.addEventListener(
|
|
25677
|
-
"mouseup",
|
|
25678
|
-
() => {
|
|
25679
|
-
this.isDragging = false;
|
|
25680
|
-
},
|
|
25681
|
-
{ once: true }
|
|
25682
|
-
);
|
|
25683
|
-
}
|
|
25684
|
-
}
|
|
25685
|
-
if (isDragging || isDropEvent || isCopyEvent || isPasteEvent || isCutEvent || isClickEvent && isSelectable) {
|
|
25686
|
-
return false;
|
|
25687
|
-
}
|
|
25688
|
-
return true;
|
|
25689
|
-
}
|
|
25690
|
-
ignoreMutation(mutation) {
|
|
25691
|
-
if (!this.dom || !this.contentDOM) return true;
|
|
25692
|
-
if (this.node.isLeaf || this.node.isAtom) return true;
|
|
25693
|
-
if (mutation.type === "selection") return false;
|
|
25694
|
-
if (this.contentDOM === mutation.target && mutation.type === "attributes") return true;
|
|
25695
|
-
if (this.contentDOM.contains(mutation.target)) return false;
|
|
25696
|
-
return true;
|
|
25697
|
-
}
|
|
25698
|
-
destroy() {
|
|
25699
|
-
this.dom.remove();
|
|
25700
|
-
this.contentDOM?.remove();
|
|
25701
|
-
}
|
|
25702
|
-
updateAttributes(attrs) {
|
|
25703
|
-
const pos = this.getPos();
|
|
25704
|
-
if (typeof pos !== "number") {
|
|
25705
|
-
return;
|
|
25706
|
-
}
|
|
25707
|
-
return this.view.dispatch(
|
|
25708
|
-
this.view.state.tr.setNodeMarkup(pos, void 0, {
|
|
25709
|
-
...this.node.attrs,
|
|
25710
|
-
...attrs
|
|
25711
|
-
})
|
|
25712
|
-
);
|
|
25713
|
-
}
|
|
25714
|
-
updateHTMLAttributes() {
|
|
25715
|
-
const { extensionService } = this.editor;
|
|
25716
|
-
const { attributes } = extensionService;
|
|
25717
|
-
const extensionAttrs = attributes.filter((i) => i.type === this.node.type.name);
|
|
25718
|
-
this.htmlAttributes = Attribute.getAttributesToRender(this.node, extensionAttrs);
|
|
25719
|
-
}
|
|
25720
|
-
createDragHandle() {
|
|
25721
|
-
const dragHandle = document.createElement("span");
|
|
25722
|
-
dragHandle.classList.add("sd-structured-content-draggable");
|
|
25723
|
-
dragHandle.draggable = true;
|
|
25724
|
-
dragHandle.contentEditable = "false";
|
|
25725
|
-
dragHandle.dataset.dragHandle = "";
|
|
25726
|
-
const textElement = document.createElement("span");
|
|
25727
|
-
textElement.textContent = "Structured content";
|
|
25728
|
-
dragHandle.append(textElement);
|
|
25729
|
-
return dragHandle;
|
|
25730
|
-
}
|
|
25731
|
-
onDragStart(event) {
|
|
25732
|
-
const { view } = this.editor;
|
|
25733
|
-
const target = event.target;
|
|
25734
|
-
const dragHandle = target.nodeType === 3 ? target.parentElement?.closest("[data-drag-handle]") : target.closest("[data-drag-handle]");
|
|
25735
|
-
if (!this.dom || this.contentDOM?.contains(target) || !dragHandle) {
|
|
25736
|
-
return;
|
|
25737
|
-
}
|
|
25738
|
-
let x = 0;
|
|
25739
|
-
let y = 0;
|
|
25740
|
-
if (this.dom !== dragHandle) {
|
|
25741
|
-
const domBox = this.dom.getBoundingClientRect();
|
|
25742
|
-
const handleBox = dragHandle.getBoundingClientRect();
|
|
25743
|
-
const offsetX = event.offsetX ?? event.nativeEvent?.offsetX;
|
|
25744
|
-
const offsetY = event.offsetY ?? event.nativeEvent?.offsetY;
|
|
25745
|
-
x = handleBox.x - domBox.x + offsetX;
|
|
25746
|
-
y = handleBox.y - domBox.y + offsetY;
|
|
25747
|
-
}
|
|
25748
|
-
event.dataTransfer?.setDragImage(this.dom, x, y);
|
|
25749
|
-
const pos = this.getPos();
|
|
25750
|
-
if (typeof pos !== "number") {
|
|
25751
|
-
return;
|
|
25752
|
-
}
|
|
25753
|
-
const selection = NodeSelection.create(view.state.doc, pos);
|
|
25754
|
-
const transaction = view.state.tr.setSelection(selection);
|
|
25755
|
-
view.dispatch(transaction);
|
|
25756
|
-
}
|
|
25757
|
-
}
|
|
25758
|
-
class StructuredContentInlineView extends StructuredContentViewBase {
|
|
25759
|
-
constructor(props) {
|
|
25760
|
-
super(props);
|
|
25761
|
-
}
|
|
25762
|
-
mount() {
|
|
25763
|
-
this.buildView();
|
|
25764
|
-
}
|
|
25765
|
-
get contentDOM() {
|
|
25766
|
-
const contentElement = this.dom?.querySelector(`.${structuredContentInnerClass$1}`);
|
|
25767
|
-
return contentElement || null;
|
|
25768
|
-
}
|
|
25769
|
-
createElement() {
|
|
25770
|
-
const element = document.createElement("span");
|
|
25771
|
-
element.classList.add(structuredContentClass$1);
|
|
25772
|
-
element.setAttribute("data-structured-content", "");
|
|
25773
|
-
const contentElement = document.createElement("span");
|
|
25774
|
-
contentElement.classList.add(structuredContentInnerClass$1);
|
|
25775
|
-
element.append(contentElement);
|
|
25776
|
-
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
25777
|
-
updateDOMAttributes(element, { ...domAttrs });
|
|
25778
|
-
return { element, contentElement };
|
|
25779
|
-
}
|
|
25780
|
-
buildView() {
|
|
25781
|
-
const { element } = this.createElement();
|
|
25782
|
-
const dragHandle = this.createDragHandle();
|
|
25783
|
-
element.prepend(dragHandle);
|
|
25784
|
-
element.addEventListener("dragstart", (e) => this.onDragStart(e));
|
|
25785
|
-
this.root = element;
|
|
25786
|
-
}
|
|
25787
|
-
updateView() {
|
|
25788
|
-
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
25789
|
-
updateDOMAttributes(this.dom, { ...domAttrs });
|
|
25790
|
-
}
|
|
25791
|
-
update(node, decorations, innerDecorations) {
|
|
25792
|
-
const result = super.update(node, decorations, innerDecorations);
|
|
25793
|
-
if (!result) return false;
|
|
25794
|
-
this.updateView();
|
|
25795
|
-
return true;
|
|
25796
|
-
}
|
|
25797
|
-
}
|
|
25798
|
-
const structuredContentClass$1 = "sd-structured-content";
|
|
25799
|
-
const structuredContentInnerClass$1 = "sd-structured-content__content";
|
|
25800
25442
|
const StructuredContent = Node$1.create({
|
|
25801
25443
|
name: "structuredContent",
|
|
25802
|
-
group: "inline
|
|
25444
|
+
group: "inline",
|
|
25803
25445
|
inline: true,
|
|
25804
25446
|
content: "inline*",
|
|
25805
|
-
isolating: true,
|
|
25806
|
-
atom: false,
|
|
25807
|
-
// false - has editable content.
|
|
25808
|
-
draggable: true,
|
|
25809
25447
|
addOptions() {
|
|
25810
25448
|
return {
|
|
25449
|
+
structuredContentClass: "sd-structured-content-tag",
|
|
25811
25450
|
htmlAttributes: {
|
|
25812
|
-
class: structuredContentClass$1,
|
|
25813
25451
|
"aria-label": "Structured content node"
|
|
25814
25452
|
}
|
|
25815
25453
|
};
|
|
25816
25454
|
},
|
|
25817
25455
|
addAttributes() {
|
|
25818
25456
|
return {
|
|
25819
|
-
id: {
|
|
25820
|
-
default: null,
|
|
25821
|
-
parseDOM: (elem) => elem.getAttribute("data-id"),
|
|
25822
|
-
renderDOM: (attrs) => {
|
|
25823
|
-
if (!attrs.id) return {};
|
|
25824
|
-
return { "data-id": attrs.id };
|
|
25825
|
-
}
|
|
25826
|
-
},
|
|
25827
25457
|
sdtPr: {
|
|
25828
25458
|
rendered: false
|
|
25829
25459
|
}
|
|
25830
25460
|
};
|
|
25831
25461
|
},
|
|
25832
25462
|
parseDOM() {
|
|
25833
|
-
return [{ tag:
|
|
25463
|
+
return [{ tag: `span.${this.options.structuredContentClass}` }];
|
|
25834
25464
|
},
|
|
25835
25465
|
renderDOM({ htmlAttributes }) {
|
|
25836
25466
|
return [
|
|
25837
25467
|
"span",
|
|
25838
25468
|
Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes, {
|
|
25839
|
-
|
|
25469
|
+
class: this.options.structuredContentClass
|
|
25840
25470
|
}),
|
|
25841
25471
|
0
|
|
25842
25472
|
];
|
|
25843
|
-
},
|
|
25844
|
-
addNodeView() {
|
|
25845
|
-
return (props) => {
|
|
25846
|
-
return new StructuredContentInlineView({ ...props });
|
|
25847
|
-
};
|
|
25848
25473
|
}
|
|
25849
25474
|
});
|
|
25850
|
-
class StructuredContentBlockView extends StructuredContentViewBase {
|
|
25851
|
-
constructor(props) {
|
|
25852
|
-
super(props);
|
|
25853
|
-
}
|
|
25854
|
-
mount() {
|
|
25855
|
-
this.buildView();
|
|
25856
|
-
}
|
|
25857
|
-
get contentDOM() {
|
|
25858
|
-
const contentElement = this.dom?.querySelector(`.${structuredContentInnerClass}`);
|
|
25859
|
-
return contentElement || null;
|
|
25860
|
-
}
|
|
25861
|
-
createElement() {
|
|
25862
|
-
const element = document.createElement("div");
|
|
25863
|
-
element.classList.add(structuredContentClass);
|
|
25864
|
-
element.setAttribute("data-structured-content-block", "");
|
|
25865
|
-
const contentElement = document.createElement("div");
|
|
25866
|
-
contentElement.classList.add(structuredContentInnerClass);
|
|
25867
|
-
element.append(contentElement);
|
|
25868
|
-
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
25869
|
-
updateDOMAttributes(element, { ...domAttrs });
|
|
25870
|
-
return { element, contentElement };
|
|
25871
|
-
}
|
|
25872
|
-
buildView() {
|
|
25873
|
-
const { element } = this.createElement();
|
|
25874
|
-
const dragHandle = this.createDragHandle();
|
|
25875
|
-
element.prepend(dragHandle);
|
|
25876
|
-
element.addEventListener("dragstart", (e) => this.onDragStart(e));
|
|
25877
|
-
this.root = element;
|
|
25878
|
-
}
|
|
25879
|
-
updateView() {
|
|
25880
|
-
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
25881
|
-
updateDOMAttributes(this.dom, { ...domAttrs });
|
|
25882
|
-
}
|
|
25883
|
-
update(node, decorations, innerDecorations) {
|
|
25884
|
-
const result = super.update(node, decorations, innerDecorations);
|
|
25885
|
-
if (!result) return false;
|
|
25886
|
-
this.updateView();
|
|
25887
|
-
return true;
|
|
25888
|
-
}
|
|
25889
|
-
}
|
|
25890
|
-
const structuredContentClass = "sd-structured-content-block";
|
|
25891
|
-
const structuredContentInnerClass = "sd-structured-content-block__content";
|
|
25892
25475
|
const StructuredContentBlock = Node$1.create({
|
|
25893
25476
|
name: "structuredContentBlock",
|
|
25894
|
-
group: "block
|
|
25477
|
+
group: "block",
|
|
25895
25478
|
content: "block*",
|
|
25896
|
-
isolating: true,
|
|
25897
|
-
atom: false,
|
|
25898
|
-
// false - has editable content.
|
|
25899
|
-
draggable: true,
|
|
25900
25479
|
addOptions() {
|
|
25901
25480
|
return {
|
|
25481
|
+
structuredContentClass: "sd-structured-content-block-tag",
|
|
25902
25482
|
htmlAttributes: {
|
|
25903
|
-
class: structuredContentClass,
|
|
25904
25483
|
"aria-label": "Structured content block node"
|
|
25905
25484
|
}
|
|
25906
25485
|
};
|
|
25907
25486
|
},
|
|
25908
25487
|
addAttributes() {
|
|
25909
25488
|
return {
|
|
25910
|
-
id: {
|
|
25911
|
-
default: null,
|
|
25912
|
-
parseDOM: (elem) => elem.getAttribute("data-id"),
|
|
25913
|
-
renderDOM: (attrs) => {
|
|
25914
|
-
if (!attrs.id) return {};
|
|
25915
|
-
return { "data-id": attrs.id };
|
|
25916
|
-
}
|
|
25917
|
-
},
|
|
25918
25489
|
sdtPr: {
|
|
25919
25490
|
rendered: false
|
|
25920
25491
|
}
|
|
25921
25492
|
};
|
|
25922
25493
|
},
|
|
25923
25494
|
parseDOM() {
|
|
25924
|
-
return [{ tag:
|
|
25495
|
+
return [{ tag: `div.${this.options.structuredContentClass}` }];
|
|
25925
25496
|
},
|
|
25926
25497
|
renderDOM({ htmlAttributes }) {
|
|
25927
25498
|
return [
|
|
25928
25499
|
"div",
|
|
25929
25500
|
Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes, {
|
|
25930
|
-
|
|
25501
|
+
class: this.options.structuredContentClass
|
|
25931
25502
|
}),
|
|
25932
25503
|
0
|
|
25933
25504
|
];
|
|
25934
|
-
},
|
|
25935
|
-
addNodeView() {
|
|
25936
|
-
return (props) => {
|
|
25937
|
-
return new StructuredContentBlockView({ ...props });
|
|
25938
|
-
};
|
|
25939
25505
|
}
|
|
25940
25506
|
});
|
|
25941
25507
|
class DocumentSectionView {
|
|
@@ -26102,7 +25668,16 @@ const DocumentSection = Node$1.create({
|
|
|
26102
25668
|
},
|
|
26103
25669
|
addAttributes() {
|
|
26104
25670
|
return {
|
|
25671
|
+
/**
|
|
25672
|
+
* @category Attribute
|
|
25673
|
+
* @param {number} [id] - Unique section identifier
|
|
25674
|
+
*/
|
|
26105
25675
|
id: {},
|
|
25676
|
+
/**
|
|
25677
|
+
* @private
|
|
25678
|
+
* @category Attribute
|
|
25679
|
+
* @param {string} [sdBlockId] - Internal block tracking
|
|
25680
|
+
*/
|
|
26106
25681
|
sdBlockId: {
|
|
26107
25682
|
default: null,
|
|
26108
25683
|
keepOnSplit: false,
|
|
@@ -26111,9 +25686,25 @@ const DocumentSection = Node$1.create({
|
|
|
26111
25686
|
return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
|
|
26112
25687
|
}
|
|
26113
25688
|
},
|
|
25689
|
+
/**
|
|
25690
|
+
* @category Attribute
|
|
25691
|
+
* @param {string} [title] - Section display label
|
|
25692
|
+
*/
|
|
26114
25693
|
title: {},
|
|
25694
|
+
/**
|
|
25695
|
+
* @category Attribute
|
|
25696
|
+
* @param {string} [description] - Section metadata
|
|
25697
|
+
*/
|
|
26115
25698
|
description: {},
|
|
25699
|
+
/**
|
|
25700
|
+
* @category Attribute
|
|
25701
|
+
* @param {string} [sectionType] - Business classification (e.g., 'legal', 'pricing')
|
|
25702
|
+
*/
|
|
26116
25703
|
sectionType: {},
|
|
25704
|
+
/**
|
|
25705
|
+
* @category Attribute
|
|
25706
|
+
* @param {boolean} [isLocked=false] - Lock state preventing edits
|
|
25707
|
+
*/
|
|
26117
25708
|
isLocked: { default: false }
|
|
26118
25709
|
};
|
|
26119
25710
|
},
|
|
@@ -26128,9 +25719,10 @@ const DocumentSection = Node$1.create({
|
|
|
26128
25719
|
* Create a lockable content section
|
|
26129
25720
|
* @category Command
|
|
26130
25721
|
* @param {SectionCreate} [options={}] - Section configuration
|
|
25722
|
+
* @returns {Function} Command - true if created, false if position invalid
|
|
26131
25723
|
* @example
|
|
26132
|
-
*
|
|
26133
|
-
* id: 1,
|
|
25724
|
+
* createDocumentSection({
|
|
25725
|
+
* id: 'legal-1',
|
|
26134
25726
|
* title: 'Terms & Conditions',
|
|
26135
25727
|
* isLocked: true,
|
|
26136
25728
|
* html: '<p>Legal content...</p>'
|
|
@@ -26211,8 +25803,9 @@ const DocumentSection = Node$1.create({
|
|
|
26211
25803
|
/**
|
|
26212
25804
|
* Remove section wrapper at cursor, preserving its content
|
|
26213
25805
|
* @category Command
|
|
25806
|
+
* @returns {Function} Command - true if removed, false if no section at position
|
|
26214
25807
|
* @example
|
|
26215
|
-
*
|
|
25808
|
+
* removeSectionAtSelection()
|
|
26216
25809
|
* @note Content stays in document, only section wrapper is removed
|
|
26217
25810
|
*/
|
|
26218
25811
|
removeSectionAtSelection: () => ({ tr, dispatch }) => {
|
|
@@ -26238,8 +25831,9 @@ const DocumentSection = Node$1.create({
|
|
|
26238
25831
|
* Delete section and all its content
|
|
26239
25832
|
* @category Command
|
|
26240
25833
|
* @param {number} id - Section to delete
|
|
25834
|
+
* @returns {Function} Command - true if deleted, false if ID doesn't exist
|
|
26241
25835
|
* @example
|
|
26242
|
-
*
|
|
25836
|
+
* removeSectionById(123)
|
|
26243
25837
|
*/
|
|
26244
25838
|
removeSectionById: (id) => ({ tr, dispatch }) => {
|
|
26245
25839
|
const sections = SectionHelpers.getAllSections(this.editor);
|
|
@@ -26259,8 +25853,9 @@ const DocumentSection = Node$1.create({
|
|
|
26259
25853
|
* Lock section against edits
|
|
26260
25854
|
* @category Command
|
|
26261
25855
|
* @param {number} id - Section to lock
|
|
25856
|
+
* @returns {Function} Command - true if locked, false if ID doesn't exist
|
|
26262
25857
|
* @example
|
|
26263
|
-
*
|
|
25858
|
+
* lockSectionById(123)
|
|
26264
25859
|
*/
|
|
26265
25860
|
lockSectionById: (id) => ({ tr, dispatch }) => {
|
|
26266
25861
|
const sections = SectionHelpers.getAllSections(this.editor);
|
|
@@ -26277,10 +25872,16 @@ const DocumentSection = Node$1.create({
|
|
|
26277
25872
|
* Modify section attributes or content
|
|
26278
25873
|
* @category Command
|
|
26279
25874
|
* @param {SectionUpdate} options - Changes to apply
|
|
25875
|
+
* @returns {Function} Command - true if updated, false if ID doesn't exist
|
|
26280
25876
|
* @example
|
|
26281
|
-
*
|
|
26282
|
-
*
|
|
26283
|
-
*
|
|
25877
|
+
* // Toggle lock
|
|
25878
|
+
* updateSectionById({ id: 123, attrs: { isLocked: false } })
|
|
25879
|
+
*
|
|
25880
|
+
* // Replace content
|
|
25881
|
+
* updateSectionById({ id: 123, html: '<p>New content</p>' })
|
|
25882
|
+
*
|
|
25883
|
+
* // Both
|
|
25884
|
+
* updateSectionById({
|
|
26284
25885
|
* id: 123,
|
|
26285
25886
|
* html: '<p>Updated</p>',
|
|
26286
25887
|
* attrs: { title: 'New Title' }
|
|
@@ -26330,10 +25931,11 @@ const BlockNode = Extension.create({
|
|
|
26330
25931
|
* Replace a block node by its ID with new content
|
|
26331
25932
|
* @category Command
|
|
26332
25933
|
* @param {string} id - The sdBlockId of the node to replace
|
|
26333
|
-
* @param {
|
|
25934
|
+
* @param {Object} contentNode - The replacement ProseMirror node
|
|
25935
|
+
* @returns {Function} Command function
|
|
26334
25936
|
* @example
|
|
26335
25937
|
* const newParagraph = editor.schema.nodes.paragraph.create({}, editor.schema.text('New content'))
|
|
26336
|
-
*
|
|
25938
|
+
* replaceBlockNodeById('block-123', newParagraph)
|
|
26337
25939
|
* @note The replacement node should have the same type as the original
|
|
26338
25940
|
*/
|
|
26339
25941
|
replaceBlockNodeById: (id, contentNode) => ({ dispatch, tr }) => {
|
|
@@ -26356,8 +25958,9 @@ const BlockNode = Extension.create({
|
|
|
26356
25958
|
* Delete a block node by its ID
|
|
26357
25959
|
* @category Command
|
|
26358
25960
|
* @param {string} id - The sdBlockId of the node to delete
|
|
25961
|
+
* @returns {Function} Command function
|
|
26359
25962
|
* @example
|
|
26360
|
-
*
|
|
25963
|
+
* deleteBlockNodeById('block-123')
|
|
26361
25964
|
* @note Completely removes the node from the document
|
|
26362
25965
|
*/
|
|
26363
25966
|
deleteBlockNodeById: (id) => ({ dispatch, tr }) => {
|
|
@@ -26381,10 +25984,11 @@ const BlockNode = Extension.create({
|
|
|
26381
25984
|
* @category Command
|
|
26382
25985
|
* @param {string} id - The sdBlockId of the node to update
|
|
26383
25986
|
* @param {Object} attrs - Attributes to update
|
|
25987
|
+
* @returns {Function} Command function
|
|
26384
25988
|
* @example
|
|
26385
|
-
*
|
|
25989
|
+
* updateBlockNodeAttributes('block-123', { textAlign: 'center' })
|
|
26386
25990
|
* @example
|
|
26387
|
-
*
|
|
25991
|
+
* updateBlockNodeAttributes('block-123', { indent: { left: 20 } })
|
|
26388
25992
|
* @note Merges new attributes with existing ones
|
|
26389
25993
|
*/
|
|
26390
25994
|
updateBlockNodeAttributes: (id, attrs = {}) => ({ dispatch, tr }) => {
|
|
@@ -26478,7 +26082,7 @@ const BlockNode = Extension.create({
|
|
|
26478
26082
|
key: BlockNodePluginKey,
|
|
26479
26083
|
appendTransaction: (transactions, _oldState, newState) => {
|
|
26480
26084
|
if (hasInitialized && !transactions.some((tr2) => tr2.docChanged)) return null;
|
|
26481
|
-
if (hasInitialized && !checkForNewBlockNodesInTrs(
|
|
26085
|
+
if (hasInitialized && !checkForNewBlockNodesInTrs(transactions)) return null;
|
|
26482
26086
|
const { tr } = newState;
|
|
26483
26087
|
let changed = false;
|
|
26484
26088
|
newState.doc.descendants((node, pos) => {
|
|
@@ -26557,8 +26161,9 @@ const TextStyle = Mark.create({
|
|
|
26557
26161
|
/**
|
|
26558
26162
|
* Remove empty text style marks
|
|
26559
26163
|
* @category Command
|
|
26164
|
+
* @returns {Function} Command function - Removes mark if no attributes present
|
|
26560
26165
|
* @example
|
|
26561
|
-
*
|
|
26166
|
+
* removeEmptyTextStyle()
|
|
26562
26167
|
* @note Cleanup utility to prevent empty span elements
|
|
26563
26168
|
* @note Automatically checks if any style attributes exist before removal
|
|
26564
26169
|
*/
|
|
@@ -26580,6 +26185,10 @@ const Bold = Mark.create({
|
|
|
26580
26185
|
},
|
|
26581
26186
|
addAttributes() {
|
|
26582
26187
|
return {
|
|
26188
|
+
/**
|
|
26189
|
+
* @category Attribute
|
|
26190
|
+
* @param {string} [value] - Bold weight value ('0' renders as normal)
|
|
26191
|
+
*/
|
|
26583
26192
|
value: {
|
|
26584
26193
|
default: null,
|
|
26585
26194
|
renderDOM: (attrs) => {
|
|
@@ -26608,23 +26217,26 @@ const Bold = Mark.create({
|
|
|
26608
26217
|
/**
|
|
26609
26218
|
* Apply bold formatting
|
|
26610
26219
|
* @category Command
|
|
26220
|
+
* @returns {Function} Command
|
|
26611
26221
|
* @example
|
|
26612
|
-
*
|
|
26222
|
+
* setBold()
|
|
26613
26223
|
* @note '0' renders as normal weight
|
|
26614
26224
|
*/
|
|
26615
26225
|
setBold: () => ({ commands: commands2 }) => commands2.setMark(this.name),
|
|
26616
26226
|
/**
|
|
26617
26227
|
* Remove bold formatting
|
|
26618
26228
|
* @category Command
|
|
26229
|
+
* @returns {Function} Command
|
|
26619
26230
|
* @example
|
|
26620
|
-
*
|
|
26231
|
+
* unsetBold()
|
|
26621
26232
|
*/
|
|
26622
26233
|
unsetBold: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
|
|
26623
26234
|
/**
|
|
26624
26235
|
* Toggle bold formatting
|
|
26625
26236
|
* @category Command
|
|
26237
|
+
* @returns {Function} Command
|
|
26626
26238
|
* @example
|
|
26627
|
-
*
|
|
26239
|
+
* toggleBold()
|
|
26628
26240
|
*/
|
|
26629
26241
|
toggleBold: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
|
|
26630
26242
|
};
|
|
@@ -26659,22 +26271,25 @@ const Italic = Mark.create({
|
|
|
26659
26271
|
/**
|
|
26660
26272
|
* Apply italic formatting
|
|
26661
26273
|
* @category Command
|
|
26274
|
+
* @returns {Function} Command
|
|
26662
26275
|
* @example
|
|
26663
|
-
*
|
|
26276
|
+
* setItalic()
|
|
26664
26277
|
*/
|
|
26665
26278
|
setItalic: () => ({ commands: commands2 }) => commands2.setMark(this.name),
|
|
26666
26279
|
/**
|
|
26667
26280
|
* Remove italic formatting
|
|
26668
26281
|
* @category Command
|
|
26282
|
+
* @returns {Function} Command
|
|
26669
26283
|
* @example
|
|
26670
|
-
*
|
|
26284
|
+
* unsetItalic()
|
|
26671
26285
|
*/
|
|
26672
26286
|
unsetItalic: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
|
|
26673
26287
|
/**
|
|
26674
26288
|
* Toggle italic formatting
|
|
26675
26289
|
* @category Command
|
|
26290
|
+
* @returns {Function} Command
|
|
26676
26291
|
* @example
|
|
26677
|
-
*
|
|
26292
|
+
* toggleItalic()
|
|
26678
26293
|
*/
|
|
26679
26294
|
toggleItalic: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
|
|
26680
26295
|
};
|
|
@@ -26758,6 +26373,10 @@ const Highlight = Mark.create({
|
|
|
26758
26373
|
},
|
|
26759
26374
|
addAttributes() {
|
|
26760
26375
|
return {
|
|
26376
|
+
/**
|
|
26377
|
+
* @category Attribute
|
|
26378
|
+
* @param {string} [color] - Background color (CSS color value)
|
|
26379
|
+
*/
|
|
26761
26380
|
color: {
|
|
26762
26381
|
default: null,
|
|
26763
26382
|
parseDOM: (element) => element.getAttribute("data-color") || element.style.backgroundColor,
|
|
@@ -26785,23 +26404,26 @@ const Highlight = Mark.create({
|
|
|
26785
26404
|
* Apply highlight with specified color
|
|
26786
26405
|
* @category Command
|
|
26787
26406
|
* @param {string} color - CSS color value
|
|
26407
|
+
* @returns {Function} Command
|
|
26788
26408
|
* @example
|
|
26789
|
-
*
|
|
26790
|
-
*
|
|
26409
|
+
* setHighlight('#FFEB3B')
|
|
26410
|
+
* setHighlight('rgba(255, 235, 59, 0.5)')
|
|
26791
26411
|
*/
|
|
26792
26412
|
setHighlight: (color) => ({ commands: commands2 }) => commands2.setMark(this.name, { color }),
|
|
26793
26413
|
/**
|
|
26794
26414
|
* Remove highlight formatting
|
|
26795
26415
|
* @category Command
|
|
26416
|
+
* @returns {Function} Command
|
|
26796
26417
|
* @example
|
|
26797
|
-
*
|
|
26418
|
+
* unsetHighlight()
|
|
26798
26419
|
*/
|
|
26799
26420
|
unsetHighlight: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
|
|
26800
26421
|
/**
|
|
26801
26422
|
* Toggle highlight formatting
|
|
26802
26423
|
* @category Command
|
|
26424
|
+
* @returns {Function} Command
|
|
26803
26425
|
* @example
|
|
26804
|
-
*
|
|
26426
|
+
* toggleHighlight()
|
|
26805
26427
|
*/
|
|
26806
26428
|
toggleHighlight: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
|
|
26807
26429
|
};
|
|
@@ -26834,8 +26456,9 @@ const Strike = Mark.create({
|
|
|
26834
26456
|
/**
|
|
26835
26457
|
* Apply strikethrough formatting
|
|
26836
26458
|
* @category Command
|
|
26459
|
+
* @returns {Function} Command
|
|
26837
26460
|
* @example
|
|
26838
|
-
*
|
|
26461
|
+
* setStrike()
|
|
26839
26462
|
*/
|
|
26840
26463
|
setStrike: () => ({ commands: commands2 }) => {
|
|
26841
26464
|
return commands2.setMark(this.name);
|
|
@@ -26843,8 +26466,9 @@ const Strike = Mark.create({
|
|
|
26843
26466
|
/**
|
|
26844
26467
|
* Remove strikethrough formatting
|
|
26845
26468
|
* @category Command
|
|
26469
|
+
* @returns {Function} Command
|
|
26846
26470
|
* @example
|
|
26847
|
-
*
|
|
26471
|
+
* unsetStrike()
|
|
26848
26472
|
*/
|
|
26849
26473
|
unsetStrike: () => ({ commands: commands2 }) => {
|
|
26850
26474
|
return commands2.unsetMark(this.name);
|
|
@@ -26852,8 +26476,9 @@ const Strike = Mark.create({
|
|
|
26852
26476
|
/**
|
|
26853
26477
|
* Toggle strikethrough formatting
|
|
26854
26478
|
* @category Command
|
|
26479
|
+
* @returns {Function} Command
|
|
26855
26480
|
* @example
|
|
26856
|
-
*
|
|
26481
|
+
* toggleStrike()
|
|
26857
26482
|
*/
|
|
26858
26483
|
toggleStrike: () => ({ commands: commands2 }) => {
|
|
26859
26484
|
return commands2.toggleMark(this.name);
|
|
@@ -26873,6 +26498,11 @@ const Link = Mark.create({
|
|
|
26873
26498
|
inclusive: false,
|
|
26874
26499
|
addOptions() {
|
|
26875
26500
|
return {
|
|
26501
|
+
/**
|
|
26502
|
+
* Allowed URL protocols
|
|
26503
|
+
* @type {string[]}
|
|
26504
|
+
* @default ['http', 'https']
|
|
26505
|
+
*/
|
|
26876
26506
|
protocols: ["http", "https"],
|
|
26877
26507
|
htmlAttributes: {
|
|
26878
26508
|
target: null,
|
|
@@ -26971,10 +26601,16 @@ const Link = Mark.create({
|
|
|
26971
26601
|
/**
|
|
26972
26602
|
* Create or update a link
|
|
26973
26603
|
* @category Command
|
|
26974
|
-
* @param {
|
|
26604
|
+
* @param {Object} options - Link configuration
|
|
26605
|
+
* @param {string} [options.href] - URL for the link
|
|
26606
|
+
* @param {string} [options.text] - Display text (uses selection if omitted)
|
|
26607
|
+
* @returns {Function} Command - Creates link with underline
|
|
26975
26608
|
* @example
|
|
26976
|
-
*
|
|
26977
|
-
*
|
|
26609
|
+
* // Link selected text
|
|
26610
|
+
* setLink({ href: 'https://example.com' })
|
|
26611
|
+
*
|
|
26612
|
+
* // Link with custom text
|
|
26613
|
+
* setLink({
|
|
26978
26614
|
* href: 'https://example.com',
|
|
26979
26615
|
* text: 'Visit Example'
|
|
26980
26616
|
* })
|
|
@@ -27026,8 +26662,9 @@ const Link = Mark.create({
|
|
|
27026
26662
|
/**
|
|
27027
26663
|
* Remove link and associated formatting
|
|
27028
26664
|
* @category Command
|
|
26665
|
+
* @returns {Function} Command - Removes link, underline, and color
|
|
27029
26666
|
* @example
|
|
27030
|
-
*
|
|
26667
|
+
* unsetLink()
|
|
27031
26668
|
* @note Also removes underline and text color
|
|
27032
26669
|
*/
|
|
27033
26670
|
unsetLink: () => ({ chain }) => {
|
|
@@ -27036,10 +26673,16 @@ const Link = Mark.create({
|
|
|
27036
26673
|
/**
|
|
27037
26674
|
* Toggle link on selection
|
|
27038
26675
|
* @category Command
|
|
27039
|
-
* @param {
|
|
26676
|
+
* @param {Object} [options] - Link configuration
|
|
26677
|
+
* @param {string} [options.href] - URL for the link
|
|
26678
|
+
* @param {string} [options.text] - Display text
|
|
26679
|
+
* @returns {Function} Command - Creates link if href provided, removes otherwise
|
|
27040
26680
|
* @example
|
|
27041
|
-
*
|
|
27042
|
-
*
|
|
26681
|
+
* // Add link
|
|
26682
|
+
* toggleLink({ href: 'https://example.com' })
|
|
26683
|
+
*
|
|
26684
|
+
* // Remove link
|
|
26685
|
+
* toggleLink()
|
|
27043
26686
|
*/
|
|
27044
26687
|
toggleLink: ({ href, text } = {}) => ({ commands: commands2 }) => {
|
|
27045
26688
|
if (!href) return commands2.unsetLink();
|
|
@@ -27926,8 +27569,8 @@ function mergePaddingObject(paddingObject) {
|
|
|
27926
27569
|
return Object.assign({}, getFreshSideObject(), paddingObject);
|
|
27927
27570
|
}
|
|
27928
27571
|
function expandToHashMap(value, keys2) {
|
|
27929
|
-
return keys2.reduce(function(hashMap,
|
|
27930
|
-
hashMap[
|
|
27572
|
+
return keys2.reduce(function(hashMap, key) {
|
|
27573
|
+
hashMap[key] = value;
|
|
27931
27574
|
return hashMap;
|
|
27932
27575
|
}, {});
|
|
27933
27576
|
}
|
|
@@ -28383,10 +28026,10 @@ function detectOverflow$1(state, options) {
|
|
|
28383
28026
|
var offsetData = state.modifiersData.offset;
|
|
28384
28027
|
if (elementContext === popper && offsetData) {
|
|
28385
28028
|
var offset2 = offsetData[placement];
|
|
28386
|
-
Object.keys(overflowOffsets).forEach(function(
|
|
28387
|
-
var multiply = [right, bottom].indexOf(
|
|
28388
|
-
var axis = [top, bottom].indexOf(
|
|
28389
|
-
overflowOffsets[
|
|
28029
|
+
Object.keys(overflowOffsets).forEach(function(key) {
|
|
28030
|
+
var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
|
|
28031
|
+
var axis = [top, bottom].indexOf(key) >= 0 ? "y" : "x";
|
|
28032
|
+
overflowOffsets[key] += offset2[axis] * multiply;
|
|
28390
28033
|
});
|
|
28391
28034
|
}
|
|
28392
28035
|
return overflowOffsets;
|
|
@@ -28833,8 +28476,8 @@ function mergeByName(modifiers2) {
|
|
|
28833
28476
|
}) : current;
|
|
28834
28477
|
return merged2;
|
|
28835
28478
|
}, {});
|
|
28836
|
-
return Object.keys(merged).map(function(
|
|
28837
|
-
return merged[
|
|
28479
|
+
return Object.keys(merged).map(function(key) {
|
|
28480
|
+
return merged[key];
|
|
28838
28481
|
});
|
|
28839
28482
|
}
|
|
28840
28483
|
var DEFAULT_OPTIONS = {
|
|
@@ -28991,8 +28634,8 @@ var TOUCH_OPTIONS = {
|
|
|
28991
28634
|
var TIPPY_DEFAULT_APPEND_TO = function TIPPY_DEFAULT_APPEND_TO2() {
|
|
28992
28635
|
return document.body;
|
|
28993
28636
|
};
|
|
28994
|
-
function hasOwnProperty(obj,
|
|
28995
|
-
return {}.hasOwnProperty.call(obj,
|
|
28637
|
+
function hasOwnProperty(obj, key) {
|
|
28638
|
+
return {}.hasOwnProperty.call(obj, key);
|
|
28996
28639
|
}
|
|
28997
28640
|
function getValueAtIndexOrReturn(value, index2, defaultValue) {
|
|
28998
28641
|
if (Array.isArray(value)) {
|
|
@@ -29022,8 +28665,8 @@ function debounce(fn2, ms) {
|
|
|
29022
28665
|
}
|
|
29023
28666
|
function removeProperties(obj, keys2) {
|
|
29024
28667
|
var clone = Object.assign({}, obj);
|
|
29025
|
-
keys2.forEach(function(
|
|
29026
|
-
delete clone[
|
|
28668
|
+
keys2.forEach(function(key) {
|
|
28669
|
+
delete clone[key];
|
|
29027
28670
|
});
|
|
29028
28671
|
return clone;
|
|
29029
28672
|
}
|
|
@@ -29050,9 +28693,9 @@ function arrayFrom(value) {
|
|
|
29050
28693
|
return [].slice.call(value);
|
|
29051
28694
|
}
|
|
29052
28695
|
function removeUndefinedProps(obj) {
|
|
29053
|
-
return Object.keys(obj).reduce(function(acc,
|
|
29054
|
-
if (obj[
|
|
29055
|
-
acc[
|
|
28696
|
+
return Object.keys(obj).reduce(function(acc, key) {
|
|
28697
|
+
if (obj[key] !== void 0) {
|
|
28698
|
+
acc[key] = obj[key];
|
|
29056
28699
|
}
|
|
29057
28700
|
return acc;
|
|
29058
28701
|
}, {});
|
|
@@ -29304,8 +28947,8 @@ var setDefaultProps = function setDefaultProps2(partialProps) {
|
|
|
29304
28947
|
validateProps(partialProps, []);
|
|
29305
28948
|
}
|
|
29306
28949
|
var keys2 = Object.keys(partialProps);
|
|
29307
|
-
keys2.forEach(function(
|
|
29308
|
-
defaultProps[
|
|
28950
|
+
keys2.forEach(function(key) {
|
|
28951
|
+
defaultProps[key] = partialProps[key];
|
|
29309
28952
|
});
|
|
29310
28953
|
};
|
|
29311
28954
|
function getExtendedPassedProps(passedProps) {
|
|
@@ -29324,18 +28967,18 @@ function getDataAttributeProps(reference2, plugins) {
|
|
|
29324
28967
|
var propKeys = plugins ? Object.keys(getExtendedPassedProps(Object.assign({}, defaultProps, {
|
|
29325
28968
|
plugins
|
|
29326
28969
|
}))) : defaultKeys;
|
|
29327
|
-
var props = propKeys.reduce(function(acc,
|
|
29328
|
-
var valueAsString = (reference2.getAttribute("data-tippy-" +
|
|
28970
|
+
var props = propKeys.reduce(function(acc, key) {
|
|
28971
|
+
var valueAsString = (reference2.getAttribute("data-tippy-" + key) || "").trim();
|
|
29329
28972
|
if (!valueAsString) {
|
|
29330
28973
|
return acc;
|
|
29331
28974
|
}
|
|
29332
|
-
if (
|
|
29333
|
-
acc[
|
|
28975
|
+
if (key === "content") {
|
|
28976
|
+
acc[key] = valueAsString;
|
|
29334
28977
|
} else {
|
|
29335
28978
|
try {
|
|
29336
|
-
acc[
|
|
28979
|
+
acc[key] = JSON.parse(valueAsString);
|
|
29337
28980
|
} catch (e) {
|
|
29338
|
-
acc[
|
|
28981
|
+
acc[key] = valueAsString;
|
|
29339
28982
|
}
|
|
29340
28983
|
}
|
|
29341
28984
|
return acc;
|
|
@@ -30259,8 +29902,8 @@ tippy.setDefaultProps({
|
|
|
30259
29902
|
});
|
|
30260
29903
|
const _export_sfc = (sfc, props) => {
|
|
30261
29904
|
const target = sfc.__vccOpts || sfc;
|
|
30262
|
-
for (const [
|
|
30263
|
-
target[
|
|
29905
|
+
for (const [key, val] of props) {
|
|
29906
|
+
target[key] = val;
|
|
30264
29907
|
}
|
|
30265
29908
|
return target;
|
|
30266
29909
|
};
|
|
@@ -30356,9 +29999,6 @@ const Mentions = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-b
|
|
|
30356
29999
|
const popoverPluginKey = new PluginKey("popoverPlugin");
|
|
30357
30000
|
const PopoverPlugin = Extension.create({
|
|
30358
30001
|
name: "popoverPlugin",
|
|
30359
|
-
addOptions() {
|
|
30360
|
-
return {};
|
|
30361
|
-
},
|
|
30362
30002
|
addPmPlugins() {
|
|
30363
30003
|
const popover = new Plugin({
|
|
30364
30004
|
key: popoverPluginKey,
|
|
@@ -31655,9 +31295,9 @@ const Pagination = Extension.create({
|
|
|
31655
31295
|
if (syncMeta && syncMeta.isChangeOrigin || listSyncMeta) {
|
|
31656
31296
|
return { ...oldState };
|
|
31657
31297
|
}
|
|
31658
|
-
const
|
|
31659
|
-
if (
|
|
31660
|
-
if (
|
|
31298
|
+
const imagePluginTransaction = tr.getMeta(ImagePlaceholderPluginKey);
|
|
31299
|
+
if (imagePluginTransaction) {
|
|
31300
|
+
if (imagePluginTransaction.type === "remove") {
|
|
31661
31301
|
onImageLoad(editor);
|
|
31662
31302
|
}
|
|
31663
31303
|
return { ...oldState };
|
|
@@ -32586,11 +32226,12 @@ const Search = Extension.create({
|
|
|
32586
32226
|
addCommands() {
|
|
32587
32227
|
return {
|
|
32588
32228
|
/**
|
|
32589
|
-
*
|
|
32229
|
+
* Navigates to the first search match
|
|
32590
32230
|
* @category Command
|
|
32231
|
+
* @returns {Function} - Command function
|
|
32591
32232
|
* @example
|
|
32592
|
-
*
|
|
32593
|
-
* @note Scrolls
|
|
32233
|
+
* goToFirstMatch()
|
|
32234
|
+
* @note Scrolls Editor to the first match of called search().
|
|
32594
32235
|
*/
|
|
32595
32236
|
goToFirstMatch: () => (
|
|
32596
32237
|
/** @returns {boolean} */
|
|
@@ -32606,13 +32247,13 @@ const Search = Extension.create({
|
|
|
32606
32247
|
}
|
|
32607
32248
|
),
|
|
32608
32249
|
/**
|
|
32609
|
-
*
|
|
32250
|
+
* Searches for the string match in Editor content
|
|
32610
32251
|
* @category Command
|
|
32611
32252
|
* @param {String|RegExp} patternInput - Search string or pattern
|
|
32253
|
+
* @returns {Function} - Command function that returns matches
|
|
32612
32254
|
* @example
|
|
32613
|
-
*
|
|
32614
|
-
*
|
|
32615
|
-
* @note Returns array of SearchMatch objects with positions and IDs
|
|
32255
|
+
* search('test string')
|
|
32256
|
+
* @note Searches for the test string in the Editor content and returns an array of matches
|
|
32616
32257
|
*/
|
|
32617
32258
|
search: (patternInput) => (
|
|
32618
32259
|
/** @returns {SearchMatch[]} */
|
|
@@ -32655,13 +32296,14 @@ const Search = Extension.create({
|
|
|
32655
32296
|
}
|
|
32656
32297
|
),
|
|
32657
32298
|
/**
|
|
32658
|
-
*
|
|
32299
|
+
* Navigates to the selected match
|
|
32659
32300
|
* @category Command
|
|
32660
|
-
* @param {SearchMatch} match
|
|
32301
|
+
* @param {SearchMatch} match Match at specific index
|
|
32302
|
+
* @returns {Function} - Command function
|
|
32661
32303
|
* @example
|
|
32662
|
-
* const
|
|
32663
|
-
*
|
|
32664
|
-
* @note Scrolls to match and
|
|
32304
|
+
* const searchResult = search('test string')
|
|
32305
|
+
* goToSearchResult(searchResult[3])
|
|
32306
|
+
* @note Scrolls Editor to the fourth match of called search() and sets selection on it.
|
|
32665
32307
|
*/
|
|
32666
32308
|
goToSearchResult: (match) => (
|
|
32667
32309
|
/** @returns {boolean} */
|
|
@@ -32923,9 +32565,6 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
|
|
|
32923
32565
|
};
|
|
32924
32566
|
const NodeResizer = Extension.create({
|
|
32925
32567
|
name: "nodeResizer",
|
|
32926
|
-
addOptions() {
|
|
32927
|
-
return {};
|
|
32928
|
-
},
|
|
32929
32568
|
addPmPlugins() {
|
|
32930
32569
|
const isHeadless = this.editor.options.isHeadless;
|
|
32931
32570
|
const hasDocument = typeof document !== "undefined";
|
|
@@ -33017,7 +32656,6 @@ const getStarterExtensions = () => {
|
|
|
33017
32656
|
DropCursor,
|
|
33018
32657
|
Image,
|
|
33019
32658
|
BookmarkStart,
|
|
33020
|
-
BookmarkEnd,
|
|
33021
32659
|
Mention,
|
|
33022
32660
|
Collaboration,
|
|
33023
32661
|
CollaborationCursor,
|
|
@@ -33060,20 +32698,18 @@ export {
|
|
|
33060
32698
|
getQuickFormatList as a,
|
|
33061
32699
|
generateLinkedStyleString as b,
|
|
33062
32700
|
getFileOpener as c,
|
|
33063
|
-
|
|
33064
|
-
|
|
33065
|
-
|
|
32701
|
+
undoDepth as d,
|
|
32702
|
+
getStarterExtensions as e,
|
|
32703
|
+
getRichTextExtensions as f,
|
|
33066
32704
|
global as g,
|
|
33067
|
-
|
|
33068
|
-
|
|
33069
|
-
|
|
33070
|
-
|
|
33071
|
-
|
|
33072
|
-
|
|
33073
|
-
|
|
33074
|
-
|
|
33075
|
-
getAllowedImageDimensions as p,
|
|
33076
|
-
replaceSelectionWithImagePlaceholder as r,
|
|
32705
|
+
Extension as h,
|
|
32706
|
+
index$1 as i,
|
|
32707
|
+
index as j,
|
|
32708
|
+
AnnotatorHelpers as k,
|
|
32709
|
+
SectionHelpers as l,
|
|
32710
|
+
getAllowedImageDimensions as m,
|
|
32711
|
+
redoDepth as r,
|
|
32712
|
+
startImageUpload as s,
|
|
33077
32713
|
useHighContrastMode as u,
|
|
33078
32714
|
yUndoPluginKey as y
|
|
33079
32715
|
};
|