@harbour-enterprises/superdoc 1.3.0-next.3 → 1.3.0-next.4

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.
@@ -1,6 +1,6 @@
1
1
  import { d as defineComponent, h, T as Transition, p as process$1, w as watchEffect, c as computed, r as ref, f as onMounted, X as onUnmounted, E as createElementBlock, G as openBlock, K as createBaseVNode, M as createCommentVNode, I as createVNode, v as unref } from "./vue-BnBKJwCW.es.js";
2
- import { N as NBaseLoading, u as useSuperdocStore, s as storeToRefs, a as useSelection } from "./index-e6096-IC.es.js";
3
- import { C as derived, r as c, q as cB, aF as fadeInTransition, y as cM, I as warnOnce, J as useConfig, N as useTheme, aG as pxfy, P as createKey, Q as useThemeClass, aH as useCompitable, ai as _export_sfc } from "./index-M8MvGhiF.es.js";
2
+ import { N as NBaseLoading, u as useSuperdocStore, s as storeToRefs, a as useSelection } from "./index-CiR7cacp.es.js";
3
+ import { C as derived, r as c, q as cB, aF as fadeInTransition, y as cM, I as warnOnce, J as useConfig, N as useTheme, aG as pxfy, P as createKey, Q as useThemeClass, aH as useCompitable, ai as _export_sfc } from "./index-BgcNLeK9.es.js";
4
4
  function self(vars) {
5
5
  const {
6
6
  opacityDisabled,
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const vue = require("./vue-De9wkgLl.cjs");
4
- const superdoc = require("./index-HQW67fDU.cjs");
5
- const index = require("./index-D0lYfjMI.cjs");
4
+ const superdoc = require("./index-Dtd_PFUu.cjs");
5
+ const index = require("./index-Buh63pW6.cjs");
6
6
  function self(vars) {
7
7
  const {
8
8
  opacityDisabled,
@@ -25317,8 +25317,9 @@ function translateFieldAnnotation(params) {
25317
25317
  hash: attrs.hash
25318
25318
  };
25319
25319
  const annotationAttrsJson = JSON.stringify(annotationAttrs);
25320
+ const sanitizedDisplayLabel = attrs.displayLabel === "undefined" || attrs.displayLabel === void 0 ? "" : attrs.displayLabel;
25320
25321
  const sdtPrElements = [
25321
- { name: "w:alias", attributes: { "w:val": attrs.displayLabel } },
25322
+ { name: "w:alias", attributes: { "w:val": sanitizedDisplayLabel } },
25322
25323
  { name: "w:tag", attributes: { "w:val": annotationAttrsJson } },
25323
25324
  { name: "w:id", attributes: { "w:val": id } }
25324
25325
  ];
@@ -30937,7 +30938,7 @@ class SuperConverter {
30937
30938
  static getStoredSuperdocVersion(docx) {
30938
30939
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
30939
30940
  }
30940
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.3") {
30941
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.4") {
30941
30942
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
30942
30943
  }
30943
30944
  /**
@@ -25318,8 +25318,9 @@ function translateFieldAnnotation(params) {
25318
25318
  hash: attrs.hash
25319
25319
  };
25320
25320
  const annotationAttrsJson = JSON.stringify(annotationAttrs);
25321
+ const sanitizedDisplayLabel = attrs.displayLabel === "undefined" || attrs.displayLabel === void 0 ? "" : attrs.displayLabel;
25321
25322
  const sdtPrElements = [
25322
- { name: "w:alias", attributes: { "w:val": attrs.displayLabel } },
25323
+ { name: "w:alias", attributes: { "w:val": sanitizedDisplayLabel } },
25323
25324
  { name: "w:tag", attributes: { "w:val": annotationAttrsJson } },
25324
25325
  { name: "w:id", attributes: { "w:val": id } }
25325
25326
  ];
@@ -30938,7 +30939,7 @@ class SuperConverter {
30938
30939
  static getStoredSuperdocVersion(docx) {
30939
30940
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
30940
30941
  }
30941
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.3") {
30942
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.4") {
30942
30943
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
30943
30944
  }
30944
30945
  /**
@@ -1,6 +1,6 @@
1
1
  import { B as Buffer$2 } from "./jszip-B1fkPkPJ.es.js";
2
2
  import { t as twipsToInches, i as inchesToTwips, p as ptToTwips, l as linesToTwips, a as twipsToLines, b as pixelsToTwips, h as halfPointToPoints, c as twipsToPixels$2, d as convertSizeToCSS, e as inchesToPixels } from "./helpers-C8e9wR5l.es.js";
3
- import { g as generateDocxRandomId, T as TextSelection$1, o as objectIncludes, w as wrapTextsInRuns, D as DOMParser$1, c as createDocFromMarkdown, a as createDocFromHTML, b as chainableEditorState, d as convertMarkdownToHTML, f as findParentNode, e as findParentNodeClosestToPos, h as generateRandom32BitHex, i as generateRandomSigned32BitIntStrId, P as PluginKey, j as Plugin, M as Mapping, N as NodeSelection, k as Selection, l as Slice, m as DOMSerializer, F as Fragment, n as Mark$1, p as dropPoint, A as AllSelection, q as Schema$1, s as canSplit, t as resolveRunProperties, u as encodeMarksFromRPr, v as liftTarget, x as canJoin, y as joinPoint, z as replaceStep$1, R as ReplaceAroundStep$1, B as htmlHandler, C as ReplaceStep, E as getResolvedParagraphProperties, G as changeListLevel, H as isList$1, I as updateNumberingProperties, L as ListHelpers, J as inputRulesPlugin, K as TrackDeleteMarkName$1, O as TrackInsertMarkName$1, Q as TrackFormatMarkName$1, U as AddMarkStep, V as RemoveMarkStep, W as CommandService, S as SuperConverter, X as EditorState, Y as unflattenListsInHtml, Z as SelectionRange, _ as Transform, $ as createOoxmlResolver, a0 as translator, a1 as translator$1, a2 as resolveDocxFontFamily, a3 as _getReferencedTableStyles, a4 as decodeRPrFromMarks, a5 as calculateResolvedParagraphProperties, a6 as encodeCSSFromPPr, a7 as encodeCSSFromRPr, a8 as generateOrderedListIndex, a9 as docxNumberingHelpers, aa as InputRule, ab as insertNewRelationship, ac as kebabCase$1, ad as getUnderlineCssString } from "./SuperConverter-CVOKZex3.es.js";
3
+ import { g as generateDocxRandomId, T as TextSelection$1, o as objectIncludes, w as wrapTextsInRuns, D as DOMParser$1, c as createDocFromMarkdown, a as createDocFromHTML, b as chainableEditorState, d as convertMarkdownToHTML, f as findParentNode, e as findParentNodeClosestToPos, h as generateRandom32BitHex, i as generateRandomSigned32BitIntStrId, P as PluginKey, j as Plugin, M as Mapping, N as NodeSelection, k as Selection, l as Slice, m as DOMSerializer, F as Fragment, n as Mark$1, p as dropPoint, A as AllSelection, q as Schema$1, s as canSplit, t as resolveRunProperties, u as encodeMarksFromRPr, v as liftTarget, x as canJoin, y as joinPoint, z as replaceStep$1, R as ReplaceAroundStep$1, B as htmlHandler, C as ReplaceStep, E as getResolvedParagraphProperties, G as changeListLevel, H as isList$1, I as updateNumberingProperties, L as ListHelpers, J as inputRulesPlugin, K as TrackDeleteMarkName$1, O as TrackInsertMarkName$1, Q as TrackFormatMarkName$1, U as AddMarkStep, V as RemoveMarkStep, W as CommandService, S as SuperConverter, X as EditorState, Y as unflattenListsInHtml, Z as SelectionRange, _ as Transform, $ as createOoxmlResolver, a0 as translator, a1 as translator$1, a2 as resolveDocxFontFamily, a3 as _getReferencedTableStyles, a4 as decodeRPrFromMarks, a5 as calculateResolvedParagraphProperties, a6 as encodeCSSFromPPr, a7 as encodeCSSFromRPr, a8 as generateOrderedListIndex, a9 as docxNumberingHelpers, aa as InputRule, ab as insertNewRelationship, ac as kebabCase$1, ad as getUnderlineCssString } from "./SuperConverter-D62X6P1R.es.js";
4
4
  import { p as process$1, r as ref, C as global$1, c as computed, E as createElementBlock, F as Fragment$1, S as renderList, O as withModifiers, G as openBlock, P as normalizeClass, M as createCommentVNode, H as toDisplayString, K as createBaseVNode, U as createApp, f as onMounted, X as onUnmounted, R as withDirectives, v as unref, Y as vModelText, y as nextTick, L as normalizeStyle, u as watch, Z as withKeys, _ as createTextVNode, I as createVNode, h, $ as readonly, s as getCurrentInstance, o as onBeforeUnmount, j as reactive, b as onBeforeMount, i as inject, a0 as onActivated, a1 as onDeactivated, a2 as Comment, d as defineComponent, a as provide, g as Teleport, t as toRef, a3 as renderSlot, a4 as isVNode, D as shallowRef, w as watchEffect, T as Transition, a5 as mergeProps, a6 as vShow, a7 as cloneVNode, a8 as Text$2, m as markRaw, N as createBlock, J as withCtx, a9 as useCssVars, V as resolveDynamicComponent, aa as normalizeProps, ab as guardReactiveProps } from "./vue-BnBKJwCW.es.js";
5
5
  import "./jszip.min-DCl8qkFO.es.js";
6
6
  import { E as EventEmitter$1 } from "./eventemitter3-CwrdEv8r.es.js";
@@ -13392,8 +13392,12 @@ const createOrUpdateTrackedChangeComment = ({ event, marks, deletionNodes, nodes
13392
13392
  const hasMatchingId = changeMarks.find((mark) => mark.attrs.id === id);
13393
13393
  if (hasMatchingId) nodesWithMark.push(node2);
13394
13394
  });
13395
+ const nodesToProcess = nodesWithMark.length ? nodesWithMark : node ? [node] : [];
13396
+ if (!nodesToProcess.length) {
13397
+ return;
13398
+ }
13395
13399
  const { deletionText, trackedChangeText } = getTrackedChangeText({
13396
- nodes: nodesWithMark.length ? nodesWithMark : [node],
13400
+ nodes: nodesToProcess,
13397
13401
  mark: trackedMark,
13398
13402
  trackedChangeType,
13399
13403
  isDeletionInsertion
@@ -14109,6 +14113,45 @@ const updateYdocDocxData = async (editor, ydoc) => {
14109
14113
  console.warn("[collaboration] Failed to update Ydoc docx data", error);
14110
14114
  }
14111
14115
  };
14116
+ let isApplyingRemoteChanges = false;
14117
+ const isApplyingRemoteHeaderFooterChanges = () => isApplyingRemoteChanges;
14118
+ const pushHeaderFooterToYjs = (editor, type, sectionId, content) => {
14119
+ if (isApplyingRemoteChanges) return;
14120
+ const ydoc = editor?.options?.ydoc;
14121
+ if (!ydoc) return;
14122
+ const headerFooterMap = ydoc.getMap("headerFooterJson");
14123
+ const key2 = `${type}:${sectionId}`;
14124
+ const existing = headerFooterMap.get(key2)?.content;
14125
+ if (existing && JSON.stringify(existing) === JSON.stringify(content)) {
14126
+ return;
14127
+ }
14128
+ ydoc.transact(() => headerFooterMap.set(key2, { type, sectionId, content }), {
14129
+ event: "header-footer-update",
14130
+ user: editor.options.user
14131
+ });
14132
+ };
14133
+ const applyRemoteHeaderFooterChanges = (editor, key2, data) => {
14134
+ if (!editor || editor.isDestroyed || !editor.converter) return;
14135
+ const { type, sectionId, content } = data;
14136
+ if (!type || !sectionId || !content) return;
14137
+ isApplyingRemoteChanges = true;
14138
+ try {
14139
+ const storage = editor.converter[`${type}s`];
14140
+ if (storage) storage[sectionId] = content;
14141
+ editor.converter.headerFooterModified = true;
14142
+ const editors = editor.converter[`${type}Editors`];
14143
+ editors?.forEach((item) => {
14144
+ if (item.id === sectionId && item.editor) {
14145
+ item.editor.replaceContent(content);
14146
+ }
14147
+ });
14148
+ editor.emit("remoteHeaderFooterChanged", { type, sectionId, content });
14149
+ } finally {
14150
+ setTimeout(() => {
14151
+ isApplyingRemoteChanges = false;
14152
+ }, 0);
14153
+ }
14154
+ };
14112
14155
  new PluginKey("collaboration");
14113
14156
  const Collaboration = Extension.create({
14114
14157
  name: "collaboration",
@@ -14137,6 +14180,18 @@ const Collaboration = Extension.create({
14137
14180
  }
14138
14181
  });
14139
14182
  });
14183
+ const headerFooterMap = this.options.ydoc.getMap("headerFooterJson");
14184
+ headerFooterMap.observe((event) => {
14185
+ if (event.transaction.local) return;
14186
+ event.changes.keys.forEach((change, key2) => {
14187
+ if (change.action === "add" || change.action === "update") {
14188
+ const data = headerFooterMap.get(key2);
14189
+ if (data) {
14190
+ applyRemoteHeaderFooterChanges(this.editor, key2, data);
14191
+ }
14192
+ }
14193
+ });
14194
+ });
14140
14195
  return [syncPlugin];
14141
14196
  },
14142
14197
  addCommands() {
@@ -15279,7 +15334,7 @@ const canUseDOM = () => {
15279
15334
  return false;
15280
15335
  }
15281
15336
  };
15282
- const summaryVersion = "1.3.0-next.3";
15337
+ const summaryVersion = "1.3.0-next.4";
15283
15338
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15284
15339
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15285
15340
  function mapAttributes(attrs) {
@@ -17912,7 +17967,7 @@ class Editor extends EventEmitter {
17912
17967
  * Process collaboration migrations
17913
17968
  */
17914
17969
  processCollaborationMigrations() {
17915
- console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.3");
17970
+ console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.4");
17916
17971
  if (!this.options.ydoc) return;
17917
17972
  const metaMap = this.options.ydoc.getMap("meta");
17918
17973
  let docVersion = metaMap.get("version");
@@ -27489,7 +27544,12 @@ class DomPainter {
27489
27544
  const hanging = paraIndent?.hanging ?? 0;
27490
27545
  const isFirstLineOfPara = lineIndex === 0 || lineIndex === void 0;
27491
27546
  const firstLineOffsetForCumX = isFirstLineOfPara ? firstLine - hanging : 0;
27492
- const indentOffset = indentLeft + firstLineOffsetForCumX;
27547
+ const wordLayoutValue = block.attrs?.wordLayout;
27548
+ const wordLayout = isMinimalWordLayout(wordLayoutValue) ? wordLayoutValue : void 0;
27549
+ const isListParagraph = Boolean(wordLayout?.marker);
27550
+ const rawTextStartPx = typeof wordLayout?.marker?.textStartX === "number" && Number.isFinite(wordLayout.marker.textStartX) ? wordLayout.marker.textStartX : typeof wordLayout?.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : void 0;
27551
+ const listIndentOffset = isFirstLineOfPara ? rawTextStartPx ?? indentLeft : indentLeft;
27552
+ const indentOffset = isListParagraph ? listIndentOffset : indentLeft + firstLineOffsetForCumX;
27493
27553
  let cumulativeX = 0;
27494
27554
  const segmentsByRun = /* @__PURE__ */ new Map();
27495
27555
  line.segments.forEach((segment) => {
@@ -40050,6 +40110,15 @@ const pxToPt = (px) => {
40050
40110
  if (px == null || !Number.isFinite(px)) return void 0;
40051
40111
  return px / PX_PER_PT;
40052
40112
  };
40113
+ const convertIndentTwipsToPx$1 = (indent) => {
40114
+ if (!indent) return void 0;
40115
+ const result = {};
40116
+ if (isFiniteNumber(indent.left)) result.left = twipsToPx$1(indent.left);
40117
+ if (isFiniteNumber(indent.right)) result.right = twipsToPx$1(indent.right);
40118
+ if (isFiniteNumber(indent.firstLine)) result.firstLine = twipsToPx$1(indent.firstLine);
40119
+ if (isFiniteNumber(indent.hanging)) result.hanging = twipsToPx$1(indent.hanging);
40120
+ return Object.keys(result).length ? result : void 0;
40121
+ };
40053
40122
  const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
40054
40123
  const isPlainObject$2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
40055
40124
  const normalizePrefix = (value) => {
@@ -43074,8 +43143,11 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
43074
43143
  const hydrated = hydrationOverride ?? hydrateParagraphStyleAttrs(para, converterContext);
43075
43144
  const mergedSpacing = mergeSpacingSources(hydrated?.spacing, paragraphProps.spacing, attrs.spacing);
43076
43145
  const normalizedSpacing = normalizeParagraphSpacing(mergedSpacing);
43077
- const indentSource = attrs.indent ?? paragraphProps.indent ?? hydrated?.indent;
43078
- const normalizedIndent = normalizePxIndent(indentSource) ?? normalizeParagraphIndent(indentSource ?? attrs.textIndent);
43146
+ const normalizeIndentObject = (value) => {
43147
+ if (!value || typeof value !== "object") return;
43148
+ return normalizePxIndent(value) ?? convertIndentTwipsToPx(value);
43149
+ };
43150
+ const normalizedIndent = normalizeIndentObject(attrs.indent) ?? convertIndentTwipsToPx(paragraphProps.indent) ?? convertIndentTwipsToPx(hydrated?.indent) ?? normalizeParagraphIndent(attrs.textIndent);
43079
43151
  const unwrapTabStops = (tabStops) => {
43080
43152
  if (!Array.isArray(tabStops)) {
43081
43153
  return void 0;
@@ -44645,9 +44717,12 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
44645
44717
  };
44646
44718
  } else {
44647
44719
  const spacingSource = para.attrs?.spacing !== void 0 ? para.attrs.spacing : paragraphProps.spacing !== void 0 ? paragraphProps.spacing : paragraphHydration?.spacing;
44648
- const indentSource = para.attrs?.indent ?? paragraphProps.indent ?? paragraphHydration?.indent;
44720
+ const normalizeIndentObject = (value) => {
44721
+ if (!value || typeof value !== "object") return;
44722
+ return normalizePxIndent(value) ?? convertIndentTwipsToPx$1(value);
44723
+ };
44649
44724
  const normalizedSpacing = normalizeParagraphSpacing(spacingSource);
44650
- const normalizedIndent = normalizePxIndent(indentSource) ?? normalizeParagraphIndent(indentSource ?? para.attrs?.textIndent);
44725
+ const normalizedIndent = normalizeIndentObject(para.attrs?.indent) ?? convertIndentTwipsToPx$1(paragraphProps.indent) ?? convertIndentTwipsToPx$1(paragraphHydration?.indent) ?? normalizeParagraphIndent(para.attrs?.textIndent);
44651
44726
  const styleNodeAttrs = paragraphHydration?.tabStops && !para.attrs?.tabStops && !para.attrs?.tabs ? { ...para.attrs ?? {}, tabStops: paragraphHydration.tabStops } : para.attrs ?? {};
44652
44727
  const styleNode = buildStyleNodeFromAttrs(styleNodeAttrs, normalizedSpacing, normalizedIndent);
44653
44728
  if (styleNodeAttrs.styleId == null && paragraphProps.styleId) {
@@ -46368,6 +46443,9 @@ const createHeaderFooterEditor = ({
46368
46443
  };
46369
46444
  const onHeaderFooterDataUpdate = async ({ editor, transaction }, mainEditor, sectionId, type) => {
46370
46445
  if (!type || !sectionId) return;
46446
+ if (isApplyingRemoteHeaderFooterChanges()) {
46447
+ return;
46448
+ }
46371
46449
  const updatedData = editor.getUpdatedJson();
46372
46450
  const editorsList = mainEditor.converter[`${type}Editors`];
46373
46451
  if (Array.isArray(editorsList)) {
@@ -46391,6 +46469,7 @@ const onHeaderFooterDataUpdate = async ({ editor, transaction }, mainEditor, sec
46391
46469
  if (editor.docChanged && mainEditor.converter) {
46392
46470
  mainEditor.converter.headerFooterModified = true;
46393
46471
  }
46472
+ pushHeaderFooterToYjs(mainEditor, type, sectionId, updatedData);
46394
46473
  await updateYdocDocxData(mainEditor);
46395
46474
  };
46396
46475
  const setEditorToolbar = ({ editor }, mainEditor) => {
@@ -51242,6 +51321,17 @@ class PresentationEditor extends EventEmitter {
51242
51321
  event: "collaborationReady",
51243
51322
  handler: handleCollaborationReady
51244
51323
  });
51324
+ const handleRemoteHeaderFooterChanged = (payload) => {
51325
+ this.#headerFooterAdapter?.invalidate(payload.sectionId);
51326
+ this.#headerFooterManager?.refresh();
51327
+ this.#pendingDocChange = true;
51328
+ this.#scheduleRerender();
51329
+ };
51330
+ this.#editor.on("remoteHeaderFooterChanged", handleRemoteHeaderFooterChanged);
51331
+ this.#editorListeners.push({
51332
+ event: "remoteHeaderFooterChanged",
51333
+ handler: handleRemoteHeaderFooterChanged
51334
+ });
51245
51335
  }
51246
51336
  /**
51247
51337
  * Setup awareness event subscriptions for remote cursor tracking.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const jszip = require("./jszip-C8_CqJxM.cjs");
3
3
  const helpers$1 = require("./helpers-nOdwpmwb.cjs");
4
- const superEditor_converter = require("./SuperConverter-XGlv5pME.cjs");
4
+ const superEditor_converter = require("./SuperConverter-qB6m0K1X.cjs");
5
5
  const vue = require("./vue-De9wkgLl.cjs");
6
6
  require("./jszip.min-BPh2MMAa.cjs");
7
7
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
@@ -13409,8 +13409,12 @@ const createOrUpdateTrackedChangeComment = ({ event, marks, deletionNodes, nodes
13409
13409
  const hasMatchingId = changeMarks.find((mark) => mark.attrs.id === id);
13410
13410
  if (hasMatchingId) nodesWithMark.push(node2);
13411
13411
  });
13412
+ const nodesToProcess = nodesWithMark.length ? nodesWithMark : node ? [node] : [];
13413
+ if (!nodesToProcess.length) {
13414
+ return;
13415
+ }
13412
13416
  const { deletionText, trackedChangeText } = getTrackedChangeText({
13413
- nodes: nodesWithMark.length ? nodesWithMark : [node],
13417
+ nodes: nodesToProcess,
13414
13418
  mark: trackedMark,
13415
13419
  trackedChangeType,
13416
13420
  isDeletionInsertion
@@ -14126,6 +14130,45 @@ const updateYdocDocxData = async (editor, ydoc) => {
14126
14130
  console.warn("[collaboration] Failed to update Ydoc docx data", error);
14127
14131
  }
14128
14132
  };
14133
+ let isApplyingRemoteChanges = false;
14134
+ const isApplyingRemoteHeaderFooterChanges = () => isApplyingRemoteChanges;
14135
+ const pushHeaderFooterToYjs = (editor, type, sectionId, content) => {
14136
+ if (isApplyingRemoteChanges) return;
14137
+ const ydoc = editor?.options?.ydoc;
14138
+ if (!ydoc) return;
14139
+ const headerFooterMap = ydoc.getMap("headerFooterJson");
14140
+ const key2 = `${type}:${sectionId}`;
14141
+ const existing = headerFooterMap.get(key2)?.content;
14142
+ if (existing && JSON.stringify(existing) === JSON.stringify(content)) {
14143
+ return;
14144
+ }
14145
+ ydoc.transact(() => headerFooterMap.set(key2, { type, sectionId, content }), {
14146
+ event: "header-footer-update",
14147
+ user: editor.options.user
14148
+ });
14149
+ };
14150
+ const applyRemoteHeaderFooterChanges = (editor, key2, data) => {
14151
+ if (!editor || editor.isDestroyed || !editor.converter) return;
14152
+ const { type, sectionId, content } = data;
14153
+ if (!type || !sectionId || !content) return;
14154
+ isApplyingRemoteChanges = true;
14155
+ try {
14156
+ const storage = editor.converter[`${type}s`];
14157
+ if (storage) storage[sectionId] = content;
14158
+ editor.converter.headerFooterModified = true;
14159
+ const editors = editor.converter[`${type}Editors`];
14160
+ editors?.forEach((item) => {
14161
+ if (item.id === sectionId && item.editor) {
14162
+ item.editor.replaceContent(content);
14163
+ }
14164
+ });
14165
+ editor.emit("remoteHeaderFooterChanged", { type, sectionId, content });
14166
+ } finally {
14167
+ setTimeout(() => {
14168
+ isApplyingRemoteChanges = false;
14169
+ }, 0);
14170
+ }
14171
+ };
14129
14172
  new superEditor_converter.PluginKey("collaboration");
14130
14173
  const Collaboration = Extension.create({
14131
14174
  name: "collaboration",
@@ -14154,6 +14197,18 @@ const Collaboration = Extension.create({
14154
14197
  }
14155
14198
  });
14156
14199
  });
14200
+ const headerFooterMap = this.options.ydoc.getMap("headerFooterJson");
14201
+ headerFooterMap.observe((event) => {
14202
+ if (event.transaction.local) return;
14203
+ event.changes.keys.forEach((change, key2) => {
14204
+ if (change.action === "add" || change.action === "update") {
14205
+ const data = headerFooterMap.get(key2);
14206
+ if (data) {
14207
+ applyRemoteHeaderFooterChanges(this.editor, key2, data);
14208
+ }
14209
+ }
14210
+ });
14211
+ });
14157
14212
  return [syncPlugin];
14158
14213
  },
14159
14214
  addCommands() {
@@ -15296,7 +15351,7 @@ const canUseDOM = () => {
15296
15351
  return false;
15297
15352
  }
15298
15353
  };
15299
- const summaryVersion = "1.3.0-next.3";
15354
+ const summaryVersion = "1.3.0-next.4";
15300
15355
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15301
15356
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15302
15357
  function mapAttributes(attrs) {
@@ -17929,7 +17984,7 @@ class Editor extends EventEmitter {
17929
17984
  * Process collaboration migrations
17930
17985
  */
17931
17986
  processCollaborationMigrations() {
17932
- console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.3");
17987
+ console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.4");
17933
17988
  if (!this.options.ydoc) return;
17934
17989
  const metaMap = this.options.ydoc.getMap("meta");
17935
17990
  let docVersion = metaMap.get("version");
@@ -27506,7 +27561,12 @@ class DomPainter {
27506
27561
  const hanging = paraIndent?.hanging ?? 0;
27507
27562
  const isFirstLineOfPara = lineIndex === 0 || lineIndex === void 0;
27508
27563
  const firstLineOffsetForCumX = isFirstLineOfPara ? firstLine - hanging : 0;
27509
- const indentOffset = indentLeft + firstLineOffsetForCumX;
27564
+ const wordLayoutValue = block.attrs?.wordLayout;
27565
+ const wordLayout = isMinimalWordLayout(wordLayoutValue) ? wordLayoutValue : void 0;
27566
+ const isListParagraph = Boolean(wordLayout?.marker);
27567
+ const rawTextStartPx = typeof wordLayout?.marker?.textStartX === "number" && Number.isFinite(wordLayout.marker.textStartX) ? wordLayout.marker.textStartX : typeof wordLayout?.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : void 0;
27568
+ const listIndentOffset = isFirstLineOfPara ? rawTextStartPx ?? indentLeft : indentLeft;
27569
+ const indentOffset = isListParagraph ? listIndentOffset : indentLeft + firstLineOffsetForCumX;
27510
27570
  let cumulativeX = 0;
27511
27571
  const segmentsByRun = /* @__PURE__ */ new Map();
27512
27572
  line.segments.forEach((segment) => {
@@ -40067,6 +40127,15 @@ const pxToPt = (px) => {
40067
40127
  if (px == null || !Number.isFinite(px)) return void 0;
40068
40128
  return px / PX_PER_PT;
40069
40129
  };
40130
+ const convertIndentTwipsToPx$1 = (indent) => {
40131
+ if (!indent) return void 0;
40132
+ const result = {};
40133
+ if (isFiniteNumber(indent.left)) result.left = twipsToPx$1(indent.left);
40134
+ if (isFiniteNumber(indent.right)) result.right = twipsToPx$1(indent.right);
40135
+ if (isFiniteNumber(indent.firstLine)) result.firstLine = twipsToPx$1(indent.firstLine);
40136
+ if (isFiniteNumber(indent.hanging)) result.hanging = twipsToPx$1(indent.hanging);
40137
+ return Object.keys(result).length ? result : void 0;
40138
+ };
40070
40139
  const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
40071
40140
  const isPlainObject$2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
40072
40141
  const normalizePrefix = (value) => {
@@ -43091,8 +43160,11 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
43091
43160
  const hydrated = hydrationOverride ?? hydrateParagraphStyleAttrs(para, converterContext);
43092
43161
  const mergedSpacing = mergeSpacingSources(hydrated?.spacing, paragraphProps.spacing, attrs.spacing);
43093
43162
  const normalizedSpacing = normalizeParagraphSpacing(mergedSpacing);
43094
- const indentSource = attrs.indent ?? paragraphProps.indent ?? hydrated?.indent;
43095
- const normalizedIndent = normalizePxIndent(indentSource) ?? normalizeParagraphIndent(indentSource ?? attrs.textIndent);
43163
+ const normalizeIndentObject = (value) => {
43164
+ if (!value || typeof value !== "object") return;
43165
+ return normalizePxIndent(value) ?? convertIndentTwipsToPx(value);
43166
+ };
43167
+ const normalizedIndent = normalizeIndentObject(attrs.indent) ?? convertIndentTwipsToPx(paragraphProps.indent) ?? convertIndentTwipsToPx(hydrated?.indent) ?? normalizeParagraphIndent(attrs.textIndent);
43096
43168
  const unwrapTabStops = (tabStops) => {
43097
43169
  if (!Array.isArray(tabStops)) {
43098
43170
  return void 0;
@@ -44662,9 +44734,12 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
44662
44734
  };
44663
44735
  } else {
44664
44736
  const spacingSource = para.attrs?.spacing !== void 0 ? para.attrs.spacing : paragraphProps.spacing !== void 0 ? paragraphProps.spacing : paragraphHydration?.spacing;
44665
- const indentSource = para.attrs?.indent ?? paragraphProps.indent ?? paragraphHydration?.indent;
44737
+ const normalizeIndentObject = (value) => {
44738
+ if (!value || typeof value !== "object") return;
44739
+ return normalizePxIndent(value) ?? convertIndentTwipsToPx$1(value);
44740
+ };
44666
44741
  const normalizedSpacing = normalizeParagraphSpacing(spacingSource);
44667
- const normalizedIndent = normalizePxIndent(indentSource) ?? normalizeParagraphIndent(indentSource ?? para.attrs?.textIndent);
44742
+ const normalizedIndent = normalizeIndentObject(para.attrs?.indent) ?? convertIndentTwipsToPx$1(paragraphProps.indent) ?? convertIndentTwipsToPx$1(paragraphHydration?.indent) ?? normalizeParagraphIndent(para.attrs?.textIndent);
44668
44743
  const styleNodeAttrs = paragraphHydration?.tabStops && !para.attrs?.tabStops && !para.attrs?.tabs ? { ...para.attrs ?? {}, tabStops: paragraphHydration.tabStops } : para.attrs ?? {};
44669
44744
  const styleNode = buildStyleNodeFromAttrs(styleNodeAttrs, normalizedSpacing, normalizedIndent);
44670
44745
  if (styleNodeAttrs.styleId == null && paragraphProps.styleId) {
@@ -46385,6 +46460,9 @@ const createHeaderFooterEditor = ({
46385
46460
  };
46386
46461
  const onHeaderFooterDataUpdate = async ({ editor, transaction }, mainEditor, sectionId, type) => {
46387
46462
  if (!type || !sectionId) return;
46463
+ if (isApplyingRemoteHeaderFooterChanges()) {
46464
+ return;
46465
+ }
46388
46466
  const updatedData = editor.getUpdatedJson();
46389
46467
  const editorsList = mainEditor.converter[`${type}Editors`];
46390
46468
  if (Array.isArray(editorsList)) {
@@ -46408,6 +46486,7 @@ const onHeaderFooterDataUpdate = async ({ editor, transaction }, mainEditor, sec
46408
46486
  if (editor.docChanged && mainEditor.converter) {
46409
46487
  mainEditor.converter.headerFooterModified = true;
46410
46488
  }
46489
+ pushHeaderFooterToYjs(mainEditor, type, sectionId, updatedData);
46411
46490
  await updateYdocDocxData(mainEditor);
46412
46491
  };
46413
46492
  const setEditorToolbar = ({ editor }, mainEditor) => {
@@ -51259,6 +51338,17 @@ class PresentationEditor extends EventEmitter {
51259
51338
  event: "collaborationReady",
51260
51339
  handler: handleCollaborationReady
51261
51340
  });
51341
+ const handleRemoteHeaderFooterChanged = (payload) => {
51342
+ this.#headerFooterAdapter?.invalidate(payload.sectionId);
51343
+ this.#headerFooterManager?.refresh();
51344
+ this.#pendingDocChange = true;
51345
+ this.#scheduleRerender();
51346
+ };
51347
+ this.#editor.on("remoteHeaderFooterChanged", handleRemoteHeaderFooterChanged);
51348
+ this.#editorListeners.push({
51349
+ event: "remoteHeaderFooterChanged",
51350
+ handler: handleRemoteHeaderFooterChanged
51351
+ });
51262
51352
  }
51263
51353
  /**
51264
51354
  * Setup awareness event subscriptions for remote cursor tracking.
@@ -1,5 +1,5 @@
1
- import { B as BIT8, M as MAX_SAFE_INTEGER, c as create, a as BITS7, u as utf8TextDecoder, b as create$1, s as setIfUndefined, d as create$2, f as from, e as floor$1, g as equalityDeep, w as writeVarUint, h as writeVarString, t as toUint8Array, i as createEncoder, j as createInjectionKey, k as toString, l as throwError, m as useSsrAdapter, n as configProviderInjectionKey, o as cssrAnchorMetaName, p as globalStyle, q as cB, r as c, v as isMounted, x as commonVariables$2, y as cM, z as cNotM, A as cE, C as derived, D as changeColor, E as insideModal, F as insidePopover, G as resolveWrappedSlot, H as on, I as warnOnce, J as useConfig, K as useMergedState, L as useMemo, N as useTheme, O as useRtl, P as createKey, Q as useThemeClass, R as createId, S as call, T as render, U as messageProviderInjectionKey, V as messageApiInjectionKey, W as fromBase64, X as onChange, Y as varStorage, Z as toBase64, _ as createUint8ArrayFromArrayBuffer, $ as offChange, a0 as writeVarUint8Array, a1 as map, a2 as length, a3 as isNode, a4 as min, a5 as pow, a6 as comments_module_events, a7 as getFileObject, a8 as getTrackChanges, a9 as CommentsPluginKey, aa as TrackChangesBasePluginKey, ab as Editor, ac as getRichTextExtensions, ad as ellipsisVerticalSvg, ae as xmarkIconSvg, af as checkIconSvg, ag as caretDownIconSvg, ah as commentIconSvg, ai as _export_sfc, aj as NDropdown, ak as SuperInput, al as vClickOutside, am as PresentationEditor, an as SuperEditor, ao as AIWriter, ap as NConfigProvider, aq as SuperToolbar } from "./index-M8MvGhiF.es.js";
2
- import "./SuperConverter-CVOKZex3.es.js";
1
+ import { B as BIT8, M as MAX_SAFE_INTEGER, c as create, a as BITS7, u as utf8TextDecoder, b as create$1, s as setIfUndefined, d as create$2, f as from, e as floor$1, g as equalityDeep, w as writeVarUint, h as writeVarString, t as toUint8Array, i as createEncoder, j as createInjectionKey, k as toString, l as throwError, m as useSsrAdapter, n as configProviderInjectionKey, o as cssrAnchorMetaName, p as globalStyle, q as cB, r as c, v as isMounted, x as commonVariables$2, y as cM, z as cNotM, A as cE, C as derived, D as changeColor, E as insideModal, F as insidePopover, G as resolveWrappedSlot, H as on, I as warnOnce, J as useConfig, K as useMergedState, L as useMemo, N as useTheme, O as useRtl, P as createKey, Q as useThemeClass, R as createId, S as call, T as render, U as messageProviderInjectionKey, V as messageApiInjectionKey, W as fromBase64, X as onChange, Y as varStorage, Z as toBase64, _ as createUint8ArrayFromArrayBuffer, $ as offChange, a0 as writeVarUint8Array, a1 as map, a2 as length, a3 as isNode, a4 as min, a5 as pow, a6 as comments_module_events, a7 as getFileObject, a8 as getTrackChanges, a9 as CommentsPluginKey, aa as TrackChangesBasePluginKey, ab as Editor, ac as getRichTextExtensions, ad as ellipsisVerticalSvg, ae as xmarkIconSvg, af as checkIconSvg, ag as caretDownIconSvg, ah as commentIconSvg, ai as _export_sfc, aj as NDropdown, ak as SuperInput, al as vClickOutside, am as PresentationEditor, an as SuperEditor, ao as AIWriter, ap as NConfigProvider, aq as SuperToolbar } from "./index-BgcNLeK9.es.js";
2
+ import "./SuperConverter-D62X6P1R.es.js";
3
3
  import { B as BlankDOCX } from "./blank-docx-ABm6XYAA.es.js";
4
4
  import { E as EventEmitter } from "./eventemitter3-CwrdEv8r.es.js";
5
5
  import { HocuspocusProvider, HocuspocusProviderWebsocket } from "@hocuspocus/provider";
@@ -7444,7 +7444,7 @@ const _sfc_main = {
7444
7444
  __name: "SuperDoc",
7445
7445
  emits: ["selection-update"],
7446
7446
  setup(__props, { emit: __emit }) {
7447
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-ltwzoe73.es.js"));
7447
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-BT0Whwl-.es.js"));
7448
7448
  const superdocStore = useSuperdocStore();
7449
7449
  const commentsStore = useCommentsStore();
7450
7450
  const {
@@ -8350,7 +8350,7 @@ class SuperDoc extends EventEmitter {
8350
8350
  this.config.colors = shuffleArray(this.config.colors);
8351
8351
  this.userColorMap = /* @__PURE__ */ new Map();
8352
8352
  this.colorIndex = 0;
8353
- this.version = "1.3.0-next.3";
8353
+ this.version = "1.3.0-next.4";
8354
8354
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8355
8355
  this.superdocId = config.superdocId || v4();
8356
8356
  this.colors = this.config.colors;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- const index = require("./index-D0lYfjMI.cjs");
3
- require("./SuperConverter-XGlv5pME.cjs");
2
+ const index = require("./index-Buh63pW6.cjs");
3
+ require("./SuperConverter-qB6m0K1X.cjs");
4
4
  const blankDocx = require("./blank-docx-DfW3Eeh2.cjs");
5
5
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
6
6
  const provider = require("@hocuspocus/provider");
@@ -7461,7 +7461,7 @@ const _sfc_main = {
7461
7461
  __name: "SuperDoc",
7462
7462
  emits: ["selection-update"],
7463
7463
  setup(__props, { emit: __emit }) {
7464
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-D6XxSIuw.cjs")));
7464
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-DkzZlntQ.cjs")));
7465
7465
  const superdocStore = useSuperdocStore();
7466
7466
  const commentsStore = useCommentsStore();
7467
7467
  const {
@@ -8367,7 +8367,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
8367
8367
  this.config.colors = shuffleArray(this.config.colors);
8368
8368
  this.userColorMap = /* @__PURE__ */ new Map();
8369
8369
  this.colorIndex = 0;
8370
- this.version = "1.3.0-next.3";
8370
+ this.version = "1.3.0-next.4";
8371
8371
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8372
8372
  this.superdocId = config.superdocId || uuid.v4();
8373
8373
  this.colors = this.config.colors;
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  require("../chunks/jszip-C8_CqJxM.cjs");
4
4
  require("../chunks/helpers-nOdwpmwb.cjs");
5
- const superEditor_converter = require("../chunks/SuperConverter-XGlv5pME.cjs");
5
+ const superEditor_converter = require("../chunks/SuperConverter-qB6m0K1X.cjs");
6
6
  require("../chunks/uuid-R7L08bOx.cjs");
7
7
  exports.SuperConverter = superEditor_converter.SuperConverter;
@@ -1,6 +1,6 @@
1
1
  import "../chunks/jszip-B1fkPkPJ.es.js";
2
2
  import "../chunks/helpers-C8e9wR5l.es.js";
3
- import { S } from "../chunks/SuperConverter-CVOKZex3.es.js";
3
+ import { S } from "../chunks/SuperConverter-D62X6P1R.es.js";
4
4
  import "../chunks/uuid-CjlX8hrF.es.js";
5
5
  export {
6
6
  S as SuperConverter
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./chunks/index-D0lYfjMI.cjs");
3
+ const index = require("./chunks/index-Buh63pW6.cjs");
4
4
  const superEditor_docxZipper = require("./super-editor/docx-zipper.cjs");
5
5
  const superEditor_fileZipper = require("./super-editor/file-zipper.cjs");
6
6
  const vue = require("./chunks/vue-De9wkgLl.cjs");
7
- const superEditor_converter = require("./chunks/SuperConverter-XGlv5pME.cjs");
7
+ const superEditor_converter = require("./chunks/SuperConverter-qB6m0K1X.cjs");
8
8
  function isNodeType(node, name) {
9
9
  return node.type.name === name;
10
10
  }
@@ -1,9 +1,9 @@
1
- import { ax as Node, ay as Mark } from "./chunks/index-M8MvGhiF.es.js";
2
- import { ao, au, a9, ab, aw, am, av, aA, an, ak, aq, az, aa, as, aC, aE, aB, ac, aD, ar, at } from "./chunks/index-M8MvGhiF.es.js";
1
+ import { ax as Node, ay as Mark } from "./chunks/index-BgcNLeK9.es.js";
2
+ import { ao, au, a9, ab, aw, am, av, aA, an, ak, aq, az, aa, as, aC, aE, aB, ac, aD, ar, at } from "./chunks/index-BgcNLeK9.es.js";
3
3
  import { default as default2 } from "./super-editor/docx-zipper.es.js";
4
4
  import { createZip } from "./super-editor/file-zipper.es.js";
5
5
  import { d as defineComponent, E as createElementBlock, G as openBlock, K as createBaseVNode } from "./chunks/vue-BnBKJwCW.es.js";
6
- import { S, r } from "./chunks/SuperConverter-CVOKZex3.es.js";
6
+ import { S, r } from "./chunks/SuperConverter-D62X6P1R.es.js";
7
7
  function isNodeType(node, name) {
8
8
  return node.type.name === name;
9
9
  }
package/dist/superdoc.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./chunks/index-D0lYfjMI.cjs");
4
- const superdoc = require("./chunks/index-HQW67fDU.cjs");
5
- const superEditor_converter = require("./chunks/SuperConverter-XGlv5pME.cjs");
3
+ const index = require("./chunks/index-Buh63pW6.cjs");
4
+ const superdoc = require("./chunks/index-Dtd_PFUu.cjs");
5
+ const superEditor_converter = require("./chunks/SuperConverter-qB6m0K1X.cjs");
6
6
  const blankDocx = require("./chunks/blank-docx-DfW3Eeh2.cjs");
7
7
  require("./chunks/jszip-C8_CqJxM.cjs");
8
8
  require("./chunks/helpers-nOdwpmwb.cjs");
@@ -1,6 +1,6 @@
1
- import { au, ab, aw, av, as, a7, ac, ar, at } from "./chunks/index-M8MvGhiF.es.js";
2
- import { D, H, P, S, c } from "./chunks/index-e6096-IC.es.js";
3
- import { S as S2, r } from "./chunks/SuperConverter-CVOKZex3.es.js";
1
+ import { au, ab, aw, av, as, a7, ac, ar, at } from "./chunks/index-BgcNLeK9.es.js";
2
+ import { D, H, P, S, c } from "./chunks/index-CiR7cacp.es.js";
3
+ import { S as S2, r } from "./chunks/SuperConverter-D62X6P1R.es.js";
4
4
  import { B } from "./chunks/blank-docx-ABm6XYAA.es.js";
5
5
  import "./chunks/jszip-B1fkPkPJ.es.js";
6
6
  import "./chunks/helpers-C8e9wR5l.es.js";