@abraca/dabra 2.26.0 → 2.27.0

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.
@@ -19417,17 +19417,14 @@ function xmlTextToMarkdown(xmlText) {
19417
19417
  }
19418
19418
  function elementTextContent(el) {
19419
19419
  const parts = [];
19420
- for (let i = 0; i < el.length; i++) {
19421
- const child = el.get(i);
19422
- if (child instanceof Y.XmlText) parts.push(xmlTextToMarkdown(child));
19423
- else if (child instanceof Y.XmlElement) {
19424
- if (child.nodeName === "docLink") {
19425
- const docId = child.getAttribute("docId");
19426
- if (docId) parts.push(`[[${docId}]]`);
19427
- continue;
19428
- }
19429
- parts.push(elementTextContent(child));
19420
+ for (const child of el.toArray()) if (child instanceof Y.XmlText) parts.push(xmlTextToMarkdown(child));
19421
+ else if (child instanceof Y.XmlElement) {
19422
+ if (child.nodeName === "docLink") {
19423
+ const docId = child.getAttribute("docId");
19424
+ if (docId) parts.push(`[[${docId}]]`);
19425
+ continue;
19430
19426
  }
19427
+ parts.push(elementTextContent(child));
19431
19428
  }
19432
19429
  return parts.join("");
19433
19430
  }
@@ -19525,8 +19522,9 @@ function serializeElement(el, indent = "") {
19525
19522
  }
19526
19523
  function serializeList(el, type, indent) {
19527
19524
  const lines = [];
19528
- for (let i = 0; i < el.length; i++) {
19529
- const item = el.get(i);
19525
+ const items = el.toArray();
19526
+ for (let i = 0; i < items.length; i++) {
19527
+ const item = items[i];
19530
19528
  if (item instanceof Y.XmlElement && item.nodeName === "listItem") {
19531
19529
  const prefix = type === "bullet" ? "- " : `${i + 1}. `;
19532
19530
  const content = elementTextContent(item);
@@ -19537,27 +19535,20 @@ function serializeList(el, type, indent) {
19537
19535
  }
19538
19536
  function serializeTaskList(el, indent) {
19539
19537
  const lines = [];
19540
- for (let i = 0; i < el.length; i++) {
19541
- const item = el.get(i);
19542
- if (item instanceof Y.XmlElement && item.nodeName === "taskItem") {
19543
- const checked = item.getAttribute("checked");
19544
- const marker = checked === true || checked === "true" ? "[x]" : "[ ]";
19545
- const content = elementTextContent(item);
19546
- lines.push(`${indent}- ${marker} ${content}`);
19547
- }
19538
+ for (const item of el.toArray()) if (item instanceof Y.XmlElement && item.nodeName === "taskItem") {
19539
+ const checked = item.getAttribute("checked");
19540
+ const marker = checked === true || checked === "true" ? "[x]" : "[ ]";
19541
+ const content = elementTextContent(item);
19542
+ lines.push(`${indent}- ${marker} ${content}`);
19548
19543
  }
19549
19544
  return lines.join("\n");
19550
19545
  }
19551
19546
  function serializeTable(el) {
19552
19547
  const rows = [];
19553
- for (let i = 0; i < el.length; i++) {
19554
- const row = el.get(i);
19548
+ for (const row of el.toArray()) {
19555
19549
  if (!(row instanceof Y.XmlElement) || row.nodeName !== "tableRow") continue;
19556
19550
  const cells = [];
19557
- for (let j = 0; j < row.length; j++) {
19558
- const cell = row.get(j);
19559
- if (cell instanceof Y.XmlElement) cells.push(elementTextContent(cell));
19560
- }
19551
+ for (const cell of row.toArray()) if (cell instanceof Y.XmlElement) cells.push(elementTextContent(cell));
19561
19552
  rows.push(cells);
19562
19553
  }
19563
19554
  if (!rows.length) return "";
@@ -19585,15 +19576,12 @@ function serializeSlottedComponent(el, componentName, childNodeName, slotName) {
19585
19576
  }
19586
19577
  function serializeChildren(el, indent) {
19587
19578
  const parts = [];
19588
- for (let i = 0; i < el.length; i++) {
19589
- const child = el.get(i);
19590
- if (child instanceof Y.XmlElement) {
19591
- const serialized = serializeElement(child, indent);
19592
- if (serialized) parts.push(serialized);
19593
- } else if (child instanceof Y.XmlText) {
19594
- const text = xmlTextToMarkdown(child);
19595
- if (text) parts.push(text);
19596
- }
19579
+ for (const child of el.toArray()) if (child instanceof Y.XmlElement) {
19580
+ const serialized = serializeElement(child, indent);
19581
+ if (serialized) parts.push(serialized);
19582
+ } else if (child instanceof Y.XmlText) {
19583
+ const text = xmlTextToMarkdown(child);
19584
+ if (text) parts.push(text);
19597
19585
  }
19598
19586
  return parts.join("\n\n");
19599
19587
  }
@@ -19606,8 +19594,7 @@ function serializeChildren(el, indent) {
19606
19594
  function yjsToMarkdown(fragment) {
19607
19595
  let title = "Untitled";
19608
19596
  const bodyParts = [];
19609
- for (let i = 0; i < fragment.length; i++) {
19610
- const child = fragment.get(i);
19597
+ for (const child of fragment.toArray()) {
19611
19598
  if (!(child instanceof Y.XmlElement)) continue;
19612
19599
  if (child.nodeName === "documentHeader") {
19613
19600
  title = elementTextContent(child) || "Untitled";
@@ -20618,8 +20605,7 @@ function buildBlocksFromMarkdown(markdown) {
20618
20605
  }
20619
20606
  function readBlocksFromFragment(fragment) {
20620
20607
  const result = [];
20621
- for (let i = 0; i < fragment.length; i++) {
20622
- const child = fragment.get(i);
20608
+ for (const child of fragment.toArray()) {
20623
20609
  if (!(child instanceof Y.XmlElement)) continue;
20624
20610
  const name = child.nodeName;
20625
20611
  if (name === "documentHeader" || name === "documentMeta") continue;
@@ -21044,11 +21030,11 @@ var DocumentManager = class {
21044
21030
  return this._rootDocId;
21045
21031
  }
21046
21032
  /**
21047
- * Whether the TreeManager in-memory index is enabled (Path-1 prototype).
21048
- * Off by default — see {@link DocumentManagerConfig.treeIndex}.
21033
+ * Whether the TreeManager in-memory index is enabled.
21034
+ * On by default — see {@link DocumentManagerConfig.treeIndex}.
21049
21035
  */
21050
21036
  get treeIndexEnabled() {
21051
- return this._config.treeIndex ?? false;
21037
+ return this._config.treeIndex ?? true;
21052
21038
  }
21053
21039
  get rootDocument() {
21054
21040
  return this._rootDoc;