y-mxgraph 0.6.5 → 0.6.6
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/binding/collaborator/cursor.d.ts.map +1 -1
- package/binding/collaborator/index.d.ts +3 -0
- package/binding/collaborator/index.d.ts.map +1 -1
- package/binding/index.d.ts +1 -0
- package/binding/index.d.ts.map +1 -1
- package/iframe-bridge/provider.cjs +23 -11
- package/iframe-bridge/provider.cjs.map +1 -1
- package/iframe-bridge/provider.js +23 -11
- package/iframe-bridge/provider.js.map +1 -1
- package/iframe-bridge/server.cjs +5 -1
- package/iframe-bridge/server.cjs.map +1 -1
- package/iframe-bridge/server.js +5 -1
- package/iframe-bridge/server.js.map +1 -1
- package/package.json +1 -1
- package/y-mxgraph.cjs +19 -6
- package/y-mxgraph.cjs.map +1 -1
- package/y-mxgraph.js +19 -6
- package/y-mxgraph.js.map +1 -1
package/y-mxgraph.cjs
CHANGED
|
@@ -914,7 +914,7 @@ function createCursorImage(color) {
|
|
|
914
914
|
return "data:image/svg+xml;base64," + encoded;
|
|
915
915
|
}
|
|
916
916
|
const CacheKey$1 = "__remoteCursor__";
|
|
917
|
-
function createCursorEl(color, username) {
|
|
917
|
+
function createCursorEl(color, username, userAccount) {
|
|
918
918
|
const cursor = document.createElement("div");
|
|
919
919
|
cursor.style.position = "absolute";
|
|
920
920
|
cursor.style.opacity = "0.9";
|
|
@@ -932,11 +932,11 @@ function createCursorEl(color, username) {
|
|
|
932
932
|
name.style.padding = "3px 7px";
|
|
933
933
|
name.style.marginTop = "8px";
|
|
934
934
|
name.style.borderRadius = "10px";
|
|
935
|
-
name.style.maxWidth = "
|
|
935
|
+
name.style.maxWidth = "140px";
|
|
936
936
|
name.style.overflow = "hidden";
|
|
937
937
|
name.style.textOverflow = "ellipsis";
|
|
938
938
|
name.style.whiteSpace = "nowrap";
|
|
939
|
-
name.innerText = username;
|
|
939
|
+
name.innerText = userAccount ? `${username} (${userAccount})` : username;
|
|
940
940
|
cursor.appendChild(name);
|
|
941
941
|
return cursor;
|
|
942
942
|
}
|
|
@@ -1028,7 +1028,7 @@ function renderRemoteCursors(ui, remotes) {
|
|
|
1028
1028
|
const graph = ui.editor.graph;
|
|
1029
1029
|
const { translate, scale } = graph.view;
|
|
1030
1030
|
currentPageRemotes.forEach(
|
|
1031
|
-
({ clientId, cursorState, userColor, userName }) => {
|
|
1031
|
+
({ clientId, cursorState, userColor, userName, userAccount }) => {
|
|
1032
1032
|
if (!cursorState) return;
|
|
1033
1033
|
let el = cache.get(clientId);
|
|
1034
1034
|
if (cursorState.hide) {
|
|
@@ -1039,7 +1039,7 @@ function renderRemoteCursors(ui, remotes) {
|
|
|
1039
1039
|
return;
|
|
1040
1040
|
}
|
|
1041
1041
|
if (!el) {
|
|
1042
|
-
el = createCursorEl(userColor, userName);
|
|
1042
|
+
el = createCursorEl(userColor, userName, userAccount);
|
|
1043
1043
|
ui.diagramContainer.appendChild(el);
|
|
1044
1044
|
cache.set(clientId, el);
|
|
1045
1045
|
}
|
|
@@ -1163,6 +1163,7 @@ function renderRemoteSelections(ui, remotes) {
|
|
|
1163
1163
|
}
|
|
1164
1164
|
const DEFAULT_USER_NAME_KEY = "user.name";
|
|
1165
1165
|
const DEFAULT_USER_COLOR_KEY = "user.color";
|
|
1166
|
+
const DEFAULT_USER_ACCOUNT_KEY = "user.account";
|
|
1166
1167
|
function bindCollaborator(file, options) {
|
|
1167
1168
|
var _a, _b;
|
|
1168
1169
|
const graph = options.graph || file.getUi().editor.graph;
|
|
@@ -1171,6 +1172,7 @@ function bindCollaborator(file, options) {
|
|
|
1171
1172
|
const cursorOption = options.cursor;
|
|
1172
1173
|
const userNameKey = typeof cursorOption === "object" && (cursorOption == null ? void 0 : cursorOption.userNameKey) ? cursorOption.userNameKey : DEFAULT_USER_NAME_KEY;
|
|
1173
1174
|
const userColorKey = typeof cursorOption === "object" && (cursorOption == null ? void 0 : cursorOption.userColorKey) ? cursorOption.userColorKey : DEFAULT_USER_COLOR_KEY;
|
|
1175
|
+
const userAccountKey = typeof cursorOption === "object" && (cursorOption == null ? void 0 : cursorOption.userAccountKey) ? cursorOption.userAccountKey : DEFAULT_USER_ACCOUNT_KEY;
|
|
1174
1176
|
let userName = getAwarenessStateValue(awareness, userNameKey);
|
|
1175
1177
|
if (!userName) {
|
|
1176
1178
|
userName = generateRandomName();
|
|
@@ -1181,6 +1183,7 @@ function bindCollaborator(file, options) {
|
|
|
1181
1183
|
userColor = generateColor(userName);
|
|
1182
1184
|
setAwarenessStateValue(awareness, userColorKey, userColor);
|
|
1183
1185
|
}
|
|
1186
|
+
getAwarenessStateValue(awareness, userAccountKey);
|
|
1184
1187
|
const cleanupCursor = bindCursor(file, {
|
|
1185
1188
|
awareness,
|
|
1186
1189
|
graph,
|
|
@@ -1204,6 +1207,10 @@ function bindCollaborator(file, options) {
|
|
|
1204
1207
|
userColorKey
|
|
1205
1208
|
);
|
|
1206
1209
|
if (newColor) userColor = newColor;
|
|
1210
|
+
getAwarenessStateValue(
|
|
1211
|
+
awareness,
|
|
1212
|
+
userAccountKey
|
|
1213
|
+
);
|
|
1207
1214
|
}
|
|
1208
1215
|
const remotes = /* @__PURE__ */ new Map();
|
|
1209
1216
|
for (const [clientId] of states.entries()) {
|
|
@@ -1211,6 +1218,11 @@ function bindCollaborator(file, options) {
|
|
|
1211
1218
|
if (!changedClientIds.has(clientId)) continue;
|
|
1212
1219
|
const name = getAwarenessStateValue(awareness, userNameKey, clientId) || clientId + "";
|
|
1213
1220
|
const color = getAwarenessStateValue(awareness, userColorKey, clientId) || "#000000";
|
|
1221
|
+
const account = getAwarenessStateValue(
|
|
1222
|
+
awareness,
|
|
1223
|
+
userAccountKey,
|
|
1224
|
+
clientId
|
|
1225
|
+
);
|
|
1214
1226
|
remotes.set(clientId, {
|
|
1215
1227
|
clientId,
|
|
1216
1228
|
cursorState: getAwarenessStateValue(
|
|
@@ -1224,7 +1236,8 @@ function bindCollaborator(file, options) {
|
|
|
1224
1236
|
clientId
|
|
1225
1237
|
),
|
|
1226
1238
|
userColor: color,
|
|
1227
|
-
userName: name
|
|
1239
|
+
userName: name,
|
|
1240
|
+
userAccount: account || void 0
|
|
1228
1241
|
});
|
|
1229
1242
|
}
|
|
1230
1243
|
renderRemoteCursors(file.getUi(), remotes);
|