croco-html 20.3.3 → 20.3.4

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.
@@ -686,6 +686,27 @@ class CustomWidgetTagService {
686
686
  }
687
687
  }
688
688
 
689
+ class TagBuildExtensions {
690
+ static buildTagString(bodyTag, attrs) {
691
+ const tagName = bodyTag.tagDescription.tag;
692
+ const attrValStrs = [];
693
+ Object.keys(attrs).forEach(attributeName => {
694
+ const attrDescription = attrs[attributeName];
695
+ const attrVal = bodyTag.attributes[attributeName] ?? attrDescription.defaultValue;
696
+ const attrValStr = (attrVal === undefined || attrVal === null)
697
+ ? null
698
+ : `${attributeName}="${attrVal}"`;
699
+ if (attrValStr) {
700
+ attrValStrs.push(attrValStr);
701
+ }
702
+ });
703
+ const attrStr = attrValStrs.length > 0
704
+ ? " " + [attrValStrs].join(" ")
705
+ : "";
706
+ return `<${tagName}${attrStr}></${tagName}>`;
707
+ }
708
+ }
709
+
689
710
  class LinkTagConsts {
690
711
  static { this.TagName = "croco-link"; }
691
712
  }
@@ -701,14 +722,11 @@ class LinkTagService {
701
722
  this.shortDescription = "Ссылка";
702
723
  }
703
724
  bodyTagToHtmlStringConverter(bodyTag) {
704
- const urlVal = bodyTag.attributes[LinkTagAttrs.Url] ?? "";
705
- const urlValStr = `${LinkTagAttrs.Url}="${urlVal}"`;
706
- const titleVal = bodyTag.attributes[LinkTagAttrs.Title] ?? "";
707
- const titleValStr = `${LinkTagAttrs.Title}="${titleVal}"`;
708
- const typeVal = bodyTag.attributes[LinkTagAttrs.Type] ?? "";
709
- const typeValStr = typeVal.length > 0 ? `${LinkTagAttrs.Type}="${typeVal}"` : "";
710
- const attrStr = [urlValStr, titleValStr, typeValStr].join(" ");
711
- return `<${this.tagName} ${attrStr}></${this.tagName}>`;
725
+ return TagBuildExtensions.buildTagString(bodyTag, {
726
+ [LinkTagAttrs.Url]: { defaultValue: "" },
727
+ [LinkTagAttrs.Title]: { defaultValue: "" },
728
+ [LinkTagAttrs.Type]: { defaultValue: null }
729
+ });
712
730
  }
713
731
  extractBlockFromHtmlElement(elem, _) {
714
732
  const data = {
@@ -4201,5 +4219,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImpo
4201
4219
  * Generated bundle index. Do not edit.
4202
4220
  */
4203
4221
 
4204
- export { AddFilesBtnComponent, AngularMaterialTableMethods, AudioEditorComponent, AudioMethods, AudioPlayerTagViewComponent, BodyTagsExtensions, BootstrapTableMethods, ButtonTagDataConsts, ButtonTagService, CrocoHtmlFileOptionsService, CrocoHtmlModule, CrocoHtmlOptionsToken, CustomWidgetEditorComponent, CustomWidgetIconComponent, CustomWidgetTagDataConsts, CustomWidgetTagService, DefinedCustomEditorBlockComponent, DefinedCustomTagViewComponent, DownloadButtonTagDataConsts, DownloadButtonTagService, ExternalVideoEditorComponent, ExternalVideoPlayers, ExternalVideoSupportedTypes, ExternalVideoTagDataConsts, ExternalVideoTagService, FileAudioTagDataConsts, FileIdSelectComponent, FileImageTagDataConsts, FileImageTagService, FileImageTagViewComponent, FileType, HtmlPageDataController, HtmlRawEditorComponent, HtmlRawTagDataConsts, HtmlRawTagService, HtmlRawViewComponent, HtmlViewComponent, HtmlViewController, ImageEditorComponent, ImageMethods, LinkEditorComponent, LinkTagAttrs, LinkTagConsts, LinkTagService, MainEditorBlockComponent, MainEditorComponent, TableBuilder, TableMethods, TableTypes, TagEditorService, TagToSpanPipe, TextAlignment, TextEditorComponent, TextSimpleMethods, TextTag, TextTagDataConsts, TextTagHtmlMarkupTagService, TextTags, ToHtmlBodyTagsPipe, ToPreviewHtmlPipe, ToPreviewPipe, UploadFilesBtnComponent, VisualEditorComponent, XmlExtensions, XmlTagCustomWidgetComponent, XmlTagExternalVideoComponent, XmlTagHeaderInnerTextViewComponent, XmlTagHeaderTextViewComponent, XmlTagHtmlViewComponent, XmlTagTextViewComponent, XmlTagViewComponent };
4222
+ export { AddFilesBtnComponent, AngularMaterialTableMethods, AudioEditorComponent, AudioMethods, AudioPlayerTagViewComponent, BodyTagsExtensions, BootstrapTableMethods, ButtonTagDataConsts, ButtonTagService, CrocoHtmlFileOptionsService, CrocoHtmlModule, CrocoHtmlOptionsToken, CustomWidgetEditorComponent, CustomWidgetIconComponent, CustomWidgetTagDataConsts, CustomWidgetTagService, DefinedCustomEditorBlockComponent, DefinedCustomTagViewComponent, DownloadButtonTagDataConsts, DownloadButtonTagService, ExternalVideoEditorComponent, ExternalVideoPlayers, ExternalVideoSupportedTypes, ExternalVideoTagDataConsts, ExternalVideoTagService, FileAudioTagDataConsts, FileIdSelectComponent, FileImageTagDataConsts, FileImageTagService, FileImageTagViewComponent, FileType, HtmlPageDataController, HtmlRawEditorComponent, HtmlRawTagDataConsts, HtmlRawTagService, HtmlRawViewComponent, HtmlViewComponent, HtmlViewController, ImageEditorComponent, ImageMethods, LinkEditorComponent, LinkTagAttrs, LinkTagConsts, LinkTagService, MainEditorBlockComponent, MainEditorComponent, TableBuilder, TableMethods, TableTypes, TagBuildExtensions, TagEditorService, TagToSpanPipe, TextAlignment, TextEditorComponent, TextSimpleMethods, TextTag, TextTagDataConsts, TextTagHtmlMarkupTagService, TextTags, ToHtmlBodyTagsPipe, ToPreviewHtmlPipe, ToPreviewPipe, UploadFilesBtnComponent, VisualEditorComponent, XmlExtensions, XmlTagCustomWidgetComponent, XmlTagExternalVideoComponent, XmlTagHeaderInnerTextViewComponent, XmlTagHeaderTextViewComponent, XmlTagHtmlViewComponent, XmlTagTextViewComponent, XmlTagViewComponent };
4205
4223
  //# sourceMappingURL=croco-html.mjs.map