@textbus/platform-browser 4.0.0-alpha.1 → 4.0.0-alpha.5
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/dom-adapter.d.ts +1 -1
- package/bundles/index.esm.js +10 -13
- package/bundles/index.js +10 -13
- package/bundles/parser.d.ts +4 -4
- package/package.json +4 -4
package/bundles/dom-adapter.d.ts
CHANGED
@@ -31,7 +31,7 @@ export declare abstract class DomAdapter<ViewComponent, ViewElement> extends Vie
|
|
31
31
|
protected constructor(mount: (host: HTMLElement, viewComponent: ViewComponent) => (void | (() => void)));
|
32
32
|
render(rootComponent: ComponentInstance): void | (() => void);
|
33
33
|
abstract componentRender(component: ComponentInstance): ViewComponent;
|
34
|
-
abstract slotRender(slot: Slot, slotHostRender: (children: Array<VElement | VTextNode | ComponentInstance>) => VElement): ViewElement;
|
34
|
+
abstract slotRender(slot: Slot, slotHostRender: (children: Array<VElement | VTextNode | ComponentInstance>) => VElement, renderEnv: any): ViewElement;
|
35
35
|
copy(): void;
|
36
36
|
/**
|
37
37
|
* 根据组件获取组件的根 DOM 节点
|
package/bundles/index.esm.js
CHANGED
@@ -187,23 +187,23 @@ let Parser = Parser_1 = class Parser {
|
|
187
187
|
this.attributeLoaders = attributeLoaders;
|
188
188
|
}
|
189
189
|
/**
|
190
|
-
* 使用指定的组件加载器解析一段 HTML
|
190
|
+
* 使用指定的组件加载器解析一段 HTML 字符串或 DOM 元素
|
191
191
|
* @param html
|
192
192
|
* @param rootComponentLoader
|
193
193
|
*/
|
194
194
|
parseDoc(html, rootComponentLoader) {
|
195
|
-
const element = Parser_1.parseHTML(html);
|
195
|
+
const element = typeof html === 'string' ? Parser_1.parseHTML(html) : html;
|
196
196
|
return rootComponentLoader.read(element, this.injector, (childSlot, slotRootElement, slotContentHostElement = slotRootElement) => {
|
197
197
|
return this.readSlot(childSlot, slotRootElement, slotContentHostElement);
|
198
198
|
});
|
199
199
|
}
|
200
200
|
/**
|
201
|
-
* 将一段 HTML
|
201
|
+
* 将一段 HTML 或 DOM 元素解析到指定插槽
|
202
202
|
* @param html
|
203
203
|
* @param rootSlot
|
204
204
|
*/
|
205
205
|
parse(html, rootSlot) {
|
206
|
-
const element = Parser_1.parseHTML(html);
|
206
|
+
const element = typeof html === 'string' ? Parser_1.parseHTML(html) : html;
|
207
207
|
return this.readFormats(element, rootSlot);
|
208
208
|
}
|
209
209
|
readComponent(el, slot) {
|
@@ -1388,17 +1388,14 @@ let MagicInput = class MagicInput extends Input {
|
|
1388
1388
|
this.doc.body.appendChild(div);
|
1389
1389
|
div.focus();
|
1390
1390
|
setTimeout(() => {
|
1391
|
-
let html = div.innerHTML;
|
1392
|
-
if (!html && text && this.isFirefox) {
|
1393
|
-
html = text;
|
1394
|
-
}
|
1395
|
-
this.handlePaste(html, text);
|
1396
1391
|
this.doc.body.removeChild(div);
|
1392
|
+
div.style.cssText = '';
|
1393
|
+
this.handlePaste(div, text);
|
1397
1394
|
});
|
1398
1395
|
}));
|
1399
1396
|
}
|
1400
|
-
handlePaste(
|
1401
|
-
const slot = this.parser.parse(
|
1397
|
+
handlePaste(dom, text) {
|
1398
|
+
const slot = this.parser.parse(dom, new Slot([
|
1402
1399
|
ContentType.BlockComponent,
|
1403
1400
|
ContentType.InlineComponent,
|
1404
1401
|
ContentType.Text
|
@@ -2038,9 +2035,9 @@ let NativeInput = class NativeInput extends Input {
|
|
2038
2035
|
document.body.appendChild(div);
|
2039
2036
|
div.focus();
|
2040
2037
|
setTimeout(() => {
|
2041
|
-
const html = div.innerHTML;
|
2042
|
-
this.handlePaste(html, text);
|
2043
2038
|
document.body.removeChild(div);
|
2039
|
+
div.style.cssText = '';
|
2040
|
+
this.handlePaste(div, text);
|
2044
2041
|
});
|
2045
2042
|
}));
|
2046
2043
|
}
|
package/bundles/index.js
CHANGED
@@ -189,23 +189,23 @@ exports.Parser = Parser_1 = class Parser {
|
|
189
189
|
this.attributeLoaders = attributeLoaders;
|
190
190
|
}
|
191
191
|
/**
|
192
|
-
* 使用指定的组件加载器解析一段 HTML
|
192
|
+
* 使用指定的组件加载器解析一段 HTML 字符串或 DOM 元素
|
193
193
|
* @param html
|
194
194
|
* @param rootComponentLoader
|
195
195
|
*/
|
196
196
|
parseDoc(html, rootComponentLoader) {
|
197
|
-
const element = Parser_1.parseHTML(html);
|
197
|
+
const element = typeof html === 'string' ? Parser_1.parseHTML(html) : html;
|
198
198
|
return rootComponentLoader.read(element, this.injector, (childSlot, slotRootElement, slotContentHostElement = slotRootElement) => {
|
199
199
|
return this.readSlot(childSlot, slotRootElement, slotContentHostElement);
|
200
200
|
});
|
201
201
|
}
|
202
202
|
/**
|
203
|
-
* 将一段 HTML
|
203
|
+
* 将一段 HTML 或 DOM 元素解析到指定插槽
|
204
204
|
* @param html
|
205
205
|
* @param rootSlot
|
206
206
|
*/
|
207
207
|
parse(html, rootSlot) {
|
208
|
-
const element = Parser_1.parseHTML(html);
|
208
|
+
const element = typeof html === 'string' ? Parser_1.parseHTML(html) : html;
|
209
209
|
return this.readFormats(element, rootSlot);
|
210
210
|
}
|
211
211
|
readComponent(el, slot) {
|
@@ -1390,17 +1390,14 @@ exports.MagicInput = class MagicInput extends Input {
|
|
1390
1390
|
this.doc.body.appendChild(div);
|
1391
1391
|
div.focus();
|
1392
1392
|
setTimeout(() => {
|
1393
|
-
let html = div.innerHTML;
|
1394
|
-
if (!html && text && this.isFirefox) {
|
1395
|
-
html = text;
|
1396
|
-
}
|
1397
|
-
this.handlePaste(html, text);
|
1398
1393
|
this.doc.body.removeChild(div);
|
1394
|
+
div.style.cssText = '';
|
1395
|
+
this.handlePaste(div, text);
|
1399
1396
|
});
|
1400
1397
|
}));
|
1401
1398
|
}
|
1402
|
-
handlePaste(
|
1403
|
-
const slot = this.parser.parse(
|
1399
|
+
handlePaste(dom, text) {
|
1400
|
+
const slot = this.parser.parse(dom, new core$1.Slot([
|
1404
1401
|
core$1.ContentType.BlockComponent,
|
1405
1402
|
core$1.ContentType.InlineComponent,
|
1406
1403
|
core$1.ContentType.Text
|
@@ -2040,9 +2037,9 @@ let NativeInput = class NativeInput extends Input {
|
|
2040
2037
|
document.body.appendChild(div);
|
2041
2038
|
div.focus();
|
2042
2039
|
setTimeout(() => {
|
2043
|
-
const html = div.innerHTML;
|
2044
|
-
this.handlePaste(html, text);
|
2045
2040
|
document.body.removeChild(div);
|
2041
|
+
div.style.cssText = '';
|
2042
|
+
this.handlePaste(div, text);
|
2046
2043
|
});
|
2047
2044
|
}));
|
2048
2045
|
}
|
package/bundles/parser.d.ts
CHANGED
@@ -73,17 +73,17 @@ export declare class Parser {
|
|
73
73
|
attributeLoaders: AttributeLoader<any>[];
|
74
74
|
constructor(options: ViewOptions, injector: Injector);
|
75
75
|
/**
|
76
|
-
* 使用指定的组件加载器解析一段 HTML
|
76
|
+
* 使用指定的组件加载器解析一段 HTML 字符串或 DOM 元素
|
77
77
|
* @param html
|
78
78
|
* @param rootComponentLoader
|
79
79
|
*/
|
80
|
-
parseDoc(html: string, rootComponentLoader: ComponentLoader): void | Slot<any> | ComponentInstance<unknown, unknown, unknown>;
|
80
|
+
parseDoc(html: string | HTMLElement, rootComponentLoader: ComponentLoader): void | Slot<any> | ComponentInstance<unknown, unknown, unknown>;
|
81
81
|
/**
|
82
|
-
* 将一段 HTML
|
82
|
+
* 将一段 HTML 或 DOM 元素解析到指定插槽
|
83
83
|
* @param html
|
84
84
|
* @param rootSlot
|
85
85
|
*/
|
86
|
-
parse(html: string, rootSlot: Slot): Slot<any>;
|
86
|
+
parse(html: string | HTMLElement, rootSlot: Slot): Slot<any>;
|
87
87
|
private readComponent;
|
88
88
|
private readText;
|
89
89
|
private readFormats;
|
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.5",
|
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,8 +26,8 @@
|
|
26
26
|
],
|
27
27
|
"dependencies": {
|
28
28
|
"@tanbo/stream": "^1.2.0",
|
29
|
-
"@textbus/core": "^4.0.0-alpha.
|
30
|
-
"@viewfly/core": "^0.2.
|
29
|
+
"@textbus/core": "^4.0.0-alpha.5",
|
30
|
+
"@viewfly/core": "^0.2.4",
|
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": "072831527fe07e7c21a14f3141d55b24d321a690"
|
52
52
|
}
|