y-mxgraph 0.1.2 → 0.1.4

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 CHANGED
@@ -29,6 +29,12 @@ import { Binding, LOCAL_ORIGIN } from 'y-mxgraph';
29
29
  const doc = new Y.Doc();
30
30
 
31
31
  App.main((app) => {
32
+ // Ensure consistent initial files across clients. draw.io generates random diagram ids by default,
33
+ // which can cause sync issues if clients start from different states. Use generateFileTemplate to create a unified template.
34
+ if (!app.currentFile.data) {
35
+ app.currentFile.data = Binding.generateFileTemplate('diagram-0');
36
+ }
37
+
32
38
  const binding = new Binding(app.currentFile, { doc });
33
39
 
34
40
  window.addEventListener('beforeunload', () => binding.destroy());
@@ -56,11 +62,21 @@ pnpm --filter y-mxgraph build
56
62
 
57
63
  # Test
58
64
  pnpm --filter y-mxgraph test
65
+ ```
59
66
 
60
- # Demo
67
+ ## Demo
68
+
69
+ ```bash
70
+ # Single-page mode (draw.io loaded directly in the current page)
61
71
  pnpm --filter @y-mxgraph/demo dev
62
72
 
63
- # Docs
73
+ # iframe mode (parent page runs WebRTC Provider, two iframes each run draw.io + y-mxgraph, synced via postMessage)
74
+ # Visit http://localhost:5173/iframe-mode.html
75
+ ```
76
+
77
+ ## Docs
78
+
79
+ ```bash
64
80
  pnpm --filter @y-mxgraph/docs dev
65
81
  ```
66
82
 
package/README.zh-CN.md CHANGED
@@ -29,6 +29,12 @@ import { Binding, LOCAL_ORIGIN } from 'y-mxgraph';
29
29
  const doc = new Y.Doc();
30
30
 
31
31
  App.main((app) => {
32
+ // 必须保证多端初始文件一致;draw.io 默认新建 diagram 时 id 是随机的,
33
+ // 若各客户端起点不同会导致协同异常。可用 generateFileTemplate 生成统一模板。
34
+ if (!app.currentFile.data) {
35
+ app.currentFile.data = Binding.generateFileTemplate('diagram-0');
36
+ }
37
+
32
38
  const binding = new Binding(app.currentFile, { doc });
33
39
 
34
40
  window.addEventListener('beforeunload', () => binding.destroy());
package/package.json CHANGED
@@ -1,7 +1,20 @@
1
1
  {
2
2
  "name": "y-mxgraph",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Yjs binding for draw.io (mxGraph) documents",
5
+ "keywords": [
6
+ "yjs",
7
+ "mxgraph",
8
+ "drawio",
9
+ "draw.io",
10
+ "crdt",
11
+ "collaboration",
12
+ "real-time",
13
+ "operational-transformation",
14
+ "diagram",
15
+ "graph",
16
+ "sync"
17
+ ],
5
18
  "type": "module",
6
19
  "main": "./y-mxgraph.cjs.js",
7
20
  "module": "./y-mxgraph.es.js",