@covalent/highlight 4.0.0-beta.4 → 4.1.0-develop.2

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,18 +1,18 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Component, Input, ViewChild, HostListener, EventEmitter, SecurityContext, Output, NgModule } from '@angular/core';
3
+ import hljs from 'highlight.js';
3
4
  import * as i1$1 from '@angular/platform-browser';
4
- import * as i2$1 from '@angular/common';
5
- import { CommonModule } from '@angular/common';
6
5
  import * as i1 from '@angular/material/button';
7
6
  import { MatButtonModule } from '@angular/material/button';
8
- import * as i2 from '@angular/cdk/clipboard';
7
+ import * as i2 from '@angular/material/icon';
8
+ import { MatIconModule } from '@angular/material/icon';
9
+ import * as i3 from '@angular/cdk/clipboard';
9
10
  import { ClipboardModule } from '@angular/cdk/clipboard';
10
- import * as i3 from '@angular/material/tooltip';
11
+ import * as i4 from '@angular/material/tooltip';
11
12
  import { MatTooltipModule } from '@angular/material/tooltip';
12
- import * as i4 from '@angular/material/icon';
13
- import { MatIconModule } from '@angular/material/icon';
13
+ import * as i3$1 from '@angular/common';
14
+ import { CommonModule } from '@angular/common';
14
15
 
15
- const _c0$1 = ["tooltip"];
16
16
  class TdCopyCodeButtonComponent {
17
17
  constructor() {
18
18
  this.copyCodeToClipboard = false;
@@ -42,37 +42,12 @@ class TdCopyCodeButtonComponent {
42
42
  }, 200);
43
43
  }
44
44
  }
45
- /** @nocollapse */ /** @nocollapse */ TdCopyCodeButtonComponent.ɵfac = function TdCopyCodeButtonComponent_Factory(t) { return new (t || TdCopyCodeButtonComponent)(); };
46
- /** @nocollapse */ /** @nocollapse */ TdCopyCodeButtonComponent.ɵcmp = /** @pureOrBreakMyCode */ i0.ɵɵdefineComponent({ type: TdCopyCodeButtonComponent, selectors: [["td-copy-code-button"]], viewQuery: function TdCopyCodeButtonComponent_Query(rf, ctx) {
47
- if (rf & 1) {
48
- i0.ɵɵviewQuery(_c0$1, 5);
49
- }
50
- if (rf & 2) {
51
- let _t;
52
- i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.tooltip = _t.first);
53
- }
54
- }, hostBindings: function TdCopyCodeButtonComponent_HostBindings(rf, ctx) {
55
- if (rf & 1) {
56
- i0.ɵɵlistener("mouseleave", function TdCopyCodeButtonComponent_mouseleave_HostBindingHandler() { return ctx.initializeTooltip(); });
57
- }
58
- }, inputs: { copiedContent: "copiedContent", copyCodeToClipboard: "copyCodeToClipboard", copyCodeTooltips: "copyCodeTooltips" }, decls: 4, vars: 2, consts: [["mat-icon-button", "", 1, "copy-button", 3, "cdkCopyToClipboard", "matTooltip", "cdkCopyToClipboardCopied"], ["tooltip", "matTooltip"], ["role", "img"]], template: function TdCopyCodeButtonComponent_Template(rf, ctx) {
59
- if (rf & 1) {
60
- i0.ɵɵelementStart(0, "button", 0, 1);
61
- i0.ɵɵlistener("cdkCopyToClipboardCopied", function TdCopyCodeButtonComponent_Template_button_cdkCopyToClipboardCopied_0_listener($event) { return ctx.textCopied($event); });
62
- i0.ɵɵelementStart(2, "mat-icon", 2);
63
- i0.ɵɵtext(3, "content_copy");
64
- i0.ɵɵelementEnd();
65
- i0.ɵɵelementEnd();
66
- }
67
- if (rf & 2) {
68
- i0.ɵɵproperty("cdkCopyToClipboard", ctx.copiedContent)("matTooltip", ctx.copyTooltip);
69
- }
70
- }, directives: [i1.MatButton, i2.CdkCopyToClipboard, i3.MatTooltip, i4.MatIcon], styles: [""] });
71
- (function () {
72
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdCopyCodeButtonComponent, [{
45
+ TdCopyCodeButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: TdCopyCodeButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
46
+ TdCopyCodeButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.2", type: TdCopyCodeButtonComponent, selector: "td-copy-code-button", inputs: { copiedContent: "copiedContent", copyCodeToClipboard: "copyCodeToClipboard", copyCodeTooltips: "copyCodeTooltips" }, host: { listeners: { "mouseleave": "initializeTooltip()" } }, viewQueries: [{ propertyName: "tooltip", first: true, predicate: ["tooltip"], descendants: true }], ngImport: i0, template: "<button\n mat-icon-button\n [cdkCopyToClipboard]=\"copiedContent\"\n class=\"copy-button\"\n [matTooltip]=\"copyTooltip\"\n #tooltip=\"matTooltip\"\n (cdkCopyToClipboardCopied)=\"textCopied($event)\"\n>\n <mat-icon role=\"img\">content_copy</mat-icon>\n</button>\n", styles: [""], components: [{ type: i1.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i3.CdkCopyToClipboard, selector: "[cdkCopyToClipboard]", inputs: ["cdkCopyToClipboard", "cdkCopyToClipboardAttempts"], outputs: ["cdkCopyToClipboardCopied"] }, { type: i4.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }] });
47
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: TdCopyCodeButtonComponent, decorators: [{
73
48
  type: Component,
74
49
  args: [{ selector: 'td-copy-code-button', template: "<button\n mat-icon-button\n [cdkCopyToClipboard]=\"copiedContent\"\n class=\"copy-button\"\n [matTooltip]=\"copyTooltip\"\n #tooltip=\"matTooltip\"\n (cdkCopyToClipboardCopied)=\"textCopied($event)\"\n>\n <mat-icon role=\"img\">content_copy</mat-icon>\n</button>\n", styles: [""] }]
75
- }], null, { copiedContent: [{
50
+ }], propDecorators: { copiedContent: [{
76
51
  type: Input
77
52
  }], copyCodeToClipboard: [{
78
53
  type: Input
@@ -84,27 +59,8 @@ class TdCopyCodeButtonComponent {
84
59
  }], initializeTooltip: [{
85
60
  type: HostListener,
86
61
  args: ['mouseleave']
87
- }] });
88
- })();
62
+ }] } });
89
63
 
