@cocreate/cursors 1.20.5 → 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 +7 -0
- package/package.json +2 -2
- package/src/index.js +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
|
|
1
8
|
## [1.20.5](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.20.4...v1.20.5) (2023-10-14)
|
|
2
9
|
|
|
3
10
|
|
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",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@cocreate/local-storage": "^1.10.5",
|
|
63
|
-
"@cocreate/message-client": "^1.8.3",
|
|
64
63
|
"@cocreate/observer": "^1.11.5",
|
|
65
64
|
"@cocreate/random-color": "^1.7.2",
|
|
66
65
|
"@cocreate/selection": "^1.9.4",
|
|
66
|
+
"@cocreate/socket-client": "^1.31.0",
|
|
67
67
|
"@cocreate/utils": "^1.25.3",
|
|
68
68
|
"@cocreate/uuid": "^1.7.2"
|
|
69
69
|
}
|
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,8 +342,8 @@ function initResizeObserver(element) {
|
|
|
342
342
|
|
|
343
343
|
function sendPosition(info) {
|
|
344
344
|
try {
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
socket.send({
|
|
346
|
+
method: "cursor",
|
|
347
347
|
data: {
|
|
348
348
|
array: info.array,
|
|
349
349
|
object: info.object,
|
|
@@ -364,8 +364,8 @@ function sendPosition(info) {
|
|
|
364
364
|
}
|
|
365
365
|
|
|
366
366
|
|
|
367
|
-
|
|
368
|
-
// if (
|
|
367
|
+
socket.listen('cursor', function (response) {
|
|
368
|
+
// if (socket.has(selection.socketId)) return;
|
|
369
369
|
let selection = response.data
|
|
370
370
|
selection.socketId = response.socketId
|
|
371
371
|
if (selection.start != null && selection.end != null)
|