@cocreate/cursors 1.11.6 → 1.11.10
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 +28 -0
- package/package.json +8 -8
- package/src/index.js +26 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## [1.11.10](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.11.9...v1.11.10) (2022-02-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update dependency versions ([21eb6ef](https://github.com/CoCreate-app/CoCreate-cursors/commit/21eb6ef01911e8128274285c11e7673b5ec8ccd3))
|
|
7
|
+
|
|
8
|
+
## [1.11.9](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.11.8...v1.11.9) (2022-01-15)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* cursor was not displaying on inputs ([d608657](https://github.com/CoCreate-app/CoCreate-cursors/commit/d608657598178c16bae66b715f1b79fc4610b1c1))
|
|
14
|
+
|
|
15
|
+
## [1.11.8](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.11.7...v1.11.8) (2022-01-13)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* If element is not contenteditable do not display cursors unless cursors=true ([be7d653](https://github.com/CoCreate-app/CoCreate-cursors/commit/be7d65339d73234f95bbec4400d6ead0adfec9ef))
|
|
21
|
+
|
|
22
|
+
## [1.11.7](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.11.6...v1.11.7) (2022-01-13)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* commented parentElement.style postion:relative and display:inline ([b2123b6](https://github.com/CoCreate-app/CoCreate-cursors/commit/b2123b6ffe9e197f2f071b36c1c3419d9db71619))
|
|
28
|
+
|
|
1
29
|
## [1.11.6](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.11.5...v1.11.6) (2022-01-11)
|
|
2
30
|
|
|
3
31
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/cursors",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.10",
|
|
4
4
|
"description": "Collaborative user cursor position for inputs, textarea's and contenteditable elements.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cursors",
|
|
@@ -62,12 +62,12 @@
|
|
|
62
62
|
"webpack-log": "^3.0.1"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@cocreate/crud-client": "^1.4.
|
|
66
|
-
"@cocreate/docs": "^1.2.
|
|
67
|
-
"@cocreate/message-client": "^1.1.
|
|
68
|
-
"@cocreate/observer": "^1.
|
|
69
|
-
"@cocreate/random-color": "^1.2.
|
|
70
|
-
"@cocreate/selection": "^1.
|
|
71
|
-
"@cocreate/uuid": "^1.1.
|
|
65
|
+
"@cocreate/crud-client": "^1.4.43",
|
|
66
|
+
"@cocreate/docs": "^1.2.65",
|
|
67
|
+
"@cocreate/message-client": "^1.1.60",
|
|
68
|
+
"@cocreate/observer": "^1.4.0",
|
|
69
|
+
"@cocreate/random-color": "^1.2.17",
|
|
70
|
+
"@cocreate/selection": "^1.4.0",
|
|
71
|
+
"@cocreate/uuid": "^1.1.55"
|
|
72
72
|
}
|
|
73
73
|
}
|
package/src/index.js
CHANGED
|
@@ -54,7 +54,7 @@ function drawCursors(selection) {
|
|
|
54
54
|
let elements = selection.element;
|
|
55
55
|
if (!elements) {
|
|
56
56
|
let selector = '[collection="' + collection + '"][document_id="' + document_id + '"][name="' + name + '"]';
|
|
57
|
-
selector += ':not(.codemirror, .
|
|
57
|
+
selector += ':not(.codemirror, .monaco, [actions])';
|
|
58
58
|
elements = document.querySelectorAll(selector);
|
|
59
59
|
}
|
|
60
60
|
for (let element of elements) {
|
|
@@ -64,7 +64,12 @@ function drawCursors(selection) {
|
|
|
64
64
|
}
|
|
65
65
|
let realtime = element.getAttribute('realtime');
|
|
66
66
|
let cursors = element.getAttribute('cursors');
|
|
67
|
+
let contenteditable = element.getAttribute('contenteditable');
|
|
67
68
|
if (realtime == 'false' || cursors == 'false') continue;
|
|
69
|
+
if (element.tagName != 'INPUT' && element.tagName != 'TEXTAREA')
|
|
70
|
+
if (contenteditable == 'false' || contenteditable == null)
|
|
71
|
+
if (cursors != 'true') continue;
|
|
72
|
+
|
|
68
73
|
if (element.hasAttribute('contenteditable')) {
|
|
69
74
|
let domTextEditor = element;
|
|
70
75
|
if (element.tagName == 'IFRAME'){
|
|
@@ -84,6 +89,7 @@ function drawCursors(selection) {
|
|
|
84
89
|
start = pos.start;
|
|
85
90
|
}
|
|
86
91
|
}
|
|
92
|
+
|
|
87
93
|
if(!element) continue;
|
|
88
94
|
let document = element.ownerDocument;
|
|
89
95
|
let mirrorDiv;
|
|
@@ -98,11 +104,14 @@ function drawCursors(selection) {
|
|
|
98
104
|
mirrorDiv.contentEditable = false;
|
|
99
105
|
mirrorDiv.element = element;
|
|
100
106
|
element.insertAdjacentElement('afterend', mirrorDiv);
|
|
101
|
-
let parent = element.parentElement;
|
|
102
|
-
let parentComputed = getComputedStyle(parent);
|
|
103
|
-
let parentStylePosition = parentComputed['position'];
|
|
104
|
-
if (parentStylePosition == 'static')
|
|
105
|
-
|
|
107
|
+
// let parent = element.parentElement;
|
|
108
|
+
// let parentComputed = getComputedStyle(parent);
|
|
109
|
+
// let parentStylePosition = parentComputed['position'];
|
|
110
|
+
// if (parentStylePosition == 'static')
|
|
111
|
+
// parent.style.position = 'relative';
|
|
112
|
+
// let parentStyleDisplay = parentComputed['display'];
|
|
113
|
+
// if (parentStyleDisplay == 'inline')
|
|
114
|
+
// parent.style.display = 'inline';
|
|
106
115
|
|
|
107
116
|
_initEvents(element);
|
|
108
117
|
initDocument(document);
|
|
@@ -117,10 +126,8 @@ function drawCursors(selection) {
|
|
|
117
126
|
if (element.clientWidth != 0)
|
|
118
127
|
scrollBarWidth = element.offsetWidth - element.clientWidth - borderWidth;
|
|
119
128
|
let style = mirrorDiv.style;
|
|
120
|
-
|
|
129
|
+
|
|
121
130
|
style.position = 'absolute';
|
|
122
|
-
style.top = element.offsetTop + 'px';
|
|
123
|
-
style.left = element.offsetLeft + 'px';
|
|
124
131
|
style.width = rect.width + 'px';
|
|
125
132
|
style.height = rect.height + 'px';
|
|
126
133
|
style.visibility = 'visible';
|
|
@@ -130,7 +137,16 @@ function drawCursors(selection) {
|
|
|
130
137
|
style.paddingRight = parseInt(computed['paddingRight']) + scrollBarWidth + 'px';
|
|
131
138
|
style.border = computed['border'];
|
|
132
139
|
style.borderColor = 'transparent';
|
|
133
|
-
|
|
140
|
+
|
|
141
|
+
if (element.parentElement.style['display'] == 'inline') {
|
|
142
|
+
style.top = element.clientTop + 'px';
|
|
143
|
+
style.left = element.clientLeft + 'px';
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
style.top = element.offsetTop + 'px';
|
|
147
|
+
style.left = element.offsetLeft + 'px';
|
|
148
|
+
}
|
|
149
|
+
|
|
134
150
|
if (element.nodeName !== 'INPUT') {
|
|
135
151
|
style.wordWrap = 'break-word';
|
|
136
152
|
style.whiteSpace = 'pre-wrap';
|