90
- const _c0 = ["highlightComponent"];
91
- const _c1 = ["copyComponent"];
92
- const _c2 = ["tooltip"];
93
- function TdHighlightComponent_div_4_Template(rf, ctx) {
94
- if (rf & 1) {
95
- i0.ɵɵelementStart(0, "div", null, 2);
96
- i0.ɵɵelement(2, "td-copy-code-button", 3);
97
- i0.ɵɵelementEnd();
98
- }
99
- if (rf & 2) {
100
- const ctx_r1 = i0.ɵɵnextContext();
101
- i0.ɵɵadvance(2);
102
- i0.ɵɵproperty("copiedContent", ctx_r1.copyContent)("copyCodeToClipboard", ctx_r1.copyCodeToClipboard)("copyCodeTooltips", ctx_r1.copyCodeTooltips);
103
- }
104
- }
105
- const _c3 = ["*"];
106
- /* tslint:disable-next-line */
107
- let hljs = require('highlight.js/lib');
108
64
  class TdHighlightComponent {
109
65
  constructor(_renderer, _elementRef, _domSanitizer, cdr) {
110
66
  this._renderer = _renderer;
@@ -199,6 +155,7 @@ class TdHighlightComponent {
199
155
  this.contentReady.emit();
200
156
  }
201
157
  _elementFromString(codeStr) {
158
+ var _a;
202
159
  // Renderer2 doesnt have a parsing method, so we have to sanitize and use [innerHTML]
203
160
  // to parse the string into DOM element for now.
204
161
  const preElement = this._renderer.createElement('pre');
@@ -207,16 +164,22 @@ class TdHighlightComponent {
207
164
  this._renderer.appendChild(preElement, codeElement);
208
165
  // Set .highlight class into <code> element
209
166
  this._renderer.addClass(codeElement, 'highlight');
210
- codeElement.innerHTML = this._domSanitizer.sanitize(SecurityContext.HTML, codeStr);
167
+ codeElement.innerHTML =
168
+ (_a = this._domSanitizer.sanitize(SecurityContext.HTML, codeStr)) !== null && _a !== void 0 ? _a : '';
211
169
  return preElement;
212
170
  }
213
171
  _render(contents) {
214
172
  // Trim leading and trailing newlines
215
- contents = contents.replace(/^(\s|\t)*\n+/g, '').replace(/(\s|\t)*\n+(\s|\t)*$/g, '');
173
+ contents = contents
174
+ .replace(/^(\s|\t)*\n+/g, '')
175
+ .replace(/(\s|\t)*\n+(\s|\t)*$/g, '');
216
176
  // Split markup by line characters
217
177
  let lines = contents.split('\n');
218
178
  // check how much indentation is used by the first actual code line
219
- const firstLineWhitespace = lines[0].match(/^(\s|\t)*/)[0];
179
+ const firstLineWhitespaceMatch = lines[0].match(/^(\s|\t)*/);
180
+ const firstLineWhitespace = firstLineWhitespaceMatch
181
+ ? firstLineWhitespaceMatch[0]
182
+ : null;
220
183
  // Remove all indentation spaces so code can be parsed correctly
221
184
  const startingWhitespaceRegex = new RegExp('^' + firstLineWhitespace);
222
185
  lines = lines.map(function (line) {
@@ -241,48 +204,19 @@ class TdHighlightComponent {
241
204
  return highlightedCode.value;
242
205
  }
243
206
  }
244
- /** @nocollapse */ /** @nocollapse */ TdHighlightComponent.ɵfac = function TdHighlightComponent_Factory(t) { return new (t || TdHighlightComponent)(i0.ɵɵdirectiveInject(i0.Renderer2), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i1$1.DomSanitizer), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
245
- /** @nocollapse */ /** @nocollapse */ TdHighlightComponent.ɵcmp = /** @pureOrBreakMyCode */ i0.ɵɵdefineComponent({ type: TdHighlightComponent, selectors: [["td-highlight"]], viewQuery: function TdHighlightComponent_Query(rf, ctx) {
246
- if (rf & 1) {
247
- i0.ɵɵviewQuery(_c0, 5);
248
- i0.ɵɵviewQuery(_c1, 5);
249
- i0.ɵɵviewQuery(_c2, 5);
250
- }
251
- if (rf & 2) {
252
- let _t;
253
- i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.highlightComp = _t.first);
254
- i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.copyComp = _t.first);
255
- i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.tooltip = _t.first);
256
- }
257
- }, inputs: { content: "content", copyCodeToClipboard: "copyCodeToClipboard", copyCodeTooltips: "copyCodeTooltips", codeLang: "codeLang", lang: "lang" }, outputs: { contentReady: "contentReady" }, ngContentSelectors: _c3, decls: 5, vars: 1, consts: [["highlightComponent", ""], [4, "ngIf"], ["copyComponent", ""], [3, "copiedContent", "copyCodeToClipboard", "copyCodeTooltips"]], template: function TdHighlightComponent_Template(rf, ctx) {
258
- if (rf & 1) {
259
- i0.ɵɵprojectionDef();
260
- i0.ɵɵelementStart(0, "div");
261
- i0.ɵɵelementStart(1, "div", null, 0);
262
- i0.ɵɵprojection(3);
263
- i0.ɵɵelementEnd();
264
- i0.ɵɵtemplate(4, TdHighlightComponent_div_4_Template, 3, 3, "div", 1);
265
- i0.ɵɵelementEnd();
266
- }
267
- if (rf & 2) {
268
- i0.ɵɵadvance(4);
269
- i0.ɵɵproperty("ngIf", ctx.copyCodeToClipboard);
270
- }
271
- }, directives: [i2$1.NgIf, TdCopyCodeButtonComponent], styles: ["[_nghost-%COMP%] {overflow-x:auto;padding:16px;display:-ms-flexbox;display:flex}[_nghost-%COMP%] pre, [_nghost-%COMP%] code, [_nghost-%COMP%] .highlight{font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace}[_nghost-%COMP%] pre{display:block;overflow-x:auto;padding:0;margin:0;background:transparent;font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace;line-height:1.45;-moz-tab-size:2;-o-tab-size:2;tab-size:2;-webkit-font-smoothing:auto;-webkit-text-size-adjust:none;-moz-text-size-adjust:none;text-size-adjust:none;position:relative;border-radius:2px;font-size:.8rem;width:100%}[_nghost-%COMP%] code{margin:0;padding:0;overflow-wrap:break-word;white-space:pre-wrap}[_nghost-%COMP%] .highlight{display:block;overflow-wrap:break-word;line-height:1.5;margin:0}[_nghost-%COMP%] .copy-button{border:none;background:inherit;margin-top:-8px;margin-right:-8px}"] });
272
- (function () {
273
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdHighlightComponent, [{
207
+ TdHighlightComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: TdHighlightComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i1$1.DomSanitizer }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
208
+ TdHighlightComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.2", type: TdHighlightComponent, selector: "td-highlight", inputs: { content: "content", copyCodeToClipboard: "copyCodeToClipboard", copyCodeTooltips: "copyCodeTooltips", codeLang: "codeLang", lang: "lang" }, outputs: { contentReady: "contentReady" }, viewQueries: [{ propertyName: "highlightComp", first: true, predicate: ["highlightComponent"], descendants: true }, { propertyName: "copyComp", first: true, predicate: ["copyComponent"], descendants: true }, { propertyName: "tooltip", first: true, predicate: ["tooltip"], descendants: true }], ngImport: i0, template: "<div>\n <div #highlightComponent>\n <ng-content></ng-content>\n </div>\n\n <div #copyComponent *ngIf=\"copyCodeToClipboard\">\n <td-copy-code-button\n [copiedContent]=\"copyContent\"\n [copyCodeToClipboard]=\"copyCodeToClipboard\"\n [copyCodeTooltips]=\"copyCodeTooltips\"\n ></td-copy-code-button>\n </div>\n</div>\n", styles: [":host ::ng-deep{overflow-x:auto;padding:16px;display:flex}:host ::ng-deep pre,:host ::ng-deep code,:host ::ng-deep .highlight{font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace}:host ::ng-deep pre{display:block;overflow-x:auto;padding:0;margin:0;background:transparent;font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace;line-height:1.45;-moz-tab-size:2;tab-size:2;-webkit-font-smoothing:auto;-webkit-text-size-adjust:none;text-size-adjust:none;position:relative;border-radius:2px;font-size:.8rem;width:100%}:host ::ng-deep code{margin:0;padding:0;overflow-wrap:break-word;white-space:pre-wrap}:host ::ng-deep .highlight{display:block;overflow-wrap:break-word;line-height:1.5;margin:0}:host ::ng-deep .copy-button{border:none;background:inherit;margin-top:-8px;margin-right:-8px}\n"], components: [{ type: TdCopyCodeButtonComponent, selector: "td-copy-code-button", inputs: ["copiedContent", "copyCodeToClipboard", "copyCodeTooltips"] }], directives: [{ type: i3$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
209
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: TdHighlightComponent, decorators: [{
274
210
  type: Component,
275
- args: [{ selector: 'td-highlight', template: "<div>\n <div #highlightComponent>\n <ng-content></ng-content>\n </div>\n\n <div #copyComponent *ngIf=\"copyCodeToClipboard\">\n <td-copy-code-button\n [copiedContent]=\"copyContent\"\n [copyCodeToClipboard]=\"copyCodeToClipboard\"\n [copyCodeTooltips]=\"copyCodeTooltips\"\n ></td-copy-code-button>\n </div>\n</div>\n", styles: [":host ::ng-deep{overflow-x:auto;padding:16px;display:-ms-flexbox;display:flex}:host ::ng-deep pre,:host ::ng-deep code,:host ::ng-deep .highlight{font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace}:host ::ng-deep pre{display:block;overflow-x:auto;padding:0;margin:0;background:transparent;font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace;line-height:1.45;-moz-tab-size:2;-o-tab-size:2;tab-size:2;-webkit-font-smoothing:auto;-webkit-text-size-adjust:none;-moz-text-size-adjust:none;text-size-adjust:none;position:relative;border-radius:2px;font-size:.8rem;width:100%}:host ::ng-deep code{margin:0;padding:0;overflow-wrap:break-word;white-space:pre-wrap}:host ::ng-deep .highlight{display:block;overflow-wrap:break-word;line-height:1.5;margin:0}:host ::ng-deep .copy-button{border:none;background:inherit;margin-top:-8px;margin-right:-8px}\n"] }]
276
- }], function () { return [{ type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i1$1.DomSanitizer }, { type: i0.ChangeDetectorRef }]; }, { content: [{
277
- type: Input,
278
- args: ['content']
211
+ args: [{ selector: 'td-highlight', template: "<div>\n <div #highlightComponent>\n <ng-content></ng-content>\n </div>\n\n <div #copyComponent *ngIf=\"copyCodeToClipboard\">\n <td-copy-code-button\n [copiedContent]=\"copyContent\"\n [copyCodeToClipboard]=\"copyCodeToClipboard\"\n [copyCodeTooltips]=\"copyCodeTooltips\"\n ></td-copy-code-button>\n </div>\n</div>\n", styles: [":host ::ng-deep{overflow-x:auto;padding:16px;display:flex}:host ::ng-deep pre,:host ::ng-deep code,:host ::ng-deep .highlight{font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace}:host ::ng-deep pre{display:block;overflow-x:auto;padding:0;margin:0;background:transparent;font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace;line-height:1.45;-moz-tab-size:2;tab-size:2;-webkit-font-smoothing:auto;-webkit-text-size-adjust:none;text-size-adjust:none;position:relative;border-radius:2px;font-size:.8rem;width:100%}:host ::ng-deep code{margin:0;padding:0;overflow-wrap:break-word;white-space:pre-wrap}:host ::ng-deep .highlight{display:block;overflow-wrap:break-word;line-height:1.5;margin:0}:host ::ng-deep .copy-button{border:none;background:inherit;margin-top:-8px;margin-right:-8px}\n"] }]
212
+ }], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i1$1.DomSanitizer }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { content: [{
213
+ type: Input
279
214
  }], copyCodeToClipboard: [{
280
215
  type: Input
281
216
  }], copyCodeTooltips: [{
282
217
  type: Input
283
218
  }], codeLang: [{
284
- type: Input,
285
- args: ['codeLang']
219
+ type: Input
286
220
  }], lang: [{
287
221
  type: Input
288
222
  }], contentReady: [{
@@ -296,25 +230,37 @@ class TdHighlightComponent {
296
230
  }], tooltip: [{
297
231
  type: ViewChild,
298
232
  args: ['tooltip']
299
- }] });
300
- })();
233
+ }] } });
301
234
 
