y-mxgraph 0.3.0 → 0.3.1
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/README.md +4 -1
- package/README.zh-CN.md +2 -0
- package/binding/index.d.ts +19 -0
- package/binding/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/types/drawio.d.ts +5 -0
- package/types/drawio.d.ts.map +1 -1
- package/y-mxgraph.cjs.js +22 -5
- package/y-mxgraph.cjs.js.map +1 -1
- package/y-mxgraph.es.js +22 -5
- package/y-mxgraph.es.js.map +1 -1
- package/y-mxgraph.iife.js +22 -5
- package/y-mxgraph.iife.js.map +1 -1
- package/y-mxgraph.umd.js +22 -5
- package/y-mxgraph.umd.js.map +1 -1
package/y-mxgraph.umd.js
CHANGED
|
@@ -1566,6 +1566,7 @@
|
|
|
1566
1566
|
constructor(file, options) {
|
|
1567
1567
|
this.suppressLocalApply = false;
|
|
1568
1568
|
this.docInitialized = false;
|
|
1569
|
+
this.ui = null;
|
|
1569
1570
|
const {
|
|
1570
1571
|
doc,
|
|
1571
1572
|
awareness,
|
|
@@ -1573,13 +1574,18 @@
|
|
|
1573
1574
|
mouseMoveThrottle,
|
|
1574
1575
|
cursor,
|
|
1575
1576
|
initialContent = "replace",
|
|
1576
|
-
applyFileData = defaultApplyFileData
|
|
1577
|
+
applyFileData = defaultApplyFileData,
|
|
1578
|
+
disableBeforeUnload = true
|
|
1577
1579
|
} = options;
|
|
1578
1580
|
this.doc = doc;
|
|
1579
1581
|
this.initialContentStrategy = initialContent;
|
|
1580
1582
|
const ui = file.getUi();
|
|
1581
1583
|
const graph = ui.editor.graph;
|
|
1582
1584
|
this.mxGraphModel = graph.model;
|
|
1585
|
+
this.ui = ui;
|
|
1586
|
+
if (disableBeforeUnload) {
|
|
1587
|
+
ui.onBeforeUnload = () => null;
|
|
1588
|
+
}
|
|
1583
1589
|
this.suppressLocalApply = true;
|
|
1584
1590
|
try {
|
|
1585
1591
|
this.docInitialized = reconcileInitialContent(
|
|
@@ -1614,6 +1620,7 @@
|
|
|
1614
1620
|
}
|
|
1615
1621
|
file.setShadowPages(file.ui.clonePages(file.ui.pages));
|
|
1616
1622
|
applyFilePatch(doc, patch, { origin: LOCAL_ORIGIN });
|
|
1623
|
+
this.resetEditorStatus();
|
|
1617
1624
|
};
|
|
1618
1625
|
this.mxGraphModel.addListener("change", this.mxListener);
|
|
1619
1626
|
this.docObserver = (events, transaction) => {
|
|
@@ -1632,10 +1639,7 @@
|
|
|
1632
1639
|
applyFileData(file, xml);
|
|
1633
1640
|
file.setShadowPages(file.ui.clonePages(file.ui.pages));
|
|
1634
1641
|
initDocSnapshot(doc, false);
|
|
1635
|
-
|
|
1636
|
-
const editor = ui2.editor;
|
|
1637
|
-
editor.setStatus("");
|
|
1638
|
-
editor.setModified(false);
|
|
1642
|
+
this.resetEditorStatus();
|
|
1639
1643
|
} finally {
|
|
1640
1644
|
this.suppressLocalApply = false;
|
|
1641
1645
|
}
|
|
@@ -1654,6 +1658,7 @@
|
|
|
1654
1658
|
try {
|
|
1655
1659
|
file.patch([patch]);
|
|
1656
1660
|
file.setShadowPages(file.ui.clonePages(file.ui.pages));
|
|
1661
|
+
this.resetEditorStatus();
|
|
1657
1662
|
} finally {
|
|
1658
1663
|
this.suppressLocalApply = false;
|
|
1659
1664
|
}
|
|
@@ -1675,6 +1680,18 @@
|
|
|
1675
1680
|
get shouldReplaceWhenDocHasData() {
|
|
1676
1681
|
return this.initialContentStrategy === "replace" && !this.docInitialized;
|
|
1677
1682
|
}
|
|
1683
|
+
/**
|
|
1684
|
+
* 重置 editor 和 file 的 modified 状态及状态栏。
|
|
1685
|
+
* Yjs 接管持久化后,draw.io 的原生保存状态不再有意义。
|
|
1686
|
+
*/
|
|
1687
|
+
resetEditorStatus() {
|
|
1688
|
+
var _a;
|
|
1689
|
+
if (!this.ui)
|
|
1690
|
+
return;
|
|
1691
|
+
this.ui.editor.setModified(false);
|
|
1692
|
+
this.ui.editor.setStatus("");
|
|
1693
|
+
(_a = this.ui.currentFile) == null ? void 0 : _a.setModified(false);
|
|
1694
|
+
}
|
|
1678
1695
|
/**
|
|
1679
1696
|
* 销毁绑定,解除所有监听器
|
|
1680
1697
|
* @param deep - 是否深度清理(包括 awareness/undoManager),默认 false
|