@textbus/platform-browser 4.0.0-alpha.24 → 4.0.0-alpha.26

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.
@@ -1,4 +1,4 @@
1
- import { Component, ComponentInstance, ComponentLiteral, Module, Textbus } from '@textbus/core';
1
+ import { ComponentConstructor, Component, ComponentLiteral, Module, Textbus } from '@textbus/core';
2
2
  import { Provider } from '@viewfly/core';
3
3
  import { AttributeLoader, ComponentLoader, FormatLoader } from './parser';
4
4
  import { DomAdapter } from './dom-adapter';
@@ -34,14 +34,14 @@ export declare class BrowserModule implements Module {
34
34
  * @param rootComponentLoader 文档根组件加载器
35
35
  * @param textbus
36
36
  */
37
- readDocumentByHTML(html: string, rootComponentLoader: ComponentLoader, textbus: Textbus): ComponentInstance;
37
+ readDocumentByHTML(html: string, rootComponentLoader: ComponentLoader, textbus: Textbus): Component;
38
38
  /**
39
39
  * 将组件数据解析到组件实例中
40
40
  * @param data 要解析的 JSON 数据
41
41
  * @param rootComponent 根组件
42
42
  * @param textbus
43
43
  */
44
- readDocumentByComponentLiteral(data: ComponentLiteral, rootComponent: Component, textbus: Textbus): ComponentInstance;
44
+ readDocumentByComponentLiteral(data: ComponentLiteral, rootComponent: ComponentConstructor, textbus: Textbus): Component;
45
45
  setup(): () => void;
46
46
  onAfterStartup(textbus: Textbus): void;
47
47
  private static createLayout;
@@ -1,4 +1,4 @@
1
- import { ComponentInstance, Slot, ViewAdapter, NodeLocation, VElement, VTextNode, Textbus } from '@textbus/core';
1
+ import { Component, Slot, ViewAdapter, NodeLocation, VElement, VTextNode, Textbus } from '@textbus/core';
2
2
  /**
3
3
  * Textbus PC 端浏览器渲染能力桥接器抽象类,提供了 DOM 元素查询能力,具体渲染能力由各前端框架实现相应桥接
4
4
  */
@@ -7,42 +7,42 @@ export declare abstract class DomAdapter<ViewComponent, ViewElement> extends Vie
7
7
  host: HTMLElement;
8
8
  protected componentRootElementCaches: {
9
9
  set: {
10
- (key: ComponentInstance<unknown, unknown, unknown>, value: HTMLElement): void;
11
- (key: HTMLElement, value: ComponentInstance<unknown, unknown, unknown>): void;
10
+ (key: Component<import("@textbus/core").State>, value: HTMLElement): void;
11
+ (key: HTMLElement, value: Component<import("@textbus/core").State>): void;
12
12
  };
13
13
  get: {
14
- (key: ComponentInstance<unknown, unknown, unknown>): HTMLElement;
15
- (key: HTMLElement): ComponentInstance<unknown, unknown, unknown>;
14
+ (key: Component<import("@textbus/core").State>): HTMLElement;
15
+ (key: HTMLElement): Component<import("@textbus/core").State>;
16
16
  };
17
- remove: (key: HTMLElement | ComponentInstance<unknown, unknown, unknown>) => void;
17
+ remove: (key: HTMLElement | Component<import("@textbus/core").State>) => void;
18
18
  };
19
19
  protected slotRootNativeElementCaches: {
20
20
  set: {
21
- (key: Slot<any>, value: HTMLElement): void;
22
- (key: HTMLElement, value: Slot<any>): void;
21
+ (key: Slot, value: HTMLElement): void;
22
+ (key: HTMLElement, value: Slot): void;
23
23
  };
24
24
  get: {
25
- (key: Slot<any>): HTMLElement;
26
- (key: HTMLElement): Slot<any>;
25
+ (key: Slot): HTMLElement;
26
+ (key: HTMLElement): Slot;
27
27
  };
28
- remove: (key: HTMLElement | Slot<any>) => void;
28
+ remove: (key: HTMLElement | Slot) => void;
29
29
  };
30
- protected slotRootVElementCaches: WeakMap<Slot<any>, VElement>;
30
+ protected slotRootVElementCaches: WeakMap<Slot, VElement>;
31
31
  protected constructor(mount: (host: HTMLElement, viewComponent: ViewComponent, textbus: Textbus) => (void | (() => void)));
32
- render(rootComponent: ComponentInstance, textbus: Textbus): void | (() => void);
33
- abstract componentRender(component: ComponentInstance): ViewComponent;
34
- abstract slotRender(slot: Slot, slotHostRender: (children: Array<VElement | VTextNode | ComponentInstance>) => VElement, renderEnv: any): ViewElement;
32
+ render(rootComponent: Component, textbus: Textbus): void | (() => void);
33
+ abstract componentRender(component: Component): ViewComponent;
34
+ abstract slotRender(slot: Slot, slotHostRender: (children: Array<VElement | VTextNode | Component>) => VElement, renderEnv: any): ViewElement;
35
35
  copy(): void;
36
36
  /**
37
37
  * 根据组件获取组件的根 DOM 节点
38
38
  * @param component
39
39
  */
40
- getNativeNodeByComponent(component: ComponentInstance): HTMLElement | null;
40
+ getNativeNodeByComponent(component: Component): HTMLElement | null;
41
41
  /**
42
42
  * 根据 DOM 节点,获对对应的组件根节点,如传入的 DOM 节点不为组件的根节点,则返回 null
43
43
  * @param node
44
44
  */
45
- getComponentByNativeNode(node: HTMLElement): ComponentInstance | null;
45
+ getComponentByNativeNode(node: HTMLElement): Component | null;
46
46
  /**
47
47
  * 根据插槽获取插槽的根 DOM 节点
48
48
  * @param slot
@@ -1,5 +1,5 @@
1
1
  import 'reflect-metadata';
2
- import { Slot, Textbus, ViewAdapter, createBidirectionalMapping, ComponentInstance, VElement, VTextNode, Controller, Selection, RootComponentRef, ContentType, Event, invokeListener, Keyboard, Commander, Scheduler, makeError, NativeSelectionBridge, FocusManager, Registry } from '@textbus/core';
2
+ import { Slot, Textbus, ViewAdapter, createBidirectionalMapping, Component, VElement, VTextNode, Controller, Selection, RootComponentRef, ContentType, Event, invokeListener, Keyboard, Commander, Scheduler, makeError, NativeSelectionBridge, FocusManager, Registry } from '@textbus/core';
3
3
  import { Subject, filter, fromEvent, Subscription, distinctUntilChanged, merge, map, Observable } from '@tanbo/stream';
4
4
  import { InjectionToken, Injectable, Inject, Optional } from '@viewfly/core';
5
5
 
@@ -323,7 +323,7 @@ class DomAdapter extends ViewAdapter {
323
323
  }
324
324
  });
325
325
  this.componentRootElementCaches = createBidirectionalMapping(a => {
326
- return a instanceof ComponentInstance;
326
+ return a instanceof Component;
327
327
  });
328
328
  this.slotRootNativeElementCaches = createBidirectionalMapping(a => {
329
329
  return a instanceof Slot;
@@ -422,7 +422,7 @@ function getLocation(target, tree, vNodeTree) {
422
422
  const child = vNodeTree.children[i];
423
423
  const nativeChild = tree.childNodes[i];
424
424
  if (nativeChild === target) {
425
- if (child instanceof ComponentInstance) {
425
+ if (child instanceof Component) {
426
426
  const index = child.parent.indexOf(child);
427
427
  return {
428
428
  slot: child.parent,
@@ -752,7 +752,7 @@ let SelectionBridge = class SelectionBridge {
752
752
  this.input.composition ||
753
753
  selection.rangeCount === 0 ||
754
754
  !this.docContainer.contains(selection.anchorNode) ||
755
- this.rootComponentRef.component.slots.length === 0) {
755
+ this.rootComponentRef.component.__slots__.length === 0) {
756
756
  return;
757
757
  }
758
758
  const rawRange = selection.getRangeAt(0);
@@ -761,14 +761,14 @@ let SelectionBridge = class SelectionBridge {
761
761
  const isFocusStart = selection.focusNode === nativeRange.startContainer && selection.focusOffset === nativeRange.startOffset;
762
762
  if (!this.docContainer.contains(selection.focusNode)) {
763
763
  if (isFocusEnd) {
764
- const nativeNode = this.domAdapter.getNativeNodeBySlot(this.rootComponentRef.component.slots.first);
764
+ const nativeNode = this.domAdapter.getNativeNodeBySlot(this.rootComponentRef.component.__slots__.first);
765
765
  if (!nativeNode) {
766
766
  return;
767
767
  }
768
768
  nativeRange.setEndAfter(nativeNode.lastChild);
769
769
  }
770
770
  else {
771
- const nativeNode = this.domAdapter.getNativeNodeBySlot(this.rootComponentRef.component.slots.last);
771
+ const nativeNode = this.domAdapter.getNativeNodeBySlot(this.rootComponentRef.component.__slots__.last);
772
772
  if (!nativeNode) {
773
773
  return;
774
774
  }
@@ -2366,7 +2366,7 @@ class BrowserModule {
2366
2366
  readDocumentByHTML(html, rootComponentLoader, textbus) {
2367
2367
  const parser = textbus.get(Parser);
2368
2368
  const doc = parser.parseDoc(html, rootComponentLoader);
2369
- if (doc instanceof ComponentInstance) {
2369
+ if (doc instanceof Component) {
2370
2370
  return doc;
2371
2371
  }
2372
2372
  throw browserErrorFn('rootComponentLoader must return a component instance.');
package/bundles/index.js CHANGED
@@ -325,7 +325,7 @@ class DomAdapter extends core$1.ViewAdapter {
325
325
  }
326
326
  });
327
327
  this.componentRootElementCaches = core$1.createBidirectionalMapping(a => {
328
- return a instanceof core$1.ComponentInstance;
328
+ return a instanceof core$1.Component;
329
329
  });
330
330
  this.slotRootNativeElementCaches = core$1.createBidirectionalMapping(a => {
331
331
  return a instanceof core$1.Slot;
@@ -424,7 +424,7 @@ function getLocation(target, tree, vNodeTree) {
424
424
  const child = vNodeTree.children[i];
425
425
  const nativeChild = tree.childNodes[i];
426
426
  if (nativeChild === target) {
427
- if (child instanceof core$1.ComponentInstance) {
427
+ if (child instanceof core$1.Component) {
428
428
  const index = child.parent.indexOf(child);
429
429
  return {
430
430
  slot: child.parent,
@@ -754,7 +754,7 @@ exports.SelectionBridge = class SelectionBridge {
754
754
  this.input.composition ||
755
755
  selection.rangeCount === 0 ||
756
756
  !this.docContainer.contains(selection.anchorNode) ||
757
- this.rootComponentRef.component.slots.length === 0) {
757
+ this.rootComponentRef.component.__slots__.length === 0) {
758
758
  return;
759
759
  }
760
760
  const rawRange = selection.getRangeAt(0);
@@ -763,14 +763,14 @@ exports.SelectionBridge = class SelectionBridge {
763
763
  const isFocusStart = selection.focusNode === nativeRange.startContainer && selection.focusOffset === nativeRange.startOffset;
764
764
  if (!this.docContainer.contains(selection.focusNode)) {
765
765
  if (isFocusEnd) {
766
- const nativeNode = this.domAdapter.getNativeNodeBySlot(this.rootComponentRef.component.slots.first);
766
+ const nativeNode = this.domAdapter.getNativeNodeBySlot(this.rootComponentRef.component.__slots__.first);
767
767
  if (!nativeNode) {
768
768
  return;
769
769
  }
770
770
  nativeRange.setEndAfter(nativeNode.lastChild);
771
771
  }
772
772
  else {
773
- const nativeNode = this.domAdapter.getNativeNodeBySlot(this.rootComponentRef.component.slots.last);
773
+ const nativeNode = this.domAdapter.getNativeNodeBySlot(this.rootComponentRef.component.__slots__.last);
774
774
  if (!nativeNode) {
775
775
  return;
776
776
  }
@@ -2368,7 +2368,7 @@ class BrowserModule {
2368
2368
  readDocumentByHTML(html, rootComponentLoader, textbus) {
2369
2369
  const parser = textbus.get(exports.Parser);
2370
2370
  const doc = parser.parseDoc(html, rootComponentLoader);
2371
- if (doc instanceof core$1.ComponentInstance) {
2371
+ if (doc instanceof core$1.Component) {
2372
2372
  return doc;
2373
2373
  }
2374
2374
  throw browserErrorFn('rootComponentLoader must return a component instance.');
@@ -1,4 +1,4 @@
1
- import { Attribute, ComponentInstance, Formatter, FormatValue, Slot, Textbus } from '@textbus/core';
1
+ import { Attribute, Component, Formatter, FormatValue, Slot, Textbus } from '@textbus/core';
2
2
  import { ViewOptions } from './browser-module';
3
3
  /**
4
4
  * 插槽解析器
@@ -20,7 +20,7 @@ export interface ComponentLoader {
20
20
  /** 识别组件的匹配方法 */
21
21
  match(element: HTMLElement): boolean;
22
22
  /** 读取组件内容的方法 */
23
- read(element: HTMLElement, textbus: Textbus, slotParser: SlotParser): ComponentInstance | Slot | void;
23
+ read(element: HTMLElement, textbus: Textbus, slotParser: SlotParser): Component | Slot | void;
24
24
  }
