y-mxgraph 0.6.2 → 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 +69 -7
- package/iframe-bridge/provider.cjs.map +1 -1
- package/iframe-bridge/provider.js +69 -7
- 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 +29 -7
- package/y-mxgraph.cjs.map +1 -1
- package/y-mxgraph.js +29 -7
- package/y-mxgraph.js.map +1 -1
package/y-mxgraph.js
CHANGED
|
@@ -895,7 +895,7 @@ function createCursorImage(color) {
|
|
|
895
895
|
return "data:image/svg+xml;base64," + encoded;
|
|
896
896
|
}
|
|
897
897
|
const CacheKey$1 = "__remoteCursor__";
|
|
898
|
-
function createCursorEl(color, username) {
|
|
898
|
+
function createCursorEl(color, username, userAccount) {
|
|
899
899
|
const cursor = document.createElement("div");
|
|
900
900
|
cursor.style.position = "absolute";
|
|
901
901
|
cursor.style.opacity = "0.9";
|
|
@@ -913,11 +913,11 @@ function createCursorEl(color, username) {
|
|
|
913
913
|
name.style.padding = "3px 7px";
|
|
914
914
|
name.style.marginTop = "8px";
|
|
915
915
|
name.style.borderRadius = "10px";
|
|
916
|
-
name.style.maxWidth = "
|
|
916
|
+
name.style.maxWidth = "140px";
|
|
917
917
|
name.style.overflow = "hidden";
|
|
918
918
|
name.style.textOverflow = "ellipsis";
|
|
919
919
|
name.style.whiteSpace = "nowrap";
|
|
920
|
-
name.innerText = username;
|
|
920
|
+
name.innerText = userAccount ? `${username} (${userAccount})` : username;
|
|
921
921
|
cursor.appendChild(name);
|
|
922
922
|
return cursor;
|
|
923
923
|
}
|
|
@@ -1009,7 +1009,7 @@ function renderRemoteCursors(ui, remotes) {
|
|
|
1009
1009
|
const graph = ui.editor.graph;
|
|
1010
1010
|
const { translate, scale } = graph.view;
|
|
1011
1011
|
currentPageRemotes.forEach(
|
|
1012
|
-
({ clientId, cursorState, userColor, userName }) => {
|
|
1012
|
+
({ clientId, cursorState, userColor, userName, userAccount }) => {
|
|
1013
1013
|
if (!cursorState) return;
|
|
1014
1014
|
let el = cache.get(clientId);
|
|
1015
1015
|
if (cursorState.hide) {
|
|
@@ -1020,7 +1020,7 @@ function renderRemoteCursors(ui, remotes) {
|
|
|
1020
1020
|
return;
|
|
1021
1021
|
}
|
|
1022
1022
|
if (!el) {
|
|
1023
|
-
el = createCursorEl(userColor, userName);
|
|
1023
|
+
el = createCursorEl(userColor, userName, userAccount);
|
|
1024
1024
|
ui.diagramContainer.appendChild(el);
|
|
1025
1025
|
cache.set(clientId, el);
|
|
1026
1026
|
}
|
|
@@ -1144,6 +1144,7 @@ function renderRemoteSelections(ui, remotes) {
|
|
|
1144
1144
|
}
|
|
1145
1145
|
const DEFAULT_USER_NAME_KEY = "user.name";
|
|
1146
1146
|
const DEFAULT_USER_COLOR_KEY = "user.color";
|
|
1147
|
+
const DEFAULT_USER_ACCOUNT_KEY = "user.account";
|
|
1147
1148
|
function bindCollaborator(file, options) {
|
|
1148
1149
|
var _a, _b;
|
|
1149
1150
|
const graph = options.graph || file.getUi().editor.graph;
|
|
@@ -1152,6 +1153,7 @@ function bindCollaborator(file, options) {
|
|
|
1152
1153
|
const cursorOption = options.cursor;
|
|
1153
1154
|
const userNameKey = typeof cursorOption === "object" && (cursorOption == null ? void 0 : cursorOption.userNameKey) ? cursorOption.userNameKey : DEFAULT_USER_NAME_KEY;
|
|
1154
1155
|
const userColorKey = typeof cursorOption === "object" && (cursorOption == null ? void 0 : cursorOption.userColorKey) ? cursorOption.userColorKey : DEFAULT_USER_COLOR_KEY;
|
|
1156
|
+
const userAccountKey = typeof cursorOption === "object" && (cursorOption == null ? void 0 : cursorOption.userAccountKey) ? cursorOption.userAccountKey : DEFAULT_USER_ACCOUNT_KEY;
|
|
1155
1157
|
let userName = getAwarenessStateValue(awareness, userNameKey);
|
|
1156
1158
|
if (!userName) {
|
|
1157
1159
|
userName = generateRandomName();
|
|
@@ -1162,6 +1164,7 @@ function bindCollaborator(file, options) {
|
|
|
1162
1164
|
userColor = generateColor(userName);
|
|
1163
1165
|
setAwarenessStateValue(awareness, userColorKey, userColor);
|
|
1164
1166
|
}
|
|
1167
|
+
getAwarenessStateValue(awareness, userAccountKey);
|
|
1165
1168
|
const cleanupCursor = bindCursor(file, {
|
|
1166
1169
|
awareness,
|
|
1167
1170
|
graph,
|
|
@@ -1176,13 +1179,31 @@ function bindCollaborator(file, options) {
|
|
|
1176
1179
|
if (typeof showCursor === "boolean" && showCursor) {
|
|
1177
1180
|
const awarenessHandler = (update) => {
|
|
1178
1181
|
const states = awareness.getStates();
|
|
1179
|
-
const remotes = /* @__PURE__ */ new Map();
|
|
1180
1182
|
const changedClientIds = /* @__PURE__ */ new Set([...update.added, ...update.updated]);
|
|
1183
|
+
if (changedClientIds.has(awareness.clientID)) {
|
|
1184
|
+
const newName = getAwarenessStateValue(awareness, userNameKey);
|
|
1185
|
+
if (newName) userName = newName;
|
|
1186
|
+
const newColor = getAwarenessStateValue(
|
|
1187
|
+
awareness,
|
|
1188
|
+
userColorKey
|
|
1189
|
+
);
|
|
1190
|
+
if (newColor) userColor = newColor;
|
|
1191
|
+
getAwarenessStateValue(
|
|
1192
|
+
awareness,
|
|
1193
|
+
userAccountKey
|
|
1194
|
+
);
|
|
1195
|
+
}
|
|
1196
|
+
const remotes = /* @__PURE__ */ new Map();
|
|
1181
1197
|
for (const [clientId] of states.entries()) {
|
|
1182
1198
|
if (clientId === awareness.clientID) continue;
|
|
1183
1199
|
if (!changedClientIds.has(clientId)) continue;
|
|
1184
1200
|
const name = getAwarenessStateValue(awareness, userNameKey, clientId) || clientId + "";
|
|
1185
1201
|
const color = getAwarenessStateValue(awareness, userColorKey, clientId) || "#000000";
|
|
1202
|
+
const account = getAwarenessStateValue(
|
|
1203
|
+
awareness,
|
|
1204
|
+
userAccountKey,
|
|
1205
|
+
clientId
|
|
1206
|
+
);
|
|
1186
1207
|
remotes.set(clientId, {
|
|
1187
1208
|
clientId,
|
|
1188
1209
|
cursorState: getAwarenessStateValue(
|
|
@@ -1196,7 +1217,8 @@ function bindCollaborator(file, options) {
|
|
|
1196
1217
|
clientId
|
|
1197
1218
|
),
|
|
1198
1219
|
userColor: color,
|
|
1199
|
-
userName: name
|
|
1220
|
+
userName: name,
|
|
1221
|
+
userAccount: account || void 0
|
|
1200
1222
|
});
|
|
1201
1223
|
}
|
|
1202
1224
|
renderRemoteCursors(file.getUi(), remotes);
|