@textbus/platform-browser 4.2.0 → 4.2.2

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.
@@ -43,7 +43,7 @@ export declare class BrowserModule implements Module {
43
43
  * @param textbus
44
44
  */
45
45
  readDocumentByComponentLiteral(data: ComponentLiteral, rootComponent: ComponentConstructor, textbus: Textbus): Component;
46
- setup(textbus: Textbus): () => void;
46
+ setup(textbus: Textbus): Promise<() => void>;
47
47
  onAfterStartup(textbus: Textbus): void;
48
48
  onDestroy(textbus: Textbus): void;
49
49
  private static createLayout;
@@ -150,6 +150,16 @@ function __metadata(metadataKey, metadataValue) {
150
150
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
151
151
  }
152
152
 
153
+ function __awaiter(thisArg, _arguments, P, generator) {
154
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
155
+ return new (P || (P = Promise))(function (resolve, reject) {
156
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
157
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
158
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
159
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
160
+ });
161
+ }
162
+
153
163
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
154
164
  var e = new Error(message);
155
165
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
@@ -1043,7 +1053,7 @@ class ExperimentalCaret {
1043
1053
  nativeRange.collapse();
1044
1054
  }
1045
1055
  const rect = getLayoutRectByRange(nativeRange);
1046
- const { fontSize, lineHeight, color } = getComputedStyle(node);
1056
+ const { fontSize, lineHeight, color, writingMode } = getComputedStyle(node);
1047
1057
  let height;
1048
1058
  if (isNaN(+lineHeight)) {
1049
1059
  const f = parseFloat(lineHeight);
@@ -1072,7 +1082,8 @@ class ExperimentalCaret {
1072
1082
  rotate = Math.round(Math.atan2(rect.width, rect.height) * 180 / Math.PI);
1073
1083
  if (rotate !== 0) {
1074
1084
  const hackEle = document.createElement('span');
1075
- hackEle.style.cssText = 'display: inline-block; width: 10px; height: 10px; position: relative; contain: layout style size;';
1085
+ // eslint-disable-next-line max-len
1086
+ hackEle.style.cssText = 'display: inline-block; width: 10px; height: 10px; position: relative; contain: layout style size; writing-mode: inherit';
1076
1087
  const pointEle = document.createElement('span');
1077
1088
  pointEle.style.cssText = 'position: absolute; left: 0; top: 0; width:0;height:0';
1078
1089
  hackEle.append(pointEle);
@@ -1087,6 +1098,9 @@ class ExperimentalCaret {
1087
1098
  hackEle.remove();
1088
1099
  }
1089
1100
  }
1101
+ if (rotate === 0 && (writingMode === 'vertical-lr' || writingMode === 'vertical-rl')) {
1102
+ rotate += 90;
1103
+ }
1090
1104
  Object.assign(this.elementRef.style, {
1091
1105
  left: left + 'px',
1092
1106
  top: top + 'px',
@@ -2243,15 +2257,18 @@ class BrowserModule {
2243
2257
  return registry.createComponentByFactory(data, rootComponent);
2244
2258
  }
2245
2259
  setup(textbus) {
2246
- this.textbus = textbus;
2247
- const host = this.config.renderTo();
2248
- if (!(host instanceof HTMLElement)) {
2249
- throw browserErrorFn('view container is not a HTMLElement');
2250
- }
2251
- host.append(this.workbench);
2252
- return () => {
2253
- this.workbench.remove();
2254
- };
2260
+ return __awaiter(this, void 0, void 0, function* () {
2261
+ this.textbus = textbus;
2262
+ const host = this.config.renderTo();
2263
+ if (!(host instanceof HTMLElement)) {
2264
+ throw browserErrorFn('view container is not a HTMLElement');
2265
+ }
2266
+ host.append(this.workbench);
2267
+ yield textbus.get(Input).onReady;
2268
+ return () => {
2269
+ this.workbench.remove();
2270
+ };
2271
+ });
2255
2272
  }
2256
2273
  onAfterStartup(textbus) {
2257
2274
  if (this.config.autoFocus) {
package/bundles/index.js CHANGED
@@ -152,6 +152,16 @@ function __metadata(metadataKey, metadataValue) {
152
152
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
153
153
  }
154
154
 
155
+ function __awaiter(thisArg, _arguments, P, generator) {
156
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
157
+ return new (P || (P = Promise))(function (resolve, reject) {
158
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
159
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
160
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
161
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
162
+ });
163
+ }
164
+
155
165
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
156
166
  var e = new Error(message);
157
167
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
@@ -1045,7 +1055,7 @@ class ExperimentalCaret {
1045
1055
  nativeRange.collapse();
1046
1056
  }
1047
1057
  const rect = getLayoutRectByRange(nativeRange);
1048
- const { fontSize, lineHeight, color } = getComputedStyle(node);
1058
+ const { fontSize, lineHeight, color, writingMode } = getComputedStyle(node);
1049
1059
  let height;
1050
1060
  if (isNaN(+lineHeight)) {
1051
1061
  const f = parseFloat(lineHeight);
@@ -1074,7 +1084,8 @@ class ExperimentalCaret {
1074
1084
  rotate = Math.round(Math.atan2(rect.width, rect.height) * 180 / Math.PI);
1075
1085
  if (rotate !== 0) {
1076
1086
  const hackEle = document.createElement('span');
1077
- hackEle.style.cssText = 'display: inline-block; width: 10px; height: 10px; position: relative; contain: layout style size;';
1087
+ // eslint-disable-next-line max-len
1088
+ hackEle.style.cssText = 'display: inline-block; width: 10px; height: 10px; position: relative; contain: layout style size; writing-mode: inherit';
1078
1089
  const pointEle = document.createElement('span');
1079
1090
  pointEle.style.cssText = 'position: absolute; left: 0; top: 0; width:0;height:0';
1080
1091
  hackEle.append(pointEle);
@@ -1089,6 +1100,9 @@ class ExperimentalCaret {
1089
1100
  hackEle.remove();
1090
1101
  }
1091
1102
  }
1103
+ if (rotate === 0 && (writingMode === 'vertical-lr' || writingMode === 'vertical-rl')) {
1104
+ rotate += 90;
1105
+ }
1092
1106
  Object.assign(this.elementRef.style, {
1093
1107
  left: left + 'px',
1094
1108
  top: top + 'px',
@@ -2245,15 +2259,18 @@ class BrowserModule {
2245
2259
  return registry.createComponentByFactory(data, rootComponent);
2246
2260
  }
2247
2261
  setup(textbus) {
2248
- this.textbus = textbus;
2249
- const host = this.config.renderTo();
2250
- if (!(host instanceof HTMLElement)) {
2251
- throw browserErrorFn('view container is not a HTMLElement');
2252
- }
2253
- host.append(this.workbench);
2254
- return () => {
2255
- this.workbench.remove();
2256
- };
2262
+ return __awaiter(this, void 0, void 0, function* () {
2263
+ this.textbus = textbus;
2264
+ const host = this.config.renderTo();
2265
+ if (!(host instanceof HTMLElement)) {
2266
+ throw browserErrorFn('view container is not a HTMLElement');
2267
+ }
2268
+ host.append(this.workbench);
2269
+ yield textbus.get(Input).onReady;
2270
+ return () => {
2271
+ this.workbench.remove();
2272
+ };
2273
+ });
2257
2274
  }
2258
2275
  onAfterStartup(textbus) {
2259
2276
  if (this.config.autoFocus) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/platform-browser",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
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.2.0",
29
+ "@textbus/core": "^4.2.1",
30
30
  "@viewfly/core": "^1.0.5"
31
31
  },
32
32
  "devDependencies": {