y-mxgraph 0.5.2 → 0.5.3

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.
Files changed (3) hide show
  1. package/README.md +12 -14
  2. package/README.zh-CN.md +12 -14
  3. package/package.json +1 -2
package/README.md CHANGED
@@ -91,7 +91,7 @@ pnpm --filter @y-mxgraph/ws-demo dev # Start client on port 5174
91
91
 
92
92
  ## iframe Bridge
93
93
 
94
- `@y-mxgraph/iframe-bridge` enables collaborative editing in iframe-isolated environments. The **server** (parent page) manages the network connection (y-webrtc, y-websocket, etc.) and syncs Y.Doc + Awareness to one or more **providers** (iframe children) via `postMessage`.
94
+ `@y-mxgraph/iframe-bridge` enables collaborative editing in iframe-isolated environments. The **server** (parent page) manages the network connection (y-webrtc, y-websocket, etc.) and syncs Y.Doc + Awareness to **providers** (iframe children) via `postMessage`.
95
95
 
96
96
  ```text
97
97
  ┌─────────────────────────────────────────────────────────────┐
@@ -102,20 +102,18 @@ pnpm --filter @y-mxgraph/ws-demo dev # Start client on port 5174
102
102
  │ │ │ │
103
103
  │ └──────┬───────┘ │
104
104
  │ ▼ │
105
- │ createIframeBridgeServer(doc, awareness)
105
+ │ createIframeBridgeServer(iframe, doc, awareness)
106
106
  │ │ postMessage │
107
107
  └──────────────│──────────────────────────────────────────────┘
108
108
 
109
- ┌──────────┴──────────┐
110
- ▼ ▼
111
- ┌─────────────┐ ┌─────────────┐
112
- Iframe A │ Iframe B │
113
- create... │ │ create...
114
- Provider() │ │ Provider()
115
- │ │
116
- │ local Y.Doc │ │ local Y.Doc │
117
- │ + draw.io │ │ + draw.io │
118
- └─────────────┘ └─────────────┘
109
+
110
+ ┌─────────────┐
111
+ │ Iframe │
112
+
113
+ local Y.Doc
114
+ + Awareness
115
+ + draw.io
116
+ └─────────────┘
119
117
  ```
120
118
 
121
119
  ```ts
@@ -135,8 +133,8 @@ const undoManager = new Y.UndoManager(doc, {
135
133
  trackedOrigins: new Set([LOCAL_ORIGIN, IFRAME_ORIGIN]),
136
134
  });
137
135
 
138
- const bridge = createIframeBridgeServer(doc, awareness, { undoManager });
139
- bridge.addIframe(iframeElement, 'child-1');
136
+ // Create bridge server, bound directly to the target iframe
137
+ const bridge = createIframeBridgeServer(iframeElement, doc, awareness, { undoManager });
140
138
 
141
139
  // Undo/redo from parent page
142
140
  document.getElementById('undo-btn')!.onclick = () => {
package/README.zh-CN.md CHANGED
@@ -53,7 +53,7 @@ App.main((app) => {
53
53
 
54
54
  ## iframe Bridge
55
55
 
56
- `@y-mxgraph/iframe-bridge` 支持在 iframe 隔离环境中进行协同编辑。**Server**(父页面)管理网络连接(y-webrtc、y-websocket 等),通过 `postMessage` 将 Y.Doc 和 Awareness 同步到一个或多个 **Provider**(iframe 子页面)。
56
+ `@y-mxgraph/iframe-bridge` 支持在 iframe 隔离环境中进行协同编辑。**Server**(父页面)管理网络连接(y-webrtc、y-websocket 等),通过 `postMessage` 将 Y.Doc 和 Awareness 同步到 **Provider**(iframe 子页面)。
57
57
 
58
58
  ```text
59
59
  ┌─────────────────────────────────────────────────────────────┐
@@ -64,20 +64,18 @@ App.main((app) => {
64
64
  │ │ │ │
65
65
  │ └──────┬───────┘ │
66
66
  │ ▼ │
67
- │ createIframeBridgeServer(doc, awareness)
67
+ │ createIframeBridgeServer(iframe, doc, awareness)
68
68
  │ │ postMessage │
69
69
  └──────────────│──────────────────────────────────────────────┘
70
70
 
71
- ┌──────────┴──────────┐
72
- ▼ ▼
73
- ┌─────────────┐ ┌─────────────┐
74
- Iframe A │ Iframe B │
75
- create... │ │ create...
76
- Provider() │ │ Provider()
77
- │ │
78
- │ 本地 Y.Doc │ │ 本地 Y.Doc │
79
- │ + draw.io │ │ + draw.io │
80
- └─────────────┘ └─────────────┘
71
+
72
+ ┌─────────────┐
73
+ │ Iframe │
74
+
75
+ 本地 Y.Doc
76
+ + Awareness
77
+ + draw.io
78
+ └─────────────┘
81
79
  ```
82
80
 
83
81
  ```ts
@@ -97,8 +95,8 @@ const undoManager = new Y.UndoManager(doc, {
97
95
  trackedOrigins: new Set([LOCAL_ORIGIN, IFRAME_ORIGIN]),
98
96
  });
99
97
 
100
- const bridge = createIframeBridgeServer(doc, awareness, { undoManager });
101
- bridge.addIframe(iframeElement, 'child-1');
98
+ // 创建 bridge server,直接绑定到目标 iframe
99
+ const bridge = createIframeBridgeServer(iframeElement, doc, awareness, { undoManager });
102
100
 
103
101
  // 从父页面执行撤销/重做
104
102
  document.getElementById('undo-btn')!.onclick = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "y-mxgraph",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Yjs binding for draw.io (mxGraph) documents",
5
5
  "keywords": [
6
6
  "yjs",
@@ -15,7 +15,6 @@
15
15
  "graph",
16
16
  "sync"
17
17
  ],
18
- "type": "module",
19
18
  "main": "./y-mxgraph.cjs.js",
20
19
  "module": "./y-mxgraph.es.js",
21
20
  "types": "./index.d.ts",