@harbour-enterprises/superdoc 1.3.1-next.1 → 1.3.1-next.3

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-BmwaXglr.cjs");
5
- const index = require("./index-Ccw24rQt.cjs");
4
+ const superdoc = require("./index-BQYtE-5U.cjs");
5
+ const index = require("./index-DLX_v-vr.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-IUXq0EQx.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-DZF2SDeC.es.js";
2
+ import { N as NBaseLoading, u as useSuperdocStore, s as storeToRefs, a as useSelection } from "./index-DXSUcHli.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-CJec1cbb.es.js";
4
4
  function self(vars) {
5
5
  const {
6
6
  opacityDisabled,
@@ -30414,9 +30414,10 @@ const updateCommentsXml = (commentDefs = [], commentsXml) => {
30414
30414
  const updateCommentsExtendedXml = (comments = [], commentsExtendedXml) => {
30415
30415
  const xmlCopy = carbonCopy(commentsExtendedXml);
30416
30416
  const commentsEx = comments.map((comment) => {
30417
+ const isResolved = comment.resolvedTime || comment.isDone;
30417
30418
  const attributes = {
30418
30419
  "w15:paraId": comment.commentParaId,
30419
- "w15:done": comment.resolvedTime ? "1" : "0"
30420
+ "w15:done": isResolved ? "1" : "0"
30420
30421
  };
30421
30422
  const parentId = comment.parentCommentId;
30422
30423
  if (parentId) {
@@ -31007,7 +31008,7 @@ class SuperConverter {
31007
31008
  static getStoredSuperdocVersion(docx) {
31008
31009
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
31009
31010
  }
31010
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.1-next.1") {
31011
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.1-next.3") {
31011
31012
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
31012
31013
  }
31013
31014
  /**
@@ -30415,9 +30415,10 @@ const updateCommentsXml = (commentDefs = [], commentsXml) => {
30415
30415
  const updateCommentsExtendedXml = (comments = [], commentsExtendedXml) => {
30416
30416
  const xmlCopy = carbonCopy(commentsExtendedXml);
30417
30417
  const commentsEx = comments.map((comment) => {
30418
+ const isResolved = comment.resolvedTime || comment.isDone;
30418
30419
  const attributes = {
30419
30420
  "w15:paraId": comment.commentParaId,
30420
- "w15:done": comment.resolvedTime ? "1" : "0"
30421
+ "w15:done": isResolved ? "1" : "0"
30421
30422
  };
30422
30423
  const parentId = comment.parentCommentId;
30423
30424
  if (parentId) {
@@ -31008,7 +31009,7 @@ class SuperConverter {
31008
31009
  static getStoredSuperdocVersion(docx) {
31009
31010
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
31010
31011
  }
31011
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.1-next.1") {
31012
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.1-next.3") {
31012
31013
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
31013
31014
  }
31014
31015
  /**
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- const index = require("./index-Ccw24rQt.cjs");
3
- require("./SuperConverter-rwP6nlvC.cjs");
2
+ const index = require("./index-DLX_v-vr.cjs");
3
+ require("./SuperConverter-p1tQGIew.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");
@@ -6217,12 +6217,13 @@ const _sfc_main$c = {
6217
6217
  return currentCommentText.value && currentCommentText.value !== "<p></p>";
6218
6218
  });
6219
6219
  const setFocus = () => {
6220
- if (props.comment.resolvedTime) return;
6221
6220
  const editor = proxy.$superdoc.activeEditor;
6222
- activeComment.value = props.comment.commentId;
6223
- props.comment.setActive(proxy.$superdoc);
6221
+ if (!props.comment.resolvedTime) {
6222
+ activeComment.value = props.comment.commentId;
6223
+ props.comment.setActive(proxy.$superdoc);
6224
+ }
6224
6225
  if (editor) {
6225
- const cursorId = props.comment.importedId || props.comment.commentId;
6226
+ const cursorId = props.comment.resolvedTime ? props.comment.commentId : props.comment.importedId || props.comment.commentId;
6226
6227
  editor.commands?.setCursorById(cursorId);
6227
6228
  }
6228
6229
  };
@@ -6458,7 +6459,7 @@ const _sfc_main$c = {
6458
6459
  };
6459
6460
  }
6460
6461
  };
6461
- const CommentDialog = /* @__PURE__ */ index._export_sfc(_sfc_main$c, [["__scopeId", "data-v-dc2a79b5"]]);
6462
+ const CommentDialog = /* @__PURE__ */ index._export_sfc(_sfc_main$c, [["__scopeId", "data-v-d50fd675"]]);
6462
6463
  const _hoisted_1$a = { class: "comments-list" };
6463
6464
  const _hoisted_2$5 = { key: 0 };
6464
6465
  const _hoisted_3$3 = { class: "comment-item" };
@@ -7465,7 +7466,7 @@ const _sfc_main = {
7465
7466
  __name: "SuperDoc",
7466
7467
  emits: ["selection-update"],
7467
7468
  setup(__props, { emit: __emit }) {
7468
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-B1rqV4Hp.cjs")));
7469
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-BXbmY3Fc.cjs")));
7469
7470
  const superdocStore = useSuperdocStore();
7470
7471
  const commentsStore = useCommentsStore();
7471
7472
  const {
@@ -8394,7 +8395,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
8394
8395
  this.config.colors = shuffleArray(this.config.colors);
8395
8396
  this.userColorMap = /* @__PURE__ */ new Map();
8396
8397
  this.colorIndex = 0;
8397
- this.version = "1.3.1-next.1";
8398
+ this.version = "1.3.1-next.3";
8398
8399
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8399
8400
  this.superdocId = config.superdocId || uuid.v4();
8400
8401
  this.colors = this.config.colors;
@@ -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 combineIndentProperties, a4 as _getReferencedTableStyles, a5 as decodeRPrFromMarks, a6 as calculateResolvedParagraphProperties, a7 as encodeCSSFromPPr, a8 as encodeCSSFromRPr, a9 as generateOrderedListIndex, aa as docxNumberingHelpers, ab as InputRule, ac as insertNewRelationship, ad as kebabCase$1, ae as getUnderlineCssString } from "./SuperConverter-AxPNFosS.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 combineIndentProperties, a4 as _getReferencedTableStyles, a5 as decodeRPrFromMarks, a6 as calculateResolvedParagraphProperties, a7 as encodeCSSFromPPr, a8 as encodeCSSFromRPr, a9 as generateOrderedListIndex, aa as docxNumberingHelpers, ab as InputRule, ac as insertNewRelationship, ad as kebabCase$1, ae as getUnderlineCssString } from "./SuperConverter-BQ6PNaJ8.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";
@@ -13542,6 +13542,12 @@ function findRangeById(doc2, id) {
13542
13542
  if (from3 === null || pos < from3) from3 = pos;
13543
13543
  if (to === null || pos + node.nodeSize > to) to = pos + node.nodeSize;
13544
13544
  }
13545
+ if (node.type.name === "commentRangeStart" && node.attrs["w:id"] === id) {
13546
+ from3 = pos;
13547
+ }
13548
+ if (node.type.name === "commentRangeEnd" && node.attrs["w:id"] === id) {
13549
+ to = pos;
13550
+ }
13545
13551
  });
13546
13552
  return from3 !== null && to !== null ? { from: from3, to } : null;
13547
13553
  }
@@ -15434,7 +15440,7 @@ const canUseDOM = () => {
15434
15440
  return false;
15435
15441
  }
15436
15442
  };
15437
- const summaryVersion = "1.3.1-next.1";
15443
+ const summaryVersion = "1.3.1-next.3";
15438
15444
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15439
15445
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15440
15446
  function mapAttributes(attrs) {
@@ -18066,7 +18072,7 @@ class Editor extends EventEmitter {
18066
18072
  * Process collaboration migrations
18067
18073
  */
18068
18074
  processCollaborationMigrations() {
18069
- console.debug("[checkVersionMigrations] Current editor version", "1.3.1-next.1");
18075
+ console.debug("[checkVersionMigrations] Current editor version", "1.3.1-next.3");
18070
18076
  if (!this.options.ydoc) return;
18071
18077
  const metaMap = this.options.ydoc.getMap("meta");
18072
18078
  let docVersion = metaMap.get("version");
@@ -25080,6 +25086,7 @@ class DomPainter {
25080
25086
  this.layoutVersion = 0;
25081
25087
  this.layoutEpoch = 0;
25082
25088
  this.processedLayoutVersion = -1;
25089
+ this.currentMapping = null;
25083
25090
  this.onScrollHandler = null;
25084
25091
  this.onWindowScrollHandler = null;
25085
25092
  this.onResizeHandler = null;
@@ -25185,7 +25192,7 @@ class DomPainter {
25185
25192
  this.blockLookup = nextLookup;
25186
25193
  this.changedBlocks = changed;
25187
25194
  }
25188
- paint(layout, mount2) {
25195
+ paint(layout, mount2, mapping) {
25189
25196
  if (!(mount2 instanceof HTMLElement)) {
25190
25197
  throw new Error("DomPainter.paint requires a valid HTMLElement mount");
25191
25198
  }
@@ -25194,6 +25201,13 @@ class DomPainter {
25194
25201
  throw new Error("DomPainter.paint requires a DOM-like document");
25195
25202
  }
25196
25203
  this.doc = doc2;
25204
+ const isSimpleTransaction = mapping && mapping.maps.length === 1;
25205
+ if (mapping && !isSimpleTransaction) {
25206
+ this.blockLookup.forEach((_, id) => this.changedBlocks.add(id));
25207
+ this.currentMapping = null;
25208
+ } else {
25209
+ this.currentMapping = mapping ?? null;
25210
+ }
25197
25211
  ensurePrintStyles(doc2);
25198
25212
  ensureLinkStyles(doc2);
25199
25213
  ensureTrackChangeStyles(doc2);
@@ -25220,6 +25234,7 @@ class DomPainter {
25220
25234
  this.currentLayout = layout;
25221
25235
  this.pageStates = [];
25222
25236
  this.changedBlocks.clear();
25237
+ this.currentMapping = null;
25223
25238
  return;
25224
25239
  }
25225
25240
  if (mode === "book") {
@@ -25228,6 +25243,7 @@ class DomPainter {
25228
25243
  this.currentLayout = layout;
25229
25244
  this.pageStates = [];
25230
25245
  this.changedBlocks.clear();
25246
+ this.currentMapping = null;
25231
25247
  return;
25232
25248
  }
25233
25249
  applyStyles$2(mount2, containerStyles);
@@ -25236,6 +25252,7 @@ class DomPainter {
25236
25252
  this.renderVirtualized(layout, mount2);
25237
25253
  this.currentLayout = layout;
25238
25254
  this.changedBlocks.clear();
25255
+ this.currentMapping = null;
25239
25256
  return;
25240
25257
  }
25241
25258
  mount2.style.gap = `${this.pageGap}px`;
@@ -25246,6 +25263,7 @@ class DomPainter {
25246
25263
  }
25247
25264
  this.currentLayout = layout;
25248
25265
  this.changedBlocks.clear();
25266
+ this.currentMapping = null;
25249
25267
  }
25250
25268
  // ----------------
25251
25269
  // Virtualized path
@@ -25777,6 +25795,8 @@ class DomPainter {
25777
25795
  pageEl.replaceChild(replacement, current.element);
25778
25796
  current.element = replacement;
25779
25797
  current.signature = fragmentSignature(fragment, this.blockLookup);
25798
+ } else if (this.currentMapping) {
25799
+ this.updatePositionAttributes(current.element, this.currentMapping);
25780
25800
  }
25781
25801
  this.updateFragmentElement(current.element, fragment, contextBase.section);
25782
25802
  current.fragment = fragment;
@@ -25805,6 +25825,45 @@ class DomPainter {
25805
25825
  state.fragments = nextFragments;
25806
25826
  this.renderDecorationsForPage(pageEl, page);
25807
25827
  }
25828
+ /**
25829
+ * Updates data-pm-start/data-pm-end attributes on all elements within a fragment
25830
+ * using the transaction's mapping. Skips header/footer content (separate PM coordinate space).
25831
+ * Also skips fragments that end before the edit point (their positions don't change).
25832
+ */
25833
+ updatePositionAttributes(fragmentEl, mapping) {
25834
+ if (fragmentEl.closest(".superdoc-page-header, .superdoc-page-footer")) {
25835
+ return;
25836
+ }
25837
+ try {
25838
+ const fragEnd = fragmentEl.dataset.pmEnd;
25839
+ if (fragEnd !== void 0 && fragEnd !== "") {
25840
+ const endNum = Number(fragEnd);
25841
+ if (Number.isFinite(endNum) && mapping.map(endNum, -1) === endNum) {
25842
+ return;
25843
+ }
25844
+ }
25845
+ const elements = fragmentEl.querySelectorAll("[data-pm-start], [data-pm-end]");
25846
+ const allElements = [fragmentEl, ...Array.from(elements)];
25847
+ for (const el of allElements) {
25848
+ const oldStart = el.dataset.pmStart;
25849
+ const oldEnd = el.dataset.pmEnd;
25850
+ if (oldStart !== void 0 && oldStart !== "") {
25851
+ const num = Number(oldStart);
25852
+ if (Number.isFinite(num)) {
25853
+ el.dataset.pmStart = String(mapping.map(num));
25854
+ }
25855
+ }
25856
+ if (oldEnd !== void 0 && oldEnd !== "") {
25857
+ const num = Number(oldEnd);
25858
+ if (Number.isFinite(num)) {
25859
+ el.dataset.pmEnd = String(mapping.map(num, -1));
25860
+ }
25861
+ }
25862
+ }
25863
+ } catch (error) {
25864
+ console.error("Error updating position attributes with mapping:", error);
25865
+ }
25866
+ }
25808
25867
  createPageState(page, pageSize) {
25809
25868
  if (!this.doc) {
25810
25869
  throw new Error("DomPainter.createPageState requires a document");
@@ -28182,8 +28241,6 @@ const fragmentSignature = (fragment, lookup) => {
28182
28241
  base2,
28183
28242
  fragment.fromLine,
28184
28243
  fragment.toLine,
28185
- fragment.pmStart ?? "",
28186
- fragment.pmEnd ?? "",
28187
28244
  fragment.continuesFromPrev ? 1 : 0,
28188
28245
  fragment.continuesOnNext ? 1 : 0,
28189
28246
  fragment.markerWidth ?? ""
@@ -28275,16 +28332,15 @@ const deriveBlockVersion = (block) => {
28275
28332
  imgRun.distTop ?? "",
28276
28333
  imgRun.distBottom ?? "",
28277
28334
  imgRun.distLeft ?? "",
28278
- imgRun.distRight ?? "",
28279
- imgRun.pmStart ?? "",
28280
- imgRun.pmEnd ?? ""
28335
+ imgRun.distRight ?? ""
28336
+ // Note: pmStart/pmEnd intentionally excluded to prevent O(n) change detection
28281
28337
  ].join(",");
28282
28338
  }
28283
28339
  if (run.kind === "lineBreak") {
28284
- return ["linebreak", run.pmStart ?? "", run.pmEnd ?? ""].join(",");
28340
+ return "linebreak";
28285
28341
  }
28286
28342
  if (run.kind === "tab") {
28287
- return [run.text ?? "", "tab", run.pmStart ?? "", run.pmEnd ?? ""].join(",");
28343
+ return [run.text ?? "", "tab"].join(",");
28288
28344
  }
28289
28345
  const textRun = run;
28290
28346
  return [
@@ -28300,8 +28356,7 @@ const deriveBlockVersion = (block) => {
28300
28356
  textRun.strike ? 1 : 0,
28301
28357
  textRun.highlight ?? "",
28302
28358
  textRun.letterSpacing != null ? textRun.letterSpacing : "",
28303
- textRun.pmStart ?? "",
28304
- textRun.pmEnd ?? "",
28359
+ // Note: pmStart/pmEnd intentionally excluded to prevent O(n) change detection
28305
28360
  textRun.token ?? "",
28306
28361
  // Tracked changes - force re-render when added or removed tracked change
28307
28362
  textRun.trackedChange ? 1 : 0,
@@ -28760,8 +28815,8 @@ const createDomPainter = (options) => {
28760
28815
  ruler: options.ruler
28761
28816
  });
28762
28817
  return {
28763
- paint(layout, mount2) {
28764
- painter.paint(layout, mount2);
28818
+ paint(layout, mount2, mapping) {
28819
+ painter.paint(layout, mount2, mapping);
28765
28820
  },
28766
28821
  setData(blocks, measures, headerBlocks, headerMeasures, footerBlocks, footerMeasures) {
28767
28822
  painter.setData(blocks, measures, headerBlocks, headerMeasures, footerBlocks, footerMeasures);
@@ -31627,8 +31682,15 @@ function layoutParagraphBlock(ctx2, anchors) {
31627
31682
  } else if (vRelativeFrom === "paragraph") {
31628
31683
  const baseAnchorY = state.cursorY;
31629
31684
  const firstLineHeight = measure.lines?.[0]?.lineHeight ?? 0;
31630
- const paragraphAdjustment = firstLineHeight / 2;
31631
- anchorY = baseAnchorY + paragraphAdjustment + offsetV;
31685
+ if (alignV === "top") {
31686
+ anchorY = baseAnchorY + offsetV;
31687
+ } else if (alignV === "bottom") {
31688
+ anchorY = baseAnchorY + firstLineHeight - imageHeight + offsetV;
31689
+ } else if (alignV === "center") {
31690
+ anchorY = baseAnchorY + (firstLineHeight - imageHeight) / 2 + offsetV;
31691
+ } else {
31692
+ anchorY = baseAnchorY + offsetV;
31693
+ }
31632
31694
  } else {
31633
31695
  const baseAnchorY = state.cursorY;
31634
31696
  anchorY = baseAnchorY + offsetV;
@@ -32689,6 +32751,13 @@ function collectPreRegisteredAnchors(blocks, measures) {
32689
32751
  function collectAnchoredDrawings(blocks, measures) {
32690
32752
  const map3 = /* @__PURE__ */ new Map();
32691
32753
  const len = Math.min(blocks.length, measures.length);
32754
+ const paragraphIndexById = /* @__PURE__ */ new Map();
32755
+ for (let i = 0; i < len; i += 1) {
32756
+ const block = blocks[i];
32757
+ if (block.kind === "paragraph") {
32758
+ paragraphIndexById.set(block.id, i);
32759
+ }
32760
+ }
32692
32761
  const nearestPrevParagraph = (fromIndex) => {
32693
32762
  for (let i = fromIndex - 1; i >= 0; i -= 1) {
32694
32763
  if (blocks[i].kind === "paragraph") return i;
@@ -32715,7 +32784,11 @@ function collectAnchoredDrawings(blocks, measures) {
32715
32784
  if (isPageRelativeAnchor(drawingBlock)) {
32716
32785
  continue;
32717
32786
  }
32718
- let anchorParaIndex = nearestPrevParagraph(i);
32787
+ const anchorParagraphId = typeof drawingBlock.attrs === "object" && drawingBlock.attrs ? drawingBlock.attrs.anchorParagraphId : void 0;
32788
+ let anchorParaIndex = typeof anchorParagraphId === "string" ? paragraphIndexById.get(anchorParagraphId) ?? null : null;
32789
+ if (anchorParaIndex == null) {
32790
+ anchorParaIndex = nearestPrevParagraph(i);
32791
+ }
32719
32792
  if (anchorParaIndex == null) anchorParaIndex = nearestNextParagraph(i);
32720
32793
  if (anchorParaIndex == null) continue;
32721
32794
  const list = map3.get(anchorParaIndex) ?? [];
@@ -32726,6 +32799,13 @@ function collectAnchoredDrawings(blocks, measures) {
32726
32799
  }
32727
32800
  function collectAnchoredTables(blocks, measures) {
32728
32801
  const map3 = /* @__PURE__ */ new Map();
32802
+ const paragraphIndexById = /* @__PURE__ */ new Map();
32803
+ for (let i = 0; i < blocks.length; i += 1) {
32804
+ const block = blocks[i];
32805
+ if (block.kind === "paragraph") {
32806
+ paragraphIndexById.set(block.id, i);
32807
+ }
32808
+ }
32729
32809
  const nearestPrevParagraph = (fromIndex) => {
32730
32810
  for (let i = fromIndex - 1; i >= 0; i -= 1) {
32731
32811
  if (blocks[i].kind === "paragraph") return i;
@@ -32745,7 +32825,11 @@ function collectAnchoredTables(blocks, measures) {
32745
32825
  const tableBlock = block;
32746
32826
  const tableMeasure = measure;
32747
32827
  if (!tableBlock.anchor?.isAnchored) continue;
32748
- let anchorParaIndex = nearestPrevParagraph(i);
32828
+ const anchorParagraphId = typeof tableBlock.attrs === "object" && tableBlock.attrs ? tableBlock.attrs.anchorParagraphId : void 0;
32829
+ let anchorParaIndex = typeof anchorParagraphId === "string" ? paragraphIndexById.get(anchorParagraphId) ?? null : null;
32830
+ if (anchorParaIndex == null) {
32831
+ anchorParaIndex = nearestPrevParagraph(i);
32832
+ }
32749
32833
  if (anchorParaIndex == null) anchorParaIndex = nearestNextParagraph(i);
32750
32834
  if (anchorParaIndex == null) continue;
32751
32835
  const list = map3.get(anchorParaIndex) ?? [];
@@ -45147,6 +45231,20 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45147
45231
  let partIndex = 0;
45148
45232
  let tabOrdinal = 0;
45149
45233
  const nextId = () => partIndex === 0 ? baseBlockId : `${baseBlockId}-${partIndex}`;
45234
+ const attachAnchorParagraphId = (block, anchorParagraphId) => {
45235
+ const applicableKinds = /* @__PURE__ */ new Set(["drawing", "image", "table"]);
45236
+ if (!applicableKinds.has(block.kind)) {
45237
+ return block;
45238
+ }
45239
+ const blockWithAttrs = block;
45240
+ return {
45241
+ ...blockWithAttrs,
45242
+ attrs: {
45243
+ ...blockWithAttrs.attrs ?? {},
45244
+ anchorParagraphId
45245
+ }
45246
+ };
45247
+ };
45150
45248
  const flushParagraph = () => {
45151
45249
  if (currentRuns.length === 0) {
45152
45250
  return;
@@ -45378,6 +45476,7 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45378
45476
  }
45379
45477
  return;
45380
45478
  }
45479
+ const anchorParagraphId = nextId();
45381
45480
  flushParagraph();
45382
45481
  const mergedMarks = [...node.marks ?? [], ...inheritedMarks ?? []];
45383
45482
  const trackedMeta = trackedChanges?.enabled ? collectTrackedChangeFromMarks(mergedMarks) : void 0;
@@ -45388,7 +45487,7 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45388
45487
  const imageBlock = converters.imageNodeToBlock(node, nextBlockId, positions, trackedMeta, trackedChanges);
45389
45488
  if (imageBlock && imageBlock.kind === "image") {
45390
45489
  annotateBlockWithTrackedChange(imageBlock, trackedMeta, trackedChanges);
45391
- blocks.push(imageBlock);
45490
+ blocks.push(attachAnchorParagraphId(imageBlock, anchorParagraphId));
45392
45491
  }
45393
45492
  }
45394
45493
  return;
@@ -45396,6 +45495,7 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45396
45495
  if (node.type === "contentBlock") {
45397
45496
  const attrs = node.attrs ?? {};
45398
45497
  if (attrs.horizontalRule === true) {
45498
+ const anchorParagraphId = nextId();
45399
45499
  flushParagraph();
45400
45500
  const indent = paragraphAttrs?.indent;
45401
45501
  const hrIndentLeft = typeof indent?.left === "number" ? indent.left : void 0;
@@ -45405,52 +45505,57 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45405
45505
  const convert = converters?.contentBlockNodeToDrawingBlock ?? contentBlockNodeToDrawingBlock;
45406
45506
  const drawingBlock = convert(hrNode, nextBlockId, positions);
45407
45507
  if (drawingBlock) {
45408
- blocks.push(drawingBlock);
45508
+ blocks.push(attachAnchorParagraphId(drawingBlock, anchorParagraphId));
45409
45509
  }
45410
45510
  }
45411
45511
  return;
45412
45512
  }
45413
45513
  if (node.type === "vectorShape") {
45514
+ const anchorParagraphId = nextId();
45414
45515
  flushParagraph();
45415
45516
  if (converters?.vectorShapeNodeToDrawingBlock) {
45416
45517
  const drawingBlock = converters.vectorShapeNodeToDrawingBlock(node, nextBlockId, positions);
45417
45518
  if (drawingBlock) {
45418
- blocks.push(drawingBlock);
45519
+ blocks.push(attachAnchorParagraphId(drawingBlock, anchorParagraphId));
45419
45520
  }
45420
45521
  }
45421
45522
  return;
45422
45523
  }
45423
45524
  if (node.type === "shapeGroup") {
45525
+ const anchorParagraphId = nextId();
45424
45526
  flushParagraph();
45425
45527
  if (converters?.shapeGroupNodeToDrawingBlock) {
45426
45528
  const drawingBlock = converters.shapeGroupNodeToDrawingBlock(node, nextBlockId, positions);
45427
45529
  if (drawingBlock) {
45428
- blocks.push(drawingBlock);
45530
+ blocks.push(attachAnchorParagraphId(drawingBlock, anchorParagraphId));
45429
45531
  }
45430
45532
  }
45431
45533
  return;
45432
45534
  }
45433
45535
  if (node.type === "shapeContainer") {
45536
+ const anchorParagraphId = nextId();
45434
45537
  flushParagraph();
45435
45538
  if (converters?.shapeContainerNodeToDrawingBlock) {
45436
45539
  const drawingBlock = converters.shapeContainerNodeToDrawingBlock(node, nextBlockId, positions);
45437
45540
  if (drawingBlock) {
45438
- blocks.push(drawingBlock);
45541
+ blocks.push(attachAnchorParagraphId(drawingBlock, anchorParagraphId));
45439
45542
  }
45440
45543
  }
45441
45544
  return;
45442
45545
  }
45443
45546
  if (node.type === "shapeTextbox") {
45547
+ const anchorParagraphId = nextId();
45444
45548
  flushParagraph();
45445
45549
  if (converters?.shapeTextboxNodeToDrawingBlock) {
45446
45550
  const drawingBlock = converters.shapeTextboxNodeToDrawingBlock(node, nextBlockId, positions);
45447
45551
  if (drawingBlock) {
45448
- blocks.push(drawingBlock);
45552
+ blocks.push(attachAnchorParagraphId(drawingBlock, anchorParagraphId));
45449
45553
  }
45450
45554
  }
45451
45555
  return;
45452
45556
  }
45453
45557
  if (node.type === "table") {
45558
+ const anchorParagraphId = nextId();
45454
45559
  flushParagraph();
45455
45560
  if (converters?.tableNodeToBlock) {
45456
45561
  const tableBlock = converters.tableNodeToBlock(
@@ -45467,7 +45572,7 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
45467
45572
  ...converterContext !== void 0 ? [converterContext] : []
45468
45573
  );
45469
45574
  if (tableBlock) {
45470
- blocks.push(tableBlock);
45575
+ blocks.push(attachAnchorParagraphId(tableBlock, anchorParagraphId));
45471
45576
  }
45472
45577
  }
45473
45578
  return;
@@ -50221,6 +50326,7 @@ class PresentationEditor extends EventEmitter {
50221
50326
  #telemetryEmitter = null;
50222
50327
  #renderScheduled = false;
50223
50328
  #pendingDocChange = false;
50329
+ #pendingMapping = null;
50224
50330
  #isRerendering = false;
50225
50331
  #selectionSync = new SelectionSyncCoordinator();
50226
50332
  #remoteCursorUpdateScheduled = false;
@@ -51828,6 +51934,15 @@ class PresentationEditor extends EventEmitter {
51828
51934
  }
51829
51935
  if (trackedChangesChanged || transaction?.docChanged) {
51830
51936
  this.#pendingDocChange = true;
51937
+ if (transaction?.docChanged) {
51938
+ if (this.#pendingMapping !== null) {
51939
+ const combined = this.#pendingMapping.slice();
51940
+ combined.appendMapping(transaction.mapping);
51941
+ this.#pendingMapping = combined;
51942
+ } else {
51943
+ this.#pendingMapping = transaction.mapping;
51944
+ }
51945
+ }
51831
51946
  this.#selectionSync.onLayoutStart();
51832
51947
  this.#scheduleRerender();
51833
51948
  }
@@ -53420,7 +53535,9 @@ class PresentationEditor extends EventEmitter {
53420
53535
  footerMeasures.length > 0 ? footerMeasures : void 0
53421
53536
  );
53422
53537
  this.#domIndexObserverManager?.pause();
53423
- painter.paint(layout, this.#painterHost);
53538
+ const mapping = this.#pendingMapping;
53539
+ this.#pendingMapping = null;
53540
+ painter.paint(layout, this.#painterHost, mapping ?? void 0);
53424
53541
  this.#applyVertAlignToLayout();
53425
53542
  this.#rebuildDomPositionIndex();
53426
53543
  this.#domIndexObserverManager?.resume();