@covalent/highlight 3.1.0 → 3.1.2-beta.6

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.
package/README.md CHANGED
@@ -16,6 +16,9 @@ By default, `--dev` build will log the following message in the console to let y
16
16
 
17
17
  + lang: string
18
18
  + Language of the code content to be parsed as highlighted html.
19
+ > **DEPRECATION WARNING: lang attribute is deprecated and it will be removed in v4.0.0**
20
+ + codeLang: string
21
+ + Language of the code content to be parsed as highlighted html.
19
22
  + content: string
20
23
  + Code content to be parsed as highlighted html. Used to load data dynamically. e.g. `.ts` content.
21
24
  + copyCodeToClipboard?: boolean
@@ -98,14 +101,14 @@ Example for **HTML** usage:
98
101
  ```typescript
99
102
  @Component({
100
103
  template: `
101
- <td-highlight lang="html">
104
+ <td-highlight codeLang="html">
102
105
  {{ code }}
103
106
  </td-highlight>
104
107
  `,
105
108
  })
106
109
  class ExampleComponent {
107
110
  code: string = `
108
- <td-highlight lang="html">
111
+ <td-highlight codeLang="html">
109
112
  <h1>hello world!</h1>
110
113
  <span>{ {property} }</span>
111
114
  </td-highlight>
@@ -116,7 +119,7 @@ Example for **CSS** usage:
116
119
  ```typescript
117
120
  @Component({
118
121
  template: `
119
- <td-highlight lang="css">
122
+ <td-highlight codeLang="css">
120
123
  {{ code }}
121
124
  </td-highlight>
122
125
  `,
@@ -145,7 +148,7 @@ Example for **Typescript**:
145
148
  ```typescript
