y-mxgraph 0.5.7 → 0.6.0
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 +2 -2
- package/iframe-bridge/provider.cjs.map +1 -1
- package/iframe-bridge/provider.js +2 -2
- package/iframe-bridge/provider.js.map +1 -1
- package/iframe-bridge/server.cjs +4 -3
- package/iframe-bridge/server.cjs.map +1 -1
- package/iframe-bridge/server.js +4 -3
- package/iframe-bridge/server.js.map +1 -1
- package/{index-Dpa3-atS.cjs → index-CcOHH2TY.cjs} +20 -5
- package/index-CcOHH2TY.cjs.map +1 -0
- package/{index-BGGQoepi.js → index-DBU79c0g.js} +20 -5
- package/index-DBU79c0g.js.map +1 -0
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/transform/index.d.ts.map +1 -0
- package/transform.cjs +6 -0
- package/transform.cjs.map +1 -0
- package/transform.js +6 -0
- package/transform.js.map +1 -0
- package/y-mxgraph.cjs +106 -69
- package/y-mxgraph.cjs.map +1 -1
- package/y-mxgraph.js +62 -25
- package/y-mxgraph.js.map +1 -1
- package/index-BGGQoepi.js.map +0 -1
- package/index-Dpa3-atS.cjs.map +0 -1
- package/transformer/index.d.ts.map +0 -1
- package/transformer.cjs +0 -6
- package/transformer.cjs.map +0 -1
- package/transformer.js +0 -6
- package/transformer.js.map +0 -1
- /package/{transformer → transform}/index.d.ts +0 -0
package/y-mxgraph.js
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
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-
|
|
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
|
+
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]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
4
23
|
const DIFF_INSERT = "i";
|
|
5
24
|
const DIFF_REMOVE = "r";
|
|
6
25
|
const DIFF_UPDATE = "u";
|
|
@@ -107,7 +126,7 @@ function applyFilePatch(doc, patch, options) {
|
|
|
107
126
|
}
|
|
108
127
|
return { anchorId, depth };
|
|
109
128
|
};
|
|
110
|
-
const enriched = inserts.map((i) => ({
|
|
129
|
+
const enriched = inserts.map((i) => __spreadValues$1(__spreadValues$1({}, i), computeAnchor(i)));
|
|
111
130
|
enriched.sort((a, b) => {
|
|
112
131
|
const aIdx = a.anchorId ? existingIndex.get(a.anchorId) : -1;
|
|
113
132
|
const bIdx = b.anchorId ? existingIndex.get(b.anchorId) : -1;
|
|
@@ -315,7 +334,7 @@ function initDocSnapshot(doc, resetSnapshot = false) {
|
|
|
315
334
|
}
|
|
316
335
|
}
|
|
317
336
|
function generatePatch(events, explicitDoc) {
|
|
318
|
-
var _a, _b;
|
|
337
|
+
var _a, _b, _c, _d, _e;
|
|
319
338
|
const patch = {};
|
|
320
339
|
const doc = (_b = (_a = events[0]) == null ? void 0 : _a.transaction) == null ? void 0 : _b.doc;
|
|
321
340
|
if (!doc) return patch;
|
|
@@ -345,7 +364,7 @@ function generatePatch(events, explicitDoc) {
|
|
|
345
364
|
u.cells = u.cells || {};
|
|
346
365
|
return u.cells;
|
|
347
366
|
};
|
|
348
|
-
const orderIds = (orderArr == null ? void 0 : orderArr.toArray())
|
|
367
|
+
const orderIds = (_c = orderArr == null ? void 0 : orderArr.toArray()) != null ? _c : [];
|
|
349
368
|
const currDiagramOrder = orderIds.length > 0 ? orderIds : diagramsMap ? Array.from(diagramsMap.keys()) : [];
|
|
350
369
|
const diagramsList = currDiagramOrder.map((id) => diagramsMap.get(id)).filter((d) => !!d);
|
|
351
370
|
const currCellsOrder = /* @__PURE__ */ new Map();
|
|
@@ -441,10 +460,9 @@ function generatePatch(events, explicitDoc) {
|
|
|
441
460
|
const attrs = attrsMap.get(cid) || {};
|
|
442
461
|
const index = currCells.indexOf(cid);
|
|
443
462
|
const previous = index <= 0 ? "" : currCells[index - 1];
|
|
444
|
-
cells[DIFF_INSERT].push({
|
|
445
|
-
...attrs,
|
|
463
|
+
cells[DIFF_INSERT].push(__spreadProps(__spreadValues$1({}, attrs), {
|
|
446
464
|
previous
|
|
447
|
-
});
|
|
465
|
+
}));
|
|
448
466
|
insertedCellIdGlobal.add(cid);
|
|
449
467
|
}
|
|
450
468
|
}
|
|
@@ -532,8 +550,8 @@ function generatePatch(events, explicitDoc) {
|
|
|
532
550
|
const cellUpdate = updateBucket[cid] = updateBucket[cid] || {};
|
|
533
551
|
let changed = false;
|
|
534
552
|
for (const k of keys) {
|
|
535
|
-
const pv = prevAttrs[k]
|
|
536
|
-
const cv = currAttrs[k]
|
|
553
|
+
const pv = (_d = prevAttrs[k]) != null ? _d : "";
|
|
554
|
+
const cv = (_e = currAttrs[k]) != null ? _e : "";
|
|
537
555
|
if (pv !== cv) {
|
|
538
556
|
cellUpdate[k] = cv;
|
|
539
557
|
changed = true;
|
|
@@ -556,7 +574,7 @@ function generatePatch(events, explicitDoc) {
|
|
|
556
574
|
for (const [did, attrsMap] of cellAttrMap.entries()) {
|
|
557
575
|
const copy = /* @__PURE__ */ new Map();
|
|
558
576
|
for (const [cid, attrs] of attrsMap.entries()) {
|
|
559
|
-
copy.set(cid, {
|
|
577
|
+
copy.set(cid, __spreadValues$1({}, attrs));
|
|
560
578
|
}
|
|
561
579
|
newCellsAttrs.set(did, copy);
|
|
562
580
|
}
|
|
@@ -602,8 +620,8 @@ function bindUndoManager(doc, file, yUndo) {
|
|
|
602
620
|
this.eventListeners.push(name, fn);
|
|
603
621
|
},
|
|
604
622
|
fireEvent(evt) {
|
|
605
|
-
var _a;
|
|
606
|
-
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 : "");
|
|
607
625
|
for (let i = 0; i + 1 < this.eventListeners.length; i += 2) {
|
|
608
626
|
const key2 = this.eventListeners[i];
|
|
609
627
|
const listener = this.eventListeners[i + 1];
|
|
@@ -715,6 +733,22 @@ function bindUndoManager(doc, file, yUndo) {
|
|
|
715
733
|
};
|
|
716
734
|
return destroy;
|
|
717
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
|
+
};
|
|
718
752
|
function getAwarenessStateValue(awareness, key2, clientId) {
|
|
719
753
|
const states = awareness.getStates();
|
|
720
754
|
const id = clientId != null ? Number(clientId) : awareness.clientID;
|
|
@@ -747,7 +781,7 @@ function setAwarenessStateValue(awareness, key2, value, clientId) {
|
|
|
747
781
|
}
|
|
748
782
|
function setByPath(obj, path, value) {
|
|
749
783
|
const parts = path.split(".");
|
|
750
|
-
const root = Array.isArray(obj) ? obj.slice() : {
|
|
784
|
+
const root = Array.isArray(obj) ? obj.slice() : __spreadValues({}, obj);
|
|
751
785
|
let cur = root;
|
|
752
786
|
for (let i = 0; i < parts.length; i++) {
|
|
753
787
|
const part = parts[i];
|
|
@@ -762,7 +796,7 @@ function setByPath(obj, path, value) {
|
|
|
762
796
|
if (next == null) {
|
|
763
797
|
next = nextIsIndex ? [] : {};
|
|
764
798
|
} else {
|
|
765
|
-
next = Array.isArray(next) ? next.slice() : {
|
|
799
|
+
next = Array.isArray(next) ? next.slice() : __spreadValues({}, next);
|
|
766
800
|
}
|
|
767
801
|
cur[key2] = next;
|
|
768
802
|
cur = next;
|
|
@@ -888,9 +922,10 @@ function createCursorEl(color, username) {
|
|
|
888
922
|
return cursor;
|
|
889
923
|
}
|
|
890
924
|
function bindCursor(file, options) {
|
|
925
|
+
var _a;
|
|
891
926
|
const graph = options.graph || file.getUi().editor.graph;
|
|
892
927
|
const awareness = options.awareness;
|
|
893
|
-
const mouseMoveThrottle = options.mouseMoveThrottle
|
|
928
|
+
const mouseMoveThrottle = (_a = options.mouseMoveThrottle) != null ? _a : 100;
|
|
894
929
|
const listener = {
|
|
895
930
|
startX: 0,
|
|
896
931
|
startY: 0,
|
|
@@ -901,7 +936,7 @@ function bindCursor(file, options) {
|
|
|
901
936
|
mouseUp: function() {
|
|
902
937
|
},
|
|
903
938
|
mouseMove: throttle(function(_sender, event) {
|
|
904
|
-
var
|
|
939
|
+
var _a2;
|
|
905
940
|
const containerRect = graph.container.getBoundingClientRect();
|
|
906
941
|
const { translate, scale } = graph.view;
|
|
907
942
|
const x = Math.round(
|
|
@@ -913,17 +948,17 @@ function bindCursor(file, options) {
|
|
|
913
948
|
awareness.setLocalStateField("cursor", {
|
|
914
949
|
x,
|
|
915
950
|
y,
|
|
916
|
-
pageId: (
|
|
951
|
+
pageId: (_a2 = file.getUi().currentPage) == null ? void 0 : _a2.getId()
|
|
917
952
|
});
|
|
918
953
|
}, mouseMoveThrottle)
|
|
919
954
|
};
|
|
920
955
|
graph.addMouseListener(listener);
|
|
921
956
|
const handleMouseLeave = () => {
|
|
922
|
-
var
|
|
957
|
+
var _a2;
|
|
923
958
|
awareness.setLocalStateField("cursor", {
|
|
924
959
|
x: 0,
|
|
925
960
|
y: 0,
|
|
926
|
-
pageId: (
|
|
961
|
+
pageId: (_a2 = file.getUi().currentPage) == null ? void 0 : _a2.getId(),
|
|
927
962
|
hide: true
|
|
928
963
|
});
|
|
929
964
|
};
|
|
@@ -1077,16 +1112,17 @@ function renderRemoteSelections(ui, remotes) {
|
|
|
1077
1112
|
if (!currentPageRemotes.length) return;
|
|
1078
1113
|
const graph = ui.editor.graph;
|
|
1079
1114
|
currentPageRemotes.forEach(({ clientId, selectionState, userColor }) => {
|
|
1115
|
+
var _a2;
|
|
1080
1116
|
let highlightCellMap = cache.get(clientId);
|
|
1081
1117
|
if (!highlightCellMap) {
|
|
1082
1118
|
highlightCellMap = /* @__PURE__ */ new Map();
|
|
1083
1119
|
cache.set(clientId, highlightCellMap);
|
|
1084
1120
|
}
|
|
1085
|
-
const currentIds = new Set((selectionState == null ? void 0 : selectionState.ids)
|
|
1121
|
+
const currentIds = new Set((_a2 = selectionState == null ? void 0 : selectionState.ids) != null ? _a2 : []);
|
|
1086
1122
|
Array.from(highlightCellMap.keys()).forEach((id) => {
|
|
1087
|
-
var
|
|
1123
|
+
var _a3;
|
|
1088
1124
|
if (!currentIds.has(id)) {
|
|
1089
|
-
(
|
|
1125
|
+
(_a3 = highlightCellMap.get(id)) == null ? void 0 : _a3.destroy();
|
|
1090
1126
|
highlightCellMap.delete(id);
|
|
1091
1127
|
}
|
|
1092
1128
|
});
|
|
@@ -1109,9 +1145,10 @@ function renderRemoteSelections(ui, remotes) {
|
|
|
1109
1145
|
const DEFAULT_USER_NAME_KEY = "user.name";
|
|
1110
1146
|
const DEFAULT_USER_COLOR_KEY = "user.color";
|
|
1111
1147
|
function bindCollaborator(file, options) {
|
|
1148
|
+
var _a, _b;
|
|
1112
1149
|
const graph = options.graph || file.getUi().editor.graph;
|
|
1113
1150
|
const awareness = options.awareness;
|
|
1114
|
-
const mouseMoveThrottle = options.mouseMoveThrottle
|
|
1151
|
+
const mouseMoveThrottle = (_a = options.mouseMoveThrottle) != null ? _a : 100;
|
|
1115
1152
|
const cursorOption = options.cursor;
|
|
1116
1153
|
const userNameKey = typeof cursorOption === "object" && (cursorOption == null ? void 0 : cursorOption.userNameKey) ? cursorOption.userNameKey : DEFAULT_USER_NAME_KEY;
|
|
1117
1154
|
const userColorKey = typeof cursorOption === "object" && (cursorOption == null ? void 0 : cursorOption.userColorKey) ? cursorOption.userColorKey : DEFAULT_USER_COLOR_KEY;
|
|
@@ -1134,7 +1171,7 @@ function bindCollaborator(file, options) {
|
|
|
1134
1171
|
awareness,
|
|
1135
1172
|
graph
|
|
1136
1173
|
});
|
|
1137
|
-
const showCursor = options.cursor
|
|
1174
|
+
const showCursor = (_b = options.cursor) != null ? _b : true;
|
|
1138
1175
|
let cleanupAwareness;
|
|
1139
1176
|
if (typeof showCursor === "boolean" && showCursor) {
|
|
1140
1177
|
const awarenessHandler = (update) => {
|
|
@@ -1384,7 +1421,7 @@ class Binding {
|
|
|
1384
1421
|
this.cleanupCollaborator = bindCollaborator(file, {
|
|
1385
1422
|
awareness,
|
|
1386
1423
|
graph,
|
|
1387
|
-
cursor: cursor
|
|
1424
|
+
cursor: cursor != null ? cursor : true,
|
|
1388
1425
|
mouseMoveThrottle
|
|
1389
1426
|
});
|
|
1390
1427
|
}
|