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