@textbus/platform-browser 4.0.0-alpha.5 → 4.0.0-alpha.6
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/README.md +0 -114
- package/bundles/collaborate-cursor.d.ts +2 -3
- package/bundles/index.esm.js +20 -20
- package/bundles/index.js +18 -18
- package/bundles/magic-input.d.ts +3 -4
- package/bundles/native-input.d.ts +2 -3
- package/bundles/parser.d.ts +4 -5
- package/bundles/selection-bridge.d.ts +2 -3
- package/package.json +3 -3
package/README.md
CHANGED
@@ -4,120 +4,6 @@ Textbus PC 浏览器支持模块
|
|
4
4
|
Textbus 是一套用于构建富交互的富文本编辑框架。和大多数富文本编辑器不同的是,Textbus 以组件为核心,格式为辅助,并大幅简化了富文本编辑器开发中常见
|
5
5
|
API,且提供了更高的抽象层,使 Textbus 不仅易于上手,同时还能驱动复杂的富文本应用。
|
6
6
|
|
7
|
-
本项目为 Textbus PC 端浏览器中间层实现,提供了 Textbus PC 端所需要的编辑器基本支持能力。如光标、选区桥接、DOM 解析及渲染能力桥接等。
|
8
|
-
|
9
|
-
如果你需要一个开箱即用的编辑器,请参考[官方文档](https://textbus.io)。
|
10
|
-
|
11
|
-
## 安装
|
12
|
-
|
13
|
-
```
|
14
|
-
npm install @textbus/core @textbus/platform-browser
|
15
|
-
```
|
16
|
-
|
17
|
-
## 创建编辑器
|
18
|
-
|
19
|
-
```ts
|
20
|
-
import { Viewer, ViewOptions } from '@textbus/browser'
|
21
|
-
|
22
|
-
import { rootComponent, rootComponentLoader } from './root.component'
|
23
|
-
|
24
|
-
const config: ViewOptions = {
|
25
|
-
// ...配置项
|
26
|
-
}
|
27
|
-
|
28
|
-
const editor = new Viewer(rootComponent, rootComponentLoader, config)
|
29
|
-
```
|
30
|
-
|
31
|
-
其中 `rootComponent`,`rootComponentLoader` 实现请参考[官方文档](https://textbus.io/docs/guide)。
|
32
|
-
|
33
|
-
### 配置项
|
34
|
-
|
35
|
-
配置项接口如下:
|
36
|
-
|
37
|
-
```ts
|
38
|
-
export interface ViewModule extends Module {
|
39
|
-
componentLoaders?: ComponentLoader[]
|
40
|
-
formatLoaders?: FormatLoader[]
|
41
|
-
}
|
42
|
-
|
43
|
-
/**
|
44
|
-
* Textbus PC 端配置接口
|
45
|
-
*/
|
46
|
-
export interface ViewOptions extends TextbusConfig {
|
47
|
-
imports?: ViewModule[]
|
48
|
-
/** 自动获取焦点 */
|
49
|
-
autoFocus?: boolean
|
50
|
-
/** 编辑区最小高度 */
|
51
|
-
minHeight?: string
|
52
|
-
/** 组件加载器 */
|
53
|
-
componentLoaders?: ComponentLoader[]
|
54
|
-
/** 格式加载器 */
|
55
|
-
formatLoaders?: FormatLoader[]
|
56
|
-
/** 默认内容 */
|
57
|
-
content?: string | ComponentLiteral
|
58
|
-
/** 文档默认样式表 */
|
59
|
-
styleSheets?: string[]
|
60
|
-
/** 配置文档编辑状态下用到的样式 */
|
61
|
-
editingStyleSheets?: string[]
|
62
|
-
}
|
63
|
-
```
|
64
|
-
|
65
|
-
### 启动
|
66
|
-
|
67
|
-
```ts
|
68
|
-
const host = document.getElementById('editor')
|
69
|
-
|
70
|
-
editor.mount(host).then(() => {
|
71
|
-
console.log('编辑器创建成功!')
|
72
|
-
})
|
73
|
-
```
|
74
|
-
|
75
|
-
### 销毁编辑器
|
76
|
-
|
77
|
-
```ts
|
78
|
-
editor.destroy()
|
79
|
-
```
|
80
|
-
|
81
|
-
### 获取焦点
|
82
|
-
|
83
|
-
```ts
|
84
|
-
editor.focus()
|
85
|
-
```
|
86
|
-
|
87
|
-
### 取消焦点
|
88
|
-
|
89
|
-
```ts
|
90
|
-
editor.blur()
|
91
|
-
```
|
92
|
-
|
93
|
-
### 获取 HTML 内容
|
94
|
-
|
95
|
-
```ts
|
96
|
-
const content = editor.getContents().content
|
97
|
-
```
|
98
|
-
|
99
|
-
### 获取 JSON 内容
|
100
|
-
|
101
|
-
```ts
|
102
|
-
const json = editor.getJSON().content
|
103
|
-
```
|
104
|
-
|
105
|
-
### 替换内容
|
106
|
-
|
107
|
-
```ts
|
108
|
-
editor.replaceContent('<p>新内容!</p>')
|
109
|
-
|
110
|
-
editor.replaceContent({
|
111
|
-
// 必须为 Textbus 导出的 JSON 格式
|
112
|
-
})
|
113
|
-
```
|
114
|
-
|
115
|
-
### 清空编辑器
|
116
|
-
|
117
|
-
```ts
|
118
|
-
editor.replaceContent('')
|
119
|
-
```
|
120
|
-
|
121
7
|
### 官方文档
|
122
8
|
|
123
9
|
更多文档请参考:[中文文档](https://textbus.io)
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
import { Selection, SelectionPaths, AbstractSelection, Scheduler } from '@textbus/core';
|
1
|
+
import { Selection, SelectionPaths, AbstractSelection, Scheduler, Textbus } from '@textbus/core';
|
3
2
|
import { SelectionBridge } from './selection-bridge';
|
4
3
|
import { Rect } from './_utils/uikit';
|
5
4
|
/**
|
@@ -44,7 +43,7 @@ export declare class CollaborateCursor {
|
|
44
43
|
private subscription;
|
45
44
|
private currentSelection;
|
46
45
|
private container;
|
47
|
-
constructor(
|
46
|
+
constructor(textbus: Textbus, nativeSelection: SelectionBridge, scheduler: Scheduler, selection: Selection, awarenessDelegate?: CollaborateSelectionAwarenessDelegate | undefined);
|
48
47
|
/**
|
49
48
|
* 刷新协作光标,由于 Textbus 只会绘制可视区域的光标,当可视区域发生变化时,需要重新绘制
|
50
49
|
*/
|
package/bundles/index.esm.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import 'reflect-metadata';
|
2
|
-
import { Slot, ViewAdapter, createBidirectionalMapping, ComponentInstance, VElement, VTextNode, Controller, Selection, RootComponentRef, ContentType, Event, invokeListener, Keyboard, Commander, Scheduler, NativeSelectionBridge } from '@textbus/core';
|
3
|
-
import { InjectionToken, Injectable, Inject,
|
2
|
+
import { Slot, Textbus, ViewAdapter, createBidirectionalMapping, ComponentInstance, VElement, VTextNode, Controller, Selection, RootComponentRef, ContentType, Event, invokeListener, Keyboard, Commander, Scheduler, NativeSelectionBridge } from '@textbus/core';
|
3
|
+
import { InjectionToken, Injectable, Inject, Optional } from '@viewfly/core';
|
4
4
|
import { Subject, filter, fromEvent, Subscription, distinctUntilChanged, merge, map, Observable } from '@tanbo/stream';
|
5
5
|
|
6
6
|
function createElement(tagName, options = {}) {
|
@@ -166,9 +166,9 @@ let Parser = Parser_1 = class Parser {
|
|
166
166
|
static parseHTML(html) {
|
167
167
|
return new DOMParser().parseFromString(html, 'text/html').body;
|
168
168
|
}
|
169
|
-
constructor(options,
|
169
|
+
constructor(options, textbus) {
|
170
170
|
this.options = options;
|
171
|
-
this.
|
171
|
+
this.textbus = textbus;
|
172
172
|
const componentLoaders = [
|
173
173
|
...(options.componentLoaders || [])
|
174
174
|
];
|
@@ -193,7 +193,7 @@ let Parser = Parser_1 = class Parser {
|
|
193
193
|
*/
|
194
194
|
parseDoc(html, rootComponentLoader) {
|
195
195
|
const element = typeof html === 'string' ? Parser_1.parseHTML(html) : html;
|
196
|
-
return rootComponentLoader.read(element, this.
|
196
|
+
return rootComponentLoader.read(element, this.textbus, (childSlot, slotRootElement, slotContentHostElement = slotRootElement) => {
|
197
197
|
return this.readSlot(childSlot, slotRootElement, slotContentHostElement);
|
198
198
|
});
|
199
199
|
}
|
@@ -214,7 +214,7 @@ let Parser = Parser_1 = class Parser {
|
|
214
214
|
}
|
215
215
|
for (const t of this.componentLoaders) {
|
216
216
|
if (t.match(el)) {
|
217
|
-
const result = t.read(el, this.
|
217
|
+
const result = t.read(el, this.textbus, (childSlot, slotRootElement, slotContentHostElement = slotRootElement) => {
|
218
218
|
return this.readSlot(childSlot, slotRootElement, slotContentHostElement);
|
219
219
|
});
|
220
220
|
if (!result) {
|
@@ -294,7 +294,7 @@ let Parser = Parser_1 = class Parser {
|
|
294
294
|
Parser = Parser_1 = __decorate([
|
295
295
|
Injectable(),
|
296
296
|
__param(0, Inject(EDITOR_OPTIONS)),
|
297
|
-
__metadata("design:paramtypes", [Object,
|
297
|
+
__metadata("design:paramtypes", [Object, Textbus])
|
298
298
|
], Parser);
|
299
299
|
|
300
300
|
class Input {
|
@@ -449,7 +449,7 @@ class DomAdapter extends ViewAdapter {
|
|
449
449
|
* Textbus PC 端选区桥接实现
|
450
450
|
*/
|
451
451
|
let SelectionBridge = class SelectionBridge {
|
452
|
-
constructor(config,
|
452
|
+
constructor(config, textbus, controller, selection, rootComponentRef, input, domAdapter) {
|
453
453
|
this.config = config;
|
454
454
|
this.selection = selection;
|
455
455
|
this.rootComponentRef = rootComponentRef;
|
@@ -461,7 +461,7 @@ let SelectionBridge = class SelectionBridge {
|
|
461
461
|
this.connector = null;
|
462
462
|
this.ignoreSelectionChange = false;
|
463
463
|
this.changeFromUser = false;
|
464
|
-
this.docContainer =
|
464
|
+
this.docContainer = textbus.get(VIEW_DOCUMENT);
|
465
465
|
this.onSelectionChange = this.selectionChangeEvent.asObservable().pipe(filter(() => {
|
466
466
|
return !controller.readonly;
|
467
467
|
}));
|
@@ -990,7 +990,7 @@ let SelectionBridge = class SelectionBridge {
|
|
990
990
|
SelectionBridge = __decorate([
|
991
991
|
Injectable(),
|
992
992
|
__param(0, Inject(EDITOR_OPTIONS)),
|
993
|
-
__metadata("design:paramtypes", [Object,
|
993
|
+
__metadata("design:paramtypes", [Object, Textbus,
|
994
994
|
Controller,
|
995
995
|
Selection,
|
996
996
|
RootComponentRef,
|
@@ -1246,7 +1246,7 @@ let MagicInput = class MagicInput extends Input {
|
|
1246
1246
|
get disabled() {
|
1247
1247
|
return this._disabled;
|
1248
1248
|
}
|
1249
|
-
constructor(parser, keyboard, commander, selection, controller, scheduler,
|
1249
|
+
constructor(parser, keyboard, commander, selection, controller, scheduler, textbus) {
|
1250
1250
|
super();
|
1251
1251
|
this.parser = parser;
|
1252
1252
|
this.keyboard = keyboard;
|
@@ -1254,10 +1254,10 @@ let MagicInput = class MagicInput extends Input {
|
|
1254
1254
|
this.selection = selection;
|
1255
1255
|
this.controller = controller;
|
1256
1256
|
this.scheduler = scheduler;
|
1257
|
-
this.
|
1257
|
+
this.textbus = textbus;
|
1258
1258
|
this.composition = false;
|
1259
1259
|
this.compositionState = null;
|
1260
|
-
this.caret = new ExperimentalCaret(this.scheduler, this.
|
1260
|
+
this.caret = new ExperimentalCaret(this.scheduler, this.textbus.get(VIEW_MASK));
|
1261
1261
|
this.isSafari = isSafari();
|
1262
1262
|
this.isFirefox = isFirefox();
|
1263
1263
|
this.isMac = isMac();
|
@@ -1555,7 +1555,7 @@ MagicInput = __decorate([
|
|
1555
1555
|
Selection,
|
1556
1556
|
Controller,
|
1557
1557
|
Scheduler,
|
1558
|
-
|
1558
|
+
Textbus])
|
1559
1559
|
], MagicInput);
|
1560
1560
|
|
1561
1561
|
/**
|
@@ -1567,7 +1567,7 @@ class CollaborateSelectionAwarenessDelegate {
|
|
1567
1567
|
* 协作光标绘制类
|
1568
1568
|
*/
|
1569
1569
|
let CollaborateCursor = class CollaborateCursor {
|
1570
|
-
constructor(
|
1570
|
+
constructor(textbus, nativeSelection, scheduler, selection, awarenessDelegate) {
|
1571
1571
|
this.nativeSelection = nativeSelection;
|
1572
1572
|
this.scheduler = scheduler;
|
1573
1573
|
this.selection = selection;
|
@@ -1620,7 +1620,7 @@ let CollaborateCursor = class CollaborateCursor {
|
|
1620
1620
|
this.onRectsChange = new Subject();
|
1621
1621
|
this.subscription = new Subscription();
|
1622
1622
|
this.currentSelection = [];
|
1623
|
-
this.container =
|
1623
|
+
this.container = textbus.get(VIEW_CONTAINER);
|
1624
1624
|
this.canvasContainer.append(this.canvas);
|
1625
1625
|
this.host.append(this.canvasContainer, this.tooltips);
|
1626
1626
|
this.container.prepend(this.host);
|
@@ -1812,7 +1812,7 @@ let CollaborateCursor = class CollaborateCursor {
|
|
1812
1812
|
CollaborateCursor = __decorate([
|
1813
1813
|
Injectable(),
|
1814
1814
|
__param(4, Optional()),
|
1815
|
-
__metadata("design:paramtypes", [
|
1815
|
+
__metadata("design:paramtypes", [Textbus,
|
1816
1816
|
SelectionBridge,
|
1817
1817
|
Scheduler,
|
1818
1818
|
Selection,
|
@@ -1933,7 +1933,7 @@ let NativeInput = class NativeInput extends Input {
|
|
1933
1933
|
get disabled() {
|
1934
1934
|
return this._disabled;
|
1935
1935
|
}
|
1936
|
-
constructor(
|
1936
|
+
constructor(textbus, parser, scheduler, selection, keyboard, domAdapter, commander, controller) {
|
1937
1937
|
super();
|
1938
1938
|
this.parser = parser;
|
1939
1939
|
this.scheduler = scheduler;
|
@@ -1954,7 +1954,7 @@ let NativeInput = class NativeInput extends Input {
|
|
1954
1954
|
this.isMac = isMac();
|
1955
1955
|
this.isMobileBrowser = isMobileBrowser();
|
1956
1956
|
this.ignoreComposition = false; // 有 bug 版本搜狗拼音
|
1957
|
-
this.documentView =
|
1957
|
+
this.documentView = textbus.get(VIEW_DOCUMENT);
|
1958
1958
|
if (!controller.readonly) {
|
1959
1959
|
this.documentView.contentEditable = 'true';
|
1960
1960
|
}
|
@@ -2285,7 +2285,7 @@ let NativeInput = class NativeInput extends Input {
|
|
2285
2285
|
};
|
2286
2286
|
NativeInput = __decorate([
|
2287
2287
|
Injectable(),
|
2288
|
-
__metadata("design:paramtypes", [
|
2288
|
+
__metadata("design:paramtypes", [Textbus,
|
2289
2289
|
Parser,
|
2290
2290
|
Scheduler,
|
2291
2291
|
Selection,
|
package/bundles/index.js
CHANGED
@@ -168,9 +168,9 @@ exports.Parser = Parser_1 = class Parser {
|
|
168
168
|
static parseHTML(html) {
|
169
169
|
return new DOMParser().parseFromString(html, 'text/html').body;
|
170
170
|
}
|
171
|
-
constructor(options,
|
171
|
+
constructor(options, textbus) {
|
172
172
|
this.options = options;
|
173
|
-
this.
|
173
|
+
this.textbus = textbus;
|
174
174
|
const componentLoaders = [
|
175
175
|
...(options.componentLoaders || [])
|
176
176
|
];
|
@@ -195,7 +195,7 @@ exports.Parser = Parser_1 = class Parser {
|
|
195
195
|
*/
|
196
196
|
parseDoc(html, rootComponentLoader) {
|
197
197
|
const element = typeof html === 'string' ? Parser_1.parseHTML(html) : html;
|
198
|
-
return rootComponentLoader.read(element, this.
|
198
|
+
return rootComponentLoader.read(element, this.textbus, (childSlot, slotRootElement, slotContentHostElement = slotRootElement) => {
|
199
199
|
return this.readSlot(childSlot, slotRootElement, slotContentHostElement);
|
200
200
|
});
|
201
201
|
}
|
@@ -216,7 +216,7 @@ exports.Parser = Parser_1 = class Parser {
|
|
216
216
|
}
|
217
217
|
for (const t of this.componentLoaders) {
|
218
218
|
if (t.match(el)) {
|
219
|
-
const result = t.read(el, this.
|
219
|
+
const result = t.read(el, this.textbus, (childSlot, slotRootElement, slotContentHostElement = slotRootElement) => {
|
220
220
|
return this.readSlot(childSlot, slotRootElement, slotContentHostElement);
|
221
221
|
});
|
222
222
|
if (!result) {
|
@@ -296,7 +296,7 @@ exports.Parser = Parser_1 = class Parser {
|
|
296
296
|
exports.Parser = Parser_1 = __decorate([
|
297
297
|
core.Injectable(),
|
298
298
|
__param(0, core.Inject(EDITOR_OPTIONS)),
|
299
|
-
__metadata("design:paramtypes", [Object, core.
|
299
|
+
__metadata("design:paramtypes", [Object, core$1.Textbus])
|
300
300
|
], exports.Parser);
|
301
301
|
|
302
302
|
class Input {
|
@@ -451,7 +451,7 @@ class DomAdapter extends core$1.ViewAdapter {
|
|
451
451
|
* Textbus PC 端选区桥接实现
|
452
452
|
*/
|
453
453
|
exports.SelectionBridge = class SelectionBridge {
|
454
|
-
constructor(config,
|
454
|
+
constructor(config, textbus, controller, selection, rootComponentRef, input, domAdapter) {
|
455
455
|
this.config = config;
|
456
456
|
this.selection = selection;
|
457
457
|
this.rootComponentRef = rootComponentRef;
|
@@ -463,7 +463,7 @@ exports.SelectionBridge = class SelectionBridge {
|
|
463
463
|
this.connector = null;
|
464
464
|
this.ignoreSelectionChange = false;
|
465
465
|
this.changeFromUser = false;
|
466
|
-
this.docContainer =
|
466
|
+
this.docContainer = textbus.get(VIEW_DOCUMENT);
|
467
467
|
this.onSelectionChange = this.selectionChangeEvent.asObservable().pipe(stream.filter(() => {
|
468
468
|
return !controller.readonly;
|
469
469
|
}));
|
@@ -992,7 +992,7 @@ exports.SelectionBridge = class SelectionBridge {
|
|
992
992
|
exports.SelectionBridge = __decorate([
|
993
993
|
core.Injectable(),
|
994
994
|
__param(0, core.Inject(EDITOR_OPTIONS)),
|
995
|
-
__metadata("design:paramtypes", [Object, core.
|
995
|
+
__metadata("design:paramtypes", [Object, core$1.Textbus,
|
996
996
|
core$1.Controller,
|
997
997
|
core$1.Selection,
|
998
998
|
core$1.RootComponentRef,
|
@@ -1248,7 +1248,7 @@ exports.MagicInput = class MagicInput extends Input {
|
|
1248
1248
|
get disabled() {
|
1249
1249
|
return this._disabled;
|
1250
1250
|
}
|
1251
|
-
constructor(parser, keyboard, commander, selection, controller, scheduler,
|
1251
|
+
constructor(parser, keyboard, commander, selection, controller, scheduler, textbus) {
|
1252
1252
|
super();
|
1253
1253
|
this.parser = parser;
|
1254
1254
|
this.keyboard = keyboard;
|
@@ -1256,10 +1256,10 @@ exports.MagicInput = class MagicInput extends Input {
|
|
1256
1256
|
this.selection = selection;
|
1257
1257
|
this.controller = controller;
|
1258
1258
|
this.scheduler = scheduler;
|
1259
|
-
this.
|
1259
|
+
this.textbus = textbus;
|
1260
1260
|
this.composition = false;
|
1261
1261
|
this.compositionState = null;
|
1262
|
-
this.caret = new ExperimentalCaret(this.scheduler, this.
|
1262
|
+
this.caret = new ExperimentalCaret(this.scheduler, this.textbus.get(VIEW_MASK));
|
1263
1263
|
this.isSafari = isSafari();
|
1264
1264
|
this.isFirefox = isFirefox();
|
1265
1265
|
this.isMac = isMac();
|
@@ -1557,7 +1557,7 @@ exports.MagicInput = __decorate([
|
|
1557
1557
|
core$1.Selection,
|
1558
1558
|
core$1.Controller,
|
1559
1559
|
core$1.Scheduler,
|
1560
|
-
core.
|
1560
|
+
core$1.Textbus])
|
1561
1561
|
], exports.MagicInput);
|
1562
1562
|
|
1563
1563
|
/**
|
@@ -1569,7 +1569,7 @@ class CollaborateSelectionAwarenessDelegate {
|
|
1569
1569
|
* 协作光标绘制类
|
1570
1570
|
*/
|
1571
1571
|
exports.CollaborateCursor = class CollaborateCursor {
|
1572
|
-
constructor(
|
1572
|
+
constructor(textbus, nativeSelection, scheduler, selection, awarenessDelegate) {
|
1573
1573
|
this.nativeSelection = nativeSelection;
|
1574
1574
|
this.scheduler = scheduler;
|
1575
1575
|
this.selection = selection;
|
@@ -1622,7 +1622,7 @@ exports.CollaborateCursor = class CollaborateCursor {
|
|
1622
1622
|
this.onRectsChange = new stream.Subject();
|
1623
1623
|
this.subscription = new stream.Subscription();
|
1624
1624
|
this.currentSelection = [];
|
1625
|
-
this.container =
|
1625
|
+
this.container = textbus.get(VIEW_CONTAINER);
|
1626
1626
|
this.canvasContainer.append(this.canvas);
|
1627
1627
|
this.host.append(this.canvasContainer, this.tooltips);
|
1628
1628
|
this.container.prepend(this.host);
|
@@ -1814,7 +1814,7 @@ exports.CollaborateCursor = class CollaborateCursor {
|
|
1814
1814
|
exports.CollaborateCursor = __decorate([
|
1815
1815
|
core.Injectable(),
|
1816
1816
|
__param(4, core.Optional()),
|
1817
|
-
__metadata("design:paramtypes", [core.
|
1817
|
+
__metadata("design:paramtypes", [core$1.Textbus,
|
1818
1818
|
exports.SelectionBridge,
|
1819
1819
|
core$1.Scheduler,
|
1820
1820
|
core$1.Selection,
|
@@ -1935,7 +1935,7 @@ let NativeInput = class NativeInput extends Input {
|
|
1935
1935
|
get disabled() {
|
1936
1936
|
return this._disabled;
|
1937
1937
|
}
|
1938
|
-
constructor(
|
1938
|
+
constructor(textbus, parser, scheduler, selection, keyboard, domAdapter, commander, controller) {
|
1939
1939
|
super();
|
1940
1940
|
this.parser = parser;
|
1941
1941
|
this.scheduler = scheduler;
|
@@ -1956,7 +1956,7 @@ let NativeInput = class NativeInput extends Input {
|
|
1956
1956
|
this.isMac = isMac();
|
1957
1957
|
this.isMobileBrowser = isMobileBrowser();
|
1958
1958
|
this.ignoreComposition = false; // 有 bug 版本搜狗拼音
|
1959
|
-
this.documentView =
|
1959
|
+
this.documentView = textbus.get(VIEW_DOCUMENT);
|
1960
1960
|
if (!controller.readonly) {
|
1961
1961
|
this.documentView.contentEditable = 'true';
|
1962
1962
|
}
|
@@ -2287,7 +2287,7 @@ let NativeInput = class NativeInput extends Input {
|
|
2287
2287
|
};
|
2288
2288
|
NativeInput = __decorate([
|
2289
2289
|
core.Injectable(),
|
2290
|
-
__metadata("design:paramtypes", [core.
|
2290
|
+
__metadata("design:paramtypes", [core$1.Textbus,
|
2291
2291
|
exports.Parser,
|
2292
2292
|
core$1.Scheduler,
|
2293
2293
|
core$1.Selection,
|
package/bundles/magic-input.d.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import { Observable } from '@tanbo/stream';
|
2
|
-
import {
|
3
|
-
import { Commander, Controller, Keyboard, Scheduler, Selection } from '@textbus/core';
|
2
|
+
import { Commander, Controller, Keyboard, Scheduler, Selection, Textbus } from '@textbus/core';
|
4
3
|
import { Parser } from './parser';
|
5
4
|
import { Caret, CaretPosition, CompositionState, Input, Scroller } from './types';
|
6
5
|
interface CaretStyle {
|
@@ -48,7 +47,7 @@ export declare class MagicInput extends Input {
|
|
48
47
|
private selection;
|
49
48
|
private controller;
|
50
49
|
private scheduler;
|
51
|
-
private
|
50
|
+
private textbus;
|
52
51
|
composition: boolean;
|
53
52
|
compositionState: CompositionState | null;
|
54
53
|
onReady: Promise<void>;
|
@@ -67,7 +66,7 @@ export declare class MagicInput extends Input {
|
|
67
66
|
private isFocus;
|
68
67
|
private nativeFocus;
|
69
68
|
private ignoreComposition;
|
70
|
-
constructor(parser: Parser, keyboard: Keyboard, commander: Commander, selection: Selection, controller: Controller, scheduler: Scheduler,
|
69
|
+
constructor(parser: Parser, keyboard: Keyboard, commander: Commander, selection: Selection, controller: Controller, scheduler: Scheduler, textbus: Textbus);
|
71
70
|
focus(range: Range, restart: boolean): void;
|
72
71
|
blur(): void;
|
73
72
|
destroy(): void;
|
@@ -1,6 +1,5 @@
|
|
1
|
-
import { Injector } from '@viewfly/core';
|
2
1
|
import { Observable } from '@tanbo/stream';
|
3
|
-
import { Commander, Controller, Keyboard, Scheduler, Selection } from '@textbus/core';
|
2
|
+
import { Commander, Controller, Keyboard, Scheduler, Selection, Textbus } from '@textbus/core';
|
4
3
|
import { Caret, CaretPosition, CompositionState, Input, Scroller } from './types';
|
5
4
|
import { Parser } from './parser';
|
6
5
|
import { DomAdapter } from './dom-adapter';
|
@@ -42,7 +41,7 @@ export declare class NativeInput extends Input {
|
|
42
41
|
private isMac;
|
43
42
|
private isMobileBrowser;
|
44
43
|
private ignoreComposition;
|
45
|
-
constructor(
|
44
|
+
constructor(textbus: Textbus, parser: Parser, scheduler: Scheduler, selection: Selection, keyboard: Keyboard, domAdapter: DomAdapter<any, any>, commander: Commander, controller: Controller);
|
46
45
|
focus(nativeRange: Range): void;
|
47
46
|
blur(): void;
|
48
47
|
destroy(): void;
|
package/bundles/parser.d.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
import { Attribute, ComponentInstance, Formatter, FormatValue, Slot } from '@textbus/core';
|
1
|
+
import { Attribute, ComponentInstance, Formatter, FormatValue, Slot, Textbus } from '@textbus/core';
|
3
2
|
import { ViewOptions } from './browser-module';
|
4
3
|
/**
|
5
4
|
* 插槽解析器
|
@@ -21,7 +20,7 @@ export interface ComponentLoader {
|
|
21
20
|
/** 识别组件的匹配方法 */
|
22
21
|
match(element: HTMLElement): boolean;
|
23
22
|
/** 读取组件内容的方法 */
|
24
|
-
read(element: HTMLElement,
|
23
|
+
read(element: HTMLElement, textbus: Textbus, slotParser: SlotParser): ComponentInstance | Slot | void;
|
25
24
|
}
|
26
25
|
export interface FormatLoaderReadResult<T extends FormatValue> {
|
27
26
|
formatter: Formatter<T>;
|
@@ -66,12 +65,12 @@ export interface AttributeLoader<T extends FormatValue> {
|
|
66
65
|
*/
|
67
66
|
export declare class Parser {
|
68
67
|
private options;
|
69
|
-
private
|
68
|
+
private textbus;
|
70
69
|
static parseHTML(html: string): HTMLElement;
|
71
70
|
componentLoaders: ComponentLoader[];
|
72
71
|
formatLoaders: FormatLoader<any>[];
|
73
72
|
attributeLoaders: AttributeLoader<any>[];
|
74
|
-
constructor(options: ViewOptions,
|
73
|
+
constructor(options: ViewOptions, textbus: Textbus);
|
75
74
|
/**
|
76
75
|
* 使用指定的组件加载器解析一段 HTML 字符串或 DOM 元素
|
77
76
|
* @param html
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { Observable } from '@tanbo/stream';
|
2
|
-
import {
|
3
|
-
import { NativeSelectionBridge, NativeSelectionConnector, SelectionPosition, AbstractSelection, RootComponentRef, Controller, Selection } from '@textbus/core';
|
2
|
+
import { NativeSelectionBridge, NativeSelectionConnector, SelectionPosition, AbstractSelection, RootComponentRef, Controller, Selection, Textbus } from '@textbus/core';
|
4
3
|
import { Rect } from './_utils/uikit';
|
5
4
|
import { Input } from './types';
|
6
5
|
import { DomAdapter } from './dom-adapter';
|
@@ -25,7 +24,7 @@ export declare class SelectionBridge implements NativeSelectionBridge {
|
|
25
24
|
private docContainer;
|
26
25
|
private cacheCaretPositionTimer;
|
27
26
|
private oldCaretPosition;
|
28
|
-
constructor(config: ViewOptions,
|
27
|
+
constructor(config: ViewOptions, textbus: Textbus, controller: Controller, selection: Selection, rootComponentRef: RootComponentRef, input: Input, domAdapter: DomAdapter<any, any>);
|
29
28
|
connect(connector: NativeSelectionConnector): void;
|
30
29
|
disConnect(): void;
|
31
30
|
getRect(location: SelectionPosition): Rect | null;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@textbus/platform-browser",
|
3
|
-
"version": "4.0.0-alpha.
|
3
|
+
"version": "4.0.0-alpha.6",
|
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.0",
|
29
|
-
"@textbus/core": "^4.0.0-alpha.
|
29
|
+
"@textbus/core": "^4.0.0-alpha.6",
|
30
30
|
"@viewfly/core": "^0.2.4",
|
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": "
|
51
|
+
"gitHead": "47394e77de252fdfd9193e1620177f944976c1a9"
|
52
52
|
}
|