y-mxgraph 0.5.7 → 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 +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-Dpa3-atS.cjs.map → index-CcOHH2TY.cjs.map} +1 -1
- package/{index-BGGQoepi.js → index-DBU79c0g.js} +20 -5
- package/{index-BGGQoepi.js.map → index-DBU79c0g.js.map} +1 -1
- package/package.json +1 -1
- package/transformer.cjs +1 -1
- package/transformer.js +1 -1
- package/y-mxgraph.cjs +62 -25
- package/y-mxgraph.cjs.map +1 -1
- package/y-mxgraph.js +62 -25
- package/y-mxgraph.js.map +1 -1
package/transformer.js
CHANGED
package/y-mxgraph.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const transformer = require("./index-
|
|
3
|
+
const transformer = require("./index-CcOHH2TY.cjs");
|
|
4
4
|
const Y = require("yjs");
|
|
5
5
|
const colord = require("colord");
|
|
6
6
|
function _interopNamespaceDefault(e) {
|
|
@@ -20,6 +20,25 @@ function _interopNamespaceDefault(e) {
|
|
|
20
20
|
return Object.freeze(n);
|
|
21
21
|
}
|
|
22
22
|
const Y__namespace = /* @__PURE__ */ _interopNamespaceDefault(Y);
|
|
23
|
+
var __defProp$1 = Object.defineProperty;
|
|
24
|
+
var __defProps = Object.defineProperties;
|
|
25
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
26
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
27
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
28
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
29
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
30
|
+
var __spreadValues$1 = (a, b) => {
|
|
31
|
+
for (var prop in b || (b = {}))
|
|
32
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
33
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
34
|
+
if (__getOwnPropSymbols$1)
|
|
35
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
36
|
+
if (__propIsEnum$1.call(b, prop))
|
|
37
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
38
|
+
}
|
|
39
|
+
return a;
|
|
40
|
+
};
|
|
41
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
42
|
const DIFF_INSERT = "i";
|
|
24
43
|
const DIFF_REMOVE = "r";
|
|
25
44
|
const DIFF_UPDATE = "u";
|
|
@@ -126,7 +145,7 @@ function applyFilePatch(doc, patch, options) {
|
|
|
126
145
|
}
|
|
127
146
|
return { anchorId, depth };
|
|
128
147
|
};
|
|
129
|
-
const enriched = inserts.map((i) => ({
|
|
148
|
+
const enriched = inserts.map((i) => __spreadValues$1(__spreadValues$1({}, i), computeAnchor(i)));
|
|
130
149
|
enriched.sort((a, b) => {
|
|
131
150
|
const aIdx = a.anchorId ? existingIndex.get(a.anchorId) : -1;
|
|
132
151
|
const bIdx = b.anchorId ? existingIndex.get(b.anchorId) : -1;
|
|
@@ -334,7 +353,7 @@ function initDocSnapshot(doc, resetSnapshot = false) {
|
|
|
334
353
|
}
|
|
335
354
|
}
|
|
336
355
|
function generatePatch(events, explicitDoc) {
|
|
337
|
-
var _a, _b;
|
|
356
|
+
var _a, _b, _c, _d, _e;
|
|
338
357
|
const patch = {};
|
|
339
358
|
const doc = (_b = (_a = events[0]) == null ? void 0 : _a.transaction) == null ? void 0 : _b.doc;
|
|
340
359
|
if (!doc) return patch;
|
|
@@ -364,7 +383,7 @@ function generatePatch(events, explicitDoc) {
|
|
|
364
383
|
u.cells = u.cells || {};
|
|
365
384
|
return u.cells;
|
|
366
385
|
};
|
|
367
|
-
const orderIds = (orderArr == null ? void 0 : orderArr.toArray())
|
|
386
|
+
const orderIds = (_c = orderArr == null ? void 0 : orderArr.toArray()) != null ? _c : [];
|
|
368
387
|
const currDiagramOrder = orderIds.length > 0 ? orderIds : diagramsMap ? Array.from(diagramsMap.keys()) : [];
|
|
369
388
|
const diagramsList = currDiagramOrder.map((id) => diagramsMap.get(id)).filter((d) => !!d);
|
|
370
389
|
const currCellsOrder = /* @__PURE__ */ new Map();
|
|
@@ -460,10 +479,9 @@ function generatePatch(events, explicitDoc) {
|
|
|
460
479
|
const attrs = attrsMap.get(cid) || {};
|
|
461
480
|
const index = currCells.indexOf(cid);
|
|
462
481
|
const previous = index <= 0 ? "" : currCells[index - 1];
|
|
463
|
-
cells[DIFF_INSERT].push({
|
|
464
|
-
...attrs,
|
|
482
|
+
cells[DIFF_INSERT].push(__spreadProps(__spreadValues$1({}, attrs), {
|
|
465
483
|
previous
|
|
466
|
-
});
|
|
484
|
+
}));
|
|
467
485
|
insertedCellIdGlobal.add(cid);
|
|
468
486
|
}
|
|
469
487
|
}
|
|
@@ -551,8 +569,8 @@ function generatePatch(events, explicitDoc) {
|
|
|
551
569
|
const cellUpdate = updateBucket[cid] = updateBucket[cid] || {};
|
|
552
570
|
let changed = false;
|
|
553
571
|
for (const k of keys) {
|
|
554
|
-
const pv = prevAttrs[k]
|
|
555
|
-
const cv = currAttrs[k]
|
|
572
|
+
const pv = (_d = prevAttrs[k]) != null ? _d : "";
|
|
573
|
+
const cv = (_e = currAttrs[k]) != null ? _e : "";
|
|
556
574
|
if (pv !== cv) {
|
|
557
575
|
cellUpdate[k] = cv;
|
|
558
576
|
changed = true;
|
|
@@ -575,7 +593,7 @@ function generatePatch(events, explicitDoc) {
|
|
|
575
593
|
for (const [did, attrsMap] of cellAttrMap.entries()) {
|
|
576
594
|
const copy = /* @__PURE__ */ new Map();
|
|
577
595
|
for (const [cid, attrs] of attrsMap.entries()) {
|
|
578
|
-
copy.set(cid, {
|
|
596
|
+
copy.set(cid, __spreadValues$1({}, attrs));
|
|
579
597
|
}
|
|
580
598
|
newCellsAttrs.set(did, copy);
|
|
581
599
|
}
|
|
@@ -621,8 +639,8 @@ function bindUndoManager(doc, file, yUndo) {
|
|
|
621
639
|
this.eventListeners.push(name, fn);
|
|
622
640
|
},
|
|
623
641
|
fireEvent(evt) {
|
|
624
|
-
var _a;
|
|
625
|
-
const eventName = (evt == null ? void 0 : evt.name) || (((_a = evt == null ? void 0 : evt.getName) == null ? void 0 : _a.call(evt))
|
|
642
|
+
var _a, _b;
|
|
643
|
+
const eventName = (evt == null ? void 0 : evt.name) || ((_b = (_a = evt == null ? void 0 : evt.getName) == null ? void 0 : _a.call(evt)) != null ? _b : "");
|
|
626
644
|
for (let i = 0; i + 1 < this.eventListeners.length; i += 2) {
|
|
627
645
|
const key = this.eventListeners[i];
|
|
628
646
|
const listener = this.eventListeners[i + 1];
|
|
@@ -734,6 +752,22 @@ function bindUndoManager(doc, file, yUndo) {
|
|
|
734
752
|
};
|
|
735
753
|
return destroy;
|
|
736
754
|
}
|
|
755
|
+
var __defProp = Object.defineProperty;
|
|
756
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
757
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
758
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
759
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
760
|
+
var __spreadValues = (a, b) => {
|
|
761
|
+
for (var prop in b || (b = {}))
|
|
762
|
+
if (__hasOwnProp.call(b, prop))
|
|
763
|
+
__defNormalProp(a, prop, b[prop]);
|
|
764
|
+
if (__getOwnPropSymbols)
|
|
765
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
766
|
+
if (__propIsEnum.call(b, prop))
|
|
767
|
+
__defNormalProp(a, prop, b[prop]);
|
|
768
|
+
}
|
|
769
|
+
return a;
|
|
770
|
+
};
|
|
737
771
|
function getAwarenessStateValue(awareness, key, clientId) {
|
|
738
772
|
const states = awareness.getStates();
|
|
739
773
|
const id = clientId != null ? Number(clientId) : awareness.clientID;
|
|
@@ -766,7 +800,7 @@ function setAwarenessStateValue(awareness, key, value, clientId) {
|
|
|
766
800
|
}
|
|
767
801
|
function setByPath(obj, path, value) {
|
|
768
802
|
const parts = path.split(".");
|
|
769
|
-
const root = Array.isArray(obj) ? obj.slice() : {
|
|
803
|
+
const root = Array.isArray(obj) ? obj.slice() : __spreadValues({}, obj);
|
|
770
804
|
let cur = root;
|
|
771
805
|
for (let i = 0; i < parts.length; i++) {
|
|
772
806
|
const part = parts[i];
|
|
@@ -781,7 +815,7 @@ function setByPath(obj, path, value) {
|
|
|
781
815
|
if (next == null) {
|
|
782
816
|
next = nextIsIndex ? [] : {};
|
|
783
817
|
} else {
|
|
784
|
-
next = Array.isArray(next) ? next.slice() : {
|
|
818
|
+
next = Array.isArray(next) ? next.slice() : __spreadValues({}, next);
|
|
785
819
|
}
|
|
786
820
|
cur[key] = next;
|
|
787
821
|
cur = next;
|
|
@@ -907,9 +941,10 @@ function createCursorEl(color, username) {
|
|
|
907
941
|
return cursor;
|
|
908
942
|
}
|
|
909
943
|
function bindCursor(file, options) {
|
|
944
|
+
var _a;
|
|
910
945
|
const graph = options.graph || file.getUi().editor.graph;
|
|
911
946
|
const awareness = options.awareness;
|
|
912
|
-
const mouseMoveThrottle = options.mouseMoveThrottle
|
|
947
|
+
const mouseMoveThrottle = (_a = options.mouseMoveThrottle) != null ? _a : 100;
|
|
913
948
|
const listener = {
|
|
914
949
|
startX: 0,
|
|
915
950
|
startY: 0,
|
|
@@ -920,7 +955,7 @@ function bindCursor(file, options) {
|
|
|
920
955
|
mouseUp: function() {
|
|
921
956
|
},
|
|
922
957
|
mouseMove: throttle(function(_sender, event) {
|
|
923
|
-
var
|
|
958
|
+
var _a2;
|
|
924
959
|
const containerRect = graph.container.getBoundingClientRect();
|
|
925
960
|
const { translate, scale } = graph.view;
|
|
926
961
|
const x = Math.round(
|
|
@@ -932,17 +967,17 @@ function bindCursor(file, options) {
|
|
|
932
967
|
awareness.setLocalStateField("cursor", {
|
|
933
968
|
x,
|
|
934
969
|
y,
|
|
935
|
-
pageId: (
|
|
970
|
+
pageId: (_a2 = file.getUi().currentPage) == null ? void 0 : _a2.getId()
|
|
936
971
|
});
|
|
937
972
|
}, mouseMoveThrottle)
|
|
938
973
|
};
|
|
939
974
|
graph.addMouseListener(listener);
|
|
940
975
|
const handleMouseLeave = () => {
|
|
941
|
-
var
|
|
976
|
+
var _a2;
|
|
942
977
|
awareness.setLocalStateField("cursor", {
|
|
943
978
|
x: 0,
|
|
944
979
|
y: 0,
|
|
945
|
-
pageId: (
|
|
980
|
+
pageId: (_a2 = file.getUi().currentPage) == null ? void 0 : _a2.getId(),
|
|
946
981
|
hide: true
|
|
947
982
|
});
|
|
948
983
|
};
|
|
@@ -1096,16 +1131,17 @@ function renderRemoteSelections(ui, remotes) {
|
|
|
1096
1131
|
if (!currentPageRemotes.length) return;
|
|
1097
1132
|
const graph = ui.editor.graph;
|
|
1098
1133
|
currentPageRemotes.forEach(({ clientId, selectionState, userColor }) => {
|
|
1134
|
+
var _a2;
|
|
1099
1135
|
let highlightCellMap = cache.get(clientId);
|
|
1100
1136
|
if (!highlightCellMap) {
|
|
1101
1137
|
highlightCellMap = /* @__PURE__ */ new Map();
|
|
1102
1138
|
cache.set(clientId, highlightCellMap);
|
|
1103
1139
|
}
|
|
1104
|
-
const currentIds = new Set((selectionState == null ? void 0 : selectionState.ids)
|
|
1140
|
+
const currentIds = new Set((_a2 = selectionState == null ? void 0 : selectionState.ids) != null ? _a2 : []);
|
|
1105
1141
|
Array.from(highlightCellMap.keys()).forEach((id) => {
|
|
1106
|
-
var
|
|
1142
|
+
var _a3;
|
|
1107
1143
|
if (!currentIds.has(id)) {
|
|
1108
|
-
(
|
|
1144
|
+
(_a3 = highlightCellMap.get(id)) == null ? void 0 : _a3.destroy();
|
|
1109
1145
|
highlightCellMap.delete(id);
|
|
1110
1146
|
}
|
|
1111
1147
|
});
|
|
@@ -1128,9 +1164,10 @@ function renderRemoteSelections(ui, remotes) {
|
|
|
1128
1164
|
const DEFAULT_USER_NAME_KEY = "user.name";
|
|
1129
1165
|
const DEFAULT_USER_COLOR_KEY = "user.color";
|
|
1130
1166
|
function bindCollaborator(file, options) {
|
|
1167
|
+
var _a, _b;
|
|
1131
1168
|
const graph = options.graph || file.getUi().editor.graph;
|
|
1132
1169
|
const awareness = options.awareness;
|
|
1133
|
-
const mouseMoveThrottle = options.mouseMoveThrottle
|
|
1170
|
+
const mouseMoveThrottle = (_a = options.mouseMoveThrottle) != null ? _a : 100;
|
|
1134
1171
|
const cursorOption = options.cursor;
|
|
1135
1172
|
const userNameKey = typeof cursorOption === "object" && (cursorOption == null ? void 0 : cursorOption.userNameKey) ? cursorOption.userNameKey : DEFAULT_USER_NAME_KEY;
|
|
1136
1173
|
const userColorKey = typeof cursorOption === "object" && (cursorOption == null ? void 0 : cursorOption.userColorKey) ? cursorOption.userColorKey : DEFAULT_USER_COLOR_KEY;
|
|
@@ -1153,7 +1190,7 @@ function bindCollaborator(file, options) {
|
|
|
1153
1190
|
awareness,
|
|
1154
1191
|
graph
|
|
1155
1192
|
});
|
|
1156
|
-
const showCursor = options.cursor
|
|
1193
|
+
const showCursor = (_b = options.cursor) != null ? _b : true;
|
|
1157
1194
|
let cleanupAwareness;
|
|
1158
1195
|
if (typeof showCursor === "boolean" && showCursor) {
|
|
1159
1196
|
const awarenessHandler = (update) => {
|
|
@@ -1403,7 +1440,7 @@ class Binding {
|
|
|
1403
1440
|
this.cleanupCollaborator = bindCollaborator(file, {
|
|
1404
1441
|
awareness,
|
|
1405
1442
|
graph,
|
|
1406
|
-
cursor: cursor
|
|
1443
|
+
cursor: cursor != null ? cursor : true,
|
|
1407
1444
|
mouseMoveThrottle
|
|
1408
1445
|
});
|
|
1409
1446
|
}
|