mindcache 3.3.2 → 3.4.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/{CloudAdapter-CeGQhFk9.d.mts → CloudAdapter-WvuWM4fD.d.mts} +2 -11
- package/dist/{CloudAdapter-CeGQhFk9.d.ts → CloudAdapter-WvuWM4fD.d.ts} +2 -11
- package/dist/cloud/index.d.mts +2 -2
- package/dist/cloud/index.d.ts +2 -2
- package/dist/cloud/index.js +37 -22
- package/dist/cloud/index.js.map +1 -1
- package/dist/cloud/index.mjs +37 -22
- package/dist/cloud/index.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +37 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cloud/index.mjs
CHANGED
|
@@ -519,14 +519,30 @@ var MindCache = class {
|
|
|
519
519
|
break;
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
|
+
} else {
|
|
523
|
+
let current = event.target;
|
|
524
|
+
while (current && current.parent) {
|
|
525
|
+
if (current.parent.parent === this.rootMap) {
|
|
526
|
+
for (const [key, val] of this.rootMap) {
|
|
527
|
+
if (val === current.parent) {
|
|
528
|
+
keysAffected.add(key);
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
break;
|
|
533
|
+
}
|
|
534
|
+
current = current.parent;
|
|
535
|
+
}
|
|
522
536
|
}
|
|
523
537
|
});
|
|
524
538
|
keysAffected.forEach((key) => {
|
|
525
539
|
const entryMap = this.rootMap.get(key);
|
|
526
540
|
if (entryMap) {
|
|
527
541
|
const value = entryMap.get("value");
|
|
542
|
+
const attrs = entryMap.get("attributes");
|
|
543
|
+
const resolvedValue = attrs?.type === "document" && value instanceof Y.Text ? value.toString() : value;
|
|
528
544
|
if (this.listeners[key]) {
|
|
529
|
-
this.listeners[key].forEach((l) => l(
|
|
545
|
+
this.listeners[key].forEach((l) => l(resolvedValue));
|
|
530
546
|
}
|
|
531
547
|
} else {
|
|
532
548
|
if (this.listeners[key]) {
|
|
@@ -656,12 +672,19 @@ var MindCache = class {
|
|
|
656
672
|
if (event.target === this.rootMap) {
|
|
657
673
|
const mapEvent = event;
|
|
658
674
|
mapEvent.keysChanged.forEach((key) => keysAffected.add(key));
|
|
659
|
-
} else
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
675
|
+
} else {
|
|
676
|
+
let current = event.target;
|
|
677
|
+
while (current && current.parent) {
|
|
678
|
+
if (current.parent === this.rootMap) {
|
|
679
|
+
for (const [key, val] of this.rootMap) {
|
|
680
|
+
if (val === current) {
|
|
681
|
+
keysAffected.add(key);
|
|
682
|
+
break;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
663
685
|
break;
|
|
664
686
|
}
|
|
687
|
+
current = current.parent;
|
|
665
688
|
}
|
|
666
689
|
}
|
|
667
690
|
});
|
|
@@ -1058,11 +1081,15 @@ var MindCache = class {
|
|
|
1058
1081
|
const existingAttrs = existingEntry.get("attributes");
|
|
1059
1082
|
if (existingAttrs?.type === "document") {
|
|
1060
1083
|
if (typeof value === "string") {
|
|
1061
|
-
this.
|
|
1084
|
+
this._replaceDocumentText(key, value);
|
|
1062
1085
|
}
|
|
1063
1086
|
return;
|
|
1064
1087
|
}
|
|
1065
1088
|
}
|
|
1089
|
+
if (!existingEntry && attributes?.type === "document") {
|
|
1090
|
+
this.set_document(key, typeof value === "string" ? value : "", attributes);
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1066
1093
|
let entryMap = this.rootMap.get(key);
|
|
1067
1094
|
const isNewEntry = !entryMap;
|
|
1068
1095
|
if (isNewEntry) {
|
|
@@ -1803,14 +1830,6 @@ var MindCache = class {
|
|
|
1803
1830
|
}
|
|
1804
1831
|
return void 0;
|
|
1805
1832
|
}
|
|
1806
|
-
/**
|
|
1807
|
-
* Get plain text content of a document key.
|
|
1808
|
-
* For collaborative editing, use get_document() and bind to an editor.
|
|
1809
|
-
*/
|
|
1810
|
-
get_document_text(key) {
|
|
1811
|
-
const yText = this.get_document(key);
|
|
1812
|
-
return yText?.toString();
|
|
1813
|
-
}
|
|
1814
1833
|
/**
|
|
1815
1834
|
* Insert text at a position in a document key.
|
|
1816
1835
|
*/
|
|
@@ -1830,15 +1849,11 @@ var MindCache = class {
|
|
|
1830
1849
|
}
|
|
1831
1850
|
}
|
|
1832
1851
|
/**
|
|
1833
|
-
* Replace all text in a document key.
|
|
1852
|
+
* Replace all text in a document key (private - use set_value for public API).
|
|
1834
1853
|
* Uses diff-based updates when changes are < diffThreshold (default 80%).
|
|
1835
1854
|
* This preserves concurrent edits and provides better undo granularity.
|
|
1836
|
-
*
|
|
1837
|
-
* @param key - The document key
|
|
1838
|
-
* @param newText - The new text content
|
|
1839
|
-
* @param diffThreshold - Percentage (0-1) of change above which full replace is used (default: 0.8)
|
|
1840
1855
|
*/
|
|
1841
|
-
|
|
1856
|
+
_replaceDocumentText(key, newText, diffThreshold = 0.8) {
|
|
1842
1857
|
const yText = this.get_document(key);
|
|
1843
1858
|
if (!yText) {
|
|
1844
1859
|
return;
|
|
@@ -1944,7 +1959,7 @@ var MindCache = class {
|
|
|
1944
1959
|
},
|
|
1945
1960
|
execute: async ({ value }) => {
|
|
1946
1961
|
if (isDocument) {
|
|
1947
|
-
this.
|
|
1962
|
+
this._replaceDocumentText(key, value);
|
|
1948
1963
|
} else {
|
|
1949
1964
|
this.set_value(key, value);
|
|
1950
1965
|
}
|
|
@@ -2100,7 +2115,7 @@ var MindCache = class {
|
|
|
2100
2115
|
switch (action) {
|
|
2101
2116
|
case "write":
|
|
2102
2117
|
if (isDocument) {
|
|
2103
|
-
this.
|
|
2118
|
+
this._replaceDocumentText(key, value);
|
|
2104
2119
|
} else {
|
|
2105
2120
|
this.set_value(key, value);
|
|
2106
2121
|
}
|