@textbus/platform-browser 3.0.0-alpha.22 → 3.0.0-alpha.23

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,40 +1,40 @@
1
- import { Commander, Controller, Keyboard, Scheduler, Selection } from '@textbus/core';
2
- import { Parser } from '../dom-support/parser';
3
- import { Caret } from './caret';
4
- /**
5
- * Textbus PC 端输入实现
6
- */
7
- export declare class Input {
8
- private parser;
9
- private keyboard;
10
- private commander;
11
- private selection;
12
- private controller;
13
- private scheduler;
14
- private caret;
15
- static openExperimentalCompositionInput: boolean;
16
- onReady: Promise<void>;
17
- private container;
18
- private subscription;
19
- private doc;
20
- private textarea;
21
- private isFocus;
22
- private inputFormatterId;
23
- private inputFormatter;
24
- private nativeFocus;
25
- private isSafari;
26
- private isMac;
27
- private isWindows;
28
- private isSougouPinYin;
29
- constructor(parser: Parser, keyboard: Keyboard, commander: Commander, selection: Selection, controller: Controller, scheduler: Scheduler, caret: Caret);
30
- focus(): void;
31
- blur(): void;
32
- destroy(): void;
33
- private init;
34
- private handleDefaultActions;
35
- private handlePaste;
36
- private handleShortcut;
37
- private handleInput;
38
- private experimentalCompositionInput;
39
- private createEditableFrame;
40
- }
1
+ import { Commander, Controller, Keyboard, Scheduler, Selection } from '@textbus/core';
2
+ import { Parser } from '../dom-support/parser';
3
+ import { Caret } from './caret';
4
+ /**
5
+ * Textbus PC 端输入实现
6
+ */
7
+ export declare class Input {
8
+ private parser;
9
+ private keyboard;
10
+ private commander;
11
+ private selection;
12
+ private controller;
13
+ private scheduler;
14
+ private caret;
15
+ static openExperimentalCompositionInput: boolean;
16
+ onReady: Promise<void>;
17
+ private container;
18
+ private subscription;
19
+ private doc;
20
+ private textarea;
21
+ private isFocus;
22
+ private inputFormatterId;
23
+ private inputFormatter;
24
+ private nativeFocus;
25
+ private isSafari;
26
+ private isMac;
27
+ private isWindows;
28
+ private isSougouPinYin;
29
+ constructor(parser: Parser, keyboard: Keyboard, commander: Commander, selection: Selection, controller: Controller, scheduler: Scheduler, caret: Caret);
30
+ focus(): void;
31
+ blur(): void;
32
+ destroy(): void;
33
+ private init;
34
+ private handleDefaultActions;
35
+ private handlePaste;
36
+ private handleShortcut;
37
+ private handleInput;
38
+ private experimentalCompositionInput;
39
+ private createEditableFrame;
40
+ }
@@ -1,77 +1,77 @@
1
- import { Observable } from '@tanbo/stream';
2
- import { Injector } from '@tanbo/di';
3
- import { NativeSelectionBridge, NativeSelectionConnector, Renderer, SelectionPosition, AbstractSelection, RootComponentRef, Controller, Selection } from '@textbus/core';
4
- import { Caret } from './caret';
5
- import { Input } from './input';
6
- /**
7
- * 选区焦点可视位置
8
- */
9
- export interface Rect {
10
- left: number;
11
- top: number;
12
- width: number;
13
- height: number;
14
- }
15
- /**
16
- * Textbus PC 端选区桥接实现
17
- */
18
- export declare class SelectionBridge implements NativeSelectionBridge {
19
- private injector;
20
- caret: Caret;
21
- private controller;
22
- private selection;
23
- private rootComponentRef;
24
- private input;
25
- private renderer;
26
- onSelectionChange: Observable<Range | null>;
27
- nativeSelection: globalThis.Selection;
28
- private selectionMaskElement;
29
- private selectionChangeEvent;
30
- private subs;
31
- private sub;
32
- private connector;
33
- private ignoreSelectionChange;
34
- private changeFromUser;
35
- private docContainer;
36
- private maskContainer;
37
- private cacheCaretPositionTimer;
38
- private oldCaretPosition;
39
- constructor(injector: Injector, caret: Caret, controller: Controller, selection: Selection, rootComponentRef: RootComponentRef, input: Input, renderer: Renderer);
40
- connect(connector: NativeSelectionConnector): void;
41
- disConnect(): void;
42
- getRect(location: SelectionPosition): Rect | null;
43
- restore(abstractSelection: AbstractSelection | null, formLocal: boolean): void;
44
- destroy(): void;
45
- getPositionByRange(abstractSelection: AbstractSelection): {
46
- focus: {
47
- node: Node;
48
- offset: number;
49
- } | null;
50
- anchor: {
51
- node: Node;
52
- offset: number;
53
- } | null;
54
- };
55
- getPreviousLinePositionByCurrent(position: SelectionPosition): SelectionPosition | null;
56
- getNextLinePositionByCurrent(position: SelectionPosition): SelectionPosition | null;
57
- private getLinePosition;
58
- /**
59
- * 获取选区向上移动一行的位置。
60
- * @param currentPosition
61
- * @param startLeft 参考位置。
62
- */
63
- private getPreviousLinePositionByOffset;
64
- /**
65
- * 获取选区向下移动一行的位置。
66
- * @param currentPosition
67
- * @param startLeft 参考位置。
68
- */
69
- private getNextLinePositionByOffset;
70
- private unListen;
71
- private listen;
72
- private syncSelection;
73
- private findSelectedNodeAndOffset;
74
- private getCorrectedPosition;
75
- private findFocusNode;
76
- private findFocusNodeByParent;
77
- }
1
+ import { Observable } from '@tanbo/stream';
2
+ import { Injector } from '@tanbo/di';
3
+ import { NativeSelectionBridge, NativeSelectionConnector, Renderer, SelectionPosition, AbstractSelection, RootComponentRef, Controller, Selection } from '@textbus/core';
4
+ import { Caret } from './caret';
5
+ import { Input } from './input';
6
+ /**
7
+ * 选区焦点可视位置
8
+ */
9
+ export interface Rect {
10
+ left: number;
11
+ top: number;
12
+ width: number;
13
+ height: number;
14
+ }
15
+ /**
16
+ * Textbus PC 端选区桥接实现
17
+ */
18
+ export declare class SelectionBridge implements NativeSelectionBridge {
19
+ private injector;
20
+ caret: Caret;
21
+ private controller;
22
+ private selection;
23
+ private rootComponentRef;
24
+ private input;
25
+ private renderer;
26
+ onSelectionChange: Observable<Range | null>;
27
+ nativeSelection: globalThis.Selection;
28
+ private selectionMaskElement;
29
+ private selectionChangeEvent;
30
+ private subs;
31
+ private sub;
32
+ private connector;
33
+ private ignoreSelectionChange;
34
+ private changeFromUser;
35
+ private docContainer;
36
+ private maskContainer;
37
+ private cacheCaretPositionTimer;
38
+ private oldCaretPosition;
39
+ constructor(injector: Injector, caret: Caret, controller: Controller, selection: Selection, rootComponentRef: RootComponentRef, input: Input, renderer: Renderer);
40
+ connect(connector: NativeSelectionConnector): void;
41
+ disConnect(): void;
42
+ getRect(location: SelectionPosition): Rect | null;
43
+ restore(abstractSelection: AbstractSelection | null, formLocal: boolean): void;
44
+ destroy(): void;
45
+ getPositionByRange(abstractSelection: AbstractSelection): {
46
+ focus: {
47
+ node: Node;
48
+ offset: number;
49
+ } | null;
50
+ anchor: {
51
+ node: Node;
52
+ offset: number;
53
+ } | null;
54
+ };
55
+ getPreviousLinePositionByCurrent(position: SelectionPosition): SelectionPosition | null;
56
+ getNextLinePositionByCurrent(position: SelectionPosition): SelectionPosition | null;
57
+ private getLinePosition;
58
+ /**
59
+ * 获取选区向上移动一行的位置。
60
+ * @param currentPosition
61
+ * @param startLeft 参考位置。
62
+ */
63
+ private getPreviousLinePositionByOffset;
64
+ /**
65
+ * 获取选区向下移动一行的位置。
66
+ * @param currentPosition
67
+ * @param startLeft 参考位置。
68
+ */
69
+ private getNextLinePositionByOffset;
70
+ private unListen;
71
+ private listen;
72
+ private syncSelection;
73
+ private findSelectedNodeAndOffset;
74
+ private getCorrectedPosition;
75
+ private findFocusNode;
76
+ private findFocusNodeByParent;
77
+ }
@@ -1,29 +1,29 @@
1
- import { ComponentLiteral, Module, TextbusConfig } from '@textbus/core';
2
- import { FormatLoader, ComponentLoader, AttributeLoader } from '../dom-support/parser';
3
- export interface ViewModule extends Module {
4
- componentLoaders?: ComponentLoader[];
5
- formatLoaders?: FormatLoader<any>[];
6
- attributeLoaders?: AttributeLoader<any>[];
7
- }
8
- /**
9
- * Textbus PC 端配置接口
10
- */
11
- export interface ViewOptions extends TextbusConfig {
12
- imports?: ViewModule[];
13
- /** 自动获取焦点 */
14
- autoFocus?: boolean;
15
- /** 编辑区最小高度 */
16
- minHeight?: string;
17
- /** 组件加载器 */
18
- componentLoaders?: ComponentLoader[];
19
- /** 格式加载器 */
20
- formatLoaders?: FormatLoader<any>[];
21
- /** 属性加载器 */
22
- attributeLoaders?: AttributeLoader<any>[];
23
- /** 默认内容 */
24
- content?: string | ComponentLiteral;
25
- /** 文档默认样式表 */
26
- styleSheets?: string[];
27
- /** 配置文档编辑状态下用到的样式 */
28
- editingStyleSheets?: string[];
29
- }
1
+ import { ComponentLiteral, Module, TextbusConfig } from '@textbus/core';
2
+ import { FormatLoader, ComponentLoader, AttributeLoader } from '../dom-support/parser';
3
+ export interface ViewModule extends Module {
4
+ componentLoaders?: ComponentLoader[];
5
+ formatLoaders?: FormatLoader<any>[];
6
+ attributeLoaders?: AttributeLoader<any>[];
7
+ }
8
+ /**
9
+ * Textbus PC 端配置接口
10
+ */
11
+ export interface ViewOptions extends TextbusConfig {
12
+ imports?: ViewModule[];
13
+ /** 自动获取焦点 */
14
+ autoFocus?: boolean;
15
+ /** 编辑区最小高度 */
16
+ minHeight?: string;
17
+ /** 组件加载器 */
18
+ componentLoaders?: ComponentLoader[];
19
+ /** 格式加载器 */
20
+ formatLoaders?: FormatLoader<any>[];
21
+ /** 属性加载器 */
22
+ attributeLoaders?: AttributeLoader<any>[];
23
+ /** 默认内容 */
24
+ content?: string | ComponentLiteral;
25
+ /** 文档默认样式表 */
26
+ styleSheets?: string[];
27
+ /** 配置文档编辑状态下用到的样式 */
28
+ editingStyleSheets?: string[];
29
+ }
@@ -1,2 +1,2 @@
1
- export * from './output-translator';
2
- export * from './parser';
1
+ export * from './output-translator';
2
+ export * from './parser';
@@ -1,16 +1,16 @@
1
- import { VElement } from '@textbus/core';
2
- /**
3
- * HTML 输出转换器
4
- */
5
- export declare class OutputTranslator {
6
- static singleTags: string[];
7
- static simpleXSSFilter: {
8
- text(text: string): string;
9
- attrName(text: string): string;
10
- attrValue(text: string): string;
11
- };
12
- private singleTagTest;
13
- transform(vDom: VElement): string;
14
- private vDomToHTMLString;
15
- private replaceEmpty;
16
- }
1
+ import { VElement } from '@textbus/core';
2
+ /**
3
+ * HTML 输出转换器
4
+ */
5
+ export declare class OutputTranslator {
6
+ static singleTags: string[];
7
+ static simpleXSSFilter: {
8
+ text(text: string): string;
9
+ attrName(text: string): string;
10
+ attrValue(text: string): string;
11
+ };
12
+ private singleTagTest;
13
+ transform(vDom: VElement): string;
14
+ private vDomToHTMLString;
15
+ private replaceEmpty;
16
+ }
@@ -1,56 +1,56 @@
1
- import { Injector } from '@tanbo/di';
2
- import { Attribute, ComponentInstance, Formatter, FormatValue, Slot } from '@textbus/core';
3
- import { ViewOptions } from '../core/types';
4
- export interface ComponentResources {
5
- links?: Array<{
6
- [key: string]: string;
7
- }>;
8
- styles?: string[];
9
- scripts?: string[];
10
- editModeStyles?: string[];
11
- }
12
- export interface SlotParser {
13
- <T extends Slot>(childSlot: T, slotRootElement: HTMLElement, slotContentHostElement?: HTMLElement): T;
14
- }
15
- /**
16
- * 组件加载器
17
- */
18
- export interface ComponentLoader {
19
- /** 组件所需要的外部资源 */
20
- resources?: ComponentResources;
21
- /** 识别组件的匹配方法 */
22
- match(element: HTMLElement): boolean;
23
- /** 读取组件内容的方法 */
24
- read(element: HTMLElement, context: Injector, slotParser: SlotParser): ComponentInstance | Slot;
25
- }
26
- export interface FormatLoaderReadResult<T extends FormatValue> {
27
- formatter: Formatter<T>;
28
- value: T;
29
- }
30
- export interface FormatLoader<T extends FormatValue> {
31
- match(element: HTMLElement): boolean;
32
- read(element: HTMLElement): FormatLoaderReadResult<T>;
33
- }
34
- export interface AttributeLoaderReadResult<T extends FormatValue> {
35
- attribute: Attribute<T>;
36
- value: T;
37
- }
38
- export interface AttributeLoader<T extends FormatValue> {
39
- match(element: HTMLElement): boolean;
40
- read(element: HTMLElement): AttributeLoaderReadResult<T>;
41
- }
42
- export declare class Parser {
43
- private options;
44
- private injector;
45
- static parseHTML(html: string): HTMLElement;
46
- componentLoaders: ComponentLoader[];
47
- formatLoaders: FormatLoader<any>[];
48
- attributeLoaders: AttributeLoader<any>[];
49
- constructor(options: ViewOptions, injector: Injector);
50
- parseDoc(html: string, rootComponentLoader: ComponentLoader): Slot<any> | ComponentInstance<import("@textbus/core").ComponentExtends, any, unknown>;
51
- parse(html: string, rootSlot: Slot): Slot<any>;
52
- private readComponent;
53
- private readFormats;
54
- private readSlot;
55
- private applyFormats;
56
- }
1
+ import { Injector } from '@tanbo/di';
2
+ import { Attribute, ComponentInstance, Formatter, FormatValue, Slot } from '@textbus/core';
3
+ import { ViewOptions } from '../core/types';
4
+ export interface ComponentResources {
5
+ links?: Array<{
6
+ [key: string]: string;
7
+ }>;
8
+ styles?: string[];
9
+ scripts?: string[];
10
+ editModeStyles?: string[];
11
+ }
12
+ export interface SlotParser {
13
+ <T extends Slot>(childSlot: T, slotRootElement: HTMLElement, slotContentHostElement?: HTMLElement): T;
14
+ }
15
+ /**
16
+ * 组件加载器
17
+ */
18
+ export interface ComponentLoader {
19
+ /** 组件所需要的外部资源 */
20
+ resources?: ComponentResources;
21
+ /** 识别组件的匹配方法 */
22
+ match(element: HTMLElement): boolean;
23
+ /** 读取组件内容的方法 */
24
+ read(element: HTMLElement, context: Injector, slotParser: SlotParser): ComponentInstance | Slot;
25
+ }
26
+ export interface FormatLoaderReadResult<T extends FormatValue> {
27
+ formatter: Formatter<T>;
28
+ value: T;
29
+ }
30
+ export interface FormatLoader<T extends FormatValue> {
31
+ match(element: HTMLElement): boolean;
32
+ read(element: HTMLElement): FormatLoaderReadResult<T>;
33
+ }
34
+ export interface AttributeLoaderReadResult<T extends FormatValue> {
35
+ attribute: Attribute<T>;
36
+ value: T;
37
+ }
38
+ export interface AttributeLoader<T extends FormatValue> {
39
+ match(element: HTMLElement): boolean;
40
+ read(element: HTMLElement): AttributeLoaderReadResult<T>;
41
+ }
42
+ export declare class Parser {
43
+ private options;
44
+ private injector;
45
+ static parseHTML(html: string): HTMLElement;
46
+ componentLoaders: ComponentLoader[];
47
+ formatLoaders: FormatLoader<any>[];
48
+ attributeLoaders: AttributeLoader<any>[];
49
+ constructor(options: ViewOptions, injector: Injector);
50
+ parseDoc(html: string, rootComponentLoader: ComponentLoader): Slot<any> | ComponentInstance<import("@textbus/core").ComponentExtends, any, unknown>;
51
+ parse(html: string, rootSlot: Slot): Slot<any>;
52
+ private readComponent;
53
+ private readFormats;
54
+ private readSlot;
55
+ private applyFormats;
56
+ }