@textbus/platform-browser 3.7.4 → 3.7.6
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/bundles/index.esm.js +27 -1
- package/bundles/index.js +27 -1
- package/package.json +2 -2
package/bundles/index.esm.js
CHANGED
@@ -264,7 +264,33 @@ let SelectionBridge = class SelectionBridge {
|
|
264
264
|
this.listen(this.connector);
|
265
265
|
return;
|
266
266
|
}
|
267
|
-
|
267
|
+
function tryOffset(position) {
|
268
|
+
if (!position.node) {
|
269
|
+
return;
|
270
|
+
}
|
271
|
+
if (position.node.nodeType === Node.TEXT_NODE) {
|
272
|
+
const len = position.node.textContent.length;
|
273
|
+
if (position.offset > len) {
|
274
|
+
position.offset = len;
|
275
|
+
}
|
276
|
+
}
|
277
|
+
else if (position.node.nodeType === Node.ELEMENT_NODE) {
|
278
|
+
const len = position.node.childNodes.length;
|
279
|
+
if (position.offset > len) {
|
280
|
+
position.offset = len;
|
281
|
+
}
|
282
|
+
}
|
283
|
+
}
|
284
|
+
try {
|
285
|
+
tryOffset(focus);
|
286
|
+
tryOffset(anchor);
|
287
|
+
this.nativeSelection.setBaseAndExtent(anchor.node, anchor.offset, focus.node, focus.offset);
|
288
|
+
}
|
289
|
+
catch (e) {
|
290
|
+
setTimeout(() => {
|
291
|
+
throw e;
|
292
|
+
});
|
293
|
+
}
|
268
294
|
if (this.nativeSelection.rangeCount) {
|
269
295
|
const nativeRange = this.nativeSelection.getRangeAt(0);
|
270
296
|
this.selectionChangeEvent.next(nativeRange);
|
package/bundles/index.js
CHANGED
@@ -266,7 +266,33 @@ exports.SelectionBridge = class SelectionBridge {
|
|
266
266
|
this.listen(this.connector);
|
267
267
|
return;
|
268
268
|
}
|
269
|
-
|
269
|
+
function tryOffset(position) {
|
270
|
+
if (!position.node) {
|
271
|
+
return;
|
272
|
+
}
|
273
|
+
if (position.node.nodeType === Node.TEXT_NODE) {
|
274
|
+
const len = position.node.textContent.length;
|
275
|
+
if (position.offset > len) {
|
276
|
+
position.offset = len;
|
277
|
+
}
|
278
|
+
}
|
279
|
+
else if (position.node.nodeType === Node.ELEMENT_NODE) {
|
280
|
+
const len = position.node.childNodes.length;
|
281
|
+
if (position.offset > len) {
|
282
|
+
position.offset = len;
|
283
|
+
}
|
284
|
+
}
|
285
|
+
}
|
286
|
+
try {
|
287
|
+
tryOffset(focus);
|
288
|
+
tryOffset(anchor);
|
289
|
+
this.nativeSelection.setBaseAndExtent(anchor.node, anchor.offset, focus.node, focus.offset);
|
290
|
+
}
|
291
|
+
catch (e) {
|
292
|
+
setTimeout(() => {
|
293
|
+
throw e;
|
294
|
+
});
|
295
|
+
}
|
270
296
|
if (this.nativeSelection.rangeCount) {
|
271
297
|
const nativeRange = this.nativeSelection.getRangeAt(0);
|
272
298
|
this.selectionChangeEvent.next(nativeRange);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@textbus/platform-browser",
|
3
|
-
"version": "3.7.
|
3
|
+
"version": "3.7.6",
|
4
4
|
"description": "Textbus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.",
|
5
5
|
"main": "./bundles/index.js",
|
6
6
|
"module": "./bundles/index.esm.js",
|
@@ -48,5 +48,5 @@
|
|
48
48
|
"bugs": {
|
49
49
|
"url": "https://github.com/textbus/textbus.git/issues"
|
50
50
|
},
|
51
|
-
"gitHead": "
|
51
|
+
"gitHead": "2bf443e8633bead50b95e48f859f31236aa6bd0e"
|
52
52
|
}
|