302
235
  class CovalentHighlightModule {
303
236
  }
304
- /** @nocollapse */ /** @nocollapse */ CovalentHighlightModule.ɵfac = function CovalentHighlightModule_Factory(t) { return new (t || CovalentHighlightModule)(); };
305
- /** @nocollapse */ /** @nocollapse */ CovalentHighlightModule.ɵmod = /** @pureOrBreakMyCode */ i0.ɵɵdefineNgModule({ type: CovalentHighlightModule });
306
- /** @nocollapse */ /** @nocollapse */ CovalentHighlightModule.ɵinj = /** @pureOrBreakMyCode */ i0.ɵɵdefineInjector({ imports: [[CommonModule, ClipboardModule, MatIconModule, MatTooltipModule, MatButtonModule]] });
307
- (function () {
308
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CovalentHighlightModule, [{
237
+ CovalentHighlightModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentHighlightModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
238
+ CovalentHighlightModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentHighlightModule, declarations: [TdHighlightComponent, TdCopyCodeButtonComponent], imports: [CommonModule,
239
+ ClipboardModule,
240
+ MatIconModule,
241
+ MatTooltipModule,
242
+ MatButtonModule], exports: [TdHighlightComponent] });
243
+ CovalentHighlightModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentHighlightModule, imports: [[
244
+ CommonModule,
245
+ ClipboardModule,
246
+ MatIconModule,
247
+ MatTooltipModule,
248
+ MatButtonModule,
249
+ ]] });
250
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentHighlightModule, decorators: [{
309
251
  type: NgModule,
310
252
  args: [{
311
- imports: [CommonModule, ClipboardModule, MatIconModule, MatTooltipModule, MatButtonModule],
253
+ imports: [
254
+ CommonModule,
255
+ ClipboardModule,
256
+ MatIconModule,
257
+ MatTooltipModule,
258
+ MatButtonModule,
259
+ ],
312
260
  declarations: [TdHighlightComponent, TdCopyCodeButtonComponent],
313
261
  exports: [TdHighlightComponent],
314
262
  }]
315
- }], null, null);
316
- })();
317
- (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(CovalentHighlightModule, { declarations: [TdHighlightComponent, TdCopyCodeButtonComponent], imports: [CommonModule, ClipboardModule, MatIconModule, MatTooltipModule, MatButtonModule], exports: [TdHighlightComponent] }); })();
263
+ }] });
318
264
 
