@textbus/platform-browser 3.5.2 → 3.5.3
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-support/parser.d.ts +4 -4
- package/bundles/index.esm.js +12 -15
- package/bundles/index.js +12 -15
- package/package.json +3 -3
@@ -86,17 +86,17 @@ export declare class Parser {
|
|
86
86
|
attributeLoaders: AttributeLoader<any>[];
|
87
87
|
constructor(options: ViewOptions, injector: Injector);
|
88
88
|
/**
|
89
|
-
* 使用指定的组件加载器解析一段 HTML
|
89
|
+
* 使用指定的组件加载器解析一段 HTML 字符串或 DOM 元素
|
90
90
|
* @param html
|
91
91
|
* @param rootComponentLoader
|
92
92
|
*/
|
93
|
-
parseDoc(html: string, rootComponentLoader: ComponentLoader): void | Slot<any> | ComponentInstance<import("@textbus/core").ComponentExtends, any, unknown>;
|
93
|
+
parseDoc(html: string | HTMLElement, rootComponentLoader: ComponentLoader): void | Slot<any> | ComponentInstance<import("@textbus/core").ComponentExtends, any, unknown>;
|
94
94
|
/**
|
95
|
-
* 将一段 HTML
|
95
|
+
* 将一段 HTML 或 DOM 元素解析到指定插槽
|
96
96
|
* @param html
|
97
97
|
* @param rootSlot
|
98
98
|
*/
|
99
|
-
parse(html: string, rootSlot: Slot): Slot<any>;
|
99
|
+
parse(html: string | HTMLElement, rootSlot: Slot): Slot<any>;
|
100
100
|
private readComponent;
|
101
101
|
private readText;
|
102
102
|
private readFormats;
|
package/bundles/index.esm.js
CHANGED
@@ -1239,23 +1239,23 @@ let Parser = Parser_1 = class Parser {
|
|
1239
1239
|
this.attributeLoaders = attributeLoaders;
|
1240
1240
|
}
|
1241
1241
|
/**
|
1242
|
-
* 使用指定的组件加载器解析一段 HTML
|
1242
|
+
* 使用指定的组件加载器解析一段 HTML 字符串或 DOM 元素
|
1243
1243
|
* @param html
|
1244
1244
|
* @param rootComponentLoader
|
1245
1245
|
*/
|
1246
1246
|
parseDoc(html, rootComponentLoader) {
|
1247
|
-
const element = Parser_1.parseHTML(html);
|
1247
|
+
const element = typeof html === 'string' ? Parser_1.parseHTML(html) : html;
|
1248
1248
|
return rootComponentLoader.read(element, this.injector, (childSlot, slotRootElement, slotContentHostElement = slotRootElement) => {
|
1249
1249
|
return this.readSlot(childSlot, slotRootElement, slotContentHostElement);
|
1250
1250
|
});
|
1251
1251
|
}
|
1252
1252
|
/**
|
1253
|
-
* 将一段 HTML
|
1253
|
+
* 将一段 HTML 或 DOM 元素解析到指定插槽
|
1254
1254
|
* @param html
|
1255
1255
|
* @param rootSlot
|
1256
1256
|
*/
|
1257
1257
|
parse(html, rootSlot) {
|
1258
|
-
const element = Parser_1.parseHTML(html);
|
1258
|
+
const element = typeof html === 'string' ? Parser_1.parseHTML(html) : html;
|
1259
1259
|
return this.readFormats(element, rootSlot);
|
1260
1260
|
}
|
1261
1261
|
readComponent(el, slot) {
|
@@ -1739,17 +1739,14 @@ let MagicInput = class MagicInput extends Input {
|
|
1739
1739
|
this.doc.body.appendChild(div);
|
1740
1740
|
div.focus();
|
1741
1741
|
setTimeout(() => {
|
1742
|
-
let html = div.innerHTML;
|
1743
|
-
if (!html && text && this.isFirefox) {
|
1744
|
-
html = text;
|
1745
|
-
}
|
1746
|
-
this.handlePaste(html, text);
|
1747
1742
|
this.doc.body.removeChild(div);
|
1743
|
+
div.style.cssText = '';
|
1744
|
+
this.handlePaste(div, text);
|
1748
1745
|
});
|
1749
1746
|
}));
|
1750
1747
|
}
|
1751
|
-
handlePaste(
|
1752
|
-
const slot = this.parser.parse(
|
1748
|
+
handlePaste(dom, text) {
|
1749
|
+
const slot = this.parser.parse(dom, new Slot([
|
1753
1750
|
ContentType.BlockComponent,
|
1754
1751
|
ContentType.InlineComponent,
|
1755
1752
|
ContentType.Text
|
@@ -2118,14 +2115,14 @@ let NativeInput = class NativeInput extends Input {
|
|
2118
2115
|
document.body.appendChild(div);
|
2119
2116
|
div.focus();
|
2120
2117
|
setTimeout(() => {
|
2121
|
-
const html = div.innerHTML;
|
2122
|
-
this.handlePaste(html, text);
|
2123
2118
|
document.body.removeChild(div);
|
2119
|
+
div.style.cssText = '';
|
2120
|
+
this.handlePaste(div, text);
|
2124
2121
|
});
|
2125
2122
|
}));
|
2126
2123
|
}
|
2127
|
-
handlePaste(
|
2128
|
-
const slot = this.parser.parse(
|
2124
|
+
handlePaste(dom, text) {
|
2125
|
+
const slot = this.parser.parse(dom, new Slot([
|
2129
2126
|
ContentType.BlockComponent,
|
2130
2127
|
ContentType.InlineComponent,
|
2131
2128
|
ContentType.Text
|
package/bundles/index.js
CHANGED
@@ -1241,23 +1241,23 @@ exports.Parser = Parser_1 = class Parser {
|
|
1241
1241
|
this.attributeLoaders = attributeLoaders;
|
1242
1242
|
}
|
1243
1243
|
/**
|
1244
|
-
* 使用指定的组件加载器解析一段 HTML
|
1244
|
+
* 使用指定的组件加载器解析一段 HTML 字符串或 DOM 元素
|
1245
1245
|
* @param html
|
1246
1246
|
* @param rootComponentLoader
|
1247
1247
|
*/
|
1248
1248
|
parseDoc(html, rootComponentLoader) {
|
1249
|
-
const element = Parser_1.parseHTML(html);
|
1249
|
+
const element = typeof html === 'string' ? Parser_1.parseHTML(html) : html;
|
1250
1250
|
return rootComponentLoader.read(element, this.injector, (childSlot, slotRootElement, slotContentHostElement = slotRootElement) => {
|
1251
1251
|
return this.readSlot(childSlot, slotRootElement, slotContentHostElement);
|
1252
1252
|
});
|
1253
1253
|
}
|
1254
1254
|
/**
|
1255
|
-
* 将一段 HTML
|
1255
|
+
* 将一段 HTML 或 DOM 元素解析到指定插槽
|
1256
1256
|
* @param html
|
1257
1257
|
* @param rootSlot
|
1258
1258
|
*/
|
1259
1259
|
parse(html, rootSlot) {
|
1260
|
-
const element = Parser_1.parseHTML(html);
|
1260
|
+
const element = typeof html === 'string' ? Parser_1.parseHTML(html) : html;
|
1261
1261
|
return this.readFormats(element, rootSlot);
|
1262
1262
|
}
|
1263
1263
|
readComponent(el, slot) {
|
@@ -1741,17 +1741,14 @@ exports.MagicInput = class MagicInput extends Input {
|
|
1741
1741
|
this.doc.body.appendChild(div);
|
1742
1742
|
div.focus();
|
1743
1743
|
setTimeout(() => {
|
1744
|
-
let html = div.innerHTML;
|
1745
|
-
if (!html && text && this.isFirefox) {
|
1746
|
-
html = text;
|
1747
|
-
}
|
1748
|
-
this.handlePaste(html, text);
|
1749
1744
|
this.doc.body.removeChild(div);
|
1745
|
+
div.style.cssText = '';
|
1746
|
+
this.handlePaste(div, text);
|
1750
1747
|
});
|
1751
1748
|
}));
|
1752
1749
|
}
|
1753
|
-
handlePaste(
|
1754
|
-
const slot = this.parser.parse(
|
1750
|
+
handlePaste(dom, text) {
|
1751
|
+
const slot = this.parser.parse(dom, new core.Slot([
|
1755
1752
|
core.ContentType.BlockComponent,
|
1756
1753
|
core.ContentType.InlineComponent,
|
1757
1754
|
core.ContentType.Text
|
@@ -2120,14 +2117,14 @@ exports.NativeInput = class NativeInput extends Input {
|
|
2120
2117
|
document.body.appendChild(div);
|
2121
2118
|
div.focus();
|
2122
2119
|
setTimeout(() => {
|
2123
|
-
const html = div.innerHTML;
|
2124
|
-
this.handlePaste(html, text);
|
2125
2120
|
document.body.removeChild(div);
|
2121
|
+
div.style.cssText = '';
|
2122
|
+
this.handlePaste(div, text);
|
2126
2123
|
});
|
2127
2124
|
}));
|
2128
2125
|
}
|
2129
|
-
handlePaste(
|
2130
|
-
const slot = this.parser.parse(
|
2126
|
+
handlePaste(dom, text) {
|
2127
|
+
const slot = this.parser.parse(dom, new core.Slot([
|
2131
2128
|
core.ContentType.BlockComponent,
|
2132
2129
|
core.ContentType.InlineComponent,
|
2133
2130
|
core.ContentType.Text
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@textbus/platform-browser",
|
3
|
-
"version": "3.5.
|
3
|
+
"version": "3.5.3",
|
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",
|
@@ -27,7 +27,7 @@
|
|
27
27
|
"dependencies": {
|
28
28
|
"@tanbo/di": "^1.1.5",
|
29
29
|
"@tanbo/stream": "^1.2.0",
|
30
|
-
"@textbus/core": "^3.5.
|
30
|
+
"@textbus/core": "^3.5.3",
|
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": "054ef00184c90bbef8632a892ee3d5a06bb67d46"
|
52
52
|
}
|