@textbus/platform-browser 5.0.0-alpha.14 → 5.0.0-alpha.16
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 +13 -9
- package/bundles/index.js +13 -9
- package/bundles/selection-bridge.d.ts +1 -1
- package/package.json +2 -2
package/bundles/index.esm.js
CHANGED
|
@@ -552,8 +552,8 @@ let SelectionBridge = class SelectionBridge {
|
|
|
552
552
|
nativeRange.collapse();
|
|
553
553
|
return getLayoutRectByRange(nativeRange);
|
|
554
554
|
}
|
|
555
|
-
restore(abstractSelection,
|
|
556
|
-
this.changeFromUser =
|
|
555
|
+
restore(abstractSelection, fromLocal) {
|
|
556
|
+
this.changeFromUser = fromLocal;
|
|
557
557
|
if (this.ignoreSelectionChange || !this.connector) {
|
|
558
558
|
return;
|
|
559
559
|
}
|
|
@@ -611,6 +611,10 @@ let SelectionBridge = class SelectionBridge {
|
|
|
611
611
|
this.listen(this.connector);
|
|
612
612
|
}
|
|
613
613
|
};
|
|
614
|
+
if (fromLocal) {
|
|
615
|
+
Promise.resolve().then(bind);
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
614
618
|
if (typeof requestIdleCallback === 'function') {
|
|
615
619
|
requestIdleCallback(bind);
|
|
616
620
|
}
|
|
@@ -803,7 +807,7 @@ let SelectionBridge = class SelectionBridge {
|
|
|
803
807
|
isUpdating = true;
|
|
804
808
|
}), this.scheduler.onDocChanged.pipe(delay()).subscribe(() => {
|
|
805
809
|
isUpdating = false;
|
|
806
|
-
}), fromEvent(document, 'selectionchange').
|
|
810
|
+
}), fromEvent(document, 'selectionchange').subscribe(() => {
|
|
807
811
|
if (isUpdating) {
|
|
808
812
|
return;
|
|
809
813
|
}
|
|
@@ -1318,13 +1322,13 @@ class ExperimentalCaret {
|
|
|
1318
1322
|
pointEle.style.cssText = 'position: absolute; left: 0; top: 0; width:0;height:0';
|
|
1319
1323
|
hackEle.append(pointEle);
|
|
1320
1324
|
node.append(hackEle);
|
|
1321
|
-
const
|
|
1325
|
+
const p1 = pointEle.getBoundingClientRect();
|
|
1322
1326
|
pointEle.style.right = '0';
|
|
1323
1327
|
pointEle.style.left = '';
|
|
1324
|
-
const
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
+
const p2 = pointEle.getBoundingClientRect();
|
|
1329
|
+
const x = p1.x - p2.x;
|
|
1330
|
+
const y = p1.y - p2.y;
|
|
1331
|
+
rotate = Math.atan2(y, x) * 180 / Math.PI;
|
|
1328
1332
|
hackEle.remove();
|
|
1329
1333
|
}
|
|
1330
1334
|
}
|
|
@@ -1339,7 +1343,7 @@ class ExperimentalCaret {
|
|
|
1339
1343
|
fontSize,
|
|
1340
1344
|
transform: `rotate(${rotate}deg)`,
|
|
1341
1345
|
});
|
|
1342
|
-
this.caret.style.backgroundColor = color;
|
|
1346
|
+
this.caret.style.backgroundColor = color === 'rgba(0, 0, 0, 0)' ? '#000' : color;
|
|
1343
1347
|
this.styleChangeEvent.next({
|
|
1344
1348
|
height: boxHeight + 'px',
|
|
1345
1349
|
lineHeight: boxHeight + 'px',
|
package/bundles/index.js
CHANGED
|
@@ -554,8 +554,8 @@ exports.SelectionBridge = class SelectionBridge {
|
|
|
554
554
|
nativeRange.collapse();
|
|
555
555
|
return getLayoutRectByRange(nativeRange);
|
|
556
556
|
}
|
|
557
|
-
restore(abstractSelection,
|
|
558
|
-
this.changeFromUser =
|
|
557
|
+
restore(abstractSelection, fromLocal) {
|
|
558
|
+
this.changeFromUser = fromLocal;
|
|
559
559
|
if (this.ignoreSelectionChange || !this.connector) {
|
|
560
560
|
return;
|
|
561
561
|
}
|
|
@@ -613,6 +613,10 @@ exports.SelectionBridge = class SelectionBridge {
|
|
|
613
613
|
this.listen(this.connector);
|
|
614
614
|
}
|
|
615
615
|
};
|
|
616
|
+
if (fromLocal) {
|
|
617
|
+
Promise.resolve().then(bind);
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
616
620
|
if (typeof requestIdleCallback === 'function') {
|
|
617
621
|
requestIdleCallback(bind);
|
|
618
622
|
}
|
|
@@ -805,7 +809,7 @@ exports.SelectionBridge = class SelectionBridge {
|
|
|
805
809
|
isUpdating = true;
|
|
806
810
|
}), this.scheduler.onDocChanged.pipe(stream.delay()).subscribe(() => {
|
|
807
811
|
isUpdating = false;
|
|
808
|
-
}), stream.fromEvent(document, 'selectionchange').
|
|
812
|
+
}), stream.fromEvent(document, 'selectionchange').subscribe(() => {
|
|
809
813
|
if (isUpdating) {
|
|
810
814
|
return;
|
|
811
815
|
}
|
|
@@ -1320,13 +1324,13 @@ class ExperimentalCaret {
|
|
|
1320
1324
|
pointEle.style.cssText = 'position: absolute; left: 0; top: 0; width:0;height:0';
|
|
1321
1325
|
hackEle.append(pointEle);
|
|
1322
1326
|
node.append(hackEle);
|
|
1323
|
-
const
|
|
1327
|
+
const p1 = pointEle.getBoundingClientRect();
|
|
1324
1328
|
pointEle.style.right = '0';
|
|
1325
1329
|
pointEle.style.left = '';
|
|
1326
|
-
const
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
+
const p2 = pointEle.getBoundingClientRect();
|
|
1331
|
+
const x = p1.x - p2.x;
|
|
1332
|
+
const y = p1.y - p2.y;
|
|
1333
|
+
rotate = Math.atan2(y, x) * 180 / Math.PI;
|
|
1330
1334
|
hackEle.remove();
|
|
1331
1335
|
}
|
|
1332
1336
|
}
|
|
@@ -1341,7 +1345,7 @@ class ExperimentalCaret {
|
|
|
1341
1345
|
fontSize,
|
|
1342
1346
|
transform: `rotate(${rotate}deg)`,
|
|
1343
1347
|
});
|
|
1344
|
-
this.caret.style.backgroundColor = color;
|
|
1348
|
+
this.caret.style.backgroundColor = color === 'rgba(0, 0, 0, 0)' ? '#000' : color;
|
|
1345
1349
|
this.styleChangeEvent.next({
|
|
1346
1350
|
height: boxHeight + 'px',
|
|
1347
1351
|
lineHeight: boxHeight + 'px',
|
|
@@ -30,7 +30,7 @@ export declare class SelectionBridge implements NativeSelectionBridge {
|
|
|
30
30
|
connect(connector: NativeSelectionConnector): void;
|
|
31
31
|
disConnect(): void;
|
|
32
32
|
getRect(location: SelectionPosition): Rect | null;
|
|
33
|
-
restore(abstractSelection: AbstractSelection | null,
|
|
33
|
+
restore(abstractSelection: AbstractSelection | null, fromLocal: boolean): void;
|
|
34
34
|
destroy(): void;
|
|
35
35
|
getPositionByRange(abstractSelection: AbstractSelection): {
|
|
36
36
|
focus: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@textbus/platform-browser",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.16",
|
|
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",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"bugs": {
|
|
48
48
|
"url": "https://github.com/textbus/textbus.git/issues"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "8c9e90bd1a3effc96dcbbd455f24a8b263087e90"
|
|
51
51
|
}
|