@cocreate/cursors 1.12.23 → 1.13.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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.13.1](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.13.0...v1.13.1) (2022-12-20)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * bump dependencies ([525f021](https://github.com/CoCreate-app/CoCreate-cursors/commit/525f02150cd4359e299d00e4b039952d75df138e))
7
+
8
+ # [1.13.0](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.12.23...v1.13.0) (2022-12-17)
9
+
10
+
11
+ ### Features
12
+
13
+ * improved cursor mirror accuracy ([184e1f4](https://github.com/CoCreate-app/CoCreate-cursors/commit/184e1f452dfc23cadd642e415f2d6b7397031a7e))
14
+
1
15
  ## [1.12.23](https://github.com/CoCreate-app/CoCreate-cursors/compare/v1.12.22...v1.12.23) (2022-12-15)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/cursors",
3
- "version": "1.12.23",
3
+ "version": "1.13.1",
4
4
  "description": "Collaborative user cursor position for inputs, textarea's and contenteditable elements.",
5
5
  "keywords": [
6
6
  "cursors",
@@ -61,12 +61,12 @@
61
61
  "webpack-log": "^3.0.1"
62
62
  },
63
63
  "dependencies": {
64
- "@cocreate/crud-client": "^1.16.11",
65
- "@cocreate/docs": "^1.4.19",
66
- "@cocreate/message-client": "^1.1.108",
67
- "@cocreate/observer": "^1.5.39",
68
- "@cocreate/random-color": "^1.2.56",
69
- "@cocreate/selection": "^1.4.44",
70
- "@cocreate/uuid": "^1.2.38"
64
+ "@cocreate/crud-client": "^1.16.16",
65
+ "@cocreate/docs": "^1.4.20",
66
+ "@cocreate/message-client": "^1.1.111",
67
+ "@cocreate/observer": "^1.5.42",
68
+ "@cocreate/random-color": "^1.2.59",
69
+ "@cocreate/selection": "^1.4.47",
70
+ "@cocreate/uuid": "^1.2.41"
71
71
  }
72
72
  }
package/src/index.js CHANGED
@@ -121,28 +121,31 @@ function drawCursors(selection) {
121
121
 
122
122
  let computed = getComputedStyle(element);
123
123
  let rect = element.getBoundingClientRect();
124
+
124
125
  let borderWidth = parseInt(computed['border-width']) * 2;
125
126
  let scrollBarWidth = 0;
126
127
  if (element.clientWidth != 0)
127
128
  scrollBarWidth = element.offsetWidth - element.clientWidth - borderWidth;
128
- let style = mirrorDiv.style;
129
129
 
130
+ let style = mirrorDiv.style;
130
131
  style.position = 'absolute';
131
132
  style.width = rect.width + 'px';
132
133
  style.height = rect.height + 'px';
133
- style.visibility = 'visible';
134
134
  style.overflowX = computed['overflowX'];
135
135
  style.overflowY = computed['overflowY'];
136
136
  style.margin = '0px';
137
- style.paddingRight = parseInt(computed['paddingRight']) + scrollBarWidth + 'px';
137
+ style.padding = computed['padding'];
138
138
  style.border = computed['border'];
139
139
  style.borderColor = 'transparent';
140
-
140
+ style.outline = computed['outline'];
141
+ style.outlineColor = 'transparent';
142
+ style.boxSizing = computed['boxSizing'];
143
+ style.lineHeight = computed['lineHeight'];
144
+
141
145
  if (element.parentElement.style['display'] == 'inline') {
142
146
  style.top = element.clientTop + 'px';
143
147
  style.left = element.clientLeft + 'px';
144
- }
145
- else {
148
+ } else {
146
149
  style.top = element.offsetTop + 'px';
147
150
  style.left = element.offsetLeft + 'px';
148
151
  }
@@ -150,12 +153,11 @@ function drawCursors(selection) {
150
153
  if (element.nodeName !== 'INPUT') {
151
154
  style.wordWrap = 'break-word';
152
155
  style.whiteSpace = 'pre-wrap';
153
- }
154
- else {
156
+ } else {
155
157
  style.whiteSpace = 'pre';
156
158
  }
157
159
 
158
- let properties = ['boxSizing', 'borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth', 'paddingTop', 'paddingBottom', 'paddingLeft', 'fontStyle', 'fontVariant', 'fontWeight', 'fontStretch', 'fontSize', 'lineHeight', 'fontFamily', 'textAlign', 'textTransform', 'textIndent', 'textDecoration', 'letterSpacing', 'wordSpacing', 'textRendering', 'webkitWritingMode', 'textTransform', 'textIndent', 'overflowWrap'];
160
+ let properties = ['fontStyle', 'fontVariant', 'fontWeight', 'fontStretch', 'fontSize', 'fontFamily', 'letterSpacing', 'lineHeight', 'textAlign', 'textTransform', 'textIndent', 'textDecoration', 'textRendering', 'textTransform', 'textIndent', 'overflowWrap', 'tabSize', 'webkitWritingMode', 'wordSpacing'];
159
161
 
160
162
  properties.forEach(function(prop) {
161
163
  if (['left', 'top'].indexOf(prop.toLowerCase()) === -1)