@harbour-enterprises/superdoc 0.25.0 → 0.26.0-next.1

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.
Files changed (33) hide show
  1. package/dist/chunks/{PdfViewer-Y13XRanw.es.js → PdfViewer-BKHHNbny.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-DDL0V0l5.cjs → PdfViewer-BdAhZa5N.cjs} +1 -1
  3. package/dist/chunks/{index-Bo5YCvD5.cjs → index-CAVKoWDJ.cjs} +3 -3
  4. package/dist/chunks/{index-DKNVSdr6.es.js → index-ClUzozbw.es.js} +3 -3
  5. package/dist/chunks/{super-editor.es-CYtLh0Ob.es.js → super-editor.es-BewiNPbf.es.js} +475 -249
  6. package/dist/chunks/{super-editor.es-Ct2sXbNV.cjs → super-editor.es-DZb1VLxX.cjs} +475 -249
  7. package/dist/core/types/index.d.ts.map +1 -1
  8. package/dist/super-editor/ai-writer.es.js +2 -2
  9. package/dist/super-editor/chunks/{converter-gSy6s2VK.js → converter-khE-H7hH.js} +90 -73
  10. package/dist/super-editor/chunks/{docx-zipper-CceGxV02.js → docx-zipper-KoUEtzIj.js} +1 -1
  11. package/dist/super-editor/chunks/{editor-CoX24lXQ.js → editor-CeTu_f0L.js} +388 -188
  12. package/dist/super-editor/chunks/{toolbar-BTw9-jfX.js → toolbar-D1RxvV5u.js} +2 -2
  13. package/dist/super-editor/converter.es.js +1 -1
  14. package/dist/super-editor/docx-zipper.es.js +2 -2
  15. package/dist/super-editor/editor.es.js +3 -3
  16. package/dist/super-editor/file-zipper.es.js +1 -1
  17. package/dist/super-editor/super-editor/src/core/Editor.d.ts +1 -0
  18. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/mc/altermateContent/alternate-content-translator.d.ts +11 -0
  19. package/dist/super-editor/super-editor/src/extensions/structured-content/structured-content-commands.d.ts +25 -0
  20. package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTablesById.d.ts +10 -0
  21. package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/index.d.ts +1 -0
  22. package/dist/super-editor/super-editor/src/extensions/table/table.d.ts +84 -0
  23. package/dist/super-editor/super-editor/src/extensions/table/tableHelpers/appendRows.d.ts +139 -0
  24. package/dist/super-editor/super-editor/src/index.d.ts +8 -2
  25. package/dist/super-editor/super-editor.es.js +18 -14
  26. package/dist/super-editor/toolbar.es.js +2 -2
  27. package/dist/super-editor.cjs +1 -1
  28. package/dist/super-editor.es.js +1 -1
  29. package/dist/superdoc.cjs +2 -2
  30. package/dist/superdoc.es.js +2 -2
  31. package/dist/superdoc.umd.js +476 -250
  32. package/dist/superdoc.umd.js.map +1 -1
  33. package/package.json +1 -1
@@ -40057,8 +40057,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40057
40057
  handlerName: "w:bookmarkEndTranslator",
40058
40058
  handler: handleBookmarkEndNode
40059
40059
  };
