@coolon/angular-ui-powerups 12.4.0-alpha.77 → 12.4.0-alpha.79

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.
@@ -785,7 +785,6 @@
785
785
  }
786
786
  MarkdownService.prototype.render = function (content) {
787
787
  return marked.marked.parse(content, {
788
- gfm: true,
789
788
  smartLists: true
790
789
  });
791
790
  };
@@ -5077,10 +5076,23 @@
5077
5076
  label: [{ type: i0.Input }]
5078
5077
  };
5079
5078
 
5079
+ /**
5080
+ * @example
5081
+ * <aup-markdown [content]="..."></aup-markdown>
5082
+ * <aup-markdown [content$]="stringValueModel$"></aup-markdown>
5083
+ * <aup-markdown ngPreserveWhitespaces>
5084
+ * # This is markdown content
5085
+ *
5086
+ * With a list
5087
+ * - a
5088
+ * - b
5089
+ * </aup-markdown>
5090
+ */
5080
5091
  var MarkdownComponent = /** @class */ (function (_super) {
5081
5092
  __extends(MarkdownComponent, _super);
5082
- function MarkdownComponent(element, markdownService) {
5093
+ function MarkdownComponent(platform, element, markdownService) {
5083
5094
  var _this = _super.call(this) || this;
5095
+ _this.platform = platform;
5084
5096
  _this.element = element;
5085
5097
  _this.markdownService = markdownService;
5086
5098
  _this.inline = false;
@@ -5089,23 +5101,38 @@
5089
5101
  }
5090
5102
  MarkdownComponent.prototype.ngOnInit = function () {
5091
5103
  var _this = this;
5092
- var chain = pectin.Dsl.disposeWith(this).chain;
5093
- chain(this.content$).subscribe(function (content) {
5094
- _this.element.nativeElement.innerHTML = ___namespace.isEmpty(content) ? '' :
5095
- _this.inline ? _this.markdownService.renderInline(content) :
5096
- _this.markdownService.render(content);
5097
- }, { initialValue: 'evaluate' });
5104
+ var when = pectin.Dsl.disposeWith(this).when;
5105
+ when(this.content$).changes(function (content) { return _this.renderContent(content); }, { initialValue: 'triggerChangeUnlessNil' });
5106
+ if (___namespace.isNil(this.content) && !___namespace.isEmpty(this.element.nativeElement.innerHTML)) {
5107
+ this.renderContent(this.extractInnerContent(this.element.nativeElement.innerHTML));
5108
+ }
5109
+ };
5110
+ MarkdownComponent.prototype.extractInnerContent = function (content) {
5111
+ var lines = content.split("\n");
5112
+ var prefix = lines.reduce(function (maxPrefix, line) {
5113
+ return Math.max(maxPrefix, line.search(/\S/));
5114
+ }, 0);
5115
+ return lines.map(function (l) { return l.substr(prefix); }).join("\n");
5116
+ };
5117
+ MarkdownComponent.prototype.renderContent = function (content) {
5118
+ if (!___namespace.isNil(content)) {
5119
+ var markdown = this.inline ?
5120
+ this.markdownService.renderInline(content) :
5121
+ this.markdownService.render(content);
5122
+ this.element.nativeElement.innerHTML = markdown;
5123
+ }
5098
5124
  };
5099
5125
  return MarkdownComponent;
5100
5126
  }(DisposableComponent));
5101
5127
  MarkdownComponent.decorators = [
5102
5128
  { type: i0.Component, args: [{
5103
5129
  selector: 'aup-markdown',
5104
- template: "<p>markdown works!</p>\n",
5130
+ template: "<ng-content></ng-content>\n",
5105
5131
  styles: [":host{display:inline-block}\n"]
5106
5132
  },] }
5107
5133
  ];
5108
5134
  MarkdownComponent.ctorParameters = function () { return [
5135
+ { type: Object, decorators: [{ type: i0.Inject, args: [i0.PLATFORM_ID,] }] },
5109
5136
  { type: i0.ElementRef },
5110
5137
  { type: MarkdownService }
5111
5138
  ]; };