319
265
  /**
320
266
  * Generated bundle index. Do not edit.
@@ -1 +1 @@
1
- {"version":3,"file":"covalent-highlight.mjs","sources":["../../../../src/platform/highlight/copy-code-button/copy-code-button.component.ts","../../../../src/platform/highlight/copy-code-button/copy-code-button.component.html","../../../../src/platform/highlight/highlight.component.html","../../../../src/platform/highlight/highlight.component.ts","../../../../src/platform/highlight/highlight.module.ts","../../../../src/platform/highlight/covalent-highlight.ts"],"sourcesContent":["import { Component, OnInit, Input, ViewChild, HostListener } from '@angular/core';\nimport { MatTooltip } from '@angular/material/tooltip';\n\nexport interface ICopyCodeTooltips {\n copy?: string;\n copied?: string;\n}\n\n@Component({\n selector: 'td-copy-code-button',\n templateUrl: './copy-code-button.component.html',\n styleUrls: ['./copy-code-button.component.scss'],\n})\nexport class TdCopyCodeButtonComponent {\n // private _copyCodeTooltips: ICopyCodeTooltips = {};\n @Input() copiedContent: string;\n @Input() copyCodeToClipboard: boolean = false;\n /**\n * copyCodeTooltips?: ICopyCodeTooltips\n *\n * Tooltips for copy button to copy and upon copying.\n */\n @Input() copyCodeTooltips: ICopyCodeTooltips = {};\n\n get copyTooltip(): string {\n return (this.copyCodeTooltips && this.copyCodeTooltips.copy) || 'Copy';\n }\n\n get copiedTooltip(): string {\n return (this.copyCodeTooltips && this.copyCodeTooltips.copied) || 'Copied';\n }\n\n @ViewChild('tooltip') tooltip: MatTooltip;\n\n textCopied(event: boolean): void {\n if (event) {\n this.tooltip.hide();\n this.tooltip.message = this.copiedTooltip;\n this.tooltip.show();\n }\n }\n @HostListener('mouseleave')\n initializeTooltip(): void {\n setTimeout(() => {\n this.tooltip.message = this.copyTooltip;\n }, 200);\n }\n}\n","<button\n mat-icon-button\n [cdkCopyToClipboard]=\"copiedContent\"\n class=\"copy-button\"\n [matTooltip]=\"copyTooltip\"\n #tooltip=\"matTooltip\"\n (cdkCopyToClipboardCopied)=\"textCopied($event)\"\n>\n <mat-icon role=\"img\">content_copy</mat-icon>\n</button>\n","<div>\n <div #highlightComponent>\n <ng-content></ng-content>\n </div>\n\n <div #copyComponent *ngIf=\"copyCodeToClipboard\">\n <td-copy-code-button\n [copiedContent]=\"copyContent\"\n [copyCodeToClipboard]=\"copyCodeToClipboard\"\n [copyCodeTooltips]=\"copyCodeTooltips\"\n ></td-copy-code-button>\n </div>\n</div>\n","import {\n Component,\n AfterViewInit,\n ElementRef,\n Input,\n Output,\n EventEmitter,\n Renderer2,\n SecurityContext,\n ViewChild,\n ChangeDetectorRef,\n AfterViewChecked,\n TemplateRef,\n} from '@angular/core';\nimport { DomSanitizer } from '@angular/platform-browser';\nimport { MatTooltip } from '@angular/material/tooltip';\nimport { ICopyCodeTooltips } from '.';\n\ndeclare const require: any;\n/* tslint:disable-next-line */\nlet hljs: any = require('highlight.js/lib');\n\n@Component({\n selector: 'td-highlight',\n styleUrls: ['./highlight.component.scss'],\n templateUrl: './highlight.component.html',\n})\nexport class TdHighlightComponent implements AfterViewInit, AfterViewChecked {\n private _initialized: boolean = false;\n\n private _content: string;\n private _lang: string = 'typescript';\n\n /**\n * content?: string\n *\n * Code content to be parsed as highlighted html.\n * Used to load data dynamically.\n *\n * e.g. `.html`, `.ts` , etc.\n */\n @Input('content')\n set content(content: string) {\n this._content = content;\n if (this._initialized) {\n this._loadContent(this._content);\n }\n }\n\n /**\n * copyCodeToClipboard?: boolean\n *\n * Display copy button on code snippets to copy code to clipboard.\n */\n @Input() copyCodeToClipboard: boolean = false;\n\n /**\n * copyCodeTooltips?: ICopyCodeTooltips\n *\n * Tooltips for copy button to copy and upon copying.\n */\n @Input() copyCodeTooltips: ICopyCodeTooltips = {};\n\n /**\n * lang?: string\n *\n * Language of the code content to be parsed as highlighted html.\n * Defaults to `typescript`\n *\n * e.g. `typescript`, `html` , etc.\n */\n\n @Input('codeLang')\n set codeLang(lang: string) {\n this.setLanguage(lang);\n }\n /** @deprecated - removed completely @4.0.0 */\n @Input()\n set lang(lang: string) {\n // tslint:disable-next-line: no-console\n console.warn('DEPRECATION WARNING: switch to codeLang attribute as lang attribute is deprecated.');\n this.setLanguage(lang);\n }\n\n copyContent: string;\n\n /**\n * contentReady?: function\n * Event emitted after the highlight content rendering is finished.\n */\n @Output() contentReady: EventEmitter<void> = new EventEmitter<void>();\n @ViewChild('highlightComponent') highlightComp: ElementRef;\n @ViewChild('copyComponent') copyComp: ElementRef;\n\n @ViewChild('tooltip') tooltip: MatTooltip;\n\n constructor(\n private _renderer: Renderer2,\n private _elementRef: ElementRef,\n private _domSanitizer: DomSanitizer,\n private cdr: ChangeDetectorRef,\n ) {}\n\n ngAfterViewChecked(): void {\n this.cdr.detectChanges();\n }\n\n ngAfterViewInit(): void {\n if (!this._content) {\n this._loadContent((<HTMLElement>this.highlightComp.nativeElement).textContent);\n } else {\n this._loadContent(this._content);\n }\n this._initialized = true;\n }\n\n setLanguage(lang: string): void {\n if (!lang) {\n throw new Error('Error: language attribute must be defined in TdHighlightComponent.');\n }\n this._lang = lang;\n if (this._initialized) {\n this._loadContent(this._content);\n }\n }\n\n /**\n * General method to parse a string of code into HTML Elements and load them into the container\n */\n private _loadContent(code: string): void {\n if (code && code.trim().length > 0) {\n // Clean container\n this._renderer.setProperty(this._elementRef.nativeElement, 'innerHTML', '');\n // Parse html string into actual HTML elements.\n this._elementFromString(this._render(code));\n if (this.copyCodeToClipboard) {\n this._renderer.appendChild(this._elementRef.nativeElement, this.copyComp.nativeElement);\n }\n }\n this.contentReady.emit();\n }\n\n private _elementFromString(codeStr: string): HTMLPreElement {\n // Renderer2 doesnt have a parsing method, so we have to sanitize and use [innerHTML]\n // to parse the string into DOM element for now.\n const preElement: HTMLPreElement = this._renderer.createElement('pre');\n this._renderer.appendChild(this._elementRef.nativeElement, preElement);\n const codeElement: HTMLElement = this._renderer.createElement('code');\n this._renderer.appendChild(preElement, codeElement);\n // Set .highlight class into <code> element\n this._renderer.addClass(codeElement, 'highlight');\n codeElement.innerHTML = this._domSanitizer.sanitize(SecurityContext.HTML, codeStr);\n return preElement;\n }\n\n private _render(contents: string): string {\n // Trim leading and trailing newlines\n contents = contents.replace(/^(\\s|\\t)*\\n+/g, '').replace(/(\\s|\\t)*\\n+(\\s|\\t)*$/g, '');\n // Split markup by line characters\n let lines: string[] = contents.split('\\n');\n\n // check how much indentation is used by the first actual code line\n const firstLineWhitespace: string = lines[0].match(/^(\\s|\\t)*/)[0];\n\n // Remove all indentation spaces so code can be parsed correctly\n const startingWhitespaceRegex: RegExp = new RegExp('^' + firstLineWhitespace);\n lines = lines.map(function (line: string): string {\n return line\n .replace('=\"\"', '') // remove empty values\n .replace(startingWhitespaceRegex, '')\n .replace(/\\s+$/, ''); // remove trailing white spaces\n });\n\n const codeToParse: string = lines\n .join('\\n')\n .replace(/\\{ \\{/gi, '{{')\n .replace(/\\} \\}/gi, '}}')\n .replace(/&lt;/gi, '<')\n .replace(/&gt;/gi, '>'); // replace with < and > to render HTML in Angular\n this.copyContent = codeToParse;\n // Parse code with highlight.js depending on language\n const highlightedCode: any = hljs.highlight(this._lang, codeToParse, true);\n highlightedCode.value = highlightedCode.value\n .replace(/=<span class=\"hljs-value\">\"\"<\\/span>/gi, '')\n .replace('<head>', '')\n .replace('<head/>', '');\n return highlightedCode.value;\n }\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { ClipboardModule } from '@angular/cdk/clipboard';\nimport { TdHighlightComponent } from './highlight.component';\nimport { MatIconModule } from '@angular/material/icon';\nimport { MatTooltipModule } from '@angular/material/tooltip';\nimport { MatButtonModule } from '@angular/material/button';\nimport { TdCopyCodeButtonComponent } from './copy-code-button/copy-code-button.component';\n\n@NgModule({\n imports: [CommonModule, ClipboardModule, MatIconModule, MatTooltipModule, MatButtonModule],\n declarations: [TdHighlightComponent, TdCopyCodeButtonComponent],\n exports: [TdHighlightComponent],\n})\nexport class CovalentHighlightModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;MAaa,yBAAyB;IALtC;QAQW,wBAAmB,GAAY,KAAK,CAAC;;;;;;QAMrC,qBAAgB,GAAsB,EAAE,CAAC;KAyBnD;IAvBC,IAAI,WAAW;QACb,OAAO,CAAC,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,KAAK,MAAM,CAAC;KACxE;IAED,IAAI,aAAa;QACf,OAAO,CAAC,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,KAAK,QAAQ,CAAC;KAC5E;IAID,UAAU,CAAC,KAAc;QACvB,IAAI,KAAK,EAAE;YACT,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC;YAC1C,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;SACrB;KACF;IAED,iBAAiB;QACf,UAAU,CAAC;YACT,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC;SACzC,EAAE,GAAG,CAAC,CAAC;KACT;;wIAjCU,yBAAyB;8HAAzB,yBAAyB;;;;;;;;;;oHAAzB,uBAAmB;;;;YCbhC,oCAOC;YADC,kJAA4B,sBAAkB,IAAC;YAE/C,mCAAqB;YAAA,4BAAY;YAAA,iBAAW;YAC9C,iBAAS;;;YAPP,sDAAoC,+BAAA;;;;4EDWzB,yBAAyB;kBALrC,SAAS;+BACE,qBAAqB;oBAMtB,aAAa;sBAArB,KAAK;gBACG,mBAAmB;sBAA3B,KAAK;gBAMG,g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B,CAAC;iBAChC;;;wFACY,uBAAuB,mBAHnB,oBAAoB,EAAE,yBAAyB,aADpD,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,aAE/E,oBAAoB;;ACZhC;;;;;;"}
1
+ {"version":3,"file":"covalent-highlight.mjs","sources":["../../../../libs/angular-highlight/src/lib/copy-code-button/copy-code-button.component.ts","../../../../libs/angular-highlight/src/lib/copy-code-button/copy-code-button.component.html","../../../../libs/angular-highlight/src/lib/highlight.component.ts","../../../../libs/angular-highlight/src/lib/highlight.component.html","../../../../libs/angular-highlight/src/lib/highlight.module.ts","../../../../libs/angular-highlight/src/covalent-highlight.ts"],"sourcesContent":["import { Component, Input, ViewChild, HostListener } from '@angular/core';\nimport { MatTooltip } from '@angular/material/tooltip';\n\nexport interface ICopyCodeTooltips {\n copy?: string;\n copied?: string;\n}\n\n@Component({\n selector: 'td-copy-code-button',\n templateUrl: './copy-code-button.component.html',\n styleUrls: ['./copy-code-button.component.scss'],\n})\nexport class TdCopyCodeButtonComponent {\n // private _copyCodeTooltips: ICopyCodeTooltips = {};\n @Input() copiedContent!: string;\n @Input() copyCodeToClipboard = false;\n /**\n * copyCodeTooltips?: ICopyCodeTooltips\n *\n * Tooltips for copy button to copy and upon copying.\n */\n @Input() copyCodeTooltips?: ICopyCodeTooltips = {};\n\n get copyTooltip(): string {\n return (this.copyCodeTooltips && this.copyCodeTooltips.copy) || 'Copy';\n }\n\n get copiedTooltip(): string {\n return (this.copyCodeTooltips && this.copyCodeTooltips.copied) || 'Copied';\n }\n\n @ViewChild('tooltip') tooltip!: MatTooltip;\n\n textCopied(event: boolean): void {\n if (event) {\n this.tooltip.hide();\n this.tooltip.message = this.copiedTooltip;\n this.tooltip.show();\n }\n }\n @HostListener('mouseleave')\n initializeTooltip(): void {\n setTimeout(() => {\n this.tooltip.message = this.copyTooltip;\n }, 200);\n }\n}\n","<button\n mat-icon-button\n [cdkCopyToClipboard]=\"copiedContent\"\n class=\"copy-button\"\n [matTooltip]=\"copyTooltip\"\n #tooltip=\"matTooltip\"\n (cdkCopyToClipboardCopied)=\"textCopied($event)\"\n>\n <mat-icon role=\"img\">content_copy</mat-icon>\n</button>\n","import {\n Component,\n AfterViewInit,\n ElementRef,\n Input,\n Output,\n EventEmitter,\n Renderer2,\n SecurityContext,\n ViewChild,\n ChangeDetectorRef,\n AfterViewChecked,\n} from '@angular/core';\nimport { DomSanitizer } from '@angular/platform-browser';\nimport { MatTooltip } from '@angular/material/tooltip';\nimport { ICopyCodeTooltips } from './copy-code-button/copy-code-button.component';\n\nimport hljs from 'highlight.js';\n\n@Component({\n selector: 'td-highlight',\n styleUrls: ['./highlight.component.scss'],\n templateUrl: './highlight.component.html',\n})\nexport class TdHighlightComponent implements AfterViewInit, AfterViewChecked {\n private _initialized = false;\n\n private _content!: string;\n private _lang = 'typescript';\n\n /**\n * content?: string\n *\n * Code content to be parsed as highlighted html.\n * Used to load data dynamically.\n *\n * e.g. `.html`, `.ts` , etc.\n */\n @Input()\n set content(content: string) {\n this._content = content;\n if (this._initialized) {\n this._loadContent(this._content);\n }\n }\n\n /**\n * copyCodeToClipboard?: boolean\n *\n * Display copy button on code snippets to copy code to clipboard.\n */\n @Input() copyCodeToClipboard? = false;\n\n /**\n * copyCodeTooltips?: ICopyCodeTooltips\n *\n * Tooltips for copy button to copy and upon copying.\n */\n @Input() copyCodeTooltips?: ICopyCodeTooltips = {};\n\n /**\n * lang?: string\n *\n * Language of the code content to be parsed as highlighted html.\n * Defaults to `typescript`\n *\n * e.g. `typescript`, `html` , etc.\n */\n\n @Input()\n set codeLang(lang: string) {\n this.setLanguage(lang);\n }\n /** @deprecated - removed completely @4.0.0 */\n @Input()\n set lang(lang: string) {\n // tslint:disable-next-line: no-console\n console.warn(\n 'DEPRECATION WARNING: switch to codeLang attribute as lang attribute is deprecated.'\n );\n this.setLanguage(lang);\n }\n\n copyContent!: string;\n\n /**\n * contentReady?: function\n * Event emitted after the highlight content rendering is finished.\n */\n @Output() contentReady: EventEmitter<void> = new EventEmitter<void>();\n @ViewChild('highlightComponent') highlightComp!: ElementRef;\n @ViewChild('copyComponent') copyComp!: ElementRef;\n\n @ViewChild('tooltip') tooltip!: MatTooltip;\n\n constructor(\n private _renderer: Renderer2,\n private _elementRef: ElementRef,\n private _domSanitizer: DomSanitizer,\n private cdr: ChangeDetectorRef\n ) {}\n\n ngAfterViewChecked(): void {\n this.cdr.detectChanges();\n }\n\n ngAfterViewInit(): void {\n if (!this._content) {\n this._loadContent(\n (<HTMLElement>this.highlightComp.nativeElement).textContent\n );\n } else {\n this._loadContent(this._content);\n }\n this._initialized = true;\n }\n\n setLanguage(lang: string): void {\n if (!lang) {\n throw new Error(\n 'Error: language attribute must be defined in TdHighlightComponent.'\n );\n }\n this._lang = lang;\n if (this._initialized) {\n this._loadContent(this._content);\n }\n }\n\n /**\n * General method to parse a string of code into HTML Elements and load them into the container\n */\n private _loadContent(code: string | null): void {\n if (code && code.trim().length > 0) {\n // Clean container\n this._renderer.setProperty(\n this._elementRef.nativeElement,\n 'innerHTML',\n ''\n );\n // Parse html string into actual HTML elements.\n this._elementFromString(this._render(code));\n if (this.copyCodeToClipboard) {\n this._renderer.appendChild(\n this._elementRef.nativeElement,\n this.copyComp.nativeElement\n );\n }\n }\n this.contentReady.emit();\n }\n\n private _elementFromString(codeStr: string): HTMLPreElement {\n // Renderer2 doesnt have a parsing method, so we have to sanitize and use [innerHTML]\n // to parse the string into DOM element for now.\n const preElement: HTMLPreElement = this._renderer.createElement('pre');\n this._renderer.appendChild(this._elementRef.nativeElement, preElement);\n const codeElement: HTMLElement = this._renderer.createElement('code');\n this._renderer.appendChild(preElement, codeElement);\n // Set .highlight class into <code> element\n this._renderer.addClass(codeElement, 'highlight');\n codeElement.innerHTML =\n this._domSanitizer.sanitize(SecurityContext.HTML, codeStr) ?? '';\n return preElement;\n }\n\n private _render(contents: string): string {\n // Trim leading and trailing newlines\n contents = contents\n .replace(/^(\\s|\\t)*\\n+/g, '')\n .replace(/(\\s|\\t)*\\n+(\\s|\\t)*$/g, '');\n // Split markup by line characters\n let lines: string[] = contents.split('\\n');\n\n // check how much indentation is used by the first actual code line\n const firstLineWhitespaceMatch = lines[0].match(/^(\\s|\\t)*/);\n const firstLineWhitespace = firstLineWhitespaceMatch\n ? firstLineWhitespaceMatch[0]\n : null;\n\n // Remove all indentation spaces so code can be parsed correctly\n const startingWhitespaceRegex = new RegExp('^' + firstLineWhitespace);\n lines = lines.map(function (line: string): string {\n return line\n .replace('=\"\"', '') // remove empty values\n .replace(startingWhitespaceRegex, '')\n .replace(/\\s+$/, ''); // remove trailing white spaces\n });\n\n const codeToParse: string = lines\n .join('\\n')\n .replace(/\\{ \\{/gi, '{{')\n .replace(/\\} \\}/gi, '}}')\n .replace(/&lt;/gi, '<')\n .replace(/&gt;/gi, '>'); // replace with < and > to render HTML in Angular\n this.copyContent = codeToParse;\n // Parse code with highlight.js depending on language\n const highlightedCode: any = hljs.highlight(this._lang, codeToParse, true);\n highlightedCode.value = highlightedCode.value\n .replace(/=<span class=\"hljs-value\">\"\"<\\/span>/gi, '')\n .replace('<head>', '')\n .replace('<head/>', '');\n return highlightedCode.value;\n }\n}\n","<div>\n <div #highlightComponent>\n <ng-content></ng-content>\n </div>\n\n <div #copyComponent *ngIf=\"copyCodeToClipboard\">\n <td-copy-code-button\n [copiedContent]=\"copyContent\"\n [copyCodeToClipboard]=\"copyCodeToClipboard\"\n [copyCodeTooltips]=\"copyCodeTooltips\"\n ></td-copy-code-button>\n </div>\n</div>\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { ClipboardModule } from '@angular/cdk/clipboard';\nimport { TdHighlightComponent } from './highlight.component';\nimport { MatIconModule } from '@angular/material/icon';\nimport { MatTooltipModule } from '@angular/material/tooltip';\nimport { MatButtonModule } from '@angular/material/button';\nimport { TdCopyCodeButtonComponent } from './copy-code-button/copy-code-button.component';\n\n@NgModule({\n imports: [\n CommonModule,\n ClipboardModule,\n MatIconModule,\n MatTooltipModule,\n MatButtonModule,\n ],\n declarations: [TdHighlightComponent, TdCopyCodeButtonComponent],\n exports: [TdHighlightComponent],\n})\nexport class CovalentHighlightModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;MAaa,yBAAyB;IALtC;QAQW,wBAAmB,GAAG,KAAK,CAAC;;;;;;QAM5B,qBAAgB,GAAuB,EAAE,CAAC;KAyBpD;IAvBC,IAAI,WAAW;QACb,OAAO,CAAC,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,KAAK,MAAM,CAAC;KACxE;IAED,IAAI,aAAa;QACf,OAAO,CAAC,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,KAAK,QAAQ,CAAC;KAC5E;IAID,UAAU,CAAC,KAAc;QACvB,IAAI,KAAK,EAAE;YACT,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC;YAC1C,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;SACrB;KACF;IAED,iBAAiB;QACf,UAAU,CAAC;YACT,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC;SACzC,EAAE,GAAG,CAAC,CAAC;KACT;;sHAjCU,yBAAyB;0GAAzB,yBAAyB,2VCbtC,iRAUA;2FDGa,yBAAyB;kBALrC,SAAS;+BACE,qBAAqB;8BAMtB,aAAa;sBAArB,KAAK;gBACG,mBAAmB;sBAA3B,KAAK;gBAMG,gBAAgB;sBAAxB,KAAK;gBAUgB,OAAO;sBAA5B,SAAS;uBAAC,SAAS;gBAUpB,iBAAiB;sBADhB,YAAY;uBAAC,YAAY;;;MEjBf,oBAAoB;IAuE/B,YACU,SAAoB,EACpB,WAAuB,EACvB,aAA2B,EAC3B,GA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,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAC1B,OAAO,eAAe,CAAC,KAAK,CAAC;KAC9B;;iHAnLU,oBAAoB;qGAApB,oBAAoB,2hBCxBjC,2VAaA;2FDWa,oBAAoB;kBALhC,SAAS;+BACE,cAAc;sLAmBpB,OAAO;sBADV,KAAK;gBAaG,mBAAmB;sBAA3B,KAAK;gBAOG,gBAAgB;sBAAxB,KAAK;gBAYF,QAAQ;sBADX,KAAK;gBAMF,IAAI;sBADP,KAAK;gBAeI,YAAY;sBAArB,MAAM;gBAC0B,aAAa;sBAA7C,SAAS;uBAAC,oBAAoB;gBACH,QAAQ;sBAAnC,SAAS;uBAAC,eAAe;gBAEJ,OAAO;sBAA5B,SAAS;uBAAC,SAAS;;;MEzET,uBAAuB;;oHAAvB,uBAAuB;qHAAvB,uBAAuB,iBAHnB,oBAAoB,EAAE,yBAAyB,aAN5D,YAAY;QACZ,eAAe;QACf,aAAa;QACb,gBAAgB;QAChB,eAAe,aAGP,oBAAoB;qHAEnB,uBAAuB,YAVzB;YACP,YAAY;YACZ,eAAe;YACf,aAAa;YACb,gBAAgB;YAChB,eAAe;SAChB;2FAIU,uBAAuB;kBAXnC,QAAQ;mBAAC;oBACR,OAAO,EAAE;wBACP,YAAY;wBACZ,eAAe;wBACf,aAAa;wBACb,gBAAgB;wBAChB,eAAe;qBAChB;oBACD,YAAY,EAAE,CAAC,oBAAoB,EAAE,yBAAyB,CAAC;oBAC/D,OAAO,EAAE,CAAC,oBAAoB,CAAC;iBAChC;;;ACnBD;;;;;;"}
@@ -1,18 +1,18 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Component, Input, ViewChild, HostListener, EventEmitter, SecurityContext, Output, NgModule } from '@angular/core';
3
3
  import * as i1$1 from '@angular/platform-browser';
