@covalent/highlight 4.0.0 → 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.
Files changed (34) hide show
  1. package/README.md +33 -151
  2. package/_highlight-theme.scss +5 -1
  3. package/covalent-highlight.d.ts +2 -1
  4. package/esm2020/covalent-highlight.mjs +5 -0
  5. package/esm2020/lib/copy-code-button/copy-code-button.component.mjs +55 -0
  6. package/esm2020/lib/highlight.component.mjs +178 -0
  7. package/esm2020/lib/highlight.module.mjs +39 -0
  8. package/esm2020/public_api.mjs +4 -0
  9. package/fesm2015/covalent-highlight.mjs +270 -0
  10. package/fesm2015/covalent-highlight.mjs.map +1 -0
  11. package/fesm2020/covalent-highlight.mjs +269 -0
  12. package/fesm2020/covalent-highlight.mjs.map +1 -0
  13. package/{copy-code-button → lib/copy-code-button}/copy-code-button.component.d.ts +4 -1
  14. package/{highlight.component.d.ts → lib/highlight.component.d.ts} +6 -3
  15. package/lib/highlight.module.d.ts +13 -0
  16. package/package.json +29 -33
  17. package/public_api.d.ts +3 -3
  18. package/bundles/covalent-highlight.umd.js +0 -444
  19. package/bundles/covalent-highlight.umd.js.map +0 -1
  20. package/bundles/covalent-highlight.umd.min.js +0 -2
  21. package/bundles/covalent-highlight.umd.min.js.map +0 -1
  22. package/copy-code-button/copy-code-button.component.scss +0 -0
  23. package/covalent-highlight.metadata.json +0 -1
  24. package/esm2015/copy-code-button/copy-code-button.component.js +0 -92
  25. package/esm2015/covalent-highlight.js +0 -10
  26. package/esm2015/highlight.component.js +0 -286
  27. package/esm2015/highlight.module.js +0 -23
  28. package/esm2015/index.js +0 -7
  29. package/esm2015/public_api.js +0 -9
  30. package/fesm2015/covalent-highlight.js +0 -416
  31. package/fesm2015/covalent-highlight.js.map +0 -1
  32. package/highlight.component.scss +0 -49
  33. package/highlight.module.d.ts +0 -2
  34. package/index.d.ts +0 -1
