@livingdocs/editable.js 5.1.8 → 5.1.10

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@livingdocs/editable.js",
3
3
  "description": "Friendly contenteditable API",
4
- "version": "5.1.8",
4
+ "version": "5.1.10",
5
5
  "dependencies": {
6
6
  "lodash-es": "^4.17.21"
7
7
  },
@@ -38,7 +38,7 @@
38
38
  "style-loader": "^4.0.0",
39
39
  "url-loader": "^4.1.1",
40
40
  "webpack": "^5.68.0",
41
- "webpack-cli": "^6.0.0",
41
+ "webpack-cli": "^7.0.0",
42
42
  "webpack-dev-server": "^5.0.0"
43
43
  },
44
44
  "engines": {
@@ -80,11 +80,11 @@
80
80
  "isCi": true,
81
81
  "name": "Drone",
82
82
  "service": "drone",
83
- "commit": "7cb28fc95b9aed20881b02a06f7d0b81ff01ab5b",
84
- "build": "2545",
83
+ "commit": "8cdf184953fcf131c2b2920d5cb9b7885a683b8d",
84
+ "build": "2585",
85
85
  "branch": "master",
86
86
  "isPr": false,
87
87
  "slug": "livingdocsIO/editable.js",
88
- "date": "2026-03-12T17:39:18.438Z"
88
+ "date": "2026-03-24T10:36:41.166Z"
89
89
  }
90
90
  }
package/src/content.js CHANGED
@@ -110,8 +110,10 @@ export function extractContent (element, keepUiElements) {
110
110
  }
111
111
 
112
112
  export function getInnerHtmlOfFragment (documentFragment) {
113
+ const deep = true
114
+ const clonedDocumentFragment = documentFragment.cloneNode(deep)
113
115
  const div = document.createElement('div')
114
- div.appendChild(documentFragment)
116
+ div.appendChild(clonedDocumentFragment)
115
117
  return div.innerHTML
116
118
  }
117
119
 
@@ -45,19 +45,25 @@ const highlightSupport = {
45
45
  this.win
46
46
  )
47
47
 
48
- const actualStartIndex = startIndex
49
- const actualEndIndex = endIndex
48
+ // If text is provided then validate that it matches
49
+ if (text) {
50
+ const tempElement = document.createElement('div')
51
+ tempElement.innerHTML = text
52
+ if (tempElement.textContent !== blockText.slice(startIndex, endIndex)) {
53
+ return -1
54
+ }
55
+ }
50
56
 
51
57
  highlightText.highlightMatches(editableHost, [{
52
- startIndex: actualStartIndex,
53
- endIndex: actualEndIndex,
58
+ startIndex,
59
+ endIndex,
54
60
  id: highlightId,
55
61
  marker
56
62
  }], false)
57
63
 
58
64
  if (dispatcher) dispatcher.notify('change', editableHost)
59
65
 
60
- return actualStartIndex
66
+ return startIndex
61
67
  },
62
68
 
63
69
  updateHighlight (editableHost, highlightId, addCssClass, removeCssClass) {
package/src/util/dom.js CHANGED
@@ -182,7 +182,10 @@ export const toCharacterRange = (range, container) => {
182
182
  startRange.setStart(container, 0)
183
183
  startRange.setEnd(range.startContainer, range.startOffset)
184
184
 
185
- const rangeText = range.toString()
185
+ // Remove zero width space to make selection more accurate,
186
+ // because it will be removed on component blur via extractContent.
187
+ const zeroWidthNonBreakingSpace = /\uFEFF/g
188
+ const rangeText = range.toString().replace(zeroWidthNonBreakingSpace, '')
186
189
  const start = startRange.toString().length
187
190
  const end = start + rangeText.length
188
191