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

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,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-79lZpkMi.cjs");
5
+ const index = require("./index-BHIGTNEQ.cjs");
6
6
  function self(vars) {
7
7
  const {
8
8
  opacityDisabled,
@@ -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-B697vddF.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-BSxlafD_.es.js";
4
4
  function self(vars) {
5
5
  const {
6
6
  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.5") {
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.5") {
30942
30943
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
30943
30944
  }
30944
30945
  /**
@@ -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-BHIGTNEQ.cjs");
3
+ require("./SuperConverter-tcg6NQjY.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-CvoctNPw.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.5";
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;
@@ -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-BSxlafD_.es.js";
2
+ import "./SuperConverter-DMbipzpl.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-Dbc_J_1L.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.5";
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,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-tcg6NQjY.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.5";
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.5");
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) => {
@@ -41177,6 +41246,19 @@ function tokenNodeToRun(node, positions, defaultFont, defaultSize, inheritedMark
41177
41246
  const effectiveMarks = nodeMarks.length > 0 ? nodeMarks : marksAsAttrs;
41178
41247
  const marks = [...effectiveMarks, ...inheritedMarks ?? []];
41179
41248
  applyMarksToRun(run, marks, hyperlinkConfig, themeColors);
41249
+ if (marksAsAttrs.length > 0) {
41250
+ run._explicitFont = true;
41251
+ }
41252
+ console.debug("[token-debug] tokenNodeToRun", {
41253
+ token,
41254
+ fontFamily: run.fontFamily,
41255
+ fontSize: run.fontSize,
41256
+ defaultFont,
41257
+ defaultSize,
41258
+ nodeMarksCount: nodeMarks.length,
41259
+ marksAsAttrsCount: marksAsAttrs.length,
41260
+ inheritedMarksCount: inheritedMarks?.length ?? 0
41261
+ });
41180
41262
  return run;
41181
41263
  }
41182
41264
  const EIGHTHS_PER_POINT = 8;
@@ -43091,8 +43173,11 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
43091
43173
  const hydrated = hydrationOverride ?? hydrateParagraphStyleAttrs(para, converterContext);
43092
43174
  const mergedSpacing = mergeSpacingSources(hydrated?.spacing, paragraphProps.spacing, attrs.spacing);
43093
43175
  const normalizedSpacing = normalizeParagraphSpacing(mergedSpacing);
43094
- const indentSource = attrs.indent ?? paragraphProps.indent ?? hydrated?.indent;
43095
- const normalizedIndent = normalizePxIndent(indentSource) ?? normalizeParagraphIndent(indentSource ?? attrs.textIndent);
43176
+ const normalizeIndentObject = (value) => {
43177
+ if (!value || typeof value !== "object") return;
43178
+ return normalizePxIndent(value) ?? convertIndentTwipsToPx(value);
43179
+ };
43180
+ const normalizedIndent = normalizeIndentObject(attrs.indent) ?? convertIndentTwipsToPx(paragraphProps.indent) ?? convertIndentTwipsToPx(hydrated?.indent) ?? normalizeParagraphIndent(attrs.textIndent);
43096
43181
  const unwrapTabStops = (tabStops) => {
43097
43182
  if (!Array.isArray(tabStops)) {
43098
43183
  return void 0;
@@ -44662,9 +44747,12 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
44662
44747
  };
44663
44748
  } else {
44664
44749
  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;
44750
+ const normalizeIndentObject = (value) => {
44751
+ if (!value || typeof value !== "object") return;
44752
+ return normalizePxIndent(value) ?? convertIndentTwipsToPx$1(value);
44753
+ };
44666
44754
  const normalizedSpacing = normalizeParagraphSpacing(spacingSource);
44667
- const normalizedIndent = normalizePxIndent(indentSource) ?? normalizeParagraphIndent(indentSource ?? para.attrs?.textIndent);
44755
+ const normalizedIndent = normalizeIndentObject(para.attrs?.indent) ?? convertIndentTwipsToPx$1(paragraphProps.indent) ?? convertIndentTwipsToPx$1(paragraphHydration?.indent) ?? normalizeParagraphIndent(para.attrs?.textIndent);
44668
44756
  const styleNodeAttrs = paragraphHydration?.tabStops && !para.attrs?.tabStops && !para.attrs?.tabs ? { ...para.attrs ?? {}, tabStops: paragraphHydration.tabStops } : para.attrs ?? {};
44669
44757
  const styleNode = buildStyleNodeFromAttrs(styleNodeAttrs, normalizedSpacing, normalizedIndent);
44670
44758
  if (styleNodeAttrs.styleId == null && paragraphProps.styleId) {
@@ -44919,6 +45007,10 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
44919
45007
  if (TOKEN_INLINE_TYPES.has(node.type)) {
44920
45008
  const tokenKind = TOKEN_INLINE_TYPES.get(node.type);
44921
45009
  if (tokenKind) {
45010
+ const marksAsAttrs = Array.isArray(node.attrs?.marksAsAttrs) ? node.attrs.marksAsAttrs : [];
45011
+ const nodeMarks = node.marks ?? [];
45012
+ const effectiveMarks = nodeMarks.length > 0 ? nodeMarks : marksAsAttrs;
45013
+ const mergedMarks = [...effectiveMarks, ...inheritedMarks ?? []];
44922
45014
  const tokenRun = tokenNodeToRun(
44923
45015
  node,
44924
45016
  positions,
@@ -44935,6 +45027,23 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
44935
45027
  const inlineStyleId = getInlineStyleId(inheritedMarks);
44936
45028
  applyRunStyles2(tokenRun, inlineStyleId, activeRunStyleId);
44937
45029
  applyBaseRunDefaults(tokenRun, baseRunDefaults, defaultFont, defaultSize);
45030
+ if (mergedMarks.length > 0) {
45031
+ applyMarksToRun(
45032
+ tokenRun,
45033
+ mergedMarks,
45034
+ hyperlinkConfig,
45035
+ themeColors,
45036
+ converterContext?.backgroundColor
45037
+ );
45038
+ }
45039
+ console.debug("[token-debug] paragraph-token-run", {
45040
+ token: tokenRun.token,
45041
+ fontFamily: tokenRun.fontFamily,
45042
+ fontSize: tokenRun.fontSize,
45043
+ inlineStyleId,
45044
+ runStyleId: activeRunStyleId,
45045
+ mergedMarksCount: mergedMarks.length
45046
+ });
44938
45047
  currentRuns.push(tokenRun);
44939
45048
  }
44940
45049
  return;
@@ -46385,6 +46494,9 @@ const createHeaderFooterEditor = ({
46385
46494
  };
46386
46495
  const onHeaderFooterDataUpdate = async ({ editor, transaction }, mainEditor, sectionId, type) => {
46387
46496
  if (!type || !sectionId) return;
46497
+ if (isApplyingRemoteHeaderFooterChanges()) {
46498
+ return;
46499
+ }
46388
46500
  const updatedData = editor.getUpdatedJson();
46389
46501
  const editorsList = mainEditor.converter[`${type}Editors`];
46390
46502
  if (Array.isArray(editorsList)) {
@@ -46408,6 +46520,7 @@ const onHeaderFooterDataUpdate = async ({ editor, transaction }, mainEditor, sec
46408
46520
  if (editor.docChanged && mainEditor.converter) {
46409
46521
  mainEditor.converter.headerFooterModified = true;
46410
46522
  }
46523
+ pushHeaderFooterToYjs(mainEditor, type, sectionId, updatedData);
46411
46524
  await updateYdocDocxData(mainEditor);
46412
46525
  };
46413
46526
  const setEditorToolbar = ({ editor }, mainEditor) => {
@@ -47915,6 +48028,77 @@ function isLineBreakRun(run) {
47915
48028
  function isFieldAnnotationRun(run) {
47916
48029
  return run.kind === "fieldAnnotation";
47917
48030
  }
48031
+ function measureTabAlignmentGroup(startRunIndex, runs, ctx2, decimalSeparator = ".") {
48032
+ const result = {
48033
+ totalWidth: 0,
48034
+ runs: [],
48035
+ endRunIndex: runs.length
48036
+ };
48037
+ let foundDecimal = false;
48038
+ for (let i = startRunIndex; i < runs.length; i++) {
48039
+ const run = runs[i];
48040
+ if (isTabRun(run)) {
48041
+ result.endRunIndex = i;
48042
+ break;
48043
+ }
48044
+ if (isLineBreakRun(run) || run.kind === "break" && run.breakType === "line") {
48045
+ result.endRunIndex = i;
48046
+ break;
48047
+ }
48048
+ if (run.kind === "text" || run.kind === void 0) {
48049
+ const textRun = run;
48050
+ const text = textRun.text || "";
48051
+ if (text.length > 0) {
48052
+ const { font } = buildFontString(textRun);
48053
+ const width = measureRunWidth(text, font, ctx2, textRun, 0);
48054
+ let beforeDecimalWidth;
48055
+ if (!foundDecimal) {
48056
+ const decimalIdx = text.indexOf(decimalSeparator);
48057
+ if (decimalIdx >= 0) {
48058
+ foundDecimal = true;
48059
+ const beforeText = text.slice(0, decimalIdx);
48060
+ beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, textRun, 0) : 0;
48061
+ result.beforeDecimalWidth = result.totalWidth + beforeDecimalWidth;
48062
+ }
48063
+ }
48064
+ result.runs.push({
48065
+ runIndex: i,
48066
+ width,
48067
+ text,
48068
+ beforeDecimalWidth
48069
+ });
48070
+ result.totalWidth += width;
48071
+ } else {
48072
+ result.runs.push({ runIndex: i, width: 0, text: "" });
48073
+ }
48074
+ continue;
48075
+ }
48076
+ if (isImageRun(run)) {
48077
+ const leftSpace = run.distLeft ?? 0;
48078
+ const rightSpace = run.distRight ?? 0;
48079
+ const imageWidth = run.width + leftSpace + rightSpace;
48080
+ result.runs.push({ runIndex: i, width: imageWidth });
48081
+ result.totalWidth += imageWidth;
48082
+ continue;
48083
+ }
48084
+ if (isFieldAnnotationRun(run)) {
48085
+ const fontSize2 = run.fontSize ?? DEFAULT_FIELD_ANNOTATION_FONT_SIZE;
48086
+ const { font } = buildFontString({
48087
+ fontFamily: run.fontFamily ?? "Arial",
48088
+ fontSize: fontSize2,
48089
+ bold: run.bold,
48090
+ italic: run.italic
48091
+ });
48092
+ const textWidth = run.displayLabel ? measureRunWidth(run.displayLabel, font, ctx2, run, 0) : 0;
48093
+ const pillWidth = textWidth + FIELD_ANNOTATION_PILL_PADDING;
48094
+ result.runs.push({ runIndex: i, width: pillWidth });
48095
+ result.totalWidth += pillWidth;
48096
+ continue;
48097
+ }
48098
+ result.runs.push({ runIndex: i, width: 0 });
48099
+ }
48100
+ return result;
48101
+ }
47918
48102
  async function measureBlock(block, constraints) {
47919
48103
  const normalized = normalizeConstraints(constraints);
47920
48104
  if (block.kind === "drawing") {
@@ -48038,6 +48222,7 @@ async function measureParagraphBlock(block, maxWidth) {
48038
48222
  let pendingTabAlignment = null;
48039
48223
  let lastAppliedTabAlign = null;
48040
48224
  const warnedTabVals = /* @__PURE__ */ new Set();
48225
+ let activeTabGroup = null;
48041
48226
  const validateTabStopVal = (stop) => {
48042
48227
  if (!ALLOWED_TAB_VALS.has(stop.val) && !warnedTabVals.has(stop.val)) {
48043
48228
  warnedTabVals.add(stop.val);
@@ -48217,6 +48402,7 @@ async function measureParagraphBlock(block, maxWidth) {
48217
48402
  continue;
48218
48403
  }
48219
48404
  if (isTabRun(run)) {
48405
+ activeTabGroup = null;
48220
48406
  if (!currentLine) {
48221
48407
  currentLine = {
48222
48408
  fromRun: runIndex,
@@ -48241,12 +48427,6 @@ async function measureParagraphBlock(block, maxWidth) {
48241
48427
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, 12);
48242
48428
  currentLine.toRun = runIndex;
48243
48429
  currentLine.toChar = 1;
48244
- if (stop) {
48245
- validateTabStopVal(stop);
48246
- pendingTabAlignment = { target: clampedTarget, val: stop.val };
48247
- } else {
48248
- pendingTabAlignment = null;
48249
- }
48250
48430
  if (stop && stop.leader && stop.leader !== "none") {
48251
48431
  const leaderStyle = stop.leader;
48252
48432
  const from3 = Math.min(originX, clampedTarget);
@@ -48254,6 +48434,36 @@ async function measureParagraphBlock(block, maxWidth) {
48254
48434
  if (!currentLine.leaders) currentLine.leaders = [];
48255
48435
  currentLine.leaders.push({ from: from3, to, style: leaderStyle });
48256
48436
  }
48437
+ if (stop) {
48438
+ validateTabStopVal(stop);
48439
+ if (stop.val === "end" || stop.val === "center" || stop.val === "decimal") {
48440
+ const groupMeasure = measureTabAlignmentGroup(runIndex + 1, runsToProcess, ctx2, decimalSeparator);
48441
+ if (groupMeasure.totalWidth > 0) {
48442
+ let groupStartX;
48443
+ if (stop.val === "end") {
48444
+ groupStartX = Math.max(0, clampedTarget - groupMeasure.totalWidth);
48445
+ } else if (stop.val === "center") {
48446
+ groupStartX = Math.max(0, clampedTarget - groupMeasure.totalWidth / 2);
48447
+ } else {
48448
+ const beforeDecimal = groupMeasure.beforeDecimalWidth ?? groupMeasure.totalWidth;
48449
+ groupStartX = Math.max(0, clampedTarget - beforeDecimal);
48450
+ }
48451
+ activeTabGroup = {
48452
+ measure: groupMeasure,
48453
+ startX: groupStartX,
48454
+ currentX: groupStartX,
48455
+ target: clampedTarget,
48456
+ val: stop.val
48457
+ };
48458
+ currentLine.width = roundValue(groupStartX);
48459
+ }
48460
+ pendingTabAlignment = null;
48461
+ } else {
48462
+ pendingTabAlignment = { target: clampedTarget, val: stop.val };
48463
+ }
48464
+ } else {
48465
+ pendingTabAlignment = null;
48466
+ }
48257
48467
  continue;
48258
48468
  }
48259
48469
  if (isImageRun(run)) {
@@ -48264,7 +48474,10 @@ async function measureParagraphBlock(block, maxWidth) {
48264
48474
  const bottomSpace = run.distBottom ?? 0;
48265
48475
  const imageHeight = run.height + topSpace + bottomSpace;
48266
48476
  let imageStartX;
48267
- if (pendingTabAlignment && currentLine) {
48477
+ if (activeTabGroup && currentLine) {
48478
+ imageStartX = activeTabGroup.currentX;
48479
+ activeTabGroup.currentX = roundValue(activeTabGroup.currentX + imageWidth);
48480
+ } else if (pendingTabAlignment && currentLine) {
48268
48481
  imageStartX = alignPendingTabForWidth(imageWidth);
48269
48482
  }
48270
48483
  if (!currentLine) {
@@ -48289,10 +48502,14 @@ async function measureParagraphBlock(block, maxWidth) {
48289
48502
  }
48290
48503
  ]
48291
48504
  };
48505
+ if (activeTabGroup && runIndex + 1 >= activeTabGroup.measure.endRunIndex) {
48506
+ activeTabGroup = null;
48507
+ }
48292
48508
  continue;
48293
48509
  }
48294
48510
  const appliedTabAlign = lastAppliedTabAlign;
48295
- if (currentLine.width + imageWidth > currentLine.maxWidth && currentLine.width > 0) {
48511
+ const skipFitCheck = activeTabGroup !== null;
48512
+ if (!skipFitCheck && currentLine.width + imageWidth > currentLine.maxWidth && currentLine.width > 0) {
48296
48513
  trimTrailingWrapSpaces(currentLine);
48297
48514
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
48298
48515
  const lineBase = currentLine;
@@ -48305,6 +48522,7 @@ async function measureParagraphBlock(block, maxWidth) {
48305
48522
  tabStopCursor = 0;
48306
48523
  pendingTabAlignment = null;
48307
48524
  lastAppliedTabAlign = null;
48525
+ activeTabGroup = null;
48308
48526
  currentLine = {
48309
48527
  fromRun: runIndex,
48310
48528
  fromChar: 0,
@@ -48337,6 +48555,9 @@ async function measureParagraphBlock(block, maxWidth) {
48337
48555
  ...imageStartX !== void 0 ? { x: imageStartX } : {}
48338
48556
  });
48339
48557
  }
48558
+ if (activeTabGroup && runIndex + 1 >= activeTabGroup.measure.endRunIndex) {
48559
+ activeTabGroup = null;
48560
+ }
48340
48561
  const tabAlign = appliedTabAlign;
48341
48562
  if (tabAlign && currentLine && tabAlign.val === "end") {
48342
48563
  currentLine.width = roundValue(tabAlign.target);
@@ -48512,7 +48733,11 @@ async function measureParagraphBlock(block, maxWidth) {
48512
48733
  }
48513
48734
  }
48514
48735
  let segmentStartX;
48515
- if (currentLine && pendingTabAlignment) {
48736
+ let inActiveTabGroup = false;
48737
+ if (activeTabGroup && currentLine) {
48738
+ segmentStartX = activeTabGroup.currentX;
48739
+ inActiveTabGroup = true;
48740
+ } else if (currentLine && pendingTabAlignment) {
48516
48741
  segmentStartX = alignSegmentAtTab(segment, font, run, charPosInRun);
48517
48742
  if (segmentStartX == null) {
48518
48743
  segmentStartX = currentLine.width;
@@ -48549,6 +48774,7 @@ async function measureParagraphBlock(block, maxWidth) {
48549
48774
  tabStopCursor = 0;
48550
48775
  pendingTabAlignment = null;
48551
48776
  lastAppliedTabAlign = null;
48777
+ activeTabGroup = null;
48552
48778
  currentLine = {
48553
48779
  fromRun: runIndex,
48554
48780
  fromChar: spaceStartChar,
@@ -48567,7 +48793,19 @@ async function measureParagraphBlock(block, maxWidth) {
48567
48793
  currentLine.width = roundValue(currentLine.width + boundarySpacing2 + singleSpaceWidth);
48568
48794
  currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run);
48569
48795
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run.fontSize);
48570
- appendSegment(currentLine.segments, runIndex, spaceStartChar, spaceEndChar, singleSpaceWidth);
48796
+ let spaceExplicitX;
48797
+ if (inActiveTabGroup && activeTabGroup) {
48798
+ spaceExplicitX = activeTabGroup.currentX;
48799
+ activeTabGroup.currentX = roundValue(activeTabGroup.currentX + singleSpaceWidth);
48800
+ }
48801
+ appendSegment(
48802
+ currentLine.segments,
48803
+ runIndex,
48804
+ spaceStartChar,
48805
+ spaceEndChar,
48806
+ singleSpaceWidth,
48807
+ spaceExplicitX
48808
+ );
48571
48809
  currentLine.spaceCount += 1;
48572
48810
  }
48573
48811
  }
@@ -48715,7 +48953,7 @@ async function measureParagraphBlock(block, maxWidth) {
48715
48953
  const totalWidthWithWord = currentLine.width + boundarySpacing + wordCommitWidth + // Safe cast: only TextRuns produce word segments from split(), other run types are handled earlier
48716
48954
  (shouldIncludeDelimiterSpace ? run.letterSpacing ?? 0 : 0);
48717
48955
  const availableWidth = currentLine.maxWidth - WIDTH_FUDGE_PX2;
48718
- let shouldBreak = currentLine.width + boundarySpacing + wordOnlyWidth > availableWidth && currentLine.width > 0 && !isTocEntry;
48956
+ let shouldBreak = !inActiveTabGroup && currentLine.width + boundarySpacing + wordOnlyWidth > availableWidth && currentLine.width > 0 && !isTocEntry;
48719
48957
  let compressedWidth = null;
48720
48958
  if (shouldBreak && justifyAlignment) {
48721
48959
  const isLastNonEmptyWordInSegment = wordIndex === lastNonEmptyWordIndex;
@@ -48780,15 +49018,14 @@ async function measureParagraphBlock(block, maxWidth) {
48780
49018
  currentLine.width = roundValue(currentLine.width + boundarySpacing + wordOnlyWidth);
48781
49019
  currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run);
48782
49020
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run.fontSize);
48783
- const useExplicitXHere = wordIndex === 0 && segmentStartX !== void 0;
48784
- appendSegment(
48785
- currentLine.segments,
48786
- runIndex,
48787
- wordStartChar,
48788
- wordEndNoSpace,
48789
- wordOnlyWidth,
48790
- useExplicitXHere ? segmentStartX : void 0
48791
- );
49021
+ let explicitXHere;
49022
+ if (inActiveTabGroup && activeTabGroup) {
49023
+ explicitXHere = activeTabGroup.currentX;
49024
+ activeTabGroup.currentX = roundValue(activeTabGroup.currentX + wordOnlyWidth);
49025
+ } else if (wordIndex === 0 && segmentStartX !== void 0) {
49026
+ explicitXHere = segmentStartX;
49027
+ }
49028
+ appendSegment(currentLine.segments, runIndex, wordStartChar, wordEndNoSpace, wordOnlyWidth, explicitXHere);
48792
49029
  trimTrailingWrapSpaces(currentLine);
48793
49030
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
48794
49031
  const lineBase = currentLine;
@@ -48803,8 +49040,13 @@ async function measureParagraphBlock(block, maxWidth) {
48803
49040
  }
48804
49041
  const newToChar = shouldIncludeDelimiterSpace ? wordEndWithSpace : wordEndNoSpace;
48805
49042
  currentLine.toChar = newToChar;
48806
- const useExplicitX = wordIndex === 0 && segmentStartX !== void 0;
48807
- const explicitX = useExplicitX ? segmentStartX : void 0;
49043
+ let explicitX;
49044
+ if (inActiveTabGroup && activeTabGroup) {
49045
+ explicitX = activeTabGroup.currentX;
49046
+ activeTabGroup.currentX = roundValue(activeTabGroup.currentX + wordCommitWidth);
49047
+ } else if (wordIndex === 0 && segmentStartX !== void 0) {
49048
+ explicitX = segmentStartX;
49049
+ }
48808
49050
  const targetWidth = compressedWidth != null ? compressedWidth : currentLine.width + boundarySpacing + wordCommitWidth + (shouldIncludeDelimiterSpace ? run.letterSpacing ?? 0 : 0);
48809
49051
  if (compressedWidth != null) {
48810
49052
  currentLine.naturalWidth = roundValue(totalWidthWithWord);
@@ -48826,6 +49068,12 @@ async function measureParagraphBlock(block, maxWidth) {
48826
49068
  }
48827
49069
  }
48828
49070
  lastAppliedTabAlign = null;
49071
+ if (activeTabGroup && runIndex + 1 >= activeTabGroup.measure.endRunIndex) {
49072
+ if (currentLine && activeTabGroup.val === "end") {
49073
+ currentLine.width = roundValue(activeTabGroup.target);
49074
+ }
49075
+ activeTabGroup = null;
49076
+ }
48829
49077
  if (!isLastSegment) {
48830
49078
  pendingTabAlignment = null;
48831
49079
  if (!currentLine) {
@@ -51259,6 +51507,17 @@ class PresentationEditor extends EventEmitter {
51259
51507
  event: "collaborationReady",
51260
51508
  handler: handleCollaborationReady
51261
51509
  });
51510
+ const handleRemoteHeaderFooterChanged = (payload) => {
51511
+ this.#headerFooterAdapter?.invalidate(payload.sectionId);
51512
+ this.#headerFooterManager?.refresh();
51513
+ this.#pendingDocChange = true;
51514
+ this.#scheduleRerender();
51515
+ };
51516
+ this.#editor.on("remoteHeaderFooterChanged", handleRemoteHeaderFooterChanged);
51517
+ this.#editorListeners.push({
51518
+ event: "remoteHeaderFooterChanged",
51519
+ handler: handleRemoteHeaderFooterChanged
51520
+ });
51262
51521
  }
51263
51522
  /**
51264
51523
  * Setup awareness event subscriptions for remote cursor tracking.