@textbus/platform-browser 3.5.0 → 4.0.0-alpha.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/browser-module.d.ts +33 -0
- package/bundles/{collaborate/collaborate-cursor.d.ts → collaborate-cursor.d.ts} +3 -4
- package/bundles/dom-adapter.d.ts +66 -0
- package/bundles/index.esm.js +682 -1271
- package/bundles/index.js +737 -1325
- package/bundles/{core/injection-tokens.d.ts → injection-tokens.d.ts} +2 -2
- package/bundles/{core/magic-input.d.ts → magic-input.d.ts} +2 -2
- package/bundles/{core/native-input.d.ts → native-input.d.ts} +7 -7
- package/bundles/{dom-support/parser.d.ts → parser.d.ts} +3 -16
- package/bundles/public-api.d.ts +8 -4
- package/bundles/{core/selection-bridge.d.ts → selection-bridge.d.ts} +8 -10
- package/bundles/types.d.ts +44 -0
- package/package.json +4 -4
- package/bundles/core/_api.d.ts +0 -6
- package/bundles/core/dom-renderer.d.ts +0 -53
- package/bundles/core/types.d.ts +0 -74
- package/bundles/dom-support/_api.d.ts +0 -2
- package/bundles/dom-support/output-translator.d.ts +0 -20
- package/bundles/viewer.d.ts +0 -90
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Observable } from '@tanbo/stream';
|
2
|
-
import { Injector } from '@
|
2
|
+
import { Injector } from '@viewfly/core';
|
3
3
|
import { Commander, Controller, Keyboard, Scheduler, Selection } from '@textbus/core';
|
4
|
-
import { Parser } from '
|
4
|
+
import { Parser } from './parser';
|
5
5
|
import { Caret, CaretPosition, CompositionState, Input, Scroller } from './types';
|
6
6
|
interface CaretStyle {
|
7
7
|
height: string;
|
@@ -1,14 +1,15 @@
|
|
1
|
-
import { Injector } from '@
|
1
|
+
import { Injector } from '@viewfly/core';
|
2
2
|
import { Observable } from '@tanbo/stream';
|
3
|
-
import { Commander, Controller, Keyboard,
|
3
|
+
import { Commander, Controller, Keyboard, Scheduler, Selection } from '@textbus/core';
|
4
4
|
import { Caret, CaretPosition, CompositionState, Input, Scroller } from './types';
|
5
|
-
import { Parser } from '
|
5
|
+
import { Parser } from './parser';
|
6
|
+
import { DomAdapter } from './dom-adapter';
|
6
7
|
declare class NativeCaret implements Caret {
|
7
8
|
private scheduler;
|
8
9
|
onPositionChange: Observable<CaretPosition | null>;
|
9
10
|
set nativeRange(range: Range | null);
|
10
11
|
get nativeRange(): Range | null;
|
11
|
-
get rect(): import("
|
12
|
+
get rect(): import("./_utils/uikit").Rect;
|
12
13
|
private oldPosition;
|
13
14
|
private _nativeRange;
|
14
15
|
private subs;
|
@@ -19,12 +20,11 @@ declare class NativeCaret implements Caret {
|
|
19
20
|
destroy(): void;
|
20
21
|
}
|
21
22
|
export declare class NativeInput extends Input {
|
22
|
-
private injector;
|
23
23
|
private parser;
|
24
24
|
private scheduler;
|
25
25
|
private selection;
|
26
26
|
private keyboard;
|
27
|
-
private
|
27
|
+
private domAdapter;
|
28
28
|
private commander;
|
29
29
|
private controller;
|
30
30
|
caret: NativeCaret;
|
@@ -42,7 +42,7 @@ export declare class NativeInput extends Input {
|
|
42
42
|
private isMac;
|
43
43
|
private isMobileBrowser;
|
44
44
|
private ignoreComposition;
|
45
|
-
constructor(injector: Injector, parser: Parser, scheduler: Scheduler, selection: Selection, keyboard: Keyboard,
|
45
|
+
constructor(injector: Injector, parser: Parser, scheduler: Scheduler, selection: Selection, keyboard: Keyboard, domAdapter: DomAdapter<any, any>, commander: Commander, controller: Controller);
|
46
46
|
focus(nativeRange: Range): void;
|
47
47
|
blur(): void;
|
48
48
|
destroy(): void;
|
@@ -1,17 +1,6 @@
|
|
1
|
-
import { Injector } from '@
|
1
|
+
import { Injector } from '@viewfly/core';
|
2
2
|
import { Attribute, ComponentInstance, Formatter, FormatValue, Slot } from '@textbus/core';
|
3
|
-
import { ViewOptions } from '
|
4
|
-
/**
|
5
|
-
* 组件可附加携带的信息,如一些样式表、脚本、或编辑时模式时的样式
|
6
|
-
*/
|
7
|
-
export interface ComponentResources {
|
8
|
-
links?: Array<{
|
9
|
-
[key: string]: string;
|
10
|
-
}>;
|
11
|
-
styles?: string[];
|
12
|
-
scripts?: string[];
|
13
|
-
editModeStyles?: string[];
|
14
|
-
}
|
3
|
+
import { ViewOptions } from './browser-module';
|
15
4
|
/**
|
16
5
|
* 插槽解析器
|
17
6
|
*/
|
@@ -29,8 +18,6 @@ export interface SlotParser {
|
|
29
18
|
* 组件加载器
|
30
19
|
*/
|
31
20
|
export interface ComponentLoader {
|
32
|
-
/** 组件所需要的外部资源 */
|
33
|
-
resources?: ComponentResources;
|
34
21
|
/** 识别组件的匹配方法 */
|
35
22
|
match(element: HTMLElement): boolean;
|
36
23
|
/** 读取组件内容的方法 */
|
@@ -90,7 +77,7 @@ export declare class Parser {
|
|
90
77
|
* @param html
|
91
78
|
* @param rootComponentLoader
|
92
79
|
*/
|
93
|
-
parseDoc(html: string, rootComponentLoader: ComponentLoader): void | Slot<any> | ComponentInstance<
|
80
|
+
parseDoc(html: string, rootComponentLoader: ComponentLoader): void | Slot<any> | ComponentInstance<unknown, unknown, unknown>;
|
94
81
|
/**
|
95
82
|
* 将一段 HTML 解析到指定插槽
|
96
83
|
* @param html
|
package/bundles/public-api.d.ts
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
import 'reflect-metadata';
|
2
2
|
export * from './_utils/uikit';
|
3
3
|
export * from './_utils/env';
|
4
|
-
export * from './
|
5
|
-
export * from './
|
6
|
-
export * from './dom-
|
7
|
-
export * from './
|
4
|
+
export * from './browser-module';
|
5
|
+
export * from './collaborate-cursor';
|
6
|
+
export * from './dom-adapter';
|
7
|
+
export * from './injection-tokens';
|
8
|
+
export * from './magic-input';
|
9
|
+
export * from './parser';
|
10
|
+
export * from './selection-bridge';
|
11
|
+
export * from './types';
|
@@ -1,22 +1,21 @@
|
|
1
1
|
import { Observable } from '@tanbo/stream';
|
2
|
-
import { Injector } from '@
|
3
|
-
import { NativeSelectionBridge, NativeSelectionConnector,
|
4
|
-
import { Rect } from '
|
5
|
-
import { Input
|
2
|
+
import { Injector } from '@viewfly/core';
|
3
|
+
import { NativeSelectionBridge, NativeSelectionConnector, SelectionPosition, AbstractSelection, RootComponentRef, Controller, Selection } from '@textbus/core';
|
4
|
+
import { Rect } from './_utils/uikit';
|
5
|
+
import { Input } from './types';
|
6
|
+
import { DomAdapter } from './dom-adapter';
|
7
|
+
import { ViewOptions } from './browser-module';
|
6
8
|
/**
|
7
9
|
* Textbus PC 端选区桥接实现
|
8
10
|
*/
|
9
11
|
export declare class SelectionBridge implements NativeSelectionBridge {
|
10
12
|
private config;
|
11
|
-
private injector;
|
12
|
-
private controller;
|
13
13
|
private selection;
|
14
14
|
private rootComponentRef;
|
15
15
|
private input;
|
16
|
-
private
|
16
|
+
private domAdapter;
|
17
17
|
onSelectionChange: Observable<Range | null>;
|
18
18
|
nativeSelection: globalThis.Selection;
|
19
|
-
private selectionMaskElement;
|
20
19
|
private selectionChangeEvent;
|
21
20
|
private subs;
|
22
21
|
private sub;
|
@@ -24,10 +23,9 @@ export declare class SelectionBridge implements NativeSelectionBridge {
|
|
24
23
|
private ignoreSelectionChange;
|
25
24
|
private changeFromUser;
|
26
25
|
private docContainer;
|
27
|
-
private maskContainer;
|
28
26
|
private cacheCaretPositionTimer;
|
29
27
|
private oldCaretPosition;
|
30
|
-
constructor(config: ViewOptions, injector: Injector, controller: Controller, selection: Selection, rootComponentRef: RootComponentRef, input: Input,
|
28
|
+
constructor(config: ViewOptions, injector: Injector, controller: Controller, selection: Selection, rootComponentRef: RootComponentRef, input: Input, domAdapter: DomAdapter<any, any>);
|
31
29
|
connect(connector: NativeSelectionConnector): void;
|
32
30
|
disConnect(): void;
|
33
31
|
getRect(location: SelectionPosition): Rect | null;
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { Slot } from '@textbus/core';
|
2
|
+
import { Observable } from '@tanbo/stream';
|
3
|
+
import { Rect } from './_utils/uikit';
|
4
|
+
export interface CaretLimit {
|
5
|
+
top: number;
|
6
|
+
bottom: number;
|
7
|
+
}
|
8
|
+
export interface Scroller {
|
9
|
+
onScroll: Observable<any>;
|
10
|
+
getLimit(): CaretLimit;
|
11
|
+
setOffset(offsetScrollTop: number): void;
|
12
|
+
}
|
13
|
+
export interface CaretPosition {
|
14
|
+
left: number;
|
15
|
+
top: number;
|
16
|
+
height: number;
|
17
|
+
}
|
18
|
+
export interface Caret {
|
19
|
+
onPositionChange: Observable<CaretPosition | null>;
|
20
|
+
readonly rect: Rect;
|
21
|
+
refresh(isFixedCaret: boolean): void;
|
22
|
+
correctScrollTop(scroller: Scroller): void;
|
23
|
+
}
|
24
|
+
export interface CompositionState {
|
25
|
+
slot: Slot;
|
26
|
+
index: number;
|
27
|
+
data: string;
|
28
|
+
}
|
29
|
+
export declare abstract class Input {
|
30
|
+
/**
|
31
|
+
* @experimental
|
32
|
+
*/
|
33
|
+
abstract composition: boolean;
|
34
|
+
/**
|
35
|
+
* @experimental
|
36
|
+
*/
|
37
|
+
abstract compositionState: CompositionState | null;
|
38
|
+
abstract onReady: Promise<void>;
|
39
|
+
abstract caret: Caret;
|
40
|
+
abstract disabled: boolean;
|
41
|
+
abstract focus(nativeRange: Range, reFlash: boolean): void;
|
42
|
+
abstract blur(): void;
|
43
|
+
abstract destroy(): void;
|
44
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@textbus/platform-browser",
|
3
|
-
"version": "
|
3
|
+
"version": "4.0.0-alpha.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,9 +25,9 @@
|
|
25
25
|
"typescript editor"
|
26
26
|
],
|
27
27
|
"dependencies": {
|
28
|
-
"@tanbo/di": "^1.1.5",
|
29
28
|
"@tanbo/stream": "^1.2.0",
|
30
|
-
"@textbus/core": "^
|
29
|
+
"@textbus/core": "^4.0.0-alpha.1",
|
30
|
+
"@viewfly/core": "^0.2.0",
|
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": "
|
51
|
+
"gitHead": "c66a476c5776f8cf719ebb0f9e7adebb391f82c1"
|
52
52
|
}
|
package/bundles/core/_api.d.ts
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
import { NativeNode, NativeRenderer } from '@textbus/core';
|
2
|
-
/**
|
3
|
-
* Textbus PC 端浏览器渲染能力实现
|
4
|
-
*/
|
5
|
-
export declare class DomRenderer implements NativeRenderer {
|
6
|
-
isSVG: RegExp;
|
7
|
-
xlinkNameSpace: string;
|
8
|
-
possibleXlinkNames: {
|
9
|
-
xlinkActuate: string;
|
10
|
-
xlinkactuate: string;
|
11
|
-
'xlink:actuate': string;
|
12
|
-
xlinkArcrole: string;
|
13
|
-
xlinkarcrole: string;
|
14
|
-
'xlink:arcrole': string;
|
15
|
-
xlinkHref: string;
|
16
|
-
xlinkhref: string;
|
17
|
-
'xlink:href': string;
|
18
|
-
xlinkRole: string;
|
19
|
-
xlinkrole: string;
|
20
|
-
'xlink:role': string;
|
21
|
-
xlinkShow: string;
|
22
|
-
xlinkshow: string;
|
23
|
-
'xlink:show': string;
|
24
|
-
xlinkTitle: string;
|
25
|
-
xlinktitle: string;
|
26
|
-
'xlink:title': string;
|
27
|
-
xlinkType: string;
|
28
|
-
xlinktype: string;
|
29
|
-
'xlink:type': string;
|
30
|
-
};
|
31
|
-
booleanProps: Record<string, string[]>;
|
32
|
-
valueProps: Record<string, string[]>;
|
33
|
-
listen<T = any>(node: NativeNode, type: string, callback: (ev: T) => any): void;
|
34
|
-
unListen(node: NativeNode, type: string, callback: (ev: any) => any): void;
|
35
|
-
createTextNode(textContent: string): NativeNode;
|
36
|
-
createElement(name: string): NativeNode;
|
37
|
-
appendChild(parent: NativeNode, newChild: NativeNode): void;
|
38
|
-
remove(node: NativeNode): void;
|
39
|
-
insertBefore(newNode: NativeNode, ref: NativeNode): void;
|
40
|
-
getChildByIndex(parent: NativeNode, index: number): NativeNode | null;
|
41
|
-
addClass(target: NativeNode, name: string): void;
|
42
|
-
removeClass(target: NativeNode, name: string): void;
|
43
|
-
setStyle(target: NativeNode, key: string, value: any): void;
|
44
|
-
syncTextContent(target: NativeNode, content: string): void;
|
45
|
-
removeStyle(target: NativeNode, key: string): void;
|
46
|
-
setAttribute(target: NativeNode, key: string, value: string): void;
|
47
|
-
removeAttribute(target: NativeNode, key: string): void;
|
48
|
-
setXlinkAttribute(target: NativeNode, key: string, value: string): void;
|
49
|
-
removeXlinkAttribute(target: NativeNode, key: string): void;
|
50
|
-
replace(newChild: NativeNode, oldChild: NativeNode): void;
|
51
|
-
copy(): void;
|
52
|
-
static replaceEmpty(s: string): string;
|
53
|
-
}
|
package/bundles/core/types.d.ts
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
import { ComponentLiteral, Module, Slot, TextbusConfig } from '@textbus/core';
|
2
|
-
import { Observable } from '@tanbo/stream';
|
3
|
-
import { FormatLoader, ComponentLoader, AttributeLoader } from '../dom-support/parser';
|
4
|
-
import { Rect } from '../_utils/uikit';
|
5
|
-
export interface ViewModule extends Module {
|
6
|
-
componentLoaders?: ComponentLoader[];
|
7
|
-
formatLoaders?: FormatLoader<any>[];
|
8
|
-
attributeLoaders?: AttributeLoader<any>[];
|
9
|
-
}
|
10
|
-
/**
|
11
|
-
* Textbus PC 端配置接口
|
12
|
-
*/
|
13
|
-
export interface ViewOptions extends TextbusConfig {
|
14
|
-
imports?: ViewModule[];
|
15
|
-
/** 自动获取焦点 */
|
16
|
-
autoFocus?: boolean;
|
17
|
-
/** 编辑区最小高度 */
|
18
|
-
minHeight?: string;
|
19
|
-
/** 组件加载器 */
|
20
|
-
componentLoaders?: ComponentLoader[];
|
21
|
-
/** 格式加载器 */
|
22
|
-
formatLoaders?: FormatLoader<any>[];
|
23
|
-
/** 属性加载器 */
|
24
|
-
attributeLoaders?: AttributeLoader<any>[];
|
25
|
-
/** 默认内容 */
|
26
|
-
content?: string | ComponentLiteral;
|
27
|
-
/** 文档默认样式表 */
|
28
|
-
styleSheets?: string[];
|
29
|
-
/** 配置文档编辑状态下用到的样式 */
|
30
|
-
editingStyleSheets?: string[];
|
31
|
-
/** 使用 contentEditable 作为编辑器控制可编辑范围 */
|
32
|
-
useContentEditable?: boolean;
|
33
|
-
}
|
34
|
-
export interface CaretLimit {
|
35
|
-
top: number;
|
36
|
-
bottom: number;
|
37
|
-
}
|
38
|
-
export interface Scroller {
|
39
|
-
onScroll: Observable<any>;
|
40
|
-
getLimit(): CaretLimit;
|
41
|
-
setOffset(offsetScrollTop: number): void;
|
42
|
-
}
|
43
|
-
export interface CaretPosition {
|
44
|
-
left: number;
|
45
|
-
top: number;
|
46
|
-
height: number;
|
47
|
-
}
|
48
|
-
export interface Caret {
|
49
|
-
onPositionChange: Observable<CaretPosition | null>;
|
50
|
-
readonly rect: Rect;
|
51
|
-
refresh(isFixedCaret: boolean): void;
|
52
|
-
correctScrollTop(scroller: Scroller): void;
|
53
|
-
}
|
54
|
-
export interface CompositionState {
|
55
|
-
slot: Slot;
|
56
|
-
index: number;
|
57
|
-
data: string;
|
58
|
-
}
|
59
|
-
export declare abstract class Input {
|
60
|
-
/**
|
61
|
-
* @experimental
|
62
|
-
*/
|
63
|
-
abstract composition: boolean;
|
64
|
-
/**
|
65
|
-
* @experimental
|
66
|
-
*/
|
67
|
-
abstract compositionState: CompositionState | null;
|
68
|
-
abstract onReady: Promise<void>;
|
69
|
-
abstract caret: Caret;
|
70
|
-
abstract disabled: boolean;
|
71
|
-
abstract focus(nativeRange: Range, reFlash: boolean): void;
|
72
|
-
abstract blur(): void;
|
73
|
-
abstract destroy(): void;
|
74
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import { VElement } from '@textbus/core';
|
2
|
-
/**
|
3
|
-
* HTML 输出转换器,用于将虚拟 DOM 转换为 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
|
-
/**
|
14
|
-
* 将虚拟 DOM 转换为 HTML 字符串的方法
|
15
|
-
* @param vDom 虚拟 DOM 节点
|
16
|
-
*/
|
17
|
-
transform(vDom: VElement): string;
|
18
|
-
private vDomToHTMLString;
|
19
|
-
private replaceEmpty;
|
20
|
-
}
|
package/bundles/viewer.d.ts
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
import { Observable, Subject, Subscription } from '@tanbo/stream';
|
2
|
-
import { Starter, ComponentLiteral, Component } from '@textbus/core';
|
3
|
-
import { ComponentLoader } from './dom-support/_api';
|
4
|
-
import { ViewOptions } from './core/_api';
|
5
|
-
export interface Resources {
|
6
|
-
styleSheets: string[];
|
7
|
-
styleSheet: string;
|
8
|
-
links: Record<string, string>[];
|
9
|
-
scripts: string[];
|
10
|
-
}
|
11
|
-
/**
|
12
|
-
* Textbus PC 端编辑器
|
13
|
-
*/
|
14
|
-
export declare class Viewer extends Starter {
|
15
|
-
rootComponent: Component;
|
16
|
-
rootComponentLoader: ComponentLoader;
|
17
|
-
options: ViewOptions;
|
18
|
-
/** 当视图获得焦点时触发 */
|
19
|
-
onFocus: Observable<void>;
|
20
|
-
/** 当视图失去焦点时触发 */
|
21
|
-
onBlur: Observable<void>;
|
22
|
-
/** 当编辑器内容变化时触发 */
|
23
|
-
onChange: Observable<void>;
|
24
|
-
/** 当用户按 Ctrl + S 时触发 */
|
25
|
-
onSave: Observable<void>;
|
26
|
-
/** 编辑器是否已销毁 */
|
27
|
-
destroyed: boolean;
|
28
|
-
/** 编辑器是否已准备好 */
|
29
|
-
isReady: boolean;
|
30
|
-
get readonly(): boolean;
|
31
|
-
set readonly(b: boolean);
|
32
|
-
isFocus(): boolean;
|
33
|
-
protected changeEvent: Subject<void>;
|
34
|
-
protected subs: Subscription[];
|
35
|
-
protected _isFocus: boolean;
|
36
|
-
private controller;
|
37
|
-
private workbench;
|
38
|
-
private id;
|
39
|
-
private resourceNodes;
|
40
|
-
private focusEvent;
|
41
|
-
private blurEvent;
|
42
|
-
private saveEvent;
|
43
|
-
private styleSheet;
|
44
|
-
private scripts;
|
45
|
-
private links;
|
46
|
-
constructor(rootComponent: Component, rootComponentLoader: ComponentLoader, options?: ViewOptions);
|
47
|
-
/**
|
48
|
-
* 初始化编辑器
|
49
|
-
* @param host 编辑器容器
|
50
|
-
*/
|
51
|
-
mount(host: HTMLElement): Promise<this>;
|
52
|
-
/**
|
53
|
-
* 获取焦点
|
54
|
-
*/
|
55
|
-
focus(): void;
|
56
|
-
/**
|
57
|
-
* 取消编辑器焦点
|
58
|
-
*/
|
59
|
-
blur(): void;
|
60
|
-
/**
|
61
|
-
* 获取编辑器所有资源
|
62
|
-
*/
|
63
|
-
getResources(): Resources;
|
64
|
-
/**
|
65
|
-
* 获取 HTML 格式的内容
|
66
|
-
*/
|
67
|
-
getHTML(): string;
|
68
|
-
/**
|
69
|
-
* 获取 JSON 格式的内容
|
70
|
-
*/
|
71
|
-
getJSON(): ComponentLiteral;
|
72
|
-
/**
|
73
|
-
* 清空内容
|
74
|
-
*/
|
75
|
-
clear(): void;
|
76
|
-
/**
|
77
|
-
* 销毁编辑器
|
78
|
-
*/
|
79
|
-
destroy(): void;
|
80
|
-
/**
|
81
|
-
* 替换编辑的内容
|
82
|
-
* @param content
|
83
|
-
*/
|
84
|
-
replaceContent(content: string | ComponentLiteral): void;
|
85
|
-
protected guardReady(): void;
|
86
|
-
private initDefaultShortcut;
|
87
|
-
private initDocStyleSheetsAndScripts;
|
88
|
-
private static createLayout;
|
89
|
-
private static cssMin;
|
90
|
-
}
|