@textbus/platform-browser 4.1.0 → 4.2.1

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.
@@ -14,7 +14,7 @@ export interface RemoteSelectionCursor {
14
14
  * 远程光标绘制范围计算代理类,可用于定制特定场景下的远程选区绘制,如表格有选区,不会遵守常见的文档流形式
15
15
  */
16
16
  export declare abstract class CollaborateSelectionAwarenessDelegate {
17
- abstract getRects(abstractSelection: AbstractSelection, nativeRange: Range): false | Rect[];
17
+ abstract getRects(abstractSelection: AbstractSelection, nativeRange: Range, selectionCursor: UserSelectionCursor): false | Rect[];
18
18
  }
19
19
  /**
20
20
  * 协作用户虚拟光标信息
@@ -23,6 +23,7 @@ export interface UserSelectionCursor {
23
23
  username: string;
24
24
  color: string;
25
25
  selection: SelectionPaths;
26
+ data?: any;
26
27
  }
27
28
  /**
28
29
  * 协作光标绘制类
@@ -1043,7 +1043,7 @@ class ExperimentalCaret {
1043
1043
  nativeRange.collapse();
1044
1044
  }
1045
1045
  const rect = getLayoutRectByRange(nativeRange);
1046
- const { fontSize, lineHeight, color } = getComputedStyle(node);
1046
+ const { fontSize, lineHeight, color, writingMode } = getComputedStyle(node);
1047
1047
  let height;
1048
1048
  if (isNaN(+lineHeight)) {
1049
1049
  const f = parseFloat(lineHeight);
@@ -1072,7 +1072,8 @@ class ExperimentalCaret {
1072
1072
  rotate = Math.round(Math.atan2(rect.width, rect.height) * 180 / Math.PI);
1073
1073
  if (rotate !== 0) {
1074
1074
  const hackEle = document.createElement('span');
1075
- hackEle.style.cssText = 'display: inline-block; width: 10px; height: 10px; position: relative; contain: layout style size;';
1075
+ // eslint-disable-next-line max-len
1076
+ hackEle.style.cssText = 'display: inline-block; width: 10px; height: 10px; position: relative; contain: layout style size; writing-mode: inherit';
1076
1077
  const pointEle = document.createElement('span');
1077
1078
  pointEle.style.cssText = 'position: absolute; left: 0; top: 0; width:0;height:0';
1078
1079
  hackEle.append(pointEle);
@@ -1087,6 +1088,9 @@ class ExperimentalCaret {
1087
1088
  hackEle.remove();
1088
1089
  }
1089
1090
  }
1091
+ if (rotate === 0 && (writingMode === 'vertical-lr' || writingMode === 'vertical-rl')) {
1092
+ rotate += 90;
1093
+ }
1090
1094
  Object.assign(this.elementRef.style, {
1091
1095
  left: left + 'px',
1092
1096
  top: top + 'px',
@@ -1348,7 +1352,12 @@ let MagicInput = class MagicInput extends Input {
1348
1352
  key: key,
1349
1353
  altKey: ev.altKey,
1350
1354
  shiftKey: ev.shiftKey,
1351
- modKey: this.isMac ? ev.metaKey : ev.ctrlKey
1355
+ modKey: this.isMac ? ev.metaKey : ev.ctrlKey,
1356
+ agent: {
1357
+ key: ev.key,
1358
+ code: ev.code,
1359
+ keyCode: ev.keyCode,
1360
+ }
1352
1361
  });
1353
1362
  if (is) {
1354
1363
  this.ignoreComposition = true;
@@ -1614,7 +1623,7 @@ let CollaborateCursor = class CollaborateCursor {
1614
1623
  anchorOffset,
1615
1624
  focusSlot,
1616
1625
  anchorSlot
1617
- }, nativeRange);
1626
+ }, nativeRange, item);
1618
1627
  }
1619
1628
  if (!rects) {
1620
1629
  rects = nativeRange.getClientRects();
@@ -1942,7 +1951,12 @@ let NativeInput = class NativeInput extends Input {
1942
1951
  key: key,
1943
1952
  altKey: ev.altKey,
1944
1953
  shiftKey: ev.shiftKey,
1945
- modKey: this.isMac ? ev.metaKey : ev.ctrlKey
1954
+ modKey: this.isMac ? ev.metaKey : ev.ctrlKey,
1955
+ agent: {
1956
+ key: ev.key,
1957
+ keyCode: ev.keyCode,
1958
+ code: ev.code
1959
+ }
1946
1960
  });
1947
1961
  if (is) {
1948
1962
  this.ignoreComposition = true;
package/bundles/index.js CHANGED
@@ -1045,7 +1045,7 @@ class ExperimentalCaret {
1045
1045
  nativeRange.collapse();
1046
1046
  }
1047
1047
  const rect = getLayoutRectByRange(nativeRange);
1048
- const { fontSize, lineHeight, color } = getComputedStyle(node);
1048
+ const { fontSize, lineHeight, color, writingMode } = getComputedStyle(node);
1049
1049
  let height;
1050
1050
  if (isNaN(+lineHeight)) {
1051
1051
  const f = parseFloat(lineHeight);
@@ -1074,7 +1074,8 @@ class ExperimentalCaret {
1074
1074
  rotate = Math.round(Math.atan2(rect.width, rect.height) * 180 / Math.PI);
1075
1075
  if (rotate !== 0) {
1076
1076
  const hackEle = document.createElement('span');
1077
- hackEle.style.cssText = 'display: inline-block; width: 10px; height: 10px; position: relative; contain: layout style size;';
1077
+ // eslint-disable-next-line max-len
1078
+ hackEle.style.cssText = 'display: inline-block; width: 10px; height: 10px; position: relative; contain: layout style size; writing-mode: inherit';
1078
1079
  const pointEle = document.createElement('span');
1079
1080
  pointEle.style.cssText = 'position: absolute; left: 0; top: 0; width:0;height:0';
1080
1081
  hackEle.append(pointEle);
@@ -1089,6 +1090,9 @@ class ExperimentalCaret {
1089
1090
  hackEle.remove();
1090
1091
  }
1091
1092
  }
1093
+ if (rotate === 0 && (writingMode === 'vertical-lr' || writingMode === 'vertical-rl')) {
1094
+ rotate += 90;
1095
+ }
1092
1096
  Object.assign(this.elementRef.style, {
1093
1097
  left: left + 'px',
1094
1098
  top: top + 'px',
@@ -1350,7 +1354,12 @@ exports.MagicInput = class MagicInput extends Input {
1350
1354
  key: key,
1351
1355
  altKey: ev.altKey,
1352
1356
  shiftKey: ev.shiftKey,
1353
- modKey: this.isMac ? ev.metaKey : ev.ctrlKey
1357
+ modKey: this.isMac ? ev.metaKey : ev.ctrlKey,
1358
+ agent: {
1359
+ key: ev.key,
1360
+ code: ev.code,
1361
+ keyCode: ev.keyCode,
1362
+ }
1354
1363
  });
1355
1364
  if (is) {
1356
1365
  this.ignoreComposition = true;
@@ -1616,7 +1625,7 @@ exports.CollaborateCursor = class CollaborateCursor {
1616
1625
  anchorOffset,
1617
1626
  focusSlot,
1618
1627
  anchorSlot
1619
- }, nativeRange);
1628
+ }, nativeRange, item);
1620
1629
  }
1621
1630
  if (!rects) {
1622
1631
  rects = nativeRange.getClientRects();
@@ -1944,7 +1953,12 @@ exports.NativeInput = class NativeInput extends Input {
1944
1953
  key: key,
1945
1954
  altKey: ev.altKey,
1946
1955
  shiftKey: ev.shiftKey,
1947
- modKey: this.isMac ? ev.metaKey : ev.ctrlKey
1956
+ modKey: this.isMac ? ev.metaKey : ev.ctrlKey,
1957
+ agent: {
1958
+ key: ev.key,
1959
+ keyCode: ev.keyCode,
1960
+ code: ev.code
1961
+ }
1948
1962
  });
1949
1963
  if (is) {
1950
1964
  this.ignoreComposition = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/platform-browser",
3
- "version": "4.1.0",
3
+ "version": "4.2.1",
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",
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@tanbo/stream": "^1.2.5",
29
- "@textbus/core": "^4.1.0",
29
+ "@textbus/core": "^4.2.1",
30
30
  "@viewfly/core": "^1.0.5"
31
31
  },
32
32
  "devDependencies": {