25
25
  export interface FormatLoaderReadResult<T = FormatValue> {
26
26
  formatter: Formatter<T>;
@@ -76,13 +76,13 @@ export declare class Parser {
76
76
  * @param html
77
77
  * @param rootComponentLoader
78
78
  */
79
- parseDoc(html: string | HTMLElement, rootComponentLoader: ComponentLoader): void | Slot<any> | ComponentInstance<unknown, unknown, unknown>;
79
+ parseDoc(html: string | HTMLElement, rootComponentLoader: ComponentLoader): void | Slot | Component<import("@textbus/core").State>;
80
80
  /**
81
81
  * 将一段 HTML 或 DOM 元素解析到指定插槽
82
82
  * @param html
83
83
  * @param rootSlot
84
84
  */
85
- parse(html: string | HTMLElement, rootSlot: Slot): Slot<any>;
85
+ parse(html: string | HTMLElement, rootSlot: Slot): Slot;
86
86
  private readComponent;
87
87
  private readText;
88
88
  private readFormats;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/platform-browser",
3
- "version": "4.0.0-alpha.24",
3
+ "version": "4.0.0-alpha.26",
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.3",
29
- "@textbus/core": "^4.0.0-alpha.24",
29
+ "@textbus/core": "^4.0.0-alpha.26",
30
30
  "@viewfly/core": "^0.6.0",
31
31
  "reflect-metadata": "^0.1.13"
32
32
  },
@@ -48,5 +48,5 @@
48
48
  "bugs": {
49
49
  "url": "https://github.com/textbus/textbus.git/issues"
50
50
  },
51
- "gitHead": "3456cd519a3c3daca4a437af97db4b57d34ad740"
51
+ "gitHead": "36aff3db9897ccd73ba4533972991d537778bd6e"
52
52
  }