@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
@@ -32315,8 +32315,7 @@ const bookmarkEndNodeHandlerEntity = {
32315
32315
  handlerName: "w:bookmarkEndTranslator",
32316
32316
  handler: handleBookmarkEndNode
32317
32317
  };
32318
- const ALTERNATE_CONTENT_NODE = "mc:AlternateContent";
32319
- const SUPPORTED_REQUIRES = /* @__PURE__ */ new Set([
32318
+ const SUPPORTED_ALTERNATE_CONTENT_REQUIRES = /* @__PURE__ */ new Set([
32320
32319
  "wps",
32321
32320
  "wp14",
32322
32321
  "w14",
@@ -32329,22 +32328,85 @@ const SUPPORTED_REQUIRES = /* @__PURE__ */ new Set([
32329
32328
  "w16sdtfl",
32330
32329
  "w16se"
32331
32330
  ]);
32331
+ const XML_NODE_NAME$1 = "mc:AlternateContent";
32332
+ const SD_NODE_NAME$1 = [];
32333
+ const validXmlAttributes$1 = [];
32334
+ function encode$1(params2) {
32335
+ const { nodeListHandler } = params2;
32336
+ const { node } = params2.extraParams;
32337
+ if (!node || !node.type) {
32338
+ return null;
32339
+ }
32340
+ const { branch, elements } = selectAlternateContentElements(node);
32341
+ if (!elements) {
32342
+ return null;
32343
+ }
32344
+ return nodeListHandler.handler({
32345
+ ...params2,
32346
+ nodes: elements,
32347
+ path: buildPath(params2.path, node, branch)
32348
+ });
32349
+ }
32350
+ function decode$1(params2) {
32351
+ const { node } = params2;
32352
+ const { drawingContent } = node.attrs;
32353
+ const drawing = {
32354
+ name: "w:drawing",
32355
+ elements: [...drawingContent ? [...drawingContent.elements || []] : []]
32356
+ };
32357
+ const choice = {
32358
+ name: "mc:Choice",
32359
+ attributes: { Requires: "wps" },
32360
+ elements: [drawing]
32361
+ };
32362
+ return {
32363
+ name: "mc:AlternateContent",
32364
+ elements: [choice]
32365
+ };
32366
+ }
32367
+ const config$1 = {
32368
+ xmlName: XML_NODE_NAME$1,
32369
+ sdNodeOrKeyName: SD_NODE_NAME$1,
32370
+ type: NodeTranslator.translatorTypes.NODE,
32371
+ encode: encode$1,
32372
+ decode: decode$1,
32373
+ attributes: validXmlAttributes$1
32374
+ };
32375
+ function selectAlternateContentElements(node) {
32376
+ if (!node?.elements?.length) {
32377
+ return { branch: null, elements: null };
32378
+ }
32379
+ const choices = node.elements.filter((el) => el?.name === "mc:Choice");
32380
+ const fallback = node.elements.find((el) => el?.name === "mc:Fallback");
32381
+ const supportedChoice = choices.find((choice) => {
32382
+ const requiresAttr = choice?.attributes?.Requires || choice?.attributes?.requires;
32383
+ if (!requiresAttr) return false;
32384
+ return requiresAttr.split(/\s+/).filter(Boolean).some((namespace2) => SUPPORTED_ALTERNATE_CONTENT_REQUIRES.has(namespace2));
32385
+ });
32386
+ const branch = supportedChoice || fallback || choices[0] || null;
32387
+ const selectedElements = branch?.elements;
32388
+ if (!selectedElements) {
32389
+ return { branch, elements: null };
32390
+ }
32391
+ return {
32392
+ branch,
32393
+ elements: carbonCopy(selectedElements)
32394
+ };
32395
+ }
32396
+ const translator$1 = NodeTranslator.from(config$1);
32397
+ function buildPath(existingPath = [], node, branch) {
32398
+ const path = [...existingPath];
32399
+ if (node) path.push(node);
32400
+ if (branch) path.push(branch);
32401
+ return path;
32402
+ }
32403
+ const ALTERNATE_CONTENT_NODE = "mc:AlternateContent";
32332
32404
  const skipHandlerResponse = { nodes: [], consumed: 0 };
32333
32405
  const isAlternateContentNode = (node) => node?.name === ALTERNATE_CONTENT_NODE;
32334
- const isSupportedChoice = (choice) => {
32335
- if (!choice?.attributes) return false;
32336
- const requires = choice.attributes.Requires || choice.attributes.requires;
32337
- if (!requires) return false;
32338
- return requires.split(/\s+/).filter(Boolean).some((namespace2) => SUPPORTED_REQUIRES.has(namespace2));
32339
- };
32340
32406
  const resolveAlternateContentElements = (alternateContent) => {
32341
- if (!alternateContent?.elements?.length) return null;
32342
- const choices = alternateContent.elements.filter((el) => el.name === "mc:Choice");
32343
- const fallback = alternateContent.elements.find((el) => el.name === "mc:Fallback");
32344
- const supportedChoice = choices.find(isSupportedChoice);
32345
- const selectedElements = supportedChoice?.elements || fallback?.elements || choices[0]?.elements;
32346
- if (!selectedElements) return null;
32347
- return carbonCopy(selectedElements);
32407
+ const { elements } = selectAlternateContentElements(alternateContent);
32408
+ if (!elements) return null;
32409
+ return elements;
32348
32410
  };
32349
32411
  const buildNodeWithoutAlternateContent = (node) => {
32350
32412
  const { elements } = node || {};
@@ -32376,16 +32438,20 @@ const handleAlternateChoice = (params2) => {
32376
32438
  }
32377
32439
  const [currentNode] = nodes;
32378
32440
  if (isAlternateContentNode(currentNode)) {
32379
- const resolvedElements = resolveAlternateContentElements(currentNode);
32380
- if (!resolvedElements) {
32381
- return skipHandlerResponse;
32382
- }
32383
- const result2 = nodeListHandler.handler({
32441
+ const nodeForTranslator = currentNode?.type ? currentNode : {
32442
+ ...currentNode,
32443
+ type: "element"
32444
+ };
32445
+ const translated = translator$1.encode({
32384
32446
  ...params2,
32385
- nodes: resolvedElements,
32386
- path: [...params2.path || [], currentNode]
32447
+ nodes: [nodeForTranslator],
32448
+ extraParams: { ...params2.extraParams || {}, node: nodeForTranslator }
32387
32449
  });
32388
- return { nodes: result2, consumed: 1 };
32450
+ if (!translated) {
32451
+ return skipHandlerResponse;
32452
+ }
32453
+ const nodesArray = Array.isArray(translated) ? translated : [translated];
32454
+ return { nodes: nodesArray, consumed: 1 };
32389
32455
  }
32390
32456
  const sanitizedNode = buildNodeWithoutAlternateContent(currentNode);
32391
32457
  if (!sanitizedNode) {
@@ -33683,55 +33749,6 @@ function translateShapeTextbox(params2) {
33683
33749
  };
33684
33750
  return textbox;
33685
33751
  }
33686
- const XML_NODE_NAME$1 = "mc:AlternateContent";
33687
- const SD_NODE_NAME$1 = [];
33688
- const validXmlAttributes$1 = [];
33689
- function encode$1(params2) {
33690
- const { nodeListHandler } = params2;
33691
- const { node } = params2.extraParams;
33692
- if (!node || !node.type) {
33693
- return null;
33694
- }
33695
- const allowedNamespaces = ["wps", "wp14", "w14", "w15"];
33696
- const wpsNode = node.elements.find(
33697
- (el) => el.name === "mc:Choice" && allowedNamespaces.includes(el.attributes["Requires"])
33698
- );
33699
- if (!wpsNode) {
33700
- return null;
33701
- }
33702
- const contents = wpsNode.elements;
33703
- return nodeListHandler.handler({
33704
- ...params2,
33705
- nodes: contents,
33706
- path: [...params2.path || [], wpsNode]
33707
- });
33708
- }
33709
- function decode$1(params2) {
33710
- const { node } = params2;
33711
- const { drawingContent } = node.attrs;
33712
- const drawing = {
33713
- name: "w:drawing",
33714
- elements: [...drawingContent ? [...drawingContent.elements || []] : []]
33715
- };
33716
- const choice = {
33717
- name: "mc:Choice",
33718
- attributes: { Requires: "wps" },
33719
- elements: [drawing]
33720
- };
33721
- return {
33722
- name: "mc:AlternateContent",
33723
- elements: [choice]
33724
- };
33725
- }
33726
- const config$1 = {
33727
- xmlName: XML_NODE_NAME$1,
33728
- sdNodeOrKeyName: SD_NODE_NAME$1,
33729
- type: NodeTranslator.translatorTypes.NODE,
33730
- encode: encode$1,
33731
- decode: decode$1,
33732
- attributes: validXmlAttributes$1
33733
- };
33734
- const translator$1 = NodeTranslator.from(config$1);
33735
33752
  function translateContentBlock(params2) {
33736
33753
  const { node } = params2;
33737
33754
  const { vmlAttributes, horizontalRule } = node.attrs;
@@ -35124,7 +35141,7 @@ const _SuperConverter = class _SuperConverter2 {
35124
35141
  static getStoredSuperdocVersion(docx) {
35125
35142
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
35126
35143
  }
35127
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.24.0") {
35144
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.25.0") {
35128
35145
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
35129
35146
  }
35130
35147
  /**
@@ -38335,7 +38352,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
38335
38352
  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);
38336
38353
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
38337
38354
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
38338
- 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;
38355
+ 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;
38339
38356
  var GOOD_LEAF_SIZE = 200;
38340
38357
  var RopeSequence = function RopeSequence2() {
38341
38358
  };
@@ -52550,7 +52567,9 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
52550
52567
  isHeaderFooterChanged: false,
52551
52568
  isCustomXmlChanged: false,
52552
52569
  focusTarget: null,
52553
- permissionResolver: null
52570
+ permissionResolver: null,
52571
+ // header/footer editors may have parent(main) editor set
52572
+ parentEditor: null
52554
52573
  });
52555
52574
  __privateMethod$1(this, _Editor_instances, initContainerElement_fn).call(this, options);
52556
52575
  __privateMethod$1(this, _Editor_instances, checkHeadless_fn).call(this, options);
@@ -53312,7 +53331,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
53312
53331
  * @returns {Object | void} Migration results
53313
53332
  */
53314
53333
  processCollaborationMigrations() {
53315
- console.debug("[checkVersionMigrations] Current editor version", "0.24.0");
53334
+ console.debug("[checkVersionMigrations] Current editor version", "0.25.0");
53316
53335
  if (!this.options.ydoc) return;
53317
53336
  const metaMap = this.options.ydoc.getMap("meta");
53318
53337
  let docVersion = metaMap.get("version");
@@ -53518,9 +53537,6 @@ init_fn = function() {
53518
53537
  this.emit("beforeCreate", { editor: this });
53519
53538
  this.on("contentError", this.options.onContentError);
53520
53539
  this.mount(this.options.element);
53521
- if (!this.options.isHeadless) {
53522
- __privateMethod$1(this, _Editor_instances, checkFonts_fn).call(this);
53523
- }
53524
53540
  this.on("create", this.options.onCreate);
53525
53541
  this.on("update", this.options.onUpdate);
53526
53542
  this.on("selectionUpdate", this.options.onSelectionUpdate);
@@ -53542,8 +53558,12 @@ init_fn = function() {
53542
53558
  if (!this.options.isHeadless) {
53543
53559
  this.initializeCollaborationData();
53544
53560
  this.initDefaultStyles();
53561
+ __privateMethod$1(this, _Editor_instances, checkFonts_fn).call(this);
53545
53562
  }
53546
- if (!this.options.ydoc || this.options.markdown || this.options.html) {
53563
+ const shouldMigrateListsOnInit = Boolean(
53564
+ this.options.markdown || this.options.html || this.options.loadFromSchema || this.options.jsonOverride || this.options.mode === "html" || this.options.mode === "text"
53565
+ );
53566
+ if (shouldMigrateListsOnInit) {
53547
53567
  this.migrateListsToV2();
53548
53568
  }
53549
53569
  this.setDocumentMode(this.options.documentMode);
@@ -53684,52 +53704,18 @@ checkFonts_fn = async function() {
53684
53704
  if (this.options.isHeadless) {
53685
53705
  return;
53686
53706
  }
53687
- const fontsUsedInDocument = this.converter.getDocumentFonts();
53688
- if (!("queryLocalFonts" in window)) {
53689
- console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
53690
- const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
53691
- this.emit("fonts-resolved", {
53692
- documentFonts: fontsUsedInDocument,
53693
- unsupportedFonts
53694
- });
53695
- return;
53696
- }
53697
- const localFontAccess = await navigator.permissions.query({ name: "local-fonts" });
53698
- if (localFontAccess.state === "denied") {
53699
- console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
53700
- const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
53701
- this.emit("fonts-resolved", {
53702
- documentFonts: fontsUsedInDocument,
53703
- unsupportedFonts
53704
- });
53705
- return;
53706
- }
53707
53707
  try {
53708
- const localFonts = await window.queryLocalFonts();
53709
- const uniqueLocalFonts = [...new Set(localFonts.map((font) => font.family))];
53710
- const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithLocalFonts_fn).call(this, fontsUsedInDocument, uniqueLocalFonts);
53708
+ const fontsUsedInDocument = this.converter.getDocumentFonts();
53709
+ const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFonts_fn).call(this, fontsUsedInDocument);
53711
53710
  this.emit("fonts-resolved", {
53712
53711
  documentFonts: fontsUsedInDocument,
53713
53712
  unsupportedFonts
53714
53713
  });
53715
53714
  } catch {
53716
- console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
53717
- const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
53718
- this.emit("fonts-resolved", {
53719
- documentFonts: fontsUsedInDocument,
53720
- unsupportedFonts
53721
- });
53715
+ console.warn("[SuperDoc] Could not determine document fonts and unsupported fonts");
53722
53716
  }
53723
53717
  };
53724
- determineUnsupportedFontsWithLocalFonts_fn = function(fonts, localFonts) {
53725
- const unsupportedFonts = fonts.filter((font) => {
53726
- const isLocalFont = localFonts.includes(font);
53727
- const isFontImported = this.fontsImported.includes(font);
53728
- return !isLocalFont && !isFontImported;
53729
- });
53730
- return unsupportedFonts;
53731
- };
53732
- determineUnsupportedFontsWithCanvas_fn = function(fonts) {
53718
+ determineUnsupportedFonts_fn = function(fonts) {
53733
53719
  const unsupportedFonts = fonts.filter((font) => {
53734
53720
  const canRender = canRenderFont(font);
53735
53721
  const isFontImported = this.fontsImported.includes(font);
@@ -53817,6 +53803,9 @@ onCollaborationReady_fn = function({ editor, ydoc }) {
53817
53803
  if (this.options.collaborationIsReady) return;
53818
53804
  console.debug("🔗 [super-editor] Collaboration ready");
53819
53805
  __privateMethod$1(this, _Editor_instances, validateDocumentInit_fn).call(this);
53806
+ if (this.options.ydoc) {
53807
+ this.migrateListsToV2();
53808
+ }
53820
53809
  this.options.onCollaborationReady({ editor, ydoc });
53821
53810
  this.options.collaborationIsReady = true;
53822
53811
  this.options.initialState = this.state;
@@ -55762,10 +55751,27 @@ function getStructuredContentBlockTags(state2) {
55762
55751
  const result = findChildren$5(state2.doc, (node) => node.type.name === "structuredContentBlock");
55763
55752
  return result;
55764
55753
  }
55754
+ function getStructuredContentTablesById(id, state2) {
55755
+ if (!id || !state2) return [];
55756
+ const blocks = getStructuredContentTagsById(id, state2).filter(
55757
+ ({ node }) => node.type.name === "structuredContentBlock"
55758
+ );
55759
+ if (!blocks.length) return [];
55760
+ const { pos: blockPos, node: blockNode } = blocks[0];
55761
+ const tablesInBlock = [];
55762
+ blockNode.descendants((child, relPos) => {
55763
+ if (child.type.name === "table") {
55764
+ const absPos = blockPos + 1 + relPos;
55765
+ tablesInBlock.push({ node: child, pos: absPos });
55766
+ }
55767
+ });
55768
+ return tablesInBlock;
55769
+ }
55765
55770
  const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
55766
55771
  __proto__: null,
55767
55772
  getStructuredContentBlockTags,
55768
55773
  getStructuredContentInlineTags,
55774
+ getStructuredContentTablesById,
55769
55775
  getStructuredContentTags,
55770
55776
  getStructuredContentTagsById
55771
55777
  }, Symbol.toStringTag, { value: "Module" }));
@@ -55962,6 +55968,36 @@ const StructuredContentCommands = Extension.create({
55962
55968
  tr.replaceWith(posFrom, posTo, content);
55963
55969
  }
55964
55970
  return true;
55971
+ },
55972
+ /**
55973
+ * Append multiple rows to the end of a table inside a structured content block.
55974
+ * Each inner array represents the cell values for one new row.
55975
+ * @category Command
55976
+ * @param {StructuredContentTableAppendRowsOptions} options - Append configuration
55977
+ * @example
55978
+ * editor.commands.appendRowsToStructuredContentTable({
55979
+ * id: 'block-123',
55980
+ * tableIndex: 0,
55981
+ * rows: [['A', 'B'], ['C', 'D']],
55982
+ * copyRowStyle: true,
55983
+ * });
55984
+ */
55985
+ appendRowsToStructuredContentTable: ({ id, tableIndex = 0, rows = [], copyRowStyle = false }) => ({ state: state2, commands: commands2, dispatch }) => {
55986
+ const normalized = normalizeRowsInput(rows);
55987
+ if (!normalized.length) return true;
55988
+ const tables = getStructuredContentTablesById(id, state2);
55989
+ if (!tables.length || tableIndex < 0 || tableIndex >= tables.length) return true;
55990
+ const { node: tableNode, pos: tablePos } = tables[tableIndex];
55991
+ if (dispatch) {
55992
+ return commands2.appendRowsWithContent({ tablePos, tableNode, valueRows: normalized, copyRowStyle });
55993
+ }
55994
+ return commands2.appendRowsWithContent({
55995
+ tablePos,
55996
+ tableNode,
55997
+ valueRows: normalized,
55998
+ copyRowStyle,
55999
+ dispatch: false
56000
+ });
55965
56001
  }
55966
56002
  };
55967
56003
  },
@@ -55971,6 +56007,15 @@ const StructuredContentCommands = Extension.create({
55971
56007
  };
55972
56008
  }
55973
56009
  });
56010
+ const normalizeRowsInput = (rowsOrValues) => {
56011
+ if (!Array.isArray(rowsOrValues) || !rowsOrValues.length) {
56012
+ return [];
56013
+ }
56014
+ if (Array.isArray(rowsOrValues[0])) {
56015
+ return rowsOrValues;
56016
+ }
56017
+ return [rowsOrValues];
56018
+ };
55974
56019
  class DocumentSectionView {
55975
56020
  constructor(node, getPos, decorations, editor) {
55976
56021
  __privateAdd$1(this, _DocumentSectionView_instances);
@@ -61723,6 +61768,107 @@ function cellWrapping($pos) {
61723
61768
  }
61724
61769
  return null;
61725
61770
  }
61771
+ function resolveTable(tr, tablePos, tableNode) {
61772
+ if (tableNode && tableNode.type && tableNode.type.name === "table") {
61773
+ return tableNode;
61774
+ }
61775
+ if (typeof tablePos === "number") {
61776
+ const current = tr.doc.nodeAt(tablePos);
61777
+ if (current && current.type.name === "table") {
61778
+ return current;
61779
+ }
61780
+ }
61781
+ return null;
61782
+ }
61783
+ function pickTemplateRowForAppend(tableNode, schema) {
61784
+ const RowType = schema.nodes.tableRow;
61785
+ const rows = [];
61786
+ tableNode.descendants((child) => {
61787
+ if (child.type === RowType) rows.push(child);
61788
+ });
61789
+ if (!rows.length) return null;
61790
+ for (let i = rows.length - 1; i >= 0; i--) {
61791
+ const r2 = rows[i];
61792
+ const hasBodyCell = r2.content?.content?.some((c2) => c2.type.name === "tableCell");
61793
+ if (hasBodyCell) return r2;
61794
+ }
61795
+ return rows[rows.length - 1];
61796
+ }
61797
+ function extractRowTemplateFormatting(cellNode, schema) {
61798
+ const ParagraphType = schema.nodes.paragraph;
61799
+ let blockType = ParagraphType;
61800
+ let blockAttrs = null;
61801
+ let textMarks = [];
61802
+ const blocks = cellNode?.content?.content || [];
61803
+ for (const block of blocks) {
61804
+ const isParagraphish = block.type === ParagraphType || block.type.name === "heading";
61805
+ if (isParagraphish) {
61806
+ blockType = block.type || ParagraphType;
61807
+ blockAttrs = block.attrs || null;
61808
+ }
61809
+ let foundText = null;
61810
+ block.descendants?.((n) => {
61811
+ if (!foundText && n.isText) foundText = n;
61812
+ });
61813
+ if (foundText) {
61814
+ textMarks = foundText.marks ? Array.from(foundText.marks) : [];
61815
+ break;
61816
+ }
61817
+ }
61818
+ if (!blockType || !blockType.validContent) blockType = ParagraphType;
61819
+ return { blockType, blockAttrs, textMarks };
61820
+ }
61821
+ function buildFormattedCellBlock(schema, value, { blockType, blockAttrs, textMarks }, copyRowStyle = false) {
61822
+ const text = typeof value === "string" ? value : value == null ? "" : String(value);
61823
+ const marks = copyRowStyle ? textMarks || [] : [];
61824
+ const textNode = schema.text(text, marks);
61825
+ const type2 = blockType || schema.nodes.paragraph;
61826
+ return type2.createAndFill(blockAttrs || null, textNode);
61827
+ }
61828
+ function buildRowFromTemplateRow({ schema, tableNode, templateRow, values, copyRowStyle = false }) {
61829
+ const RowType = schema.nodes.tableRow;
61830
+ const CellType = schema.nodes.tableCell;
61831
+ const HeaderType = schema.nodes.tableHeader;
61832
+ const map22 = TableMap.get(tableNode);
61833
+ const totalColumns = map22.width;
61834
+ const byColumns = Array.isArray(values) && values.length === totalColumns;
61835
+ const newCells = [];
61836
+ let columnCursor = 0;
61837
+ templateRow.content.content.forEach((cellNode, cellIndex) => {
61838
+ const isHeaderCell = cellNode.type === HeaderType;
61839
+ const targetCellType = isHeaderCell ? CellType : cellNode.type;
61840
+ const attrs = { ...cellNode.attrs };
61841
+ const formatting = extractRowTemplateFormatting(cellNode, schema);
61842
+ let cellValue = "";
61843
+ if (byColumns) {
61844
+ const span = Math.max(1, attrs.colspan || 1);
61845
+ cellValue = values[columnCursor] ?? "";
61846
+ columnCursor += span;
61847
+ } else {
61848
+ cellValue = Array.isArray(values) ? values[cellIndex] ?? "" : "";
61849
+ }
61850
+ const content = buildFormattedCellBlock(schema, cellValue, formatting, copyRowStyle);
61851
+ const newCell = targetCellType.createAndFill(attrs, content);
61852
+ if (newCell) newCells.push(newCell);
61853
+ });
61854
+ return RowType.createAndFill(null, newCells);
61855
+ }
61856
+ function insertRowsAtTableEnd({ tr, tablePos, tableNode, rows }) {
61857
+ if (!rows || !rows.length) return;
61858
+ const RowTypeName = "tableRow";
61859
+ let lastRowRelPos = 0;
61860
+ let lastRowNode = null;
61861
+ tableNode.descendants((child, relPos) => {
61862
+ if (child.type.name === RowTypeName) {
61863
+ lastRowRelPos = relPos;
61864
+ lastRowNode = child;
61865
+ }
61866
+ });
61867
+ if (!lastRowNode) return;
61868
+ const lastRowAbsEnd = tablePos + 1 + lastRowRelPos + lastRowNode.nodeSize;
61869
+ const frag = Fragment.fromArray(rows);
61870
+ tr.insert(lastRowAbsEnd, frag);
61871
+ }
61726
61872
  const Table = Node$1.create({
61727
61873
  name: "table",
61728
61874
  content: "tableRow+",
@@ -61882,6 +62028,47 @@ const Table = Node$1.create({
61882
62028
  },
61883
62029
  addCommands() {
61884
62030
  return {
62031
+ /**
62032
+ * Append multiple rows to the end of a table in a single transaction.
62033
+ * @category Command
62034
+ * @param {appendRowsWithContentOptions} options - Append configuration
62035
+ * @example
62036
+ * editor.commands.appendRowsWithContent({ tablePos, valueRows: [['A','B'], ['C','D']], copyRowStyle: true })
62037
+ */
62038
+ appendRowsWithContent: ({ tablePos, tableNode, valueRows = [], copyRowStyle = false }) => ({ editor, chain }) => {
62039
+ if (typeof tablePos !== "number" && !tableNode || !Array.isArray(valueRows) || !valueRows.length) {
62040
+ return false;
62041
+ }
62042
+ return chain().command(({ tr, dispatch }) => {
62043
+ const workingTable = resolveTable(tr, tablePos, tableNode);
62044
+ if (!workingTable) return false;
62045
+ const templateRow = pickTemplateRowForAppend(workingTable, editor.schema);
62046
+ if (!templateRow) return false;
62047
+ const newRows = valueRows.map(
62048
+ (vals) => buildRowFromTemplateRow({
62049
+ schema: editor.schema,
62050
+ tableNode: workingTable,
62051
+ templateRow,
62052
+ values: vals,
62053
+ copyRowStyle
62054
+ })
62055
+ ).filter(Boolean);
62056
+ if (!newRows.length) return false;
62057
+ let resolvedTablePos = tablePos;
62058
+ if (typeof resolvedTablePos !== "number" && workingTable) {
62059
+ const tables = editor.getNodesOfType("table");
62060
+ const match = workingTable ? tables.find((t) => t.node.eq(workingTable)) : tables[0];
62061
+ resolvedTablePos = match?.pos ?? null;
62062
+ }
62063
+ if (typeof resolvedTablePos !== "number") {
62064
+ return false;
62065
+ }
62066
+ if (dispatch) {
62067
+ insertRowsAtTableEnd({ tr, tablePos, tableNode: workingTable, rows: newRows });
62068
+ }
62069
+ return true;
62070
+ }).run();
62071
+ },
61885
62072
  /**
61886
62073
  * Insert a new table into the document
61887
62074
  * @category Command
@@ -64788,58 +64975,6 @@ const registerImages = async (foundImages, editor, view) => {
64788
64975
  }
64789
64976
  });
64790
64977
  };
64791
- const normalizeWrap = (attrs = {}) => {
64792
- const wrap2 = attrs.wrap;
64793
- if (wrap2?.type && wrap2.type !== "Inline") {
64794
- return {
64795
- type: wrap2.type,
64796
- attrs: wrap2.attrs ?? {}
64797
- };
64798
- }
64799
- if (wrap2?.type === "Inline" && Object.keys(wrap2.attrs ?? {}).length) {
64800
- return {
64801
- type: "Inline",
64802
- attrs: wrap2.attrs
64803
- };
64804
- }
64805
- if (!wrap2 && attrs.wrapText) {
64806
- return {
64807
- type: "Square",
64808
- attrs: {
64809
- wrapText: attrs.wrapText
64810
- }
64811
- };
64812
- }
64813
- if (!wrap2 && attrs.wrapTopAndBottom) {
64814
- return {
64815
- type: "TopAndBottom",
64816
- attrs: {}
64817
- };
64818
- }
64819
- if (wrap2?.type === "Inline") {
64820
- return {
64821
- type: "Inline",
64822
- attrs: wrap2.attrs ?? {}
64823
- };
64824
- }
64825
- return {
64826
- type: "Inline",
64827
- attrs: {}
64828
- };
64829
- };
64830
- const normalizeMarginOffset = (marginOffset = {}) => {
64831
- const { left: left2, horizontal, ...rest } = marginOffset;
64832
- return {
64833
- ...rest,
64834
- horizontal: horizontal ?? left2
64835
- };
64836
- };
64837
- const getNormalizedImageAttrs = (attrs = {}) => {
64838
- return {
64839
- wrap: normalizeWrap(attrs),
64840
- marginOffset: normalizeMarginOffset(attrs.marginOffset ?? {})
64841
- };
64842
- };
64843
64978
  const ImagePositionPluginKey = new PluginKey("ImagePosition");
64844
64979
  const ImagePositionPlugin = ({ editor }) => {
64845
64980
  const { view } = editor;
@@ -64852,8 +64987,9 @@ const ImagePositionPlugin = ({ editor }) => {
64852
64987
  return DecorationSet.empty;
64853
64988
  },
64854
64989
  apply(tr, oldDecorationSet, oldState, newState) {
64855
- if (!tr.docChanged) return oldDecorationSet;
64990
+ if (!tr.docChanged && !shouldUpdate) return oldDecorationSet;
64856
64991
  const decorations = getImagePositionDecorations(newState, view);
64992
+ shouldUpdate = false;
64857
64993
  return DecorationSet.create(newState.doc, decorations);
64858
64994
  }
64859
64995
  },
@@ -64862,7 +64998,6 @@ const ImagePositionPlugin = ({ editor }) => {
64862
64998
  update: (view2, lastState) => {
64863
64999
  const pagination = PaginationPluginKey.getState(lastState);
64864
65000
  if (shouldUpdate) {
64865
- shouldUpdate = false;
64866
65001
  const decorations = getImagePositionDecorations(lastState, view2);
64867
65002
  const updateTransaction = view2.state.tr.setMeta(ImagePositionPluginKey, { decorations });
64868
65003
  view2.dispatch(updateTransaction);
@@ -64888,41 +65023,35 @@ const getImagePositionDecorations = (state2, view) => {
64888
65023
  let className = "";
64889
65024
  const { vRelativeFrom, alignH } = node.attrs.anchorData;
64890
65025
  const { size: size2, padding } = node.attrs;
64891
- const { marginOffset } = getNormalizedImageAttrs(node.attrs);
64892
65026
  const pageBreak = findPreviousDomNodeWithClass(view, pos, "pagination-break-wrapper");
64893
- if (pageBreak) {
64894
- switch (alignH) {
64895
- case "left":
64896
- style2 += "float: left; left: 0; margin-left: 0; ";
64897
- break;
64898
- case "right":
64899
- style2 += "float: right; right: 0; margin-right: 0; ";
64900
- break;
64901
- case "center":
64902
- style2 += "display: block; margin-left: auto; margin-right: auto; ";
64903
- break;
65027
+ if (pageBreak && vRelativeFrom === "margin" && alignH) {
65028
+ const topPos = pageBreak?.offsetTop + pageBreak?.offsetHeight;
65029
+ let horizontalAlignment = `${alignH}: 0;`;
65030
+ if (alignH === "center") horizontalAlignment = "left: 50%; transform: translateX(-50%);";
65031
+ style2 += vRelativeFrom === "margin" ? `position: absolute; top: ${topPos}px; ${horizontalAlignment}` : "";
65032
+ const nextPos = view.posAtDOM(pageBreak, 1);
65033
+ if (nextPos < 0) {
65034
+ const $pos = view.state.doc.resolve(pos);
65035
+ decorations.push(
65036
+ Decoration.node(pos - 1, pos + $pos.parent.nodeSize - 1, {
65037
+ style: `height: ${size2.height + parseInt(padding.top) + parseInt(padding.bottom)}px`
65038
+ })
65039
+ );
64904
65040
  }
64905
- const topPos = marginOffset.top !== void 0 ? marginOffset.top : pageBreak?.offsetTop + pageBreak?.offsetHeight;
64906
- style2 += vRelativeFrom === "margin" ? `position: absolute; top: ${topPos}px; ` : "";
64907
- if (vRelativeFrom === "margin") {
64908
- const nextPos = view.posAtDOM(pageBreak, 1);
64909
- if (nextPos < 0) {
64910
- const $pos = view.state.doc.resolve(pos);
64911
- decorations.push(
64912
- Decoration.node(pos - 1, pos + $pos.parent.nodeSize - 1, {
64913
- style: `height: ${size2.height + parseInt(padding.top) + parseInt(padding.bottom)}px`
64914
- })
64915
- );
64916
- }
64917
- const imageBlock = document.createElement("div");
64918
- imageBlock.className = "anchor-image-placeholder";
64919
- imageBlock.style.float = alignH;
64920
- imageBlock.style.width = size2.width + parseInt(padding[alignH]) + "px";
64921
- imageBlock.style.height = size2.height + parseInt(padding.top) + parseInt(padding.bottom) + "px";
64922
- decorations.push(Decoration.widget(nextPos, imageBlock, { key: "stable-key" }));
65041
+ const imageBlock = document.createElement("div");
65042
+ imageBlock.className = "anchor-image-placeholder";
65043
+ imageBlock.style.float = alignH === "left" || alignH === "right" ? alignH : "none";
65044
+ let paddingHorizontal;
65045
+ if (alignH === "center") {
65046
+ paddingHorizontal = (parseInt(padding.left) || 0) + (parseInt(padding.right) || 0);
65047
+ } else {
65048
+ paddingHorizontal = parseInt(padding[alignH]) || 0;
64923
65049
  }
65050
+ imageBlock.style.width = size2.width + paddingHorizontal + "px";
65051
+ imageBlock.style.height = size2.height + parseInt(padding.top) + parseInt(padding.bottom) + "px";
65052
+ decorations.push(Decoration.widget(nextPos, imageBlock, { key: "stable-key" }));
65053
+ decorations.push(Decoration.inline(pos, pos + node.nodeSize, { style: style2, class: className }));
64924
65054
  }
64925
- decorations.push(Decoration.inline(pos, pos + node.nodeSize, { style: style2, class: className }));
64926
65055
  }
64927
65056
  });
64928
65057
  return decorations;
@@ -64947,6 +65076,58 @@ const findPreviousDomNodeWithClass = (view, pos, className) => {
64947
65076
  }
64948
65077
  return null;
64949
65078
  };
65079
+ const normalizeWrap = (attrs = {}) => {
65080
+ const wrap2 = attrs.wrap;
65081
+ if (wrap2?.type && wrap2.type !== "Inline") {
65082
+ return {
65083
+ type: wrap2.type,
65084
+ attrs: wrap2.attrs ?? {}
65085
+ };
65086
+ }
65087
+ if (wrap2?.type === "Inline" && Object.keys(wrap2.attrs ?? {}).length) {
65088
+ return {
65089
+ type: "Inline",
65090
+ attrs: wrap2.attrs
65091
+ };
65092
+ }
65093
+ if (!wrap2 && attrs.wrapText) {
65094
+ return {
65095
+ type: "Square",
65096
+ attrs: {
65097
+ wrapText: attrs.wrapText
65098
+ }
65099
+ };
65100
+ }
65101
+ if (!wrap2 && attrs.wrapTopAndBottom) {
65102
+ return {
65103
+ type: "TopAndBottom",
65104
+ attrs: {}
65105
+ };
65106
+ }
65107
+ if (wrap2?.type === "Inline") {
65108
+ return {
65109
+ type: "Inline",
65110
+ attrs: wrap2.attrs ?? {}
65111
+ };
65112
+ }
65113
+ return {
65114
+ type: "Inline",
65115
+ attrs: {}
65116
+ };
65117
+ };
65118
+ const normalizeMarginOffset = (marginOffset = {}) => {
65119
+ const { left: left2, horizontal, ...rest } = marginOffset;
65120
+ return {
65121
+ ...rest,
65122
+ horizontal: horizontal ?? left2
65123
+ };
65124
+ };
65125
+ const getNormalizedImageAttrs = (attrs = {}) => {
65126
+ return {
65127
+ wrap: normalizeWrap(attrs),
65128
+ marginOffset: normalizeMarginOffset(attrs.marginOffset ?? {})
65129
+ };
65130
+ };
64950
65131
  const getRotationMargins = (w2, h2, angleDegrees) => {
64951
65132
  const rad = angleDegrees * (Math.PI / 180);
64952
65133
  const cos = Math.abs(Math.cos(rad));
@@ -65155,27 +65336,15 @@ const Image = Node$1.create({
65155
65336
  style2 += "float: right;";
65156
65337
  floatRight = true;
65157
65338
  } else if (["largest", "bothSides"].includes(attrs.wrapText)) {
65158
- const pageStyles2 = this.editor?.converter?.pageStyles;
65159
- if (pageStyles2?.pageSize && pageStyles2?.pageMargins && size2.width) {
65160
- const pageWidth = inchesToPixels(pageStyles2.pageSize.width);
65161
- const leftMargin = inchesToPixels(pageStyles2.pageMargins.left);
65162
- const rightMargin = inchesToPixels(pageStyles2.pageMargins.right);
65163
- const contentWidth = pageWidth - leftMargin - rightMargin;
65164
- const imageWidth = size2.width + (attrs.distLeft || 0) + (attrs.distRight || 0);
65165
- const leftSpace = marginOffset.horizontal;
65166
- const rightSpace = contentWidth - leftSpace - imageWidth;
65167
- if (rightSpace < 0) {
65168
- style2 += "float: left;";
65169
- } else if (rightSpace > leftSpace) {
65170
- style2 += "float: left;";
65171
- } else {
65172
- style2 += "float: right;";
65173
- floatRight = true;
65174
- baseHorizontal = rightSpace;
65175
- }
65176
- } else {
65177
- style2 += "float: left;";
65178
- }
65339
+ const pageStylesData2 = getDataFromPageStyles({
65340
+ editor: this.editor,
65341
+ marginOffset,
65342
+ size: size2,
65343
+ attrs
65344
+ });
65345
+ style2 += pageStylesData2.style;
65346
+ floatRight = pageStylesData2.floatRight;
65347
+ baseHorizontal = pageStylesData2.baseHorizontal;
65179
65348
  }
65180
65349
  if (attrs.distTop) margin.top += attrs.distTop;
65181
65350
  if (attrs.distBottom) margin.bottom += attrs.distBottom;
@@ -65185,27 +65354,15 @@ const Image = Node$1.create({
65185
65354
  case "Through":
65186
65355
  case "Tight":
65187
65356
  style2 += "clear: both;";
65188
- const pageStyles = this.editor?.converter?.pageStyles;
65189
- if (pageStyles?.pageSize && pageStyles?.pageMargins && size2.width) {
65190
- const pageWidth = inchesToPixels(pageStyles.pageSize.width);
65191
- const leftMargin = inchesToPixels(pageStyles.pageMargins.left);
65192
- const rightMargin = inchesToPixels(pageStyles.pageMargins.right);
65193
- const contentWidth = pageWidth - leftMargin - rightMargin;
65194
- const imageWidth = size2.width + (attrs.distLeft || 0) + (attrs.distRight || 0);
65195
- const leftSpace = marginOffset.horizontal;
65196
- const rightSpace = contentWidth - leftSpace - imageWidth;
65197
- if (rightSpace < 0) {
65198
- style2 += "float: left;";
65199
- } else if (rightSpace > leftSpace) {
65200
- style2 += "float: left;";
65201
- } else {
65202
- style2 += "float: right;";
65203
- floatRight = true;
65204
- baseHorizontal = rightSpace;
65205
- }
65206
- } else {
65207
- style2 += "float: left;";
65208
- }
65357
+ const pageStylesData = getDataFromPageStyles({
65358
+ editor: this.editor,
65359
+ marginOffset,
65360
+ size: size2,
65361
+ attrs
65362
+ });
65363
+ style2 += pageStylesData.style;
65364
+ floatRight = pageStylesData.floatRight;
65365
+ baseHorizontal = pageStylesData.baseHorizontal;
65209
65366
  if (attrs.distTop) margin.top += attrs.distTop;
65210
65367
  if (attrs.distBottom) margin.bottom += attrs.distBottom;
65211
65368
  if (attrs.distLeft) margin.left += attrs.distLeft;
@@ -65242,6 +65399,22 @@ const Image = Node$1.create({
65242
65399
  }
65243
65400
  const hasAnchorData = Boolean(anchorData);
65244
65401
  const hasMarginOffsets = marginOffset?.horizontal != null || marginOffset?.top != null;
65402
+ if (hasAnchorData) {
65403
+ switch (anchorData.hRelativeFrom) {
65404
+ case "page":
65405
+ const pageStyles = this.editor?.converter?.pageStyles || this.editor?.options.parentEditor?.converter?.pageStyles;
65406
+ margin.left -= inchesToPixels(pageStyles?.pageMargins?.left) || 0;
65407
+ break;
65408
+ case "margin":
65409
+ if (anchorData.alignH === "center") {
65410
+ style2 += "position: absolute; left: 50%; transform: translateX(-50%);";
65411
+ }
65412
+ if (anchorData.alignH === "left" || anchorData.alignH === "right") {
65413
+ style2 += `position: absolute; ${anchorData.alignH}: 0;`;
65414
+ }
65415
+ break;
65416
+ }
65417
+ }
65245
65418
  if (hasAnchorData || hasMarginOffsets) {
65246
65419
  const relativeFromPageV = anchorData?.vRelativeFrom === "page";
65247
65420
  const maxMarginV = 500;
@@ -65390,6 +65563,37 @@ const Image = Node$1.create({
65390
65563
  return [ImageRegistrationPlugin({ editor: this.editor }), ImagePositionPlugin({ editor: this.editor })];
65391
65564
  }
65392
65565
  });
65566
+ const getDataFromPageStyles = ({ editor, marginOffset, size: size2, attrs }) => {
65567
+ let style2 = "";
65568
+ let floatRight = false;
65569
+ let baseHorizontal = marginOffset?.horizontal || 0;
65570
+ const pageStyles = editor?.converter?.pageStyles || editor?.options.parentEditor?.converter?.pageStyles;
65571
+ if (pageStyles?.pageSize && pageStyles?.pageMargins && size2.width) {
65572
+ const pageWidth = inchesToPixels(pageStyles.pageSize.width);
65573
+ const leftMargin = inchesToPixels(pageStyles.pageMargins.left);
65574
+ const rightMargin = inchesToPixels(pageStyles.pageMargins.right);
65575
+ const contentWidth = pageWidth - leftMargin - rightMargin;
65576
+ const imageWidth = size2.width + (attrs.distLeft || 0) + (attrs.distRight || 0);
65577
+ const leftSpace = marginOffset.horizontal;
65578
+ const rightSpace = contentWidth - leftSpace - imageWidth;
65579
+ if (rightSpace < 0) {
65580
+ style2 += "float: left;";
65581
+ } else if (rightSpace > leftSpace) {
65582
+ style2 += "float: left;";
65583
+ } else {
65584
+ style2 += "float: right;";
65585
+ floatRight = true;
65586
+ baseHorizontal = rightSpace;
65587
+ }
65588
+ } else {
65589
+ style2 += "float: left;";
65590
+ }
65591
+ return {
65592
+ style: style2,
65593
+ floatRight,
65594
+ baseHorizontal
65595
+ };
65596
+ };
65393
65597
  const ACCEPT_IMAGE_TYPES = [".jpg", ".jpeg", ".png", "image/jpeg", "image/png"];
65394
65598
  const getFileOpener = () => {
65395
65599
  let fileInput = document.createElement("input");
@@ -67511,6 +67715,15 @@ const TrackChanges = Extension.create({
67511
67715
  const { from: from2, to } = state2.selection;
67512
67716
  return commands2.acceptTrackedChangesBetween(from2, to);
67513
67717
  },
67718
+ acceptTrackedChangeFromToolbar: () => ({ state: state2, commands: commands2 }) => {
67719
+ const commentsPluginState = CommentsPluginKey.getState(state2);
67720
+ const activeThreadId = commentsPluginState?.activeThreadId;
67721
+ if (activeThreadId && commentsPluginState?.trackedChanges?.[activeThreadId]) {
67722
+ return commands2.acceptTrackedChangeById(activeThreadId);
67723
+ } else {
67724
+ return commands2.acceptTrackedChangeBySelection();
67725
+ }
67726
+ },
67514
67727
  acceptTrackedChangeById: (id) => ({ state: state2, tr, commands: commands2 }) => {
67515
67728
  const toResolve = getChangesByIdToResolve(state2, id) || [];
67516
67729
  return toResolve.map(({ from: from2, to }) => {
@@ -67539,6 +67752,15 @@ const TrackChanges = Extension.create({
67539
67752
  const { from: from2, to } = state2.selection;
67540
67753
  return commands2.rejectTrackedChangesBetween(from2, to);
67541
67754
  },
67755
+ rejectTrackedChangeFromToolbar: () => ({ state: state2, commands: commands2 }) => {
67756
+ const commentsPluginState = CommentsPluginKey.getState(state2);
67757
+ const activeThreadId = commentsPluginState?.activeThreadId;
67758
+ if (activeThreadId && commentsPluginState?.trackedChanges?.[activeThreadId]) {
67759
+ return commands2.rejectTrackedChangeById(activeThreadId);
67760
+ } else {
67761
+ return commands2.rejectTrackedChangeOnSelection();
67762
+ }
67763
+ },
67542
67764
  rejectAllTrackedChanges: () => ({ state: state2, commands: commands2 }) => {
67543
67765
  const from2 = 0, to = state2.doc.content.size;
67544
67766
  return commands2.rejectTrackedChangesBetween(from2, to);
@@ -72832,7 +73054,7 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
72832
73054
  return oldState;
72833
73055
  }
72834
73056
  if (typeof document === "undefined" || editor.options.isHeadless) return oldState;
72835
- if (editor.options.documentMode === "viewing" || !editor.isEditable) {
73057
+ if (!editor.options.isHeaderOrFooter && (editor.options.documentMode === "viewing" || !editor.isEditable)) {
72836
73058
  return DecorationSet.empty;
72837
73059
  }
72838
73060
  const { selection } = newState;
@@ -85941,7 +86163,7 @@ const makeDefaultItems = ({
85941
86163
  disabled: false,
85942
86164
  name: "acceptTrackedChangeBySelection",
85943
86165
  tooltip: toolbarTexts2.trackChangesAccept,
85944
- command: "acceptTrackedChangeBySelection",
86166
+ command: "acceptTrackedChangeFromToolbar",
85945
86167
  icon: toolbarIcons2.trackChangesAccept,
85946
86168
  group: "left",
85947
86169
  attributes: {
@@ -85953,7 +86175,7 @@ const makeDefaultItems = ({
85953
86175
  disabled: false,
85954
86176
  name: "rejectTrackedChangeOnSelection",
85955
86177
  tooltip: toolbarTexts2.trackChangesReject,
85956
- command: "rejectTrackedChangeOnSelection",
86178
+ command: "rejectTrackedChangeFromToolbar",
85957
86179
  icon: toolbarIcons2.trackChangesReject,
85958
86180
  group: "left",
85959
86181
  attributes: {
@@ -88974,8 +89196,12 @@ const Extensions = {
88974
89196
  Node: Node$1,
88975
89197
  Attribute: Attribute2,
88976
89198
  Extension,
89199
+ Mark: Mark2,
89200
+ //
88977
89201
  Plugin,
88978
- Mark: Mark2
89202
+ PluginKey,
89203
+ Decoration,
89204
+ DecorationSet
88979
89205
  };
88980
89206
  export {
88981
89207
  AIWriter as A,