@cocreate/text 1.16.2 → 1.16.5

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/package.json +10 -10
  3. package/src/index.js +11 -4
package/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## [1.16.5](https://github.com/CoCreate-app/CoCreate-text/compare/v1.16.4...v1.16.5) (2022-06-22)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * ifactiveElement inputEvent skip = false ([0b61519](https://github.com/CoCreate-app/CoCreate-text/commit/0b61519e2bd9592502ebb7a2ba88b71a16e11e55))
7
+
8
+ ## [1.16.4](https://github.com/CoCreate-app/CoCreate-text/compare/v1.16.3...v1.16.4) (2022-06-18)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * bump dependencies ([2128b8d](https://github.com/CoCreate-app/CoCreate-text/commit/2128b8d11122a2024d7549e571b286ae6aa1d463))
14
+
15
+ ## [1.16.3](https://github.com/CoCreate-app/CoCreate-text/compare/v1.16.2...v1.16.3) (2022-06-16)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * when iframe need to get iframe elements attributes to send to crdt undo and redo ([ddfc15e](https://github.com/CoCreate-app/CoCreate-text/commit/ddfc15e1184ff7adf4bfabb9a7d147a531b645d6))
21
+
1
22
  ## [1.16.2](https://github.com/CoCreate-app/CoCreate-text/compare/v1.16.1...v1.16.2) (2022-06-13)
2
23
 
3
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/text",
3
- "version": "1.16.2",
3
+ "version": "1.16.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",
@@ -61,14 +61,14 @@
61
61
  "webpack-log": "^3.0.1"
62
62
  },
63
63
  "dependencies": {
64
- "@cocreate/actions": "^1.4.2",
65
- "@cocreate/crdt": "^1.11.0",
66
- "@cocreate/crud-client": "^1.7.0",
67
- "@cocreate/cursors": "^1.11.20",
68
- "@cocreate/docs": "^1.3.2",
69
- "@cocreate/hosting": "^1.3.2",
70
- "@cocreate/observer": "^1.5.2",
71
- "@cocreate/selection": "^1.4.10",
72
- "@cocreate/uuid": "^1.2.2"
64
+ "@cocreate/actions": "^1.4.3",
65
+ "@cocreate/crdt": "^1.11.1",
66
+ "@cocreate/crud-client": "^1.7.1",
67
+ "@cocreate/cursors": "^1.11.21",
68
+ "@cocreate/docs": "^1.3.3",
69
+ "@cocreate/hosting": "^1.3.3",
70
+ "@cocreate/observer": "^1.5.3",
71
+ "@cocreate/selection": "^1.4.11",
72
+ "@cocreate/uuid": "^1.2.4"
73
73
  }
74
74
  }
package/src/index.js CHANGED
@@ -193,12 +193,11 @@ function _keydown (event) {
193
193
  event.preventDefault();
194
194
  }
195
195
  else if (event.ctrlKey) {
196
- const { collection, document_id, name, isCrud, isCrdt, isSave } = crud.getAttr(element);
197
196
  if (event.keyCode == 90) {
198
- crdt.undoText({ collection, document_id, name, isCrud, isCrdt, isSave })
197
+ updateText({element, range, undoRedo: 'undo'});
199
198
  }
200
199
  else if (event.keyCode == 89) {
201
- crdt.redoText({ collection, document_id, name, isCrud, isCrdt, isSave })
200
+ updateText({element, range, undoRedo: 'redo'});
202
201
  }
203
202
  }
204
203
  }
@@ -258,7 +257,7 @@ export function sendPosition (element) {
258
257
  cursors.sendPosition({ collection, document_id, name, start, end });
259
258
  }
260
259
 
261
- function updateText ({element, value, start, end, range}) {
260
+ function updateText ({element, value, start, end, range, undoRedo}) {
262
261
  if (range) {
263
262
  if (range.element)
264
263
  element = range.element;
@@ -269,6 +268,11 @@ function updateText ({element, value, start, end, range}) {
269
268
  const { collection, document_id, name, isCrud, isCrdt, isSave } = crud.getAttr(element);
270
269
  if (isCrdt == "false") return;
271
270
 
271
+ if (undoRedo == 'undo')
272
+ return crdt.undoText({ collection, document_id, name, isCrud, isCrdt, isSave })
273
+ if (undoRedo == 'redo')
274
+ return crdt.redoText({ collection, document_id, name, isCrud, isCrdt, isSave })
275
+
272
276
  let length = end - start;
273
277
  if (element.tagName === "INPUT" || element.tagName === "TEXTAREA") {
274
278
  crdt.updateText({ collection, document_id, name, value, start, length, crud: isCrud, save: isSave });
@@ -355,6 +359,9 @@ function _updateElementText (element, value, start, end) {
355
359
 
356
360
  export function _dispatchInputEvent(element, content, start, end, prev_start, prev_end) {
357
361
  let detail = {value: content, start, end, prev_start, prev_end, skip: true};
362
+ let activeElement = element.ownerDocument.activeElement;
363
+ if (activeElement == element)
364
+ detail.skip = false;
358
365
  if (eventObj) {
359
366
  let event = new CustomEvent(eventObj.type, { bubbles: true });
360
367
  Object.defineProperty(event, 'stopCCText', { writable: false, value: true });