@harbour-enterprises/superdoc 1.9.0-next.7 → 1.9.0-next.8

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.
@@ -39129,7 +39129,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39129
39129
  static getStoredSuperdocVersion(docx) {
39130
39130
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
39131
39131
  }
39132
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.9.0-next.7") {
39132
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.9.0-next.8") {
39133
39133
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
39134
39134
  }
39135
39135
  /**
@@ -64608,6 +64608,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64608
64608
  });
64609
64609
  }
64610
64610
  });
64611
+ if (removedNodes.length) {
64612
+ const removedNodesIds = removedNodes.map((item) => item.node.attrs.fieldId);
64613
+ const found2 = findChildren$5(
64614
+ tr.doc,
64615
+ (node2) => node2.type.name === "fieldAnnotation" && removedNodesIds.includes(node2.attrs.fieldId)
64616
+ );
64617
+ const foundSet = new Set(found2.map((item) => item.node.attrs.fieldId));
64618
+ const removedNodesFiltered = removedNodes.filter((item) => !foundSet.has(item.node.attrs.fieldId));
64619
+ removedNodes = removedNodesFiltered;
64620
+ }
64611
64621
  return removedNodes;
64612
64622
  }
64613
64623
  function transactionDeletedAnything(tr) {
@@ -65534,7 +65544,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
65534
65544
  return false;
65535
65545
  }
65536
65546
  };
65537
- const summaryVersion = "1.9.0-next.7";
65547
+ const summaryVersion = "1.9.0-next.8";
65538
65548
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
65539
65549
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
65540
65550
  function mapAttributes(attrs) {
@@ -68283,7 +68293,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68283
68293
  * Process collaboration migrations
68284
68294
  */
68285
68295
  processCollaborationMigrations() {
68286
- console.debug("[checkVersionMigrations] Current editor version", "1.9.0-next.7");
68296
+ console.debug("[checkVersionMigrations] Current editor version", "1.9.0-next.8");
68287
68297
  if (!this.options.ydoc) return;
68288
68298
  const metaMap = this.options.ydoc.getMap("meta");
68289
68299
  let docVersion = metaMap.get("version");
@@ -78681,9 +78691,35 @@ ${o}
78681
78691
  annotation.dataset.pmEnd = String(run2.pmEnd);
78682
78692
  }
78683
78693
  annotation.dataset.layoutEpoch = String(this.layoutEpoch);
78694
+ this.appendAnnotationCaretAnchor(annotation, run2);
78684
78695
  this.applySdtDataset(annotation, run2.sdt);
78685
78696
  return annotation;
78686
78697
  }