40060
- const ALTERNATE_CONTENT_NODE = "mc:AlternateContent";
40061
- const SUPPORTED_REQUIRES = /* @__PURE__ */ new Set([
40060
+ const SUPPORTED_ALTERNATE_CONTENT_REQUIRES = /* @__PURE__ */ new Set([
40062
40061
  "wps",
40063
40062
  "wp14",
40064
40063
  "w14",
@@ -40071,22 +40070,85 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40071
40070
  "w16sdtfl",
40072
40071
  "w16se"
40073
40072
  ]);
40073
+ const XML_NODE_NAME$1 = "mc:AlternateContent";
40074
+ const SD_NODE_NAME$1 = [];
40075
+ const validXmlAttributes$1 = [];
40076
+ function encode$1(params2) {
40077
+ const { nodeListHandler } = params2;
40078
+ const { node } = params2.extraParams;
40079
+ if (!node || !node.type) {
40080
+ return null;
40081
+ }
40082
+ const { branch, elements } = selectAlternateContentElements(node);
40083
+ if (!elements) {
40084
+ return null;
40085
+ }
40086
+ return nodeListHandler.handler({
40087
+ ...params2,
40088
+ nodes: elements,
40089
+ path: buildPath(params2.path, node, branch)
40090
+ });
40091
+ }
40092
+ function decode$1(params2) {
40093
+ const { node } = params2;
40094
+ const { drawingContent } = node.attrs;
40095
+ const drawing = {
40096
+ name: "w:drawing",
40097
+ elements: [...drawingContent ? [...drawingContent.elements || []] : []]
40098
+ };
40099
+ const choice = {
40100
+ name: "mc:Choice",
40101
+ attributes: { Requires: "wps" },
40102
+ elements: [drawing]
40103
+ };
40104
+ return {
40105
+ name: "mc:AlternateContent",
40106
+ elements: [choice]
40107
+ };
40108
+ }
40109
+ const config$1 = {
40110
+ xmlName: XML_NODE_NAME$1,
40111
+ sdNodeOrKeyName: SD_NODE_NAME$1,
40112
+ type: NodeTranslator.translatorTypes.NODE,
40113
+ encode: encode$1,
40114
+ decode: decode$1,
40115
+ attributes: validXmlAttributes$1
40116
+ };
40117
+ function selectAlternateContentElements(node) {
40118
+ if (!node?.elements?.length) {
40119
+ return { branch: null, elements: null };
40120
+ }
40121
+ const choices = node.elements.filter((el) => el?.name === "mc:Choice");
40122
+ const fallback = node.elements.find((el) => el?.name === "mc:Fallback");
40123
+ const supportedChoice = choices.find((choice) => {
40124
+ const requiresAttr = choice?.attributes?.Requires || choice?.attributes?.requires;
40125
+ if (!requiresAttr) return false;
40126
+ return requiresAttr.split(/\s+/).filter(Boolean).some((namespace2) => SUPPORTED_ALTERNATE_CONTENT_REQUIRES.has(namespace2));
40127
+ });
40128
+ const branch = supportedChoice || fallback || choices[0] || null;
40129
+ const selectedElements = branch?.elements;
40130
+ if (!selectedElements) {
40131
+ return { branch, elements: null };
40132
+ }
40133
+ return {
40134
+ branch,
40135
+ elements: carbonCopy(selectedElements)
40136
+ };
40137
+ }
40138
+ const translator$1 = NodeTranslator.from(config$1);
40139
+ function buildPath(existingPath = [], node, branch) {
40140
+ const path = [...existingPath];
40141
+ if (node) path.push(node);
40142
+ if (branch) path.push(branch);
40143
+ return path;
40144
+ }
40145
+ const ALTERNATE_CONTENT_NODE = "mc:AlternateContent";
40074
40146
  const skipHandlerResponse = { nodes: [], consumed: 0 };
40075
40147
  const isAlternateContentNode = (node) => node?.name === ALTERNATE_CONTENT_NODE;
40076
- const isSupportedChoice = (choice) => {
40077
- if (!choice?.attributes) return false;
40078
- const requires = choice.attributes.Requires || choice.attributes.requires;
40079
- if (!requires) return false;
40080
- return requires.split(/\s+/).filter(Boolean).some((namespace2) => SUPPORTED_REQUIRES.has(namespace2));
40081
- };
40082
40148
  const resolveAlternateContentElements = (alternateContent) => {
40083
- if (!alternateContent?.elements?.length) return null;
40084
- const choices = alternateContent.elements.filter((el) => el.name === "mc:Choice");
40085
- const fallback = alternateContent.elements.find((el) => el.name === "mc:Fallback");
40086
- const supportedChoice = choices.find(isSupportedChoice);
40087
- const selectedElements = supportedChoice?.elements || fallback?.elements || choices[0]?.elements;
40088
- if (!selectedElements) return null;
40089
- return carbonCopy(selectedElements);
40149
+ const { elements } = selectAlternateContentElements(alternateContent);
40150
+ if (!elements) return null;
40151
+ return elements;
40090
40152
  };
40091
40153
  const buildNodeWithoutAlternateContent = (node) => {
40092
40154
  const { elements } = node || {};
@@ -40118,16 +40180,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40118
40180
  }
40119
40181
  const [currentNode] = nodes;
40120
40182
  if (isAlternateContentNode(currentNode)) {
40121
- const resolvedElements = resolveAlternateContentElements(currentNode);
40122
- if (!resolvedElements) {
40123
- return skipHandlerResponse;
40124
- }
40125
- const result2 = nodeListHandler.handler({
40183
+ const nodeForTranslator = currentNode?.type ? currentNode : {
40184
+ ...currentNode,
40185
+ type: "element"
40186
+ };
40187
+ const translated = translator$1.encode({
40126
40188
  ...params2,
40127
- nodes: resolvedElements,
40128
- path: [...params2.path || [], currentNode]
40189
+ nodes: [nodeForTranslator],
40190
+ extraParams: { ...params2.extraParams || {}, node: nodeForTranslator }
40129
40191
  });
40130
- return { nodes: result2, consumed: 1 };
40192
+ if (!translated) {
40193
+ return skipHandlerResponse;
40194
+ }
40195
+ const nodesArray = Array.isArray(translated) ? translated : [translated];
40196
+ return { nodes: nodesArray, consumed: 1 };
40131
40197
  }
40132
40198
  const sanitizedNode = buildNodeWithoutAlternateContent(currentNode);
40133
40199
  if (!sanitizedNode) {
@@ -41398,55 +41464,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41398
41464
  };
41399
41465
  return textbox;
41400
41466
  }
41401
- const XML_NODE_NAME$1 = "mc:AlternateContent";
41402
- const SD_NODE_NAME$1 = [];
41403
- const validXmlAttributes$1 = [];
41404
- function encode$1(params2) {
41405
- const { nodeListHandler } = params2;
41406
- const { node } = params2.extraParams;
41407
- if (!node || !node.type) {
41408
- return null;
41409
- }
41410
- const allowedNamespaces = ["wps", "wp14", "w14", "w15"];
41411
- const wpsNode = node.elements.find(
41412
- (el) => el.name === "mc:Choice" && allowedNamespaces.includes(el.attributes["Requires"])
41413
- );
41414
- if (!wpsNode) {
41415
- return null;
41416
- }
41417
- const contents = wpsNode.elements;
41418
- return nodeListHandler.handler({
41419
- ...params2,
41420
- nodes: contents,
41421
- path: [...params2.path || [], wpsNode]
41422
- });
41423
- }
41424
- function decode$1(params2) {
41425
- const { node } = params2;
41426
- const { drawingContent } = node.attrs;
41427
- const drawing = {
41428
- name: "w:drawing",
41429
- elements: [...drawingContent ? [...drawingContent.elements || []] : []]
41430
- };
41431
- const choice = {
41432
- name: "mc:Choice",
41433
- attributes: { Requires: "wps" },
41434
- elements: [drawing]
41435
- };
41436
- return {
41437
- name: "mc:AlternateContent",
41438
- elements: [choice]
41439
- };
41440
- }
41441
- const config$1 = {
41442
- xmlName: XML_NODE_NAME$1,
41443
- sdNodeOrKeyName: SD_NODE_NAME$1,
41444
- type: NodeTranslator.translatorTypes.NODE,
41445
- encode: encode$1,
41446
- decode: decode$1,
41447
- attributes: validXmlAttributes$1
41448
- };
41449
- const translator$1 = NodeTranslator.from(config$1);
41450
41467
  function translateContentBlock(params2) {
41451
41468
  const { node } = params2;
41452
41469
  const { vmlAttributes, horizontalRule } = node.attrs;
@@ -42839,7 +42856,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42839
42856
  static getStoredSuperdocVersion(docx) {
42840
42857
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42841
42858
  }
42842
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.24.0") {
42859
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.25.0") {
42843
42860
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42844
42861
  }
42845
42862
  /**
@@ -46050,7 +46067,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
46050
46067
  var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
46051
46068
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
46052
46069
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
46053
- 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, checkFonts_fn, determineUnsupportedFontsWithLocalFonts_fn, determineUnsupportedFontsWithCanvas_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ListItemNodeView_instances, init_fn3, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
46070
+ 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, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ListItemNodeView_instances, init_fn3, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
46054
46071
  var GOOD_LEAF_SIZE = 200;
46055
46072
  var RopeSequence = function RopeSequence2() {
46056
46073
  };
@@ -60265,7 +60282,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
60265
60282
  isHeaderFooterChanged: false,
60266
60283
  isCustomXmlChanged: false,
60267
60284
  focusTarget: null,
60268
- permissionResolver: null
60285
+ permissionResolver: null,
60286
+ // header/footer editors may have parent(main) editor set
60287
+ parentEditor: null
60269
60288
  });
60270
60289
  __privateMethod$1(this, _Editor_instances, initContainerElement_fn).call(this, options);
60271
60290
  __privateMethod$1(this, _Editor_instances, checkHeadless_fn).call(this, options);
@@ -61027,7 +61046,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61027
61046
  * @returns {Object | void} Migration results
61028
61047
  */
61029
61048
  processCollaborationMigrations() {
61030
- console.debug("[checkVersionMigrations] Current editor version", "0.24.0");
61049
+ console.debug("[checkVersionMigrations] Current editor version", "0.25.0");
61031
61050
  if (!this.options.ydoc) return;
61032
61051
  const metaMap = this.options.ydoc.getMap("meta");
61033
61052
  let docVersion = metaMap.get("version");
@@ -61233,9 +61252,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61233
61252
  this.emit("beforeCreate", { editor: this });
61234
61253
  this.on("contentError", this.options.onContentError);
61235
61254
  this.mount(this.options.element);
61236
- if (!this.options.isHeadless) {
61237
- __privateMethod$1(this, _Editor_instances, checkFonts_fn).call(this);
61238
- }
61239
61255
  this.on("create", this.options.onCreate);
61240
61256
  this.on("update", this.options.onUpdate);
61241
61257
  this.on("selectionUpdate", this.options.onSelectionUpdate);
@@ -61257,8 +61273,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61257
61273
  if (!this.options.isHeadless) {
61258
61274
  this.initializeCollaborationData();
61259
61275
  this.initDefaultStyles();
61276
+ __privateMethod$1(this, _Editor_instances, checkFonts_fn).call(this);
61260
61277
  }
61261
- if (!this.options.ydoc || this.options.markdown || this.options.html) {
61278
+ const shouldMigrateListsOnInit = Boolean(
61279
+ this.options.markdown || this.options.html || this.options.loadFromSchema || this.options.jsonOverride || this.options.mode === "html" || this.options.mode === "text"
61280
+ );
61281
+ if (shouldMigrateListsOnInit) {
61262
61282
  this.migrateListsToV2();
61263
61283
  }
61264
61284
  this.setDocumentMode(this.options.documentMode);
@@ -61399,52 +61419,18 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61399
61419
  if (this.options.isHeadless) {
61400
61420
  return;
61401
61421
  }
61402
- const fontsUsedInDocument = this.converter.getDocumentFonts();
61403
- if (!("queryLocalFonts" in window)) {
61404
- console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
61405
- const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
61406
- this.emit("fonts-resolved", {
61407
- documentFonts: fontsUsedInDocument,
61408
- unsupportedFonts
61409
- });
61410
- return;
61411
- }
61412
- const localFontAccess = await navigator.permissions.query({ name: "local-fonts" });
61413
- if (localFontAccess.state === "denied") {
61414
- console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
61415
- const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
61416
- this.emit("fonts-resolved", {
61417
- documentFonts: fontsUsedInDocument,
61418
- unsupportedFonts
61419
- });
61420
- return;
61421
- }
61422
61422
  try {
61423
- const localFonts = await window.queryLocalFonts();
61424
- const uniqueLocalFonts = [...new Set(localFonts.map((font) => font.family))];
61425
- const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithLocalFonts_fn).call(this, fontsUsedInDocument, uniqueLocalFonts);
61423
+ const fontsUsedInDocument = this.converter.getDocumentFonts();
61424
+ const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFonts_fn).call(this, fontsUsedInDocument);
61426
61425
  this.emit("fonts-resolved", {
61427
61426
  documentFonts: fontsUsedInDocument,
61428
61427
  unsupportedFonts
61429
61428
  });
61430
61429
  } catch {
61431
- console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
61432
- const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
61433
- this.emit("fonts-resolved", {
61434
- documentFonts: fontsUsedInDocument,
61435
- unsupportedFonts
61436
- });
61430
+ console.warn("[SuperDoc] Could not determine document fonts and unsupported fonts");
61437
61431
  }
61438
61432
  };
61439
- determineUnsupportedFontsWithLocalFonts_fn = function(fonts, localFonts) {
61440
- const unsupportedFonts = fonts.filter((font) => {
61441
- const isLocalFont = localFonts.includes(font);
61442
- const isFontImported = this.fontsImported.includes(font);
61443
- return !isLocalFont && !isFontImported;
61444
- });
61445
- return unsupportedFonts;
61446
- };
61447
- determineUnsupportedFontsWithCanvas_fn = function(fonts) {
61433
+ determineUnsupportedFonts_fn = function(fonts) {
61448
61434
  const unsupportedFonts = fonts.filter((font) => {
61449
61435
  const canRender = canRenderFont(font);
61450
61436
  const isFontImported = this.fontsImported.includes(font);
@@ -61532,6 +61518,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61532
61518
  if (this.options.collaborationIsReady) return;
61533
61519
  console.debug("🔗 [super-editor] Collaboration ready");
61534
61520
  __privateMethod$1(this, _Editor_instances, validateDocumentInit_fn).call(this);
61521
+ if (this.options.ydoc) {
61522
+ this.migrateListsToV2();
61523
+ }
61535
61524
  this.options.onCollaborationReady({ editor, ydoc });
61536
61525
  this.options.collaborationIsReady = true;
61537
61526
  this.options.initialState = this.state;
@@ -63477,10 +63466,27 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63477
63466
  const result = findChildren$5(state2.doc, (node) => node.type.name === "structuredContentBlock");
63478
63467
  return result;
63479
63468
  }
63469
+ function getStructuredContentTablesById(id, state2) {
63470
+ if (!id || !state2) return [];
63471
+ const blocks = getStructuredContentTagsById(id, state2).filter(
63472
+ ({ node }) => node.type.name === "structuredContentBlock"
63473
+ );
63474
+ if (!blocks.length) return [];
63475
+ const { pos: blockPos, node: blockNode } = blocks[0];
63476
+ const tablesInBlock = [];
63477
+ blockNode.descendants((child, relPos) => {
63478
+ if (child.type.name === "table") {
63479
+ const absPos = blockPos + 1 + relPos;
63480
+ tablesInBlock.push({ node: child, pos: absPos });
63481
+ }
63482
+ });
63483
+ return tablesInBlock;
63484
+ }
63480
63485
  const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
63481
63486
  __proto__: null,
63482
63487
  getStructuredContentBlockTags,
63483
63488
  getStructuredContentInlineTags,
63489
+ getStructuredContentTablesById,
63484
63490
  getStructuredContentTags,
63485
63491
  getStructuredContentTagsById
63486
63492
  }, Symbol.toStringTag, { value: "Module" }));
@@ -63677,6 +63683,36 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63677
63683
  tr.replaceWith(posFrom, posTo, content);
63678
63684
  }
63679
63685
  return true;
63686
+ },
63687
+ /**
63688
+ * Append multiple rows to the end of a table inside a structured content block.
63689
+ * Each inner array represents the cell values for one new row.
63690
+ * @category Command
63691
+ * @param {StructuredContentTableAppendRowsOptions} options - Append configuration
63692
+ * @example
63693
+ * editor.commands.appendRowsToStructuredContentTable({
63694
+ * id: 'block-123',
63695
+ * tableIndex: 0,
63696
+ * rows: [['A', 'B'], ['C', 'D']],
63697
+ * copyRowStyle: true,
63698
+ * });
63699
+ */
63700
+ appendRowsToStructuredContentTable: ({ id, tableIndex = 0, rows = [], copyRowStyle = false }) => ({ state: state2, commands: commands2, dispatch }) => {
63701
+ const normalized = normalizeRowsInput(rows);
63702
+ if (!normalized.length) return true;
63703
+ const tables = getStructuredContentTablesById(id, state2);
63704
+ if (!tables.length || tableIndex < 0 || tableIndex >= tables.length) return true;
63705
+ const { node: tableNode, pos: tablePos } = tables[tableIndex];
63706
+ if (dispatch) {
63707
+ return commands2.appendRowsWithContent({ tablePos, tableNode, valueRows: normalized, copyRowStyle });
63708
+ }
63709
+ return commands2.appendRowsWithContent({
63710
+ tablePos,
63711
+ tableNode,
63712
+ valueRows: normalized,
63713
+ copyRowStyle,
63714
+ dispatch: false
63715
+ });
63680
63716
  }
