@textbus/platform-browser 4.0.0-alpha.5 → 4.0.0-alpha.7

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 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 { Injector } from '@viewfly/core';
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(injector: Injector, nativeSelection: SelectionBridge, scheduler: Scheduler, selection: Selection, awarenessDelegate?: CollaborateSelectionAwarenessDelegate | undefined);
46
+ constructor(textbus: Textbus, nativeSelection: SelectionBridge, scheduler: Scheduler, selection: Selection, awarenessDelegate?: CollaborateSelectionAwarenessDelegate | undefined);
48
47
  /**
49
48
  * 刷新协作光标,由于 Textbus 只会绘制可视区域的光标,当可视区域发生变化时,需要重新绘制
50
49
  */
@@ -1,7 +1,7 @@
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, Injector, Optional } from '@viewfly/core';
2
+ import { Slot, Textbus, ViewAdapter, createBidirectionalMapping, ComponentInstance, VElement, VTextNode, Controller, Selection, RootComponentRef, ContentType, Event, invokeListener, Keyboard, Commander, Scheduler, NativeSelectionBridge, FocusManager } from '@textbus/core';
4
3
  import { Subject, filter, fromEvent, Subscription, distinctUntilChanged, merge, map, Observable } from '@tanbo/stream';
4
+ import { InjectionToken, Injectable, Inject, Optional } from '@viewfly/core';
5
5
 