146
149
  @Component({
147
150
  template: `
148
- <td-highlight lang="typescript">
151
+ <td-highlight codeLang="typescript">
149
152
  {{ code }}
150
153
  </td-highlight>
151
154
  `,
@@ -1,15 +1,24 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('highlight.js/lib'), require('@angular/core'), require('@angular/platform-browser'), require('@angular/material/tooltip'), require('@angular/common'), require('@angular/cdk/clipboard'), require('@angular/material/icon'), require('@angular/material/button')) :
3
- typeof define === 'function' && define.amd ? define('@covalent/highlight', ['exports', 'highlight.js/lib', '@angular/core', '@angular/platform-browser', '@angular/material/tooltip', '@angular/common', '@angular/cdk/clipboard', '@angular/material/icon', '@angular/material/button'], factory) :
4
- (global = global || self, factory((global.covalent = global.covalent || {}, global.covalent.highlight = {}), global.lib, global.ng.core, global.ng.platformBrowser, global.ng.material.tooltip, global.ng.common, global.ng.cdk.clipboard, global.ng.material.icon, global.ng.material.button));
5
- }(this, (function (exports, lib, core, platformBrowser, tooltip, common, clipboard, icon, button) { 'use strict';
6
-
7
- lib = lib && Object.prototype.hasOwnProperty.call(lib, 'default') ? lib['default'] : lib;
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/platform-browser'), require('@angular/common'), require('@angular/cdk/clipboard'), require('@angular/material/icon'), require('@angular/material/tooltip'), require('@angular/material/button')) :
3
+ typeof define === 'function' && define.amd ? define('@covalent/highlight', ['exports', '@angular/core', '@angular/platform-browser', '@angular/common', '@angular/cdk/clipboard', '@angular/material/icon', '@angular/material/tooltip', '@angular/material/button'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.covalent = global.covalent || {}, global.covalent.highlight = {}), global.ng.core, global.ng.platformBrowser, global.ng.common, global.ng.cdk.clipboard, global.ng.material.icon, global.ng.material.tooltip, global.ng.material.button));
5
+ }(this, (function (exports, core, platformBrowser, common, clipboard, icon, tooltip, button) { 'use strict';
8
6
 
7
+ /**
8
+ * @fileoverview added by tsickle
9
+ * Generated from: highlight.component.ts
10
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
11
+ */
9
12
  /* tslint:disable-next-line */
10
13
  /** @type {?} */
11
-
14
+ var hljs = require('highlight.js/lib');
12
15
  var TdHighlightComponent = /** @class */ (function () {
16
+ /**
17
+ * @param {?} _renderer
18
+ * @param {?} _elementRef
19
+ * @param {?} _domSanitizer
20
+ * @param {?} cdr
21
+ */
13
22
  function TdHighlightComponent(_renderer, _elementRef, _domSanitizer, cdr) {
14
23
  this._renderer = _renderer;
15
24
  this._elementRef = _elementRef;
@@ -37,14 +46,6 @@
37
46
  }
38
47
  Object.defineProperty(TdHighlightComponent.prototype, "content", {
39
48
  /**
40
- * content?: string
41
- *
42
- * Code content to be parsed as highlighted html.
43
- * Used to load data dynamically.
44
- *
45
- * e.g. `.html`, `.ts` , etc.
46
- */
47
- set: /**
48
49
  * content?: string
49
50
  *
50
51
  * Code content to be parsed as highlighted html.
@@ -54,16 +55,16 @@
54
55
  * @param {?} content
55
56
  * @return {?}
56
57
  */
57
- function (content) {
58
+ set: function (content) {
58
59
  this._content = content;
59
60
  if (this._initialized) {
60
61
  this._loadContent(this._content);
61
62
  }
62
63
  },
63
- enumerable: true,
64
+ enumerable: false,
64
65
  configurable: true
65
66
  });
66
- Object.defineProperty(TdHighlightComponent.prototype, "lang", {
67
+ Object.defineProperty(TdHighlightComponent.prototype, "codeLang", {
67
68
  /**
68
69
  * lang?: string
69
70
  *
@@ -71,47 +72,41 @@
71
72
  * Defaults to `typescript`
72
73
  *
73
74
  * e.g. `typescript`, `html` , etc.
75
+ * @param {?} lang
76
+ * @return {?}
74
77
  */
75
- set: /**
76
- * lang?: string
77
- *
78
- * Language of the code content to be parsed as highlighted html.
79
- * Defaults to `typescript`
80
- *
81
- * e.g. `typescript`, `html` , etc.
78
+ set: function (lang) {
79
+ this.setLanguage(lang);
80
+ },
81
+ enumerable: false,
82
+ configurable: true
83
+ });
84
+ Object.defineProperty(TdHighlightComponent.prototype, "lang", {
85
+ /**
86
+ * @deprecated - removed completely \@4.0.0
82
87
  * @param {?} lang
83
88
  * @return {?}
84
89
  */
85
- function (lang) {
86
- if (!lang) {
87
- throw new Error('Error: language attribute must be defined in TdHighlightComponent.');
88
- }
89
- this._lang = lang;
90
- if (this._initialized) {
91
- this._loadContent(this._content);
92
- }
90
+ set: function (lang) {
91
+ // tslint:disable-next-line: no-console
92
+ console.warn('DEPRECATION WARNING: switch to codeLang attribute as lang attribute is deprecated.');
93
+ this.setLanguage(lang);
93
94
  },
94
- enumerable: true,
95
+ enumerable: false,
95
96
  configurable: true
96
97
  });
97
98
  /**
98
99
  * @return {?}
99
100
  */
100
- TdHighlightComponent.prototype.ngAfterViewChecked = /**
101
- * @return {?}
102
- */
103
- function () {
101
+ TdHighlightComponent.prototype.ngAfterViewChecked = function () {
104
102
  this.cdr.detectChanges();
105
103
  };
106
104
  /**
107
105
  * @return {?}
108
106
  */
109
- TdHighlightComponent.prototype.ngAfterViewInit = /**
110
- * @return {?}
111
- */
112
- function () {
107
+ TdHighlightComponent.prototype.ngAfterViewInit = function () {
113
108
  if (!this._content) {
114
- this._loadContent(((/** @type {?} */ (this.highlightComp.nativeElement))).textContent);
109
+ this._loadContent((( /** @type {?} */(this.highlightComp.nativeElement))).textContent);
115
110
  }
116
111
  else {
117
112
  this._loadContent(this._content);
@@ -119,21 +114,25 @@
119
114
  this._initialized = true;
120
115
  };
121
116
  /**
122
- * General method to parse a string of code into HTML Elements and load them into the container
123
- */
124
- /**
125
- * General method to parse a string of code into HTML Elements and load them into the container
126
- * @private
127
- * @param {?} code
117
+ * @param {?} lang
128
118
  * @return {?}
129
119
  */
130
- TdHighlightComponent.prototype._loadContent = /**
120
+ TdHighlightComponent.prototype.setLanguage = function (lang) {
121
+ if (!lang) {
122
+ throw new Error('Error: language attribute must be defined in TdHighlightComponent.');
123
+ }
124
+ this._lang = lang;
125
+ if (this._initialized) {
126
+ this._loadContent(this._content);
127
+ }
128
+ };
129
+ /**
131
130
  * General method to parse a string of code into HTML Elements and load them into the container
132
131
  * @private
133
132
  * @param {?} code
134
133
  * @return {?}
135
134
  */
136
- function (code) {
135
+ TdHighlightComponent.prototype._loadContent = function (code) {
137
136
  if (code && code.trim().length > 0) {
138
137
  // Clean container
139
138
  this._renderer.setProperty(this._elementRef.nativeElement, 'innerHTML', '');
@@ -150,12 +149,7 @@
150
149
  * @param {?} codeStr
151
150
  * @return {?}
152
151
  */
153
- TdHighlightComponent.prototype._elementFromString = /**
154
- * @private
155
- * @param {?} codeStr
156
- * @return {?}
157
- */
158
- function (codeStr) {
152
+ TdHighlightComponent.prototype._elementFromString = function (codeStr) {
159
153
  // Renderer2 doesnt have a parsing method, so we have to sanitize and use [innerHTML]
160
154
  // to parse the string into DOM element for now.
161
155
  /** @type {?} */
@@ -174,12 +168,7 @@
174
168
  * @param {?} contents
175
169
  * @return {?}
176
170
  */
177
- TdHighlightComponent.prototype._render = /**
178
- * @private
179
- * @param {?} contents
180
- * @return {?}
181
- */
182
- function (contents) {
171
+ TdHighlightComponent.prototype._render = function (contents) {
183
172
  // Trim leading and trailing newlines
184
173
  contents = contents.replace(/^(\s|\t)*\n+/g, '').replace(/(\s|\t)*\n+(\s|\t)*$/g, '');
185
174
  // Split markup by line characters
@@ -191,11 +180,10 @@
191
180
  // Remove all indentation spaces so code can be parsed correctly
192
181
  /** @type {?} */
193
182
  var startingWhitespaceRegex = new RegExp('^' + firstLineWhitespace);
194
- lines = lines.map((/**
183
+ lines = lines.map(( /**
195
184
  * @param {?} line
196
185
  * @return {?}
197
- */
198
- function (line) {
186
+ */function (line) {
199
187
  return line
200
188
  .replace('=""', '') // remove empty values
201
189
  .replace(startingWhitespaceRegex, '')
@@ -211,39 +199,40 @@
211
199
  this.copyContent = codeToParse;
212
200
  // Parse code with highlight.js depending on language
213
201
  /** @type {?} */
214
- var highlightedCode = lib.highlight(this._lang, codeToParse, true);
202
+ var highlightedCode = hljs.highlight(this._lang, codeToParse, true);
215
203
  highlightedCode.value = highlightedCode.value
216
204
  .replace(/=<span class="hljs-value">""<\/span>/gi, '')
217
205
  .replace('<head>', '')
218
206
  .replace('<head/>', '');
219
207
  return highlightedCode.value;
220
208
  };
221
- TdHighlightComponent.decorators = [
222
- { type: core.Component, args: [{
223
- selector: 'td-highlight',
224
- 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",
225
- styles: [":host ::ng-deep{overflow-x:auto;padding:16px;display:-ms-flexbox;display:flex}: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{display:block;overflow-x:auto;padding:0;margin:0;background:0 0;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;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}"]
226
- }] }
227
- ];
228
- /** @nocollapse */
229
- TdHighlightComponent.ctorParameters = function () { return [
230
- { type: core.Renderer2 },
231
- { type: core.ElementRef },
232
- { type: platformBrowser.DomSanitizer },
233
- { type: core.ChangeDetectorRef }
234
- ]; };
235
- TdHighlightComponent.propDecorators = {
236
- content: [{ type: core.Input, args: ['content',] }],
237
- copyCodeToClipboard: [{ type: core.Input }],
238
- copyCodeTooltips: [{ type: core.Input }],
239
- lang: [{ type: core.Input, args: ['lang',] }],
240
- contentReady: [{ type: core.Output }],
241
- highlightComp: [{ type: core.ViewChild, args: ['highlightComponent',] }],
242
- copyComp: [{ type: core.ViewChild, args: ['copyComponent',] }],
243
- tooltip: [{ type: core.ViewChild, args: ['tooltip',] }]
244
- };
245
209
  return TdHighlightComponent;
246
210
  }());
211
+ TdHighlightComponent.decorators = [
212
+ { type: core.Component, args: [{
213
+ selector: 'td-highlight',
214
+ 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",
215
+ 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}"]
216
+ }] }
217
+ ];
218
+ /** @nocollapse */
219
+ TdHighlightComponent.ctorParameters = function () { return [
220
+ { type: core.Renderer2 },
221
+ { type: core.ElementRef },
222
+ { type: platformBrowser.DomSanitizer },
223
+ { type: core.ChangeDetectorRef }
224
+ ]; };
225
+ TdHighlightComponent.propDecorators = {
226
+ content: [{ type: core.Input, args: ['content',] }],
227
+ copyCodeToClipboard: [{ type: core.Input }],
228
+ copyCodeTooltips: [{ type: core.Input }],
229
+ codeLang: [{ type: core.Input, args: ['codeLang',] }],
230
+ lang: [{ type: core.Input }],
231
+ contentReady: [{ type: core.Output }],
232
+ highlightComp: [{ type: core.ViewChild, args: ['highlightComponent',] }],
233
+ copyComp: [{ type: core.ViewChild, args: ['copyComponent',] }],
234
+ tooltip: [{ type: core.ViewChild, args: ['tooltip',] }]
235
+ };
247
236
  if (false) {
248
237
  /**
249
238
  * @type {?}
@@ -312,7 +301,8 @@
312
301
 
313
302
  /**
314
303
  * @fileoverview added by tsickle
315
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
304
+ * Generated from: copy-code-button/copy-code-button.component.ts
305
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
316
306
  */
317
307
  /**
318
308
  * @record
@@ -335,34 +325,30 @@
335
325
  this.copyCodeTooltips = {};
336
326
  }
337
327
  Object.defineProperty(TdCopyCodeButtonComponent.prototype, "copyTooltip", {
338
- get: /**
328
+ /**
339
329
  * @return {?}
340
330
  */
341
- function () {
331
+ get: function () {
342
332
  return (this.copyCodeTooltips && this.copyCodeTooltips.copy) || 'Copy';
343
333
  },
344
- enumerable: true,
334
+ enumerable: false,
345
335
  configurable: true
346
336
  });
347
337
  Object.defineProperty(TdCopyCodeButtonComponent.prototype, "copiedTooltip", {
348
- get: /**
338
+ /**
349
339
  * @return {?}
350
340
  */
351
- function () {
341
+ get: function () {
352
342
  return (this.copyCodeTooltips && this.copyCodeTooltips.copied) || 'Copied';
353
343
  },
354
- enumerable: true,
344
+ enumerable: false,
355
345
  configurable: true
356
346
  });
357
347
  /**
358
348
  * @param {?} event
359
349
  * @return {?}
360
350
  */
361
- TdCopyCodeButtonComponent.prototype.textCopied = /**
362
- * @param {?} event
363
- * @return {?}
364
- */
365
- function (event) {
351
+ TdCopyCodeButtonComponent.prototype.textCopied = function (event) {
366
352
  if (event) {
367
353
  this.tooltip.hide();
368
354
  this.tooltip.message = this.copiedTooltip;
@@ -372,34 +358,30 @@
372
358
  /**
373
359
  * @return {?}
374
360
  */
375
- TdCopyCodeButtonComponent.prototype.initializeTooltip = /**
376
- * @return {?}
377
- */
378
- function () {
361
+ TdCopyCodeButtonComponent.prototype.initializeTooltip = function () {
379
362
  var _this = this;
380
- setTimeout((/**
363
+ setTimeout(( /**
381
364
  * @return {?}
382
- */
383
- function () {
365
+ */function () {
384
366
  _this.tooltip.message = _this.copyTooltip;
385
367
  }), 200);
386
368
  };
387
- TdCopyCodeButtonComponent.decorators = [
388
- { type: core.Component, args: [{
389
- selector: 'td-copy-code-button',
390
- 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",
391
- styles: [""]
392
- }] }
393
- ];
394
- TdCopyCodeButtonComponent.propDecorators = {
395
- copiedContent: [{ type: core.Input }],
396
- copyCodeToClipboard: [{ type: core.Input }],
397
- copyCodeTooltips: [{ type: core.Input }],
398
- tooltip: [{ type: core.ViewChild, args: ['tooltip',] }],
399
- initializeTooltip: [{ type: core.HostListener, args: ['mouseleave',] }]
400
- };
401
369
  return TdCopyCodeButtonComponent;
402
370
  }());
371
+ TdCopyCodeButtonComponent.decorators = [
372
+ { type: core.Component, args: [{
373
+ selector: 'td-copy-code-button',
374
+ 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",
375
+ styles: [""]
376
+ }] }
377
+ ];
378
+ TdCopyCodeButtonComponent.propDecorators = {
379
+ copiedContent: [{ type: core.Input }],
380
+ copyCodeToClipboard: [{ type: core.Input }],
381
+ copyCodeTooltips: [{ type: core.Input }],
382
+ tooltip: [{ type: core.ViewChild, args: ['tooltip',] }],
383
+ initializeTooltip: [{ type: core.HostListener, args: ['mouseleave',] }]
384
+ };
403
385
  if (false) {
404
386
  /** @type {?} */
405
387
  TdCopyCodeButtonComponent.prototype.copiedContent;
@@ -418,20 +400,39 @@
418
400
 
419
401
  /**
420
402
  * @fileoverview added by tsickle
421
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
403
+ * Generated from: highlight.module.ts
404
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
422
405
  */
423
406
  var CovalentHighlightModule = /** @class */ (function () {
424
407
  function CovalentHighlightModule() {
425
408
  }
426
- CovalentHighlightModule.decorators = [
427
- { type: core.NgModule, args: [{
428
- imports: [common.CommonModule, clipboard.ClipboardModule, icon.MatIconModule, tooltip.MatTooltipModule, button.MatButtonModule],
429
- declarations: [TdHighlightComponent, TdCopyCodeButtonComponent],
430
- exports: [TdHighlightComponent],
431
- },] }
432
- ];
433
409
  return CovalentHighlightModule;
434
410
  }());
411
+ CovalentHighlightModule.decorators = [
412
+ { type: core.NgModule, args: [{
413
+ imports: [common.CommonModule, clipboard.ClipboardModule, icon.MatIconModule, tooltip.MatTooltipModule, button.MatButtonModule],
414
+ declarations: [TdHighlightComponent, TdCopyCodeButtonComponent],
415
+ exports: [TdHighlightComponent],
416
+ },] }
417
+ ];
418
+
419
+ /**
420
+ * @fileoverview added by tsickle
421
+ * Generated from: public_api.ts
422
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
423
+ */
424
+
425
+ /**
426
+ * @fileoverview added by tsickle
427
+ * Generated from: index.ts
428
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
429
+ */
430
+
431
+ /**
432
+ * @fileoverview added by tsickle
433
+ * Generated from: covalent-highlight.ts
434
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
435
+ */
435
436
 
436
437
  exports.CovalentHighlightModule = CovalentHighlightModule;
437
438
  exports.TdCopyCodeButtonComponent = TdCopyCodeButtonComponent;
@@ -1 +1 @@
1
- {"version":3,"file":"covalent-highlight.umd.js","sources":["ng://@covalent/highlight/highlight.component.ts","ng://@covalent/highlight/copy-code-button/copy-code-button.component.ts","ng://@covalent/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 @Input('lang')\n set lang(lang: string) {\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 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 /**\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":["EventEmitter","SecurityContext","hljs","Component","Renderer2","ElementRef","DomSanitizer","ChangeDetectorRef","Input","Output","ViewChild","HostListener","NgModule","CommonModule","ClipboardModule","MatIconModule","MatTooltipModule","MatButtonModule"],"mappings":";;;;;;;;;;;;QA8FE,8BACU,SAAoB,EACpB,WAAuB,EACvB,aAA2B,EAC3B,GAAsB;YAHtB,cAAS,GAAT,SAAS,CAAW;YACpB,gBAAW,GAAX,WAAW,CAAY;YACvB,kBAAa,GAAb,aAAa,CAAc;YAC3B,QAAG,GAAH,GAAG,CAAmB;YAtExB,iBAAY,GAAY,KAAK,CAAC;YAG9B,UAAK,GAAW,YAAY,CAAC;;;;;;YAuB5B,wBAAmB,GAAY,KAAK,CAAC;;;;;;YAOrC,qBAAgB,GAAsB,EAAE,CAAC;;;;;YA2BxC,iBAAY,GAAuB,IAAIA,iBAAY,EAAQ,CAAC;SAWlE;QA1DJ,sBACI,yCAAO;;;;;;;;;;;;;;;;;;;YADX,UACY,OAAe;gBACzB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;gBACxB,IAAI,IAAI,CAAC,YAAY,EAAE;oBACrB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;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/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":["EventEmitter","SecurityContext","Component","Renderer2","ElementRef","DomSanitizer","ChangeDetectorRef","Input","Output","ViewChild","HostListener","NgModule","CommonModule","ClipboardModule","MatIconModule","MatTooltipModule","MatButtonModule"],"mappings":";;;;;;;;;;;;;QAoBI,IAAI,GAAQ,OAAO,CAAC,kBAAkB,CAAC;;;;;;;;QA4EzC,8BACU,SAAoB,EACpB,WAAuB,EACvB,aAA2B,EAC3B,GAAsB;YAHtB,cAAS,GAAT,SAAS,CAAW;YACpB,gBAAW,GAAX,WAAW,CAAY;YACvB,kBAAa,GAAb,aAAa,CAAc;YAC3B,QAAG,GAAH,GAAG,CAAmB;YAxExB,iBAAY,GAAY,KAAK,CAAC;YAG9B,UAAK,GAAW,YAAY,CAAC;;;;;;YAuB5B,wBAAmB,GAAY,KAAK,CAAC;;;;;;YAOrC,qBAAgB,GAAsB,EAAE,CAAC;;;;;YA6BxC,iBAAY,GAAuB,IAAIA,iBAAY,EAAQ,CAAC;SAWlE;QA5DJ,sBACI,yCAAO;;;;;;;;;;;iBADX,UACY,OAAe;gBACzB,IAAI,CAAC,QAAQ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AK;sCACLA,UAAK;mCAMLA,UAAK;0BAULE,cAAS,SAAC,SAAS;oCASnBC,iBAAY,SAAC,YAAY;;;;QA1B1B,kDAA+B;;QAC/B,wDAA8C;;;;;;;QAM9C,qDAAkD;;QAUlD,4CAA0C;;;;;;;;;QClB5C;;;;;gBALCC,aAAQ,SAAC;oBACR,OAAO,EAAE,CAACC,mBAAY,EAAEC,yBAAe,EAAEC,kBAAa,EAAEC,wBAAgB,EAAEC,sBAAe,CAAC;oBAC1F,YAAY,EAAE,CAAC,oBAAoB,EAAE,yBAAyB,CAAC;oBAC/D,OAAO,EAAE,CAAC,oBAAoB,CAAC;iBAChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("highlight.js/lib"),require("@angular/core"),require("@angular/platform-browser"),require("@angular/material/tooltip"),require("@angular/common"),require("@angular/cdk/clipboard"),require("@angular/material/icon"),require("@angular/material/button")):"function"==typeof define&&define.amd?define("@covalent/highlight",["exports","highlight.js/lib","@angular/core","@angular/platform-browser","@angular/material/tooltip","@angular/common","@angular/cdk/clipboard","@angular/material/icon","@angular/material/button"],t):t(((e=e||self).covalent=e.covalent||{},e.covalent.highlight={}),e.lib,e.ng.core,e.ng.platformBrowser,e.ng.material.tooltip,e.ng.common,e.ng.cdk.clipboard,e.ng.material.icon,e.ng.material.button)}(this,(function(e,t,o,n,i,r,p,a,l){"use strict";t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var d=function(){function e(e,t,n,i){this._renderer=e,this._elementRef=t,this._domSanitizer=n,this.cdr=i,this._initialized=!1,this._lang="typescript",this.copyCodeToClipboard=!1,this.copyCodeTooltips={},this.contentReady=new o.EventEmitter}return Object.defineProperty(e.prototype,"content",{set:function(e){this._content=e,this._initialized&&this._loadContent(this._content)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lang",{set:function(e){if(!e)throw new Error("Error: language attribute must be defined in TdHighlightComponent.");this._lang=e,this._initialized&&this._loadContent(this._content)},enumerable:!0,configurable:!0}),e.prototype.ngAfterViewChecked=function(){this.cdr.detectChanges()},e.prototype.ngAfterViewInit=function(){this._content?this._loadContent(this._content):this._loadContent(this.highlightComp.nativeElement.textContent),this._initialized=!0},e.prototype._loadContent=function(e){e&&e.trim().length>0&&(this._renderer.setProperty(this._elementRef.nativeElement,"innerHTML",""),this._elementFromString(this._render(e)),this.copyCodeToClipboard&&this._renderer.appendChild(this._elementRef.nativeElement,this.copyComp.nativeElement)),this.contentReady.emit()},e.prototype._elementFromString=function(e){var t=this._renderer.createElement("pre");this._renderer.appendChild(this._elementRef.nativeElement,t);var n=this._renderer.createElement("code");return this._renderer.appendChild(t,n),this._renderer.addClass(n,"highlight"),n.innerHTML=this._domSanitizer.sanitize(o.SecurityContext.HTML,e),t},e.prototype._render=function(e){var o=(e=e.replace(/^(\s|\t)*\n+/g,"").replace(/(\s|\t)*\n+(\s|\t)*$/g,"")).split("\n"),n=o[0].match(/^(\s|\t)*/)[0],i=new RegExp("^"+n),r=(o=o.map((function(e){return e.replace('=""',"").replace(i,"").replace(/\s+$/,"")}))).join("\n").replace(/\{ \{/gi,"{{").replace(/\} \}/gi,"}}").replace(/&lt;/gi,"<").replace(/&gt;/gi,">");this.copyContent=r;var p=t.highlight(this._lang,r,!0);return p.value=p.value.replace(/=<span class="hljs-value">""<\/span>/gi,"").replace("<head>","").replace("<head/>",""),p.value},e.decorators=[{type:o.Component,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 .highlight,:host ::ng-deep code,:host ::ng-deep pre{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:0 0;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;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}']}]}],e.ctorParameters=function(){return[{type:o.Renderer2},{type:o.ElementRef},{type:n.DomSanitizer},{type:o.ChangeDetectorRef}]},e.propDecorators={content:[{type:o.Input,args:["content"]}],copyCodeToClipboard:[{type:o.Input}],copyCodeTooltips:[{type:o.Input}],lang:[{type:o.Input,args:["lang"]}],contentReady:[{type:o.Output}],highlightComp:[{type:o.ViewChild,args:["highlightComponent"]}],copyComp:[{type:o.ViewChild,args:["copyComponent"]}],tooltip:[{type:o.ViewChild,args:["tooltip"]}]},e}();var c=function(){function e(){this.copyCodeToClipboard=!1,this.copyCodeTooltips={}}return Object.defineProperty(e.prototype,"copyTooltip",{get:function(){return this.copyCodeTooltips&&this.copyCodeTooltips.copy||"Copy"},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"copiedTooltip",{get:function(){return this.copyCodeTooltips&&this.copyCodeTooltips.copied||"Copied"},enumerable:!0,configurable:!0}),e.prototype.textCopied=function(e){e&&(this.tooltip.hide(),this.tooltip.message=this.copiedTooltip,this.tooltip.show())},e.prototype.initializeTooltip=function(){var e=this;setTimeout((function(){e.tooltip.message=e.copyTooltip}),200)},e.decorators=[{type:o.Component,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:[""]}]}],e.propDecorators={copiedContent:[{type:o.Input}],copyCodeToClipboard:[{type:o.Input}],copyCodeTooltips:[{type:o.Input}],tooltip:[{type:o.ViewChild,args:["tooltip"]}],initializeTooltip:[{type:o.HostListener,args:["mouseleave"]}]},e}();var s=function(){function e(){}return e.decorators=[{type:o.NgModule,args:[{imports:[r.CommonModule,p.ClipboardModule,a.MatIconModule,i.MatTooltipModule,l.MatButtonModule],declarations:[d,c],exports:[d]}]}],e}();e.CovalentHighlightModule=s,e.TdCopyCodeButtonComponent=c,e.TdHighlightComponent=d,Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/platform-browser"),require("@angular/common"),require("@angular/cdk/clipboard"),require("@angular/material/icon"),require("@angular/material/tooltip"),require("@angular/material/button")):"function"==typeof define&&define.amd?define("@covalent/highlight",["exports","@angular/core","@angular/platform-browser","@angular/common","@angular/cdk/clipboard","@angular/material/icon","@angular/material/tooltip","@angular/material/button"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).covalent=e.covalent||{},e.covalent.highlight={}),e.ng.core,e.ng.platformBrowser,e.ng.common,e.ng.cdk.clipboard,e.ng.material.icon,e.ng.material.tooltip,e.ng.material.button)}(this,(function(e,t,o,n,i,r,p,a){"use strict";var l=require("highlight.js/lib"),d=function(){function e(e,o,n,i){this._renderer=e,this._elementRef=o,this._domSanitizer=n,this.cdr=i,this._initialized=!1,this._lang="typescript",this.copyCodeToClipboard=!1,this.copyCodeTooltips={},this.contentReady=new t.EventEmitter}return Object.defineProperty(e.prototype,"content",{set:function(e){this._content=e,this._initialized&&this._loadContent(this._content)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"codeLang",{set:function(e){this.setLanguage(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lang",{set:function(e){console.warn("DEPRECATION WARNING: switch to codeLang attribute as lang attribute is deprecated."),this.setLanguage(e)},enumerable:!1,configurable:!0}),e.prototype.ngAfterViewChecked=function(){this.cdr.detectChanges()},e.prototype.ngAfterViewInit=function(){this._content?this._loadContent(this._content):this._loadContent(this.highlightComp.nativeElement.textContent),this._initialized=!0},e.prototype.setLanguage=function(e){if(!e)throw new Error("Error: language attribute must be defined in TdHighlightComponent.");this._lang=e,this._initialized&&this._loadContent(this._content)},e.prototype._loadContent=function(e){e&&e.trim().length>0&&(this._renderer.setProperty(this._elementRef.nativeElement,"innerHTML",""),this._elementFromString(this._render(e)),this.copyCodeToClipboard&&this._renderer.appendChild(this._elementRef.nativeElement,this.copyComp.nativeElement)),this.contentReady.emit()},e.prototype._elementFromString=function(e){var o=this._renderer.createElement("pre");this._renderer.appendChild(this._elementRef.nativeElement,o);var n=this._renderer.createElement("code");return this._renderer.appendChild(o,n),this._renderer.addClass(n,"highlight"),n.innerHTML=this._domSanitizer.sanitize(t.SecurityContext.HTML,e),o},e.prototype._render=function(e){var t=(e=e.replace(/^(\s|\t)*\n+/g,"").replace(/(\s|\t)*\n+(\s|\t)*$/g,"")).split("\n"),o=t[0].match(/^(\s|\t)*/)[0],n=new RegExp("^"+o),i=(t=t.map((function(e){return e.replace('=""',"").replace(n,"").replace(/\s+$/,"")}))).join("\n").replace(/\{ \{/gi,"{{").replace(/\} \}/gi,"}}").replace(/&lt;/gi,"<").replace(/&gt;/gi,">");this.copyContent=i;var r=l.highlight(this._lang,i,!0);return r.value=r.value.replace(/=<span class="hljs-value">""<\/span>/gi,"").replace("<head>","").replace("<head/>",""),r.value},e}();d.decorators=[{type:t.Component,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{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}"]}]}],d.ctorParameters=function(){return[{type:t.Renderer2},{type:t.ElementRef},{type:o.DomSanitizer},{type:t.ChangeDetectorRef}]},d.propDecorators={content:[{type:t.Input,args:["content"]}],copyCodeToClipboard:[{type:t.Input}],copyCodeTooltips:[{type:t.Input}],codeLang:[{type:t.Input,args:["codeLang"]}],lang:[{type:t.Input}],contentReady:[{type:t.Output}],highlightComp:[{type:t.ViewChild,args:["highlightComponent"]}],copyComp:[{type:t.ViewChild,args:["copyComponent"]}],tooltip:[{type:t.ViewChild,args:["tooltip"]}]};var c=function(){function e(){this.copyCodeToClipboard=!1,this.copyCodeTooltips={}}return Object.defineProperty(e.prototype,"copyTooltip",{get:function(){return this.copyCodeTooltips&&this.copyCodeTooltips.copy||"Copy"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"copiedTooltip",{get:function(){return this.copyCodeTooltips&&this.copyCodeTooltips.copied||"Copied"},enumerable:!1,configurable:!0}),e.prototype.textCopied=function(e){e&&(this.tooltip.hide(),this.tooltip.message=this.copiedTooltip,this.tooltip.show())},e.prototype.initializeTooltip=function(){var e=this;setTimeout((function(){e.tooltip.message=e.copyTooltip}),200)},e}();c.decorators=[{type:t.Component,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:[""]}]}],c.propDecorators={copiedContent:[{type:t.Input}],copyCodeToClipboard:[{type:t.Input}],copyCodeTooltips:[{type:t.Input}],tooltip:[{type:t.ViewChild,args:["tooltip"]}],initializeTooltip:[{type:t.HostListener,args:["mouseleave"]}]};var s=function(){};s.decorators=[{type:t.NgModule,args:[{imports:[n.CommonModule,i.ClipboardModule,r.MatIconModule,p.MatTooltipModule,a.MatButtonModule],declarations:[d,c],exports:[d]}]}],e.CovalentHighlightModule=s,e.TdCopyCodeButtonComponent=c,e.TdHighlightComponent=d,Object.defineProperty(e,"__esModule",{value:!0})}));
2
2
  //# sourceMappingURL=covalent-highlight.umd.min.js.map