63681
63717
  };
63682
63718
  },
@@ -63686,6 +63722,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63686
63722
  };
63687
63723
  }
63688
63724
  });
63725
+ const normalizeRowsInput = (rowsOrValues) => {
63726
+ if (!Array.isArray(rowsOrValues) || !rowsOrValues.length) {
63727
+ return [];
63728
+ }
63729
+ if (Array.isArray(rowsOrValues[0])) {
63730
+ return rowsOrValues;
63731
+ }
63732
+ return [rowsOrValues];
63733
+ };
63689
63734
  class DocumentSectionView {
63690
63735
  constructor(node, getPos, decorations, editor) {
63691
63736
  __privateAdd$1(this, _DocumentSectionView_instances);
@@ -69438,6 +69483,107 @@ Please report this to https://github.com/markedjs/marked.`, e) {
69438
69483
  }
69439
69484
  return null;
69440
69485
  }
69486
+ function resolveTable(tr, tablePos, tableNode) {
69487
+ if (tableNode && tableNode.type && tableNode.type.name === "table") {
69488
+ return tableNode;
69489
+ }
69490
+ if (typeof tablePos === "number") {
69491
+ const current = tr.doc.nodeAt(tablePos);
69492
+ if (current && current.type.name === "table") {
69493
+ return current;
69494
+ }
69495
+ }
69496
+ return null;
69497
+ }
69498
+ function pickTemplateRowForAppend(tableNode, schema) {
69499
+ const RowType = schema.nodes.tableRow;
69500
+ const rows = [];
69501
+ tableNode.descendants((child) => {
69502
+ if (child.type === RowType) rows.push(child);
69503
+ });
69504
+ if (!rows.length) return null;
69505
+ for (let i2 = rows.length - 1; i2 >= 0; i2--) {
69506
+ const r2 = rows[i2];
69507
+ const hasBodyCell = r2.content?.content?.some((c2) => c2.type.name === "tableCell");
69508
+ if (hasBodyCell) return r2;
69509
+ }
69510
+ return rows[rows.length - 1];
69511
+ }
69512
+ function extractRowTemplateFormatting(cellNode, schema) {
69513
+ const ParagraphType = schema.nodes.paragraph;
69514
+ let blockType = ParagraphType;
69515
+ let blockAttrs = null;
69516
+ let textMarks = [];
69517
+ const blocks = cellNode?.content?.content || [];
69518
+ for (const block of blocks) {
69519
+ const isParagraphish = block.type === ParagraphType || block.type.name === "heading";
69520
+ if (isParagraphish) {
69521
+ blockType = block.type || ParagraphType;
69522
+ blockAttrs = block.attrs || null;
69523
+ }
69524
+ let foundText = null;
69525
+ block.descendants?.((n) => {
69526
+ if (!foundText && n.isText) foundText = n;
69527
+ });
69528
+ if (foundText) {
69529
+ textMarks = foundText.marks ? Array.from(foundText.marks) : [];
69530
+ break;
69531
+ }
69532
+ }
69533
+ if (!blockType || !blockType.validContent) blockType = ParagraphType;
69534
+ return { blockType, blockAttrs, textMarks };
69535
+ }
69536
+ function buildFormattedCellBlock(schema, value, { blockType, blockAttrs, textMarks }, copyRowStyle = false) {
69537
+ const text = typeof value === "string" ? value : value == null ? "" : String(value);
69538
+ const marks = copyRowStyle ? textMarks || [] : [];
69539
+ const textNode = schema.text(text, marks);
69540
+ const type2 = blockType || schema.nodes.paragraph;
69541
+ return type2.createAndFill(blockAttrs || null, textNode);
69542
+ }
69543
+ function buildRowFromTemplateRow({ schema, tableNode, templateRow, values, copyRowStyle = false }) {
69544
+ const RowType = schema.nodes.tableRow;
69545
+ const CellType = schema.nodes.tableCell;
69546
+ const HeaderType = schema.nodes.tableHeader;
69547
+ const map2 = TableMap.get(tableNode);
69548
+ const totalColumns = map2.width;
69549
+ const byColumns = Array.isArray(values) && values.length === totalColumns;
69550
+ const newCells = [];
69551
+ let columnCursor = 0;
69552
+ templateRow.content.content.forEach((cellNode, cellIndex) => {
69553
+ const isHeaderCell = cellNode.type === HeaderType;
69554
+ const targetCellType = isHeaderCell ? CellType : cellNode.type;
69555
+ const attrs = { ...cellNode.attrs };
69556
+ const formatting = extractRowTemplateFormatting(cellNode, schema);
69557
+ let cellValue = "";
69558
+ if (byColumns) {
69559
+ const span = Math.max(1, attrs.colspan || 1);
69560
+ cellValue = values[columnCursor] ?? "";
69561
+ columnCursor += span;
69562
+ } else {
69563
+ cellValue = Array.isArray(values) ? values[cellIndex] ?? "" : "";
69564
+ }
69565
+ const content = buildFormattedCellBlock(schema, cellValue, formatting, copyRowStyle);
69566
+ const newCell = targetCellType.createAndFill(attrs, content);
69567
+ if (newCell) newCells.push(newCell);
69568
+ });
69569
+ return RowType.createAndFill(null, newCells);
69570
+ }
69571
+ function insertRowsAtTableEnd({ tr, tablePos, tableNode, rows }) {
69572
+ if (!rows || !rows.length) return;
69573
+ const RowTypeName = "tableRow";
69574
+ let lastRowRelPos = 0;
69575
+ let lastRowNode = null;
69576
+ tableNode.descendants((child, relPos) => {
69577
+ if (child.type.name === RowTypeName) {
69578
+ lastRowRelPos = relPos;
69579
+ lastRowNode = child;
69580
+ }
69581
+ });
69582
+ if (!lastRowNode) return;
69583
+ const lastRowAbsEnd = tablePos + 1 + lastRowRelPos + lastRowNode.nodeSize;
69584
+ const frag = Fragment.fromArray(rows);
69585
+ tr.insert(lastRowAbsEnd, frag);
69586
+ }
69441
69587
  const Table = Node$1.create({
69442
69588
  name: "table",
69443
69589
  content: "tableRow+",
@@ -69597,6 +69743,47 @@ Please report this to https://github.com/markedjs/marked.`, e) {
69597
69743
  },
69598
69744
  addCommands() {
69599
69745
  return {
69746
+ /**
69747
+ * Append multiple rows to the end of a table in a single transaction.
69748
+ * @category Command
69749
+ * @param {appendRowsWithContentOptions} options - Append configuration
69750
+ * @example
69751
+ * editor.commands.appendRowsWithContent({ tablePos, valueRows: [['A','B'], ['C','D']], copyRowStyle: true })
69752
+ */
69753
+ appendRowsWithContent: ({ tablePos, tableNode, valueRows = [], copyRowStyle = false }) => ({ editor, chain }) => {
69754
+ if (typeof tablePos !== "number" && !tableNode || !Array.isArray(valueRows) || !valueRows.length) {
69755
+ return false;
69756
+ }
69757
+ return chain().command(({ tr, dispatch }) => {
69758
+ const workingTable = resolveTable(tr, tablePos, tableNode);
69759
+ if (!workingTable) return false;
69760
+ const templateRow = pickTemplateRowForAppend(workingTable, editor.schema);
69761
+ if (!templateRow) return false;
69762
+ const newRows = valueRows.map(
69763
+ (vals) => buildRowFromTemplateRow({
69764
+ schema: editor.schema,
69765
+ tableNode: workingTable,
69766
+ templateRow,
69767
+ values: vals,
69768
+ copyRowStyle
69769
+ })
69770
+ ).filter(Boolean);
69771
+ if (!newRows.length) return false;
69772
+ let resolvedTablePos = tablePos;
69773
+ if (typeof resolvedTablePos !== "number" && workingTable) {
69774
+ const tables = editor.getNodesOfType("table");
69775
+ const match = workingTable ? tables.find((t) => t.node.eq(workingTable)) : tables[0];
69776
+ resolvedTablePos = match?.pos ?? null;
69777
+ }
69778
+ if (typeof resolvedTablePos !== "number") {
69779
+ return false;
69780
+ }
69781
+ if (dispatch) {
69782
+ insertRowsAtTableEnd({ tr, tablePos, tableNode: workingTable, rows: newRows });
69783
+ }
69784
+ return true;
69785
+ }).run();
69786
+ },
69600
69787
  /**
69601
69788
  * Insert a new table into the document
69602
69789
  * @category Command
@@ -72503,58 +72690,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72503
72690
  }
72504
72691
  });
72505
72692
  };
72506
- const normalizeWrap = (attrs = {}) => {
72507
- const wrap2 = attrs.wrap;
72508
- if (wrap2?.type && wrap2.type !== "Inline") {
72509
- return {
72510
- type: wrap2.type,
72511
- attrs: wrap2.attrs ?? {}
72512
- };
72513
- }
72514
- if (wrap2?.type === "Inline" && Object.keys(wrap2.attrs ?? {}).length) {
72515
- return {
72516
- type: "Inline",
72517
- attrs: wrap2.attrs
72518
- };
72519
- }
72520
- if (!wrap2 && attrs.wrapText) {
72521
- return {
72522
- type: "Square",
72523
- attrs: {
72524
- wrapText: attrs.wrapText
72525
- }
72526
- };
72527
- }
72528
- if (!wrap2 && attrs.wrapTopAndBottom) {
72529
- return {
72530
- type: "TopAndBottom",
72531
- attrs: {}
72532
- };
72533
- }
72534
- if (wrap2?.type === "Inline") {
72535
- return {
72536
- type: "Inline",
72537
- attrs: wrap2.attrs ?? {}
72538
- };
72539
- }
72540
- return {
72541
- type: "Inline",
72542
- attrs: {}
72543
- };
72544
- };
72545
- const normalizeMarginOffset = (marginOffset = {}) => {
72546
- const { left: left2, horizontal, ...rest } = marginOffset;
72547
- return {
72548
- ...rest,
72549
- horizontal: horizontal ?? left2
72550
- };
72551
- };
72552
- const getNormalizedImageAttrs = (attrs = {}) => {
72553
- return {
72554
- wrap: normalizeWrap(attrs),
72555
- marginOffset: normalizeMarginOffset(attrs.marginOffset ?? {})
72556
- };
72557
- };
72558
72693
  const ImagePositionPluginKey = new PluginKey("ImagePosition");
72559
72694
  const ImagePositionPlugin = ({ editor }) => {
72560
72695
  const { view } = editor;
@@ -72567,8 +72702,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72567
72702
  return DecorationSet.empty;
72568
72703
  },
72569
72704
  apply(tr, oldDecorationSet, oldState, newState) {
72570
- if (!tr.docChanged) return oldDecorationSet;
72705
+ if (!tr.docChanged && !shouldUpdate) return oldDecorationSet;
72571
72706
  const decorations = getImagePositionDecorations(newState, view);
72707
+ shouldUpdate = false;
72572
72708
  return DecorationSet.create(newState.doc, decorations);
72573
72709
  }
72574
72710
  },
@@ -72577,7 +72713,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72577
72713
  update: (view2, lastState) => {
72578
72714
  const pagination = PaginationPluginKey.getState(lastState);
72579
72715
  if (shouldUpdate) {
72580
- shouldUpdate = false;
72581
72716
  const decorations = getImagePositionDecorations(lastState, view2);
72582
72717
  const updateTransaction = view2.state.tr.setMeta(ImagePositionPluginKey, { decorations });
72583
72718
  view2.dispatch(updateTransaction);
@@ -72603,41 +72738,35 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72603
72738
  let className = "";
72604
72739
  const { vRelativeFrom, alignH } = node.attrs.anchorData;
72605
72740
  const { size: size2, padding } = node.attrs;
72606
- const { marginOffset } = getNormalizedImageAttrs(node.attrs);
72607
72741
  const pageBreak = findPreviousDomNodeWithClass(view, pos, "pagination-break-wrapper");
72608
- if (pageBreak) {
72609
- switch (alignH) {
72610
- case "left":
72611
- style2 += "float: left; left: 0; margin-left: 0; ";
72612
- break;
72613
- case "right":
72614
- style2 += "float: right; right: 0; margin-right: 0; ";
72615
- break;
72616
- case "center":
72617
- style2 += "display: block; margin-left: auto; margin-right: auto; ";
72618
- break;
72742
+ if (pageBreak && vRelativeFrom === "margin" && alignH) {
72743
+ const topPos = pageBreak?.offsetTop + pageBreak?.offsetHeight;
72744
+ let horizontalAlignment = `${alignH}: 0;`;
72745
+ if (alignH === "center") horizontalAlignment = "left: 50%; transform: translateX(-50%);";
72746
+ style2 += vRelativeFrom === "margin" ? `position: absolute; top: ${topPos}px; ${horizontalAlignment}` : "";
72747
+ const nextPos = view.posAtDOM(pageBreak, 1);
72748
+ if (nextPos < 0) {
72749
+ const $pos = view.state.doc.resolve(pos);
72750
+ decorations.push(
72751
+ Decoration.node(pos - 1, pos + $pos.parent.nodeSize - 1, {
72752
+ style: `height: ${size2.height + parseInt(padding.top) + parseInt(padding.bottom)}px`
72753
+ })
72754
+ );
72619
72755
  }
72620
- const topPos = marginOffset.top !== void 0 ? marginOffset.top : pageBreak?.offsetTop + pageBreak?.offsetHeight;
72621
- style2 += vRelativeFrom === "margin" ? `position: absolute; top: ${topPos}px; ` : "";
72622
- if (vRelativeFrom === "margin") {
72623
- const nextPos = view.posAtDOM(pageBreak, 1);
72624
- if (nextPos < 0) {
72625
- const $pos = view.state.doc.resolve(pos);
72626
- decorations.push(
72627
- Decoration.node(pos - 1, pos + $pos.parent.nodeSize - 1, {
72628
- style: `height: ${size2.height + parseInt(padding.top) + parseInt(padding.bottom)}px`
72629
- })
72630
- );
72631
- }
72632
- const imageBlock = document.createElement("div");
72633
- imageBlock.className = "anchor-image-placeholder";
72634
- imageBlock.style.float = alignH;
72635
- imageBlock.style.width = size2.width + parseInt(padding[alignH]) + "px";
72636
- imageBlock.style.height = size2.height + parseInt(padding.top) + parseInt(padding.bottom) + "px";
72637
- decorations.push(Decoration.widget(nextPos, imageBlock, { key: "stable-key" }));
72756
+ const imageBlock = document.createElement("div");
72757
+ imageBlock.className = "anchor-image-placeholder";
72758
+ imageBlock.style.float = alignH === "left" || alignH === "right" ? alignH : "none";
72759
+ let paddingHorizontal;
72760
+ if (alignH === "center") {
72761
+ paddingHorizontal = (parseInt(padding.left) || 0) + (parseInt(padding.right) || 0);
72762
+ } else {
72763
+ paddingHorizontal = parseInt(padding[alignH]) || 0;
72638
72764
  }
72765
+ imageBlock.style.width = size2.width + paddingHorizontal + "px";
72766
+ imageBlock.style.height = size2.height + parseInt(padding.top) + parseInt(padding.bottom) + "px";
72767
+ decorations.push(Decoration.widget(nextPos, imageBlock, { key: "stable-key" }));
72768
+ decorations.push(Decoration.inline(pos, pos + node.nodeSize, { style: style2, class: className }));
72639
72769
  }
72640
- decorations.push(Decoration.inline(pos, pos + node.nodeSize, { style: style2, class: className }));
72641
72770
  }
72642
72771
  });
72643
72772
  return decorations;
@@ -72662,6 +72791,58 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72662
72791
  }
72663
72792
  return null;
72664
72793
  };
72794
+ const normalizeWrap = (attrs = {}) => {
72795
+ const wrap2 = attrs.wrap;
72796
+ if (wrap2?.type && wrap2.type !== "Inline") {
72797
+ return {
72798
+ type: wrap2.type,
72799
+ attrs: wrap2.attrs ?? {}
72800
+ };
72801
+ }
72802
+ if (wrap2?.type === "Inline" && Object.keys(wrap2.attrs ?? {}).length) {
72803
+ return {
72804
+ type: "Inline",
72805
+ attrs: wrap2.attrs
72806
+ };
72807
+ }
72808
+ if (!wrap2 && attrs.wrapText) {
72809
+ return {
72810
+ type: "Square",
72811
+ attrs: {
72812
+ wrapText: attrs.wrapText
72813
+ }
72814
+ };
72815
+ }
72816
+ if (!wrap2 && attrs.wrapTopAndBottom) {
72817
+ return {
72818
+ type: "TopAndBottom",
72819
+ attrs: {}
72820
+ };
72821
+ }
72822
+ if (wrap2?.type === "Inline") {
72823
+ return {
72824
+ type: "Inline",
72825
+ attrs: wrap2.attrs ?? {}
72826
+ };
72827
+ }
72828
+ return {
72829
+ type: "Inline",
72830
+ attrs: {}
72831
+ };
72832
+ };
72833
+ const normalizeMarginOffset = (marginOffset = {}) => {
72834
+ const { left: left2, horizontal, ...rest } = marginOffset;
72835
+ return {
72836
+ ...rest,
72837
+ horizontal: horizontal ?? left2
72838
+ };
72839
+ };
72840
+ const getNormalizedImageAttrs = (attrs = {}) => {
72841
+ return {
72842
+ wrap: normalizeWrap(attrs),
72843
+ marginOffset: normalizeMarginOffset(attrs.marginOffset ?? {})
72844
+ };
72845
+ };
72665
72846
  const getRotationMargins = (w2, h2, angleDegrees) => {
72666
72847
  const rad = angleDegrees * (Math.PI / 180);
72667
72848
  const cos = Math.abs(Math.cos(rad));
@@ -72870,27 +73051,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72870
73051
  style2 += "float: right;";
72871
73052
  floatRight = true;
72872
73053
  } else if (["largest", "bothSides"].includes(attrs.wrapText)) {
72873
- const pageStyles2 = this.editor?.converter?.pageStyles;
72874
- if (pageStyles2?.pageSize && pageStyles2?.pageMargins && size2.width) {
72875
- const pageWidth = inchesToPixels(pageStyles2.pageSize.width);
72876
- const leftMargin = inchesToPixels(pageStyles2.pageMargins.left);
72877
- const rightMargin = inchesToPixels(pageStyles2.pageMargins.right);
72878
- const contentWidth = pageWidth - leftMargin - rightMargin;
72879
- const imageWidth = size2.width + (attrs.distLeft || 0) + (attrs.distRight || 0);
72880
- const leftSpace = marginOffset.horizontal;
72881
- const rightSpace = contentWidth - leftSpace - imageWidth;
72882
- if (rightSpace < 0) {
72883
- style2 += "float: left;";
72884
- } else if (rightSpace > leftSpace) {
72885
- style2 += "float: left;";
72886
- } else {
72887
- style2 += "float: right;";
72888
- floatRight = true;
72889
- baseHorizontal = rightSpace;
72890
- }
72891
- } else {
72892
- style2 += "float: left;";
72893
- }
73054
+ const pageStylesData2 = getDataFromPageStyles({
73055
+ editor: this.editor,
73056
+ marginOffset,
73057
+ size: size2,
73058
+ attrs
73059
+ });
73060
+ style2 += pageStylesData2.style;
73061
+ floatRight = pageStylesData2.floatRight;
73062
+ baseHorizontal = pageStylesData2.baseHorizontal;
72894
73063
  }
72895
73064
  if (attrs.distTop) margin.top += attrs.distTop;
72896
73065
  if (attrs.distBottom) margin.bottom += attrs.distBottom;
@@ -72900,27 +73069,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72900
73069
  case "Through":
72901
73070
  case "Tight":
72902
73071
  style2 += "clear: both;";
72903
- const pageStyles = this.editor?.converter?.pageStyles;
72904
- if (pageStyles?.pageSize && pageStyles?.pageMargins && size2.width) {
72905
- const pageWidth = inchesToPixels(pageStyles.pageSize.width);
72906
- const leftMargin = inchesToPixels(pageStyles.pageMargins.left);
72907
- const rightMargin = inchesToPixels(pageStyles.pageMargins.right);
72908
- const contentWidth = pageWidth - leftMargin - rightMargin;
72909
- const imageWidth = size2.width + (attrs.distLeft || 0) + (attrs.distRight || 0);
72910
- const leftSpace = marginOffset.horizontal;
72911
- const rightSpace = contentWidth - leftSpace - imageWidth;
72912
- if (rightSpace < 0) {
72913
- style2 += "float: left;";
72914
- } else if (rightSpace > leftSpace) {
72915
- style2 += "float: left;";
72916
- } else {
72917
- style2 += "float: right;";
72918
- floatRight = true;
72919
- baseHorizontal = rightSpace;
72920
- }
72921
- } else {
72922
- style2 += "float: left;";
72923
- }
73072
+ const pageStylesData = getDataFromPageStyles({
73073
+ editor: this.editor,
73074
+ marginOffset,
73075
+ size: size2,
73076
+ attrs
73077
+ });
73078
+ style2 += pageStylesData.style;
73079
+ floatRight = pageStylesData.floatRight;
73080
+ baseHorizontal = pageStylesData.baseHorizontal;
72924
73081
  if (attrs.distTop) margin.top += attrs.distTop;
72925
73082
  if (attrs.distBottom) margin.bottom += attrs.distBottom;
72926
73083
  if (attrs.distLeft) margin.left += attrs.distLeft;
@@ -72957,6 +73114,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72957
73114
  }
72958
73115
  const hasAnchorData = Boolean(anchorData);
72959
73116
  const hasMarginOffsets = marginOffset?.horizontal != null || marginOffset?.top != null;
73117
+ if (hasAnchorData) {
73118
+ switch (anchorData.hRelativeFrom) {
73119
+ case "page":
73120
+ const pageStyles = this.editor?.converter?.pageStyles || this.editor?.options.parentEditor?.converter?.pageStyles;
73121
+ margin.left -= inchesToPixels(pageStyles?.pageMargins?.left) || 0;
73122
+ break;
73123
+ case "margin":
73124
+ if (anchorData.alignH === "center") {
73125
+ style2 += "position: absolute; left: 50%; transform: translateX(-50%);";
73126
+ }
73127
+ if (anchorData.alignH === "left" || anchorData.alignH === "right") {
73128
+ style2 += `position: absolute; ${anchorData.alignH}: 0;`;
73129
+ }
73130
+ break;
73131
+ }
73132
+ }
72960
73133
  if (hasAnchorData || hasMarginOffsets) {
72961
73134
  const relativeFromPageV = anchorData?.vRelativeFrom === "page";
72962
73135
  const maxMarginV = 500;
@@ -73105,6 +73278,37 @@ Please report this to https://github.com/markedjs/marked.`, e) {
73105
73278
  return [ImageRegistrationPlugin({ editor: this.editor }), ImagePositionPlugin({ editor: this.editor })];
73106
73279
  }
73107
73280
  });
73281
+ const getDataFromPageStyles = ({ editor, marginOffset, size: size2, attrs }) => {
73282
+ let style2 = "";
73283
+ let floatRight = false;
73284
+ let baseHorizontal = marginOffset?.horizontal || 0;
73285
+ const pageStyles = editor?.converter?.pageStyles || editor?.options.parentEditor?.converter?.pageStyles;
73286
+ if (pageStyles?.pageSize && pageStyles?.pageMargins && size2.width) {
73287
+ const pageWidth = inchesToPixels(pageStyles.pageSize.width);
73288
+ const leftMargin = inchesToPixels(pageStyles.pageMargins.left);
73289
+ const rightMargin = inchesToPixels(pageStyles.pageMargins.right);
73290
+ const contentWidth = pageWidth - leftMargin - rightMargin;
73291
+ const imageWidth = size2.width + (attrs.distLeft || 0) + (attrs.distRight || 0);
73292
+ const leftSpace = marginOffset.horizontal;
73293
+ const rightSpace = contentWidth - leftSpace - imageWidth;
73294
+ if (rightSpace < 0) {
73295
+ style2 += "float: left;";
73296
+ } else if (rightSpace > leftSpace) {
73297
+ style2 += "float: left;";
73298
+ } else {
73299
+ style2 += "float: right;";
73300
+ floatRight = true;
73301
+ baseHorizontal = rightSpace;
73302
+ }
73303
+ } else {
73304
+ style2 += "float: left;";
73305
+ }
73306
+ return {
73307
+ style: style2,
73308
+ floatRight,
73309
+ baseHorizontal
73310
+ };
73311
+ };
73108
73312
  const ACCEPT_IMAGE_TYPES = [".jpg", ".jpeg", ".png", "image/jpeg", "image/png"];
73109
73313
  const getFileOpener = () => {
73110
73314
  let fileInput = document.createElement("input");
@@ -75226,6 +75430,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75226
75430
  const { from: from2, to } = state2.selection;
75227
75431
  return commands2.acceptTrackedChangesBetween(from2, to);
75228
75432
  },
75433
+ acceptTrackedChangeFromToolbar: () => ({ state: state2, commands: commands2 }) => {
75434
+ const commentsPluginState = CommentsPluginKey.getState(state2);
75435
+ const activeThreadId = commentsPluginState?.activeThreadId;
75436
+ if (activeThreadId && commentsPluginState?.trackedChanges?.[activeThreadId]) {
75437
+ return commands2.acceptTrackedChangeById(activeThreadId);
75438
+ } else {
75439
+ return commands2.acceptTrackedChangeBySelection();
75440
+ }
75441
+ },
75229
75442
  acceptTrackedChangeById: (id) => ({ state: state2, tr, commands: commands2 }) => {
75230
75443
  const toResolve = getChangesByIdToResolve(state2, id) || [];
75231
75444
  return toResolve.map(({ from: from2, to }) => {
@@ -75254,6 +75467,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75254
75467
  const { from: from2, to } = state2.selection;
75255
75468
  return commands2.rejectTrackedChangesBetween(from2, to);
75256
75469
  },
75470
+ rejectTrackedChangeFromToolbar: () => ({ state: state2, commands: commands2 }) => {
75471
+ const commentsPluginState = CommentsPluginKey.getState(state2);
75472
+ const activeThreadId = commentsPluginState?.activeThreadId;
75473
+ if (activeThreadId && commentsPluginState?.trackedChanges?.[activeThreadId]) {
75474
+ return commands2.rejectTrackedChangeById(activeThreadId);
75475
+ } else {
75476
+ return commands2.rejectTrackedChangeOnSelection();
75477
+ }
75478
+ },
75257
75479
  rejectAllTrackedChanges: () => ({ state: state2, commands: commands2 }) => {
75258
75480
  const from2 = 0, to = state2.doc.content.size;
75259
75481
  return commands2.rejectTrackedChangesBetween(from2, to);
@@ -80547,7 +80769,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
80547
80769
  return oldState;
80548
80770
  }
80549
80771
  if (typeof document === "undefined" || editor.options.isHeadless) return oldState;
80550
- if (editor.options.documentMode === "viewing" || !editor.isEditable) {
80772
+ if (!editor.options.isHeaderOrFooter && (editor.options.documentMode === "viewing" || !editor.isEditable)) {
80551
80773
  return DecorationSet.empty;
80552
80774
  }
80553
80775
  const { selection } = newState;
@@ -93656,7 +93878,7 @@ ${style2}
93656
93878
  disabled: false,
93657
93879
  name: "acceptTrackedChangeBySelection",
93658
93880
  tooltip: toolbarTexts2.trackChangesAccept,
93659
- command: "acceptTrackedChangeBySelection",
93881
+ command: "acceptTrackedChangeFromToolbar",
93660
93882
  icon: toolbarIcons2.trackChangesAccept,
93661
93883
  group: "left",
93662
93884
  attributes: {
@@ -93668,7 +93890,7 @@ ${style2}
93668
93890
  disabled: false,
93669
93891
  name: "rejectTrackedChangeOnSelection",
93670
93892
  tooltip: toolbarTexts2.trackChangesReject,
93671
- command: "rejectTrackedChangeOnSelection",
93893
+ command: "rejectTrackedChangeFromToolbar",
93672
93894
  icon: toolbarIcons2.trackChangesReject,
93673
93895
  group: "left",
93674
93896
  attributes: {
@@ -96689,8 +96911,12 @@ ${style2}
96689
96911
  Node: Node$1,
96690
96912
  Attribute,
96691
96913
  Extension,
96914
+ Mark,
96915
+ //
96692
96916
  Plugin,
96693
- Mark
96917
+ PluginKey,
96918
+ Decoration,
96919
+ DecorationSet
96694
96920
  };
96695
96921
  const DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
96696
96922
  const PDF = "application/pdf";
@@ -113844,7 +114070,7 @@ ${style2}
113844
114070
  this.config.colors = shuffleArray(this.config.colors);
113845
114071
  this.userColorMap = /* @__PURE__ */ new Map();
113846
114072
  this.colorIndex = 0;
113847
- this.version = "0.24.0";
114073
+ this.version = "0.25.0";
113848
114074
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
113849
114075
  this.superdocId = config2.superdocId || v4();
113850
114076
  this.colors = this.config.colors;