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