@abraca/dabra 2.26.0 → 2.28.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.
- package/dist/abracadabra-provider.cjs +28 -42
- package/dist/abracadabra-provider.cjs.map +1 -1
- package/dist/abracadabra-provider.esm.js +28 -42
- package/dist/abracadabra-provider.esm.js.map +1 -1
- package/dist/index.d.ts +12 -9
- package/package.json +2 -2
- package/src/DocConverters.ts +13 -16
- package/src/DocumentManager.ts +13 -10
|
@@ -19477,17 +19477,14 @@ function xmlTextToMarkdown(xmlText) {
|
|
|
19477
19477
|
}
|
|
19478
19478
|
function elementTextContent(el) {
|
|
19479
19479
|
const parts = [];
|
|
19480
|
-
for (
|
|
19481
|
-
|
|
19482
|
-
if (child
|
|
19483
|
-
|
|
19484
|
-
if (
|
|
19485
|
-
|
|
19486
|
-
if (docId) parts.push(`[[${docId}]]`);
|
|
19487
|
-
continue;
|
|
19488
|
-
}
|
|
19489
|
-
parts.push(elementTextContent(child));
|
|
19480
|
+
for (const child of el.toArray()) if (child instanceof yjs.XmlText) parts.push(xmlTextToMarkdown(child));
|
|
19481
|
+
else if (child instanceof yjs.XmlElement) {
|
|
19482
|
+
if (child.nodeName === "docLink") {
|
|
19483
|
+
const docId = child.getAttribute("docId");
|
|
19484
|
+
if (docId) parts.push(`[[${docId}]]`);
|
|
19485
|
+
continue;
|
|
19490
19486
|
}
|
|
19487
|
+
parts.push(elementTextContent(child));
|
|
19491
19488
|
}
|
|
19492
19489
|
return parts.join("");
|
|
19493
19490
|
}
|
|
@@ -19585,8 +19582,9 @@ function serializeElement(el, indent = "") {
|
|
|
19585
19582
|
}
|
|
19586
19583
|
function serializeList(el, type, indent) {
|
|
19587
19584
|
const lines = [];
|
|
19588
|
-
|
|
19589
|
-
|
|
19585
|
+
const items = el.toArray();
|
|
19586
|
+
for (let i = 0; i < items.length; i++) {
|
|
19587
|
+
const item = items[i];
|
|
19590
19588
|
if (item instanceof yjs.XmlElement && item.nodeName === "listItem") {
|
|
19591
19589
|
const prefix = type === "bullet" ? "- " : `${i + 1}. `;
|
|
19592
19590
|
const content = elementTextContent(item);
|
|
@@ -19597,27 +19595,20 @@ function serializeList(el, type, indent) {
|
|
|
19597
19595
|
}
|
|
19598
19596
|
function serializeTaskList(el, indent) {
|
|
19599
19597
|
const lines = [];
|
|
19600
|
-
for (
|
|
19601
|
-
const
|
|
19602
|
-
|
|
19603
|
-
|
|
19604
|
-
|
|
19605
|
-
const content = elementTextContent(item);
|
|
19606
|
-
lines.push(`${indent}- ${marker} ${content}`);
|
|
19607
|
-
}
|
|
19598
|
+
for (const item of el.toArray()) if (item instanceof yjs.XmlElement && item.nodeName === "taskItem") {
|
|
19599
|
+
const checked = item.getAttribute("checked");
|
|
19600
|
+
const marker = checked === true || checked === "true" ? "[x]" : "[ ]";
|
|
19601
|
+
const content = elementTextContent(item);
|
|
19602
|
+
lines.push(`${indent}- ${marker} ${content}`);
|
|
19608
19603
|
}
|
|
19609
19604
|
return lines.join("\n");
|
|
19610
19605
|
}
|
|
19611
19606
|
function serializeTable(el) {
|
|
19612
19607
|
const rows = [];
|
|
19613
|
-
for (
|
|
19614
|
-
const row = el.get(i);
|
|
19608
|
+
for (const row of el.toArray()) {
|
|
19615
19609
|
if (!(row instanceof yjs.XmlElement) || row.nodeName !== "tableRow") continue;
|
|
19616
19610
|
const cells = [];
|
|
19617
|
-
for (
|
|
19618
|
-
const cell = row.get(j);
|
|
19619
|
-
if (cell instanceof yjs.XmlElement) cells.push(elementTextContent(cell));
|
|
19620
|
-
}
|
|
19611
|
+
for (const cell of row.toArray()) if (cell instanceof yjs.XmlElement) cells.push(elementTextContent(cell));
|
|
19621
19612
|
rows.push(cells);
|
|
19622
19613
|
}
|
|
19623
19614
|
if (!rows.length) return "";
|
|
@@ -19645,15 +19636,12 @@ function serializeSlottedComponent(el, componentName, childNodeName, slotName) {
|
|
|
19645
19636
|
}
|
|
19646
19637
|
function serializeChildren(el, indent) {
|
|
19647
19638
|
const parts = [];
|
|
19648
|
-
for (
|
|
19649
|
-
const
|
|
19650
|
-
if (
|
|
19651
|
-
|
|
19652
|
-
|
|
19653
|
-
|
|
19654
|
-
const text = xmlTextToMarkdown(child);
|
|
19655
|
-
if (text) parts.push(text);
|
|
19656
|
-
}
|
|
19639
|
+
for (const child of el.toArray()) if (child instanceof yjs.XmlElement) {
|
|
19640
|
+
const serialized = serializeElement(child, indent);
|
|
19641
|
+
if (serialized) parts.push(serialized);
|
|
19642
|
+
} else if (child instanceof yjs.XmlText) {
|
|
19643
|
+
const text = xmlTextToMarkdown(child);
|
|
19644
|
+
if (text) parts.push(text);
|
|
19657
19645
|
}
|
|
19658
19646
|
return parts.join("\n\n");
|
|
19659
19647
|
}
|
|
@@ -19666,8 +19654,7 @@ function serializeChildren(el, indent) {
|
|
|
19666
19654
|
function yjsToMarkdown(fragment) {
|
|
19667
19655
|
let title = "Untitled";
|
|
19668
19656
|
const bodyParts = [];
|
|
19669
|
-
for (
|
|
19670
|
-
const child = fragment.get(i);
|
|
19657
|
+
for (const child of fragment.toArray()) {
|
|
19671
19658
|
if (!(child instanceof yjs.XmlElement)) continue;
|
|
19672
19659
|
if (child.nodeName === "documentHeader") {
|
|
19673
19660
|
title = elementTextContent(child) || "Untitled";
|
|
@@ -20678,8 +20665,7 @@ function buildBlocksFromMarkdown(markdown) {
|
|
|
20678
20665
|
}
|
|
20679
20666
|
function readBlocksFromFragment(fragment) {
|
|
20680
20667
|
const result = [];
|
|
20681
|
-
for (
|
|
20682
|
-
const child = fragment.get(i);
|
|
20668
|
+
for (const child of fragment.toArray()) {
|
|
20683
20669
|
if (!(child instanceof yjs.XmlElement)) continue;
|
|
20684
20670
|
const name = child.nodeName;
|
|
20685
20671
|
if (name === "documentHeader" || name === "documentMeta") continue;
|
|
@@ -21109,11 +21095,11 @@ var DocumentManager = class {
|
|
|
21109
21095
|
return this._rootDocId;
|
|
21110
21096
|
}
|
|
21111
21097
|
/**
|
|
21112
|
-
* Whether the TreeManager in-memory index is enabled
|
|
21113
|
-
*
|
|
21098
|
+
* Whether the TreeManager in-memory index is enabled.
|
|
21099
|
+
* On by default — see {@link DocumentManagerConfig.treeIndex}.
|
|
21114
21100
|
*/
|
|
21115
21101
|
get treeIndexEnabled() {
|
|
21116
|
-
return this._config.treeIndex ??
|
|
21102
|
+
return this._config.treeIndex ?? true;
|
|
21117
21103
|
}
|
|
21118
21104
|
get rootDocument() {
|
|
21119
21105
|
return this._rootDoc;
|