@textbus/platform-browser 4.0.0-alpha.11 → 4.0.0-alpha.13
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 +16 -3
- package/bundles/dom-adapter.d.ts +3 -3
- package/bundles/index.esm.js +33 -3
- package/bundles/index.js +32 -2
- package/package.json +3 -3
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ComponentLiteral, Module } from '@textbus/core';
|
1
|
+
import { Component, ComponentInstance, ComponentLiteral, Module, Textbus } from '@textbus/core';
|
2
2
|
import { Provider } from '@viewfly/core';
|
3
3
|
import { AttributeLoader, ComponentLoader, FormatLoader } from './parser';
|
4
4
|
import { DomAdapter } from './dom-adapter';
|
@@ -17,8 +17,6 @@ export interface ViewOptions {
|
|
17
17
|
formatLoaders?: FormatLoader<any>[];
|
18
18
|
/** 属性加载器 */
|
19
19
|
attributeLoaders?: AttributeLoader<any>[];
|
20
|
-
/** 默认内容 */
|
21
|
-
content?: string | ComponentLiteral;
|
22
20
|
/** 使用 contentEditable 作为编辑器控制可编辑范围 */
|
23
21
|
useContentEditable?: boolean;
|
24
22
|
}
|
@@ -28,6 +26,21 @@ export declare class BrowserModule implements Module {
|
|
28
26
|
providers: Provider[];
|
29
27
|
private workbench;
|
30
28
|
constructor(host: HTMLElement, config: ViewOptions);
|
29
|
+
/**
|
30
|
+
* 解析 HTML 并返回一个组件实例
|
31
|
+
* @param html 要解析的 HTML
|
32
|
+
* @param rootComponentLoader 文档根组件加载器
|
33
|
+
* @param textbus
|
34
|
+
*/
|
35
|
+
readDocumentByHTML(html: string, rootComponentLoader: ComponentLoader, textbus: Textbus): ComponentInstance;
|
36
|
+
/**
|
37
|
+
* 将组件数据解析到组件实例中
|
38
|
+
* @param data 要解析的 JSON 数据
|
39
|
+
* @param rootComponent 根组件
|
40
|
+
* @param textbus
|
41
|
+
*/
|
42
|
+
readDocumentByComponentLiteral(data: ComponentLiteral, rootComponent: Component, textbus: Textbus): ComponentInstance;
|
43
|
+
onAfterStartup(textbus: Textbus): void;
|
31
44
|
onDestroy(): void;
|
32
45
|
private static createLayout;
|
33
46
|
}
|
package/bundles/dom-adapter.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ComponentInstance, Slot, ViewAdapter, NodeLocation, VElement, VTextNode } from '@textbus/core';
|
1
|
+
import { ComponentInstance, Slot, ViewAdapter, NodeLocation, VElement, VTextNode, Textbus } from '@textbus/core';
|
2
2
|
/**
|
3
3
|
* Textbus PC 端浏览器渲染能力桥接器抽象类,提供了 DOM 元素查询能力,具体渲染能力由各前端框架实现相应桥接
|
4
4
|
*/
|
@@ -28,8 +28,8 @@ export declare abstract class DomAdapter<ViewComponent, ViewElement> extends Vie
|
|
28
28
|
remove: (key: HTMLElement | Slot<any>) => void;
|
29
29
|
};
|
30
30
|
protected slotRootVElementCaches: WeakMap<Slot<any>, VElement>;
|
31
|
-
protected constructor(mount: (host: HTMLElement, viewComponent: ViewComponent) => (void | (() => void)));
|
32
|
-
render(rootComponent: ComponentInstance): void | (() => void);
|
31
|
+
protected constructor(mount: (host: HTMLElement, viewComponent: ViewComponent, textbus: Textbus) => (void | (() => void)));
|
32
|
+
render(rootComponent: ComponentInstance, textbus: Textbus): void | (() => void);
|
33
33
|
abstract componentRender(component: ComponentInstance): ViewComponent;
|
34
34
|
abstract slotRender(slot: Slot, slotHostRender: (children: Array<VElement | VTextNode | ComponentInstance>) => VElement, renderEnv: any): ViewElement;
|
35
35
|
copy(): void;
|
package/bundles/index.esm.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import 'reflect-metadata';
|
2
|
-
import { Slot, Textbus, ViewAdapter, createBidirectionalMapping, ComponentInstance, VElement, VTextNode, Controller, Selection, RootComponentRef, ContentType, Event, invokeListener, Keyboard, Commander, Scheduler, NativeSelectionBridge, FocusManager } from '@textbus/core';
|
2
|
+
import { Slot, Textbus, ViewAdapter, createBidirectionalMapping, ComponentInstance, VElement, VTextNode, Controller, Selection, RootComponentRef, ContentType, Event, invokeListener, Keyboard, Commander, Scheduler, makeError, NativeSelectionBridge, FocusManager, Registry } from '@textbus/core';
|
3
3
|
import { Subject, filter, fromEvent, Subscription, distinctUntilChanged, merge, map, Observable } from '@tanbo/stream';
|
4
4
|
import { InjectionToken, Injectable, Inject, Optional } from '@viewfly/core';
|
5
5
|
|
@@ -330,9 +330,9 @@ class DomAdapter extends ViewAdapter {
|
|
330
330
|
});
|
331
331
|
this.slotRootVElementCaches = new WeakMap();
|
332
332
|
}
|
333
|
-
render(rootComponent) {
|
333
|
+
render(rootComponent, textbus) {
|
334
334
|
const view = this.componentRender(rootComponent);
|
335
|
-
return this.mount(this.host, view);
|
335
|
+
return this.mount(this.host, view, textbus);
|
336
336
|
}
|
337
337
|
copy() {
|
338
338
|
document.execCommand('copy');
|
@@ -2295,6 +2295,7 @@ NativeInput = __decorate([
|
|
2295
2295
|
Controller])
|
2296
2296
|
], NativeInput);
|
2297
2297
|
|
2298
|
+
const browserErrorFn = makeError('BrowserModule');
|
2298
2299
|
class BrowserModule {
|
2299
2300
|
constructor(host, config) {
|
2300
2301
|
this.host = host;
|
@@ -2357,6 +2358,35 @@ class BrowserModule {
|
|
2357
2358
|
this.workbench = wrapper;
|
2358
2359
|
this.host.append(wrapper);
|
2359
2360
|
}
|
2361
|
+
/**
|
2362
|
+
* 解析 HTML 并返回一个组件实例
|
2363
|
+
* @param html 要解析的 HTML
|
2364
|
+
* @param rootComponentLoader 文档根组件加载器
|
2365
|
+
* @param textbus
|
2366
|
+
*/
|
2367
|
+
readDocumentByHTML(html, rootComponentLoader, textbus) {
|
2368
|
+
const parser = textbus.get(Parser);
|
2369
|
+
const doc = parser.parseDoc(html, rootComponentLoader);
|
2370
|
+
if (doc instanceof ComponentInstance) {
|
2371
|
+
return doc;
|
2372
|
+
}
|
2373
|
+
throw browserErrorFn('rootComponentLoader must return a component instance.');
|
2374
|
+
}
|
2375
|
+
/**
|
2376
|
+
* 将组件数据解析到组件实例中
|
2377
|
+
* @param data 要解析的 JSON 数据
|
2378
|
+
* @param rootComponent 根组件
|
2379
|
+
* @param textbus
|
2380
|
+
*/
|
2381
|
+
readDocumentByComponentLiteral(data, rootComponent, textbus) {
|
2382
|
+
const registry = textbus.get(Registry);
|
2383
|
+
return registry.createComponentByFactory(data, rootComponent);
|
2384
|
+
}
|
2385
|
+
onAfterStartup(textbus) {
|
2386
|
+
if (this.config.autoFocus) {
|
2387
|
+
textbus.focus();
|
2388
|
+
}
|
2389
|
+
}
|
2360
2390
|
onDestroy() {
|
2361
2391
|
this.workbench.remove();
|
2362
2392
|
}
|
package/bundles/index.js
CHANGED
@@ -332,9 +332,9 @@ class DomAdapter extends core$1.ViewAdapter {
|
|
332
332
|
});
|
333
333
|
this.slotRootVElementCaches = new WeakMap();
|
334
334
|
}
|
335
|
-
render(rootComponent) {
|
335
|
+
render(rootComponent, textbus) {
|
336
336
|
const view = this.componentRender(rootComponent);
|
337
|
-
return this.mount(this.host, view);
|
337
|
+
return this.mount(this.host, view, textbus);
|
338
338
|
}
|
339
339
|
copy() {
|
340
340
|
document.execCommand('copy');
|
@@ -2297,6 +2297,7 @@ NativeInput = __decorate([
|
|
2297
2297
|
core$1.Controller])
|
2298
2298
|
], NativeInput);
|
2299
2299
|
|
2300
|
+
const browserErrorFn = core$1.makeError('BrowserModule');
|
2300
2301
|
class BrowserModule {
|
2301
2302
|
constructor(host, config) {
|
2302
2303
|
this.host = host;
|
@@ -2359,6 +2360,35 @@ class BrowserModule {
|
|
2359
2360
|
this.workbench = wrapper;
|
2360
2361
|
this.host.append(wrapper);
|
2361
2362
|
}
|
2363
|
+
/**
|
2364
|
+
* 解析 HTML 并返回一个组件实例
|
2365
|
+
* @param html 要解析的 HTML
|
2366
|
+
* @param rootComponentLoader 文档根组件加载器
|
2367
|
+
* @param textbus
|
2368
|
+
*/
|
2369
|
+
readDocumentByHTML(html, rootComponentLoader, textbus) {
|
2370
|
+
const parser = textbus.get(exports.Parser);
|
2371
|
+
const doc = parser.parseDoc(html, rootComponentLoader);
|
2372
|
+
if (doc instanceof core$1.ComponentInstance) {
|
2373
|
+
return doc;
|
2374
|
+
}
|
2375
|
+
throw browserErrorFn('rootComponentLoader must return a component instance.');
|
2376
|
+
}
|
2377
|
+
/**
|
2378
|
+
* 将组件数据解析到组件实例中
|
2379
|
+
* @param data 要解析的 JSON 数据
|
2380
|
+
* @param rootComponent 根组件
|
2381
|
+
* @param textbus
|
2382
|
+
*/
|
2383
|
+
readDocumentByComponentLiteral(data, rootComponent, textbus) {
|
2384
|
+
const registry = textbus.get(core$1.Registry);
|
2385
|
+
return registry.createComponentByFactory(data, rootComponent);
|
2386
|
+
}
|
2387
|
+
onAfterStartup(textbus) {
|
2388
|
+
if (this.config.autoFocus) {
|
2389
|
+
textbus.focus();
|
2390
|
+
}
|
2391
|
+
}
|
2362
2392
|
onDestroy() {
|
2363
2393
|
this.workbench.remove();
|
2364
2394
|
}
|
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.13",
|
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.13",
|
30
30
|
"@viewfly/core": "^0.3.0",
|
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": "625efd792f5cc6d8008cdb007b4fe2adf6701189"
|
52
52
|
}
|