@harbour-enterprises/superdoc 0.20.0-next.8 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{PdfViewer-Ch0v9vA6.cjs → PdfViewer--8KwZWwP.cjs} +1 -1
- package/dist/chunks/{PdfViewer-BoDHZ2nW.es.js → PdfViewer-SpPk10jl.es.js} +1 -1
- package/dist/chunks/{index-BWPWqVxp.es.js → index-BjLjS5O9.es.js} +3 -3
- package/dist/chunks/{index-DFOT300M.cjs → index-yRUOdLmp.cjs} +3 -3
- package/dist/chunks/{super-editor.es-BQ6kZTNg.cjs → super-editor.es-CuNhawtn.cjs} +1937 -3044
- package/dist/chunks/{super-editor.es-sBfWb5tn.es.js → super-editor.es-D24_Ox1u.es.js} +1937 -3044
- package/dist/core/SuperDoc.d.ts.map +1 -1
- package/dist/style.css +0 -38
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-C91Sr_5w.js → converter-Cg4SgA5y.js} +1132 -1616
- package/dist/super-editor/chunks/{docx-zipper-Cl7LYpt6.js → docx-zipper-CDX2fnxb.js} +2 -2
- package/dist/super-editor/chunks/{editor-a7cQT9Dw.js → editor-MKuu81v8.js} +638 -1250
- package/dist/super-editor/chunks/{toolbar-DiNFtCKr.js → toolbar-CpQ7L2K-.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/src/core/helpers/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/exporter.d.ts +1 -7
- package/dist/super-editor/src/core/super-converter/v2/importer/imageImporter.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v2/importer/tableImporter.d.ts +22 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/utils.d.ts +3 -10
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/w-p-helpers.d.ts +1 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tc/helpers/legacy-handle-table-cell-node.d.ts +1 -1
- package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +1 -11
- package/dist/super-editor/src/extensions/image/imageHelpers/imagePlaceholderPlugin.d.ts +5 -0
- package/dist/super-editor/src/extensions/image/imageHelpers/index.d.ts +1 -2
- package/dist/super-editor/src/extensions/image/imageHelpers/processUploadedImage.d.ts +2 -2
- package/dist/super-editor/src/extensions/image/imageHelpers/startImageUpload.d.ts +23 -18
- package/dist/super-editor/src/extensions/structured-content/structured-content-block.d.ts +1 -3
- package/dist/super-editor/src/extensions/structured-content/structured-content.d.ts +1 -3
- package/dist/super-editor/src/extensions/table/table.d.ts +0 -330
- package/dist/super-editor/style.css +0 -38
- package/dist/super-editor/super-editor.es.js +55 -65
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +2566 -3673
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/super-editor/src/core/helpers/updateDOMAttributes.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/export-helpers/pre-process-vertical-merge-cells.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/helpers/mediaHelpers.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bidiVisual/bidiVisual-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bidiVisual/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/bottom-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/marginBottom-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/drawing/drawing-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/drawing/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/end-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/marginEnd-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/gridCol/gridCol-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/gridCol/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideH/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideH/insideH-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideV/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideV/insideV-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/left-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/marginLeft-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/marginRight-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/right-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/shd/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/shd/shd-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/marginStart-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/start-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tbl/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tbl/tbl-translator.d.ts +0 -28
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblBorders/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblBorders/tblBorders-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCaption/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCaption/tblCaption-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCellMar/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCellMar/tblCellMar-translator.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblDescription/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblDescription/tblDescription-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-helpers.d.ts +0 -5
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-translator.d.ts +0 -5
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblInd/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblInd/tblInd-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLayout/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLayout/tblLayout-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLook/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLook/tblLook-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblOverlap/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblOverlap/tblOverlap-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblPr/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblPr/tblPr-translator.d.ts +0 -5
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyle/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyle/tblStyle-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleColBandSize/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleColBandSize/tblStyleColBandSize-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleRowBandSize/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleRowBandSize/tblStyleRowBandSize-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblW/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblW/tblW-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblpPr/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblpPr/tblpPr-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/index.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/marginTop-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/top-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/anchor-translator.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/helpers/handle-anchor-node.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/helpers/translate-anchor-node.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/decode-image-node-helpers.d.ts +0 -18
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/encode-image-node-helpers.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/helpers/handle-inline-node.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/helpers/translate-inline-node.d.ts +0 -6
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/index.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/inline-translator.d.ts +0 -6
- package/dist/super-editor/src/extensions/image/imageHelpers/fileNameUtils.d.ts +0 -3
- package/dist/super-editor/src/extensions/image/imageHelpers/handleBase64.d.ts +0 -1
- package/dist/super-editor/src/extensions/image/imageHelpers/handleUrl.d.ts +0 -2
- package/dist/super-editor/src/extensions/image/imageHelpers/imageRegistrationPlugin.d.ts +0 -11
- package/dist/super-editor/src/extensions/structured-content/StructuredContentBlockView.d.ts +0 -9
- package/dist/super-editor/src/extensions/structured-content/StructuredContentInlineView.d.ts +0 -9
- package/dist/super-editor/src/extensions/structured-content/StructuredContentViewBase.d.ts +0 -24
|
@@ -2,8 +2,8 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __typeError = (msg) => {
|
|
3
3
|
throw TypeError(msg);
|
|
4
4
|
};
|
|
5
|
-
var __defNormalProp = (obj,
|
|
6
|
-
var __publicField = (obj,
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
7
|
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
8
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
@@ -12,9 +12,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
12
12
|
var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _ListItemNodeView_instances, init_fn2, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _DocumentSectionView_instances, init_fn3, addToolTip_fn;
|
|
13
13
|
import * as Y from "yjs";
|
|
14
14
|
import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
|
|
15
|
-
import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as InputRule, ah as kebabCase, ai as findParentNodeClosestToPos, aj as getListItemStyleDefinitions, ak as docxNumberigHelpers, al as parseIndentElement, am as combineIndents, an as StepMap, ao as
|
|
15
|
+
import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as InputRule, ah as kebabCase, ai as findParentNodeClosestToPos, aj as getListItemStyleDefinitions, ak as docxNumberigHelpers, al as parseIndentElement, am as combineIndents, an as StepMap, ao as getColStyleDeclaration, ap as SelectionRange, aq as Transform, ar as isInTable$1, as as createColGroup, at as generateDocxRandomId, au as insertNewRelationship, av as htmlHandler } from "./converter-Cg4SgA5y.js";
|
|
16
16
|
import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
|
|
17
|
-
import { D as DocxZipper } from "./docx-zipper-
|
|
17
|
+
import { D as DocxZipper } from "./docx-zipper-CDX2fnxb.js";
|
|
18
18
|
var GOOD_LEAF_SIZE = 200;
|
|
19
19
|
var RopeSequence = function RopeSequence2() {
|
|
20
20
|
};
|
|
@@ -662,11 +662,11 @@ function hasBlockDesc(dom) {
|
|
|
662
662
|
const selectionCollapsed = function(domSel) {
|
|
663
663
|
return domSel.focusNode && isEquivalentPosition(domSel.focusNode, domSel.focusOffset, domSel.anchorNode, domSel.anchorOffset);
|
|
664
664
|
};
|
|
665
|
-
function keyEvent(keyCode,
|
|
665
|
+
function keyEvent(keyCode, key) {
|
|
666
666
|
let event = document.createEvent("Event");
|
|
667
667
|
event.initEvent("keydown", true, true);
|
|
668
668
|
event.keyCode = keyCode;
|
|
669
|
-
event.key = event.code =
|
|
669
|
+
event.key = event.code = key;
|
|
670
670
|
return event;
|
|
671
671
|
}
|
|
672
672
|
function deepActiveElement(doc2) {
|
|
@@ -1872,18 +1872,17 @@ class NodeViewDesc extends ViewDesc {
|
|
|
1872
1872
|
}
|
|
1873
1873
|
// Mark this node as being the selected node.
|
|
1874
1874
|
selectNode() {
|
|
1875
|
-
if (this.nodeDOM.nodeType == 1)
|
|
1875
|
+
if (this.nodeDOM.nodeType == 1)
|
|
1876
1876
|
this.nodeDOM.classList.add("ProseMirror-selectednode");
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
}
|
|
1877
|
+
if (this.contentDOM || !this.node.type.spec.draggable)
|
|
1878
|
+
this.dom.draggable = true;
|
|
1880
1879
|
}
|
|
1881
1880
|
// Remove selected node marking from this node.
|
|
1882
1881
|
deselectNode() {
|
|
1883
1882
|
if (this.nodeDOM.nodeType == 1) {
|
|
1884
1883
|
this.nodeDOM.classList.remove("ProseMirror-selectednode");
|
|
1885
1884
|
if (this.contentDOM || !this.node.type.spec.draggable)
|
|
1886
|
-
this.
|
|
1885
|
+
this.dom.removeAttribute("draggable");
|
|
1887
1886
|
}
|
|
1888
1887
|
}
|
|
1889
1888
|
get domAtom() {
|
|
@@ -3543,7 +3542,7 @@ class MouseDown {
|
|
|
3543
3542
|
}
|
|
3544
3543
|
const target = flushed ? null : event.target;
|
|
3545
3544
|
const targetDesc = target ? view.docView.nearestDesc(target, true) : null;
|
|
3546
|
-
this.target = targetDesc && targetDesc.
|
|
3545
|
+
this.target = targetDesc && targetDesc.dom.nodeType == 1 ? targetDesc.dom : null;
|
|
3547
3546
|
let { selection } = view.state;
|
|
3548
3547
|
if (event.button == 0 && targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos)
|
|
3549
3548
|
this.mightDrag = {
|
|
@@ -5914,9 +5913,9 @@ const writeAny = (encoder, data) => {
|
|
|
5914
5913
|
const keys2 = Object.keys(data);
|
|
5915
5914
|
writeVarUint(encoder, keys2.length);
|
|
5916
5915
|
for (let i = 0; i < keys2.length; i++) {
|
|
5917
|
-
const
|
|
5918
|
-
writeVarString(encoder,
|
|
5919
|
-
writeAny(encoder, data[
|
|
5916
|
+
const key = keys2[i];
|
|
5917
|
+
writeVarString(encoder, key);
|
|
5918
|
+
writeAny(encoder, data[key]);
|
|
5920
5919
|
}
|
|
5921
5920
|
}
|
|
5922
5921
|
break;
|
|
@@ -5935,17 +5934,17 @@ const unexpectedCase = () => {
|
|
|
5935
5934
|
throw create$1("Unexpected case");
|
|
5936
5935
|
};
|
|
5937
5936
|
const create = () => /* @__PURE__ */ new Map();
|
|
5938
|
-
const setIfUndefined = (map2,
|
|
5939
|
-
let set = map2.get(
|
|
5937
|
+
const setIfUndefined = (map2, key, createT) => {
|
|
5938
|
+
let set = map2.get(key);
|
|
5940
5939
|
if (set === void 0) {
|
|
5941
|
-
map2.set(
|
|
5940
|
+
map2.set(key, set = createT());
|
|
5942
5941
|
}
|
|
5943
5942
|
return set;
|
|
5944
5943
|
};
|
|
5945
5944
|
const keys = Object.keys;
|
|
5946
5945
|
const every = (obj, f) => {
|
|
5947
|
-
for (const
|
|
5948
|
-
if (!f(obj[
|
|
5946
|
+
for (const key in obj) {
|
|
5947
|
+
if (!f(obj[key], key)) {
|
|
5949
5948
|
return false;
|
|
5950
5949
|
}
|
|
5951
5950
|
}
|
|
@@ -6001,14 +6000,14 @@ class VarStoragePolyfill {
|
|
|
6001
6000
|
* @param {string} key
|
|
6002
6001
|
* @param {any} newValue
|
|
6003
6002
|
*/
|
|
6004
|
-
setItem(
|
|
6005
|
-
this.map.set(
|
|
6003
|
+
setItem(key, newValue) {
|
|
6004
|
+
this.map.set(key, newValue);
|
|
6006
6005
|
}
|
|
6007
6006
|
/**
|
|
6008
6007
|
* @param {string} key
|
|
6009
6008
|
*/
|
|
6010
|
-
getItem(
|
|
6011
|
-
return this.map.get(
|
|
6009
|
+
getItem(key) {
|
|
6010
|
+
return this.map.get(key);
|
|
6012
6011
|
}
|
|
6013
6012
|
}
|
|
6014
6013
|
let _localStorage = new VarStoragePolyfill();
|
|
@@ -6051,9 +6050,9 @@ const computeParams = () => {
|
|
|
6051
6050
|
params = create();
|
|
6052
6051
|
(location.search || "?").slice(1).split("&").forEach((kv) => {
|
|
6053
6052
|
if (kv.length !== 0) {
|
|
6054
|
-
const [
|
|
6055
|
-
params.set(`--${fromCamelCase(
|
|
6056
|
-
params.set(`-${fromCamelCase(
|
|
6053
|
+
const [key, value] = kv.split("=");
|
|
6054
|
+
params.set(`--${fromCamelCase(key, "-")}`, value);
|
|
6055
|
+
params.set(`-${fromCamelCase(key, "-")}`, value);
|
|
6057
6056
|
}
|
|
6058
6057
|
});
|
|
6059
6058
|
} else {
|
|
@@ -6336,8 +6335,8 @@ const ySyncPlugin = (yXmlFragment, {
|
|
|
6336
6335
|
const change = tr.getMeta(ySyncPluginKey);
|
|
6337
6336
|
if (change !== void 0) {
|
|
6338
6337
|
pluginState = Object.assign({}, pluginState);
|
|
6339
|
-
for (const
|
|
6340
|
-
pluginState[
|
|
6338
|
+
for (const key in change) {
|
|
6339
|
+
pluginState[key] = change[key];
|
|
6341
6340
|
}
|
|
6342
6341
|
}
|
|
6343
6342
|
pluginState.addToHistory = tr.getMeta("addToHistory") !== false;
|
|
@@ -6609,7 +6608,7 @@ class ProsemirrorBinding {
|
|
|
6609
6608
|
snapshot = Y.snapshot(historyDoc);
|
|
6610
6609
|
if (historyType._item === null) {
|
|
6611
6610
|
const rootKey = Array.from(this.doc.share.keys()).find(
|
|
6612
|
-
(
|
|
6611
|
+
(key) => this.doc.share.get(key) === this.type
|
|
6613
6612
|
);
|
|
6614
6613
|
historyType = historyDoc.getXmlFragment(rootKey);
|
|
6615
6614
|
} else {
|
|
@@ -6898,10 +6897,10 @@ const createTypeFromTextNodes = (nodes, meta) => {
|
|
|
6898
6897
|
};
|
|
6899
6898
|
const createTypeFromElementNode = (node, meta) => {
|
|
6900
6899
|
const type = new Y.XmlElement(node.type.name);
|
|
6901
|
-
for (const
|
|
6902
|
-
const val = node.attrs[
|
|
6903
|
-
if (val !== null &&
|
|
6904
|
-
type.setAttribute(
|
|
6900
|
+
for (const key in node.attrs) {
|
|
6901
|
+
const val = node.attrs[key];
|
|
6902
|
+
if (val !== null && key !== "ychange") {
|
|
6903
|
+
type.setAttribute(key, val);
|
|
6905
6904
|
}
|
|
6906
6905
|
}
|
|
6907
6906
|
type.insert(
|
|
@@ -6916,13 +6915,13 @@ const createTypeFromElementNode = (node, meta) => {
|
|
|
6916
6915
|
const createTypeFromTextOrElementNode = (node, meta) => node instanceof Array ? createTypeFromTextNodes(node, meta) : createTypeFromElementNode(node, meta);
|
|
6917
6916
|
const isObject = (val) => typeof val === "object" && val !== null;
|
|
6918
6917
|
const equalAttrs = (pattrs, yattrs) => {
|
|
6919
|
-
const keys2 = Object.keys(pattrs).filter((
|
|
6920
|
-
let eq = keys2.length === (yattrs == null ? 0 : Object.keys(yattrs).filter((
|
|
6918
|
+
const keys2 = Object.keys(pattrs).filter((key) => pattrs[key] !== null);
|
|
6919
|
+
let eq = keys2.length === (yattrs == null ? 0 : Object.keys(yattrs).filter((key) => yattrs[key] !== null).length);
|
|
6921
6920
|
for (let i = 0; i < keys2.length && eq; i++) {
|
|
6922
|
-
const
|
|
6923
|
-
const l = pattrs[
|
|
6924
|
-
const r2 = yattrs[
|
|
6925
|
-
eq =
|
|
6921
|
+
const key = keys2[i];
|
|
6922
|
+
const l = pattrs[key];
|
|
6923
|
+
const r2 = yattrs[key];
|
|
6924
|
+
eq = key === "ychange" || l === r2 || isObject(l) && isObject(r2) && equalAttrs(l, r2);
|
|
6926
6925
|
}
|
|
6927
6926
|
return eq;
|
|
6928
6927
|
};
|
|
@@ -7069,18 +7068,18 @@ const updateYFragment = (y, yDomFragment, pNode, meta) => {
|
|
|
7069
7068
|
if (yDomFragment instanceof Y.XmlElement) {
|
|
7070
7069
|
const yDomAttrs = yDomFragment.getAttributes();
|
|
7071
7070
|
const pAttrs = pNode.attrs;
|
|
7072
|
-
for (const
|
|
7073
|
-
if (pAttrs[
|
|
7074
|
-
if (yDomAttrs[
|
|
7075
|
-
yDomFragment.setAttribute(
|
|
7071
|
+
for (const key in pAttrs) {
|
|
7072
|
+
if (pAttrs[key] !== null) {
|
|
7073
|
+
if (yDomAttrs[key] !== pAttrs[key] && key !== "ychange") {
|
|
7074
|
+
yDomFragment.setAttribute(key, pAttrs[key]);
|
|
7076
7075
|
}
|
|
7077
7076
|
} else {
|
|
7078
|
-
yDomFragment.removeAttribute(
|
|
7077
|
+
yDomFragment.removeAttribute(key);
|
|
7079
7078
|
}
|
|
7080
7079
|
}
|
|
7081
|
-
for (const
|
|
7082
|
-
if (pAttrs[
|
|
7083
|
-
yDomFragment.removeAttribute(
|
|
7080
|
+
for (const key in yDomAttrs) {
|
|
7081
|
+
if (pAttrs[key] === void 0) {
|
|
7082
|
+
yDomFragment.removeAttribute(key);
|
|
7084
7083
|
}
|
|
7085
7084
|
}
|
|
7086
7085
|
}
|
|
@@ -7211,19 +7210,19 @@ const updateMetas = () => {
|
|
|
7211
7210
|
const tr = view.state.tr;
|
|
7212
7211
|
const syncState = ySyncPluginKey.getState(view.state);
|
|
7213
7212
|
if (syncState && syncState.binding && !syncState.binding.isDestroyed) {
|
|
7214
|
-
metas.forEach((val,
|
|
7215
|
-
tr.setMeta(
|
|
7213
|
+
metas.forEach((val, key) => {
|
|
7214
|
+
tr.setMeta(key, val);
|
|
7216
7215
|
});
|
|
7217
7216
|
view.dispatch(tr);
|
|
7218
7217
|
}
|
|
7219
7218
|
});
|
|
7220
7219
|
};
|
|
7221
|
-
const setMeta$1 = (view,
|
|
7220
|
+
const setMeta$1 = (view, key, value) => {
|
|
7222
7221
|
if (!viewsToUpdate) {
|
|
7223
7222
|
viewsToUpdate = /* @__PURE__ */ new Map();
|
|
7224
7223
|
timeout(0, updateMetas);
|
|
7225
7224
|
}
|
|
7226
|
-
setIfUndefined(viewsToUpdate, view, create).set(
|
|
7225
|
+
setIfUndefined(viewsToUpdate, view, create).set(key, value);
|
|
7227
7226
|
};
|
|
7228
7227
|
const absolutePositionToRelativePosition = (pos, type, mapping) => {
|
|
7229
7228
|
if (pos === 0) {
|
|
@@ -7923,21 +7922,21 @@ class Attribute {
|
|
|
7923
7922
|
let attrs = {};
|
|
7924
7923
|
for (const item of items) {
|
|
7925
7924
|
const mergedAttributes = { ...attrs };
|
|
7926
|
-
for (const [
|
|
7927
|
-
const exists = mergedAttributes[
|
|
7925
|
+
for (const [key, value] of Object.entries(item)) {
|
|
7926
|
+
const exists = mergedAttributes[key];
|
|
7928
7927
|
if (!exists) {
|
|
7929
|
-
mergedAttributes[
|
|
7928
|
+
mergedAttributes[key] = value;
|
|
7930
7929
|
continue;
|
|
7931
7930
|
}
|
|
7932
|
-
if (
|
|
7931
|
+
if (key === "class") {
|
|
7933
7932
|
const valueClasses = value ? value.split(" ") : [];
|
|
7934
|
-
const existingClasses = mergedAttributes[
|
|
7933
|
+
const existingClasses = mergedAttributes[key] ? mergedAttributes[key].split(" ") : [];
|
|
7935
7934
|
const insertClasses = valueClasses.filter((value2) => !existingClasses.includes(value2));
|
|
7936
|
-
mergedAttributes[
|
|
7937
|
-
} else if (
|
|
7938
|
-
mergedAttributes[
|
|
7935
|
+
mergedAttributes[key] = [...existingClasses, ...insertClasses].join(" ");
|
|
7936
|
+
} else if (key === "style") {
|
|
7937
|
+
mergedAttributes[key] = [mergedAttributes[key], value].join("; ");
|
|
7939
7938
|
} else {
|
|
7940
|
-
mergedAttributes[
|
|
7939
|
+
mergedAttributes[key] = value;
|
|
7941
7940
|
}
|
|
7942
7941
|
}
|
|
7943
7942
|
attrs = mergedAttributes;
|
|
@@ -8247,8 +8246,8 @@ const insertTabNode = () => ({ tr, state, dispatch }) => {
|
|
|
8247
8246
|
if (dispatch) dispatch(tr);
|
|
8248
8247
|
return true;
|
|
8249
8248
|
};
|
|
8250
|
-
const setMeta = (
|
|
8251
|
-
tr.setMeta(
|
|
8249
|
+
const setMeta = (key, value) => ({ tr }) => {
|
|
8250
|
+
tr.setMeta(key, value);
|
|
8252
8251
|
return true;
|
|
8253
8252
|
};
|
|
8254
8253
|
const ensureMarks = (state, splittableMarks) => {
|
|
@@ -11376,14 +11375,14 @@ const updateYdocDocxData = async (editor, ydoc) => {
|
|
|
11376
11375
|
const metaMap = ydoc.getMap("meta");
|
|
11377
11376
|
const docx = [...metaMap.get("docx")];
|
|
11378
11377
|
const newXml = await editor.exportDocx({ getUpdatedDocs: true });
|
|
11379
|
-
Object.keys(newXml).forEach((
|
|
11380
|
-
const fileIndex = docx.findIndex((item) => item.name ===
|
|
11378
|
+
Object.keys(newXml).forEach((key) => {
|
|
11379
|
+
const fileIndex = docx.findIndex((item) => item.name === key);
|
|
11381
11380
|
if (fileIndex > -1) {
|
|
11382
11381
|
docx.splice(fileIndex, 1);
|
|
11383
11382
|
}
|
|
11384
11383
|
docx.push({
|
|
11385
|
-
name:
|
|
11386
|
-
content: newXml[
|
|
11384
|
+
name: key,
|
|
11385
|
+
content: newXml[key]
|
|
11387
11386
|
});
|
|
11388
11387
|
});
|
|
11389
11388
|
ydoc.transact(
|
|
@@ -11399,8 +11398,8 @@ const initPaginationData = async (editor) => {
|
|
|
11399
11398
|
const sectionData = { headers: {}, footers: {} };
|
|
11400
11399
|
const headerIds = editor.converter.headerIds.ids;
|
|
11401
11400
|
const footerIds = editor.converter.footerIds.ids;
|
|
11402
|
-
for (let
|
|
11403
|
-
const sectionId = headerIds[
|
|
11401
|
+
for (let key in headerIds) {
|
|
11402
|
+
const sectionId = headerIds[key];
|
|
11404
11403
|
if (!sectionId) continue;
|
|
11405
11404
|
const dataForThisSection = editor.converter.headers[sectionId];
|
|
11406
11405
|
if (!sectionData.headers[sectionId]) sectionData.headers[sectionId] = {};
|
|
@@ -11410,8 +11409,8 @@ const initPaginationData = async (editor) => {
|
|
|
11410
11409
|
sectionData.headers[sectionId].sectionEditor = sectionEditor;
|
|
11411
11410
|
sectionData.headers[sectionId].sectionContainer = sectionContainer;
|
|
11412
11411
|
}
|
|
11413
|
-
for (let
|
|
11414
|
-
const sectionId = footerIds[
|
|
11412
|
+
for (let key in footerIds) {
|
|
11413
|
+
const sectionId = footerIds[key];
|
|
11415
11414
|
if (!sectionId) continue;
|
|
11416
11415
|
const dataForThisSection = editor.converter.footers[sectionId];
|
|
11417
11416
|
if (!sectionData.headers[sectionId]) sectionData.footers[sectionId] = {};
|
|
@@ -12480,16 +12479,16 @@ const generateTableIfNecessary = ({ tableNode, annotationValues, tr, state }) =>
|
|
|
12480
12479
|
if (rowsToGenerate <= 1) return;
|
|
12481
12480
|
const validateAttributes = (attrs) => {
|
|
12482
12481
|
const cleaned = {};
|
|
12483
|
-
for (const [
|
|
12482
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
12484
12483
|
if (value !== void 0 && value !== null) {
|
|
12485
|
-
if (
|
|
12486
|
-
cleaned[
|
|
12487
|
-
} else if (
|
|
12488
|
-
cleaned[
|
|
12484
|
+
if (key === "displayLabel") {
|
|
12485
|
+
cleaned[key] = String(value);
|
|
12486
|
+
} else if (key === "rawHtml" || key === "linkUrl" || key === "imageSrc") {
|
|
12487
|
+
cleaned[key] = String(value);
|
|
12489
12488
|
} else if (typeof value === "string" && value.length > 0) {
|
|
12490
|
-
cleaned[
|
|
12489
|
+
cleaned[key] = value;
|
|
12491
12490
|
} else if (typeof value !== "string") {
|
|
12492
|
-
cleaned[
|
|
12491
|
+
cleaned[key] = value;
|
|
12493
12492
|
}
|
|
12494
12493
|
}
|
|
12495
12494
|
}
|
|
@@ -12767,10 +12766,10 @@ const Collaboration = Extension.create({
|
|
|
12767
12766
|
this.options.fragment = fragment;
|
|
12768
12767
|
const metaMap = this.options.ydoc.getMap("media");
|
|
12769
12768
|
metaMap.observe((event) => {
|
|
12770
|
-
event.changes.keys.forEach((_,
|
|
12771
|
-
if (!(
|
|
12772
|
-
const fileData = metaMap.get(
|
|
12773
|
-
this.editor.storage.image.media[
|
|
12769
|
+
event.changes.keys.forEach((_, key) => {
|
|
12770
|
+
if (!(key in this.editor.storage.image.media)) {
|
|
12771
|
+
const fileData = metaMap.get(key);
|
|
12772
|
+
this.editor.storage.image.media[key] = fileData;
|
|
12774
12773
|
}
|
|
12775
12774
|
});
|
|
12776
12775
|
});
|
|
@@ -12790,8 +12789,8 @@ const initializeMetaMap = (ydoc, editor) => {
|
|
|
12790
12789
|
metaMap.set("docx", editor.options.content);
|
|
12791
12790
|
metaMap.set("fonts", editor.options.fonts);
|
|
12792
12791
|
const mediaMap = ydoc.getMap("media");
|
|
12793
|
-
Object.entries(editor.options.mediaFiles).forEach(([
|
|
12794
|
-
mediaMap.set(
|
|
12792
|
+
Object.entries(editor.options.mediaFiles).forEach(([key, value]) => {
|
|
12793
|
+
mediaMap.set(key, value);
|
|
12795
12794
|
});
|
|
12796
12795
|
};
|
|
12797
12796
|
const checkDocxChanged = (transaction) => {
|
|
@@ -13553,8 +13552,8 @@ function processRelationships(root, convertedXml, results) {
|
|
|
13553
13552
|
};
|
|
13554
13553
|
const seenIds = /* @__PURE__ */ new Set();
|
|
13555
13554
|
const filtered = [];
|
|
13556
|
-
function extractStringAttr(attrs,
|
|
13557
|
-
return typeof attrs[
|
|
13555
|
+
function extractStringAttr(attrs, key) {
|
|
13556
|
+
return typeof attrs[key] === "string" ? attrs[key].trim() : "";
|
|
13558
13557
|
}
|
|
13559
13558
|
for (const rel of root.elements) {
|
|
13560
13559
|
rel.attributes = rel.attributes || {};
|
|
@@ -13776,10 +13775,10 @@ class SuperValidator {
|
|
|
13776
13775
|
this.logger.debug("Document analysis:", documentAnalysis);
|
|
13777
13776
|
let hasModifiedDocument = false;
|
|
13778
13777
|
const validationResults = [];
|
|
13779
|
-
Object.entries(__privateGet(this, _stateValidators)).forEach(([
|
|
13780
|
-
this.logger.debug(`🕵 Validating with ${
|
|
13778
|
+
Object.entries(__privateGet(this, _stateValidators)).forEach(([key, validator]) => {
|
|
13779
|
+
this.logger.debug(`🕵 Validating with ${key}...`);
|
|
13781
13780
|
const { results, modified } = validator(tr, documentAnalysis);
|
|
13782
|
-
validationResults.push({ key
|
|
13781
|
+
validationResults.push({ key, results });
|
|
13783
13782
|
hasModifiedDocument = hasModifiedDocument || modified;
|
|
13784
13783
|
});
|
|
13785
13784
|
if (!this.dryRun) dispatch(tr);
|
|
@@ -13796,10 +13795,10 @@ class SuperValidator {
|
|
|
13796
13795
|
const { dispatch } = __privateGet(this, _editor).view;
|
|
13797
13796
|
let hasModifiedDocument = false;
|
|
13798
13797
|
const validationResults = [];
|
|
13799
|
-
Object.entries(__privateGet(this, _xmlValidators)).forEach(([
|
|
13800
|
-
this.logger.debug(`🕵 Validating export with ${
|
|
13798
|
+
Object.entries(__privateGet(this, _xmlValidators)).forEach(([key, validator]) => {
|
|
13799
|
+
this.logger.debug(`🕵 Validating export with ${key}...`);
|
|
13801
13800
|
const { results, modified } = validator();
|
|
13802
|
-
validationResults.push({ key
|
|
13801
|
+
validationResults.push({ key, results });
|
|
13803
13802
|
hasModifiedDocument = hasModifiedDocument || modified;
|
|
13804
13803
|
});
|
|
13805
13804
|
if (!this.dryRun && hasModifiedDocument) dispatch(tr);
|
|
@@ -13823,11 +13822,11 @@ initializeValidators_fn = function() {
|
|
|
13823
13822
|
const requiredMarks = /* @__PURE__ */ new Set();
|
|
13824
13823
|
const initializeValidatorSet = (validatorFactories) => {
|
|
13825
13824
|
return Object.fromEntries(
|
|
13826
|
-
Object.entries(validatorFactories).map(([
|
|
13827
|
-
const validatorLogger = this.logger.withPrefix(
|
|
13825
|
+
Object.entries(validatorFactories).map(([key, factory]) => {
|
|
13826
|
+
const validatorLogger = this.logger.withPrefix(key);
|
|
13828
13827
|
const validator = factory({ editor: __privateGet(this, _editor), logger: validatorLogger });
|
|
13829
13828
|
__privateMethod(this, _SuperValidator_instances, collectValidatorRequirements_fn).call(this, validator, requiredNodes, requiredMarks);
|
|
13830
|
-
return [
|
|
13829
|
+
return [key, validator];
|
|
13831
13830
|
})
|
|
13832
13831
|
);
|
|
13833
13832
|
};
|
|
@@ -14747,7 +14746,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14747
14746
|
* @returns {Object | void} Migration results
|
|
14748
14747
|
*/
|
|
14749
14748
|
processCollaborationMigrations() {
|
|
14750
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.
|
|
14749
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.19.0");
|
|
14751
14750
|
if (!this.options.ydoc) return;
|
|
14752
14751
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
14753
14752
|
let docVersion = metaMap.get("version");
|
|
@@ -14983,9 +14982,7 @@ init_fn = function() {
|
|
|
14983
14982
|
this.initializeCollaborationData();
|
|
14984
14983
|
this.initDefaultStyles();
|
|
14985
14984
|
}
|
|
14986
|
-
if (!this.options.ydoc
|
|
14987
|
-
this.migrateListsToV2();
|
|
14988
|
-
}
|
|
14985
|
+
if (!this.options.ydoc) this.migrateListsToV2();
|
|
14989
14986
|
this.setDocumentMode(this.options.documentMode);
|
|
14990
14987
|
if (!this.options.ydoc) {
|
|
14991
14988
|
if (!this.options.isChildEditor) {
|
|
@@ -15149,8 +15146,8 @@ initMedia_fn = function() {
|
|
|
15149
15146
|
if (!this.options.ydoc) return this.storage.image.media = this.options.mediaFiles;
|
|
15150
15147
|
const mediaMap = this.options.ydoc.getMap("media");
|
|
15151
15148
|
if (this.options.isNewFile) {
|
|
15152
|
-
Object.entries(this.options.mediaFiles).forEach(([
|
|
15153
|
-
mediaMap.set(
|
|
15149
|
+
Object.entries(this.options.mediaFiles).forEach(([key, value]) => {
|
|
15150
|
+
mediaMap.set(key, value);
|
|
15154
15151
|
});
|
|
15155
15152
|
this.storage.image.media = this.options.mediaFiles;
|
|
15156
15153
|
} else {
|
|
@@ -16034,11 +16031,11 @@ const FormatCommands = Extension.create({
|
|
|
16034
16031
|
const { type, attrs } = mark;
|
|
16035
16032
|
const { name } = type;
|
|
16036
16033
|
if (name === "textStyle") {
|
|
16037
|
-
Object.keys(attrs).forEach((
|
|
16038
|
-
if (!attrs[
|
|
16034
|
+
Object.keys(attrs).forEach((key) => {
|
|
16035
|
+
if (!attrs[key]) return;
|
|
16039
16036
|
const attributes = {};
|
|
16040
|
-
attributes[
|
|
16041
|
-
processedMarks.push({ name:
|
|
16037
|
+
attributes[key] = attrs[key];
|
|
16038
|
+
processedMarks.push({ name: key, attrs: attributes });
|
|
16042
16039
|
});
|
|
16043
16040
|
} else {
|
|
16044
16041
|
processedMarks.push({ name, attrs });
|
|
@@ -16053,13 +16050,13 @@ const FormatCommands = Extension.create({
|
|
|
16053
16050
|
fontFamily: ["setFontFamily", "unsetFontFamily"]
|
|
16054
16051
|
};
|
|
16055
16052
|
let result = chain();
|
|
16056
|
-
Object.keys(marksToCommands).forEach((
|
|
16057
|
-
const [setCommand, unsetCommand, defaultParam] = marksToCommands[
|
|
16058
|
-
const markToApply = processedMarks.find((mark) => mark.name ===
|
|
16059
|
-
const hasEmptyAttrs = markToApply?.attrs && markToApply?.attrs[
|
|
16053
|
+
Object.keys(marksToCommands).forEach((key) => {
|
|
16054
|
+
const [setCommand, unsetCommand, defaultParam] = marksToCommands[key];
|
|
16055
|
+
const markToApply = processedMarks.find((mark) => mark.name === key);
|
|
16056
|
+
const hasEmptyAttrs = markToApply?.attrs && markToApply?.attrs[key];
|
|
16060
16057
|
let cmd = {};
|
|
16061
16058
|
if (!markToApply && !hasEmptyAttrs) cmd = { command: unsetCommand, argument: defaultParam };
|
|
16062
|
-
else cmd = { command: setCommand, argument: markToApply.attrs[
|
|
16059
|
+
else cmd = { command: setCommand, argument: markToApply.attrs[key] || defaultParam };
|
|
16063
16060
|
result = result[cmd.command](cmd.argument);
|
|
16064
16061
|
});
|
|
16065
16062
|
this.storage.storedStyle = null;
|
|
@@ -17563,7 +17560,7 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
|
|
|
17563
17560
|
resultStyles["text-transform"] = basedOnDefinitionStyles["text-transform"];
|
|
17564
17561
|
}
|
|
17565
17562
|
Object.entries(resultStyles).forEach(([k, value]) => {
|
|
17566
|
-
const
|
|
17563
|
+
const key = kebabCase(k);
|
|
17567
17564
|
const flattenedMarks = [];
|
|
17568
17565
|
node?.marks?.forEach((n) => {
|
|
17569
17566
|
if (n.type.name === "textStyle") {
|
|
@@ -17574,46 +17571,46 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
|
|
|
17574
17571
|
});
|
|
17575
17572
|
return;
|
|
17576
17573
|
}
|
|
17577
|
-
flattenedMarks.push({ key: n.type.name, value: n.attrs[
|
|
17574
|
+
flattenedMarks.push({ key: n.type.name, value: n.attrs[key] });
|
|
17578
17575
|
});
|
|
17579
|
-
const mark = flattenedMarks.find((n) => n.key ===
|
|
17576
|
+
const mark = flattenedMarks.find((n) => n.key === key);
|
|
17580
17577
|
const hasParentIndent = Object.keys(parent?.attrs?.indent || {});
|
|
17581
17578
|
const hasParentSpacing = Object.keys(parent?.attrs?.spacing || {});
|
|
17582
17579
|
const listTypes = ["orderedList", "listItem"];
|
|
17583
17580
|
if (!mark) {
|
|
17584
|
-
if (
|
|
17581
|
+
if (key === "spacing" && includeSpacing && !hasParentSpacing) {
|
|
17585
17582
|
const space = getSpacingStyle(value);
|
|
17586
17583
|
Object.entries(space).forEach(([k2, v]) => {
|
|
17587
17584
|
markValue[k2] = v;
|
|
17588
17585
|
});
|
|
17589
|
-
} else if (
|
|
17586
|
+
} else if (key === "indent" && includeSpacing && !hasParentIndent) {
|
|
17590
17587
|
const { leftIndent, rightIndent, firstLine } = value;
|
|
17591
17588
|
if (leftIndent) markValue["margin-left"] = leftIndent + "px";
|
|
17592
17589
|
if (rightIndent) markValue["margin-right"] = rightIndent + "px";
|
|
17593
17590
|
if (firstLine) markValue["text-indent"] = firstLine + "px";
|
|
17594
|
-
} else if (
|
|
17591
|
+
} else if (key === "bold" && node) {
|
|
17595
17592
|
const val = value?.value;
|
|
17596
17593
|
if (!listTypes.includes(node.type.name) && val !== "0") {
|
|
17597
17594
|
markValue["font-weight"] = "bold";
|
|
17598
17595
|
}
|
|
17599
|
-
} else if (
|
|
17596
|
+
} else if (key === "text-transform" && node) {
|
|
17600
17597
|
if (!listTypes.includes(node.type.name)) {
|
|
17601
|
-
markValue[
|
|
17598
|
+
markValue[key] = value;
|
|
17602
17599
|
}
|
|
17603
|
-
} else if (
|
|
17600
|
+
} else if (key === "font-size" && node) {
|
|
17604
17601
|
if (!listTypes.includes(node.type.name)) {
|
|
17605
|
-
markValue[
|
|
17602
|
+
markValue[key] = value;
|
|
17606
17603
|
}
|
|
17607
|
-
} else if (
|
|
17604
|
+
} else if (key === "color" && node) {
|
|
17608
17605
|
if (!listTypes.includes(node.type.name)) {
|
|
17609
|
-
markValue[
|
|
17606
|
+
markValue[key] = value;
|
|
17610
17607
|
}
|
|
17611
17608
|
} else if (typeof value === "string") {
|
|
17612
|
-
markValue[
|
|
17609
|
+
markValue[key] = value;
|
|
17613
17610
|
}
|
|
17614
17611
|
}
|
|
17615
17612
|
});
|
|
17616
|
-
const final = Object.entries(markValue).map(([
|
|
17613
|
+
const final = Object.entries(markValue).map(([key, value]) => `${key}: ${value}`).join(";");
|
|
17617
17614
|
return final;
|
|
17618
17615
|
};
|
|
17619
17616
|
const applyLinkedStyleToTransaction = (tr, editor, style) => {
|
|
@@ -18308,7 +18305,7 @@ function orderedListSync(editor) {
|
|
|
18308
18305
|
listNumberingType,
|
|
18309
18306
|
customFormat
|
|
18310
18307
|
};
|
|
18311
|
-
const keysChanged = Object.keys(updatedAttrs).some((
|
|
18308
|
+
const keysChanged = Object.keys(updatedAttrs).some((key) => node.attrs[key] !== updatedAttrs[key]);
|
|
18312
18309
|
if (keysChanged) {
|
|
18313
18310
|
tr.setNodeMarkup(pos, void 0, updatedAttrs);
|
|
18314
18311
|
}
|
|
@@ -19347,12 +19344,6 @@ const HardBreak = Node$1.create({
|
|
|
19347
19344
|
};
|
|
19348
19345
|
}
|
|
19349
19346
|
});
|
|
19350
|
-
const getColStyleDeclaration = (minWidth, width) => {
|
|
19351
|
-
if (width) {
|
|
19352
|
-
return ["width", `${Math.max(width, minWidth)}px`];
|
|
19353
|
-
}
|
|
19354
|
-
return ["min-width", `${minWidth}px`];
|
|
19355
|
-
};
|
|
19356
19347
|
const createTableView = ({ editor }) => {
|
|
19357
19348
|
return class TableView {
|
|
19358
19349
|
constructor(node, cellMinWidth) {
|
|
@@ -19441,11 +19432,11 @@ function updateTable(editor, node, table) {
|
|
|
19441
19432
|
const allExtensionsAttrs = editor.extensionService.attributes;
|
|
19442
19433
|
const tableExtensionAttrs = allExtensionsAttrs.filter((e) => e.type === "table");
|
|
19443
19434
|
const htmlAttributes = Attribute.getAttributesToRender(node, tableExtensionAttrs);
|
|
19444
|
-
Object.entries(htmlAttributes).forEach(([
|
|
19445
|
-
if (
|
|
19435
|
+
Object.entries(htmlAttributes).forEach(([key, value]) => {
|
|
19436
|
+
if (key === "style") {
|
|
19446
19437
|
table.style.cssText = value;
|
|
19447
19438
|
} else {
|
|
19448
|
-
table.setAttribute(
|
|
19439
|
+
table.setAttribute(key, value);
|
|
19449
19440
|
}
|
|
19450
19441
|
});
|
|
19451
19442
|
}
|
|
@@ -19513,55 +19504,26 @@ const createTable = (schema, rowsCount, colsCount, withHeaderRow, cellContent =
|
|
|
19513
19504
|
const tableBorders = createTableBorders();
|
|
19514
19505
|
return types.table.createChecked({ borders: tableBorders }, rows);
|
|
19515
19506
|
};
|
|
19516
|
-
const createColGroup = (node, cellMinWidth, overrideCol, overrideValue) => {
|
|
19517
|
-
let totalWidth = 0;
|
|
19518
|
-
let fixedWidth = true;
|
|
19519
|
-
const cols = [];
|
|
19520
|
-
const colsValues = [];
|
|
19521
|
-
const row = node.firstChild;
|
|
19522
|
-
if (!row) return {};
|
|
19523
|
-
for (let i = 0, col = 0; i < row.childCount; i++) {
|
|
19524
|
-
const { colspan, colwidth } = row.child(i).attrs;
|
|
19525
|
-
for (let j = 0; j < colspan; j++, col++) {
|
|
19526
|
-
const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j];
|
|
19527
|
-
totalWidth += hasWidth || cellMinWidth;
|
|
19528
|
-
if (!hasWidth) fixedWidth = false;
|
|
19529
|
-
const [prop, value] = getColStyleDeclaration(cellMinWidth, hasWidth);
|
|
19530
|
-
cols.push(["col", { style: `${prop}: ${value}` }]);
|
|
19531
|
-
colsValues.push(parseInt(value, 10));
|
|
19532
|
-
}
|
|
19533
|
-
}
|
|
19534
|
-
const tableWidth = fixedWidth ? `${totalWidth}px` : "";
|
|
19535
|
-
const tableMinWidth = fixedWidth ? "" : `${totalWidth}px`;
|
|
19536
|
-
const colgroup = ["colgroup", {}, ...cols];
|
|
19537
|
-
const colgroupValues = [...colsValues];
|
|
19538
|
-
return {
|
|
19539
|
-
colgroup,
|
|
19540
|
-
tableWidth,
|
|
19541
|
-
tableMinWidth,
|
|
19542
|
-
colgroupValues
|
|
19543
|
-
};
|
|
19544
|
-
};
|
|
19545
19507
|
var readFromCache;
|
|
19546
19508
|
var addToCache;
|
|
19547
19509
|
if (typeof WeakMap != "undefined") {
|
|
19548
19510
|
let cache = /* @__PURE__ */ new WeakMap();
|
|
19549
|
-
readFromCache = (
|
|
19550
|
-
addToCache = (
|
|
19551
|
-
cache.set(
|
|
19511
|
+
readFromCache = (key) => cache.get(key);
|
|
19512
|
+
addToCache = (key, value) => {
|
|
19513
|
+
cache.set(key, value);
|
|
19552
19514
|
return value;
|
|
19553
19515
|
};
|
|
19554
19516
|
} else {
|
|
19555
19517
|
const cache = [];
|
|
19556
19518
|
const cacheSize = 10;
|
|
19557
19519
|
let cachePos = 0;
|
|
19558
|
-
readFromCache = (
|
|
19520
|
+
readFromCache = (key) => {
|
|
19559
19521
|
for (let i = 0; i < cache.length; i += 2)
|
|
19560
|
-
if (cache[i] ==
|
|
19522
|
+
if (cache[i] == key) return cache[i + 1];
|
|
19561
19523
|
};
|
|
19562
|
-
addToCache = (
|
|
19524
|
+
addToCache = (key, value) => {
|
|
19563
19525
|
if (cachePos == cacheSize) cachePos = 0;
|
|
19564
|
-
cache[cachePos++] =
|
|
19526
|
+
cache[cachePos++] = key;
|
|
19565
19527
|
return cache[cachePos++] = value;
|
|
19566
19528
|
};
|
|
19567
19529
|
}
|
|
@@ -21795,8 +21757,8 @@ const Table = Node$1.create({
|
|
|
21795
21757
|
default: {},
|
|
21796
21758
|
renderDOM({ borders }) {
|
|
21797
21759
|
if (!borders) return {};
|
|
21798
|
-
const style = Object.entries(borders).reduce((acc, [
|
|
21799
|
-
return `${acc}border-${
|
|
21760
|
+
const style = Object.entries(borders).reduce((acc, [key, { size, color }]) => {
|
|
21761
|
+
return `${acc}border-${key}: ${Math.ceil(size)}px solid ${color || "black"};`;
|
|
21800
21762
|
}, "");
|
|
21801
21763
|
return {
|
|
21802
21764
|
style
|
|
@@ -21855,24 +21817,6 @@ const Table = Node$1.create({
|
|
|
21855
21817
|
tableCellSpacing: {
|
|
21856
21818
|
default: null,
|
|
21857
21819
|
rendered: false
|
|
21858
|
-
},
|
|
21859
|
-
/**
|
|
21860
|
-
* @category Attribute
|
|
21861
|
-
* @param {TableProperties} [tableProperties] - Properties for the table.
|
|
21862
|
-
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 371-483
|
|
21863
|
-
*/
|
|
21864
|
-
tableProperties: {
|
|
21865
|
-
default: null,
|
|
21866
|
-
rendered: false
|
|
21867
|
-
},
|
|
21868
|
-
/**
|
|
21869
|
-
* @category Attribute
|
|
21870
|
-
* @param {TableGrid} [grid] - Grid definition for the table
|
|
21871
|
-
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 432
|
|
21872
|
-
*/
|
|
21873
|
-
grid: {
|
|
21874
|
-
default: null,
|
|
21875
|
-
rendered: false
|
|
21876
21820
|
}
|
|
21877
21821
|
};
|
|
21878
21822
|
},
|
|
@@ -22929,11 +22873,11 @@ createAnnotation_fn = function({ displayLabel } = {}) {
|
|
|
22929
22873
|
let mergedAttrs = Attribute.mergeAttributes(this.htmlAttributes, {
|
|
22930
22874
|
style: omitHighlight ? "" : annotationStyle
|
|
22931
22875
|
});
|
|
22932
|
-
for (let [
|
|
22933
|
-
if (
|
|
22876
|
+
for (let [key, value] of Object.entries(mergedAttrs)) {
|
|
22877
|
+
if (key === "style") {
|
|
22934
22878
|
annotation.style.cssText = value;
|
|
22935
22879
|
} else {
|
|
22936
|
-
annotation.setAttribute(
|
|
22880
|
+
annotation.setAttribute(key, value);
|
|
22937
22881
|
}
|
|
22938
22882
|
}
|
|
22939
22883
|
return {
|
|
@@ -23107,13 +23051,13 @@ function hash$2(str) {
|
|
|
23107
23051
|
}
|
|
23108
23052
|
const colorToInt = (x) => parseInt(x.replace(/_/g, ""), 36);
|
|
23109
23053
|
const compressedColorMap = "1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm".split(" ").reduce((acc, next) => {
|
|
23110
|
-
const
|
|
23054
|
+
const key = colorToInt(next.substring(0, 3));
|
|
23111
23055
|
const hex = colorToInt(next.substring(3)).toString(16);
|
|
23112
23056
|
let prefix = "";
|
|
23113
23057
|
for (let i = 0; i < 6 - hex.length; i++) {
|
|
23114
23058
|
prefix += "0";
|
|
23115
23059
|
}
|
|
23116
|
-
acc[
|
|
23060
|
+
acc[key] = `${prefix}${hex}`;
|
|
23117
23061
|
return acc;
|
|
23118
23062
|
}, {});
|
|
23119
23063
|
function nameToHex(color) {
|
|
@@ -24229,657 +24173,146 @@ function getFormatAttrsFromMarks(marks) {
|
|
|
24229
24173
|
}
|
|
24230
24174
|
return formatAttrs;
|
|
24231
24175
|
}
|
|
24232
|
-
const
|
|
24233
|
-
|
|
24234
|
-
|
|
24235
|
-
|
|
24236
|
-
|
|
24237
|
-
|
|
24238
|
-
|
|
24239
|
-
|
|
24240
|
-
|
|
24241
|
-
|
|
24242
|
-
|
|
24243
|
-
|
|
24244
|
-
|
|
24245
|
-
|
|
24246
|
-
|
|
24247
|
-
|
|
24248
|
-
|
|
24249
|
-
|
|
24250
|
-
|
|
24251
|
-
|
|
24252
|
-
|
|
24253
|
-
|
|
24254
|
-
|
|
24255
|
-
|
|
24256
|
-
|
|
24257
|
-
|
|
24258
|
-
try {
|
|
24259
|
-
const response = await fetch(url, {
|
|
24260
|
-
mode: "cors",
|
|
24261
|
-
credentials: "omit",
|
|
24262
|
-
headers: {
|
|
24263
|
-
// Add common headers that might help with CORS
|
|
24264
|
-
Accept: "image/*,*/*;q=0.8"
|
|
24176
|
+
const ImagePlaceholderPluginKey = new PluginKey("ImagePlaceholder");
|
|
24177
|
+
const ImagePlaceholderPlugin = () => {
|
|
24178
|
+
return new Plugin({
|
|
24179
|
+
key: ImagePlaceholderPluginKey,
|
|
24180
|
+
state: {
|
|
24181
|
+
init() {
|
|
24182
|
+
return DecorationSet.empty;
|
|
24183
|
+
},
|
|
24184
|
+
apply(tr, set) {
|
|
24185
|
+
set = set.map(tr.mapping, tr.doc);
|
|
24186
|
+
let action = tr.getMeta(ImagePlaceholderPluginKey);
|
|
24187
|
+
if (action?.type === "add") {
|
|
24188
|
+
let widget = document.createElement("placeholder");
|
|
24189
|
+
let deco = Decoration.widget(action.pos, widget, {
|
|
24190
|
+
id: action.id
|
|
24191
|
+
});
|
|
24192
|
+
set = set.add(tr.doc, [deco]);
|
|
24193
|
+
} else if (action?.type === "remove") {
|
|
24194
|
+
set = set.remove(set.find(null, null, (spec) => spec.id == action.id));
|
|
24195
|
+
}
|
|
24196
|
+
return set;
|
|
24197
|
+
}
|
|
24198
|
+
},
|
|
24199
|
+
props: {
|
|
24200
|
+
decorations(state) {
|
|
24201
|
+
return this.getState(state);
|
|
24265
24202
|
}
|
|
24266
|
-
});
|
|
24267
|
-
if (!response.ok) {
|
|
24268
|
-
console.warn(`Failed to fetch image from ${url}: ${response.status} ${response.statusText}`);
|
|
24269
|
-
return null;
|
|
24270
|
-
}
|
|
24271
|
-
const blob = await response.blob();
|
|
24272
|
-
const finalFilename = filename || extractFilenameFromUrl(url);
|
|
24273
|
-
const finalMimeType = mimeType || response.headers.get("content-type") || blob.type || "image/jpeg";
|
|
24274
|
-
return new File([blob], finalFilename, { type: finalMimeType });
|
|
24275
|
-
} catch (error) {
|
|
24276
|
-
if (isCorsError(error)) {
|
|
24277
|
-
console.warn(`CORS policy prevents accessing image from ${url}:`, error.message);
|
|
24278
|
-
return null;
|
|
24279
24203
|
}
|
|
24280
|
-
|
|
24281
|
-
return null;
|
|
24282
|
-
}
|
|
24204
|
+
});
|
|
24283
24205
|
};
|
|
24284
|
-
const
|
|
24285
|
-
|
|
24286
|
-
|
|
24287
|
-
return
|
|
24288
|
-
errorMessage.includes("failed to fetch");
|
|
24206
|
+
const findPlaceholder = (state, id) => {
|
|
24207
|
+
let decos = ImagePlaceholderPluginKey.getState(state);
|
|
24208
|
+
let found = decos?.find(null, null, (spec) => spec.id === id);
|
|
24209
|
+
return found?.length ? found[0].from : null;
|
|
24289
24210
|
};
|
|
24290
|
-
const
|
|
24291
|
-
|
|
24292
|
-
|
|
24293
|
-
|
|
24294
|
-
|
|
24295
|
-
|
|
24296
|
-
|
|
24211
|
+
const ImagePositionPluginKey = new PluginKey("ImagePosition");
|
|
24212
|
+
const ImagePositionPlugin = ({ editor }) => {
|
|
24213
|
+
const { view } = editor;
|
|
24214
|
+
let shouldUpdate = false;
|
|
24215
|
+
return new Plugin({
|
|
24216
|
+
name: "ImagePositionPlugin",
|
|
24217
|
+
key: ImagePositionPluginKey,
|
|
24218
|
+
state: {
|
|
24219
|
+
init() {
|
|
24220
|
+
return DecorationSet.empty;
|
|
24221
|
+
},
|
|
24222
|
+
apply(tr, oldDecorationSet, oldState, newState) {
|
|
24223
|
+
if (!tr.docChanged) return oldDecorationSet;
|
|
24224
|
+
const decorations = getImagePositionDecorations(newState, view);
|
|
24225
|
+
return DecorationSet.create(newState.doc, decorations);
|
|
24226
|
+
}
|
|
24227
|
+
},
|
|
24228
|
+
view: () => {
|
|
24229
|
+
return {
|
|
24230
|
+
update: (view2, lastState) => {
|
|
24231
|
+
const pagination = PaginationPluginKey.getState(lastState);
|
|
24232
|
+
if (shouldUpdate) {
|
|
24233
|
+
shouldUpdate = false;
|
|
24234
|
+
const decorations = getImagePositionDecorations(lastState, view2);
|
|
24235
|
+
const updateTransaction = view2.state.tr.setMeta(ImagePositionPluginKey, { decorations });
|
|
24236
|
+
view2.dispatch(updateTransaction);
|
|
24237
|
+
}
|
|
24238
|
+
if (pagination?.isReadyToInit) {
|
|
24239
|
+
shouldUpdate = true;
|
|
24240
|
+
}
|
|
24241
|
+
}
|
|
24242
|
+
};
|
|
24243
|
+
},
|
|
24244
|
+
props: {
|
|
24245
|
+
decorations(state) {
|
|
24246
|
+
return this.getState(state);
|
|
24247
|
+
}
|
|
24297
24248
|
}
|
|
24298
|
-
return filename || "image.jpg";
|
|
24299
|
-
} catch {
|
|
24300
|
-
return "image.jpg";
|
|
24301
|
-
}
|
|
24302
|
-
};
|
|
24303
|
-
const validateUrlAccessibility = async (url) => {
|
|
24304
|
-
try {
|
|
24305
|
-
const response = await fetch(url, {
|
|
24306
|
-
method: "HEAD",
|
|
24307
|
-
mode: "cors",
|
|
24308
|
-
credentials: "omit"
|
|
24309
|
-
});
|
|
24310
|
-
return response.ok;
|
|
24311
|
-
} catch {
|
|
24312
|
-
return false;
|
|
24313
|
-
}
|
|
24314
|
-
};
|
|
24315
|
-
const handleImageUpload = (file) => {
|
|
24316
|
-
return new Promise((resolve, reject) => {
|
|
24317
|
-
let reader = new FileReader();
|
|
24318
|
-
reader.onload = (event) => {
|
|
24319
|
-
resolve(event.target.result);
|
|
24320
|
-
};
|
|
24321
|
-
reader.onerror = reject;
|
|
24322
|
-
setTimeout(() => reader.readAsDataURL(file), 250);
|
|
24323
24249
|
});
|
|
24324
24250
|
};
|
|
24325
|
-
const
|
|
24326
|
-
|
|
24327
|
-
|
|
24328
|
-
|
|
24329
|
-
|
|
24330
|
-
|
|
24331
|
-
|
|
24332
|
-
|
|
24333
|
-
|
|
24334
|
-
)
|
|
24335
|
-
|
|
24336
|
-
|
|
24337
|
-
|
|
24338
|
-
|
|
24339
|
-
|
|
24340
|
-
|
|
24341
|
-
|
|
24342
|
-
|
|
24251
|
+
const getImagePositionDecorations = (state, view) => {
|
|
24252
|
+
let decorations = [];
|
|
24253
|
+
state.doc.descendants((node, pos) => {
|
|
24254
|
+
if (node.attrs.anchorData) {
|
|
24255
|
+
let style = "";
|
|
24256
|
+
let className = "";
|
|
24257
|
+
const { vRelativeFrom, alignH } = node.attrs.anchorData;
|
|
24258
|
+
const { size, padding, marginOffset } = node.attrs;
|
|
24259
|
+
const pageBreak = findPreviousDomNodeWithClass(view, pos, "pagination-break-wrapper");
|
|
24260
|
+
if (pageBreak) {
|
|
24261
|
+
switch (alignH) {
|
|
24262
|
+
case "left":
|
|
24263
|
+
style += "float: left; left: 0; margin-left: 0; ";
|
|
24264
|
+
break;
|
|
24265
|
+
case "right":
|
|
24266
|
+
style += "float: right; right: 0; margin-right: 0; ";
|
|
24267
|
+
break;
|
|
24268
|
+
case "center":
|
|
24269
|
+
style += "display: block; margin-left: auto; margin-right: auto; ";
|
|
24270
|
+
break;
|
|
24271
|
+
}
|
|
24272
|
+
const topPos = marginOffset.top !== void 0 ? marginOffset.top : pageBreak?.offsetTop + pageBreak?.offsetHeight;
|
|
24273
|
+
style += vRelativeFrom === "margin" ? `position: absolute; top: ${topPos}px; ` : "";
|
|
24274
|
+
if (vRelativeFrom === "margin") {
|
|
24275
|
+
const nextPos = view.posAtDOM(pageBreak, 1);
|
|
24276
|
+
if (nextPos < 0) {
|
|
24277
|
+
const $pos = view.state.doc.resolve(pos);
|
|
24278
|
+
decorations.push(
|
|
24279
|
+
Decoration.node(pos - 1, pos + $pos.parent.nodeSize - 1, {
|
|
24280
|
+
style: `height: ${size.height + parseInt(padding.top) + parseInt(padding.bottom)}px`
|
|
24281
|
+
})
|
|
24282
|
+
);
|
|
24283
|
+
}
|
|
24284
|
+
const imageBlock = document.createElement("div");
|
|
24285
|
+
imageBlock.className = "anchor-image-placeholder";
|
|
24286
|
+
imageBlock.style.float = alignH;
|
|
24287
|
+
imageBlock.style.width = size.width + parseInt(padding[alignH]) + "px";
|
|
24288
|
+
imageBlock.style.height = size.height + parseInt(padding.top) + parseInt(padding.bottom) + "px";
|
|
24289
|
+
decorations.push(Decoration.widget(nextPos, imageBlock, { key: "stable-key" }));
|
|
24343
24290
|
}
|
|
24344
24291
|
}
|
|
24345
|
-
|
|
24346
|
-
|
|
24347
|
-
const targetPixelWidth = Math.round(logicalWidth * dpr);
|
|
24348
|
-
const targetPixelHeight = Math.round(logicalHeight * dpr);
|
|
24349
|
-
const finalTargetWidth = Math.min(targetPixelWidth, img.width);
|
|
24350
|
-
const finalTargetHeight = Math.min(targetPixelHeight, img.height);
|
|
24351
|
-
const resizeNeeded = finalTargetWidth !== img.width || finalTargetHeight !== img.height;
|
|
24352
|
-
if (resizeNeeded) {
|
|
24353
|
-
multiStepResize(canvas, finalTargetWidth, finalTargetHeight);
|
|
24354
|
-
}
|
|
24355
|
-
if (typeof fileData === "string") {
|
|
24356
|
-
const resizedBase64 = canvas.toDataURL();
|
|
24357
|
-
resolve(resizedBase64);
|
|
24358
|
-
} else {
|
|
24359
|
-
canvas.toBlob((blob) => {
|
|
24360
|
-
const updatedFile = new File([blob], fileData.name, {
|
|
24361
|
-
type: fileData.type,
|
|
24362
|
-
lastModified: Date.now()
|
|
24363
|
-
});
|
|
24364
|
-
resolve({ file: updatedFile, width: logicalWidth, height: logicalHeight });
|
|
24365
|
-
});
|
|
24366
|
-
}
|
|
24367
|
-
};
|
|
24368
|
-
img.onerror = (error) => reject(error);
|
|
24369
|
-
img.src = typeof fileData === "string" ? fileData : URL.createObjectURL(fileData);
|
|
24292
|
+
decorations.push(Decoration.inline(pos, pos + node.nodeSize, { style, class: className }));
|
|
24293
|
+
}
|
|
24370
24294
|
});
|
|
24295
|
+
return decorations;
|
|
24371
24296
|
};
|
|
24372
|
-
const
|
|
24373
|
-
|
|
24374
|
-
if (
|
|
24375
|
-
|
|
24376
|
-
let adjustedHeight = height;
|
|
24377
|
-
const aspectRatio = width / height;
|
|
24378
|
-
if (height > maxHeight) {
|
|
24379
|
-
adjustedHeight = maxHeight;
|
|
24380
|
-
adjustedWidth = Math.round(maxHeight * aspectRatio);
|
|
24297
|
+
const findPreviousDomNodeWithClass = (view, pos, className) => {
|
|
24298
|
+
let { node } = view.domAtPos(pos);
|
|
24299
|
+
if (node.nodeType === 3) {
|
|
24300
|
+
node = node.parentNode;
|
|
24381
24301
|
}
|
|
24382
|
-
|
|
24383
|
-
|
|
24384
|
-
|
|
24302
|
+
while (node) {
|
|
24303
|
+
if (node.classList && node.classList.contains(className)) {
|
|
24304
|
+
return node;
|
|
24305
|
+
}
|
|
24306
|
+
if (node.previousSibling) {
|
|
24307
|
+
node = node.previousSibling;
|
|
24308
|
+
while (node && node.lastChild) {
|
|
24309
|
+
node = node.lastChild;
|
|
24310
|
+
}
|
|
24311
|
+
} else {
|
|
24312
|
+
node = node.parentNode;
|
|
24313
|
+
}
|
|
24385
24314
|
}
|
|
24386
|
-
return
|
|
24387
|
-
};
|
|
24388
|
-
function resample_high_quality(canvas, width, height, resize_canvas) {
|
|
24389
|
-
var width_source = canvas.width;
|
|
24390
|
-
var height_source = canvas.height;
|
|
24391
|
-
width = Math.round(width);
|
|
24392
|
-
height = Math.round(height);
|
|
24393
|
-
var ratio_w = width_source / width;
|
|
24394
|
-
var ratio_h = height_source / height;
|
|
24395
|
-
var ratio_w_half = Math.ceil(ratio_w / 2);
|
|
24396
|
-
var ratio_h_half = Math.ceil(ratio_h / 2);
|
|
24397
|
-
var ctx = canvas.getContext("2d");
|
|
24398
|
-
var img = ctx.getImageData(0, 0, width_source, height_source);
|
|
24399
|
-
var img2 = ctx.createImageData(width, height);
|
|
24400
|
-
var data = img.data;
|
|
24401
|
-
var data2 = img2.data;
|
|
24402
|
-
for (var j = 0; j < height; j++) {
|
|
24403
|
-
for (var i = 0; i < width; i++) {
|
|
24404
|
-
var x2 = (i + j * width) * 4;
|
|
24405
|
-
var weight = 0;
|
|
24406
|
-
var weights = 0;
|
|
24407
|
-
var weights_alpha = 0;
|
|
24408
|
-
var gx_r = 0;
|
|
24409
|
-
var gx_g = 0;
|
|
24410
|
-
var gx_b = 0;
|
|
24411
|
-
var gx_a = 0;
|
|
24412
|
-
var center_y = (j + 0.5) * ratio_h;
|
|
24413
|
-
var yy_start = Math.floor(j * ratio_h);
|
|
24414
|
-
var yy_stop = Math.ceil((j + 1) * ratio_h);
|
|
24415
|
-
for (var yy = yy_start; yy < yy_stop; yy++) {
|
|
24416
|
-
var dy = Math.abs(center_y - (yy + 0.5)) / ratio_h_half;
|
|
24417
|
-
var center_x = (i + 0.5) * ratio_w;
|
|
24418
|
-
var w0 = dy * dy;
|
|
24419
|
-
var xx_start = Math.floor(i * ratio_w);
|
|
24420
|
-
var xx_stop = Math.ceil((i + 1) * ratio_w);
|
|
24421
|
-
for (var xx = xx_start; xx < xx_stop; xx++) {
|
|
24422
|
-
var dx = Math.abs(center_x - (xx + 0.5)) / ratio_w_half;
|
|
24423
|
-
var w = Math.sqrt(w0 + dx * dx);
|
|
24424
|
-
if (w >= 1) {
|
|
24425
|
-
continue;
|
|
24426
|
-
}
|
|
24427
|
-
weight = 2 * w * w * w - 3 * w * w + 1;
|
|
24428
|
-
var pos_x = 4 * (xx + yy * width_source);
|
|
24429
|
-
gx_a += weight * data[pos_x + 3];
|
|
24430
|
-
weights_alpha += weight;
|
|
24431
|
-
if (data[pos_x + 3] < 255) weight = weight * data[pos_x + 3] / 250;
|
|
24432
|
-
gx_r += weight * data[pos_x];
|
|
24433
|
-
gx_g += weight * data[pos_x + 1];
|
|
24434
|
-
gx_b += weight * data[pos_x + 2];
|
|
24435
|
-
weights += weight;
|
|
24436
|
-
}
|
|
24437
|
-
}
|
|
24438
|
-
data2[x2] = gx_r / weights;
|
|
24439
|
-
data2[x2 + 1] = gx_g / weights;
|
|
24440
|
-
data2[x2 + 2] = gx_b / weights;
|
|
24441
|
-
data2[x2 + 3] = gx_a / weights_alpha;
|
|
24442
|
-
}
|
|
24443
|
-
}
|
|
24444
|
-
{
|
|
24445
|
-
canvas.width = width;
|
|
24446
|
-
canvas.height = height;
|
|
24447
|
-
}
|
|
24448
|
-
ctx.putImageData(img2, 0, 0);
|
|
24449
|
-
}
|
|
24450
|
-
function multiStepResize(canvas, width, height) {
|
|
24451
|
-
let oc = document.createElement("canvas");
|
|
24452
|
-
let octx = oc.getContext("2d");
|
|
24453
|
-
let ctx = canvas.getContext("2d");
|
|
24454
|
-
let steps = Math.ceil(Math.log(canvas.width / width) / Math.log(2));
|
|
24455
|
-
steps = Math.max(steps, 1);
|
|
24456
|
-
let stepWidth = width * Math.pow(2, steps - 1);
|
|
24457
|
-
let stepHeight = height * Math.pow(2, steps - 1);
|
|
24458
|
-
let currentWidth = canvas.width;
|
|
24459
|
-
let currentHeight = canvas.height;
|
|
24460
|
-
oc.width = currentWidth;
|
|
24461
|
-
oc.height = currentHeight;
|
|
24462
|
-
octx.drawImage(canvas, 0, 0);
|
|
24463
|
-
while (steps > 0) {
|
|
24464
|
-
stepWidth = Math.max(stepWidth, width);
|
|
24465
|
-
stepHeight = Math.max(stepHeight, height);
|
|
24466
|
-
canvas.width = stepWidth;
|
|
24467
|
-
canvas.height = stepHeight;
|
|
24468
|
-
ctx.drawImage(oc, 0, 0, currentWidth, currentHeight, 0, 0, stepWidth, stepHeight);
|
|
24469
|
-
currentWidth = stepWidth;
|
|
24470
|
-
currentHeight = stepHeight;
|
|
24471
|
-
oc.width = currentWidth;
|
|
24472
|
-
oc.height = currentHeight;
|
|
24473
|
-
octx.drawImage(canvas, 0, 0);
|
|
24474
|
-
stepWidth = Math.round(stepWidth / 2);
|
|
24475
|
-
stepHeight = Math.round(stepHeight / 2);
|
|
24476
|
-
steps--;
|
|
24477
|
-
}
|
|
24478
|
-
resample_high_quality(canvas, width, height);
|
|
24479
|
-
}
|
|
24480
|
-
const FALLBACK_NAME = "image";
|
|
24481
|
-
const stripDiacritics = (value) => value.normalize("NFKD").replace(/[\u0300-\u036f]/g, "");
|
|
24482
|
-
const sanitizeSegment = (segment, { allowDots = false } = {}) => {
|
|
24483
|
-
if (!segment) return "";
|
|
24484
|
-
const normalized = stripDiacritics(segment).replace(/[\s\u2000-\u206f]+/g, "_").replace(/[\\/]+/g, "_");
|
|
24485
|
-
const allowedPattern = allowDots ? /[^0-9A-Za-z._-]+/g : /[^0-9A-Za-z_-]+/g;
|
|
24486
|
-
let sanitized = normalized.replace(allowedPattern, "_");
|
|
24487
|
-
sanitized = sanitized.replace(/_+/g, "_");
|
|
24488
|
-
sanitized = sanitized.replace(/^[_.-]+/, "");
|
|
24489
|
-
sanitized = sanitized.replace(/[_-]+$/, "");
|
|
24490
|
-
return sanitized;
|
|
24491
|
-
};
|
|
24492
|
-
const splitFileName = (name) => {
|
|
24493
|
-
const trimmed = name?.trim?.() ?? "";
|
|
24494
|
-
const lastDot = trimmed.lastIndexOf(".");
|
|
24495
|
-
if (lastDot <= 0 || lastDot === trimmed.length - 1) {
|
|
24496
|
-
return { base: trimmed, ext: "" };
|
|
24497
|
-
}
|
|
24498
|
-
return {
|
|
24499
|
-
base: trimmed.slice(0, lastDot),
|
|
24500
|
-
ext: trimmed.slice(lastDot + 1)
|
|
24501
|
-
};
|
|
24502
|
-
};
|
|
24503
|
-
const sanitizeImageFileName = (inputName) => {
|
|
24504
|
-
const { base: base2, ext } = splitFileName(inputName || "");
|
|
24505
|
-
const sanitizedBase = sanitizeSegment(base2, { allowDots: true }) || FALLBACK_NAME;
|
|
24506
|
-
const sanitizedExt = sanitizeSegment(ext, { allowDots: false }).toLowerCase();
|
|
24507
|
-
if (!sanitizedExt) return sanitizedBase;
|
|
24508
|
-
return `${sanitizedBase}.${sanitizedExt}`;
|
|
24509
|
-
};
|
|
24510
|
-
const ensureUniqueFileName = (preferredName, existingNames = /* @__PURE__ */ new Set()) => {
|
|
24511
|
-
const sanitized = sanitizeImageFileName(preferredName);
|
|
24512
|
-
if (!existingNames || typeof existingNames.has !== "function") {
|
|
24513
|
-
return sanitized;
|
|
24514
|
-
}
|
|
24515
|
-
const existingSet = /* @__PURE__ */ new Set();
|
|
24516
|
-
existingNames.forEach((name) => existingSet.add(sanitizeImageFileName(name)));
|
|
24517
|
-
if (!existingSet.has(sanitized)) {
|
|
24518
|
-
return sanitized;
|
|
24519
|
-
}
|
|
24520
|
-
const { base: base2, ext } = splitFileName(sanitized);
|
|
24521
|
-
let counter = 1;
|
|
24522
|
-
let candidate = sanitized;
|
|
24523
|
-
const suffix = () => `${base2}-${counter}${ext ? `.${ext}` : ""}`;
|
|
24524
|
-
while (existingSet.has(candidate)) {
|
|
24525
|
-
candidate = suffix();
|
|
24526
|
-
counter += 1;
|
|
24527
|
-
}
|
|
24528
|
-
return candidate;
|
|
24529
|
-
};
|
|
24530
|
-
const buildMediaPath = (fileName) => `word/media/${fileName}`;
|
|
24531
|
-
const fileTooLarge = (file) => {
|
|
24532
|
-
let fileSizeMb = Number((file.size / (1024 * 1024)).toFixed(4));
|
|
24533
|
-
if (fileSizeMb > 5) {
|
|
24534
|
-
window.alert("Image size must be less than 5MB");
|
|
24535
|
-
return true;
|
|
24536
|
-
}
|
|
24537
|
-
return false;
|
|
24538
|
-
};
|
|
24539
|
-
const checkAndProcessImage = async ({ getMaxContentSize, file }) => {
|
|
24540
|
-
if (fileTooLarge(file)) {
|
|
24541
|
-
return { file: null, size: { width: 0, height: 0 } };
|
|
24542
|
-
}
|
|
24543
|
-
try {
|
|
24544
|
-
const processedImageResult = await processUploadedImage(file, getMaxContentSize);
|
|
24545
|
-
const process = processedImageResult;
|
|
24546
|
-
return { file: process.file, size: { width: process.width, height: process.height } };
|
|
24547
|
-
} catch (err) {
|
|
24548
|
-
console.warn("Error processing image:", err);
|
|
24549
|
-
return { file: null, size: { width: 0, height: 0 } };
|
|
24550
|
-
}
|
|
24551
|
-
};
|
|
24552
|
-
function replaceSelectionWithImagePlaceholder({ editorOptions, view, id }) {
|
|
24553
|
-
let { tr } = view.state;
|
|
24554
|
-
let { selection } = tr;
|
|
24555
|
-
if (editorOptions.isHeaderOrFooter) {
|
|
24556
|
-
selection = editorOptions.lastSelection;
|
|
24557
|
-
}
|
|
24558
|
-
if (!selection.empty && !editorOptions.isHeaderOrFooter) {
|
|
24559
|
-
tr.deleteSelection();
|
|
24560
|
-
}
|
|
24561
|
-
tr = addImagePlaceholder(view.state, tr, id, selection.from);
|
|
24562
|
-
view.dispatch(tr);
|
|
24563
|
-
}
|
|
24564
|
-
const generateUniqueDocPrId = (editor) => {
|
|
24565
|
-
const existingIds = /* @__PURE__ */ new Set();
|
|
24566
|
-
editor?.state?.doc?.descendants((node) => {
|
|
24567
|
-
if (node.type.name === "image" && node.attrs.id !== void 0 && node.attrs.id !== null) {
|
|
24568
|
-
existingIds.add(String(node.attrs.id));
|
|
24569
|
-
}
|
|
24570
|
-
});
|
|
24571
|
-
let candidate;
|
|
24572
|
-
do {
|
|
24573
|
-
const hex = generateDocxRandomId();
|
|
24574
|
-
candidate = String(parseInt(hex, 16));
|
|
24575
|
-
} while (!candidate || existingIds.has(candidate));
|
|
24576
|
-
return candidate;
|
|
24577
|
-
};
|
|
24578
|
-
async function uploadAndInsertImage({ editor, view, file, size, id }) {
|
|
24579
|
-
const imageUploadHandler = typeof editor.options.handleImageUpload === "function" ? editor.options.handleImageUpload : handleImageUpload;
|
|
24580
|
-
const placeholderId = id;
|
|
24581
|
-
try {
|
|
24582
|
-
const existingFileNames = new Set(Object.keys(editor.storage.image.media ?? {}).map((key2) => key2.split("/").pop()));
|
|
24583
|
-
const uniqueFileName = ensureUniqueFileName(file.name, existingFileNames);
|
|
24584
|
-
const normalizedFile = uniqueFileName === file.name ? file : new File([file], uniqueFileName, {
|
|
24585
|
-
type: file.type,
|
|
24586
|
-
lastModified: file.lastModified ?? Date.now()
|
|
24587
|
-
});
|
|
24588
|
-
let url = await imageUploadHandler(normalizedFile);
|
|
24589
|
-
let placeholderPos = findPlaceholder(view.state, placeholderId);
|
|
24590
|
-
if (placeholderPos == null) {
|
|
24591
|
-
return;
|
|
24592
|
-
}
|
|
24593
|
-
const mediaPath = buildMediaPath(uniqueFileName);
|
|
24594
|
-
const docPrId = generateUniqueDocPrId(editor);
|
|
24595
|
-
let rId = null;
|
|
24596
|
-
if (editor.options.mode === "docx") {
|
|
24597
|
-
const [, path] = mediaPath.split("word/");
|
|
24598
|
-
const id2 = addImageRelationship({ editor, path });
|
|
24599
|
-
if (id2) rId = id2;
|
|
24600
|
-
}
|
|
24601
|
-
let imageNode = view.state.schema.nodes.image.create({
|
|
24602
|
-
src: mediaPath,
|
|
24603
|
-
size,
|
|
24604
|
-
id: docPrId,
|
|
24605
|
-
rId
|
|
24606
|
-
});
|
|
24607
|
-
editor.storage.image.media = Object.assign(editor.storage.image.media, { [mediaPath]: url });
|
|
24608
|
-
if (editor.options.ydoc && typeof editor.commands.addImageToCollaboration === "function") {
|
|
24609
|
-
editor.commands.addImageToCollaboration({ mediaPath, fileData: url });
|
|
24610
|
-
}
|
|
24611
|
-
let tr = view.state.tr;
|
|
24612
|
-
tr.replaceWith(placeholderPos, placeholderPos, imageNode);
|
|
24613
|
-
tr = removeImagePlaceholder(view.state, tr, placeholderId);
|
|
24614
|
-
view.dispatch(tr);
|
|
24615
|
-
} catch {
|
|
24616
|
-
const tr = removeImagePlaceholder(view.state, view.state.tr, placeholderId);
|
|
24617
|
-
view.dispatch(tr);
|
|
24618
|
-
}
|
|
24619
|
-
}
|
|
24620
|
-
function addImageRelationship({ editor, path }) {
|
|
24621
|
-
const target = path;
|
|
24622
|
-
const type = "image";
|
|
24623
|
-
try {
|
|
24624
|
-
const id = insertNewRelationship(target, type, editor);
|
|
24625
|
-
return id;
|
|
24626
|
-
} catch {
|
|
24627
|
-
return null;
|
|
24628
|
-
}
|
|
24629
|
-
}
|
|
24630
|
-
const key = new PluginKey("ImageRegistration");
|
|
24631
|
-
const ImageRegistrationPlugin = ({ editor }) => {
|
|
24632
|
-
const { view } = editor;
|
|
24633
|
-
return new Plugin({
|
|
24634
|
-
key,
|
|
24635
|
-
state: {
|
|
24636
|
-
init() {
|
|
24637
|
-
return { set: DecorationSet.empty };
|
|
24638
|
-
},
|
|
24639
|
-
apply(tr, { set }) {
|
|
24640
|
-
const meta = tr.getMeta(key);
|
|
24641
|
-
if (meta) {
|
|
24642
|
-
set = meta.set;
|
|
24643
|
-
return { set };
|
|
24644
|
-
}
|
|
24645
|
-
set = set.map(tr.mapping, tr.doc);
|
|
24646
|
-
return { set };
|
|
24647
|
-
}
|
|
24648
|
-
},
|
|
24649
|
-
appendTransaction: (trs, _oldState, state) => {
|
|
24650
|
-
let foundImages = [];
|
|
24651
|
-
trs.forEach((tr2) => {
|
|
24652
|
-
if (tr2.docChanged) {
|
|
24653
|
-
tr2.steps.forEach((step, index2) => {
|
|
24654
|
-
const stepMap = step.getMap();
|
|
24655
|
-
foundImages = foundImages.map(({ node, pos, id }) => {
|
|
24656
|
-
const mappedPos = stepMap.map(pos, -1);
|
|
24657
|
-
return { node, pos: mappedPos, id };
|
|
24658
|
-
});
|
|
24659
|
-
if (step instanceof ReplaceStep || step instanceof ReplaceAroundStep$1) {
|
|
24660
|
-
(tr2.docs[index2 + 1] || tr2.doc).nodesBetween(
|
|
24661
|
-
stepMap.map(step.from, -1),
|
|
24662
|
-
stepMap.map(step.to, 1),
|
|
24663
|
-
(node, pos) => {
|
|
24664
|
-
if (node.type.name === "image" && !node.attrs.src.startsWith("word/media")) {
|
|
24665
|
-
const id = {};
|
|
24666
|
-
foundImages.push({ node, pos, id });
|
|
24667
|
-
} else {
|
|
24668
|
-
return true;
|
|
24669
|
-
}
|
|
24670
|
-
}
|
|
24671
|
-
);
|
|
24672
|
-
}
|
|
24673
|
-
});
|
|
24674
|
-
}
|
|
24675
|
-
});
|
|
24676
|
-
if (!foundImages || foundImages.length === 0) {
|
|
24677
|
-
return null;
|
|
24678
|
-
}
|
|
24679
|
-
registerImages(foundImages, editor, view);
|
|
24680
|
-
const tr = state.tr;
|
|
24681
|
-
let { set } = key.getState(state);
|
|
24682
|
-
foundImages.slice().sort((a, b) => a.pos - b.pos).forEach(({ pos, id }) => {
|
|
24683
|
-
let deco = Decoration.widget(pos, () => document.createElement("placeholder"), {
|
|
24684
|
-
side: -1,
|
|
24685
|
-
id
|
|
24686
|
-
});
|
|
24687
|
-
set = set.add(tr.doc, [deco]);
|
|
24688
|
-
});
|
|
24689
|
-
foundImages.slice().sort((a, b) => b.pos - a.pos).forEach(({ node, pos }) => {
|
|
24690
|
-
tr.delete(pos, pos + node.nodeSize);
|
|
24691
|
-
});
|
|
24692
|
-
set = set.map(tr.mapping, tr.doc);
|
|
24693
|
-
tr.setMeta(key, { set });
|
|
24694
|
-
return tr;
|
|
24695
|
-
},
|
|
24696
|
-
props: {
|
|
24697
|
-
decorations(state) {
|
|
24698
|
-
let { set } = key.getState(state);
|
|
24699
|
-
return set;
|
|
24700
|
-
}
|
|
24701
|
-
}
|
|
24702
|
-
});
|
|
24703
|
-
};
|
|
24704
|
-
const findPlaceholder = (state, id) => {
|
|
24705
|
-
let { set } = key.getState(state);
|
|
24706
|
-
let found = set?.find(null, null, (spec) => spec.id === id);
|
|
24707
|
-
return found?.length ? found[0].from : null;
|
|
24708
|
-
};
|
|
24709
|
-
const removeImagePlaceholder = (state, tr, id) => {
|
|
24710
|
-
let { set } = key.getState(state);
|
|
24711
|
-
set = set.map(tr.mapping, tr.doc);
|
|
24712
|
-
set = set.remove(set.find(null, null, (spec) => spec.id == id));
|
|
24713
|
-
return tr.setMeta(key, { set, type: "remove" });
|
|
24714
|
-
};
|
|
24715
|
-
const addImagePlaceholder = (state, tr, id, pos) => {
|
|
24716
|
-
let { set } = key.getState(state);
|
|
24717
|
-
set = set.map(tr.mapping, tr.doc);
|
|
24718
|
-
let deco = Decoration.widget(pos, () => document.createElement("placeholder"), {
|
|
24719
|
-
id
|
|
24720
|
-
});
|
|
24721
|
-
set = set.add(tr.doc, [deco]);
|
|
24722
|
-
return tr.setMeta(key, { set, type: "add" });
|
|
24723
|
-
};
|
|
24724
|
-
const getImageRegistrationMetaType = (tr) => {
|
|
24725
|
-
const meta = tr.getMeta(key);
|
|
24726
|
-
if (meta && meta.type) {
|
|
24727
|
-
return meta.type;
|
|
24728
|
-
}
|
|
24729
|
-
return null;
|
|
24730
|
-
};
|
|
24731
|
-
const registerImages = async (foundImages, editor, view) => {
|
|
24732
|
-
foundImages.forEach(async (image) => {
|
|
24733
|
-
const src = image.node.attrs.src;
|
|
24734
|
-
const id = image.id;
|
|
24735
|
-
let file = null;
|
|
24736
|
-
if (src.startsWith("http")) {
|
|
24737
|
-
const isAccessible = await validateUrlAccessibility(src);
|
|
24738
|
-
if (isAccessible) {
|
|
24739
|
-
file = await urlToFile(src);
|
|
24740
|
-
} else {
|
|
24741
|
-
console.warn(`Image URL ${src} is not accessible due to CORS or other restrictions. Using original URL.`);
|
|
24742
|
-
const tr = view.state.tr;
|
|
24743
|
-
removeImagePlaceholder(view.state, tr, id);
|
|
24744
|
-
view.dispatch(tr);
|
|
24745
|
-
return;
|
|
24746
|
-
}
|
|
24747
|
-
} else if (src.startsWith("data:")) {
|
|
24748
|
-
file = base64ToFile(src);
|
|
24749
|
-
} else {
|
|
24750
|
-
console.error(`Unsupported image source: ${src}`);
|
|
24751
|
-
}
|
|
24752
|
-
if (!file) {
|
|
24753
|
-
const tr = view.state.tr;
|
|
24754
|
-
removeImagePlaceholder(view.state, tr, id);
|
|
24755
|
-
view.dispatch(tr);
|
|
24756
|
-
return;
|
|
24757
|
-
}
|
|
24758
|
-
try {
|
|
24759
|
-
const process = await checkAndProcessImage({
|
|
24760
|
-
getMaxContentSize: () => editor.getMaxContentSize(),
|
|
24761
|
-
file
|
|
24762
|
-
});
|
|
24763
|
-
if (!process.file) {
|
|
24764
|
-
const tr = view.state.tr;
|
|
24765
|
-
removeImagePlaceholder(view.state, tr, id);
|
|
24766
|
-
view.dispatch(tr);
|
|
24767
|
-
return;
|
|
24768
|
-
}
|
|
24769
|
-
await uploadAndInsertImage({ editor, view, file: process.file, size: process.size, id });
|
|
24770
|
-
} catch (error) {
|
|
24771
|
-
console.error(`Error processing image from ${src}:`, error);
|
|
24772
|
-
const tr = view.state.tr;
|
|
24773
|
-
removeImagePlaceholder(view.state, tr, id);
|
|
24774
|
-
view.dispatch(tr);
|
|
24775
|
-
}
|
|
24776
|
-
});
|
|
24777
|
-
};
|
|
24778
|
-
const ImagePositionPluginKey = new PluginKey("ImagePosition");
|
|
24779
|
-
const ImagePositionPlugin = ({ editor }) => {
|
|
24780
|
-
const { view } = editor;
|
|
24781
|
-
let shouldUpdate = false;
|
|
24782
|
-
return new Plugin({
|
|
24783
|
-
name: "ImagePositionPlugin",
|
|
24784
|
-
key: ImagePositionPluginKey,
|
|
24785
|
-
state: {
|
|
24786
|
-
init() {
|
|
24787
|
-
return DecorationSet.empty;
|
|
24788
|
-
},
|
|
24789
|
-
apply(tr, oldDecorationSet, oldState, newState) {
|
|
24790
|
-
if (!tr.docChanged) return oldDecorationSet;
|
|
24791
|
-
const decorations = getImagePositionDecorations(newState, view);
|
|
24792
|
-
return DecorationSet.create(newState.doc, decorations);
|
|
24793
|
-
}
|
|
24794
|
-
},
|
|
24795
|
-
view: () => {
|
|
24796
|
-
return {
|
|
24797
|
-
update: (view2, lastState) => {
|
|
24798
|
-
const pagination = PaginationPluginKey.getState(lastState);
|
|
24799
|
-
if (shouldUpdate) {
|
|
24800
|
-
shouldUpdate = false;
|
|
24801
|
-
const decorations = getImagePositionDecorations(lastState, view2);
|
|
24802
|
-
const updateTransaction = view2.state.tr.setMeta(ImagePositionPluginKey, { decorations });
|
|
24803
|
-
view2.dispatch(updateTransaction);
|
|
24804
|
-
}
|
|
24805
|
-
if (pagination?.isReadyToInit) {
|
|
24806
|
-
shouldUpdate = true;
|
|
24807
|
-
}
|
|
24808
|
-
}
|
|
24809
|
-
};
|
|
24810
|
-
},
|
|
24811
|
-
props: {
|
|
24812
|
-
decorations(state) {
|
|
24813
|
-
return this.getState(state);
|
|
24814
|
-
}
|
|
24815
|
-
}
|
|
24816
|
-
});
|
|
24817
|
-
};
|
|
24818
|
-
const getImagePositionDecorations = (state, view) => {
|
|
24819
|
-
let decorations = [];
|
|
24820
|
-
state.doc.descendants((node, pos) => {
|
|
24821
|
-
if (node.attrs.anchorData) {
|
|
24822
|
-
let style = "";
|
|
24823
|
-
let className = "";
|
|
24824
|
-
const { vRelativeFrom, alignH } = node.attrs.anchorData;
|
|
24825
|
-
const { size, padding, marginOffset } = node.attrs;
|
|
24826
|
-
const pageBreak = findPreviousDomNodeWithClass(view, pos, "pagination-break-wrapper");
|
|
24827
|
-
if (pageBreak) {
|
|
24828
|
-
switch (alignH) {
|
|
24829
|
-
case "left":
|
|
24830
|
-
style += "float: left; left: 0; margin-left: 0; ";
|
|
24831
|
-
break;
|
|
24832
|
-
case "right":
|
|
24833
|
-
style += "float: right; right: 0; margin-right: 0; ";
|
|
24834
|
-
break;
|
|
24835
|
-
case "center":
|
|
24836
|
-
style += "display: block; margin-left: auto; margin-right: auto; ";
|
|
24837
|
-
break;
|
|
24838
|
-
}
|
|
24839
|
-
const topPos = marginOffset.top !== void 0 ? marginOffset.top : pageBreak?.offsetTop + pageBreak?.offsetHeight;
|
|
24840
|
-
style += vRelativeFrom === "margin" ? `position: absolute; top: ${topPos}px; ` : "";
|
|
24841
|
-
if (vRelativeFrom === "margin") {
|
|
24842
|
-
const nextPos = view.posAtDOM(pageBreak, 1);
|
|
24843
|
-
if (nextPos < 0) {
|
|
24844
|
-
const $pos = view.state.doc.resolve(pos);
|
|
24845
|
-
decorations.push(
|
|
24846
|
-
Decoration.node(pos - 1, pos + $pos.parent.nodeSize - 1, {
|
|
24847
|
-
style: `height: ${size.height + parseInt(padding.top) + parseInt(padding.bottom)}px`
|
|
24848
|
-
})
|
|
24849
|
-
);
|
|
24850
|
-
}
|
|
24851
|
-
const imageBlock = document.createElement("div");
|
|
24852
|
-
imageBlock.className = "anchor-image-placeholder";
|
|
24853
|
-
imageBlock.style.float = alignH;
|
|
24854
|
-
imageBlock.style.width = size.width + parseInt(padding[alignH]) + "px";
|
|
24855
|
-
imageBlock.style.height = size.height + parseInt(padding.top) + parseInt(padding.bottom) + "px";
|
|
24856
|
-
decorations.push(Decoration.widget(nextPos, imageBlock, { key: "stable-key" }));
|
|
24857
|
-
}
|
|
24858
|
-
}
|
|
24859
|
-
decorations.push(Decoration.inline(pos, pos + node.nodeSize, { style, class: className }));
|
|
24860
|
-
}
|
|
24861
|
-
});
|
|
24862
|
-
return decorations;
|
|
24863
|
-
};
|
|
24864
|
-
const findPreviousDomNodeWithClass = (view, pos, className) => {
|
|
24865
|
-
let { node } = view.domAtPos(pos);
|
|
24866
|
-
if (node.nodeType === 3) {
|
|
24867
|
-
node = node.parentNode;
|
|
24868
|
-
}
|
|
24869
|
-
while (node) {
|
|
24870
|
-
if (node.classList && node.classList.contains(className)) {
|
|
24871
|
-
return node;
|
|
24872
|
-
}
|
|
24873
|
-
if (node.previousSibling) {
|
|
24874
|
-
node = node.previousSibling;
|
|
24875
|
-
while (node && node.lastChild) {
|
|
24876
|
-
node = node.lastChild;
|
|
24877
|
-
}
|
|
24878
|
-
} else {
|
|
24879
|
-
node = node.parentNode;
|
|
24880
|
-
}
|
|
24881
|
-
}
|
|
24882
|
-
return null;
|
|
24315
|
+
return null;
|
|
24883
24316
|
};
|
|
24884
24317
|
const Image = Node$1.create({
|
|
24885
24318
|
name: "image",
|
|
@@ -25048,90 +24481,331 @@ const Image = Node$1.create({
|
|
|
25048
24481
|
if (relativeFromPageV && top2 >= maxMarginV) style += `margin-top: ${maxMarginV}px;`;
|
|
25049
24482
|
else style += `margin-top: ${top2}px;`;
|
|
25050
24483
|
}
|
|
25051
|
-
return { style };
|
|
25052
|
-
}
|
|
25053
|
-
},
|
|
25054
|
-
/**
|
|
25055
|
-
* @category Attribute
|
|
25056
|
-
* @param {string} [style] - Custom inline CSS styles
|
|
25057
|
-
*/
|
|
25058
|
-
style: {
|
|
25059
|
-
default: null,
|
|
25060
|
-
rendered: true,
|
|
25061
|
-
renderDOM: ({ style }) => {
|
|
25062
|
-
if (!style) return {};
|
|
25063
|
-
return { style };
|
|
24484
|
+
return { style };
|
|
24485
|
+
}
|
|
24486
|
+
},
|
|
24487
|
+
/**
|
|
24488
|
+
* @category Attribute
|
|
24489
|
+
* @param {string} [style] - Custom inline CSS styles
|
|
24490
|
+
*/
|
|
24491
|
+
style: {
|
|
24492
|
+
default: null,
|
|
24493
|
+
rendered: true,
|
|
24494
|
+
renderDOM: ({ style }) => {
|
|
24495
|
+
if (!style) return {};
|
|
24496
|
+
return { style };
|
|
24497
|
+
}
|
|
24498
|
+
}
|
|
24499
|
+
};
|
|
24500
|
+
},
|
|
24501
|
+
parseDOM() {
|
|
24502
|
+
return [
|
|
24503
|
+
{
|
|
24504
|
+
tag: this.options.allowBase64 ? "img[src]" : 'img[src]:not([src^="data:"])'
|
|
24505
|
+
}
|
|
24506
|
+
];
|
|
24507
|
+
},
|
|
24508
|
+
renderDOM({ htmlAttributes }) {
|
|
24509
|
+
return ["img", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
24510
|
+
},
|
|
24511
|
+
addCommands() {
|
|
24512
|
+
return {
|
|
24513
|
+
/**
|
|
24514
|
+
* Insert an image at the current position
|
|
24515
|
+
* @category Command
|
|
24516
|
+
* @param {Object} options - Image attributes
|
|
24517
|
+
* @param {string} options.src - Image source URL or data URI
|
|
24518
|
+
* @param {string} [options.alt] - Alternative text
|
|
24519
|
+
* @param {string} [options.title] - Image title
|
|
24520
|
+
* @param {Object} [options.size] - Image dimensions
|
|
24521
|
+
* @returns {Function} Command function
|
|
24522
|
+
* @example
|
|
24523
|
+
* // Insert an image from a URL
|
|
24524
|
+
* setImage({ src: 'https://example.com/image.jpg' })
|
|
24525
|
+
*
|
|
24526
|
+
* // Insert a base64 encoded image
|
|
24527
|
+
* setImage({
|
|
24528
|
+
* src: 'data:image/png;base64,...',
|
|
24529
|
+
* alt: 'Company logo',
|
|
24530
|
+
* size: { width: 200 }
|
|
24531
|
+
* })
|
|
24532
|
+
* @note Supports URLs, relative paths, and base64 data URIs
|
|
24533
|
+
*/
|
|
24534
|
+
setImage: (options) => ({ commands: commands2 }) => {
|
|
24535
|
+
return commands2.insertContent({
|
|
24536
|
+
type: this.name,
|
|
24537
|
+
attrs: options
|
|
24538
|
+
});
|
|
24539
|
+
}
|
|
24540
|
+
};
|
|
24541
|
+
},
|
|
24542
|
+
addPmPlugins() {
|
|
24543
|
+
return [ImagePlaceholderPlugin(), ImagePositionPlugin({ editor: this.editor })];
|
|
24544
|
+
}
|
|
24545
|
+
});
|
|
24546
|
+
const ACCEPT_IMAGE_TYPES = [".jpg", ".jpeg", ".png", "image/jpeg", "image/png"];
|
|
24547
|
+
const getFileOpener = () => {
|
|
24548
|
+
let fileInput = document.createElement("input");
|
|
24549
|
+
fileInput.type = "file";
|
|
24550
|
+
let acceptTypes = ACCEPT_IMAGE_TYPES;
|
|
24551
|
+
fileInput.accept = acceptTypes.join(",");
|
|
24552
|
+
const openFile = () => {
|
|
24553
|
+
return new Promise((resolve, reject) => {
|
|
24554
|
+
fileInput.onchange = async () => {
|
|
24555
|
+
const files = fileInput.files;
|
|
24556
|
+
if (!files) return resolve(null);
|
|
24557
|
+
const file = files.item(0);
|
|
24558
|
+
if (!file) return resolve(null);
|
|
24559
|
+
return resolve({ file });
|
|
24560
|
+
};
|
|
24561
|
+
fileInput.oncancel = () => resolve(null);
|
|
24562
|
+
fileInput.onerror = reject;
|
|
24563
|
+
fileInput.click();
|
|
24564
|
+
});
|
|
24565
|
+
};
|
|
24566
|
+
return openFile;
|
|
24567
|
+
};
|
|
24568
|
+
const handleImageUpload = (file) => {
|
|
24569
|
+
return new Promise((resolve, reject) => {
|
|
24570
|
+
let reader = new FileReader();
|
|
24571
|
+
reader.onload = (event) => {
|
|
24572
|
+
resolve(event.target.result);
|
|
24573
|
+
};
|
|
24574
|
+
reader.onerror = reject;
|
|
24575
|
+
setTimeout(() => reader.readAsDataURL(file), 250);
|
|
24576
|
+
});
|
|
24577
|
+
};
|
|
24578
|
+
const processUploadedImage = (fileData, editor) => {
|
|
24579
|
+
return new Promise((resolve, reject) => {
|
|
24580
|
+
const img = new window.Image();
|
|
24581
|
+
img.onload = () => {
|
|
24582
|
+
const canvas = document.createElement("canvas");
|
|
24583
|
+
const { width: logicalWidth, height: logicalHeight } = getAllowedImageDimensions(img.width, img.height, editor);
|
|
24584
|
+
canvas.width = img.width;
|
|
24585
|
+
canvas.height = img.height;
|
|
24586
|
+
const ctx = canvas.getContext("2d");
|
|
24587
|
+
if (ctx) {
|
|
24588
|
+
ctx.imageSmoothingEnabled = true;
|
|
24589
|
+
try {
|
|
24590
|
+
ctx.imageSmoothingQuality = "high";
|
|
24591
|
+
} catch {
|
|
24592
|
+
}
|
|
24593
|
+
}
|
|
24594
|
+
ctx.drawImage(img, 0, 0, img.width, img.height);
|
|
24595
|
+
const dpr = typeof window !== "undefined" && window.devicePixelRatio ? window.devicePixelRatio : 1;
|
|
24596
|
+
const targetPixelWidth = Math.round(logicalWidth * dpr);
|
|
24597
|
+
const targetPixelHeight = Math.round(logicalHeight * dpr);
|
|
24598
|
+
const finalTargetWidth = Math.min(targetPixelWidth, img.width);
|
|
24599
|
+
const finalTargetHeight = Math.min(targetPixelHeight, img.height);
|
|
24600
|
+
const resizeNeeded = finalTargetWidth !== img.width || finalTargetHeight !== img.height;
|
|
24601
|
+
if (resizeNeeded) {
|
|
24602
|
+
multiStepResize(canvas, finalTargetWidth, finalTargetHeight);
|
|
24603
|
+
}
|
|
24604
|
+
if (typeof fileData === "string") {
|
|
24605
|
+
const resizedBase64 = canvas.toDataURL();
|
|
24606
|
+
resolve(resizedBase64);
|
|
24607
|
+
} else {
|
|
24608
|
+
canvas.toBlob((blob) => {
|
|
24609
|
+
const updatedFile = new File([blob], fileData.name, {
|
|
24610
|
+
type: fileData.type,
|
|
24611
|
+
lastModified: Date.now()
|
|
24612
|
+
});
|
|
24613
|
+
resolve({ file: updatedFile, width: logicalWidth, height: logicalHeight });
|
|
24614
|
+
});
|
|
24615
|
+
}
|
|
24616
|
+
};
|
|
24617
|
+
img.onerror = (error) => reject(error);
|
|
24618
|
+
img.src = typeof fileData === "string" ? fileData : URL.createObjectURL(fileData);
|
|
24619
|
+
});
|
|
24620
|
+
};
|
|
24621
|
+
const getAllowedImageDimensions = (width, height, editor) => {
|
|
24622
|
+
const { width: maxWidth, height: maxHeight } = editor.getMaxContentSize();
|
|
24623
|
+
if (!maxWidth || !maxHeight) return { width, height };
|
|
24624
|
+
let adjustedWidth = width;
|
|
24625
|
+
let adjustedHeight = height;
|
|
24626
|
+
const aspectRatio = width / height;
|
|
24627
|
+
if (height > maxHeight) {
|
|
24628
|
+
adjustedHeight = maxHeight;
|
|
24629
|
+
adjustedWidth = Math.round(maxHeight * aspectRatio);
|
|
24630
|
+
}
|
|
24631
|
+
if (adjustedWidth > maxWidth) {
|
|
24632
|
+
adjustedWidth = maxWidth;
|
|
24633
|
+
adjustedHeight = Math.round(maxWidth / aspectRatio);
|
|
24634
|
+
}
|
|
24635
|
+
return { width: adjustedWidth, height: adjustedHeight };
|
|
24636
|
+
};
|
|
24637
|
+
function resample_high_quality(canvas, width, height, resize_canvas) {
|
|
24638
|
+
var width_source = canvas.width;
|
|
24639
|
+
var height_source = canvas.height;
|
|
24640
|
+
width = Math.round(width);
|
|
24641
|
+
height = Math.round(height);
|
|
24642
|
+
var ratio_w = width_source / width;
|
|
24643
|
+
var ratio_h = height_source / height;
|
|
24644
|
+
var ratio_w_half = Math.ceil(ratio_w / 2);
|
|
24645
|
+
var ratio_h_half = Math.ceil(ratio_h / 2);
|
|
24646
|
+
var ctx = canvas.getContext("2d");
|
|
24647
|
+
var img = ctx.getImageData(0, 0, width_source, height_source);
|
|
24648
|
+
var img2 = ctx.createImageData(width, height);
|
|
24649
|
+
var data = img.data;
|
|
24650
|
+
var data2 = img2.data;
|
|
24651
|
+
for (var j = 0; j < height; j++) {
|
|
24652
|
+
for (var i = 0; i < width; i++) {
|
|
24653
|
+
var x2 = (i + j * width) * 4;
|
|
24654
|
+
var weight = 0;
|
|
24655
|
+
var weights = 0;
|
|
24656
|
+
var weights_alpha = 0;
|
|
24657
|
+
var gx_r = 0;
|
|
24658
|
+
var gx_g = 0;
|
|
24659
|
+
var gx_b = 0;
|
|
24660
|
+
var gx_a = 0;
|
|
24661
|
+
var center_y = (j + 0.5) * ratio_h;
|
|
24662
|
+
var yy_start = Math.floor(j * ratio_h);
|
|
24663
|
+
var yy_stop = Math.ceil((j + 1) * ratio_h);
|
|
24664
|
+
for (var yy = yy_start; yy < yy_stop; yy++) {
|
|
24665
|
+
var dy = Math.abs(center_y - (yy + 0.5)) / ratio_h_half;
|
|
24666
|
+
var center_x = (i + 0.5) * ratio_w;
|
|
24667
|
+
var w0 = dy * dy;
|
|
24668
|
+
var xx_start = Math.floor(i * ratio_w);
|
|
24669
|
+
var xx_stop = Math.ceil((i + 1) * ratio_w);
|
|
24670
|
+
for (var xx = xx_start; xx < xx_stop; xx++) {
|
|
24671
|
+
var dx = Math.abs(center_x - (xx + 0.5)) / ratio_w_half;
|
|
24672
|
+
var w = Math.sqrt(w0 + dx * dx);
|
|
24673
|
+
if (w >= 1) {
|
|
24674
|
+
continue;
|
|
24675
|
+
}
|
|
24676
|
+
weight = 2 * w * w * w - 3 * w * w + 1;
|
|
24677
|
+
var pos_x = 4 * (xx + yy * width_source);
|
|
24678
|
+
gx_a += weight * data[pos_x + 3];
|
|
24679
|
+
weights_alpha += weight;
|
|
24680
|
+
if (data[pos_x + 3] < 255) weight = weight * data[pos_x + 3] / 250;
|
|
24681
|
+
gx_r += weight * data[pos_x];
|
|
24682
|
+
gx_g += weight * data[pos_x + 1];
|
|
24683
|
+
gx_b += weight * data[pos_x + 2];
|
|
24684
|
+
weights += weight;
|
|
25064
24685
|
}
|
|
25065
24686
|
}
|
|
25066
|
-
|
|
25067
|
-
|
|
25068
|
-
|
|
25069
|
-
|
|
25070
|
-
|
|
25071
|
-
tag: this.options.allowBase64 ? "img[src]" : 'img[src]:not([src^="data:"])'
|
|
25072
|
-
}
|
|
25073
|
-
];
|
|
25074
|
-
},
|
|
25075
|
-
renderDOM({ htmlAttributes }) {
|
|
25076
|
-
return ["img", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
25077
|
-
},
|
|
25078
|
-
addCommands() {
|
|
25079
|
-
return {
|
|
25080
|
-
/**
|
|
25081
|
-
* Insert an image at the current position
|
|
25082
|
-
* @category Command
|
|
25083
|
-
* @param {Object} options - Image attributes
|
|
25084
|
-
* @param {string} options.src - Image source URL or data URI
|
|
25085
|
-
* @param {string} [options.alt] - Alternative text
|
|
25086
|
-
* @param {string} [options.title] - Image title
|
|
25087
|
-
* @param {Object} [options.size] - Image dimensions
|
|
25088
|
-
* @returns {Function} Command function
|
|
25089
|
-
* @example
|
|
25090
|
-
* // Insert an image from a URL
|
|
25091
|
-
* setImage({ src: 'https://example.com/image.jpg' })
|
|
25092
|
-
*
|
|
25093
|
-
* // Insert a base64 encoded image
|
|
25094
|
-
* setImage({
|
|
25095
|
-
* src: 'data:image/png;base64,...',
|
|
25096
|
-
* alt: 'Company logo',
|
|
25097
|
-
* size: { width: 200 }
|
|
25098
|
-
* })
|
|
25099
|
-
* @note Supports URLs, relative paths, and base64 data URIs
|
|
25100
|
-
*/
|
|
25101
|
-
setImage: (options) => ({ commands: commands2 }) => {
|
|
25102
|
-
return commands2.insertContent({
|
|
25103
|
-
type: this.name,
|
|
25104
|
-
attrs: options
|
|
25105
|
-
});
|
|
25106
|
-
}
|
|
25107
|
-
};
|
|
25108
|
-
},
|
|
25109
|
-
addPmPlugins() {
|
|
25110
|
-
return [ImageRegistrationPlugin({ editor: this.editor }), ImagePositionPlugin({ editor: this.editor })];
|
|
24687
|
+
data2[x2] = gx_r / weights;
|
|
24688
|
+
data2[x2 + 1] = gx_g / weights;
|
|
24689
|
+
data2[x2 + 2] = gx_b / weights;
|
|
24690
|
+
data2[x2 + 3] = gx_a / weights_alpha;
|
|
24691
|
+
}
|
|
25111
24692
|
}
|
|
25112
|
-
|
|
25113
|
-
|
|
25114
|
-
|
|
25115
|
-
|
|
25116
|
-
|
|
25117
|
-
|
|
25118
|
-
|
|
25119
|
-
const
|
|
25120
|
-
|
|
25121
|
-
|
|
25122
|
-
|
|
25123
|
-
|
|
25124
|
-
|
|
25125
|
-
|
|
25126
|
-
|
|
25127
|
-
|
|
25128
|
-
|
|
25129
|
-
|
|
25130
|
-
|
|
25131
|
-
|
|
25132
|
-
|
|
25133
|
-
|
|
24693
|
+
{
|
|
24694
|
+
canvas.width = width;
|
|
24695
|
+
canvas.height = height;
|
|
24696
|
+
}
|
|
24697
|
+
ctx.putImageData(img2, 0, 0);
|
|
24698
|
+
}
|
|
24699
|
+
function multiStepResize(canvas, targetWidth, targetHeight) {
|
|
24700
|
+
const originalWidth = canvas.width;
|
|
24701
|
+
const originalHeight = canvas.height;
|
|
24702
|
+
const scaleX = targetWidth / originalWidth;
|
|
24703
|
+
const scaleY = targetHeight / originalHeight;
|
|
24704
|
+
const scaleFactor = Math.min(scaleX, scaleY);
|
|
24705
|
+
if (scaleFactor < 0.5) {
|
|
24706
|
+
let currentWidth = originalWidth;
|
|
24707
|
+
let currentHeight = originalHeight;
|
|
24708
|
+
while (currentWidth > targetWidth * 2 || currentHeight > targetHeight * 2) {
|
|
24709
|
+
const nextWidth = Math.round(currentWidth / 2);
|
|
24710
|
+
const nextHeight = Math.round(currentHeight / 2);
|
|
24711
|
+
resample_high_quality(canvas, nextWidth, nextHeight);
|
|
24712
|
+
currentWidth = nextWidth;
|
|
24713
|
+
currentHeight = nextHeight;
|
|
24714
|
+
}
|
|
24715
|
+
if (currentWidth !== targetWidth || currentHeight !== targetHeight) {
|
|
24716
|
+
resample_high_quality(canvas, targetWidth, targetHeight);
|
|
24717
|
+
}
|
|
24718
|
+
} else {
|
|
24719
|
+
resample_high_quality(canvas, targetWidth, targetHeight);
|
|
24720
|
+
}
|
|
24721
|
+
}
|
|
24722
|
+
const startImageUpload = async ({ editor, view, file }) => {
|
|
24723
|
+
const imageUploadHandler = typeof editor.options.handleImageUpload === "function" ? editor.options.handleImageUpload : handleImageUpload;
|
|
24724
|
+
let fileSizeMb = Number((file.size / (1024 * 1024)).toFixed(4));
|
|
24725
|
+
if (fileSizeMb > 5) {
|
|
24726
|
+
window.alert("Image size must be less than 5MB");
|
|
24727
|
+
return;
|
|
24728
|
+
}
|
|
24729
|
+
let width;
|
|
24730
|
+
let height;
|
|
24731
|
+
try {
|
|
24732
|
+
const processedImageResult = await processUploadedImage(file, editor);
|
|
24733
|
+
width = processedImageResult.width;
|
|
24734
|
+
height = processedImageResult.height;
|
|
24735
|
+
file = processedImageResult.file;
|
|
24736
|
+
} catch (err) {
|
|
24737
|
+
console.warn("Error processing image:", err);
|
|
24738
|
+
editor.emit("exception", { error: err, editor });
|
|
24739
|
+
return;
|
|
24740
|
+
}
|
|
24741
|
+
await uploadImage({
|
|
24742
|
+
editor,
|
|
24743
|
+
view,
|
|
24744
|
+
file,
|
|
24745
|
+
size: { width, height },
|
|
24746
|
+
uploadHandler: imageUploadHandler
|
|
24747
|
+
});
|
|
25134
24748
|
};
|
|
24749
|
+
async function uploadImage({ editor, view, file, size, uploadHandler }) {
|
|
24750
|
+
let id = {};
|
|
24751
|
+
let { tr, schema } = view.state;
|
|
24752
|
+
let { selection } = tr;
|
|
24753
|
+
if (editor.options.isHeaderOrFooter) {
|
|
24754
|
+
selection = editor.options.lastSelection;
|
|
24755
|
+
}
|
|
24756
|
+
if (!selection.empty && !editor.options.isHeaderOrFooter) {
|
|
24757
|
+
tr.deleteSelection();
|
|
24758
|
+
}
|
|
24759
|
+
let imageMeta = {
|
|
24760
|
+
type: "add",
|
|
24761
|
+
pos: selection.from,
|
|
24762
|
+
id
|
|
24763
|
+
};
|
|
24764
|
+
tr.setMeta(ImagePlaceholderPluginKey, imageMeta);
|
|
24765
|
+
view.dispatch(tr);
|
|
24766
|
+
try {
|
|
24767
|
+
let url = await uploadHandler(file);
|
|
24768
|
+
let fileName = file.name.replace(" ", "_");
|
|
24769
|
+
let placeholderPos = findPlaceholder(view.state, id);
|
|
24770
|
+
if (placeholderPos == null) {
|
|
24771
|
+
return;
|
|
24772
|
+
}
|
|
24773
|
+
let removeMeta = { type: "remove", id };
|
|
24774
|
+
let mediaPath = `word/media/${fileName}`;
|
|
24775
|
+
let rId = null;
|
|
24776
|
+
if (editor.options.mode === "docx") {
|
|
24777
|
+
const [, path] = mediaPath.split("word/");
|
|
24778
|
+
const imageid = addImageRelationship({ editor, path });
|
|
24779
|
+
if (imageid) rId = imageid;
|
|
24780
|
+
}
|
|
24781
|
+
let imageNode = schema.nodes.image.create({
|
|
24782
|
+
src: mediaPath,
|
|
24783
|
+
size,
|
|
24784
|
+
rId
|
|
24785
|
+
});
|
|
24786
|
+
editor.storage.image.media = Object.assign(editor.storage.image.media, { [mediaPath]: url });
|
|
24787
|
+
if (editor.options.ydoc) {
|
|
24788
|
+
editor.commands.addImageToCollaboration({ mediaPath, fileData: url });
|
|
24789
|
+
}
|
|
24790
|
+
view.dispatch(
|
|
24791
|
+
view.state.tr.replaceWith(placeholderPos, placeholderPos, imageNode).setMeta(ImagePlaceholderPluginKey, removeMeta)
|
|
24792
|
+
);
|
|
24793
|
+
} catch (error) {
|
|
24794
|
+
let removeMeta = { type: "remove", id };
|
|
24795
|
+
view.dispatch(tr.setMeta(ImagePlaceholderPluginKey, removeMeta));
|
|
24796
|
+
editor.emit("exception", { error, editor });
|
|
24797
|
+
}
|
|
24798
|
+
}
|
|
24799
|
+
function addImageRelationship({ editor, path }) {
|
|
24800
|
+
const target = path;
|
|
24801
|
+
const type = "image";
|
|
24802
|
+
try {
|
|
24803
|
+
const relationshipId = insertNewRelationship(target, type, editor);
|
|
24804
|
+
return relationshipId;
|
|
24805
|
+
} catch {
|
|
24806
|
+
return null;
|
|
24807
|
+
}
|
|
24808
|
+
}
|
|
25135
24809
|
const BookmarkStart = Node$1.create({
|
|
25136
24810
|
name: "bookmarkStart",
|
|
25137
24811
|
group: "inline",
|
|
@@ -25446,8 +25120,8 @@ renderDom_fn = function(node, htmlAttributes) {
|
|
|
25446
25120
|
__privateMethod(this, _AutoPageNumberNodeView_instances, scheduleUpdateNodeStyle_fn).call(this, currentPos, marks);
|
|
25447
25121
|
Object.assign(nodeContent.style, styles);
|
|
25448
25122
|
nodeContent.appendChild(content);
|
|
25449
|
-
Object.entries(htmlAttributes).forEach(([
|
|
25450
|
-
if (value) nodeContent.setAttribute(
|
|
25123
|
+
Object.entries(htmlAttributes).forEach(([key, value]) => {
|
|
25124
|
+
if (value) nodeContent.setAttribute(key, value);
|
|
25451
25125
|
});
|
|
25452
25126
|
return nodeContent;
|
|
25453
25127
|
};
|
|
@@ -25513,8 +25187,8 @@ const processMarks = (marks) => {
|
|
|
25513
25187
|
break;
|
|
25514
25188
|
default:
|
|
25515
25189
|
if (attrs?.style) {
|
|
25516
|
-
Object.entries(attrs.style).forEach(([
|
|
25517
|
-
styles[
|
|
25190
|
+
Object.entries(attrs.style).forEach(([key, value]) => {
|
|
25191
|
+
styles[key] = value;
|
|
25518
25192
|
});
|
|
25519
25193
|
}
|
|
25520
25194
|
break;
|
|
@@ -25762,353 +25436,69 @@ const ContentBlock = Node$1.create({
|
|
|
25762
25436
|
};
|
|
25763
25437
|
}
|
|
25764
25438
|
});
|
|
25765
|
-
class StructuredContentViewBase {
|
|
25766
|
-
constructor(props) {
|
|
25767
|
-
__publicField(this, "node");
|
|
25768
|
-
__publicField(this, "view");
|
|
25769
|
-
__publicField(this, "getPos");
|
|
25770
|
-
__publicField(this, "decorations");
|
|
25771
|
-
__publicField(this, "innerDecorations");
|
|
25772
|
-
__publicField(this, "editor");
|
|
25773
|
-
__publicField(this, "extension");
|
|
25774
|
-
__publicField(this, "htmlAttributes");
|
|
25775
|
-
__publicField(this, "root");
|
|
25776
|
-
__publicField(this, "isDragging", false);
|
|
25777
|
-
this.node = props.node;
|
|
25778
|
-
this.view = props.editor.view;
|
|
25779
|
-
this.getPos = props.getPos;
|
|
25780
|
-
this.decorations = props.decorations;
|
|
25781
|
-
this.innerDecorations = props.innerDecorations;
|
|
25782
|
-
this.editor = props.editor;
|
|
25783
|
-
this.extension = props.extension;
|
|
25784
|
-
this.htmlAttributes = props.htmlAttributes;
|
|
25785
|
-
this.mount(props);
|
|
25786
|
-
}
|
|
25787
|
-
mount() {
|
|
25788
|
-
return;
|
|
25789
|
-
}
|
|
25790
|
-
get dom() {
|
|
25791
|
-
return this.root;
|
|
25792
|
-
}
|
|
25793
|
-
get contentDOM() {
|
|
25794
|
-
return null;
|
|
25795
|
-
}
|
|
25796
|
-
update(node, decorations, innerDecorations) {
|
|
25797
|
-
if (node.type !== this.node.type) {
|
|
25798
|
-
return false;
|
|
25799
|
-
}
|
|
25800
|
-
this.node = node;
|
|
25801
|
-
this.decorations = decorations;
|
|
25802
|
-
this.innerDecorations = innerDecorations;
|
|
25803
|
-
this.updateHTMLAttributes();
|
|
25804
|
-
return true;
|
|
25805
|
-
}
|
|
25806
|
-
stopEvent(event) {
|
|
25807
|
-
if (!this.dom) return false;
|
|
25808
|
-
const target = event.target;
|
|
25809
|
-
const isInElement = this.dom.contains(target) && !this.contentDOM?.contains(target);
|
|
25810
|
-
if (!isInElement) return false;
|
|
25811
|
-
const isDragEvent = event.type.startsWith("drag");
|
|
25812
|
-
const isDropEvent = event.type === "drop";
|
|
25813
|
-
const isInput = ["INPUT", "BUTTON", "SELECT", "TEXTAREA"].includes(target.tagName) || target.isContentEditable;
|
|
25814
|
-
if (isInput && !isDropEvent && !isDragEvent) return true;
|
|
25815
|
-
const { isEditable } = this.editor;
|
|
25816
|
-
const { isDragging } = this;
|
|
25817
|
-
const isDraggable = !!this.node.type.spec.draggable;
|
|
25818
|
-
const isSelectable = NodeSelection.isSelectable(this.node);
|
|
25819
|
-
const isCopyEvent = event.type === "copy";
|
|
25820
|
-
const isPasteEvent = event.type === "paste";
|
|
25821
|
-
const isCutEvent = event.type === "cut";
|
|
25822
|
-
const isClickEvent = event.type === "mousedown";
|
|
25823
|
-
if (!isDraggable && isSelectable && isDragEvent && event.target === this.dom) {
|
|
25824
|
-
event.preventDefault();
|
|
25825
|
-
}
|
|
25826
|
-
if (isDraggable && isDragEvent && !isDragging && event.target === this.dom) {
|
|
25827
|
-
event.preventDefault();
|
|
25828
|
-
return false;
|
|
25829
|
-
}
|
|
25830
|
-
if (isDraggable && isEditable && !isDragging && isClickEvent) {
|
|
25831
|
-
const dragHandle = target.closest("[data-drag-handle]");
|
|
25832
|
-
const isValidDragHandle = dragHandle && (this.dom === dragHandle || this.dom.contains(dragHandle));
|
|
25833
|
-
if (isValidDragHandle) {
|
|
25834
|
-
this.isDragging = true;
|
|
25835
|
-
document.addEventListener(
|
|
25836
|
-
"dragend",
|
|
25837
|
-
() => {
|
|
25838
|
-
this.isDragging = false;
|
|
25839
|
-
},
|
|
25840
|
-
{ once: true }
|
|
25841
|
-
);
|
|
25842
|
-
document.addEventListener(
|
|
25843
|
-
"drop",
|
|
25844
|
-
() => {
|
|
25845
|
-
this.isDragging = false;
|
|
25846
|
-
},
|
|
25847
|
-
{ once: true }
|
|
25848
|
-
);
|
|
25849
|
-
document.addEventListener(
|
|
25850
|
-
"mouseup",
|
|
25851
|
-
() => {
|
|
25852
|
-
this.isDragging = false;
|
|
25853
|
-
},
|
|
25854
|
-
{ once: true }
|
|
25855
|
-
);
|
|
25856
|
-
}
|
|
25857
|
-
}
|
|
25858
|
-
if (isDragging || isDropEvent || isCopyEvent || isPasteEvent || isCutEvent || isClickEvent && isSelectable) {
|
|
25859
|
-
return false;
|
|
25860
|
-
}
|
|
25861
|
-
return true;
|
|
25862
|
-
}
|
|
25863
|
-
ignoreMutation(mutation) {
|
|
25864
|
-
if (!this.dom || !this.contentDOM) return true;
|
|
25865
|
-
if (this.node.isLeaf || this.node.isAtom) return true;
|
|
25866
|
-
if (mutation.type === "selection") return false;
|
|
25867
|
-
if (this.contentDOM === mutation.target && mutation.type === "attributes") return true;
|
|
25868
|
-
if (this.contentDOM.contains(mutation.target)) return false;
|
|
25869
|
-
return true;
|
|
25870
|
-
}
|
|
25871
|
-
destroy() {
|
|
25872
|
-
this.dom.remove();
|
|
25873
|
-
this.contentDOM?.remove();
|
|
25874
|
-
}
|
|
25875
|
-
updateAttributes(attrs) {
|
|
25876
|
-
const pos = this.getPos();
|
|
25877
|
-
if (typeof pos !== "number") {
|
|
25878
|
-
return;
|
|
25879
|
-
}
|
|
25880
|
-
return this.view.dispatch(
|
|
25881
|
-
this.view.state.tr.setNodeMarkup(pos, void 0, {
|
|
25882
|
-
...this.node.attrs,
|
|
25883
|
-
...attrs
|
|
25884
|
-
})
|
|
25885
|
-
);
|
|
25886
|
-
}
|
|
25887
|
-
updateHTMLAttributes() {
|
|
25888
|
-
const { extensionService } = this.editor;
|
|
25889
|
-
const { attributes } = extensionService;
|
|
25890
|
-
const extensionAttrs = attributes.filter((i) => i.type === this.node.type.name);
|
|
25891
|
-
this.htmlAttributes = Attribute.getAttributesToRender(this.node, extensionAttrs);
|
|
25892
|
-
}
|
|
25893
|
-
createDragHandle() {
|
|
25894
|
-
const dragHandle = document.createElement("span");
|
|
25895
|
-
dragHandle.classList.add("sd-structured-content-draggable");
|
|
25896
|
-
dragHandle.draggable = true;
|
|
25897
|
-
dragHandle.contentEditable = "false";
|
|
25898
|
-
dragHandle.dataset.dragHandle = "";
|
|
25899
|
-
const textElement = document.createElement("span");
|
|
25900
|
-
textElement.textContent = "Structured content";
|
|
25901
|
-
dragHandle.append(textElement);
|
|
25902
|
-
return dragHandle;
|
|
25903
|
-
}
|
|
25904
|
-
onDragStart(event) {
|
|
25905
|
-
const { view } = this.editor;
|
|
25906
|
-
const target = event.target;
|
|
25907
|
-
const dragHandle = target.nodeType === 3 ? target.parentElement?.closest("[data-drag-handle]") : target.closest("[data-drag-handle]");
|
|
25908
|
-
if (!this.dom || this.contentDOM?.contains(target) || !dragHandle) {
|
|
25909
|
-
return;
|
|
25910
|
-
}
|
|
25911
|
-
let x = 0;
|
|
25912
|
-
let y = 0;
|
|
25913
|
-
if (this.dom !== dragHandle) {
|
|
25914
|
-
const domBox = this.dom.getBoundingClientRect();
|
|
25915
|
-
const handleBox = dragHandle.getBoundingClientRect();
|
|
25916
|
-
const offsetX = event.offsetX ?? event.nativeEvent?.offsetX;
|
|
25917
|
-
const offsetY = event.offsetY ?? event.nativeEvent?.offsetY;
|
|
25918
|
-
x = handleBox.x - domBox.x + offsetX;
|
|
25919
|
-
y = handleBox.y - domBox.y + offsetY;
|
|
25920
|
-
}
|
|
25921
|
-
event.dataTransfer?.setDragImage(this.dom, x, y);
|
|
25922
|
-
const pos = this.getPos();
|
|
25923
|
-
if (typeof pos !== "number") {
|
|
25924
|
-
return;
|
|
25925
|
-
}
|
|
25926
|
-
const selection = NodeSelection.create(view.state.doc, pos);
|
|
25927
|
-
const transaction = view.state.tr.setSelection(selection);
|
|
25928
|
-
view.dispatch(transaction);
|
|
25929
|
-
}
|
|
25930
|
-
}
|
|
25931
|
-
class StructuredContentInlineView extends StructuredContentViewBase {
|
|
25932
|
-
constructor(props) {
|
|
25933
|
-
super(props);
|
|
25934
|
-
}
|
|
25935
|
-
mount() {
|
|
25936
|
-
this.buildView();
|
|
25937
|
-
}
|
|
25938
|
-
get contentDOM() {
|
|
25939
|
-
const contentElement = this.dom?.querySelector(`.${structuredContentInnerClass$1}`);
|
|
25940
|
-
return contentElement || null;
|
|
25941
|
-
}
|
|
25942
|
-
createElement() {
|
|
25943
|
-
const element = document.createElement("span");
|
|
25944
|
-
element.classList.add(structuredContentClass$1);
|
|
25945
|
-
element.setAttribute("data-structured-content", "");
|
|
25946
|
-
const contentElement = document.createElement("span");
|
|
25947
|
-
contentElement.classList.add(structuredContentInnerClass$1);
|
|
25948
|
-
element.append(contentElement);
|
|
25949
|
-
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
25950
|
-
updateDOMAttributes(element, { ...domAttrs });
|
|
25951
|
-
return { element, contentElement };
|
|
25952
|
-
}
|
|
25953
|
-
buildView() {
|
|
25954
|
-
const { element } = this.createElement();
|
|
25955
|
-
const dragHandle = this.createDragHandle();
|
|
25956
|
-
element.prepend(dragHandle);
|
|
25957
|
-
element.addEventListener("dragstart", (e) => this.onDragStart(e));
|
|
25958
|
-
this.root = element;
|
|
25959
|
-
}
|
|
25960
|
-
updateView() {
|
|
25961
|
-
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
25962
|
-
updateDOMAttributes(this.dom, { ...domAttrs });
|
|
25963
|
-
}
|
|
25964
|
-
update(node, decorations, innerDecorations) {
|
|
25965
|
-
const result = super.update(node, decorations, innerDecorations);
|
|
25966
|
-
if (!result) return false;
|
|
25967
|
-
this.updateView();
|
|
25968
|
-
return true;
|
|
25969
|
-
}
|
|
25970
|
-
}
|
|
25971
|
-
const structuredContentClass$1 = "sd-structured-content";
|
|
25972
|
-
const structuredContentInnerClass$1 = "sd-structured-content__content";
|
|
25973
25439
|
const StructuredContent = Node$1.create({
|
|
25974
25440
|
name: "structuredContent",
|
|
25975
|
-
group: "inline
|
|
25441
|
+
group: "inline",
|
|
25976
25442
|
inline: true,
|
|
25977
25443
|
content: "inline*",
|
|
25978
|
-
isolating: true,
|
|
25979
|
-
atom: false,
|
|
25980
|
-
// false - has editable content.
|
|
25981
|
-
draggable: true,
|
|
25982
25444
|
addOptions() {
|
|
25983
25445
|
return {
|
|
25446
|
+
structuredContentClass: "sd-structured-content-tag",
|
|
25984
25447
|
htmlAttributes: {
|
|
25985
|
-
class: structuredContentClass$1,
|
|
25986
25448
|
"aria-label": "Structured content node"
|
|
25987
25449
|
}
|
|
25988
25450
|
};
|
|
25989
25451
|
},
|
|
25990
25452
|
addAttributes() {
|
|
25991
25453
|
return {
|
|
25992
|
-
id: {
|
|
25993
|
-
default: null,
|
|
25994
|
-
parseDOM: (elem) => elem.getAttribute("data-id"),
|
|
25995
|
-
renderDOM: (attrs) => {
|
|
25996
|
-
if (!attrs.id) return {};
|
|
25997
|
-
return { "data-id": attrs.id };
|
|
25998
|
-
}
|
|
25999
|
-
},
|
|
26000
25454
|
sdtPr: {
|
|
26001
25455
|
rendered: false
|
|
26002
25456
|
}
|
|
26003
25457
|
};
|
|
26004
25458
|
},
|
|
26005
25459
|
parseDOM() {
|
|
26006
|
-
return [{ tag:
|
|
25460
|
+
return [{ tag: `span.${this.options.structuredContentClass}` }];
|
|
26007
25461
|
},
|
|
26008
25462
|
renderDOM({ htmlAttributes }) {
|
|
26009
25463
|
return [
|
|
26010
25464
|
"span",
|
|
26011
25465
|
Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes, {
|
|
26012
|
-
|
|
25466
|
+
class: this.options.structuredContentClass
|
|
26013
25467
|
}),
|
|
26014
25468
|
0
|
|
26015
25469
|
];
|
|
26016
|
-
},
|
|
26017
|
-
addNodeView() {
|
|
26018
|
-
return (props) => {
|
|
26019
|
-
return new StructuredContentInlineView({ ...props });
|
|
26020
|
-
};
|
|
26021
25470
|
}
|
|
26022
25471
|
});
|
|
26023
|
-
class StructuredContentBlockView extends StructuredContentViewBase {
|
|
26024
|
-
constructor(props) {
|
|
26025
|
-
super(props);
|
|
26026
|
-
}
|
|
26027
|
-
mount() {
|
|
26028
|
-
this.buildView();
|
|
26029
|
-
}
|
|
26030
|
-
get contentDOM() {
|
|
26031
|
-
const contentElement = this.dom?.querySelector(`.${structuredContentInnerClass}`);
|
|
26032
|
-
return contentElement || null;
|
|
26033
|
-
}
|
|
26034
|
-
createElement() {
|
|
26035
|
-
const element = document.createElement("div");
|
|
26036
|
-
element.classList.add(structuredContentClass);
|
|
26037
|
-
element.setAttribute("data-structured-content-block", "");
|
|
26038
|
-
const contentElement = document.createElement("div");
|
|
26039
|
-
contentElement.classList.add(structuredContentInnerClass);
|
|
26040
|
-
element.append(contentElement);
|
|
26041
|
-
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
26042
|
-
updateDOMAttributes(element, { ...domAttrs });
|
|
26043
|
-
return { element, contentElement };
|
|
26044
|
-
}
|
|
26045
|
-
buildView() {
|
|
26046
|
-
const { element } = this.createElement();
|
|
26047
|
-
const dragHandle = this.createDragHandle();
|
|
26048
|
-
element.prepend(dragHandle);
|
|
26049
|
-
element.addEventListener("dragstart", (e) => this.onDragStart(e));
|
|
26050
|
-
this.root = element;
|
|
26051
|
-
}
|
|
26052
|
-
updateView() {
|
|
26053
|
-
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
26054
|
-
updateDOMAttributes(this.dom, { ...domAttrs });
|
|
26055
|
-
}
|
|
26056
|
-
update(node, decorations, innerDecorations) {
|
|
26057
|
-
const result = super.update(node, decorations, innerDecorations);
|
|
26058
|
-
if (!result) return false;
|
|
26059
|
-
this.updateView();
|
|
26060
|
-
return true;
|
|
26061
|
-
}
|
|
26062
|
-
}
|
|
26063
|
-
const structuredContentClass = "sd-structured-content-block";
|
|
26064
|
-
const structuredContentInnerClass = "sd-structured-content-block__content";
|
|
26065
25472
|
const StructuredContentBlock = Node$1.create({
|
|
26066
25473
|
name: "structuredContentBlock",
|
|
26067
|
-
group: "block
|
|
25474
|
+
group: "block",
|
|
26068
25475
|
content: "block*",
|
|
26069
|
-
isolating: true,
|
|
26070
|
-
atom: false,
|
|
26071
|
-
// false - has editable content.
|
|
26072
|
-
draggable: true,
|
|
26073
25476
|
addOptions() {
|
|
26074
25477
|
return {
|
|
25478
|
+
structuredContentClass: "sd-structured-content-block-tag",
|
|
26075
25479
|
htmlAttributes: {
|
|
26076
|
-
class: structuredContentClass,
|
|
26077
25480
|
"aria-label": "Structured content block node"
|
|
26078
25481
|
}
|
|
26079
25482
|
};
|
|
26080
25483
|
},
|
|
26081
25484
|
addAttributes() {
|
|
26082
25485
|
return {
|
|
26083
|
-
id: {
|
|
26084
|
-
default: null,
|
|
26085
|
-
parseDOM: (elem) => elem.getAttribute("data-id"),
|
|
26086
|
-
renderDOM: (attrs) => {
|
|
26087
|
-
if (!attrs.id) return {};
|
|
26088
|
-
return { "data-id": attrs.id };
|
|
26089
|
-
}
|
|
26090
|
-
},
|
|
26091
25486
|
sdtPr: {
|
|
26092
25487
|
rendered: false
|
|
26093
25488
|
}
|
|
26094
25489
|
};
|
|
26095
25490
|
},
|
|
26096
25491
|
parseDOM() {
|
|
26097
|
-
return [{ tag:
|
|
25492
|
+
return [{ tag: `div.${this.options.structuredContentClass}` }];
|
|
26098
25493
|
},
|
|
26099
25494
|
renderDOM({ htmlAttributes }) {
|
|
26100
25495
|
return [
|
|
26101
25496
|
"div",
|
|
26102
25497
|
Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes, {
|
|
26103
|
-
|
|
25498
|
+
class: this.options.structuredContentClass
|
|
26104
25499
|
}),
|
|
26105
25500
|
0
|
|
26106
25501
|
];
|
|
26107
|
-
},
|
|
26108
|
-
addNodeView() {
|
|
26109
|
-
return (props) => {
|
|
26110
|
-
return new StructuredContentBlockView({ ...props });
|
|
26111
|
-
};
|
|
26112
25502
|
}
|
|
26113
25503
|
});
|
|
26114
25504
|
class DocumentSectionView {
|
|
@@ -28176,8 +27566,8 @@ function mergePaddingObject(paddingObject) {
|
|
|
28176
27566
|
return Object.assign({}, getFreshSideObject(), paddingObject);
|
|
28177
27567
|
}
|
|
28178
27568
|
function expandToHashMap(value, keys2) {
|
|
28179
|
-
return keys2.reduce(function(hashMap,
|
|
28180
|
-
hashMap[
|
|
27569
|
+
return keys2.reduce(function(hashMap, key) {
|
|
27570
|
+
hashMap[key] = value;
|
|
28181
27571
|
return hashMap;
|
|
28182
27572
|
}, {});
|
|
28183
27573
|
}
|
|
@@ -28633,10 +28023,10 @@ function detectOverflow$1(state, options) {
|
|
|
28633
28023
|
var offsetData = state.modifiersData.offset;
|
|
28634
28024
|
if (elementContext === popper && offsetData) {
|
|
28635
28025
|
var offset2 = offsetData[placement];
|
|
28636
|
-
Object.keys(overflowOffsets).forEach(function(
|
|
28637
|
-
var multiply = [right, bottom].indexOf(
|
|
28638
|
-
var axis = [top, bottom].indexOf(
|
|
28639
|
-
overflowOffsets[
|
|
28026
|
+
Object.keys(overflowOffsets).forEach(function(key) {
|
|
28027
|
+
var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
|
|
28028
|
+
var axis = [top, bottom].indexOf(key) >= 0 ? "y" : "x";
|
|
28029
|
+
overflowOffsets[key] += offset2[axis] * multiply;
|
|
28640
28030
|
});
|
|
28641
28031
|
}
|
|
28642
28032
|
return overflowOffsets;
|
|
@@ -29083,8 +28473,8 @@ function mergeByName(modifiers2) {
|
|
|
29083
28473
|
}) : current;
|
|
29084
28474
|
return merged2;
|
|
29085
28475
|
}, {});
|
|
29086
|
-
return Object.keys(merged).map(function(
|
|
29087
|
-
return merged[
|
|
28476
|
+
return Object.keys(merged).map(function(key) {
|
|
28477
|
+
return merged[key];
|
|
29088
28478
|
});
|
|
29089
28479
|
}
|
|
29090
28480
|
var DEFAULT_OPTIONS = {
|
|
@@ -29241,8 +28631,8 @@ var TOUCH_OPTIONS = {
|
|
|
29241
28631
|
var TIPPY_DEFAULT_APPEND_TO = function TIPPY_DEFAULT_APPEND_TO2() {
|
|
29242
28632
|
return document.body;
|
|
29243
28633
|
};
|
|
29244
|
-
function hasOwnProperty(obj,
|
|
29245
|
-
return {}.hasOwnProperty.call(obj,
|
|
28634
|
+
function hasOwnProperty(obj, key) {
|
|
28635
|
+
return {}.hasOwnProperty.call(obj, key);
|
|
29246
28636
|
}
|
|
29247
28637
|
function getValueAtIndexOrReturn(value, index2, defaultValue) {
|
|
29248
28638
|
if (Array.isArray(value)) {
|
|
@@ -29272,8 +28662,8 @@ function debounce(fn2, ms) {
|
|
|
29272
28662
|
}
|
|
29273
28663
|
function removeProperties(obj, keys2) {
|
|
29274
28664
|
var clone = Object.assign({}, obj);
|
|
29275
|
-
keys2.forEach(function(
|
|
29276
|
-
delete clone[
|
|
28665
|
+
keys2.forEach(function(key) {
|
|
28666
|
+
delete clone[key];
|
|
29277
28667
|
});
|
|
29278
28668
|
return clone;
|
|
29279
28669
|
}
|
|
@@ -29300,9 +28690,9 @@ function arrayFrom(value) {
|
|
|
29300
28690
|
return [].slice.call(value);
|
|
29301
28691
|
}
|
|
29302
28692
|
function removeUndefinedProps(obj) {
|
|
29303
|
-
return Object.keys(obj).reduce(function(acc,
|
|
29304
|
-
if (obj[
|
|
29305
|
-
acc[
|
|
28693
|
+
return Object.keys(obj).reduce(function(acc, key) {
|
|
28694
|
+
if (obj[key] !== void 0) {
|
|
28695
|
+
acc[key] = obj[key];
|
|
29306
28696
|
}
|
|
29307
28697
|
return acc;
|
|
29308
28698
|
}, {});
|
|
@@ -29554,8 +28944,8 @@ var setDefaultProps = function setDefaultProps2(partialProps) {
|
|
|
29554
28944
|
validateProps(partialProps, []);
|
|
29555
28945
|
}
|
|
29556
28946
|
var keys2 = Object.keys(partialProps);
|
|
29557
|
-
keys2.forEach(function(
|
|
29558
|
-
defaultProps[
|
|
28947
|
+
keys2.forEach(function(key) {
|
|
28948
|
+
defaultProps[key] = partialProps[key];
|
|
29559
28949
|
});
|
|
29560
28950
|
};
|
|
29561
28951
|
function getExtendedPassedProps(passedProps) {
|
|
@@ -29574,18 +28964,18 @@ function getDataAttributeProps(reference2, plugins) {
|
|
|
29574
28964
|
var propKeys = plugins ? Object.keys(getExtendedPassedProps(Object.assign({}, defaultProps, {
|
|
29575
28965
|
plugins
|
|
29576
28966
|
}))) : defaultKeys;
|
|
29577
|
-
var props = propKeys.reduce(function(acc,
|
|
29578
|
-
var valueAsString = (reference2.getAttribute("data-tippy-" +
|
|
28967
|
+
var props = propKeys.reduce(function(acc, key) {
|
|
28968
|
+
var valueAsString = (reference2.getAttribute("data-tippy-" + key) || "").trim();
|
|
29579
28969
|
if (!valueAsString) {
|
|
29580
28970
|
return acc;
|
|
29581
28971
|
}
|
|
29582
|
-
if (
|
|
29583
|
-
acc[
|
|
28972
|
+
if (key === "content") {
|
|
28973
|
+
acc[key] = valueAsString;
|
|
29584
28974
|
} else {
|
|
29585
28975
|
try {
|
|
29586
|
-
acc[
|
|
28976
|
+
acc[key] = JSON.parse(valueAsString);
|
|
29587
28977
|
} catch (e) {
|
|
29588
|
-
acc[
|
|
28978
|
+
acc[key] = valueAsString;
|
|
29589
28979
|
}
|
|
29590
28980
|
}
|
|
29591
28981
|
return acc;
|
|
@@ -30509,8 +29899,8 @@ tippy.setDefaultProps({
|
|
|
30509
29899
|
});
|
|
30510
29900
|
const _export_sfc = (sfc, props) => {
|
|
30511
29901
|
const target = sfc.__vccOpts || sfc;
|
|
30512
|
-
for (const [
|
|
30513
|
-
target[
|
|
29902
|
+
for (const [key, val] of props) {
|
|
29903
|
+
target[key] = val;
|
|
30514
29904
|
}
|
|
30515
29905
|
return target;
|
|
30516
29906
|
};
|
|
@@ -31902,9 +31292,9 @@ const Pagination = Extension.create({
|
|
|
31902
31292
|
if (syncMeta && syncMeta.isChangeOrigin || listSyncMeta) {
|
|
31903
31293
|
return { ...oldState };
|
|
31904
31294
|
}
|
|
31905
|
-
const
|
|
31906
|
-
if (
|
|
31907
|
-
if (
|
|
31295
|
+
const imagePluginTransaction = tr.getMeta(ImagePlaceholderPluginKey);
|
|
31296
|
+
if (imagePluginTransaction) {
|
|
31297
|
+
if (imagePluginTransaction.type === "remove") {
|
|
31908
31298
|
onImageLoad(editor);
|
|
31909
31299
|
}
|
|
31910
31300
|
return { ...oldState };
|
|
@@ -33305,20 +32695,18 @@ export {
|
|
|
33305
32695
|
getQuickFormatList as a,
|
|
33306
32696
|
generateLinkedStyleString as b,
|
|
33307
32697
|
getFileOpener as c,
|
|
33308
|
-
|
|
33309
|
-
|
|
33310
|
-
|
|
32698
|
+
undoDepth as d,
|
|
32699
|
+
getStarterExtensions as e,
|
|
32700
|
+
getRichTextExtensions as f,
|
|
33311
32701
|
global as g,
|
|
33312
|
-
|
|
33313
|
-
|
|
33314
|
-
|
|
33315
|
-
|
|
33316
|
-
|
|
33317
|
-
|
|
33318
|
-
|
|
33319
|
-
|
|
33320
|
-
getAllowedImageDimensions as p,
|
|
33321
|
-
replaceSelectionWithImagePlaceholder as r,
|
|
32702
|
+
Extension as h,
|
|
32703
|
+
index$1 as i,
|
|
32704
|
+
index as j,
|
|
32705
|
+
AnnotatorHelpers as k,
|
|
32706
|
+
SectionHelpers as l,
|
|
32707
|
+
getAllowedImageDimensions as m,
|
|
32708
|
+
redoDepth as r,
|
|
32709
|
+
startImageUpload as s,
|
|
33322
32710
|
useHighContrastMode as u,
|
|
33323
32711
|
yUndoPluginKey as y
|
|
33324
32712
|
};
|