4
- import * as i3 from '@angular/material/tooltip';
4
+ import * as i4 from '@angular/material/tooltip';
5
5
  import { MatTooltipModule } from '@angular/material/tooltip';
6
- import * as i2$1 from '@angular/common';
7
- import { CommonModule } from '@angular/common';
6
+ import hljs from 'highlight.js';
8
7
  import * as i1 from '@angular/material/button';
9
8
  import { MatButtonModule } from '@angular/material/button';
10
- import * as i2 from '@angular/cdk/clipboard';
11
- import { ClipboardModule } from '@angular/cdk/clipboard';
12
- import * as i4 from '@angular/material/icon';
9
+ import * as i2 from '@angular/material/icon';
13
10
  import { MatIconModule } from '@angular/material/icon';
11
+ import * as i3 from '@angular/cdk/clipboard';
12
+ import { ClipboardModule } from '@angular/cdk/clipboard';
13
+ import * as i3$1 from '@angular/common';
14
+ import { CommonModule } from '@angular/common';
14
15
 
15
- const _c0$1 = ["tooltip"];
16
16
  class TdCopyCodeButtonComponent {
17
17
  constructor() {
18
18
  this.copyCodeToClipboard = false;
@@ -42,56 +42,25 @@ class TdCopyCodeButtonComponent {
42
42
  }, 200);
43
43
  }
