@taiga-ui/addon-doc 2.29.0 → 2.30.0

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.
@@ -1,8 +1,10 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/common'), require('ngx-highlightjs'), require('@taiga-ui/cdk'), require('@taiga-ui/kit'), require('@taiga-ui/core'), require('@angular/forms'), require('@angular/router'), require('@angular/animations'), require('@angular/cdk/clipboard'), require('@ng-web-apis/common'), require('@tinkoff/ng-polymorpheus'), require('@taiga-ui/addon-mobile'), require('@angular/platform-browser')) :
3
- typeof define === 'function' && define.amd ? define('@taiga-ui/addon-doc', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/common', 'ngx-highlightjs', '@taiga-ui/cdk', '@taiga-ui/kit', '@taiga-ui/core', '@angular/forms', '@angular/router', '@angular/animations', '@angular/cdk/clipboard', '@ng-web-apis/common', '@tinkoff/ng-polymorpheus', '@taiga-ui/addon-mobile', '@angular/platform-browser'], factory) :
4
- (global = global || self, factory((global['taiga-ui'] = global['taiga-ui'] || {}, global['taiga-ui']['addon-doc'] = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.ng.common, global.ngxHighlightjs, global.cdk, global.kit, global.core$1, global.ng.forms, global.ng.router, global.ng.animations, global.ng.cdk.clipboard, global.common$1, global.ngPolymorpheus, global.addonMobile, global.ng.platformBrowser));
5
- }(this, (function (exports, core, rxjs, operators, common, ngxHighlightjs, cdk, kit, core$1, forms, router, animations, clipboard, common$1, ngPolymorpheus, addonMobile, platformBrowser) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('markdown-it'), require('@angular/common'), require('ngx-highlightjs'), require('@taiga-ui/cdk'), require('@taiga-ui/kit'), require('@taiga-ui/core'), require('@angular/forms'), require('@angular/router'), require('@angular/animations'), require('@angular/cdk/clipboard'), require('@ng-web-apis/common'), require('@tinkoff/ng-polymorpheus'), require('@taiga-ui/addon-mobile'), require('@angular/platform-browser')) :
3
+ typeof define === 'function' && define.amd ? define('@taiga-ui/addon-doc', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', 'markdown-it', '@angular/common', 'ngx-highlightjs', '@taiga-ui/cdk', '@taiga-ui/kit', '@taiga-ui/core', '@angular/forms', '@angular/router', '@angular/animations', '@angular/cdk/clipboard', '@ng-web-apis/common', '@tinkoff/ng-polymorpheus', '@taiga-ui/addon-mobile', '@angular/platform-browser'], factory) :
4
+ (global = global || self, factory((global['taiga-ui'] = global['taiga-ui'] || {}, global['taiga-ui']['addon-doc'] = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.MarkdownIt, global.ng.common, global.ngxHighlightjs, global.cdk, global.kit, global.core$1, global.ng.forms, global.ng.router, global.ng.animations, global.ng.cdk.clipboard, global.common$1, global.ngPolymorpheus, global.addonMobile, global.ng.platformBrowser));
5
+ }(this, (function (exports, core, rxjs, operators, MarkdownIt, common, ngxHighlightjs, cdk, kit, core$1, forms, router, animations, clipboard, common$1, ngPolymorpheus, addonMobile, platformBrowser) { 'use strict';
6
+
7
+ MarkdownIt = MarkdownIt && Object.prototype.hasOwnProperty.call(MarkdownIt, 'default') ? MarkdownIt['default'] : MarkdownIt;
6
8
 
7
9
  /*! *****************************************************************************
8
10
  Copyright (c) Microsoft Corporation.
@@ -243,11 +245,23 @@
243
245
  });
244
246
  }
245
247
 
248
+ function tryParseMarkdownCodeBlock(text) {
249
+ var tokens = new MarkdownIt().parse(text, {});
250
+ var result = tokens.filter(function (_a) {
251
+ var tag = _a.tag;
252
+ return tag === 'code';
253
+ }).map(function (_a) {
254
+ var content = _a.content;
255
+ return content;
256
+ });
257
+ return result.length ? result : [text];
258
+ }
259
+
246
260
  var TuiDocCodeComponent = /** @class */ (function () {
247
261
  function TuiDocCodeComponent() {
248
262
  this.rawLoader$$ = new rxjs.BehaviorSubject('');
249
263
  this.filename = '';
250
- this.processor$ = this.rawLoader$$.pipe(operators.switchMap(rawLoad));
264
+ this.processor$ = this.rawLoader$$.pipe(operators.switchMap(rawLoad), operators.map(tryParseMarkdownCodeBlock));
251
265
  }
252
266
  Object.defineProperty(TuiDocCodeComponent.prototype, "code", {
253
267
  set: function (code) {
@@ -275,8 +289,8 @@
275
289
  TuiDocCodeComponent = __decorate([
276
290
  core.Component({
277
291
  selector: 'tui-doc-code',
278
- template: "<p *ngIf=\"filename\" class=\"t-header\">{{filename}}</p>\n<pre\n class=\"t-code\"\n><code [lineNumbers]=\"true\" [highlight]=\"processor$ | async\"></code></pre>\n",
279
- styles: [":host{display:block}.t-header{font:var(--tui-font-text-s);font-weight:700}.t-code{margin:0}.hljs:not(:empty){font:var(--tui-font-text-m);padding:1.5rem 2rem;font-family:monospace;background:var(--tui-clear-disabled);word-wrap:break-word;white-space:pre-wrap}@media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution:0.001dpcm){.hljs:not(:empty)::-webkit-scrollbar,.hljs:not(:empty)::-webkit-scrollbar-thumb{width:1rem;height:1rem;border-radius:6.25rem;background-clip:padding-box;border:6px solid transparent}.hljs:not(:empty)::-webkit-scrollbar{background-color:transparent}.hljs:not(:empty)::-webkit-scrollbar-thumb{background-color:var(--tui-clear-hover)}.hljs:not(:empty)::-webkit-scrollbar-thumb:hover{background-color:var(--tui-clear-active)}.hljs:not(:empty)::-webkit-scrollbar-thumb:active{background-color:var(--tui-text-03)}}:host._has-filename .hljs:not(:empty){border-radius:.75rem}@media screen and (max-width:47.9375em){.hljs:not(:empty){padding:1rem}}"]
292
+ template: "<p *ngIf=\"filename\" class=\"t-header\">{{filename}}</p>\n<pre\n *ngFor=\"let content of processor$ | async\"\n class=\"t-code\"\n><code [lineNumbers]=\"true\" [highlight]=\"content\"></code></pre>\n",
293
+ styles: [":host{display:block}.t-header{font:var(--tui-font-text-s);font-weight:700}.t-code{margin:0}.t-code+.t-code{margin-top:1rem}.hljs:not(:empty){font:var(--tui-font-text-m);padding:1.5rem 2rem;font-family:monospace;background:var(--tui-clear-disabled);word-wrap:break-word;white-space:pre-wrap}@media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution:0.001dpcm){.hljs:not(:empty)::-webkit-scrollbar,.hljs:not(:empty)::-webkit-scrollbar-thumb{width:1rem;height:1rem;border-radius:6.25rem;background-clip:padding-box;border:6px solid transparent}.hljs:not(:empty)::-webkit-scrollbar{background-color:transparent}.hljs:not(:empty)::-webkit-scrollbar-thumb{background-color:var(--tui-clear-hover)}.hljs:not(:empty)::-webkit-scrollbar-thumb:hover{background-color:var(--tui-clear-active)}.hljs:not(:empty)::-webkit-scrollbar-thumb:active{background-color:var(--tui-text-03)}}:host._has-filename .hljs:not(:empty){border-radius:.75rem}@media screen and (max-width:47.9375em){.hljs:not(:empty){padding:1rem}}"]
280
294
  })
281
295
  ], TuiDocCodeComponent);
282
296
  return TuiDocCodeComponent;