@textbus/platform-browser 5.0.0-alpha.15 → 5.0.0-alpha.17

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.
@@ -50,7 +50,7 @@ function getLayoutRectByRange(range) {
50
50
  return {
51
51
  left: rect.right,
52
52
  top: rect.top,
53
- width: range.collapsed ? 0 : rect.width,
53
+ width: range.collapsed ? 1 : rect.width,
54
54
  height: rect.height
55
55
  };
56
56
  }
@@ -62,7 +62,7 @@ function getLayoutRectByRange(range) {
62
62
  return {
63
63
  left: rect.right,
64
64
  top: rect.top,
65
- width: range.collapsed ? 0 : rect.width,
65
+ width: range.collapsed ? 1 : rect.width,
66
66
  height: rect.height
67
67
  };
68
68
  }
@@ -76,7 +76,7 @@ function getLayoutRectByRange(range) {
76
76
  return {
77
77
  left: rect.right,
78
78
  top: rect.top,
79
- width: range.collapsed ? 0 : rect.width,
79
+ width: range.collapsed ? 1 : rect.width,
80
80
  height: rect.height
81
81
  };
82
82
  }
@@ -87,7 +87,7 @@ function getLayoutRectByRange(range) {
87
87
  return {
88
88
  left: rect.left,
89
89
  top: rect.top,
90
- width: range.collapsed ? 0 : rect.width,
90
+ width: range.collapsed ? 1 : rect.width,
91
91
  height: rect.height
92
92
  };
93
93
  }
@@ -107,7 +107,7 @@ function getLayoutRectByRange(range) {
107
107
  return {
108
108
  left: rect.left,
109
109
  top: rect.top,
110
- width: range.collapsed ? 0 : rect.width,
110
+ width: range.collapsed ? 1 : rect.width,
111
111
  height: rect.height
112
112
  };
113
113
  }
@@ -1322,17 +1322,17 @@ class ExperimentalCaret {
1322
1322
  pointEle.style.cssText = 'position: absolute; left: 0; top: 0; width:0;height:0';
1323
1323
  hackEle.append(pointEle);
1324
1324
  node.append(hackEle);
1325
- const t1 = pointEle.getBoundingClientRect().top;
1325
+ const p1 = pointEle.getBoundingClientRect();
1326
1326
  pointEle.style.right = '0';
1327
1327
  pointEle.style.left = '';
1328
- const t2 = pointEle.getBoundingClientRect().top;
1329
- if (t2 < t1) {
1330
- rotate = -rotate;
1331
- }
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;
1332
1332
  hackEle.remove();
1333
1333
  }
1334
1334
  }
1335
- if (rotate === 0 && (writingMode === 'vertical-lr' || writingMode === 'vertical-rl')) {
1335
+ if (writingMode === 'vertical-lr' || writingMode === 'vertical-rl') {
1336
1336
  rotate += 90;
1337
1337
  }
1338
1338
  Object.assign(this.elementRef.style, {
@@ -1343,7 +1343,7 @@ class ExperimentalCaret {
1343
1343
  fontSize,
1344
1344
  transform: `rotate(${rotate}deg)`,
1345
1345
  });
1346
- this.caret.style.backgroundColor = color;
1346
+ this.caret.style.backgroundColor = color === 'rgba(0, 0, 0, 0)' ? '#000' : color;
1347
1347
  this.styleChangeEvent.next({
1348
1348
  height: boxHeight + 'px',
1349
1349
  lineHeight: boxHeight + 'px',
package/bundles/index.js CHANGED
@@ -52,7 +52,7 @@ function getLayoutRectByRange(range) {
52
52
  return {
53
53
  left: rect.right,
54
54
  top: rect.top,
55
- width: range.collapsed ? 0 : rect.width,
55
+ width: range.collapsed ? 1 : rect.width,
56
56
  height: rect.height
57
57
  };
58
58
  }
@@ -64,7 +64,7 @@ function getLayoutRectByRange(range) {
64
64
  return {
65
65
  left: rect.right,
66
66
  top: rect.top,
67
- width: range.collapsed ? 0 : rect.width,
67
+ width: range.collapsed ? 1 : rect.width,
68
68
  height: rect.height
69
69
  };
70
70
  }
@@ -78,7 +78,7 @@ function getLayoutRectByRange(range) {
78
78
  return {
79
79
  left: rect.right,
80
80
  top: rect.top,
81
- width: range.collapsed ? 0 : rect.width,
81
+ width: range.collapsed ? 1 : rect.width,
82
82
  height: rect.height
83
83
  };
84
84
  }
@@ -89,7 +89,7 @@ function getLayoutRectByRange(range) {
89
89
  return {
90
90
  left: rect.left,
91
91
  top: rect.top,
92
- width: range.collapsed ? 0 : rect.width,
92
+ width: range.collapsed ? 1 : rect.width,
93
93
  height: rect.height
94
94
  };
95
95
  }
@@ -109,7 +109,7 @@ function getLayoutRectByRange(range) {
109
109
  return {
110
110
  left: rect.left,
111
111
  top: rect.top,
112
- width: range.collapsed ? 0 : rect.width,
112
+ width: range.collapsed ? 1 : rect.width,
113
113
  height: rect.height
114
114
  };
115
115
  }
@@ -1324,17 +1324,17 @@ class ExperimentalCaret {
1324
1324
  pointEle.style.cssText = 'position: absolute; left: 0; top: 0; width:0;height:0';
1325
1325
  hackEle.append(pointEle);
1326
1326
  node.append(hackEle);
1327
- const t1 = pointEle.getBoundingClientRect().top;
1327
+ const p1 = pointEle.getBoundingClientRect();
1328
1328
  pointEle.style.right = '0';
1329
1329
  pointEle.style.left = '';
1330
- const t2 = pointEle.getBoundingClientRect().top;
1331
- if (t2 < t1) {
1332
- rotate = -rotate;
1333
- }
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;
1334
1334
  hackEle.remove();
1335
1335
  }
1336
1336
  }
1337
- if (rotate === 0 && (writingMode === 'vertical-lr' || writingMode === 'vertical-rl')) {
1337
+ if (writingMode === 'vertical-lr' || writingMode === 'vertical-rl') {
1338
1338
  rotate += 90;
1339
1339
  }
1340
1340
  Object.assign(this.elementRef.style, {
@@ -1345,7 +1345,7 @@ class ExperimentalCaret {
1345
1345
  fontSize,
1346
1346
  transform: `rotate(${rotate}deg)`,
1347
1347
  });
1348
- this.caret.style.backgroundColor = color;
1348
+ this.caret.style.backgroundColor = color === 'rgba(0, 0, 0, 0)' ? '#000' : color;
1349
1349
  this.styleChangeEvent.next({
1350
1350
  height: boxHeight + 'px',
1351
1351
  lineHeight: boxHeight + 'px',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/platform-browser",
3
- "version": "5.0.0-alpha.15",
3
+ "version": "5.0.0-alpha.17",
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": "0f3c64c5c6105a2e4207ab772e64d3acb801d22a"
50
+ "gitHead": "18b9c97853ebde681d91d6be1b3cf0b78de2dcc8"
51
51
  }