6
6
  function createElement(tagName, options = {}) {
7
7
  const el = document.createElement(tagName);
@@ -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, injector) {
169
+ constructor(options, textbus) {
170
170
  this.options = options;
171
- this.injector = injector;
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.injector, (childSlot, slotRootElement, slotContentHostElement = slotRootElement) => {
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.injector, (childSlot, slotRootElement, slotContentHostElement = slotRootElement) => {
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, Injector])
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, injector, controller, selection, rootComponentRef, input, domAdapter) {
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 = injector.get(VIEW_DOCUMENT);
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, Injector,
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, injector) {
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.injector = injector;
1257
+ this.textbus = textbus;
1258
1258
  this.composition = false;
1259
1259
  this.compositionState = null;
1260
- this.caret = new ExperimentalCaret(this.scheduler, this.injector.get(VIEW_MASK));
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
- Injector])
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(injector, nativeSelection, scheduler, selection, awarenessDelegate) {
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 = injector.get(VIEW_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", [Injector,
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(injector, parser, scheduler, selection, keyboard, domAdapter, commander, controller) {
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 = injector.get(VIEW_DOCUMENT);
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", [Injector,
2288
+ __metadata("design:paramtypes", [Textbus,
2289
2289
  Parser,
2290
2290
  Scheduler,
2291
2291
  Selection,
@@ -2331,11 +2331,29 @@ class BrowserModule {
2331
2331
  }, {
2332
2332
  provide: DomAdapter,
2333
2333
  useValue: config.adapter
2334
+ }, {
2335
+ provide: FocusManager,
2336
+ useFactory: (input) => {
2337
+ const focusEvent = new Subject();
2338
+ const blurEvent = new Subject();
2339
+ input.caret.onPositionChange.pipe(map(p => !!p), distinctUntilChanged()).subscribe(b => {
2340
+ if (b) {
2341
+ focusEvent.next();
2342
+ }
2343
+ else {
2344
+ blurEvent.next();
2345
+ }
2346
+ });
2347
+ return {
2348
+ onFocus: focusEvent,
2349
+ onBlur: blurEvent
2350
+ };
2351
+ },
2352
+ deps: [Input]
2334
2353
  },
2335
2354
  Parser,
2336
2355
  SelectionBridge,
2337
- CollaborateCursor
2338
- ];
2356
+ CollaborateCursor];
2339
2357
  this.workbench = wrapper;
2340
2358
  this.host.append(wrapper);
2341
2359
  }
package/bundles/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  require('reflect-metadata');
4
4
  var core$1 = require('@textbus/core');
5
- var core = require('@viewfly/core');
6
5
  var stream = require('@tanbo/stream');
6
+ var core = require('@viewfly/core');
7
7
 
8
8
  function createElement(tagName, options = {}) {
9
9
  const el = document.createElement(tagName);
@@ -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, injector) {
171
+ constructor(options, textbus) {
172
172
  this.options = options;
173
- this.injector = injector;
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.injector, (childSlot, slotRootElement, slotContentHostElement = slotRootElement) => {
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.injector, (childSlot, slotRootElement, slotContentHostElement = slotRootElement) => {
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.Injector])
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, injector, controller, selection, rootComponentRef, input, domAdapter) {
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 = injector.get(VIEW_DOCUMENT);
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.Injector,
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, injector) {
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.injector = injector;
1259
+ this.textbus = textbus;
1260
1260
  this.composition = false;
1261
1261
  this.compositionState = null;
1262
- this.caret = new ExperimentalCaret(this.scheduler, this.injector.get(VIEW_MASK));
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.Injector])
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(injector, nativeSelection, scheduler, selection, awarenessDelegate) {
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 = injector.get(VIEW_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.Injector,
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(injector, parser, scheduler, selection, keyboard, domAdapter, commander, controller) {
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 = injector.get(VIEW_DOCUMENT);
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.Injector,
2290
+ __metadata("design:paramtypes", [core$1.Textbus,
2291
2291
  exports.Parser,
2292
2292
  core$1.Scheduler,
2293
2293
  core$1.Selection,
@@ -2333,11 +2333,29 @@ class BrowserModule {
2333
2333
  }, {
2334
2334
  provide: DomAdapter,
2335
2335
  useValue: config.adapter
2336
+ }, {
2337
+ provide: core$1.FocusManager,
2338
+ useFactory: (input) => {
2339
+ const focusEvent = new stream.Subject();
2340
+ const blurEvent = new stream.Subject();
2341
+ input.caret.onPositionChange.pipe(stream.map(p => !!p), stream.distinctUntilChanged()).subscribe(b => {
2342
+ if (b) {
2343
+ focusEvent.next();
2344
+ }
2345
+ else {
2346
+ blurEvent.next();
2347
+ }
2348
+ });
2349
+ return {
2350
+ onFocus: focusEvent,
2351
+ onBlur: blurEvent
2352
+ };
2353
+ },
2354
+ deps: [Input]
2336
2355
  },
2337
2356
  exports.Parser,
2338
2357
  exports.SelectionBridge,
2339
- exports.CollaborateCursor
2340
- ];
2358
+ exports.CollaborateCursor];
2341
2359
  this.workbench = wrapper;
2342
2360
  this.host.append(wrapper);
2343
2361
  }
@@ -1,6 +1,5 @@
1
1
  import { Observable } from '@tanbo/stream';
2
- import { Injector } from '@viewfly/core';
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 injector;
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, injector: Injector);
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(injector: Injector, parser: Parser, scheduler: Scheduler, selection: Selection, keyboard: Keyboard, domAdapter: DomAdapter<any, any>, commander: Commander, controller: Controller);
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;
@@ -1,5 +1,4 @@
1
- import { Injector } from '@viewfly/core';
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, injector: Injector, slotParser: SlotParser): ComponentInstance | Slot | void;
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 injector;
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, injector: Injector);
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 { Injector } from '@viewfly/core';
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, injector: Injector, controller: Controller, selection: Selection, rootComponentRef: RootComponentRef, input: Input, domAdapter: DomAdapter<any, any>);
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.5",
3
+ "version": "4.0.0-alpha.7",
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.5",
29
+ "@textbus/core": "^4.0.0-alpha.7",
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": "072831527fe07e7c21a14f3141d55b24d321a690"
51
+ "gitHead": "b2f485e1177b20e88d302933760e741118ff8765"
52
52
  }