44
44
  }
45
- /** @nocollapse */ /** @nocollapse */ TdCopyCodeButtonComponent.ɵfac = function TdCopyCodeButtonComponent_Factory(t) { return new (t || TdCopyCodeButtonComponent)(); };
46
- /** @nocollapse */ /** @nocollapse */ TdCopyCodeButtonComponent.ɵcmp = /** @pureOrBreakMyCode */ i0.ɵɵdefineComponent({ type: TdCopyCodeButtonComponent, selectors: [["td-copy-code-button"]], viewQuery: function TdCopyCodeButtonComponent_Query(rf, ctx) { if (rf & 1) {
47
- i0.ɵɵviewQuery(_c0$1, 5);
48
- } if (rf & 2) {
49
- let _t;
50
- i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.tooltip = _t.first);
51
- } }, hostBindings: function TdCopyCodeButtonComponent_HostBindings(rf, ctx) { if (rf & 1) {
52
- i0.ɵɵlistener("mouseleave", function TdCopyCodeButtonComponent_mouseleave_HostBindingHandler() { return ctx.initializeTooltip(); });
53
- } }, inputs: { copiedContent: "copiedContent", copyCodeToClipboard: "copyCodeToClipboard", copyCodeTooltips: "copyCodeTooltips" }, decls: 4, vars: 2, consts: [["mat-icon-button", "", 1, "copy-button", 3, "cdkCopyToClipboard", "matTooltip", "cdkCopyToClipboardCopied"], ["tooltip", "matTooltip"], ["role", "img"]], template: function TdCopyCodeButtonComponent_Template(rf, ctx) { if (rf & 1) {
54
- i0.ɵɵelementStart(0, "button", 0, 1);
55
- i0.ɵɵlistener("cdkCopyToClipboardCopied", function TdCopyCodeButtonComponent_Template_button_cdkCopyToClipboardCopied_0_listener($event) { return ctx.textCopied($event); });
56
- i0.ɵɵelementStart(2, "mat-icon", 2);
57
- i0.ɵɵtext(3, "content_copy");
58
- i0.ɵɵelementEnd();
59
- i0.ɵɵelementEnd();
60
- } if (rf & 2) {
61
- i0.ɵɵproperty("cdkCopyToClipboard", ctx.copiedContent)("matTooltip", ctx.copyTooltip);
62
- } }, directives: [i1.MatButton, i2.CdkCopyToClipboard, i3.MatTooltip, i4.MatIcon], styles: [""] });
63
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdCopyCodeButtonComponent, [{
64
- type: Component,
65
- args: [{ selector: 'td-copy-code-button', template: "<button\n mat-icon-button\n [cdkCopyToClipboard]=\"copiedContent\"\n class=\"copy-button\"\n [matTooltip]=\"copyTooltip\"\n #tooltip=\"matTooltip\"\n (cdkCopyToClipboardCopied)=\"textCopied($event)\"\n>\n <mat-icon role=\"img\">content_copy</mat-icon>\n</button>\n", styles: [""] }]
66
- }], null, { copiedContent: [{
67
- type: Input
68
- }], copyCodeToClipboard: [{
69
- type: Input
70
- }], copyCodeTooltips: [{
71
- type: Input
72
- }], tooltip: [{
73
- type: ViewChild,
74
- args: ['tooltip']
75
- }], initializeTooltip: [{
76
- type: HostListener,
77
- args: ['mouseleave']
78
- }] }); })();
45
+ TdCopyCodeButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: TdCopyCodeButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
46
+ TdCopyCodeButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.2", type: TdCopyCodeButtonComponent, selector: "td-copy-code-button", inputs: { copiedContent: "copiedContent", copyCodeToClipboard: "copyCodeToClipboard", copyCodeTooltips: "copyCodeTooltips" }, host: { listeners: { "mouseleave": "initializeTooltip()" } }, viewQueries: [{ propertyName: "tooltip", first: true, predicate: ["tooltip"], descendants: true }], ngImport: i0, template: "<button\n mat-icon-button\n [cdkCopyToClipboard]=\"copiedContent\"\n class=\"copy-button\"\n [matTooltip]=\"copyTooltip\"\n #tooltip=\"matTooltip\"\n (cdkCopyToClipboardCopied)=\"textCopied($event)\"\n>\n <mat-icon role=\"img\">content_copy</mat-icon>\n</button>\n", styles: [""], components: [{ type: i1.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i3.CdkCopyToClipboard, selector: "[cdkCopyToClipboard]", inputs: ["cdkCopyToClipboard", "cdkCopyToClipboardAttempts"], outputs: ["cdkCopyToClipboardCopied"] }, { type: i4.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }] });
47
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: TdCopyCodeButtonComponent, decorators: [{
48
+ type: Component,
49
+ args: [{ selector: 'td-copy-code-button', template: "<button\n mat-icon-button\n [cdkCopyToClipboard]=\"copiedContent\"\n class=\"copy-button\"\n [matTooltip]=\"copyTooltip\"\n #tooltip=\"matTooltip\"\n (cdkCopyToClipboardCopied)=\"textCopied($event)\"\n>\n <mat-icon role=\"img\">content_copy</mat-icon>\n</button>\n", styles: [""] }]
50
+ }], propDecorators: { copiedContent: [{
51
+ type: Input
52
+ }], copyCodeToClipboard: [{
53
+ type: Input
54
+ }], copyCodeTooltips: [{
55
+ type: Input
56
+ }], tooltip: [{
57
+ type: ViewChild,
58
+ args: ['tooltip']
59
+ }], initializeTooltip: [{
60
+ type: HostListener,
61
+ args: ['mouseleave']
62
+ }] } });
79
63
 
