@textbus/platform-browser 4.0.0-alpha.8 → 4.0.0
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.
- package/bundles/_utils/uikit.d.ts +0 -1
- package/bundles/browser-module.d.ts +24 -7
- package/bundles/collaborate-cursor.d.ts +7 -12
- package/bundles/dom-adapter.d.ts +4 -64
- package/bundles/index.esm.js +273 -351
- package/bundles/index.js +275 -354
- package/bundles/magic-input.d.ts +10 -11
- package/bundles/native-input.d.ts +4 -9
- package/bundles/parser.d.ts +9 -10
- package/bundles/public-api.d.ts +1 -0
- package/bundles/selection-bridge.d.ts +2 -2
- package/bundles/types.d.ts +1 -14
- package/package.json +6 -6
@@ -22,5 +22,4 @@ export interface UIElementParams {
|
|
22
22
|
on?: Record<string, (ev: Event) => void>;
|
23
23
|
}
|
24
24
|
export declare function createElement(tagName: string, options?: UIElementParams): HTMLElement;
|
25
|
-
export declare function createTextNode(content: string): Text;
|
26
25
|
export declare function getLayoutRectByRange(range: Range): Rect;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ComponentLiteral, Module } 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';
|
@@ -6,7 +6,10 @@ import { DomAdapter } from './dom-adapter';
|
|
6
6
|
* Textbus PC 端配置接口
|
7
7
|
*/
|
8
8
|
export interface ViewOptions {
|
9
|
-
|
9
|
+
/** 跨平台适配器 */
|
10
|
+
adapter: DomAdapter;
|
11
|
+
/** 编辑器根节点 */
|
12
|
+
renderTo(): HTMLElement;
|
10
13
|
/** 自动获取焦点 */
|
11
14
|
autoFocus?: boolean;
|
12
15
|
/** 编辑区最小高度 */
|
@@ -17,17 +20,31 @@ export interface ViewOptions {
|
|
17
20
|
formatLoaders?: FormatLoader<any>[];
|
18
21
|
/** 属性加载器 */
|
19
22
|
attributeLoaders?: AttributeLoader<any>[];
|
20
|
-
/** 默认内容 */
|
21
|
-
content?: string | ComponentLiteral;
|
22
23
|
/** 使用 contentEditable 作为编辑器控制可编辑范围 */
|
23
24
|
useContentEditable?: boolean;
|
24
25
|
}
|
25
26
|
export declare class BrowserModule implements Module {
|
26
|
-
host: HTMLElement;
|
27
27
|
config: ViewOptions;
|
28
28
|
providers: Provider[];
|
29
29
|
private workbench;
|
30
|
-
|
31
|
-
|
30
|
+
private textbus?;
|
31
|
+
constructor(config: ViewOptions);
|
32
|
+
/**
|
33
|
+
* 解析 HTML 并返回一个组件实例
|
34
|
+
* @param html 要解析的 HTML
|
35
|
+
* @param rootComponentLoader 文档根组件加载器
|
36
|
+
* @param textbus
|
37
|
+
*/
|
38
|
+
readDocumentByHTML(html: string, rootComponentLoader: ComponentLoader, textbus: Textbus): Component;
|
39
|
+
/**
|
40
|
+
* 将组件数据解析到组件实例中
|
41
|
+
* @param data 要解析的 JSON 数据
|
42
|
+
* @param rootComponent 根组件
|
43
|
+
* @param textbus
|
44
|
+
*/
|
45
|
+
readDocumentByComponentLiteral(data: ComponentLiteral, rootComponent: ComponentConstructor, textbus: Textbus): Component;
|
46
|
+
setup(textbus: Textbus): () => void;
|
47
|
+
onAfterStartup(textbus: Textbus): void;
|
48
|
+
onDestroy(textbus: Textbus): void;
|
32
49
|
private static createLayout;
|
33
50
|
}
|
@@ -1,15 +1,7 @@
|
|
1
|
-
import { Selection,
|
1
|
+
import { Selection, AbstractSelection, Scheduler, Textbus } from '@textbus/core';
|
2
|
+
import { UserActivity } from '@textbus/collaborate';
|
2
3
|
import { SelectionBridge } from './selection-bridge';
|
3
4
|
import { Rect } from './_utils/uikit';
|
4
|
-
/**
|
5
|
-
* 远程用户及光标位置信息
|
6
|
-
*/
|
7
|
-
export interface RemoteSelection {
|
8
|
-
id: string;
|
9
|
-
color: string;
|
10
|
-
username: string;
|
11
|
-
paths: SelectionPaths;
|
12
|
-
}
|
13
5
|
export interface SelectionRect extends Rect {
|
14
6
|
color: string;
|
15
7
|
username: string;
|
@@ -33,6 +25,7 @@ export declare class CollaborateCursor {
|
|
33
25
|
private nativeSelection;
|
34
26
|
private scheduler;
|
35
27
|
private selection;
|
28
|
+
private userActivity;
|
36
29
|
private awarenessDelegate?;
|
37
30
|
private host;
|
38
31
|
private canvasContainer;
|
@@ -43,7 +36,9 @@ export declare class CollaborateCursor {
|
|
43
36
|
private subscription;
|
44
37
|
private currentSelection;
|
45
38
|
private container;
|
46
|
-
|
39
|
+
private ratio;
|
40
|
+
constructor(textbus: Textbus, nativeSelection: SelectionBridge, scheduler: Scheduler, selection: Selection, userActivity: UserActivity, awarenessDelegate?: CollaborateSelectionAwarenessDelegate | undefined);
|
41
|
+
init(): void;
|
47
42
|
/**
|
48
43
|
* 刷新协作光标,由于 Textbus 只会绘制可视区域的光标,当可视区域发生变化时,需要重新绘制
|
49
44
|
*/
|
@@ -53,7 +48,7 @@ export declare class CollaborateCursor {
|
|
53
48
|
* 根据远程用户光标位置,绘制协作光标
|
54
49
|
* @param paths
|
55
50
|
*/
|
56
|
-
draw
|
51
|
+
private draw;
|
57
52
|
protected drawUserCursor(rects: SelectionRect[]): void;
|
58
53
|
private getUserCursor;
|
59
54
|
}
|
package/bundles/dom-adapter.d.ts
CHANGED
@@ -1,66 +1,6 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
export declare abstract class DomAdapter<ViewComponent, ViewElement> extends ViewAdapter {
|
6
|
-
private mount;
|
1
|
+
import { Adapter } from '@textbus/core';
|
2
|
+
import { Subject } from '@tanbo/stream';
|
3
|
+
export declare abstract class DomAdapter<ViewComponent extends object = object, ViewElement extends object = object> extends Adapter<HTMLElement, Node, ViewComponent, ViewElement> {
|
4
|
+
onViewUpdated: Subject<void>;
|
7
5
|
host: HTMLElement;
|
8
|
-
protected componentRootElementCaches: {
|
9
|
-
set: {
|
10
|
-
(key: ComponentInstance<unknown, unknown, unknown>, value: HTMLElement): void;
|
11
|
-
(key: HTMLElement, value: ComponentInstance<unknown, unknown, unknown>): void;
|
12
|
-
};
|
13
|
-
get: {
|
14
|
-
(key: ComponentInstance<unknown, unknown, unknown>): HTMLElement;
|
15
|
-
(key: HTMLElement): ComponentInstance<unknown, unknown, unknown>;
|
16
|
-
};
|
17
|
-
remove: (key: HTMLElement | ComponentInstance<unknown, unknown, unknown>) => void;
|
18
|
-
};
|
19
|
-
protected slotRootNativeElementCaches: {
|
20
|
-
set: {
|
21
|
-
(key: Slot<any>, value: HTMLElement): void;
|
22
|
-
(key: HTMLElement, value: Slot<any>): void;
|
23
|
-
};
|
24
|
-
get: {
|
25
|
-
(key: Slot<any>): HTMLElement;
|
26
|
-
(key: HTMLElement): Slot<any>;
|
27
|
-
};
|
28
|
-
remove: (key: HTMLElement | Slot<any>) => void;
|
29
|
-
};
|
30
|
-
protected slotRootVElementCaches: WeakMap<Slot<any>, VElement>;
|
31
|
-
protected constructor(mount: (host: HTMLElement, viewComponent: ViewComponent) => (void | (() => void)));
|
32
|
-
render(rootComponent: ComponentInstance): void | (() => void);
|
33
|
-
abstract componentRender(component: ComponentInstance): ViewComponent;
|
34
|
-
abstract slotRender(slot: Slot, slotHostRender: (children: Array<VElement | VTextNode | ComponentInstance>) => VElement, renderEnv: any): ViewElement;
|
35
|
-
copy(): void;
|
36
|
-
/**
|
37
|
-
* 根据组件获取组件的根 DOM 节点
|
38
|
-
* @param component
|
39
|
-
*/
|
40
|
-
getNativeNodeByComponent(component: ComponentInstance): HTMLElement | null;
|
41
|
-
/**
|
42
|
-
* 根据 DOM 节点,获对对应的组件根节点,如传入的 DOM 节点不为组件的根节点,则返回 null
|
43
|
-
* @param node
|
44
|
-
*/
|
45
|
-
getComponentByNativeNode(node: HTMLElement): ComponentInstance | null;
|
46
|
-
/**
|
47
|
-
* 根据插槽获取插槽的根 DOM 节点
|
48
|
-
* @param slot
|
49
|
-
*/
|
50
|
-
getNativeNodeBySlot(slot: Slot): HTMLElement | null;
|
51
|
-
/**
|
52
|
-
* 根据 DOM 节点,获对对应的插槽根节点,如传入的 DOM 节点不为插槽的根节点,则返回 null
|
53
|
-
* @param node
|
54
|
-
*/
|
55
|
-
getSlotByNativeNode(node: HTMLElement): Slot | null;
|
56
|
-
/**
|
57
|
-
* 获取插槽内容节点集合
|
58
|
-
* @param slot
|
59
|
-
*/
|
60
|
-
getNodesBySlot(slot: Slot): Node[];
|
61
|
-
/**
|
62
|
-
* 获取原生节点的原始数据在文档中的位置
|
63
|
-
* @param node
|
64
|
-
*/
|
65
|
-
getLocationByNativeNode(node: Node): NodeLocation | null;
|
66
6
|
}
|