croco-html 4.3.4 → 4.3.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/fesm2022/croco-html.mjs
CHANGED
|
@@ -988,7 +988,7 @@ class TableTagService {
|
|
|
988
988
|
}
|
|
989
989
|
|
|
990
990
|
class BodyTagsExtensions {
|
|
991
|
-
static { this.
|
|
991
|
+
static { this._tagServices = {
|
|
992
992
|
[TextTags.text]: new TextTagHtmlMarkupTagService("text", "T"),
|
|
993
993
|
[TextTags.h1]: new TextTagHtmlMarkupTagService("h1", "H1"),
|
|
994
994
|
[TextTags.h2]: new TextTagHtmlMarkupTagService("h2", "H2"),
|
|
@@ -1004,7 +1004,7 @@ class BodyTagsExtensions {
|
|
|
1004
1004
|
[TableTypes.Table]: new TableTagService()
|
|
1005
1005
|
}; }
|
|
1006
1006
|
static hasTagService(tagName, options) {
|
|
1007
|
-
if (this.
|
|
1007
|
+
if (this._tagServices.hasOwnProperty(tagName)) {
|
|
1008
1008
|
return true;
|
|
1009
1009
|
}
|
|
1010
1010
|
if (options.definedCustomTags.hasOwnProperty(tagName)) {
|
|
@@ -1013,8 +1013,8 @@ class BodyTagsExtensions {
|
|
|
1013
1013
|
return false;
|
|
1014
1014
|
}
|
|
1015
1015
|
static getTagService(tagName, options) {
|
|
1016
|
-
if (this.
|
|
1017
|
-
return this.
|
|
1016
|
+
if (this._tagServices.hasOwnProperty(tagName)) {
|
|
1017
|
+
return this._tagServices[tagName];
|
|
1018
1018
|
}
|
|
1019
1019
|
return options.definedCustomTags[tagName];
|
|
1020
1020
|
}
|
|
@@ -1037,14 +1037,15 @@ class BodyTagsExtensions {
|
|
|
1037
1037
|
}
|
|
1038
1038
|
static getBodyTags(html, options) {
|
|
1039
1039
|
let result = HtmlExtractionMethods.transformHtmlStringToBlocks(html, options);
|
|
1040
|
-
return result.map(x => BodyTagsExtensions.toBodyTag(x));
|
|
1040
|
+
return result.map(x => BodyTagsExtensions.toBodyTag(x, options));
|
|
1041
1041
|
}
|
|
1042
1042
|
static sanitizeInnerHtml(html) {
|
|
1043
1043
|
return html.trim().replace('\n\t', '');
|
|
1044
1044
|
}
|
|
1045
|
-
static toBodyTag(data) {
|
|
1046
|
-
|
|
1047
|
-
|
|
1045
|
+
static toBodyTag(data, options) {
|
|
1046
|
+
const tagName = data.tagName;
|
|
1047
|
+
if (this.hasTagService(tagName, options)) {
|
|
1048
|
+
return this.getTagService(tagName, options).toBodyTag(data);
|
|
1048
1049
|
}
|
|
1049
1050
|
return {
|
|
1050
1051
|
presentOrEdit: true,
|