@cocreate/text 1.15.1 → 1.15.2

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,10 @@
1
+ ## [1.15.2](https://github.com/CoCreate-app/CoCreate-text/compare/v1.15.1...v1.15.2) (2022-01-31)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * use string param provided by crdt-update event ([6c05759](https://github.com/CoCreate-app/CoCreate-text/commit/6c05759ac0dd45e5c8123324192d5993ae25b05c))
7
+
1
8
  ## [1.15.1](https://github.com/CoCreate-app/CoCreate-text/compare/v1.15.0...v1.15.1) (2022-01-23)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/text",
3
- "version": "1.15.1",
3
+ "version": "1.15.2",
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",
package/src/index.js CHANGED
@@ -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
- let html = await crdt.getText({collection, document_id, name});
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
  }