@covalent/highlight 6.3.0-beta.4 → 6.4.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,267 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { Component, Input, ViewChild, HostListener, EventEmitter, SecurityContext, Output, NgModule } from '@angular/core';
3
- import * as i1$1 from '@angular/platform-browser';
4
- import * as i3 from '@angular/material/tooltip';
5
- import { MatTooltipModule } from '@angular/material/tooltip';
6
- import hljs from 'highlight.js';
7
- import * as i2$1 from '@angular/common';
8
- import { CommonModule } from '@angular/common';
9
- import * as i1 from '@angular/cdk/clipboard';
10
- import { ClipboardModule } from '@angular/cdk/clipboard';
11
- import * as i2 from '@angular/material/icon';
12
- import { MatIconModule } from '@angular/material/icon';
13
- import * as i4 from '@angular/material/button';
14
- import { MatButtonModule } from '@angular/material/button';
15
-
16
- class TdCopyCodeButtonComponent {
17
- constructor() {
18
- this.copyCodeToClipboard = false;
19
- /**
20
- * copyCodeTooltips?: ICopyCodeTooltips
21
- *
22
- * Tooltips for copy button to copy and upon copying.
23
- */
24
- this.copyCodeTooltips = {};
25
- }
26
- get copyTooltip() {
27
- return (this.copyCodeTooltips && this.copyCodeTooltips.copy) || 'Copy';
28
- }
29
- get copiedTooltip() {
30
- return (this.copyCodeTooltips && this.copyCodeTooltips.copied) || 'Copied';
31
- }
32
- textCopied(event) {
33
- if (event) {
34
- this.tooltip.hide();
35
- this.tooltip.message = this.copiedTooltip;
36
- this.tooltip.show();
37
- }
38
- }
39
- initializeTooltip() {
40
- setTimeout(() => {
41
- this.tooltip.message = this.copyTooltip;
42
- }, 200);
43
- }
44
- }
45
- TdCopyCodeButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: TdCopyCodeButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
46
- TdCopyCodeButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", 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: [""], dependencies: [{ kind: "directive", type: i1.CdkCopyToClipboard, selector: "[cdkCopyToClipboard]", inputs: ["cdkCopyToClipboard", "cdkCopyToClipboardAttempts"], outputs: ["cdkCopyToClipboardCopied"] }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i3.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "component", type: i4.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }] });
47
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", 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" }]
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
- }] } });
63
-
64
- class TdHighlightComponent {
65
- /**
66
- * content?: string
67
- *
68
- * Code content to be parsed as highlighted html.
69
- * Used to load data dynamically.
70
- *
71
- * e.g. `.html`, `.ts` , etc.
72
- */
73
- set content(content) {
74
- this._content = content;
75
- if (this._initialized) {
76
- this._loadContent(this._content);
77
- }
78
- }
79
- /**
80
- * lang?: string
81
- *
82
- * Language of the code content to be parsed as highlighted html.
83
- * Defaults to `typescript`
84
- *
85
- * e.g. `typescript`, `html` , etc.
86
- */
87
- set codeLang(lang) {
88
- this.setLanguage(lang);
89
- }
90
- /** @deprecated - removed completely @4.0.0 */
91
- set lang(lang) {
92
- // tslint:disable-next-line: no-console
93
- console.warn('DEPRECATION WARNING: switch to codeLang attribute as lang attribute is deprecated.');
94
- this.setLanguage(lang);
95
- }
96
- constructor(_renderer, _elementRef, _domSanitizer, cdr) {
97
- this._renderer = _renderer;
98
- this._elementRef = _elementRef;
99
- this._domSanitizer = _domSanitizer;
100
- this.cdr = cdr;
101
- this._initialized = false;
102
- this._lang = 'typescript';
103
- /**
104
- * copyCodeToClipboard?: boolean
105
- *
106
- * Display copy button on code snippets to copy code to clipboard.
107
- */
108
- this.copyCodeToClipboard = false;
109
- /**
110
- * copyCodeTooltips?: ICopyCodeTooltips
111
- *
112
- * Tooltips for copy button to copy and upon copying.
113
- */
114
- this.copyCodeTooltips = {};
115
- /**
116
- * contentReady?: function
117
- * Event emitted after the highlight content rendering is finished.
118
- */
119
- this.contentReady = new EventEmitter();
120
- }
121
- ngAfterViewChecked() {
122
- this.cdr.detectChanges();
123
- }
124
- ngAfterViewInit() {
125
- if (!this._content) {
126
- this._loadContent(this.highlightComp.nativeElement.textContent);
127
- }
128
- else {
129
- this._loadContent(this._content);
130
- }
131
- this._initialized = true;
132
- }
133
- setLanguage(lang) {
134
- if (!lang) {
135
- throw new Error('Error: language attribute must be defined in TdHighlightComponent.');
136
- }
137
- this._lang = lang;
138
- if (this._initialized) {
139
- this._loadContent(this._content);
140
- }
141
- }
142
- /**
143
- * General method to parse a string of code into HTML Elements and load them into the container
144
- */
145
- _loadContent(code) {
146
- if (code && code.trim().length > 0) {
147
- // Clean container
148
- this._renderer.setProperty(this._elementRef.nativeElement, 'innerHTML', '');
149
- // Parse html string into actual HTML elements.
150
- this._elementFromString(this._render(code));
151
- if (this.copyCodeToClipboard) {
152
- this._renderer.appendChild(this._elementRef.nativeElement, this.copyComp.nativeElement);
153
- }
154
- }
155
- this.contentReady.emit();
156
- }
157
- _elementFromString(codeStr) {
158
- // Renderer2 doesnt have a parsing method, so we have to sanitize and use [innerHTML]
159
- // to parse the string into DOM element for now.
160
- const preElement = this._renderer.createElement('pre');
161
- this._renderer.appendChild(this._elementRef.nativeElement, preElement);
162
- const codeElement = this._renderer.createElement('code');
163
- this._renderer.appendChild(preElement, codeElement);
164
- // Set .highlight class into <code> element
165
- this._renderer.addClass(codeElement, 'highlight');
166
- codeElement.innerHTML =
167
- this._domSanitizer.sanitize(SecurityContext.HTML, codeStr) ?? '';
168
- return preElement;
169
- }
170
- _render(contents) {
171
- // Trim leading and trailing newlines
172
- contents = contents
173
- .replace(/^(\s|\t)*\n+/g, '')
174
- .replace(/(\s|\t)*\n+(\s|\t)*$/g, '');
175
- // Split markup by line characters
176
- let lines = contents.split('\n');
177
- // check how much indentation is used by the first actual code line
178
- const firstLineWhitespaceMatch = lines[0].match(/^(\s|\t)*/);
179
- const firstLineWhitespace = firstLineWhitespaceMatch
180
- ? firstLineWhitespaceMatch[0]
181
- : null;
182
- // Remove all indentation spaces so code can be parsed correctly
183
- const startingWhitespaceRegex = new RegExp('^' + firstLineWhitespace);
184
- lines = lines.map(function (line) {
185
- return line
186
- .replace('=""', '') // remove empty values
187
- .replace(startingWhitespaceRegex, '')
188
- .replace(/\s+$/, ''); // remove trailing white spaces
189
- });
190
- const codeToParse = lines
191
- .join('\n')
192
- .replace(/\{ \{/gi, '{{')
193
- .replace(/\} \}/gi, '}}')
194
- .replace(/&lt;/gi, '<')
195
- .replace(/&gt;/gi, '>'); // replace with < and > to render HTML in Angular
196
- this.copyContent = codeToParse;
197
- // Parse code with highlight.js depending on language
198
- const highlightedCode = hljs.highlight(this._lang, codeToParse, true);
199
- highlightedCode.value = highlightedCode.value
200
- .replace(/=<span class="hljs-value">""<\/span>/gi, '')
201
- .replace('<head>', '')
202
- .replace('<head/>', '');
203
- return highlightedCode.value;
204
- }
205
- }
206
- TdHighlightComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", 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: "14.0.0", version: "15.2.5", 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;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"], dependencies: [{ kind: "directive", type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: TdCopyCodeButtonComponent, selector: "td-copy-code-button", inputs: ["copiedContent", "copyCodeToClipboard", "copyCodeTooltips"] }] });
208
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", 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;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
- }] } });
233
-
234
- class CovalentHighlightModule {
235
- }
236
- CovalentHighlightModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: CovalentHighlightModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
237
- CovalentHighlightModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.5", 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: "15.2.5", ngImport: i0, type: CovalentHighlightModule, imports: [CommonModule,
243
- ClipboardModule,
244
- MatIconModule,
245
- MatTooltipModule,
246
- MatButtonModule] });
247
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: CovalentHighlightModule, decorators: [{
248
- type: NgModule,
249
- args: [{
250
- imports: [
251
- CommonModule,
252
- ClipboardModule,
253
- MatIconModule,
254
- MatTooltipModule,
255
- MatButtonModule,
256
- ],
257
- declarations: [TdHighlightComponent, TdCopyCodeButtonComponent],
258
- exports: [TdHighlightComponent],
259
- }]
260
- }] });
261
-
262
- /**
263
- * Generated bundle index. Do not edit.
264
- */
265
-
266
- export { CovalentHighlightModule, TdCopyCodeButtonComponent, TdHighlightComponent };
267
- //# sourceMappingURL=covalent-highlight.mjs.map
@@ -1 +0,0 @@
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":["i1","i2","i3.TdCopyCodeButtonComponent"],"mappings":";;;;;;;;;;;;;;;MAaa,yBAAyB,CAAA;AALtC,IAAA,WAAA,GAAA;QAQW,IAAmB,CAAA,mBAAA,GAAG,KAAK,CAAC;AACrC;;;;AAIG;QACM,IAAgB,CAAA,gBAAA,GAAuB,EAAE,CAAC;AAyBpD,KAAA;AAvBC,IAAA,IAAI,WAAW,GAAA;AACb,QAAA,OAAO,CAAC,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,KAAK,MAAM,CAAC;KACxE;AAED,IAAA,IAAI,aAAa,GAAA;AACf,QAAA,OAAO,CAAC,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,KAAK,QAAQ,CAAC;KAC5E;AAID,IAAA,UAAU,CAAC,KAAc,EAAA;AACvB,QAAA,IAAI,KAAK,EAAE;AACT,YAAA,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC;AAC1C,YAAA,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;AACrB,SAAA;KACF;IAED,iBAAiB,GAAA;QACf,UAAU,CAAC,MAAK;YACd,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC;SACzC,EAAE,GAAG,CAAC,CAAC;KACT;;sHAjCU,yBAAyB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA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