@textbus/platform-browser 4.0.0-alpha.8 → 4.0.1
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
package/bundles/magic-input.d.ts
CHANGED
@@ -1,46 +1,45 @@
|
|
1
1
|
import { Observable } from '@tanbo/stream';
|
2
2
|
import { Commander, Controller, Keyboard, Scheduler, Selection, Textbus } from '@textbus/core';
|
3
3
|
import { Parser } from './parser';
|
4
|
-
import { Caret,
|
4
|
+
import { Caret, CaretLimit, CaretPosition, Input } from './types';
|
5
|
+
import { DomAdapter } from './dom-adapter';
|
5
6
|
interface CaretStyle {
|
6
7
|
height: string;
|
7
8
|
lineHeight: string;
|
8
9
|
fontSize: string;
|
9
10
|
}
|
10
11
|
declare class ExperimentalCaret implements Caret {
|
12
|
+
private domRenderer;
|
11
13
|
private scheduler;
|
12
14
|
private editorMask;
|
13
15
|
onPositionChange: Observable<CaretPosition | null>;
|
14
16
|
onStyleChange: Observable<CaretStyle>;
|
15
17
|
elementRef: HTMLElement;
|
16
|
-
|
18
|
+
changeFromSelf: boolean;
|
19
|
+
getLimit: () => CaretLimit;
|
17
20
|
get rect(): DOMRect;
|
18
|
-
compositionElement: HTMLElement;
|
19
21
|
private timer;
|
20
22
|
private caret;
|
21
|
-
private oldPosition;
|
22
23
|
private set display(value);
|
23
24
|
private get display();
|
24
25
|
private _display;
|
25
26
|
private flashing;
|
26
|
-
private subs;
|
27
27
|
private subscription;
|
28
28
|
private positionChangeEvent;
|
29
29
|
private styleChangeEvent;
|
30
30
|
private oldRange;
|
31
|
-
|
32
|
-
|
33
|
-
refresh(isFixedCaret?: boolean): void;
|
31
|
+
constructor(domRenderer: DomAdapter, scheduler: Scheduler, editorMask: HTMLElement);
|
32
|
+
refresh(): void;
|
34
33
|
show(range: Range, restart: boolean): void;
|
35
34
|
hide(): void;
|
36
35
|
destroy(): void;
|
37
|
-
correctScrollTop(scroller: Scroller): void;
|
38
36
|
private updateCursorPosition;
|
39
37
|
}
|
40
38
|
/**
|
41
39
|
* Textbus PC 端输入实现
|
42
40
|
*/
|
43
41
|
export declare class MagicInput extends Input {
|
42
|
+
private domAdapter;
|
44
43
|
private parser;
|
45
44
|
private keyboard;
|
46
45
|
private commander;
|
@@ -49,7 +48,6 @@ export declare class MagicInput extends Input {
|
|
49
48
|
private scheduler;
|
50
49
|
private textbus;
|
51
50
|
composition: boolean;
|
52
|
-
compositionState: CompositionState | null;
|
53
51
|
onReady: Promise<void>;
|
54
52
|
caret: ExperimentalCaret;
|
55
53
|
set disabled(b: boolean);
|
@@ -66,10 +64,11 @@ export declare class MagicInput extends Input {
|
|
66
64
|
private isFocus;
|
67
65
|
private nativeFocus;
|
68
66
|
private ignoreComposition;
|
69
|
-
constructor(parser: Parser, keyboard: Keyboard, commander: Commander, selection: Selection, controller: Controller, scheduler: Scheduler, textbus: Textbus);
|
67
|
+
constructor(domAdapter: DomAdapter, parser: Parser, keyboard: Keyboard, commander: Commander, selection: Selection, controller: Controller, scheduler: Scheduler, textbus: Textbus);
|
70
68
|
focus(range: Range, restart: boolean): void;
|
71
69
|
blur(): void;
|
72
70
|
destroy(): void;
|
71
|
+
private reInit;
|
73
72
|
private init;
|
74
73
|
private handleDefaultActions;
|
75
74
|
private handlePaste;
|
@@ -1,26 +1,22 @@
|
|
1
1
|
import { Observable } from '@tanbo/stream';
|
2
|
-
import { Commander, Controller, Keyboard,
|
3
|
-
import { Caret, CaretPosition,
|
2
|
+
import { Commander, Controller, Keyboard, Selection, Textbus } from '@textbus/core';
|
3
|
+
import { Caret, CaretPosition, Input } from './types';
|
4
4
|
import { Parser } from './parser';
|
5
5
|
import { DomAdapter } from './dom-adapter';
|
6
6
|
declare class NativeCaret implements Caret {
|
7
|
-
private scheduler;
|
8
7
|
onPositionChange: Observable<CaretPosition | null>;
|
9
8
|
set nativeRange(range: Range | null);
|
10
9
|
get nativeRange(): Range | null;
|
11
10
|
get rect(): import("./_utils/uikit").Rect;
|
12
|
-
private oldPosition;
|
13
11
|
private _nativeRange;
|
14
12
|
private subs;
|
15
13
|
private positionChangeEvent;
|
16
|
-
constructor(
|
14
|
+
constructor();
|
17
15
|
refresh(): void;
|
18
|
-
correctScrollTop(scroller: Scroller): void;
|
19
16
|
destroy(): void;
|
20
17
|
}
|
21
18
|
export declare class NativeInput extends Input {
|
22
19
|
private parser;
|
23
|
-
private scheduler;
|
24
20
|
private selection;
|
25
21
|
private keyboard;
|
26
22
|
private domAdapter;
|
@@ -28,7 +24,6 @@ export declare class NativeInput extends Input {
|
|
28
24
|
private controller;
|
29
25
|
caret: NativeCaret;
|
30
26
|
composition: boolean;
|
31
|
-
compositionState: CompositionState | null;
|
32
27
|
onReady: Promise<void>;
|
33
28
|
set disabled(b: boolean);
|
34
29
|
get disabled(): boolean;
|
@@ -41,7 +36,7 @@ export declare class NativeInput extends Input {
|
|
41
36
|
private isMac;
|
42
37
|
private isMobileBrowser;
|
43
38
|
private ignoreComposition;
|
44
|
-
constructor(textbus: Textbus, parser: Parser,
|
39
|
+
constructor(textbus: Textbus, parser: Parser, selection: Selection, keyboard: Keyboard, domAdapter: DomAdapter, commander: Commander, controller: Controller);
|
45
40
|
focus(nativeRange: Range): void;
|
46
41
|
blur(): void;
|
47
42
|
destroy(): void;
|
package/bundles/parser.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Attribute,
|
1
|
+
import { Attribute, Component, ContentType, Formatter, FormatValue, Slot, Textbus } from '@textbus/core';
|
2
2
|
import { ViewOptions } from './browser-module';
|
3
3
|
/**
|
4
4
|
* 插槽解析器
|
@@ -18,18 +18,18 @@ export interface SlotParser {
|
|
18
18
|
*/
|
19
19
|
export interface ComponentLoader {
|
20
20
|
/** 识别组件的匹配方法 */
|
21
|
-
match(element: HTMLElement): boolean;
|
21
|
+
match(element: HTMLElement, returnableContentTypes: ContentType[]): boolean;
|
22
22
|
/** 读取组件内容的方法 */
|
23
|
-
read(element: HTMLElement, textbus: Textbus, slotParser: SlotParser):
|
23
|
+
read(element: HTMLElement, textbus: Textbus, slotParser: SlotParser): Component | Slot | void;
|
24
24
|
}
|
25
|
-
export interface FormatLoaderReadResult<T
|
25
|
+
export interface FormatLoaderReadResult<T = FormatValue> {
|
26
26
|
formatter: Formatter<T>;
|
27
27
|
value: T;
|
28
28
|
}
|
29
29
|
/**
|
30
30
|
* 格式加载器
|
31
31
|
*/
|
32
|
-
export interface FormatLoader<T
|
32
|
+
export interface FormatLoader<T = FormatValue> {
|
33
33
|
/**
|
34
34
|
* 匹配一个 DOM 节点是否是某个格式节点
|
35
35
|
* @param element
|
@@ -41,14 +41,14 @@ export interface FormatLoader<T extends FormatValue> {
|
|
41
41
|
*/
|
42
42
|
read(element: HTMLElement): FormatLoaderReadResult<T>;
|
43
43
|
}
|
44
|
-
export interface AttributeLoaderReadResult<T
|
44
|
+
export interface AttributeLoaderReadResult<T = FormatValue> {
|
45
45
|
attribute: Attribute<T>;
|
46
46
|
value: T;
|
47
47
|
}
|
48
48
|
/**
|
49
49
|
* 属性加载器
|
50
50
|
*/
|
51
|
-
export interface AttributeLoader<T
|
51
|
+
export interface AttributeLoader<T = FormatValue> {
|
52
52
|
/**
|
53
53
|
* 匹配一个 DOM 节点是否是某个属性节点
|
54
54
|
* @param element
|
@@ -64,7 +64,6 @@ export interface AttributeLoader<T extends FormatValue> {
|
|
64
64
|
* 用于解析 HTML,并把 HTML 内容转换为 Textbus 可以支持的组件或插槽数据
|
65
65
|
*/
|
66
66
|
export declare class Parser {
|
67
|
-
private options;
|
68
67
|
private textbus;
|
69
68
|
static parseHTML(html: string): HTMLElement;
|
70
69
|
componentLoaders: ComponentLoader[];
|
@@ -76,13 +75,13 @@ export declare class Parser {
|
|
76
75
|
* @param html
|
77
76
|
* @param rootComponentLoader
|
78
77
|
*/
|
79
|
-
parseDoc(html: string | HTMLElement, rootComponentLoader: ComponentLoader): void | Slot
|
78
|
+
parseDoc(html: string | HTMLElement, rootComponentLoader: ComponentLoader): void | Slot | Component<import("@textbus/core").State>;
|
80
79
|
/**
|
81
80
|
* 将一段 HTML 或 DOM 元素解析到指定插槽
|
82
81
|
* @param html
|
83
82
|
* @param rootSlot
|
84
83
|
*/
|
85
|
-
parse(html: string | HTMLElement, rootSlot: Slot): Slot
|
84
|
+
parse(html: string | HTMLElement, rootSlot: Slot): Slot;
|
86
85
|
private readComponent;
|
87
86
|
private readText;
|
88
87
|
private readFormats;
|
package/bundles/public-api.d.ts
CHANGED
@@ -6,6 +6,7 @@ export * from './collaborate-cursor';
|
|
6
6
|
export * from './dom-adapter';
|
7
7
|
export * from './injection-tokens';
|
8
8
|
export * from './magic-input';
|
9
|
+
export * from './native-input';
|
9
10
|
export * from './parser';
|
10
11
|
export * from './selection-bridge';
|
11
12
|
export * from './types';
|
@@ -2,8 +2,8 @@ import { Observable } from '@tanbo/stream';
|
|
2
2
|
import { NativeSelectionBridge, NativeSelectionConnector, SelectionPosition, AbstractSelection, RootComponentRef, Controller, Selection, Textbus } from '@textbus/core';
|
3
3
|
import { Rect } from './_utils/uikit';
|
4
4
|
import { Input } from './types';
|
5
|
-
import { DomAdapter } from './dom-adapter';
|
6
5
|
import { ViewOptions } from './browser-module';
|
6
|
+
import { DomAdapter } from './dom-adapter';
|
7
7
|
/**
|
8
8
|
* Textbus PC 端选区桥接实现
|
9
9
|
*/
|
@@ -24,7 +24,7 @@ export declare class SelectionBridge implements NativeSelectionBridge {
|
|
24
24
|
private docContainer;
|
25
25
|
private cacheCaretPositionTimer;
|
26
26
|
private oldCaretPosition;
|
27
|
-
constructor(config: ViewOptions, textbus: Textbus, controller: Controller, selection: Selection, rootComponentRef: RootComponentRef, input: Input, domAdapter: DomAdapter
|
27
|
+
constructor(config: ViewOptions, textbus: Textbus, controller: Controller, selection: Selection, rootComponentRef: RootComponentRef, input: Input, domAdapter: DomAdapter);
|
28
28
|
connect(connector: NativeSelectionConnector): void;
|
29
29
|
disConnect(): void;
|
30
30
|
getRect(location: SelectionPosition): Rect | null;
|
package/bundles/types.d.ts
CHANGED
@@ -1,15 +1,9 @@
|
|
1
|
-
import { Slot } from '@textbus/core';
|
2
1
|
import { Observable } from '@tanbo/stream';
|
3
2
|
import { Rect } from './_utils/uikit';
|
4
3
|
export interface CaretLimit {
|
5
4
|
top: number;
|
6
5
|
bottom: number;
|
7
6
|
}
|
8
|
-
export interface Scroller {
|
9
|
-
onScroll: Observable<any>;
|
10
|
-
getLimit(): CaretLimit;
|
11
|
-
setOffset(offsetScrollTop: number): void;
|
12
|
-
}
|
13
7
|
export interface CaretPosition {
|
14
8
|
left: number;
|
15
9
|
top: number;
|
@@ -18,13 +12,7 @@ export interface CaretPosition {
|
|
18
12
|
export interface Caret {
|
19
13
|
onPositionChange: Observable<CaretPosition | null>;
|
20
14
|
readonly rect: Rect;
|
21
|
-
refresh(
|
22
|
-
correctScrollTop(scroller: Scroller): void;
|
23
|
-
}
|
24
|
-
export interface CompositionState {
|
25
|
-
slot: Slot;
|
26
|
-
index: number;
|
27
|
-
data: string;
|
15
|
+
refresh(): void;
|
28
16
|
}
|
29
17
|
export declare abstract class Input {
|
30
18
|
/**
|
@@ -34,7 +22,6 @@ export declare abstract class Input {
|
|
34
22
|
/**
|
35
23
|
* @experimental
|
36
24
|
*/
|
37
|
-
abstract compositionState: CompositionState | null;
|
38
25
|
abstract onReady: Promise<void>;
|
39
26
|
abstract caret: Caret;
|
40
27
|
abstract disabled: boolean;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@textbus/platform-browser",
|
3
|
-
"version": "4.0.
|
3
|
+
"version": "4.0.1",
|
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",
|
@@ -25,10 +25,10 @@
|
|
25
25
|
"typescript editor"
|
26
26
|
],
|
27
27
|
"dependencies": {
|
28
|
-
"@tanbo/stream": "^1.2.
|
29
|
-
"@textbus/
|
30
|
-
"@
|
31
|
-
"
|
28
|
+
"@tanbo/stream": "^1.2.5",
|
29
|
+
"@textbus/collaborate": "^4.0.1",
|
30
|
+
"@textbus/core": "^4.0.1",
|
31
|
+
"@viewfly/core": "^1.0.0-alpha.22"
|
32
32
|
},
|
33
33
|
"devDependencies": {
|
34
34
|
"@rollup/plugin-commonjs": "^23.0.2",
|
@@ -48,5 +48,5 @@
|
|
48
48
|
"bugs": {
|
49
49
|
"url": "https://github.com/textbus/textbus.git/issues"
|
50
50
|
},
|
51
|
-
"gitHead": "
|
51
|
+
"gitHead": "650431b993553439e58d48949bd9cadda23fb147"
|
52
52
|
}
|