@cocreate/selection 1.2.21 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # [1.3.0](https://github.com/CoCreate-app/CoCreate-selection/compare/v1.2.21...v1.3.0) (2021-12-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update dependencies ([4fa877a](https://github.com/CoCreate-app/CoCreate-selection/commit/4fa877ad1df7ec4a58f050a7132aa3f071ccfd5d))
7
+
8
+
9
+ ### Features
10
+
11
+ * support nested contenteditable and selections for cursor positions ([8efc22d](https://github.com/CoCreate-app/CoCreate-selection/commit/8efc22d303ba88dbb6fdbf4d65cb2988afec73ca))
12
+
1
13
  ## [1.2.21](https://github.com/CoCreate-app/CoCreate-selection/compare/v1.2.20...v1.2.21) (2021-12-08)
2
14
 
3
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/selection",
3
- "version": "1.2.21",
3
+ "version": "1.3.0",
4
4
  "description": "A simple selection component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "selection",
@@ -61,8 +61,8 @@
61
61
  "webpack-log": "^3.0.1"
62
62
  },
63
63
  "dependencies": {
64
- "@cocreate/docs": "^1.2.60",
65
- "@cocreate/hosting": "^1.2.56",
66
- "@cocreate/utils": "^1.3.16"
64
+ "@cocreate/docs": "^1.2.61",
65
+ "@cocreate/hosting": "^1.2.57",
66
+ "@cocreate/utils": "^1.3.18"
67
67
  }
68
68
  }
package/src/index.js CHANGED
@@ -62,6 +62,7 @@ export function getSelection(element) {
62
62
 
63
63
  let rangeObj = {
64
64
  element: contenteditable,
65
+ // domTextEditor,
65
66
  startOffset: range.startOffset,
66
67
  endOffset: range.endOffset,
67
68
  startContainer,
@@ -288,9 +289,17 @@ function getInsertPosition(element){
288
289
 
289
290
  export function getStringPosition({string, target, position, attribute, property, value}) {
290
291
  try {
292
+ let element;
291
293
  let selector = cssPath(target, '[contenteditable]');
292
294
  let dom = domParser(string);
293
- let element = dom.querySelector(selector);
295
+ if (!selector.includes('[eid=') && dom.tagName == "DOM-PARSER"){
296
+ let containerEl = document.createElement('div');
297
+ containerEl.appendChild(dom)
298
+ selector = `dom-parser > ${selector}`
299
+ element = containerEl.querySelector(selector);
300
+ }
301
+ else
302
+ element = dom.querySelector(selector);
294
303
  if (!element){
295
304
  console.log('element could not be found using selector:', selector);
296
305
  return;