@cocreate/text 1.15.0 → 1.15.4
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/docs/index.html +1 -1
- package/package.json +10 -10
- package/src/index.js +7 -6
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
+
## [1.15.4](https://github.com/CoCreate-app/CoCreate-text/compare/v1.15.3...v1.15.4) (2022-02-03)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* replaced show and hide class hidden with attribute hidden ([1249d5d](https://github.com/CoCreate-app/CoCreate-text/commit/1249d5d188f285db365f6bc31e8fedf2dfee263b))
|
7
|
+
|
8
|
+
## [1.15.3](https://github.com/CoCreate-app/CoCreate-text/compare/v1.15.2...v1.15.3) (2022-02-01)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* update dependency versions ([4079711](https://github.com/CoCreate-app/CoCreate-text/commit/407971197a1fc21dbefdc4419ca836afb369bcad))
|
14
|
+
|
15
|
+
## [1.15.2](https://github.com/CoCreate-app/CoCreate-text/compare/v1.15.1...v1.15.2) (2022-01-31)
|
16
|
+
|
17
|
+
|
18
|
+
### Bug Fixes
|
19
|
+
|
20
|
+
* use string param provided by crdt-update event ([6c05759](https://github.com/CoCreate-app/CoCreate-text/commit/6c05759ac0dd45e5c8123324192d5993ae25b05c))
|
21
|
+
|
22
|
+
## [1.15.1](https://github.com/CoCreate-app/CoCreate-text/compare/v1.15.0...v1.15.1) (2022-01-23)
|
23
|
+
|
24
|
+
|
25
|
+
### Bug Fixes
|
26
|
+
|
27
|
+
* return if name == _id ([5bd2ce1](https://github.com/CoCreate-app/CoCreate-text/commit/5bd2ce1a21c639f870cbab70288963c126a0ac42))
|
28
|
+
|
1
29
|
# [1.15.0](https://github.com/CoCreate-app/CoCreate-text/compare/v1.14.9...v1.15.0) (2022-01-22)
|
2
30
|
|
3
31
|
|
package/docs/index.html
CHANGED
@@ -74,7 +74,7 @@
|
|
74
74
|
<div class="container svColumn overflow:hidden card position:relative border-radius:2px width:auto height:100%" id="sandbox">
|
75
75
|
<div class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
|
76
76
|
<a class="margin-right:10px" id="code" show="#preview" hide="#code, #view"><i class="far fa-eye"></i></a>
|
77
|
-
<a class="margin-right:10px
|
77
|
+
<a class="margin-right:10px" id="preview" show="#code, #view" hide="#preview" hidden><i class="fas fa-code"></i></a>
|
78
78
|
<a class="margin-right:5px" fullscreen target="#playground"><i class="fas fa-expand"></i></a>
|
79
79
|
</div>
|
80
80
|
<div class="svRow">
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@cocreate/text",
|
3
|
-
"version": "1.15.
|
3
|
+
"version": "1.15.4",
|
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",
|
@@ -61,14 +61,14 @@
|
|
61
61
|
"webpack-log": "^3.0.1"
|
62
62
|
},
|
63
63
|
"dependencies": {
|
64
|
-
"@cocreate/actions": "^1.3.
|
65
|
-
"@cocreate/crdt": "^1.
|
66
|
-
"@cocreate/crud-client": "^1.4.
|
67
|
-
"@cocreate/cursors": "^1.11.
|
68
|
-
"@cocreate/docs": "^1.2.
|
69
|
-
"@cocreate/hosting": "^1.2.
|
70
|
-
"@cocreate/observer": "^1.
|
71
|
-
"@cocreate/selection": "^1.
|
72
|
-
"@cocreate/uuid": "^1.1.
|
64
|
+
"@cocreate/actions": "^1.3.28",
|
65
|
+
"@cocreate/crdt": "^1.9.0",
|
66
|
+
"@cocreate/crud-client": "^1.4.43",
|
67
|
+
"@cocreate/cursors": "^1.11.9",
|
68
|
+
"@cocreate/docs": "^1.2.65",
|
69
|
+
"@cocreate/hosting": "^1.2.60",
|
70
|
+
"@cocreate/observer": "^1.4.0",
|
71
|
+
"@cocreate/selection": "^1.4.0",
|
72
|
+
"@cocreate/uuid": "^1.1.55"
|
73
73
|
}
|
74
74
|
}
|
package/src/index.js
CHANGED
@@ -28,7 +28,7 @@ function initElements (elements) {
|
|
28
28
|
function initElement (element) {
|
29
29
|
const { collection, document_id, name, isRealtime, isCrdt, isCrud, isSave, isRead } = crud.getAttr(element);
|
30
30
|
if(document_id == "pending") return;
|
31
|
-
if(isCrdt == "false" || isRealtime == "false" || element.type == 'number') return;
|
31
|
+
if(isCrdt == "false" || isRealtime == "false" || element.type == 'number' || name == '_id') return;
|
32
32
|
if(!crud.checkAttrValue(collection) || !crud.checkAttrValue(document_id)) return;
|
33
33
|
if(element.tagName === "INPUT" && ["text", "email", "tel", "url"].includes(element.type) || element.tagName === "TEXTAREA" || element.hasAttribute('contenteditable')) {
|
34
34
|
if(!collection || !document_id || !name) return;
|
@@ -279,7 +279,7 @@ function _crdtUpdateListener () {
|
|
279
279
|
});
|
280
280
|
}
|
281
281
|
|
282
|
-
function updateElements({elements, collection, document_id, name, value, start, length}){
|
282
|
+
function updateElements({elements, collection, document_id, name, value, start, length, string}){
|
283
283
|
if(!elements){
|
284
284
|
let selectors = `[collection='${collection}'][document_id='${document_id}'][name='${name}']`;
|
285
285
|
elements = document.querySelectorAll(`input${selectors}, textarea${selectors}, [contenteditable]${selectors}, [editor='dom']${selectors}`);
|
@@ -292,11 +292,11 @@ function updateElements({elements, collection, document_id, name, value, start,
|
|
292
292
|
// let isEditable = element.getAttribute('contenteditable');
|
293
293
|
if (!element.hasAttribute('contenteditable') && isCrdt == 'false') return;
|
294
294
|
|
295
|
-
updateElement({element, collection, document_id, name, value, start, length});
|
295
|
+
updateElement({element, collection, document_id, name, value, start, length, string});
|
296
296
|
});
|
297
297
|
}
|
298
298
|
|
299
|
-
async function updateElement ({element, collection, document_id, name, value, start, length }) {
|
299
|
+
async function updateElement ({element, collection, document_id, name, value, start, length, string }) {
|
300
300
|
if (element.tagName == 'IFRAME') {
|
301
301
|
element = element.contentDocument.documentElement;
|
302
302
|
if (element.contenteditable != 'false')
|
@@ -313,14 +313,15 @@ async function updateElement ({element, collection, document_id, name, value, st
|
|
313
313
|
}
|
314
314
|
else {
|
315
315
|
let domTextEditor = element;
|
316
|
-
|
316
|
+
if (string == undefined)
|
317
|
+
string = await crdt.getText({collection, document_id, name});
|
318
|
+
let html = string;
|
317
319
|
if (length) {
|
318
320
|
let end = start + length;
|
319
321
|
updateDom({ domTextEditor, start, end, html });
|
320
322
|
}
|
321
323
|
if (value) {
|
322
324
|
if (element.innerHTML != value) {
|
323
|
-
// domTextEditor.htmlString = html;
|
324
325
|
updateDom({ domTextEditor, value, start, end: start, html });
|
325
326
|
}
|
326
327
|
}
|