croco-html 4.3.3 → 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
|
@@ -269,9 +269,9 @@ class FileImageTagService {
|
|
|
269
269
|
fileIdAttr = `${FileImageTagDataConsts.FileIdAttrName}="${bodyTag.attributes[FileImageTagDataConsts.FileIdAttrName]}"`;
|
|
270
270
|
}
|
|
271
271
|
if (bodyTag.attributes.hasOwnProperty(FileImageTagDataConsts.ScreenMediaRequest) && bodyTag.attributes[FileImageTagDataConsts.ScreenMediaRequest]) {
|
|
272
|
-
screenMediaRequestAttr =
|
|
272
|
+
screenMediaRequestAttr = ` ${FileImageTagDataConsts.ScreenMediaRequest}="${bodyTag.attributes[FileImageTagDataConsts.ScreenMediaRequest]}"`;
|
|
273
273
|
}
|
|
274
|
-
return `<${FileImageTagDataConsts.TagName} ${fileIdAttr}
|
|
274
|
+
return `<${FileImageTagDataConsts.TagName} ${fileIdAttr}${screenMediaRequestAttr}></${FileImageTagDataConsts.TagName}>`;
|
|
275
275
|
}
|
|
276
276
|
extractBlockFromHtmlElement(elem, options) {
|
|
277
277
|
let fileId = elem.getAttribute(FileImageTagDataConsts.FileIdAttrName);
|
|
@@ -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,17 +1013,18 @@ 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
|
}
|
|
1021
1021
|
static convertToHtmlString(bodyTag, options) {
|
|
1022
|
-
const tagName = bodyTag.tagDescription.tag;
|
|
1022
|
+
const tagName = bodyTag.tagDescription.tag.toLowerCase();
|
|
1023
1023
|
if (this.hasTagService(tagName, options)) {
|
|
1024
1024
|
return this.getTagService(tagName, options).bodyTagToHtmlStringConverter(bodyTag);
|
|
1025
1025
|
}
|
|
1026
|
-
|
|
1026
|
+
console.log("convertToHtmlString", bodyTag, options);
|
|
1027
|
+
return `<mapper-not-found>"${tagName}" тег не найден.</mapper-not-found>`;
|
|
1027
1028
|
}
|
|
1028
1029
|
static bodyTagsToHtml(bodyTags, options) {
|
|
1029
1030
|
let htmls = bodyTags.map(bodyTag => (BodyTagsExtensions.convertToHtmlString(bodyTag, options)));
|
|
@@ -1036,14 +1037,15 @@ class BodyTagsExtensions {
|
|
|
1036
1037
|
}
|
|
1037
1038
|
static getBodyTags(html, options) {
|
|
1038
1039
|
let result = HtmlExtractionMethods.transformHtmlStringToBlocks(html, options);
|
|
1039
|
-
return result.map(x => BodyTagsExtensions.toBodyTag(x));
|
|
1040
|
+
return result.map(x => BodyTagsExtensions.toBodyTag(x, options));
|
|
1040
1041
|
}
|
|
1041
1042
|
static sanitizeInnerHtml(html) {
|
|
1042
1043
|
return html.trim().replace('\n\t', '');
|
|
1043
1044
|
}
|
|
1044
|
-
static toBodyTag(data) {
|
|
1045
|
-
|
|
1046
|
-
|
|
1045
|
+
static toBodyTag(data, options) {
|
|
1046
|
+
const tagName = data.tagName;
|
|
1047
|
+
if (this.hasTagService(tagName, options)) {
|
|
1048
|
+
return this.getTagService(tagName, options).toBodyTag(data);
|
|
1047
1049
|
}
|
|
1048
1050
|
return {
|
|
1049
1051
|
presentOrEdit: true,
|
|
@@ -2281,7 +2283,7 @@ class MainEditorBlockComponent {
|
|
|
2281
2283
|
this.onTagSaved.emit(this.tag);
|
|
2282
2284
|
}
|
|
2283
2285
|
isDefinedCustomTag() {
|
|
2284
|
-
console.log("isDefinedCustomTag()", this._options);
|
|
2286
|
+
console.log("isDefinedCustomTag()", this.tag, this._options);
|
|
2285
2287
|
if (this._options.definedCustomTags.hasOwnProperty(this.tag.tagDescription.tag)) {
|
|
2286
2288
|
return true;
|
|
2287
2289
|
}
|