croco-html 4.2.4 → 4.2.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.
@@ -139,8 +139,8 @@ class HtmlExtractionMethods {
139
139
  for (let i = 0; i < element.children.length; i++) {
140
140
  const elem = element.children.item(i);
141
141
  const loweredTagName = elem.tagName.toLowerCase();
142
- if (BodyTagsExtensions.tagServices.hasOwnProperty(loweredTagName)) {
143
- const tagService = BodyTagsExtensions.tagServices[loweredTagName];
142
+ if (BodyTagsExtensions.hasTagService(loweredTagName, options)) {
143
+ const tagService = BodyTagsExtensions.getTagService(loweredTagName, options);
144
144
  const resultBlock = tagService.extractBlockFromHtmlElement(elem, options);
145
145
  data.push(resultBlock);
146
146
  continue;
@@ -1004,6 +1004,21 @@ class BodyTagsExtensions {
1004
1004
  [ButtonTagDataConsts.TagName]: new ButtonTagService(),
1005
1005
  [TableTypes.Table]: new TableTagService()
1006
1006
  }; }
1007
+ static hasTagService(tagName, options) {
1008
+ if (this.tagServices.hasOwnProperty(tagName)) {
1009
+ return true;
1010
+ }
1011
+ if (options.definedCustomTags.hasOwnProperty(tagName)) {
1012
+ return true;
1013
+ }
1014
+ return false;
1015
+ }
1016
+ static getTagService(tagName, options) {
1017
+ if (this.tagServices.hasOwnProperty(tagName)) {
1018
+ return this.tagServices[tagName];
1019
+ }
1020
+ return options.definedCustomTags[tagName];
1021
+ }
1007
1022
  static convertToHtmlString(bodyTag) {
1008
1023
  const tagName = bodyTag.tagDescription.tag;
1009
1024
  if (this.tagServices.hasOwnProperty(tagName)) {
@@ -1757,7 +1772,7 @@ class XmlTagViewComponent {
1757
1772
  return TextTags.headerTextTags.includes(item.tagName);
1758
1773
  }
1759
1774
  isDefinedCustomTag(item) {
1760
- return this._options.definedCustomTags.includes(item.tagName);
1775
+ return this._options.definedCustomTags.hasOwnProperty(item.tagName);
1761
1776
  }
1762
1777
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: XmlTagViewComponent, deps: [{ token: CrocoHtmlOptionsToken }], target: i0.ɵɵFactoryTarget.Component }); }
1763
1778
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.14", type: XmlTagViewComponent, isStandalone: true, selector: "croco-html-xml-tag-view", inputs: { data: "data" }, ngImport: i0, template: "<div>\n @for (item of data; track $index) {\n <div class=\"row\">\n\n @if (item.tagName === 'text') {\n <div>\n <croco-html-xml-tag-text-view [item]=\"item\"></croco-html-xml-tag-text-view>\n </div>\n }\n\n @if (item.tagName === 'html-raw') {\n <div>\n <croco-html-raw-view [rawHtml]=\"item.data.innerHTML\"></croco-html-raw-view>\n </div>\n }\n\n @if (isHeaderTextTag(item)) {\n <div>\n <croco-html-xml-tag-header-text-view [item]=\"item\"></croco-html-xml-tag-header-text-view>\n </div>\n }\n\n @if (item.tagName === 'file-image') {\n <div>\n <croco-html-file-image-tag-view [item]=\"item\"></croco-html-file-image-tag-view>\n </div>\n }\n\n @if (item.tagName === 'custom-widget') {\n <div>\n <croco-html-xml-tag-custom-widget [tagData]=\"item.data\"></croco-html-xml-tag-custom-widget>\n </div>\n }\n\n @if (item.tagName === 'table' && item.validationResult) {\n\n @if (item.validationResult.isSucceeded){\n <croco-html-xml-tag-html-view [html]=\"item.data.bootstrapHtml\">\n </croco-html-xml-tag-html-view>\n }\n @else {\n <croco-html-error-banner [message]=\"item.validationResult.message\">\n </croco-html-error-banner>\n }\n }\n\n @if (item.tagName === 'external-video') {\n <div>\n <croco-html-xml-tag-external-video [data]=\"item\"></croco-html-xml-tag-external-video>\n </div>\n }\n\n @if (item.tagName === 'download-file-button') {\n <div>\n <croco-html-xml-tag-download-file-button [data]=\"item\"></croco-html-xml-tag-download-file-button>\n </div>\n }\n\n @if (item.tagName === 'button') {\n <div>\n <croco-html-xml-tag-button [data]=\"item\"></croco-html-xml-tag-button>\n </div>\n }\n\n @if (item.tagName === 'unsupported-tag') {\n <div class=\"red\" style=\"margin-top: 10px;\">\n <h4>\u0414\u0430\u043D\u043D\u044B\u0439 \u0442\u0435\u0433 \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044F</h4>\n <span>\n {{item.data.tagString}}\n </span>\n </div>\n }\n\n @if (isDefinedCustomTag(item)) {\n <div>\n <croco-html-defined-custom-tag-view [data]=\"item\"></croco-html-defined-custom-tag-view>\n </div>\n }\n\n </div>\n }\n</div>", styles: [".red{background-color:#c94444;color:#fff}\n"], dependencies: [{ kind: "component", type: XmlTagTextViewComponent, selector: "croco-html-xml-tag-text-view", inputs: ["item"] }, { kind: "component", type: HtmlRawViewComponent, selector: "croco-html-raw-view", inputs: ["rawHtml"] }, { kind: "component", type: XmlTagHeaderTextViewComponent, selector: "croco-html-xml-tag-header-text-view", inputs: ["item"] }, { kind: "component", type: FileImageTagViewComponent, selector: "croco-html-file-image-tag-view", inputs: ["item"] }, { kind: "component", type: XmlTagHtmlViewComponent, selector: "croco-html-xml-tag-html-view", inputs: ["html"] }, { kind: "component", type: ErrorBannerComponent, selector: "croco-html-error-banner", inputs: ["message"] }, { kind: "component", type: XmlTagExternalVideoComponent, selector: "croco-html-xml-tag-external-video", inputs: ["data", "tagData"] }, { kind: "component", type: XmlTagDownloadFileButtonComponent, selector: "croco-html-xml-tag-download-file-button", inputs: ["data", "tagData"] }, { kind: "component", type: XmlTagButtonComponent, selector: "croco-html-xml-tag-button", inputs: ["data", "tagData"] }, { kind: "component", type: XmlTagCustomWidgetComponent, selector: "croco-html-xml-tag-custom-widget", inputs: ["tagData"] }, { kind: "component", type: DefinedCustomTagViewComponent, selector: "croco-html-defined-custom-tag-view", inputs: ["data"] }], encapsulation: i0.ViewEncapsulation.None }); }
@@ -2267,7 +2282,7 @@ class MainEditorBlockComponent {
2267
2282
  this.onTagSaved.emit(this.tag);
2268
2283
  }
2269
2284
  isDefinedCustomTag() {
2270
- if (this._options.definedCustomTags.includes(this.tag.tagDescription.tag)) {
2285
+ if (this._options.definedCustomTags.hasOwnProperty(this.tag.tagDescription.tag)) {
2271
2286
  return true;
2272
2287
  }
2273
2288
  return false;
@@ -2371,8 +2386,8 @@ class VisualEditorComponent {
2371
2386
  this.startAddingText();
2372
2387
  return;
2373
2388
  }
2374
- if (BodyTagsExtensions.tagServices.hasOwnProperty(tagName)) {
2375
- const tagService = BodyTagsExtensions.tagServices[tagName];
2389
+ if (BodyTagsExtensions.hasTagService(tagName, this._options)) {
2390
+ const tagService = BodyTagsExtensions.getTagService(tagName, this._options);
2376
2391
  let tag = tagService.getDefaultValue({
2377
2392
  htmlRaw: this.htmlRaw,
2378
2393
  selectedVideoPlayer: this.selectedVideoPlayer