@textbus/platform-browser 4.0.0-alpha.30 → 4.0.0-alpha.32

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.
@@ -5,6 +5,7 @@ import { Component, Slot, ViewAdapter, NodeLocation, VElement, VTextNode, Textbu
5
5
  export declare abstract class DomAdapter<ViewComponent, ViewElement> extends ViewAdapter {
6
6
  private mount;
7
7
  host: HTMLElement;
8
+ protected firstRending: boolean;
8
9
  protected componentRootElementCaches: {
9
10
  set: {
10
11
  (key: Component<import("@textbus/core").State>, value: HTMLElement): void;
@@ -323,6 +323,7 @@ class DomAdapter extends ViewAdapter {
323
323
  id: 'textbus-' + Number((Math.random() + '').substring(2)).toString(16)
324
324
  }
325
325
  });
326
+ this.firstRending = true;
326
327
  this.componentRootElementCaches = createBidirectionalMapping(a => {
327
328
  return a instanceof Component;
328
329
  });
@@ -333,6 +334,7 @@ class DomAdapter extends ViewAdapter {
333
334
  }
334
335
  render(rootComponent, textbus) {
335
336
  const view = this.componentRender(rootComponent);
337
+ this.firstRending = false;
336
338
  return this.mount(this.host, view, textbus);
337
339
  }
338
340
  copy() {
@@ -1299,13 +1301,8 @@ let MagicInput = class MagicInput extends Input {
1299
1301
  if (!this.isFocus) {
1300
1302
  (_a = this.textarea) === null || _a === void 0 ? void 0 : _a.focus();
1301
1303
  setTimeout(() => {
1302
- var _a, _b, _c;
1303
1304
  if (!this.nativeFocus && this.isFocus) {
1304
- this.subscription.unsubscribe();
1305
- (_b = (_a = this.textarea) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(this.textarea);
1306
- this.subscription = new Subscription();
1307
- this.init();
1308
- (_c = this.textarea) === null || _c === void 0 ? void 0 : _c.focus();
1305
+ this.reInit();
1309
1306
  }
1310
1307
  });
1311
1308
  }
@@ -1321,6 +1318,22 @@ let MagicInput = class MagicInput extends Input {
1321
1318
  this.caret.destroy();
1322
1319
  this.subscription.unsubscribe();
1323
1320
  }
1321
+ reInit(delay = false) {
1322
+ var _a, _b, _c;
1323
+ this.subscription.unsubscribe();
1324
+ (_b = (_a = this.textarea) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(this.textarea);
1325
+ this.subscription = new Subscription();
1326
+ this.init();
1327
+ if (delay) {
1328
+ setTimeout(() => {
1329
+ var _a;
1330
+ (_a = this.textarea) === null || _a === void 0 ? void 0 : _a.focus();
1331
+ });
1332
+ }
1333
+ else {
1334
+ (_c = this.textarea) === null || _c === void 0 ? void 0 : _c.focus();
1335
+ }
1336
+ }
1324
1337
  init() {
1325
1338
  const doc = this.doc;
1326
1339
  const contentBody = doc.body;
@@ -1329,7 +1342,10 @@ let MagicInput = class MagicInput extends Input {
1329
1342
  contentBody.appendChild(textarea);
1330
1343
  this.textarea = textarea;
1331
1344
  this.subscription.add(fromEvent(textarea, 'blur').subscribe(() => {
1332
- this.isFocus = false;
1345
+ if (this.isFocus) {
1346
+ this.isFocus = false;
1347
+ this.reInit(true);
1348
+ }
1333
1349
  this.nativeFocus = false;
1334
1350
  this.caret.hide();
1335
1351
  }), fromEvent(textarea, 'focus').subscribe(() => {
package/bundles/index.js CHANGED
@@ -325,6 +325,7 @@ class DomAdapter extends core$1.ViewAdapter {
325
325
  id: 'textbus-' + Number((Math.random() + '').substring(2)).toString(16)
326
326
  }
327
327
  });
328
+ this.firstRending = true;
328
329
  this.componentRootElementCaches = core$1.createBidirectionalMapping(a => {
329
330
  return a instanceof core$1.Component;
330
331
  });
@@ -335,6 +336,7 @@ class DomAdapter extends core$1.ViewAdapter {
335
336
  }
336
337
  render(rootComponent, textbus) {
337
338
  const view = this.componentRender(rootComponent);
339
+ this.firstRending = false;
338
340
  return this.mount(this.host, view, textbus);
339
341
  }
340
342
  copy() {
@@ -1301,13 +1303,8 @@ exports.MagicInput = class MagicInput extends Input {
1301
1303
  if (!this.isFocus) {
1302
1304
  (_a = this.textarea) === null || _a === void 0 ? void 0 : _a.focus();
1303
1305
  setTimeout(() => {
1304
- var _a, _b, _c;
1305
1306
  if (!this.nativeFocus && this.isFocus) {
1306
- this.subscription.unsubscribe();
1307
- (_b = (_a = this.textarea) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(this.textarea);
1308
- this.subscription = new stream.Subscription();
1309
- this.init();
1310
- (_c = this.textarea) === null || _c === void 0 ? void 0 : _c.focus();
1307
+ this.reInit();
1311
1308
  }
1312
1309
  });
1313
1310
  }
@@ -1323,6 +1320,22 @@ exports.MagicInput = class MagicInput extends Input {
1323
1320
  this.caret.destroy();
1324
1321
  this.subscription.unsubscribe();
1325
1322
  }
1323
+ reInit(delay = false) {
1324
+ var _a, _b, _c;
1325
+ this.subscription.unsubscribe();
1326
+ (_b = (_a = this.textarea) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(this.textarea);
1327
+ this.subscription = new stream.Subscription();
1328
+ this.init();
1329
+ if (delay) {
1330
+ setTimeout(() => {
1331
+ var _a;
1332
+ (_a = this.textarea) === null || _a === void 0 ? void 0 : _a.focus();
1333
+ });
1334
+ }
1335
+ else {
1336
+ (_c = this.textarea) === null || _c === void 0 ? void 0 : _c.focus();
1337
+ }
1338
+ }
1326
1339
  init() {
1327
1340
  const doc = this.doc;
1328
1341
  const contentBody = doc.body;
@@ -1331,7 +1344,10 @@ exports.MagicInput = class MagicInput extends Input {
1331
1344
  contentBody.appendChild(textarea);
1332
1345
  this.textarea = textarea;
1333
1346
  this.subscription.add(stream.fromEvent(textarea, 'blur').subscribe(() => {
1334
- this.isFocus = false;
1347
+ if (this.isFocus) {
1348
+ this.isFocus = false;
1349
+ this.reInit(true);
1350
+ }
1335
1351
  this.nativeFocus = false;
1336
1352
  this.caret.hide();
1337
1353
  }), stream.fromEvent(textarea, 'focus').subscribe(() => {
@@ -70,6 +70,7 @@ export declare class MagicInput extends Input {
70
70
  focus(range: Range, restart: boolean): void;
71
71
  blur(): void;
72
72
  destroy(): void;
73
+ private reInit;
73
74
  private init;
74
75
  private handleDefaultActions;
75
76
  private handlePaste;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/platform-browser",
3
- "version": "4.0.0-alpha.30",
3
+ "version": "4.0.0-alpha.32",
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,9 +26,9 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@tanbo/stream": "^1.2.3",
29
- "@textbus/collaborate": "^4.0.0-alpha.30",
30
- "@textbus/core": "^4.0.0-alpha.30",
31
- "@viewfly/core": "^0.6.0",
29
+ "@textbus/collaborate": "^4.0.0-alpha.31",
30
+ "@textbus/core": "^4.0.0-alpha.31",
31
+ "@viewfly/core": "^0.6.1",
32
32
  "reflect-metadata": "^0.1.13"
33
33
  },
34
34
  "devDependencies": {
@@ -49,5 +49,5 @@
49
49
  "bugs": {
50
50
  "url": "https://github.com/textbus/textbus.git/issues"
51
51
  },
52
- "gitHead": "9b14d8cf2a2473f31a36b51ee3d988ddecf776fb"
52
+ "gitHead": "00d52c23dde48068e14e46379b85ddac0743c6ff"
53
53
  }