@cocreate/cursors 1.20.4 → 1.20.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/CHANGELOG.md +15 -0
- package/package.json +6 -6
- package/src/index.js +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [1.20.6](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.20.5...v1.20.6) (2023-10-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* removed @cocreate/message-client ([50548ed](https://github.com/CoCreate-app/CoCreate-cursors/commit/50548ed558f40f1fa95ccbc24ffaa29cc97769ca))
|
|
7
|
+
|
|
8
|
+
## [1.20.5](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.20.4...v1.20.5) (2023-10-14)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* add missing socketId ([bc855f8](https://github.com/CoCreate-app/CoCreate-cursors/commit/bc855f8458084899a74d89f15994e3e767675850))
|
|
14
|
+
* bump dependencies ([53cbfe3](https://github.com/CoCreate-app/CoCreate-cursors/commit/53cbfe387f8d682ad3c03748d2582fd79ce79aad))
|
|
15
|
+
|
|
1
16
|
## [1.20.4](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.20.3...v1.20.4) (2023-10-09)
|
|
2
17
|
|
|
3
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/cursors",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.6",
|
|
4
4
|
"description": "Collaborative user cursor position for inputs, textarea's and contenteditable elements.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cursors",
|
|
@@ -59,12 +59,12 @@
|
|
|
59
59
|
"webpack-log": "^3.0.1"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@cocreate/local-storage": "^1.10.
|
|
63
|
-
"@cocreate/
|
|
64
|
-
"@cocreate/observer": "^1.11.4",
|
|
62
|
+
"@cocreate/local-storage": "^1.10.5",
|
|
63
|
+
"@cocreate/observer": "^1.11.5",
|
|
65
64
|
"@cocreate/random-color": "^1.7.2",
|
|
66
|
-
"@cocreate/selection": "^1.9.
|
|
67
|
-
"@cocreate/
|
|
65
|
+
"@cocreate/selection": "^1.9.4",
|
|
66
|
+
"@cocreate/socket-client": "^1.31.0",
|
|
67
|
+
"@cocreate/utils": "^1.25.3",
|
|
68
68
|
"@cocreate/uuid": "^1.7.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/src/index.js
CHANGED
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
/*globals ResizeObserver*/
|
|
24
24
|
import observer from '@cocreate/observer';
|
|
25
25
|
import { getAttributeNames } from '@cocreate/utils';
|
|
26
|
-
import
|
|
26
|
+
import socket from '@cocreate/socket-client';
|
|
27
27
|
import uuid from '@cocreate/uuid';
|
|
28
28
|
import localStorage from '@cocreate/local-storage';
|
|
29
29
|
import { getElementPosition } from '@cocreate/selection';
|
|
30
30
|
import { randomColor } from '@cocreate/random-color';
|
|
31
31
|
import './index.css';
|
|
32
32
|
|
|
33
|
-
const clientId =
|
|
33
|
+
const clientId = socket.clientId || uuid.generate(12);
|
|
34
34
|
const cursorBackground = randomColor();
|
|
35
35
|
|
|
36
36
|
let environment_prod = true;
|
|
@@ -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 &&
|
|
95
|
+
if (window.activeElement == element && socket.has(selection.socketId)) {
|
|
96
96
|
continue;
|
|
97
97
|
}
|
|
98
98
|
let realtime = element.getAttribute('realtime');
|
|
@@ -342,9 +342,8 @@ function initResizeObserver(element) {
|
|
|
342
342
|
|
|
343
343
|
function sendPosition(info) {
|
|
344
344
|
try {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
message: "cursor",
|
|
345
|
+
socket.send({
|
|
346
|
+
method: "cursor",
|
|
348
347
|
data: {
|
|
349
348
|
array: info.array,
|
|
350
349
|
object: info.object,
|
|
@@ -365,9 +364,10 @@ function sendPosition(info) {
|
|
|
365
364
|
}
|
|
366
365
|
|
|
367
366
|
|
|
368
|
-
|
|
369
|
-
// if (
|
|
367
|
+
socket.listen('cursor', function (response) {
|
|
368
|
+
// if (socket.has(selection.socketId)) return;
|
|
370
369
|
let selection = response.data
|
|
370
|
+
selection.socketId = response.socketId
|
|
371
371
|
if (selection.start != null && selection.end != null)
|
|
372
372
|
drawCursors(selection);
|
|
373
373
|
else
|