80
- const _c0 = ["highlightComponent"];
81
- const _c1 = ["copyComponent"];
82
- const _c2 = ["tooltip"];
83
- function TdHighlightComponent_div_4_Template(rf, ctx) { if (rf & 1) {
84
- i0.ɵɵelementStart(0, "div", null, 2);
85
- i0.ɵɵelement(2, "td-copy-code-button", 3);
86
- i0.ɵɵelementEnd();
87
- } if (rf & 2) {
88
- const ctx_r1 = i0.ɵɵnextContext();
89
- i0.ɵɵadvance(2);
90
- i0.ɵɵproperty("copiedContent", ctx_r1.copyContent)("copyCodeToClipboard", ctx_r1.copyCodeToClipboard)("copyCodeTooltips", ctx_r1.copyCodeTooltips);
91
- } }
92
- const _c3 = ["*"];
93
- /* tslint:disable-next-line */
94
- let hljs = require('highlight.js/lib');
95
64
  class TdHighlightComponent {
96
65
  constructor(_renderer, _elementRef, _domSanitizer, cdr) {
97
66
  this._renderer = _renderer;
@@ -194,16 +163,22 @@ class TdHighlightComponent {
194
163
  this._renderer.appendChild(preElement, codeElement);
195
164
  // Set .highlight class into <code> element
196
165
  this._renderer.addClass(codeElement, 'highlight');
197
- codeElement.innerHTML = this._domSanitizer.sanitize(SecurityContext.HTML, codeStr);
166
+ codeElement.innerHTML =
167
+ this._domSanitizer.sanitize(SecurityContext.HTML, codeStr) ?? '';
198
168
  return preElement;
199
169
  }
200
170
  _render(contents) {
201
171
  // Trim leading and trailing newlines
202
- contents = contents.replace(/^(\s|\t)*\n+/g, '').replace(/(\s|\t)*\n+(\s|\t)*$/g, '');
172
+ contents = contents
173
+ .replace(/^(\s|\t)*\n+/g, '')
174
+ .replace(/(\s|\t)*\n+(\s|\t)*$/g, '');
203
175
  // Split markup by line characters
204
176
  let lines = contents.split('\n');
205
177
  // check how much indentation is used by the first actual code line
206
- const firstLineWhitespace = lines[0].match(/^(\s|\t)*/)[0];
178
+ const firstLineWhitespaceMatch = lines[0].match(/^(\s|\t)*/);
179
+ const firstLineWhitespace = firstLineWhitespaceMatch
180
+ ? firstLineWhitespaceMatch[0]
181
+ : null;
207
182
  // Remove all indentation spaces so code can be parsed correctly
208
183
  const startingWhitespaceRegex = new RegExp('^' + firstLineWhitespace);
209
184
  lines = lines.map(function (line) {
@@ -228,70 +203,63 @@ class TdHighlightComponent {
228
203
  return highlightedCode.value;
229
204
  }
230
205
  }
231
- /** @nocollapse */ /** @nocollapse */ TdHighlightComponent.ɵfac = function TdHighlightComponent_Factory(t) { return new (t || TdHighlightComponent)(i0.ɵɵdirectiveInject(i0.Renderer2), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i1$1.DomSanitizer), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
232
- /** @nocollapse */ /** @nocollapse */ TdHighlightComponent.ɵcmp = /** @pureOrBreakMyCode */ i0.ɵɵdefineComponent({ type: TdHighlightComponent, selectors: [["td-highlight"]], viewQuery: function TdHighlightComponent_Query(rf, ctx) { if (rf & 1) {
233
- i0.ɵɵviewQuery(_c0, 5);
234
- i0.ɵɵviewQuery(_c1, 5);
235
- i0.ɵɵviewQuery(_c2, 5);
236
- } if (rf & 2) {
237
- let _t;
238
- i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.highlightComp = _t.first);
239
- i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.copyComp = _t.first);
240
- i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.tooltip = _t.first);
241
- } }, inputs: { content: "content", copyCodeToClipboard: "copyCodeToClipboard", copyCodeTooltips: "copyCodeTooltips", codeLang: "codeLang", lang: "lang" }, outputs: { contentReady: "contentReady" }, ngContentSelectors: _c3, decls: 5, vars: 1, consts: [["highlightComponent", ""], [4, "ngIf"], ["copyComponent", ""], [3, "copiedContent", "copyCodeToClipboard", "copyCodeTooltips"]], template: function TdHighlightComponent_Template(rf, ctx) { if (rf & 1) {
242
- i0.ɵɵprojectionDef();
243
- i0.ɵɵelementStart(0, "div");
244
- i0.ɵɵelementStart(1, "div", null, 0);
245
- i0.ɵɵprojection(3);
246
- i0.ɵɵelementEnd();
247
- i0.ɵɵtemplate(4, TdHighlightComponent_div_4_Template, 3, 3, "div", 1);
248
- i0.ɵɵelementEnd();
249
- } if (rf & 2) {
250
- i0.ɵɵadvance(4);
251
- i0.ɵɵproperty("ngIf", ctx.copyCodeToClipboard);
252
- } }, directives: [i2$1.NgIf, TdCopyCodeButtonComponent], styles: ["[_nghost-%COMP%] {overflow-x:auto;padding:16px;display:-ms-flexbox;display:flex}[_nghost-%COMP%] pre, [_nghost-%COMP%] code, [_nghost-%COMP%] .highlight{font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace}[_nghost-%COMP%] pre{display:block;overflow-x:auto;padding:0;margin:0;background:transparent;font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace;line-height:1.45;-moz-tab-size:2;-o-tab-size:2;tab-size:2;-webkit-font-smoothing:auto;-webkit-text-size-adjust:none;-moz-text-size-adjust:none;text-size-adjust:none;position:relative;border-radius:2px;font-size:.8rem;width:100%}[_nghost-%COMP%] code{margin:0;padding:0;overflow-wrap:break-word;white-space:pre-wrap}[_nghost-%COMP%] .highlight{display:block;overflow-wrap:break-word;line-height:1.5;margin:0}[_nghost-%COMP%] .copy-button{border:none;background:inherit;margin-top:-8px;margin-right:-8px}"] });
253
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdHighlightComponent, [{
254
- type: Component,
255
- args: [{ selector: 'td-highlight', template: "<div>\n <div #highlightComponent>\n <ng-content></ng-content>\n </div>\n\n <div #copyComponent *ngIf=\"copyCodeToClipboard\">\n <td-copy-code-button\n [copiedContent]=\"copyContent\"\n [copyCodeToClipboard]=\"copyCodeToClipboard\"\n [copyCodeTooltips]=\"copyCodeTooltips\"\n ></td-copy-code-button>\n </div>\n</div>\n", styles: [":host ::ng-deep{overflow-x:auto;padding:16px;display:-ms-flexbox;display:flex}:host ::ng-deep pre,:host ::ng-deep code,:host ::ng-deep .highlight{font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace}:host ::ng-deep pre{display:block;overflow-x:auto;padding:0;margin:0;background:transparent;font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace;line-height:1.45;-moz-tab-size:2;-o-tab-size:2;tab-size:2;-webkit-font-smoothing:auto;-webkit-text-size-adjust:none;-moz-text-size-adjust:none;text-size-adjust:none;position:relative;border-radius:2px;font-size:.8rem;width:100%}:host ::ng-deep code{margin:0;padding:0;overflow-wrap:break-word;white-space:pre-wrap}:host ::ng-deep .highlight{display:block;overflow-wrap:break-word;line-height:1.5;margin:0}:host ::ng-deep .copy-button{border:none;background:inherit;margin-top:-8px;margin-right:-8px}\n"] }]
256
- }], function () { return [{ type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i1$1.DomSanitizer }, { type: i0.ChangeDetectorRef }]; }, { content: [{
257
- type: Input,
258
- args: ['content']
259
- }], copyCodeToClipboard: [{
260
- type: Input
261
- }], copyCodeTooltips: [{
262
- type: Input
263
- }], codeLang: [{
264
- type: Input,
265
- args: ['codeLang']
266
- }], lang: [{
267
- type: Input
268
- }], contentReady: [{
269
- type: Output
270
- }], highlightComp: [{
271
- type: ViewChild,
272
- args: ['highlightComponent']
273
- }], copyComp: [{
274
- type: ViewChild,
275
- args: ['copyComponent']
276
- }], tooltip: [{
277
- type: ViewChild,
278
- args: ['tooltip']
279
- }] }); })();
206
+ TdHighlightComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: TdHighlightComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i1$1.DomSanitizer }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
207
+ TdHighlightComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.2", type: TdHighlightComponent, selector: "td-highlight", inputs: { content: "content", copyCodeToClipboard: "copyCodeToClipboard", copyCodeTooltips: "copyCodeTooltips", codeLang: "codeLang", lang: "lang" }, outputs: { contentReady: "contentReady" }, viewQueries: [{ propertyName: "highlightComp", first: true, predicate: ["highlightComponent"], descendants: true }, { propertyName: "copyComp", first: true, predicate: ["copyComponent"], descendants: true }, { propertyName: "tooltip", first: true, predicate: ["tooltip"], descendants: true }], ngImport: i0, template: "<div>\n <div #highlightComponent>\n <ng-content></ng-content>\n </div>\n\n <div #copyComponent *ngIf=\"copyCodeToClipboard\">\n <td-copy-code-button\n [copiedContent]=\"copyContent\"\n [copyCodeToClipboard]=\"copyCodeToClipboard\"\n [copyCodeTooltips]=\"copyCodeTooltips\"\n ></td-copy-code-button>\n </div>\n</div>\n", styles: [":host ::ng-deep{overflow-x:auto;padding:16px;display:flex}:host ::ng-deep pre,:host ::ng-deep code,:host ::ng-deep .highlight{font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace}:host ::ng-deep pre{display:block;overflow-x:auto;padding:0;margin:0;background:transparent;font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace;line-height:1.45;-moz-tab-size:2;tab-size:2;-webkit-font-smoothing:auto;-webkit-text-size-adjust:none;text-size-adjust:none;position:relative;border-radius:2px;font-size:.8rem;width:100%}:host ::ng-deep code{margin:0;padding:0;overflow-wrap:break-word;white-space:pre-wrap}:host ::ng-deep .highlight{display:block;overflow-wrap:break-word;line-height:1.5;margin:0}:host ::ng-deep .copy-button{border:none;background:inherit;margin-top:-8px;margin-right:-8px}\n"], components: [{ type: TdCopyCodeButtonComponent, selector: "td-copy-code-button", inputs: ["copiedContent", "copyCodeToClipboard", "copyCodeTooltips"] }], directives: [{ type: i3$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
208
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: TdHighlightComponent, decorators: [{
209
+ type: Component,
210
+ args: [{ selector: 'td-highlight', template: "<div>\n <div #highlightComponent>\n <ng-content></ng-content>\n </div>\n\n <div #copyComponent *ngIf=\"copyCodeToClipboard\">\n <td-copy-code-button\n [copiedContent]=\"copyContent\"\n [copyCodeToClipboard]=\"copyCodeToClipboard\"\n [copyCodeTooltips]=\"copyCodeTooltips\"\n ></td-copy-code-button>\n </div>\n</div>\n", styles: [":host ::ng-deep{overflow-x:auto;padding:16px;display:flex}:host ::ng-deep pre,:host ::ng-deep code,:host ::ng-deep .highlight{font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace}:host ::ng-deep pre{display:block;overflow-x:auto;padding:0;margin:0;background:transparent;font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace;line-height:1.45;-moz-tab-size:2;tab-size:2;-webkit-font-smoothing:auto;-webkit-text-size-adjust:none;text-size-adjust:none;position:relative;border-radius:2px;font-size:.8rem;width:100%}:host ::ng-deep code{margin:0;padding:0;overflow-wrap:break-word;white-space:pre-wrap}:host ::ng-deep .highlight{display:block;overflow-wrap:break-word;line-height:1.5;margin:0}:host ::ng-deep .copy-button{border:none;background:inherit;margin-top:-8px;margin-right:-8px}\n"] }]
211
+ }], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i1$1.DomSanitizer }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { content: [{
212
+ type: Input
213
+ }], copyCodeToClipboard: [{
214
+ type: Input
215
+ }], copyCodeTooltips: [{
216
+ type: Input
217
+ }], codeLang: [{
218
+ type: Input
219
+ }], lang: [{
220
+ type: Input
221
+ }], contentReady: [{
222
+ type: Output
223
+ }], highlightComp: [{
224
+ type: ViewChild,
225
+ args: ['highlightComponent']
226
+ }], copyComp: [{
227
+ type: ViewChild,
228
+ args: ['copyComponent']
229
+ }], tooltip: [{
230
+ type: ViewChild,
231
+ args: ['tooltip']
232
+ }] } });
280
233
 