78698
+ /**
78699
+ * Adds a hidden DOM anchor at pmEnd so caret placement after the annotation is correct.
78700
+ */
78701
+ appendAnnotationCaretAnchor(annotation, run2) {
78702
+ if (!this.doc || run2.pmEnd == null) return;
78703
+ const caretAnchor = this.doc.createElement("span");
78704
+ caretAnchor.dataset.pmStart = String(run2.pmEnd);
78705
+ caretAnchor.dataset.pmEnd = String(run2.pmEnd);
78706
+ caretAnchor.dataset.layoutEpoch = String(this.layoutEpoch);
78707
+ caretAnchor.classList.add("annotation-caret-anchor");
78708
+ caretAnchor.style.position = "absolute";
78709
+ caretAnchor.style.left = "100%";
78710
+ caretAnchor.style.top = "0";
78711
+ caretAnchor.style.width = "0";
78712
+ caretAnchor.style.height = "1em";
78713
+ caretAnchor.style.overflow = "hidden";
78714
+ caretAnchor.style.pointerEvents = "none";
78715
+ caretAnchor.style.userSelect = "none";
78716
+ caretAnchor.style.opacity = "0";
78717
+ caretAnchor.textContent = "​";
78718
+ if (!annotation.style.position) {
78719
+ annotation.style.position = "relative";
78720
+ }
78721
+ annotation.appendChild(caretAnchor);
78722
+ }
78687
78723
  /**
78688
78724
  * Renders a single line of a paragraph block.
78689
78725
  *
@@ -81625,7 +81661,8 @@ ${o}
81625
81661
  "tab",
81626
81662
  "footnoteReference",
81627
81663
  "passthroughInline",
81628
- "bookmarkEnd"
81664
+ "bookmarkEnd",
81665
+ "fieldAnnotation"
81629
81666
  ]);
81630
81667
  const TOKEN_INLINE_TYPES = /* @__PURE__ */ new Map([
81631
81668
  ["page-number", "pageNumber"],
@@ -111611,7 +111648,9 @@ ${o}
111611
111648
  nodeViewMap.set(this.node, this);
111612
111649
  calculateResolvedParagraphProperties(this.editor, this.node, this.editor.state.doc.resolve(this.getPos()));
111613
111650
  this.dom = document.createElement("p");
111614
- this.contentDOM = document.createElement("span");
111651
+ const contentEl = document.createElement("span");
111652
+ contentEl.classList.add("sd-paragraph-content");
111653
+ this.contentDOM = contentEl;
111615
111654
  this.dom.appendChild(this.contentDOM);
111616
111655
  if (this.#checkIsList()) {
111617
111656
  this.#initList(node2.attrs.listRendering);
@@ -112117,6 +112156,37 @@ ${o}
112117
112156
  }
112118
112157
  });
112119
112158
  }
112159
+ const shouldAddLeadingCaret = (node2) => {
112160
+ if (node2.type.name !== "paragraph") return false;
112161
+ if (node2.childCount === 0) return false;
112162
+ const first2 = node2.child(0);
112163
+ if (first2.type.name === "fieldAnnotation") return true;
112164
+ if (first2.type.name !== "run") return false;
112165
+ if (first2.childCount === 0) return false;
112166
+ return first2.child(0).type.name === "fieldAnnotation";
112167
+ };
112168
+ function createLeadingCaretPlugin() {
112169
+ const leadingCaretPlugin = new Plugin({
112170
+ props: {
112171
+ decorations(state) {
112172
+ if (typeof document === "undefined") return null;
112173
+ const decorations = [];
112174
+ state.doc.descendants((node2, pos) => {
112175
+ if (!shouldAddLeadingCaret(node2)) return true;
112176
+ const widgetPos = pos + 1;
112177
+ const deco = Decoration.widget(widgetPos, () => document.createTextNode("​"), {
112178
+ key: `sd-leading-caret-${pos}`,
112179
+ side: -1
112180
+ });
112181
+ decorations.push(deco);
112182
+ return false;
112183
+ });
112184
+ return decorations.length ? DecorationSet.create(state.doc, decorations) : null;
112185
+ }
112186
+ }
112187
+ });
112188
+ return leadingCaretPlugin;
112189
+ }
112120
112190
  function createDropcapPlugin(editor) {
112121
112191
  const { view } = editor;
112122
112192
  const dropcapWidthCache = /* @__PURE__ */ new Map();
@@ -112493,7 +112563,7 @@ ${o}
112493
112563
  }
112494
112564
  }
112495
112565
  });
112496
- return [dropcapPlugin, numberingPlugin, listEmptyInputPlugin];
112566
+ return [dropcapPlugin, numberingPlugin, listEmptyInputPlugin, createLeadingCaretPlugin()];
112497
112567
  }
112498
112568
  });
112499
112569
  const Heading = Extension.create({
@@ -152321,7 +152391,7 @@ ${reason}`);
152321
152391
  this.config.colors = shuffleArray(this.config.colors);
152322
152392
  this.userColorMap = /* @__PURE__ */ new Map();
152323
152393
  this.colorIndex = 0;
152324
- this.version = "1.9.0-next.7";
152394
+ this.version = "1.9.0-next.8";
152325
152395
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
152326
152396
  this.superdocId = config2.superdocId || v4();
152327
152397
  this.colors = this.config.colors;