@textbus/platform-browser 3.7.4 → 3.7.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.
- package/bundles/index.esm.js +24 -1
- package/bundles/index.js +24 -1
- package/package.json +2 -2
package/bundles/index.esm.js
CHANGED
@@ -264,7 +264,30 @@ let SelectionBridge = class SelectionBridge {
|
|
264
264
|
this.listen(this.connector);
|
265
265
|
return;
|
266
266
|
}
|
267
|
-
|
267
|
+
function tryOffset(position) {
|
268
|
+
if (position.node.nodeType === Node.TEXT_NODE) {
|
269
|
+
const len = position.node.textContent.length;
|
270
|
+
if (position.offset > len) {
|
271
|
+
position.offset = len;
|
272
|
+
}
|
273
|
+
}
|
274
|
+
else if (position.node.nodeType === Node.ELEMENT_NODE) {
|
275
|
+
const len = position.node.childNodes.length;
|
276
|
+
if (position.offset > len) {
|
277
|
+
position.offset = len;
|
278
|
+
}
|
279
|
+
}
|
280
|
+
}
|
281
|
+
tryOffset(focus);
|
282
|
+
tryOffset(anchor);
|
283
|
+
try {
|
284
|
+
this.nativeSelection.setBaseAndExtent(anchor.node, anchor.offset, focus.node, focus.offset);
|
285
|
+
}
|
286
|
+
catch (e) {
|
287
|
+
setTimeout(() => {
|
288
|
+
throw e;
|
289
|
+
});
|
290
|
+
}
|
268
291
|
if (this.nativeSelection.rangeCount) {
|
269
292
|
const nativeRange = this.nativeSelection.getRangeAt(0);
|
270
293
|
this.selectionChangeEvent.next(nativeRange);
|
package/bundles/index.js
CHANGED
@@ -266,7 +266,30 @@ exports.SelectionBridge = class SelectionBridge {
|
|
266
266
|
this.listen(this.connector);
|
267
267
|
return;
|
268
268
|
}
|
269
|
-
|
269
|
+
function tryOffset(position) {
|
270
|
+
if (position.node.nodeType === Node.TEXT_NODE) {
|
271
|
+
const len = position.node.textContent.length;
|
272
|
+
if (position.offset > len) {
|
273
|
+
position.offset = len;
|
274
|
+
}
|
275
|
+
}
|
276
|
+
else if (position.node.nodeType === Node.ELEMENT_NODE) {
|
277
|
+
const len = position.node.childNodes.length;
|
278
|
+
if (position.offset > len) {
|
279
|
+
position.offset = len;
|
280
|
+
}
|
281
|
+
}
|
282
|
+
}
|
283
|
+
tryOffset(focus);
|
284
|
+
tryOffset(anchor);
|
285
|
+
try {
|
286
|
+
this.nativeSelection.setBaseAndExtent(anchor.node, anchor.offset, focus.node, focus.offset);
|
287
|
+
}
|
288
|
+
catch (e) {
|
289
|
+
setTimeout(() => {
|
290
|
+
throw e;
|
291
|
+
});
|
292
|
+
}
|
270
293
|
if (this.nativeSelection.rangeCount) {
|
271
294
|
const nativeRange = this.nativeSelection.getRangeAt(0);
|
272
295
|
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.5",
|
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": "799ab8aafd2d8ed262a797da7872df10720c694d"
|
52
52
|
}
|