@cocreate/text 1.12.23 → 1.12.27

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,32 @@
1
+ ## [1.12.27](https://github.com/CoCreate-app/CoCreate-text/compare/v1.12.26...v1.12.27) (2021-11-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * updated selection dependency ([9c85e4d](https://github.com/CoCreate-app/CoCreate-text/commit/9c85e4db523349309070f24a4f34b9994f25df22))
7
+
8
+ ## [1.12.26](https://github.com/CoCreate-app/CoCreate-text/compare/v1.12.25...v1.12.26) (2021-11-24)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * improved on logical conditons on when to processSelection ([53f8ad4](https://github.com/CoCreate-app/CoCreate-text/commit/53f8ad4e075c77b89ade24e56b6512431ac17b35))
14
+
15
+ ## [1.12.25](https://github.com/CoCreate-app/CoCreate-text/compare/v1.12.24...v1.12.25) (2021-11-23)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * update dependencies ([c0f3d30](https://github.com/CoCreate-app/CoCreate-text/commit/c0f3d3033a4806b82f16555ed3dc02cc059ed4fa))
21
+
22
+ ## [1.12.24](https://github.com/CoCreate-app/CoCreate-text/compare/v1.12.23...v1.12.24) (2021-11-23)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * update crud dependency ([19e931d](https://github.com/CoCreate-app/CoCreate-text/commit/19e931dc1234a5209412ca2bcccaf246d154f557))
28
+ * update selction and crdt dependencies ([a7dc2ca](https://github.com/CoCreate-app/CoCreate-text/commit/a7dc2ca004eb945e51b93d8a20f8095cc8d9b1b3))
29
+
1
30
  ## [1.12.23](https://github.com/CoCreate-app/CoCreate-text/compare/v1.12.22...v1.12.23) (2021-11-23)
2
31
 
3
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/text",
3
- "version": "1.12.23",
3
+ "version": "1.12.27",
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,13 +61,13 @@
61
61
  "webpack-log": "^3.0.1"
62
62
  },
63
63
  "dependencies": {
64
- "@cocreate/action": "^1.3.15",
65
- "@cocreate/crdt": "^1.8.17",
66
- "@cocreate/crud-client": "^1.4.29",
67
- "@cocreate/cursors": "^1.10.9",
68
- "@cocreate/docs": "^1.2.53",
69
- "@cocreate/hosting": "^1.2.48",
70
- "@cocreate/observer": "^1.3.45",
71
- "@cocreate/selection": "^1.2.9"
64
+ "@cocreate/action": "^1.3.17",
65
+ "@cocreate/crdt": "^1.8.21",
66
+ "@cocreate/crud-client": "^1.4.33",
67
+ "@cocreate/cursors": "^1.10.11",
68
+ "@cocreate/docs": "^1.2.55",
69
+ "@cocreate/hosting": "^1.2.51",
70
+ "@cocreate/observer": "^1.3.47",
71
+ "@cocreate/selection": "^1.2.15"
72
72
  }
73
73
  }
package/src/index.js CHANGED
@@ -51,7 +51,7 @@ function initElement (element) {
51
51
  if (value)
52
52
  crdt.replaceText({ collection, document_id, name, value, crud: isCrud, save: isSave, read: isRead });
53
53
  }
54
- else
54
+ else {
55
55
  if (element.hasAttribute('contenteditable')){
56
56
  element.innerHTML = '';
57
57
  }
@@ -59,6 +59,7 @@ function initElement (element) {
59
59
  element.value = '';
60
60
  }
61
61
  updateElement({ element, collection, document_id, name, value: response, start: 0 })
62
+ }
62
63
  });
63
64
  }
64
65
  }
package/src/updateDom.js CHANGED
@@ -12,7 +12,10 @@ export function updateDom({domTextEditor, value, start, end, html}) {
12
12
  let domEl, newEl = element, oldEl, curCaret;
13
13
  if(!newEl){
14
14
  newEl = domTextEditor.cloneNode(true);
15
- newEl.innerHTML = html || domTextEditor.htmlString;
15
+ if (html != undefined)
16
+ newEl.innerHTML = html;
17
+ else
18
+ newEl.innerHTML = domTextEditor.htmlString;
16
19
  domEl = domTextEditor;
17
20
  type = 'innerHTML';
18
21
  }
@@ -65,10 +68,12 @@ export function updateDom({domTextEditor, value, start, end, html}) {
65
68
  domEl.replaceChildren(...newEl.childNodes);
66
69
  }
67
70
  }
68
- if(curCaret && start && end) {
69
- let p = processSelection(domEl, value, curCaret.start, curCaret.end, start, end, curCaret.range);
70
- sendPosition(domEl);
71
- _dispatchInputEvent(p.element, p.value, p.start, p.end, p.prev_start, p.prev_end);
71
+ if(curCaret && start >= 0 && end >= 0) {
72
+ if (curCaret.range && curCaret.start >= curCaret.range.startOffset) {
73
+ let p = processSelection(domEl, value, curCaret.start, curCaret.end, start, end, curCaret.range);
74
+ sendPosition(domEl);
75
+ _dispatchInputEvent(p.element, p.value, p.start, p.end, p.prev_start, p.prev_end);
76
+ }
72
77
  }
73
78
 
74
79
  if (newEl.tagName == 'HTML' || 'HEAD' || 'BODY' || 'SCRIPT'){