281
234
  class CovalentHighlightModule {
282
235
  }
283
- /** @nocollapse */ /** @nocollapse */ CovalentHighlightModule.ɵfac = function CovalentHighlightModule_Factory(t) { return new (t || CovalentHighlightModule)(); };
284
- /** @nocollapse */ /** @nocollapse */ CovalentHighlightModule.ɵmod = /** @pureOrBreakMyCode */ i0.ɵɵdefineNgModule({ type: CovalentHighlightModule });
285
- /** @nocollapse */ /** @nocollapse */ CovalentHighlightModule.ɵinj = /** @pureOrBreakMyCode */ i0.ɵɵdefineInjector({ imports: [[CommonModule, ClipboardModule, MatIconModule, MatTooltipModule, MatButtonModule]] });
286
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CovalentHighlightModule, [{
287
- type: NgModule,
288
- args: [{
289
- imports: [CommonModule, ClipboardModule, MatIconModule, MatTooltipModule, MatButtonModule],
290
- declarations: [TdHighlightComponent, TdCopyCodeButtonComponent],
291
- exports: [TdHighlightComponent],
292
- }]
293
- }], null, null); })();
294
- (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(CovalentHighlightModule, { declarations: [TdHighlightComponent, TdCopyCodeButtonComponent], imports: [CommonModule, ClipboardModule, MatIconModule, MatTooltipModule, MatButtonModule], exports: [TdHighlightComponent] }); })();
236
+ CovalentHighlightModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentHighlightModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
237
+ CovalentHighlightModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentHighlightModule, declarations: [TdHighlightComponent, TdCopyCodeButtonComponent], imports: [CommonModule,
238
+ ClipboardModule,
239
+ MatIconModule,
240
+ MatTooltipModule,
241
+ MatButtonModule], exports: [TdHighlightComponent] });
242
+ CovalentHighlightModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentHighlightModule, imports: [[
243
+ CommonModule,
244
+ ClipboardModule,
245
+ MatIconModule,
246
+ MatTooltipModule,
247
+ MatButtonModule,
248
+ ]] });
249
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentHighlightModule, decorators: [{
250
+ type: NgModule,
251
+ args: [{
252
+ imports: [
253
+ CommonModule,
254
+ ClipboardModule,
255
+ MatIconModule,
256
+ MatTooltipModule,
257
+ MatButtonModule,
258
+ ],
259
+ declarations: [TdHighlightComponent, TdCopyCodeButtonComponent],
260
+ exports: [TdHighlightComponent],
261
+ }]
262
+ }] });
295
263
 
296
264
  /**
297
265
  * Generated bundle index. Do not edit.