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

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-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-Dp7mSzy1.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-SYGYHKb5.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-BmwaXglr.cjs");
5
- const index = require("./index-Ccw24rQt.cjs");
4
+ const superdoc = require("./index-DWfzQ0RN.cjs");
5
+ const index = require("./index-BjQU1XSp.cjs");
6
6
  function self(vars) {
7
7
  const {
8
8
  opacityDisabled,
@@ -31007,7 +31007,7 @@ class SuperConverter {
31007
31007
  static getStoredSuperdocVersion(docx) {
31008
31008
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
31009
31009
  }
31010
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.1-next.1") {
31010
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.1-next.2") {
31011
31011
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
31012
31012
  }
31013
31013
  /**
@@ -31008,7 +31008,7 @@ class SuperConverter {
31008
31008
  static getStoredSuperdocVersion(docx) {
31009
31009
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
31010
31010
  }
31011
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.1-next.1") {
31011
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.1-next.2") {
31012
31012
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
31013
31013
  }
31014
31014
  /**
@@ -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-rwP6nlvC.cjs");
4
+ const superEditor_converter = require("./SuperConverter-Cu6cvHlN.cjs");
5
5
  const vue = require("./vue-De9wkgLl.cjs");
6
6
  require("./jszip.min-BPh2MMAa.cjs");
7
7
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
@@ -15451,7 +15451,7 @@ const canUseDOM = () => {
15451
15451
  return false;
15452
15452
  }
15453
15453
  };
15454
- const summaryVersion = "1.3.1-next.1";
15454
+ const summaryVersion = "1.3.1-next.2";
15455
15455
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15456
15456
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15457
15457
  function mapAttributes(attrs) {
@@ -18083,7 +18083,7 @@ class Editor extends EventEmitter {
18083
18083
  * Process collaboration migrations
18084
18084
  */
18085
18085
  processCollaborationMigrations() {
18086
- console.debug("[checkVersionMigrations] Current editor version", "1.3.1-next.1");
18086
+ console.debug("[checkVersionMigrations] Current editor version", "1.3.1-next.2");
18087
18087
  if (!this.options.ydoc) return;
18088
18088
  const metaMap = this.options.ydoc.getMap("meta");
18089
18089
  let docVersion = metaMap.get("version");
@@ -25097,6 +25097,7 @@ class DomPainter {
25097
25097
  this.layoutVersion = 0;
25098
25098
  this.layoutEpoch = 0;
25099
25099
  this.processedLayoutVersion = -1;
25100
+ this.currentMapping = null;
25100
25101
  this.onScrollHandler = null;
25101
25102
  this.onWindowScrollHandler = null;
25102
25103
  this.onResizeHandler = null;
@@ -25202,7 +25203,7 @@ class DomPainter {
25202
25203
  this.blockLookup = nextLookup;
25203
25204
  this.changedBlocks = changed;
25204
25205
  }
25205
- paint(layout, mount2) {
25206
+ paint(layout, mount2, mapping) {
25206
25207
  if (!(mount2 instanceof HTMLElement)) {
25207
25208
  throw new Error("DomPainter.paint requires a valid HTMLElement mount");
25208
25209
  }
@@ -25211,6 +25212,13 @@ class DomPainter {
25211
25212
  throw new Error("DomPainter.paint requires a DOM-like document");
25212
25213
  }
25213
25214
  this.doc = doc2;
25215
+ const isSimpleTransaction = mapping && mapping.maps.length === 1;
25216
+ if (mapping && !isSimpleTransaction) {
25217
+ this.blockLookup.forEach((_, id) => this.changedBlocks.add(id));
25218
+ this.currentMapping = null;
25219
+ } else {
25220
+ this.currentMapping = mapping ?? null;
25221
+ }
25214
25222
  ensurePrintStyles(doc2);
25215
25223
  ensureLinkStyles(doc2);
25216
25224
  ensureTrackChangeStyles(doc2);
@@ -25237,6 +25245,7 @@ class DomPainter {
25237
25245
  this.currentLayout = layout;
25238
25246
  this.pageStates = [];
25239
25247
  this.changedBlocks.clear();
25248
+ this.currentMapping = null;
25240
25249
  return;
25241
25250
  }
25242
25251
  if (mode === "book") {
@@ -25245,6 +25254,7 @@ class DomPainter {
25245
25254
  this.currentLayout = layout;
25246
25255
  this.pageStates = [];
25247
25256
  this.changedBlocks.clear();
25257
+ this.currentMapping = null;
25248
25258
  return;
25249
25259
  }
25250
25260
  applyStyles$2(mount2, containerStyles);
@@ -25253,6 +25263,7 @@ class DomPainter {
25253
25263
  this.renderVirtualized(layout, mount2);
25254
25264
  this.currentLayout = layout;
25255
25265
  this.changedBlocks.clear();
25266
+ this.currentMapping = null;
25256
25267
  return;
25257
25268
  }
25258
25269
  mount2.style.gap = `${this.pageGap}px`;
@@ -25263,6 +25274,7 @@ class DomPainter {
25263
25274
  }
25264
25275
  this.currentLayout = layout;
25265
25276
  this.changedBlocks.clear();
25277
+ this.currentMapping = null;
25266
25278
  }
25267
25279
  // ----------------
25268
25280
  // Virtualized path
@@ -25794,6 +25806,8 @@ class DomPainter {
25794
25806
  pageEl.replaceChild(replacement, current.element);
25795
25807
  current.element = replacement;
25796
25808
  current.signature = fragmentSignature(fragment, this.blockLookup);
25809
+ } else if (this.currentMapping) {
25810
+ this.updatePositionAttributes(current.element, this.currentMapping);
25797
25811
  }
25798
25812
  this.updateFragmentElement(current.element, fragment, contextBase.section);
25799
25813
  current.fragment = fragment;
@@ -25822,6 +25836,45 @@ class DomPainter {
25822
25836
  state.fragments = nextFragments;
25823
25837
  this.renderDecorationsForPage(pageEl, page);
25824
25838
  }
25839
+ /**
25840
+ * Updates data-pm-start/data-pm-end attributes on all elements within a fragment
25841
+ * using the transaction's mapping. Skips header/footer content (separate PM coordinate space).
25842
+ * Also skips fragments that end before the edit point (their positions don't change).
25843
+ */
25844
+ updatePositionAttributes(fragmentEl, mapping) {
25845
+ if (fragmentEl.closest(".superdoc-page-header, .superdoc-page-footer")) {
25846
+ return;
25847
+ }
25848
+ try {
25849
+ const fragEnd = fragmentEl.dataset.pmEnd;
25850
+ if (fragEnd !== void 0 && fragEnd !== "") {
25851
+ const endNum = Number(fragEnd);
25852
+ if (Number.isFinite(endNum) && mapping.map(endNum, -1) === endNum) {
25853
+ return;
25854
+ }
25855
+ }
25856
+ const elements = fragmentEl.querySelectorAll("[data-pm-start], [data-pm-end]");
25857
+ const allElements = [fragmentEl, ...Array.from(elements)];
25858
+ for (const el of allElements) {
25859
+ const oldStart = el.dataset.pmStart;
25860
+ const oldEnd = el.dataset.pmEnd;
25861
+ if (oldStart !== void 0 && oldStart !== "") {
25862
+ const num = Number(oldStart);
25863
+ if (Number.isFinite(num)) {
25864
+ el.dataset.pmStart = String(mapping.map(num));
25865
+ }
25866
+ }
25867
+ if (oldEnd !== void 0 && oldEnd !== "") {
25868
+ const num = Number(oldEnd);
25869
+ if (Number.isFinite(num)) {
25870
+ el.dataset.pmEnd = String(mapping.map(num, -1));
25871
+ }
25872
+ }
25873
+ }
25874
+ } catch (error) {
25875
+ console.error("Error updating position attributes with mapping:", error);
25876
+ }
25877
+ }
25825
25878
  createPageState(page, pageSize) {
25826
25879
  if (!this.doc) {
25827
25880
  throw new Error("DomPainter.createPageState requires a document");
@@ -28199,8 +28252,6 @@ const fragmentSignature = (fragment, lookup) => {
28199
28252
  base2,
28200
28253
  fragment.fromLine,
28201
28254
  fragment.toLine,
28202
- fragment.pmStart ?? "",
28203
- fragment.pmEnd ?? "",
28204
28255
  fragment.continuesFromPrev ? 1 : 0,
28205
28256
  fragment.continuesOnNext ? 1 : 0,
28206
28257
  fragment.markerWidth ?? ""
@@ -28292,16 +28343,15 @@ const deriveBlockVersion = (block) => {
28292
28343
  imgRun.distTop ?? "",
28293
28344
  imgRun.distBottom ?? "",
28294
28345
  imgRun.distLeft ?? "",
28295
- imgRun.distRight ?? "",
28296
- imgRun.pmStart ?? "",
28297
- imgRun.pmEnd ?? ""
28346
+ imgRun.distRight ?? ""
28347
+ // Note: pmStart/pmEnd intentionally excluded to prevent O(n) change detection
28298
28348
  ].join(",");
28299
28349
  }
28300
28350
  if (run.kind === "lineBreak") {
28301
- return ["linebreak", run.pmStart ?? "", run.pmEnd ?? ""].join(",");
28351
+ return "linebreak";
28302
28352
  }
28303
28353
  if (run.kind === "tab") {
28304
- return [run.text ?? "", "tab", run.pmStart ?? "", run.pmEnd ?? ""].join(",");
28354
+ return [run.text ?? "", "tab"].join(",");
28305
28355
  }
28306
28356
  const textRun = run;
28307
28357
  return [
@@ -28317,8 +28367,7 @@ const deriveBlockVersion = (block) => {
28317
28367
  textRun.strike ? 1 : 0,
28318
28368
  textRun.highlight ?? "",
28319
28369
  textRun.letterSpacing != null ? textRun.letterSpacing : "",
28320
- textRun.pmStart ?? "",
28321
- textRun.pmEnd ?? "",
28370
+ // Note: pmStart/pmEnd intentionally excluded to prevent O(n) change detection
28322
28371
  textRun.token ?? "",
28323
28372
  // Tracked changes - force re-render when added or removed tracked change
28324
28373
  textRun.trackedChange ? 1 : 0,
@@ -28777,8 +28826,8 @@ const createDomPainter = (options) => {
28777
28826
  ruler: options.ruler
28778
28827
  });
28779
28828
  return {
28780
- paint(layout, mount2) {
28781
- painter.paint(layout, mount2);
28829
+ paint(layout, mount2, mapping) {
28830
+ painter.paint(layout, mount2, mapping);
28782
28831
  },
28783
28832
  setData(blocks, measures, headerBlocks, headerMeasures, footerBlocks, footerMeasures) {
28784
28833
  painter.setData(blocks, measures, headerBlocks, headerMeasures, footerBlocks, footerMeasures);
@@ -50238,6 +50287,7 @@ class PresentationEditor extends EventEmitter {
50238
50287
  #telemetryEmitter = null;
50239
50288
  #renderScheduled = false;
50240
50289
  #pendingDocChange = false;
50290
+ #pendingMapping = null;
50241
50291
  #isRerendering = false;
50242
50292
  #selectionSync = new SelectionSyncCoordinator();
50243
50293
  #remoteCursorUpdateScheduled = false;
@@ -51845,6 +51895,15 @@ class PresentationEditor extends EventEmitter {
51845
51895
  }
51846
51896
  if (trackedChangesChanged || transaction?.docChanged) {
51847
51897
  this.#pendingDocChange = true;
51898
+ if (transaction?.docChanged) {
51899
+ if (this.#pendingMapping !== null) {
51900
+ const combined = this.#pendingMapping.slice();
51901
+ combined.appendMapping(transaction.mapping);
51902
+ this.#pendingMapping = combined;
51903
+ } else {
51904
+ this.#pendingMapping = transaction.mapping;
51905
+ }
51906
+ }
51848
51907
  this.#selectionSync.onLayoutStart();
51849
51908
  this.#scheduleRerender();
51850
51909
  }
@@ -53437,7 +53496,9 @@ class PresentationEditor extends EventEmitter {
53437
53496
  footerMeasures.length > 0 ? footerMeasures : void 0
53438
53497
  );
53439
53498
  this.#domIndexObserverManager?.pause();
53440
- painter.paint(layout, this.#painterHost);
53499
+ const mapping = this.#pendingMapping;
53500
+ this.#pendingMapping = null;
53501
+ painter.paint(layout, this.#painterHost, mapping ?? void 0);
53441
53502
  this.#applyVertAlignToLayout();
53442
53503
  this.#rebuildDomPositionIndex();
53443
53504
  this.#domIndexObserverManager?.resume();
@@ -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-BjQU1XSp.cjs");
3
+ require("./SuperConverter-Cu6cvHlN.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");
@@ -7465,7 +7465,7 @@ const _sfc_main = {
7465
7465
  __name: "SuperDoc",
7466
7466
  emits: ["selection-update"],
7467
7467
  setup(__props, { emit: __emit }) {
7468
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-B1rqV4Hp.cjs")));
7468
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-BFIKd3-b.cjs")));
7469
7469
  const superdocStore = useSuperdocStore();
7470
7470
  const commentsStore = useCommentsStore();
7471
7471
  const {
@@ -8394,7 +8394,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
8394
8394
  this.config.colors = shuffleArray(this.config.colors);
8395
8395
  this.userColorMap = /* @__PURE__ */ new Map();
8396
8396
  this.colorIndex = 0;
8397
- this.version = "1.3.1-next.1";
8397
+ this.version = "1.3.1-next.2";
8398
8398
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8399
8399
  this.superdocId = config.superdocId || uuid.v4();
8400
8400
  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-DZF2SDeC.es.js";
2
- import "./SuperConverter-AxPNFosS.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-SYGYHKb5.es.js";
2
+ import "./SuperConverter-BE5tNyQz.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";
@@ -7448,7 +7448,7 @@ const _sfc_main = {
7448
7448
  __name: "SuperDoc",
7449
7449
  emits: ["selection-update"],
7450
7450
  setup(__props, { emit: __emit }) {
7451
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-BVvi-ZEK.es.js"));
7451
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-B0cx-Fxj.es.js"));
7452
7452
  const superdocStore = useSuperdocStore();
7453
7453
  const commentsStore = useCommentsStore();
7454
7454
  const {
@@ -8377,7 +8377,7 @@ class SuperDoc extends EventEmitter {
8377
8377
  this.config.colors = shuffleArray(this.config.colors);
8378
8378
  this.userColorMap = /* @__PURE__ */ new Map();
8379
8379
  this.colorIndex = 0;
8380
- this.version = "1.3.1-next.1";
8380
+ this.version = "1.3.1-next.2";
8381
8381
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8382
8382
  this.superdocId = config.superdocId || v4();
8383
8383
  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-BE5tNyQz.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";
@@ -15434,7 +15434,7 @@ const canUseDOM = () => {
15434
15434
  return false;
15435
15435
  }
15436
15436
  };
15437
- const summaryVersion = "1.3.1-next.1";
15437
+ const summaryVersion = "1.3.1-next.2";
15438
15438
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15439
15439
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15440
15440
  function mapAttributes(attrs) {
@@ -18066,7 +18066,7 @@ class Editor extends EventEmitter {
18066
18066
  * Process collaboration migrations
18067
18067
  */
18068
18068
  processCollaborationMigrations() {
18069
- console.debug("[checkVersionMigrations] Current editor version", "1.3.1-next.1");
18069
+ console.debug("[checkVersionMigrations] Current editor version", "1.3.1-next.2");
18070
18070
  if (!this.options.ydoc) return;
18071
18071
  const metaMap = this.options.ydoc.getMap("meta");
18072
18072
  let docVersion = metaMap.get("version");
@@ -25080,6 +25080,7 @@ class DomPainter {
25080
25080
  this.layoutVersion = 0;
25081
25081
  this.layoutEpoch = 0;
25082
25082
  this.processedLayoutVersion = -1;
25083
+ this.currentMapping = null;
25083
25084
  this.onScrollHandler = null;
25084
25085
  this.onWindowScrollHandler = null;
25085
25086
  this.onResizeHandler = null;
@@ -25185,7 +25186,7 @@ class DomPainter {
25185
25186
  this.blockLookup = nextLookup;
25186
25187
  this.changedBlocks = changed;
25187
25188
  }
25188
- paint(layout, mount2) {
25189
+ paint(layout, mount2, mapping) {
25189
25190
  if (!(mount2 instanceof HTMLElement)) {
25190
25191
  throw new Error("DomPainter.paint requires a valid HTMLElement mount");
25191
25192
  }
@@ -25194,6 +25195,13 @@ class DomPainter {
25194
25195
  throw new Error("DomPainter.paint requires a DOM-like document");
25195
25196
  }
25196
25197
  this.doc = doc2;
25198
+ const isSimpleTransaction = mapping && mapping.maps.length === 1;
25199
+ if (mapping && !isSimpleTransaction) {
25200
+ this.blockLookup.forEach((_, id) => this.changedBlocks.add(id));
25201
+ this.currentMapping = null;
25202
+ } else {
25203
+ this.currentMapping = mapping ?? null;
25204
+ }
25197
25205
  ensurePrintStyles(doc2);
25198
25206
  ensureLinkStyles(doc2);
25199
25207
  ensureTrackChangeStyles(doc2);
@@ -25220,6 +25228,7 @@ class DomPainter {
25220
25228
  this.currentLayout = layout;
25221
25229
  this.pageStates = [];
25222
25230
  this.changedBlocks.clear();
25231
+ this.currentMapping = null;
25223
25232
  return;
25224
25233
  }
25225
25234
  if (mode === "book") {
@@ -25228,6 +25237,7 @@ class DomPainter {
25228
25237
  this.currentLayout = layout;
25229
25238
  this.pageStates = [];
25230
25239
  this.changedBlocks.clear();
25240
+ this.currentMapping = null;
25231
25241
  return;
25232
25242
  }
25233
25243
  applyStyles$2(mount2, containerStyles);
@@ -25236,6 +25246,7 @@ class DomPainter {
25236
25246
  this.renderVirtualized(layout, mount2);
25237
25247
  this.currentLayout = layout;
25238
25248
  this.changedBlocks.clear();
25249
+ this.currentMapping = null;
25239
25250
  return;
25240
25251
  }
25241
25252
  mount2.style.gap = `${this.pageGap}px`;
@@ -25246,6 +25257,7 @@ class DomPainter {
25246
25257
  }
25247
25258
  this.currentLayout = layout;
25248
25259
  this.changedBlocks.clear();
25260
+ this.currentMapping = null;
25249
25261
  }
25250
25262
  // ----------------
25251
25263
  // Virtualized path
@@ -25777,6 +25789,8 @@ class DomPainter {
25777
25789
  pageEl.replaceChild(replacement, current.element);
25778
25790
  current.element = replacement;
25779
25791
  current.signature = fragmentSignature(fragment, this.blockLookup);
25792
+ } else if (this.currentMapping) {
25793
+ this.updatePositionAttributes(current.element, this.currentMapping);
25780
25794
  }
25781
25795
  this.updateFragmentElement(current.element, fragment, contextBase.section);
25782
25796
  current.fragment = fragment;
@@ -25805,6 +25819,45 @@ class DomPainter {
25805
25819
  state.fragments = nextFragments;
25806
25820
  this.renderDecorationsForPage(pageEl, page);
25807
25821
  }
25822
+ /**
25823
+ * Updates data-pm-start/data-pm-end attributes on all elements within a fragment
25824
+ * using the transaction's mapping. Skips header/footer content (separate PM coordinate space).
25825
+ * Also skips fragments that end before the edit point (their positions don't change).
25826
+ */
25827
+ updatePositionAttributes(fragmentEl, mapping) {
25828
+ if (fragmentEl.closest(".superdoc-page-header, .superdoc-page-footer")) {
25829
+ return;
25830
+ }
25831
+ try {
25832
+ const fragEnd = fragmentEl.dataset.pmEnd;
25833
+ if (fragEnd !== void 0 && fragEnd !== "") {
25834
+ const endNum = Number(fragEnd);
25835
+ if (Number.isFinite(endNum) && mapping.map(endNum, -1) === endNum) {
25836
+ return;
25837
+ }
25838
+ }
25839
+ const elements = fragmentEl.querySelectorAll("[data-pm-start], [data-pm-end]");
25840
+ const allElements = [fragmentEl, ...Array.from(elements)];
25841
+ for (const el of allElements) {
25842
+ const oldStart = el.dataset.pmStart;
25843
+ const oldEnd = el.dataset.pmEnd;
25844
+ if (oldStart !== void 0 && oldStart !== "") {
25845
+ const num = Number(oldStart);
25846
+ if (Number.isFinite(num)) {
25847
+ el.dataset.pmStart = String(mapping.map(num));
25848
+ }
25849
+ }
25850
+ if (oldEnd !== void 0 && oldEnd !== "") {
25851
+ const num = Number(oldEnd);
25852
+ if (Number.isFinite(num)) {
25853
+ el.dataset.pmEnd = String(mapping.map(num, -1));
25854
+ }
25855
+ }
25856
+ }
25857
+ } catch (error) {
25858
+ console.error("Error updating position attributes with mapping:", error);
25859
+ }
25860
+ }
25808
25861
  createPageState(page, pageSize) {
25809
25862
  if (!this.doc) {
25810
25863
  throw new Error("DomPainter.createPageState requires a document");
@@ -28182,8 +28235,6 @@ const fragmentSignature = (fragment, lookup) => {
28182
28235
  base2,
28183
28236
  fragment.fromLine,
28184
28237
  fragment.toLine,
28185
- fragment.pmStart ?? "",
28186
- fragment.pmEnd ?? "",
28187
28238
  fragment.continuesFromPrev ? 1 : 0,
28188
28239
  fragment.continuesOnNext ? 1 : 0,
28189
28240
  fragment.markerWidth ?? ""
@@ -28275,16 +28326,15 @@ const deriveBlockVersion = (block) => {
28275
28326
  imgRun.distTop ?? "",
28276
28327
  imgRun.distBottom ?? "",
28277
28328
  imgRun.distLeft ?? "",
28278
- imgRun.distRight ?? "",
28279
- imgRun.pmStart ?? "",
28280
- imgRun.pmEnd ?? ""
28329
+ imgRun.distRight ?? ""
28330
+ // Note: pmStart/pmEnd intentionally excluded to prevent O(n) change detection
28281
28331
  ].join(",");
28282
28332
  }
28283
28333
  if (run.kind === "lineBreak") {
28284
- return ["linebreak", run.pmStart ?? "", run.pmEnd ?? ""].join(",");
28334
+ return "linebreak";
28285
28335
  }
28286
28336
  if (run.kind === "tab") {
28287
- return [run.text ?? "", "tab", run.pmStart ?? "", run.pmEnd ?? ""].join(",");
28337
+ return [run.text ?? "", "tab"].join(",");
28288
28338
  }
28289
28339
  const textRun = run;
28290
28340
  return [
@@ -28300,8 +28350,7 @@ const deriveBlockVersion = (block) => {
28300
28350
  textRun.strike ? 1 : 0,
28301
28351
  textRun.highlight ?? "",
28302
28352
  textRun.letterSpacing != null ? textRun.letterSpacing : "",
28303
- textRun.pmStart ?? "",
28304
- textRun.pmEnd ?? "",
28353
+ // Note: pmStart/pmEnd intentionally excluded to prevent O(n) change detection
28305
28354
  textRun.token ?? "",
28306
28355
  // Tracked changes - force re-render when added or removed tracked change
28307
28356
  textRun.trackedChange ? 1 : 0,
@@ -28760,8 +28809,8 @@ const createDomPainter = (options) => {
28760
28809
  ruler: options.ruler
28761
28810
  });
28762
28811
  return {
28763
- paint(layout, mount2) {
28764
- painter.paint(layout, mount2);
28812
+ paint(layout, mount2, mapping) {
28813
+ painter.paint(layout, mount2, mapping);
28765
28814
  },
28766
28815
  setData(blocks, measures, headerBlocks, headerMeasures, footerBlocks, footerMeasures) {
28767
28816
  painter.setData(blocks, measures, headerBlocks, headerMeasures, footerBlocks, footerMeasures);
@@ -50221,6 +50270,7 @@ class PresentationEditor extends EventEmitter {
50221
50270
  #telemetryEmitter = null;
50222
50271
  #renderScheduled = false;
50223
50272
  #pendingDocChange = false;
50273
+ #pendingMapping = null;
50224
50274
  #isRerendering = false;
50225
50275
  #selectionSync = new SelectionSyncCoordinator();
50226
50276
  #remoteCursorUpdateScheduled = false;
@@ -51828,6 +51878,15 @@ class PresentationEditor extends EventEmitter {
51828
51878
  }
51829
51879
  if (trackedChangesChanged || transaction?.docChanged) {
51830
51880
  this.#pendingDocChange = true;
51881
+ if (transaction?.docChanged) {
51882
+ if (this.#pendingMapping !== null) {
51883
+ const combined = this.#pendingMapping.slice();
51884
+ combined.appendMapping(transaction.mapping);
51885
+ this.#pendingMapping = combined;
51886
+ } else {
51887
+ this.#pendingMapping = transaction.mapping;
51888
+ }
51889
+ }
51831
51890
  this.#selectionSync.onLayoutStart();
51832
51891
  this.#scheduleRerender();
51833
51892
  }
@@ -53420,7 +53479,9 @@ class PresentationEditor extends EventEmitter {
53420
53479
  footerMeasures.length > 0 ? footerMeasures : void 0
53421
53480
  );
53422
53481
  this.#domIndexObserverManager?.pause();
53423
- painter.paint(layout, this.#painterHost);
53482
+ const mapping = this.#pendingMapping;
53483
+ this.#pendingMapping = null;
53484
+ painter.paint(layout, this.#painterHost, mapping ?? void 0);
53424
53485
  this.#applyVertAlignToLayout();
53425
53486
  this.#rebuildDomPositionIndex();
53426
53487
  this.#domIndexObserverManager?.resume();
@@ -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-rwP6nlvC.cjs");
5
+ const superEditor_converter = require("../chunks/SuperConverter-Cu6cvHlN.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-AxPNFosS.es.js";
3
+ import { S } from "../chunks/SuperConverter-BE5tNyQz.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-Ccw24rQt.cjs");
3
+ const index = require("./chunks/index-BjQU1XSp.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-rwP6nlvC.cjs");
7
+ const superEditor_converter = require("./chunks/SuperConverter-Cu6cvHlN.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-DZF2SDeC.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-DZF2SDeC.es.js";
1
+ import { ax as Node, ay as Mark } from "./chunks/index-SYGYHKb5.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-SYGYHKb5.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-AxPNFosS.es.js";
6
+ import { S, r } from "./chunks/SuperConverter-BE5tNyQz.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-Ccw24rQt.cjs");
4
- const superdoc = require("./chunks/index-BmwaXglr.cjs");
5
- const superEditor_converter = require("./chunks/SuperConverter-rwP6nlvC.cjs");
3
+ const index = require("./chunks/index-BjQU1XSp.cjs");
4
+ const superdoc = require("./chunks/index-DWfzQ0RN.cjs");
5
+ const superEditor_converter = require("./chunks/SuperConverter-Cu6cvHlN.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-DZF2SDeC.es.js";
2
- import { D, H, P, S, c } from "./chunks/index-IUXq0EQx.es.js";
3
- import { S as S2, r } from "./chunks/SuperConverter-AxPNFosS.es.js";
1
+ import { au, ab, aw, av, as, a7, ac, ar, at } from "./chunks/index-SYGYHKb5.es.js";
2
+ import { D, H, P, S, c } from "./chunks/index-Dp7mSzy1.es.js";
3
+ import { S as S2, r } from "./chunks/SuperConverter-BE5tNyQz.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";