@@ -1,416 +0,0 @@
1
- import { EventEmitter, SecurityContext, Component, Renderer2, ElementRef, ChangeDetectorRef, Input, Output, ViewChild, HostListener, NgModule } from '@angular/core';
2
- import { DomSanitizer } from '@angular/platform-browser';
3
- import { MatTooltipModule } from '@angular/material/tooltip';
4
- import { CommonModule } from '@angular/common';
5
- import { ClipboardModule } from '@angular/cdk/clipboard';
6
- import { MatIconModule } from '@angular/material/icon';
7
- import { MatButtonModule } from '@angular/material/button';
8
-
9
- /**
10
- * @fileoverview added by tsickle
11
- * Generated from: highlight.component.ts
12
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
13
- */
14
- /* tslint:disable-next-line */
15
- /** @type {?} */
16
- let hljs = require('highlight.js/lib');
17
- class TdHighlightComponent {
18
- /**
19
- * @param {?} _renderer
20
- * @param {?} _elementRef
21
- * @param {?} _domSanitizer
22
- * @param {?} cdr
23
- */
24
- constructor(_renderer, _elementRef, _domSanitizer, cdr) {
25
- this._renderer = _renderer;
26
- this._elementRef = _elementRef;
27
- this._domSanitizer = _domSanitizer;
28
- this.cdr = cdr;
29
- this._initialized = false;
30
- this._lang = 'typescript';
31
- /**
32
- * copyCodeToClipboard?: boolean
33
- *
34
- * Display copy button on code snippets to copy code to clipboard.
35
- */
36
- this.copyCodeToClipboard = false;
37
- /**
38
- * copyCodeTooltips?: ICopyCodeTooltips
39
- *
40
- * Tooltips for copy button to copy and upon copying.
41
- */
42
- this.copyCodeTooltips = {};
43
- /**
44
- * contentReady?: function
45
- * Event emitted after the highlight content rendering is finished.
46
- */
47
- this.contentReady = new EventEmitter();
48
- }
49
- /**
50
- * content?: string
51
- *
52
- * Code content to be parsed as highlighted html.
53
- * Used to load data dynamically.
54
- *
55
- * e.g. `.html`, `.ts` , etc.
56
- * @param {?} content
57
- * @return {?}
58
- */
59
- set content(content) {
60
- this._content = content;
61
- if (this._initialized) {
62
- this._loadContent(this._content);
63
- }
64
- }
65
- /**
66
- * lang?: string
67
- *
68
- * Language of the code content to be parsed as highlighted html.
69
- * Defaults to `typescript`
70
- *
71
- * e.g. `typescript`, `html` , etc.
72
- * @param {?} lang
73
- * @return {?}
74
- */
75
- set codeLang(lang) {
76
- this.setLanguage(lang);
77
- }
78
- /**
79
- * @deprecated - removed completely \@4.0.0
80
- * @param {?} lang
81
- * @return {?}
82
- */
83
- set lang(lang) {
84
- // tslint:disable-next-line: no-console
85
- console.warn('DEPRECATION WARNING: switch to codeLang attribute as lang attribute is deprecated.');
86
- this.setLanguage(lang);
87
- }
88
- /**
89
- * @return {?}
90
- */
91
- ngAfterViewChecked() {
92
- this.cdr.detectChanges();
93
- }
94
- /**
95
- * @return {?}
96
- */
97
- ngAfterViewInit() {
98
- if (!this._content) {
99
- this._loadContent(((/** @type {?} */ (this.highlightComp.nativeElement))).textContent);
100
- }
101
- else {
102
- this._loadContent(this._content);
103
- }
104
- this._initialized = true;
105
- }
106
- /**
107
- * @param {?} lang
108
- * @return {?}
109
- */
110
- setLanguage(lang) {
111
- if (!lang) {
112
- throw new Error('Error: language attribute must be defined in TdHighlightComponent.');
113
- }
114
- this._lang = lang;
115
- if (this._initialized) {
116
- this._loadContent(this._content);
117
- }
118
- }
119
- /**
120
- * General method to parse a string of code into HTML Elements and load them into the container
121
- * @private
122
- * @param {?} code
123
- * @return {?}
124
- */
125
- _loadContent(code) {
126
- if (code && code.trim().length > 0) {
127
- // Clean container
128
- this._renderer.setProperty(this._elementRef.nativeElement, 'innerHTML', '');
129
- // Parse html string into actual HTML elements.
130
- this._elementFromString(this._render(code));
131
- if (this.copyCodeToClipboard) {
132
- this._renderer.appendChild(this._elementRef.nativeElement, this.copyComp.nativeElement);
133
- }
134
- }
135
- this.contentReady.emit();
136
- }
137
- /**
138
- * @private
139
- * @param {?} codeStr
140
- * @return {?}
141
- */
142
- _elementFromString(codeStr) {
143
- // Renderer2 doesnt have a parsing method, so we have to sanitize and use [innerHTML]
144
- // to parse the string into DOM element for now.
145
- /** @type {?} */
146
- const preElement = this._renderer.createElement('pre');
147
- this._renderer.appendChild(this._elementRef.nativeElement, preElement);
148
- /** @type {?} */
149
- const codeElement = this._renderer.createElement('code');
150
- this._renderer.appendChild(preElement, codeElement);
151
- // Set .highlight class into <code> element
152
- this._renderer.addClass(codeElement, 'highlight');
153
- codeElement.innerHTML = this._domSanitizer.sanitize(SecurityContext.HTML, codeStr);
154
- return preElement;
155
- }
156
- /**
157
- * @private
158
- * @param {?} contents
159
- * @return {?}
160
- */
161
- _render(contents) {
162
- // Trim leading and trailing newlines
163
- contents = contents.replace(/^(\s|\t)*\n+/g, '').replace(/(\s|\t)*\n+(\s|\t)*$/g, '');
164
- // Split markup by line characters
165
- /** @type {?} */
166
- let lines = contents.split('\n');
167
- // check how much indentation is used by the first actual code line
168
- /** @type {?} */
169
- const firstLineWhitespace = lines[0].match(/^(\s|\t)*/)[0];
170
- // Remove all indentation spaces so code can be parsed correctly
171
- /** @type {?} */
172
- const startingWhitespaceRegex = new RegExp('^' + firstLineWhitespace);
173
- lines = lines.map((/**
174
- * @param {?} line
175
- * @return {?}
176
- */
177
- function (line) {
178
- return line
179
- .replace('=""', '') // remove empty values
180
- .replace(startingWhitespaceRegex, '')
181
- .replace(/\s+$/, ''); // remove trailing white spaces
182
- }));
183
- /** @type {?} */
184
- const codeToParse = lines
185
- .join('\n')
186
- .replace(/\{ \{/gi, '{{')
187
- .replace(/\} \}/gi, '}}')
188
- .replace(/&lt;/gi, '<')
189
- .replace(/&gt;/gi, '>');
190
- this.copyContent = codeToParse;
191
- // Parse code with highlight.js depending on language
192
- /** @type {?} */
193
- const highlightedCode = hljs.highlight(this._lang, codeToParse, true);
194
- highlightedCode.value = highlightedCode.value
195
- .replace(/=<span class="hljs-value">""<\/span>/gi, '')
196
- .replace('<head>', '')
197
- .replace('<head/>', '');
198
- return highlightedCode.value;
199
- }
200
- }
201
- TdHighlightComponent.decorators = [
202
- { type: Component, args: [{
203
- selector: 'td-highlight',
204
- 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",
205
- styles: [":host ::ng-deep{display:-ms-flexbox;display:flex;overflow-x:auto;padding:16px}:host ::ng-deep .highlight,:host ::ng-deep code,:host ::ng-deep pre{font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace}:host ::ng-deep pre{-moz-tab-size:2;-o-tab-size:2;-webkit-font-smoothing:auto;-webkit-text-size-adjust:none;background:rgba(0,0,0,0);border-radius:2px;display:block;font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace;font-size:.8rem;line-height:1.45;margin:0;overflow-x:auto;padding:0;position:relative;tab-size:2;width:100%}:host ::ng-deep code{margin:0;overflow-wrap:break-word;padding:0;white-space:pre-wrap}:host ::ng-deep .highlight{display:block;line-height:1.5;margin:0;overflow-wrap:break-word}:host ::ng-deep .copy-button{background:inherit;border:none;margin-right:-8px;margin-top:-8px}"]
206
- }] }
207
- ];
208
- /** @nocollapse */
209
- TdHighlightComponent.ctorParameters = () => [
210
- { type: Renderer2 },
211
- { type: ElementRef },
212
- { type: DomSanitizer },
213
- { type: ChangeDetectorRef }
214
- ];
215
- TdHighlightComponent.propDecorators = {
216
- content: [{ type: Input, args: ['content',] }],
217
- copyCodeToClipboard: [{ type: Input }],
218
- copyCodeTooltips: [{ type: Input }],
219
- codeLang: [{ type: Input, args: ['codeLang',] }],
220
- lang: [{ type: Input }],
221
- contentReady: [{ type: Output }],
222
- highlightComp: [{ type: ViewChild, args: ['highlightComponent',] }],
223
- copyComp: [{ type: ViewChild, args: ['copyComponent',] }],
224
- tooltip: [{ type: ViewChild, args: ['tooltip',] }]
225
- };
226
- if (false) {
227
- /**
228
- * @type {?}
229
- * @private
230
- */
231
- TdHighlightComponent.prototype._initialized;
232
- /**
233
- * @type {?}
234
- * @private
235
- */
236
- TdHighlightComponent.prototype._content;
237
- /**
238
- * @type {?}
239
- * @private
240
- */
241
- TdHighlightComponent.prototype._lang;
242
- /**
243
- * copyCodeToClipboard?: boolean
244
- *
245
- * Display copy button on code snippets to copy code to clipboard.
246
- * @type {?}
247
- */
248
- TdHighlightComponent.prototype.copyCodeToClipboard;
249
- /**
250
- * copyCodeTooltips?: ICopyCodeTooltips
251
- *
252
- * Tooltips for copy button to copy and upon copying.
253
- * @type {?}
254
- */
255
- TdHighlightComponent.prototype.copyCodeTooltips;
256
- /** @type {?} */
257
- TdHighlightComponent.prototype.copyContent;
258
- /**
259
- * contentReady?: function
260
- * Event emitted after the highlight content rendering is finished.
261
- * @type {?}
262
- */
263
- TdHighlightComponent.prototype.contentReady;
264
- /** @type {?} */
265
- TdHighlightComponent.prototype.highlightComp;
266
- /** @type {?} */
267
- TdHighlightComponent.prototype.copyComp;
268
- /** @type {?} */
269
- TdHighlightComponent.prototype.tooltip;
270
- /**
271
- * @type {?}
272
- * @private
273
- */
274
- TdHighlightComponent.prototype._renderer;
275
- /**
276
- * @type {?}
277
- * @private
278
- */
279
- TdHighlightComponent.prototype._elementRef;
280
- /**
281
- * @type {?}
282
- * @private
283
- */
284
- TdHighlightComponent.prototype._domSanitizer;
285
- /**
286
- * @type {?}
287
- * @private
288
- */
289
- TdHighlightComponent.prototype.cdr;
290
- }
291
-
292
- /**
293
- * @fileoverview added by tsickle
294
- * Generated from: copy-code-button/copy-code-button.component.ts
295
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
296
- */
297
- /**
298
- * @record
299
- */
300
- function ICopyCodeTooltips() { }
301
- if (false) {
302
- /** @type {?|undefined} */
303
- ICopyCodeTooltips.prototype.copy;
304
- /** @type {?|undefined} */
305
- ICopyCodeTooltips.prototype.copied;
306
- }
307
- class TdCopyCodeButtonComponent {
308
- constructor() {
309
- this.copyCodeToClipboard = false;
310
- /**
311
- * copyCodeTooltips?: ICopyCodeTooltips
312
- *
313
- * Tooltips for copy button to copy and upon copying.
314
- */
315
- this.copyCodeTooltips = {};
316
- }
317
- /**
318
- * @return {?}
319
- */
320
- get copyTooltip() {
321
- return (this.copyCodeTooltips && this.copyCodeTooltips.copy) || 'Copy';
322
- }
323
- /**
324
- * @return {?}
325
- */
326
- get copiedTooltip() {
327
- return (this.copyCodeTooltips && this.copyCodeTooltips.copied) || 'Copied';
328
- }
329
- /**
330
- * @param {?} event
331
- * @return {?}
332
- */
333
- textCopied(event) {
334
- if (event) {
335
- this.tooltip.hide();
336
- this.tooltip.message = this.copiedTooltip;
337
- this.tooltip.show();
338
- }
339
- }
340
- /**
341
- * @return {?}
342
- */
343
- initializeTooltip() {
344
- setTimeout((/**
345
- * @return {?}
346
- */
347
- () => {
348
- this.tooltip.message = this.copyTooltip;
349
- }), 200);
350
- }
351
- }
352
- TdCopyCodeButtonComponent.decorators = [
353
- { type: Component, args: [{
354
- selector: 'td-copy-code-button',
355
- 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",
356
- styles: [""]
357
- }] }
358
- ];
359
- TdCopyCodeButtonComponent.propDecorators = {
360
- copiedContent: [{ type: Input }],
361
- copyCodeToClipboard: [{ type: Input }],
362
- copyCodeTooltips: [{ type: Input }],
363
- tooltip: [{ type: ViewChild, args: ['tooltip',] }],
364
- initializeTooltip: [{ type: HostListener, args: ['mouseleave',] }]
365
- };
366
- if (false) {
367
- /** @type {?} */
368
- TdCopyCodeButtonComponent.prototype.copiedContent;
369
- /** @type {?} */
370
- TdCopyCodeButtonComponent.prototype.copyCodeToClipboard;
371
- /**
372
- * copyCodeTooltips?: ICopyCodeTooltips
373
- *
374
- * Tooltips for copy button to copy and upon copying.
375
- * @type {?}
376
- */
377
- TdCopyCodeButtonComponent.prototype.copyCodeTooltips;
378
- /** @type {?} */
379
- TdCopyCodeButtonComponent.prototype.tooltip;
380
- }
381
-
382
- /**
383
- * @fileoverview added by tsickle
384
- * Generated from: highlight.module.ts
385
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
386
- */
387
- class CovalentHighlightModule {
388
- }
389
- CovalentHighlightModule.decorators = [
390
- { type: NgModule, args: [{
391
- imports: [CommonModule, ClipboardModule, MatIconModule, MatTooltipModule, MatButtonModule],
392
- declarations: [TdHighlightComponent, TdCopyCodeButtonComponent],
393
- exports: [TdHighlightComponent],
394
- },] }
395
- ];
396
-
397
- /**
398
- * @fileoverview added by tsickle
399
- * Generated from: public_api.ts
400
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
401
- */
402
-
403
- /**
404
- * @fileoverview added by tsickle
405
- * Generated from: index.ts
406
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
407
- */
408
-
409
- /**
410
- * @fileoverview added by tsickle
411
- * Generated from: covalent-highlight.ts
412
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
413
- */
414
-
415
- export { CovalentHighlightModule, TdCopyCodeButtonComponent, TdHighlightComponent };
416
- //# sourceMappingURL=covalent-highlight.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"covalent-highlight.js","sources":["../../../../src/platform/highlight/highlight.component.ts","../../../src/platform/highlight/copy-code-button/copy-code-button.component.ts","../../../../src/platform/highlight/highlight.module.ts"],"sourcesContent":["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 { 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","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"],"names":[],"mappings":";;;;;;;;;;;;;;;IAoBI,IAAI,GAAQ,OAAO,CAAC,kBAAkB,CAAC;MAO9B,oBAAoB;;;;;;;IAqE/B,YACU,SAAoB,EACpB,WAAuB,EACvB,aAA2B,EAC3B,GAAsB;QAHtB,cAAS,GAAT,SAAS,CAAW;QACpB,gBAAW,GAAX,WAAW,CAAY;QACvB,kBAAa,GAAb,aAAa,CAAc;QAC3B,QAAG,GAAH,GAAG,CAAmB;QAxExB,iBAAY,GAAY,KAAK,CAAC;QAG9B,UAAK,GAAW,YAAY,CAAC;;;;;;QAuB5B,wBAAmB,GAAY,KAAK,CAAC;;;;;;QAOrC,qBAAgB,GAAsB,EAAE,CAAC;;;;;QA6BxC,iBAAY,GAAuB,IAAI,YAAY,EAAQ,CAAC;KAWlE;;;;;;;;;;;IA5DJ,IACI,OAAO,CAAC,OAAe;QACzB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAClC;KACF;;;;;;;;;;;IAyBD,IACI,QAAQ,CAAC,IAAY;QACvB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;KACxB;;;;;;IAED,IACI,IAAI,CAAC,IAAY;;QAEnB,OAAO,CAAC,IAAI,CAAC,oFAAoF,CAAC,CAAC;QACnG,IAAI,CAAC,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auto;
6
- padding: $padding;
7
- display: flex;
8
- pre,
9
- code,
10
- .highlight {
11
- font-family: $code-font;
12
- }
13
- pre {
14
- display: block;
15
- overflow-x: auto;
16
- padding: 0;
17
- margin: 0;
18
- background: transparent;
19
- font-family: $code-font;
20
- line-height: 1.45;
21
- tab-size: 2;
22
- -webkit-font-smoothing: auto;
23
- -webkit-text-size-adjust: none;
24
- position: relative;
25
- border-radius: 2px;
26
- font-size: 0.8rem;
27
- width: 100%;
28
- }
29
-
30
- code {
31
- margin: 0;
32
- padding: 0;
33
- overflow-wrap: break-word;
34
- white-space: pre-wrap;
35
- }
36
-
37
- .highlight {
38
- display: block;
39
- overflow-wrap: break-word;
40
- line-height: 1.5;
41
- margin: 0;
42
- }
43
- .copy-button {
44
- border: none;
45
- background: inherit;
46
- margin-top: -8px;
47
- margin-right: -8px;
48
- }
49
- }
@@ -1,2 +0,0 @@
1
- export declare class CovalentHighlightModule {
2
- }
package/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './public_api';