@cocreate/cursors 1.20.0 → 1.20.1
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/CHANGELOG.md +8 -0
- package/CoCreate.config.js +24 -24
- package/package.json +2 -2
- package/src/index.js +12 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [1.20.1](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.20.0...v1.20.1) (2023-10-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* replaced socketId with socket.has(data.sockeId) ([b3515d7](https://github.com/CoCreate-app/CoCreate-cursors/commit/b3515d7d13758210624b0e4d0ee6cda2a0c3a382))
|
|
7
|
+
* update to use data.socketId and data.clientId ([1d780ec](https://github.com/CoCreate-app/CoCreate-cursors/commit/1d780ec9998235075347e8da0ed7d753b43cf46c))
|
|
8
|
+
|
|
1
9
|
# [1.20.0](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.19.2...v1.20.0) (2023-09-19)
|
|
2
10
|
|
|
3
11
|
|
package/CoCreate.config.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
"organization_id": "",
|
|
3
|
-
"key": "",
|
|
4
|
-
"host": "",
|
|
5
|
-
"sources": [
|
|
6
|
-
{
|
|
7
|
-
"array": "files",
|
|
8
|
-
"object": {
|
|
9
|
-
"_id": "6019eae64eea0817df303b12",
|
|
10
|
-
"name": "index.html",
|
|
11
|
-
"path": "/docs/cursors",
|
|
12
|
-
"pathname": "/docs/cursors/index.html",
|
|
13
|
-
"src": "{{./docs/index.html}}",
|
|
14
|
-
"host": [
|
|
15
|
-
"*",
|
|
16
|
-
"general.cocreate.app"
|
|
17
|
-
],
|
|
18
|
-
"directory": "cursors",
|
|
19
|
-
"content-type": "{{content-type}}",
|
|
20
|
-
"public": "true"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
}
|
|
1
|
+
module.exports = {
|
|
2
|
+
"organization_id": "",
|
|
3
|
+
"key": "",
|
|
4
|
+
"host": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
{
|
|
7
|
+
"array": "files",
|
|
8
|
+
"object": {
|
|
9
|
+
"_id": "6019eae64eea0817df303b12",
|
|
10
|
+
"name": "index.html",
|
|
11
|
+
"path": "/docs/cursors",
|
|
12
|
+
"pathname": "/docs/cursors/index.html",
|
|
13
|
+
"src": "{{./docs/index.html}}",
|
|
14
|
+
"host": [
|
|
15
|
+
"*",
|
|
16
|
+
"general.cocreate.app"
|
|
17
|
+
],
|
|
18
|
+
"directory": "cursors",
|
|
19
|
+
"content-type": "{{content-type}}",
|
|
20
|
+
"public": "true"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/cursors",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.1",
|
|
4
4
|
"description": "Collaborative user cursor position for inputs, textarea's and contenteditable elements.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cursors",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@cocreate/local-storage": "^1.10.2",
|
|
63
|
-
"@cocreate/message-client": "^1.
|
|
63
|
+
"@cocreate/message-client": "^1.8.0",
|
|
64
64
|
"@cocreate/observer": "^1.11.2",
|
|
65
65
|
"@cocreate/random-color": "^1.7.2",
|
|
66
66
|
"@cocreate/selection": "^1.9.2",
|
package/src/index.js
CHANGED
|
@@ -79,7 +79,7 @@ function initDocument(doc) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
function drawCursors(selection) {
|
|
82
|
-
const socket_id = selection['
|
|
82
|
+
const socket_id = selection['socketId'];
|
|
83
83
|
const array = selection['array'];
|
|
84
84
|
const object = selection['object'];
|
|
85
85
|
const key = selection['key'];
|
|
@@ -92,7 +92,7 @@ function drawCursors(selection) {
|
|
|
92
92
|
elements = document.querySelectorAll(selector);
|
|
93
93
|
}
|
|
94
94
|
for (let element of elements) {
|
|
95
|
-
if (window.activeElement == element && selection.
|
|
95
|
+
if (window.activeElement == element && message.socket.has(selection.socketId)) {
|
|
96
96
|
continue;
|
|
97
97
|
}
|
|
98
98
|
let realtime = element.getAttribute('realtime');
|
|
@@ -106,8 +106,8 @@ function drawCursors(selection) {
|
|
|
106
106
|
if (element.hasAttribute('contenteditable')) {
|
|
107
107
|
let domTextEditor = element;
|
|
108
108
|
if (element.tagName == 'IFRAME') {
|
|
109
|
-
// let frameClientId = element.contentDocument.defaultView.CoCreateSockets.
|
|
110
|
-
// if (frameClientId == selection.
|
|
109
|
+
// let frameClientId = element.contentDocument.defaultView.CoCreateSockets.id;
|
|
110
|
+
// if (frameClientId == selection.socketId) continue;
|
|
111
111
|
domTextEditor = element.contentDocument.documentElement;
|
|
112
112
|
}
|
|
113
113
|
if (!domTextEditor.htmlString)
|
|
@@ -283,7 +283,7 @@ function updateCursors(element) {
|
|
|
283
283
|
let cursors = mirrorDiv.querySelectorAll('cursor');
|
|
284
284
|
|
|
285
285
|
cursors.forEach(function (child_cursor, index, array) {
|
|
286
|
-
let
|
|
286
|
+
let socketId = child_cursor.getAttribute('socket_id');
|
|
287
287
|
let userName = child_cursor.getAttribute('user-name');
|
|
288
288
|
let background = child_cursor.getAttribute('user-background');
|
|
289
289
|
let color = child_cursor.getAttribute('user-color');
|
|
@@ -293,7 +293,7 @@ function updateCursors(element) {
|
|
|
293
293
|
element: [element],
|
|
294
294
|
start,
|
|
295
295
|
end,
|
|
296
|
-
|
|
296
|
+
socketId,
|
|
297
297
|
userName,
|
|
298
298
|
background,
|
|
299
299
|
color
|
|
@@ -303,13 +303,13 @@ function updateCursors(element) {
|
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
-
function removeCursor(
|
|
307
|
-
let elements = document.querySelectorAll(`cursor[socket_id="${
|
|
306
|
+
function removeCursor(socketId) {
|
|
307
|
+
let elements = document.querySelectorAll(`cursor[socket_id="${socketId}"]`);
|
|
308
308
|
elements.forEach(function (element, index, array) {
|
|
309
309
|
element.parentNode.removeChild(element);
|
|
310
310
|
});
|
|
311
311
|
|
|
312
|
-
let sel_elements = document.querySelectorAll(`selection[socket_id="${
|
|
312
|
+
let sel_elements = document.querySelectorAll(`selection[socket_id="${socketId}"]`);
|
|
313
313
|
sel_elements.forEach(function (sel_element, index, array) {
|
|
314
314
|
sel_element.parentNode.removeChild(sel_element);
|
|
315
315
|
});
|
|
@@ -351,13 +351,12 @@ function sendPosition(info) {
|
|
|
351
351
|
key: info.key,
|
|
352
352
|
start: info.start,
|
|
353
353
|
end: info.end,
|
|
354
|
-
clientId: clientId,
|
|
355
354
|
color: info.color || localStorage.getItem("cursorColor"),
|
|
356
355
|
background: info.background || localStorage.getItem("cursorBackground") || cursorBackground,
|
|
357
356
|
userName: info.userName || localStorage.getItem("userName") || clientId,
|
|
358
357
|
user_id: info.user_id || localStorage.getItem("user_id") || clientId
|
|
359
358
|
},
|
|
360
|
-
broadcastBrowser:
|
|
359
|
+
broadcastBrowser: true
|
|
361
360
|
});
|
|
362
361
|
}
|
|
363
362
|
catch (e) {
|
|
@@ -367,12 +366,12 @@ function sendPosition(info) {
|
|
|
367
366
|
|
|
368
367
|
|
|
369
368
|
message.listen('cursor', function (response) {
|
|
370
|
-
// if (selection.
|
|
369
|
+
// if (message.socket.has(selection.socketId)) return;
|
|
371
370
|
let selection = response.data
|
|
372
371
|
if (selection.start != null && selection.end != null)
|
|
373
372
|
drawCursors(selection);
|
|
374
373
|
else
|
|
375
|
-
removeCursor(selection.
|
|
374
|
+
removeCursor(selection.socketId);
|
|
376
375
|
});
|
|
377
376
|
|
|
378
377
|
observer.init({
|