@cocreate/cursors 1.11.5 → 1.11.9

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 CHANGED
@@ -1,3 +1,31 @@
1
+ ## [1.11.9](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.11.8...v1.11.9) (2022-01-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * cursor was not displaying on inputs ([d608657](https://github.com/CoCreate-app/CoCreate-cursors/commit/d608657598178c16bae66b715f1b79fc4610b1c1))
7
+
8
+ ## [1.11.8](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.11.7...v1.11.8) (2022-01-13)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * If element is not contenteditable do not display cursors unless cursors=true ([be7d653](https://github.com/CoCreate-app/CoCreate-cursors/commit/be7d65339d73234f95bbec4400d6ead0adfec9ef))
14
+
15
+ ## [1.11.7](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.11.6...v1.11.7) (2022-01-13)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * commented parentElement.style postion:relative and display:inline ([b2123b6](https://github.com/CoCreate-app/CoCreate-cursors/commit/b2123b6ffe9e197f2f071b36c1c3419d9db71619))
21
+
22
+ ## [1.11.6](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.11.5...v1.11.6) (2022-01-11)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * removed commented code ([6eabd19](https://github.com/CoCreate-app/CoCreate-cursors/commit/6eabd1955963b44ba6db6259f0a492ddfe2cd54a))
28
+
1
29
  ## [1.11.5](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.11.4...v1.11.5) (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.5",
3
+ "version": "1.11.9",
4
4
  "description": "Collaborative user cursor position for inputs, textarea's and contenteditable elements.",
5
5
  "keywords": [
6
6
  "cursors",
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, .quill, .monaco, [actions])';
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,12 +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 = parent.style.position;
104
- let parentStylePosition = parentComputed['position'];
105
- if (parentStylePosition == 'static')
106
- parent.style.position = 'relative';
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';
107
115
 
108
116
  _initEvents(element);
109
117
  initDocument(document);
@@ -118,10 +126,8 @@ function drawCursors(selection) {
118
126
  if (element.clientWidth != 0)
119
127
  scrollBarWidth = element.offsetWidth - element.clientWidth - borderWidth;
120
128
  let style = mirrorDiv.style;
121
-
129
+
122
130
  style.position = 'absolute';
123
- style.top = element.offsetTop + 'px';
124
- style.left = element.offsetLeft + 'px';
125
131
  style.width = rect.width + 'px';
126
132
  style.height = rect.height + 'px';
127
133
  style.visibility = 'visible';
@@ -131,7 +137,16 @@ function drawCursors(selection) {
131
137
  style.paddingRight = parseInt(computed['paddingRight']) + scrollBarWidth + 'px';
132
138
  style.border = computed['border'];
133
139
  style.borderColor = 'transparent';
134
-
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
+
135
150
  if (element.nodeName !== 'INPUT') {
136
151
  style.wordWrap = 'break-word';
137
152
  style.whiteSpace = 'pre-wrap';