@livingdocs/editable.js 3.0.14 → 3.0.15
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/dist/editable.js +1 -1
- package/dist/editable.js.map +1 -1
- package/package.json +4 -4
- package/src/highlight-text.js +2 -2
- package/src/selection.js +4 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livingdocs/editable.js",
|
|
3
3
|
"description": "Friendly contenteditable API",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.15",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@babel/runtime": "^7.16.7",
|
|
7
7
|
"bowser": "2.11.0",
|
|
@@ -83,11 +83,11 @@
|
|
|
83
83
|
"isCi": true,
|
|
84
84
|
"name": "Drone",
|
|
85
85
|
"service": "drone",
|
|
86
|
-
"commit": "
|
|
87
|
-
"build": "
|
|
86
|
+
"commit": "cfb72eb34899004520ea0b1d0bd7bb9434681502",
|
|
87
|
+
"build": "454",
|
|
88
88
|
"branch": "master",
|
|
89
89
|
"isPr": false,
|
|
90
90
|
"slug": "livingdocsIO/editable.js",
|
|
91
|
-
"date": "2022-02-
|
|
91
|
+
"date": "2022-02-23T12:28:23.761Z"
|
|
92
92
|
}
|
|
93
93
|
}
|
package/src/highlight-text.js
CHANGED
|
@@ -134,7 +134,7 @@ export default {
|
|
|
134
134
|
// This has two notable behaviours:
|
|
135
135
|
// - It uses a NodeIterator which will skip elements
|
|
136
136
|
// with data-editable="remove"
|
|
137
|
-
// - It returns a
|
|
137
|
+
// - It returns a \n for <br> elements
|
|
138
138
|
// (The only block level element allowed inside of editables)
|
|
139
139
|
function getText (element, callback) {
|
|
140
140
|
const iterator = new NodeIterator(element)
|
|
@@ -143,7 +143,7 @@ function getText (element, callback) {
|
|
|
143
143
|
if (next.nodeType === nodeType.textNode && next.data !== '') {
|
|
144
144
|
callback(next.data)
|
|
145
145
|
} else if (next.nodeType === nodeType.elementNode && next.nodeName === 'BR') {
|
|
146
|
-
callback('
|
|
146
|
+
callback('\n')
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
}
|
package/src/selection.js
CHANGED
|
@@ -94,10 +94,10 @@ export default class Selection extends Cursor {
|
|
|
94
94
|
|
|
95
95
|
// trims whitespaces on the left and right of a selection, i.e. what you want in case of links
|
|
96
96
|
trimRange () {
|
|
97
|
-
const
|
|
98
|
-
const whitespacesOnTheLeft =
|
|
99
|
-
const lastNonWhitespace =
|
|
100
|
-
const whitespacesOnTheRight = lastNonWhitespace === -1 ? 0 :
|
|
97
|
+
const textToTrim = this.range.toString()
|
|
98
|
+
const whitespacesOnTheLeft = textToTrim.search(/\S|$/)
|
|
99
|
+
const lastNonWhitespace = textToTrim.search(/\S[\s]+$/)
|
|
100
|
+
const whitespacesOnTheRight = lastNonWhitespace === -1 ? 0 : textToTrim.length - (lastNonWhitespace + 1)
|
|
101
101
|
this.range.setStart(this.range.startContainer, this.range.startOffset + whitespacesOnTheLeft)
|
|
102
102
|
this.range.setEnd(this.range.endContainer, this.range.endOffset - whitespacesOnTheRight)
|
|
103
103
|
}
|