y-mxgraph 0.5.6 → 0.5.8
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/iframe-bridge/{provider.cjs.js → provider.cjs} +3 -3
- package/iframe-bridge/provider.cjs.map +1 -0
- package/iframe-bridge/{provider.es.js → provider.js} +3 -3
- package/iframe-bridge/provider.js.map +1 -0
- package/iframe-bridge/{server.cjs.js → server.cjs} +5 -4
- package/iframe-bridge/server.cjs.map +1 -0
- package/iframe-bridge/{server.es.js → server.js} +5 -4
- package/iframe-bridge/server.js.map +1 -0
- package/index-CcOHH2TY.cjs +272 -0
- package/index-CcOHH2TY.cjs.map +1 -0
- package/index-DBU79c0g.js +256 -0
- package/index-DBU79c0g.js.map +1 -0
- package/package.json +14 -9
- package/transformer.cjs +6 -0
- package/transformer.cjs.map +1 -0
- package/transformer.js +6 -0
- package/transformer.js.map +1 -0
- package/{y-mxgraph.cjs.js → y-mxgraph.cjs} +130 -317
- package/y-mxgraph.cjs.map +1 -0
- package/{y-mxgraph.es.js → y-mxgraph.js} +65 -252
- package/y-mxgraph.js.map +1 -0
- package/iframe-bridge/provider.cjs.js.map +0 -1
- package/iframe-bridge/provider.es.js.map +0 -1
- package/iframe-bridge/server.cjs.js.map +0 -1
- package/iframe-bridge/server.es.js.map +0 -1
- package/y-mxgraph.cjs.js.map +0 -1
- package/y-mxgraph.es.js.map +0 -1
|
@@ -1,191 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { k as key, a as key$1, d as diagramOrderKey, b as key$2, m as mxCellOrderKey, c as key$3, p as parse, e as parse$1, f as serializer, s as serialize, x as xml2ydoc, y as ydoc2xml } from "./index-DBU79c0g.js";
|
|
2
2
|
import * as Y from "yjs";
|
|
3
3
|
import { colord } from "colord";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
var __defProp$1 = Object.defineProperty;
|
|
5
|
+
var __defProps = Object.defineProperties;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp$1 = (obj, key2, value) => key2 in obj ? __defProp$1(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
11
|
+
var __spreadValues$1 = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
14
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols$1)
|
|
16
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
17
|
+
if (__propIsEnum$1.call(b, prop))
|
|
18
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
9
19
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const obj = node;
|
|
14
|
-
const keys = Object.keys(obj);
|
|
15
|
-
for (const key2 of keys) {
|
|
16
|
-
if (key2 === "_attributes") continue;
|
|
17
|
-
let value = obj[key2];
|
|
18
|
-
const keyLower = key2.toLowerCase();
|
|
19
|
-
if ((keyLower === "diagram" || keyLower === "mxcell") && value !== void 0 && !Array.isArray(value)) {
|
|
20
|
-
obj[key2] = [value];
|
|
21
|
-
value = obj[key2];
|
|
22
|
-
}
|
|
23
|
-
if (Array.isArray(value)) {
|
|
24
|
-
for (const v of value) deepProcess(v);
|
|
25
|
-
} else if (value && typeof value === "object") {
|
|
26
|
-
deepProcess(value);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function parse$4(xml) {
|
|
31
|
-
const result = xml2js(xml, { compact: true });
|
|
32
|
-
deepProcess(result);
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
function serializer$1(obj, spaces = 2) {
|
|
36
|
-
return js2xml(obj, {
|
|
37
|
-
compact: true,
|
|
38
|
-
spaces
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
const key$3 = "mxCell";
|
|
42
|
-
const mxGeometryKey = "mxGeometry";
|
|
43
|
-
const mxGeometryAttributeKey = "geometry";
|
|
44
|
-
function parse$3(object) {
|
|
45
|
-
var _a;
|
|
46
|
-
const xmlElement = new Y.XmlElement("mxCell");
|
|
47
|
-
for (const attribute of Object.keys(object._attributes || {})) {
|
|
48
|
-
xmlElement.setAttribute(
|
|
49
|
-
attribute,
|
|
50
|
-
`${((_a = object._attributes) == null ? void 0 : _a[attribute]) || ""}`
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
if (object[mxGeometryKey]) {
|
|
54
|
-
const geometry = object[mxGeometryKey];
|
|
55
|
-
const geometryString = js2xml(geometry, {
|
|
56
|
-
compact: true
|
|
57
|
-
});
|
|
58
|
-
xmlElement.setAttribute(mxGeometryAttributeKey, geometryString);
|
|
59
|
-
delete object[mxGeometryKey];
|
|
60
|
-
}
|
|
61
|
-
return xmlElement;
|
|
62
|
-
}
|
|
63
|
-
function serialize$2(xmlElement) {
|
|
64
|
-
const rawAttributes = {
|
|
65
|
-
...xmlElement.getAttributes()
|
|
66
|
-
};
|
|
67
|
-
let mxGeometry = null;
|
|
68
|
-
let mxGeometryString;
|
|
69
|
-
if (mxGeometryAttributeKey in rawAttributes) {
|
|
70
|
-
mxGeometryString = rawAttributes[mxGeometryAttributeKey];
|
|
71
|
-
delete rawAttributes[mxGeometryAttributeKey];
|
|
72
|
-
}
|
|
73
|
-
const attributes = {};
|
|
74
|
-
for (const [key2, value] of Object.entries(rawAttributes)) {
|
|
75
|
-
if (typeof value === "string") {
|
|
76
|
-
attributes[key2] = value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
77
|
-
} else if (value != null) {
|
|
78
|
-
attributes[key2] = String(value);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (mxGeometryString) {
|
|
82
|
-
try {
|
|
83
|
-
const parsed = xml2js(mxGeometryString, { compact: true });
|
|
84
|
-
mxGeometry = parsed[mxGeometryKey] ?? null;
|
|
85
|
-
if (mxGeometry && mxGeometry._attributes) {
|
|
86
|
-
mxGeometry._attributes["as"] = "geometry";
|
|
87
|
-
}
|
|
88
|
-
} catch (e) {
|
|
89
|
-
console.warn("[y-mxgraph] Failed to parse mxGeometry:", e);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
const obj = {
|
|
93
|
-
_attributes: attributes
|
|
94
|
-
};
|
|
95
|
-
if (mxGeometry) {
|
|
96
|
-
obj[mxGeometryKey] = mxGeometry;
|
|
97
|
-
}
|
|
98
|
-
return obj;
|
|
99
|
-
}
|
|
100
|
-
const key$2 = "mxGraphModel";
|
|
101
|
-
const mxCellOrderKey = key$3 + "Order";
|
|
102
|
-
function parse$2(object, doc) {
|
|
103
|
-
const mxCells = (object.root[key$3] || []).map((cell) => {
|
|
104
|
-
var _a;
|
|
105
|
-
return {
|
|
106
|
-
value: parse$3(cell),
|
|
107
|
-
id: ((_a = cell._attributes) == null ? void 0 : _a.id) || ""
|
|
108
|
-
};
|
|
109
|
-
});
|
|
110
|
-
const mxGraphElement = (doc == null ? void 0 : doc.getMap(key$2)) || new Y.Map();
|
|
111
|
-
const cells = new Y.Map();
|
|
112
|
-
const cellsOrder = new Y.Array();
|
|
113
|
-
mxCells.forEach((cell) => {
|
|
114
|
-
cells.set(cell.id, cell.value);
|
|
115
|
-
});
|
|
116
|
-
cellsOrder.push(mxCells.map((cell) => cell.id));
|
|
117
|
-
mxGraphElement.set(key$3, cells);
|
|
118
|
-
mxGraphElement.set(mxCellOrderKey, cellsOrder);
|
|
119
|
-
return mxGraphElement;
|
|
120
|
-
}
|
|
121
|
-
function serialize$1(map) {
|
|
122
|
-
const cells = map.get(key$3);
|
|
123
|
-
const cellsOrder = map.get(mxCellOrderKey);
|
|
124
|
-
return {
|
|
125
|
-
_attributes: {},
|
|
126
|
-
root: {
|
|
127
|
-
[key$3]: cellsOrder.toArray().map((id) => serialize$2(cells.get(id)))
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
const key$1 = "diagram";
|
|
132
|
-
function parse$1(object) {
|
|
133
|
-
var _a, _b;
|
|
134
|
-
const yDiagramElement = new Y.Map();
|
|
135
|
-
yDiagramElement.set("name", `${((_a = object._attributes) == null ? void 0 : _a.name) || ""}`);
|
|
136
|
-
yDiagramElement.set("id", `${((_b = object._attributes) == null ? void 0 : _b.id) || ""}`);
|
|
137
|
-
const mxGraphModel = parse$2(object[key$2]);
|
|
138
|
-
yDiagramElement.set(key$2, mxGraphModel);
|
|
139
|
-
return yDiagramElement;
|
|
140
|
-
}
|
|
141
|
-
function serialize(yDiagram) {
|
|
142
|
-
const mxGraphModel = yDiagram.get(key$2);
|
|
143
|
-
return {
|
|
144
|
-
_attributes: {
|
|
145
|
-
name: yDiagram.get("name"),
|
|
146
|
-
id: yDiagram.get("id")
|
|
147
|
-
},
|
|
148
|
-
[key$2]: mxGraphModel ? serialize$1(mxGraphModel) : void 0
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
const key = "mxfile";
|
|
152
|
-
const diagramOrderKey = key$1 + "Order";
|
|
153
|
-
function parse(object, doc) {
|
|
154
|
-
var _a;
|
|
155
|
-
const mxfile = doc.getMap(key);
|
|
156
|
-
mxfile.set("pages", (((_a = object._attributes) == null ? void 0 : _a.pages) || "1") + "");
|
|
157
|
-
const diagramList = object.diagram.map((diagram) => {
|
|
158
|
-
var _a2;
|
|
159
|
-
return {
|
|
160
|
-
value: parse$1(diagram),
|
|
161
|
-
id: ((_a2 = diagram._attributes) == null ? void 0 : _a2.id) || ""
|
|
162
|
-
};
|
|
163
|
-
});
|
|
164
|
-
const diagramMap = new Y.Map();
|
|
165
|
-
const diagramOrder = new Y.Array();
|
|
166
|
-
diagramList.forEach((diagram) => {
|
|
167
|
-
diagramMap.set(diagram.id, diagram.value);
|
|
168
|
-
});
|
|
169
|
-
diagramOrder.push(diagramList.map((diagram) => diagram.id));
|
|
170
|
-
mxfile.set(key$1, diagramMap);
|
|
171
|
-
mxfile.set(diagramOrderKey, diagramOrder);
|
|
172
|
-
return mxfile;
|
|
173
|
-
}
|
|
174
|
-
function serializer(yMxFile) {
|
|
175
|
-
const diagrams = yMxFile.get(key$1);
|
|
176
|
-
const diagramOrder = yMxFile.get(
|
|
177
|
-
diagramOrderKey
|
|
178
|
-
);
|
|
179
|
-
const orderIds = diagramOrder ? diagramOrder.toArray() : [];
|
|
180
|
-
const ids = orderIds.length > 0 ? orderIds : diagrams ? Array.from(diagrams.keys()) : [];
|
|
181
|
-
const obj = {
|
|
182
|
-
_attributes: {
|
|
183
|
-
pages: yMxFile.get("pages") || "1"
|
|
184
|
-
},
|
|
185
|
-
[key$1]: ids.map((id) => diagrams.get(id)).filter((d) => !!d).map((diagramElement) => serialize(diagramElement))
|
|
186
|
-
};
|
|
187
|
-
return obj;
|
|
188
|
-
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
189
23
|
const DIFF_INSERT = "i";
|
|
190
24
|
const DIFF_REMOVE = "r";
|
|
191
25
|
const DIFF_UPDATE = "u";
|
|
@@ -252,7 +86,7 @@ function applyFilePatch(doc, patch, options) {
|
|
|
252
86
|
const existingIndex = /* @__PURE__ */ new Map();
|
|
253
87
|
existingIds.forEach((id, idx) => existingIndex.set(id, idx));
|
|
254
88
|
const inserts = patch[DIFF_INSERT].map((item, order) => {
|
|
255
|
-
const object = parse
|
|
89
|
+
const object = parse(item.data);
|
|
256
90
|
const diagramObj = Array.isArray(object == null ? void 0 : object.diagram) ? object.diagram[0] : object == null ? void 0 : object.diagram;
|
|
257
91
|
const diagramElement = parse$1(
|
|
258
92
|
diagramObj
|
|
@@ -292,7 +126,7 @@ function applyFilePatch(doc, patch, options) {
|
|
|
292
126
|
}
|
|
293
127
|
return { anchorId, depth };
|
|
294
128
|
};
|
|
295
|
-
const enriched = inserts.map((i) => ({
|
|
129
|
+
const enriched = inserts.map((i) => __spreadValues$1(__spreadValues$1({}, i), computeAnchor(i)));
|
|
296
130
|
enriched.sort((a, b) => {
|
|
297
131
|
const aIdx = a.anchorId ? existingIndex.get(a.anchorId) : -1;
|
|
298
132
|
const bIdx = b.anchorId ? existingIndex.get(b.anchorId) : -1;
|
|
@@ -500,7 +334,7 @@ function initDocSnapshot(doc, resetSnapshot = false) {
|
|
|
500
334
|
}
|
|
501
335
|
}
|
|
502
336
|
function generatePatch(events, explicitDoc) {
|
|
503
|
-
var _a, _b;
|
|
337
|
+
var _a, _b, _c, _d, _e;
|
|
504
338
|
const patch = {};
|
|
505
339
|
const doc = (_b = (_a = events[0]) == null ? void 0 : _a.transaction) == null ? void 0 : _b.doc;
|
|
506
340
|
if (!doc) return patch;
|
|
@@ -530,7 +364,7 @@ function generatePatch(events, explicitDoc) {
|
|
|
530
364
|
u.cells = u.cells || {};
|
|
531
365
|
return u.cells;
|
|
532
366
|
};
|
|
533
|
-
const orderIds = (orderArr == null ? void 0 : orderArr.toArray())
|
|
367
|
+
const orderIds = (_c = orderArr == null ? void 0 : orderArr.toArray()) != null ? _c : [];
|
|
534
368
|
const currDiagramOrder = orderIds.length > 0 ? orderIds : diagramsMap ? Array.from(diagramsMap.keys()) : [];
|
|
535
369
|
const diagramsList = currDiagramOrder.map((id) => diagramsMap.get(id)).filter((d) => !!d);
|
|
536
370
|
const currCellsOrder = /* @__PURE__ */ new Map();
|
|
@@ -578,7 +412,7 @@ function generatePatch(events, explicitDoc) {
|
|
|
578
412
|
const previous = index <= 0 ? "" : currDiagramOrder[index - 1];
|
|
579
413
|
const yDiagram = diagramsMap.get(id);
|
|
580
414
|
if (!yDiagram) continue;
|
|
581
|
-
const data = serializer
|
|
415
|
+
const data = serializer({ diagram: serialize(yDiagram) });
|
|
582
416
|
patch[DIFF_INSERT].push({ id, previous, data });
|
|
583
417
|
insertedDiagramIdGlobal.add(id);
|
|
584
418
|
}
|
|
@@ -626,10 +460,9 @@ function generatePatch(events, explicitDoc) {
|
|
|
626
460
|
const attrs = attrsMap.get(cid) || {};
|
|
627
461
|
const index = currCells.indexOf(cid);
|
|
628
462
|
const previous = index <= 0 ? "" : currCells[index - 1];
|
|
629
|
-
cells[DIFF_INSERT].push({
|
|
630
|
-
...attrs,
|
|
463
|
+
cells[DIFF_INSERT].push(__spreadProps(__spreadValues$1({}, attrs), {
|
|
631
464
|
previous
|
|
632
|
-
});
|
|
465
|
+
}));
|
|
633
466
|
insertedCellIdGlobal.add(cid);
|
|
634
467
|
}
|
|
635
468
|
}
|
|
@@ -717,8 +550,8 @@ function generatePatch(events, explicitDoc) {
|
|
|
717
550
|
const cellUpdate = updateBucket[cid] = updateBucket[cid] || {};
|
|
718
551
|
let changed = false;
|
|
719
552
|
for (const k of keys) {
|
|
720
|
-
const pv = prevAttrs[k]
|
|
721
|
-
const cv = currAttrs[k]
|
|
553
|
+
const pv = (_d = prevAttrs[k]) != null ? _d : "";
|
|
554
|
+
const cv = (_e = currAttrs[k]) != null ? _e : "";
|
|
722
555
|
if (pv !== cv) {
|
|
723
556
|
cellUpdate[k] = cv;
|
|
724
557
|
changed = true;
|
|
@@ -741,7 +574,7 @@ function generatePatch(events, explicitDoc) {
|
|
|
741
574
|
for (const [did, attrsMap] of cellAttrMap.entries()) {
|
|
742
575
|
const copy = /* @__PURE__ */ new Map();
|
|
743
576
|
for (const [cid, attrs] of attrsMap.entries()) {
|
|
744
|
-
copy.set(cid, {
|
|
577
|
+
copy.set(cid, __spreadValues$1({}, attrs));
|
|
745
578
|
}
|
|
746
579
|
newCellsAttrs.set(did, copy);
|
|
747
580
|
}
|
|
@@ -750,45 +583,6 @@ function generatePatch(events, explicitDoc) {
|
|
|
750
583
|
docSnapshots.set(doc, snap);
|
|
751
584
|
return patch;
|
|
752
585
|
}
|
|
753
|
-
function xml2ydoc(xml, doc) {
|
|
754
|
-
const object = parse$4(xml);
|
|
755
|
-
const mxfile = object.mxfile;
|
|
756
|
-
const mxGraphModel = object.mxGraphModel;
|
|
757
|
-
if (mxfile) {
|
|
758
|
-
doc.transact(() => {
|
|
759
|
-
parse(mxfile, doc);
|
|
760
|
-
});
|
|
761
|
-
} else if (mxGraphModel) {
|
|
762
|
-
doc.transact(() => {
|
|
763
|
-
parse$2(mxGraphModel, doc);
|
|
764
|
-
});
|
|
765
|
-
} else {
|
|
766
|
-
throw new Error("不支持的文件格式");
|
|
767
|
-
}
|
|
768
|
-
return doc;
|
|
769
|
-
}
|
|
770
|
-
function ydoc2xml(doc, spaces = 0) {
|
|
771
|
-
if (doc.share.has(key)) {
|
|
772
|
-
return serializer$1(
|
|
773
|
-
{
|
|
774
|
-
[key]: serializer(
|
|
775
|
-
doc.share.get(key)
|
|
776
|
-
)
|
|
777
|
-
},
|
|
778
|
-
spaces
|
|
779
|
-
);
|
|
780
|
-
} else if (doc.share.has(key$2)) {
|
|
781
|
-
return serializer$1(
|
|
782
|
-
{
|
|
783
|
-
[key$2]: serialize$1(
|
|
784
|
-
doc.share.get(key$2)
|
|
785
|
-
)
|
|
786
|
-
},
|
|
787
|
-
spaces
|
|
788
|
-
);
|
|
789
|
-
}
|
|
790
|
-
return "";
|
|
791
|
-
}
|
|
792
586
|
const LOCAL_ORIGIN = {};
|
|
793
587
|
function createMxEventObject(name, props) {
|
|
794
588
|
const _props = props || {};
|
|
@@ -826,8 +620,8 @@ function bindUndoManager(doc, file, yUndo) {
|
|
|
826
620
|
this.eventListeners.push(name, fn);
|
|
827
621
|
},
|
|
828
622
|
fireEvent(evt) {
|
|
829
|
-
var _a;
|
|
830
|
-
const eventName = (evt == null ? void 0 : evt.name) || (((_a = evt == null ? void 0 : evt.getName) == null ? void 0 : _a.call(evt))
|
|
623
|
+
var _a, _b;
|
|
624
|
+
const eventName = (evt == null ? void 0 : evt.name) || ((_b = (_a = evt == null ? void 0 : evt.getName) == null ? void 0 : _a.call(evt)) != null ? _b : "");
|
|
831
625
|
for (let i = 0; i + 1 < this.eventListeners.length; i += 2) {
|
|
832
626
|
const key2 = this.eventListeners[i];
|
|
833
627
|
const listener = this.eventListeners[i + 1];
|
|
@@ -939,6 +733,22 @@ function bindUndoManager(doc, file, yUndo) {
|
|
|
939
733
|
};
|
|
940
734
|
return destroy;
|
|
941
735
|
}
|
|
736
|
+
var __defProp = Object.defineProperty;
|
|
737
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
738
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
739
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
740
|
+
var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
741
|
+
var __spreadValues = (a, b) => {
|
|
742
|
+
for (var prop in b || (b = {}))
|
|
743
|
+
if (__hasOwnProp.call(b, prop))
|
|
744
|
+
__defNormalProp(a, prop, b[prop]);
|
|
745
|
+
if (__getOwnPropSymbols)
|
|
746
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
747
|
+
if (__propIsEnum.call(b, prop))
|
|
748
|
+
__defNormalProp(a, prop, b[prop]);
|
|
749
|
+
}
|
|
750
|
+
return a;
|
|
751
|
+
};
|
|
942
752
|
function getAwarenessStateValue(awareness, key2, clientId) {
|
|
943
753
|
const states = awareness.getStates();
|
|
944
754
|
const id = clientId != null ? Number(clientId) : awareness.clientID;
|
|
@@ -971,7 +781,7 @@ function setAwarenessStateValue(awareness, key2, value, clientId) {
|
|
|
971
781
|
}
|
|
972
782
|
function setByPath(obj, path, value) {
|
|
973
783
|
const parts = path.split(".");
|
|
974
|
-
const root = Array.isArray(obj) ? obj.slice() : {
|
|
784
|
+
const root = Array.isArray(obj) ? obj.slice() : __spreadValues({}, obj);
|
|
975
785
|
let cur = root;
|
|
976
786
|
for (let i = 0; i < parts.length; i++) {
|
|
977
787
|
const part = parts[i];
|
|
@@ -986,7 +796,7 @@ function setByPath(obj, path, value) {
|
|
|
986
796
|
if (next == null) {
|
|
987
797
|
next = nextIsIndex ? [] : {};
|
|
988
798
|
} else {
|
|
989
|
-
next = Array.isArray(next) ? next.slice() : {
|
|
799
|
+
next = Array.isArray(next) ? next.slice() : __spreadValues({}, next);
|
|
990
800
|
}
|
|
991
801
|
cur[key2] = next;
|
|
992
802
|
cur = next;
|
|
@@ -1112,9 +922,10 @@ function createCursorEl(color, username) {
|
|
|
1112
922
|
return cursor;
|
|
1113
923
|
}
|
|
1114
924
|
function bindCursor(file, options) {
|
|
925
|
+
var _a;
|
|
1115
926
|
const graph = options.graph || file.getUi().editor.graph;
|
|
1116
927
|
const awareness = options.awareness;
|
|
1117
|
-
const mouseMoveThrottle = options.mouseMoveThrottle
|
|
928
|
+
const mouseMoveThrottle = (_a = options.mouseMoveThrottle) != null ? _a : 100;
|
|
1118
929
|
const listener = {
|
|
1119
930
|
startX: 0,
|
|
1120
931
|
startY: 0,
|
|
@@ -1125,7 +936,7 @@ function bindCursor(file, options) {
|
|
|
1125
936
|
mouseUp: function() {
|
|
1126
937
|
},
|
|
1127
938
|
mouseMove: throttle(function(_sender, event) {
|
|
1128
|
-
var
|
|
939
|
+
var _a2;
|
|
1129
940
|
const containerRect = graph.container.getBoundingClientRect();
|
|
1130
941
|
const { translate, scale } = graph.view;
|
|
1131
942
|
const x = Math.round(
|
|
@@ -1137,17 +948,17 @@ function bindCursor(file, options) {
|
|
|
1137
948
|
awareness.setLocalStateField("cursor", {
|
|
1138
949
|
x,
|
|
1139
950
|
y,
|
|
1140
|
-
pageId: (
|
|
951
|
+
pageId: (_a2 = file.getUi().currentPage) == null ? void 0 : _a2.getId()
|
|
1141
952
|
});
|
|
1142
953
|
}, mouseMoveThrottle)
|
|
1143
954
|
};
|
|
1144
955
|
graph.addMouseListener(listener);
|
|
1145
956
|
const handleMouseLeave = () => {
|
|
1146
|
-
var
|
|
957
|
+
var _a2;
|
|
1147
958
|
awareness.setLocalStateField("cursor", {
|
|
1148
959
|
x: 0,
|
|
1149
960
|
y: 0,
|
|
1150
|
-
pageId: (
|
|
961
|
+
pageId: (_a2 = file.getUi().currentPage) == null ? void 0 : _a2.getId(),
|
|
1151
962
|
hide: true
|
|
1152
963
|
});
|
|
1153
964
|
};
|
|
@@ -1301,16 +1112,17 @@ function renderRemoteSelections(ui, remotes) {
|
|
|
1301
1112
|
if (!currentPageRemotes.length) return;
|
|
1302
1113
|
const graph = ui.editor.graph;
|
|
1303
1114
|
currentPageRemotes.forEach(({ clientId, selectionState, userColor }) => {
|
|
1115
|
+
var _a2;
|
|
1304
1116
|
let highlightCellMap = cache.get(clientId);
|
|
1305
1117
|
if (!highlightCellMap) {
|
|
1306
1118
|
highlightCellMap = /* @__PURE__ */ new Map();
|
|
1307
1119
|
cache.set(clientId, highlightCellMap);
|
|
1308
1120
|
}
|
|
1309
|
-
const currentIds = new Set((selectionState == null ? void 0 : selectionState.ids)
|
|
1121
|
+
const currentIds = new Set((_a2 = selectionState == null ? void 0 : selectionState.ids) != null ? _a2 : []);
|
|
1310
1122
|
Array.from(highlightCellMap.keys()).forEach((id) => {
|
|
1311
|
-
var
|
|
1123
|
+
var _a3;
|
|
1312
1124
|
if (!currentIds.has(id)) {
|
|
1313
|
-
(
|
|
1125
|
+
(_a3 = highlightCellMap.get(id)) == null ? void 0 : _a3.destroy();
|
|
1314
1126
|
highlightCellMap.delete(id);
|
|
1315
1127
|
}
|
|
1316
1128
|
});
|
|
@@ -1333,9 +1145,10 @@ function renderRemoteSelections(ui, remotes) {
|
|
|
1333
1145
|
const DEFAULT_USER_NAME_KEY = "user.name";
|
|
1334
1146
|
const DEFAULT_USER_COLOR_KEY = "user.color";
|
|
1335
1147
|
function bindCollaborator(file, options) {
|
|
1148
|
+
var _a, _b;
|
|
1336
1149
|
const graph = options.graph || file.getUi().editor.graph;
|
|
1337
1150
|
const awareness = options.awareness;
|
|
1338
|
-
const mouseMoveThrottle = options.mouseMoveThrottle
|
|
1151
|
+
const mouseMoveThrottle = (_a = options.mouseMoveThrottle) != null ? _a : 100;
|
|
1339
1152
|
const cursorOption = options.cursor;
|
|
1340
1153
|
const userNameKey = typeof cursorOption === "object" && (cursorOption == null ? void 0 : cursorOption.userNameKey) ? cursorOption.userNameKey : DEFAULT_USER_NAME_KEY;
|
|
1341
1154
|
const userColorKey = typeof cursorOption === "object" && (cursorOption == null ? void 0 : cursorOption.userColorKey) ? cursorOption.userColorKey : DEFAULT_USER_COLOR_KEY;
|
|
@@ -1358,7 +1171,7 @@ function bindCollaborator(file, options) {
|
|
|
1358
1171
|
awareness,
|
|
1359
1172
|
graph
|
|
1360
1173
|
});
|
|
1361
|
-
const showCursor = options.cursor
|
|
1174
|
+
const showCursor = (_b = options.cursor) != null ? _b : true;
|
|
1362
1175
|
let cleanupAwareness;
|
|
1363
1176
|
if (typeof showCursor === "boolean" && showCursor) {
|
|
1364
1177
|
const awarenessHandler = (update) => {
|
|
@@ -1404,7 +1217,7 @@ const defaultApplyFileData = (file, xml) => {
|
|
|
1404
1217
|
function mergeFileIntoDoc(doc, fileXml, strategy) {
|
|
1405
1218
|
let parsed;
|
|
1406
1219
|
try {
|
|
1407
|
-
parsed = parse
|
|
1220
|
+
parsed = parse(fileXml);
|
|
1408
1221
|
} catch (err) {
|
|
1409
1222
|
console.warn(
|
|
1410
1223
|
"[y-mxgraph] 合并失败,file XML 解析异常,回退到 replace:",
|
|
@@ -1608,7 +1421,7 @@ class Binding {
|
|
|
1608
1421
|
this.cleanupCollaborator = bindCollaborator(file, {
|
|
1609
1422
|
awareness,
|
|
1610
1423
|
graph,
|
|
1611
|
-
cursor: cursor
|
|
1424
|
+
cursor: cursor != null ? cursor : true,
|
|
1612
1425
|
mouseMoveThrottle
|
|
1613
1426
|
});
|
|
1614
1427
|
}
|
|
@@ -1687,4 +1500,4 @@ export {
|
|
|
1687
1500
|
xml2ydoc,
|
|
1688
1501
|
ydoc2xml
|
|
1689
1502
|
};
|
|
1690
|
-
//# sourceMappingURL=y-mxgraph.
|
|
1503
|
+
//# sourceMappingURL=y-mxgraph.js.map
|