@textbus/platform-browser 3.0.0-alpha.38 → 3.0.0-alpha.39

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.
@@ -49,6 +49,9 @@ export declare class MagicInput extends Input {
49
49
  composition: boolean;
50
50
  onReady: Promise<void>;
51
51
  caret: ExperimentalCaret;
52
+ set disabled(b: boolean);
53
+ get disabled(): boolean;
54
+ private _disabled;
52
55
  private container;
53
56
  private subscription;
54
57
  private doc;
@@ -34,6 +34,9 @@ export declare class NativeInput extends Input {
34
34
  caret: NativeCaret;
35
35
  composition: boolean;
36
36
  onReady: Promise<void>;
37
+ set disabled(b: boolean);
38
+ get disabled(): boolean;
39
+ private _disabled;
37
40
  private documentView;
38
41
  private nativeSelection;
39
42
  private subscription;
@@ -55,6 +55,7 @@ export declare abstract class Input {
55
55
  abstract composition: boolean;
56
56
  abstract onReady: Promise<void>;
57
57
  abstract caret: Caret;
58
+ abstract disabled: boolean;
58
59
  abstract focus(nativeRange: Range, reFlash: boolean): void;
59
60
  abstract blur(): void;
60
61
  abstract destroy(): void;
@@ -515,7 +515,8 @@ let SelectionBridge = class SelectionBridge {
515
515
  if (this.ignoreSelectionChange ||
516
516
  this.input.composition ||
517
517
  selection.rangeCount === 0 ||
518
- !this.docContainer.contains(selection.anchorNode)) {
518
+ !this.docContainer.contains(selection.anchorNode) ||
519
+ this.rootComponentRef.component.slots.length === 0) {
519
520
  return;
520
521
  }
521
522
  const rawRange = selection.getRangeAt(0);
@@ -525,12 +526,24 @@ let SelectionBridge = class SelectionBridge {
525
526
  if (!this.docContainer.contains(selection.focusNode)) {
526
527
  if (isFocusEnd) {
527
528
  const vEle = this.renderer.getVNodeBySlot(this.rootComponentRef.component.slots.first);
529
+ if (!vEle) {
530
+ return;
531
+ }
528
532
  const nativeNode = this.renderer.getNativeNodeByVNode(vEle);
533
+ if (!nativeNode) {
534
+ return;
535
+ }
529
536
  nativeRange.setEndAfter(nativeNode.lastChild);
530
537
  }
531
538
  else {
532
539
  const vEle = this.renderer.getVNodeBySlot(this.rootComponentRef.component.slots.last);
540
+ if (!vEle) {
541
+ return;
542
+ }
533
543
  const nativeNode = this.renderer.getNativeNodeByVNode(vEle);
544
+ if (!nativeNode) {
545
+ return;
546
+ }
534
547
  nativeRange.setStartBefore(nativeNode.firstChild);
535
548
  }
536
549
  }
@@ -1538,6 +1551,15 @@ class ExperimentalCaret {
1538
1551
  * Textbus PC 端输入实现
1539
1552
  */
1540
1553
  let MagicInput = class MagicInput extends Input {
1554
+ set disabled(b) {
1555
+ this._disabled = b;
1556
+ if (b && this.textarea) {
1557
+ this.textarea.disabled = b;
1558
+ }
1559
+ }
1560
+ get disabled() {
1561
+ return this._disabled;
1562
+ }
1541
1563
  constructor(parser, keyboard, commander, selection, controller, scheduler, injector) {
1542
1564
  super();
1543
1565
  this.parser = parser;
@@ -1549,6 +1571,7 @@ let MagicInput = class MagicInput extends Input {
1549
1571
  this.injector = injector;
1550
1572
  this.composition = false;
1551
1573
  this.caret = new ExperimentalCaret(this.scheduler, this.injector.get(VIEW_MASK));
1574
+ this._disabled = false;
1552
1575
  this.container = this.createEditableFrame();
1553
1576
  this.subscription = new Subscription();
1554
1577
  this.textarea = null;
@@ -1577,7 +1600,9 @@ let MagicInput = class MagicInput extends Input {
1577
1600
  }
1578
1601
  focus(range, restart) {
1579
1602
  var _a;
1580
- this.caret.show(range, restart);
1603
+ if (!this.disabled) {
1604
+ this.caret.show(range, restart);
1605
+ }
1581
1606
  if (this.controller.readonly) {
1582
1607
  return;
1583
1608
  }
@@ -1610,6 +1635,7 @@ let MagicInput = class MagicInput extends Input {
1610
1635
  const doc = this.doc;
1611
1636
  const contentBody = doc.body;
1612
1637
  const textarea = doc.createElement('textarea');
1638
+ textarea.disabled = this.disabled;
1613
1639
  contentBody.appendChild(textarea);
1614
1640
  this.textarea = textarea;
1615
1641
  this.subscription.add(fromEvent(textarea, 'blur').subscribe(() => {
@@ -1879,6 +1905,15 @@ class NativeCaret {
1879
1905
  }
1880
1906
  }
1881
1907
  let NativeInput = class NativeInput extends Input {
1908
+ set disabled(b) {
1909
+ this._disabled = b;
1910
+ if (b && !this.controller.readonly) {
1911
+ this.documentView.contentEditable = b ? 'true' : 'false';
1912
+ }
1913
+ }
1914
+ get disabled() {
1915
+ return this._disabled;
1916
+ }
1882
1917
  constructor(injector, parser, scheduler, selection, keyboard, commander, controller) {
1883
1918
  super();
1884
1919
  this.injector = injector;
@@ -1891,6 +1926,7 @@ let NativeInput = class NativeInput extends Input {
1891
1926
  this.caret = new NativeCaret(this.scheduler);
1892
1927
  this.composition = false;
1893
1928
  this.onReady = Promise.resolve();
1929
+ this._disabled = false;
1894
1930
  this.nativeSelection = document.getSelection();
1895
1931
  this.subscription = new Subscription();
1896
1932
  this.nativeRange = null;
package/bundles/index.js CHANGED
@@ -517,7 +517,8 @@ exports.SelectionBridge = class SelectionBridge {
517
517
  if (this.ignoreSelectionChange ||
518
518
  this.input.composition ||
519
519
  selection.rangeCount === 0 ||
520
- !this.docContainer.contains(selection.anchorNode)) {
520
+ !this.docContainer.contains(selection.anchorNode) ||
521
+ this.rootComponentRef.component.slots.length === 0) {
521
522
  return;
522
523
  }
523
524
  const rawRange = selection.getRangeAt(0);
@@ -527,12 +528,24 @@ exports.SelectionBridge = class SelectionBridge {
527
528
  if (!this.docContainer.contains(selection.focusNode)) {
528
529
  if (isFocusEnd) {
529
530
  const vEle = this.renderer.getVNodeBySlot(this.rootComponentRef.component.slots.first);
531
+ if (!vEle) {
532
+ return;
533
+ }
530
534
  const nativeNode = this.renderer.getNativeNodeByVNode(vEle);
535
+ if (!nativeNode) {
536
+ return;
537
+ }
531
538
  nativeRange.setEndAfter(nativeNode.lastChild);
532
539
  }
533
540
  else {
534
541
  const vEle = this.renderer.getVNodeBySlot(this.rootComponentRef.component.slots.last);
542
+ if (!vEle) {
543
+ return;
544
+ }
535
545
  const nativeNode = this.renderer.getNativeNodeByVNode(vEle);
546
+ if (!nativeNode) {
547
+ return;
548
+ }
536
549
  nativeRange.setStartBefore(nativeNode.firstChild);
537
550
  }
538
551
  }
@@ -1540,6 +1553,15 @@ class ExperimentalCaret {
1540
1553
  * Textbus PC 端输入实现
1541
1554
  */
1542
1555
  exports.MagicInput = class MagicInput extends Input {
1556
+ set disabled(b) {
1557
+ this._disabled = b;
1558
+ if (b && this.textarea) {
1559
+ this.textarea.disabled = b;
1560
+ }
1561
+ }
1562
+ get disabled() {
1563
+ return this._disabled;
1564
+ }
1543
1565
  constructor(parser, keyboard, commander, selection, controller, scheduler, injector) {
1544
1566
  super();
1545
1567
  this.parser = parser;
@@ -1551,6 +1573,7 @@ exports.MagicInput = class MagicInput extends Input {
1551
1573
  this.injector = injector;
1552
1574
  this.composition = false;
1553
1575
  this.caret = new ExperimentalCaret(this.scheduler, this.injector.get(VIEW_MASK));
1576
+ this._disabled = false;
1554
1577
  this.container = this.createEditableFrame();
1555
1578
  this.subscription = new stream.Subscription();
1556
1579
  this.textarea = null;
@@ -1579,7 +1602,9 @@ exports.MagicInput = class MagicInput extends Input {
1579
1602
  }
1580
1603
  focus(range, restart) {
1581
1604
  var _a;
1582
- this.caret.show(range, restart);
1605
+ if (!this.disabled) {
1606
+ this.caret.show(range, restart);
1607
+ }
1583
1608
  if (this.controller.readonly) {
1584
1609
  return;
1585
1610
  }
@@ -1612,6 +1637,7 @@ exports.MagicInput = class MagicInput extends Input {
1612
1637
  const doc = this.doc;
1613
1638
  const contentBody = doc.body;
1614
1639
  const textarea = doc.createElement('textarea');
1640
+ textarea.disabled = this.disabled;
1615
1641
  contentBody.appendChild(textarea);
1616
1642
  this.textarea = textarea;
1617
1643
  this.subscription.add(stream.fromEvent(textarea, 'blur').subscribe(() => {
@@ -1881,6 +1907,15 @@ class NativeCaret {
1881
1907
  }
1882
1908
  }
1883
1909
  exports.NativeInput = class NativeInput extends Input {
1910
+ set disabled(b) {
1911
+ this._disabled = b;
1912
+ if (b && !this.controller.readonly) {
1913
+ this.documentView.contentEditable = b ? 'true' : 'false';
1914
+ }
1915
+ }
1916
+ get disabled() {
1917
+ return this._disabled;
1918
+ }
1884
1919
  constructor(injector, parser, scheduler, selection, keyboard, commander, controller) {
1885
1920
  super();
1886
1921
  this.injector = injector;
@@ -1893,6 +1928,7 @@ exports.NativeInput = class NativeInput extends Input {
1893
1928
  this.caret = new NativeCaret(this.scheduler);
1894
1929
  this.composition = false;
1895
1930
  this.onReady = Promise.resolve();
1931
+ this._disabled = false;
1896
1932
  this.nativeSelection = document.getSelection();
1897
1933
  this.subscription = new stream.Subscription();
1898
1934
  this.nativeRange = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/platform-browser",
3
- "version": "3.0.0-alpha.38",
3
+ "version": "3.0.0-alpha.39",
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",
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@tanbo/di": "^1.1.4",
29
29
  "@tanbo/stream": "^1.1.8",
30
- "@textbus/core": "^3.0.0-alpha.38",
30
+ "@textbus/core": "^3.0.0-alpha.39",
31
31
  "reflect-metadata": "^0.1.13"
32
32
  },
33
33
  "devDependencies": {
@@ -48,5 +48,5 @@
48
48
  "bugs": {
49
49
  "url": "https://github.com/textbus/textbus.git/issues"
50
50
  },
51
- "gitHead": "5a467be66bf6ed9feca7e3c591bfbc73600e69f9"
51
+ "gitHead": "049b7797052dbf0e430571ff47d25e289086028b"
52
52
  }