@cocreate/text 1.23.4 → 1.23.5
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +8 -0
- package/package.json +7 -7
- package/src/index.js +11 -20
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [1.23.5](https://github.com/CoCreate-app/CoCreate-text/compare/v1.23.4...v1.23.5) (2023-10-14)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* bump dependencies ([df2dcb5](https://github.com/CoCreate-app/CoCreate-text/commit/df2dcb567ae7ad79b534b01d5ee5ef03b53572e7))
|
7
|
+
* formating ([8ec34e1](https://github.com/CoCreate-app/CoCreate-text/commit/8ec34e151b8fccfe2eff2474e58247f313e2cc5f))
|
8
|
+
|
1
9
|
## [1.23.4](https://github.com/CoCreate-app/CoCreate-text/compare/v1.23.3...v1.23.4) (2023-10-09)
|
2
10
|
|
3
11
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@cocreate/text",
|
3
|
-
"version": "1.23.
|
3
|
+
"version": "1.23.5",
|
4
4
|
"description": "A simple text component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
|
5
5
|
"keywords": [
|
6
6
|
"text",
|
@@ -58,12 +58,12 @@
|
|
58
58
|
"webpack-log": "^3.0.1"
|
59
59
|
},
|
60
60
|
"dependencies": {
|
61
|
-
"@cocreate/actions": "^1.11.
|
62
|
-
"@cocreate/crdt": "^1.22.
|
63
|
-
"@cocreate/cursors": "^1.20.
|
64
|
-
"@cocreate/observer": "^1.11.
|
65
|
-
"@cocreate/selection": "^1.9.
|
66
|
-
"@cocreate/utils": "^1.25.
|
61
|
+
"@cocreate/actions": "^1.11.6",
|
62
|
+
"@cocreate/crdt": "^1.22.4",
|
63
|
+
"@cocreate/cursors": "^1.20.4",
|
64
|
+
"@cocreate/observer": "^1.11.5",
|
65
|
+
"@cocreate/selection": "^1.9.4",
|
66
|
+
"@cocreate/utils": "^1.25.3",
|
67
67
|
"@cocreate/uuid": "^1.7.2"
|
68
68
|
}
|
69
69
|
}
|
package/src/index.js
CHANGED
@@ -50,8 +50,7 @@ function initElement(element) {
|
|
50
50
|
_addEventListeners(element.contentDocument.documentElement);
|
51
51
|
let Document = element.contentDocument;
|
52
52
|
initDocument(Document);
|
53
|
-
}
|
54
|
-
else if (isCrdt != 'true') {
|
53
|
+
} else if (isCrdt != 'true') {
|
55
54
|
_addEventListeners(element);
|
56
55
|
}
|
57
56
|
}
|
@@ -85,18 +84,16 @@ function initElement(element) {
|
|
85
84
|
let value;
|
86
85
|
if (element.hasAttribute('contenteditable')) {
|
87
86
|
value = element.innerHTML;
|
88
|
-
}
|
89
|
-
else {
|
87
|
+
} else {
|
90
88
|
value = element.value;
|
91
89
|
}
|
90
|
+
|
92
91
|
if (value)
|
93
92
|
crdt.replaceText({ array, object, key, value, crud: isCrud, save: isSave, read: isRead });
|
94
|
-
}
|
95
|
-
else {
|
93
|
+
} else {
|
96
94
|
if (element.hasAttribute('contenteditable')) {
|
97
95
|
element.innerHTML = '';
|
98
|
-
}
|
99
|
-
else {
|
96
|
+
} else {
|
100
97
|
element.value = '';
|
101
98
|
}
|
102
99
|
updateElement({ element, array, object, key, value: response, start: 0 })
|
@@ -187,8 +184,7 @@ function _cut(event) {
|
|
187
184
|
console.log(selection.toString());
|
188
185
|
if (event.clipboardData) {
|
189
186
|
event.clipboardData.setData('text/plain', selection.toString());
|
190
|
-
}
|
191
|
-
else {
|
187
|
+
} else {
|
192
188
|
navigator.clipboard.writeText(selection.toString()).then(function () {
|
193
189
|
/* clipboard successfully set */
|
194
190
|
}, function () {
|
@@ -228,20 +224,16 @@ function _keydown(event) {
|
|
228
224
|
|
229
225
|
if (event.key == "Backspace" && start == end) {
|
230
226
|
updateText({ element, start: start - 1, end, range });
|
231
|
-
}
|
232
|
-
else if (event.key == 'Tab') {
|
227
|
+
} else if (event.key == 'Tab') {
|
233
228
|
updateText({ element, value: "\t", start, range });
|
234
|
-
}
|
235
|
-
else if (event.key == "Enter") {
|
229
|
+
} else if (event.key == "Enter") {
|
236
230
|
updateText({ element, value: "\n", start, range });
|
237
231
|
}
|
238
232
|
event.preventDefault();
|
239
|
-
}
|
240
|
-
else if (event.ctrlKey) {
|
233
|
+
} else if (event.ctrlKey) {
|
241
234
|
if (event.keyCode == 90) {
|
242
235
|
updateText({ element, range, undoRedo: 'undo' });
|
243
|
-
}
|
244
|
-
else if (event.keyCode == 89) {
|
236
|
+
} else if (event.keyCode == 89) {
|
245
237
|
updateText({ element, range, undoRedo: 'redo' });
|
246
238
|
}
|
247
239
|
}
|
@@ -372,8 +364,7 @@ async function updateElement({ element, array, object, key, value, start, length
|
|
372
364
|
if (value) {
|
373
365
|
_updateElementText(element, value, start, start);
|
374
366
|
}
|
375
|
-
}
|
376
|
-
else {
|
367
|
+
} else {
|
377
368
|
let domTextEditor = element;
|
378
369
|
if (string == undefined)
|
379
370
|
string = await crdt.getText({ array, object, key });
|