@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,7 +1,8 @@
1
1
  import { AfterViewInit, ElementRef, EventEmitter, Renderer2, ChangeDetectorRef, AfterViewChecked } from '@angular/core';
2
2
  import { DomSanitizer } from '@angular/platform-browser';
3
3
  import { MatTooltip } from '@angular/material/tooltip';
4
- import { ICopyCodeTooltips } from '.';
4
+ import { ICopyCodeTooltips } from './copy-code-button/copy-code-button.component';
5
+ import * as i0 from "@angular/core";
5
6
  export declare class TdHighlightComponent implements AfterViewInit, AfterViewChecked {
6
7
  private _renderer;
7
8
  private _elementRef;
@@ -24,13 +25,13 @@ export declare class TdHighlightComponent implements AfterViewInit, AfterViewChe
24
25
  *
25
26
  * Display copy button on code snippets to copy code to clipboard.
26
27
  */
27
- copyCodeToClipboard: boolean;
28
+ copyCodeToClipboard?: boolean | undefined;
28
29
  /**
29
30
  * copyCodeTooltips?: ICopyCodeTooltips
30
31
  *
31
32
  * Tooltips for copy button to copy and upon copying.
32
33
  */
33
- copyCodeTooltips: ICopyCodeTooltips;
34
+ copyCodeTooltips?: ICopyCodeTooltips;
34
35
  /**
35
36
  * lang?: string
36
37
  *
@@ -61,4 +62,6 @@ export declare class TdHighlightComponent implements AfterViewInit, AfterViewChe
61
62
  private _loadContent;
62
63
  private _elementFromString;
63
64
  private _render;
65
+ static ɵfac: i0.ɵɵFactoryDeclaration<TdHighlightComponent, never>;
66
+ static ɵcmp: i0.ɵɵComponentDeclaration<TdHighlightComponent, "td-highlight", never, { "content": "content"; "copyCodeToClipboard": "copyCodeToClipboard"; "copyCodeTooltips": "copyCodeTooltips"; "codeLang": "codeLang"; "lang": "lang"; }, { "contentReady": "contentReady"; }, never, ["*"]>;
64
67
  }
@@ -0,0 +1,13 @@
1
+ import * as i0 from "@angular/core";
2
+ import * as i1 from "./highlight.component";
3
+ import * as i2 from "./copy-code-button/copy-code-button.component";
4
+ import * as i3 from "@angular/common";
5
+ import * as i4 from "@angular/cdk/clipboard";
6
+ import * as i5 from "@angular/material/icon";
7
+ import * as i6 from "@angular/material/tooltip";
8
+ import * as i7 from "@angular/material/button";
9
+ export declare class CovalentHighlightModule {
10
+ static ɵfac: i0.ɵɵFactoryDeclaration<CovalentHighlightModule, never>;
11
+ static ɵmod: i0.ɵɵNgModuleDeclaration<CovalentHighlightModule, [typeof i1.TdHighlightComponent, typeof i2.TdCopyCodeButtonComponent], [typeof i3.CommonModule, typeof i4.ClipboardModule, typeof i5.MatIconModule, typeof i6.MatTooltipModule, typeof i7.MatButtonModule], [typeof i1.TdHighlightComponent]>;
12
+ static ɵinj: i0.ɵɵInjectorDeclaration<CovalentHighlightModule>;
13
+ }
package/package.json CHANGED
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "name": "@covalent/highlight",
3
- "version": "4.0.0",
3
+ "version": "4.1.0-develop.2",
4
4
  "description": "Teradata UI Platform Highlight Module",
5
+ "license": "MIT",
6
+ "author": "Teradata UX",
5
7
  "keywords": [
6
8
  "angular",
7
9
  "components",
@@ -9,41 +11,35 @@
9
11
  "highlight",
10
12
  "highlightjs"
11
13
  ],
12
- "repository": {
13
- "type": "git",
14
- "url": "https://github.com/teradata/covalent.git"
15
- },
16
- "bugs": {
17
- "url": "https://github.com/teradata/covalent/issues"
14
+ "peerDependencies": {
15
+ "highlight.js": "^11.4.0",
16
+ "@angular/common": "^13.2.0",
17
+ "@angular/core": "^13.2.0",
18
+ "@angular/platform-browser": "^13.2.0",
19
+ "@angular/cdk": "^13.2.0",
20
+ "@angular/material": "^13.2.1"
18
21
  },
19
- "license": "MIT",
20
- "author": "Teradata UX",
21
- "contributors": [
22
- "Kyle Ledbetter <kyle.ledbetter@teradata.com>",
23
- "Richa Vyas <richa.vyas@teradata.com>",
24
- "Ed Morales <eduardo.morales@teradata.com>",
25
- "Jason Weaver <jason.weaver@teradata.com>",
26
- "Jeremy Wilken <jeremy.wilken@teradata.com>",
27
- "Jeremy Smartt <jeremy.smartt@teradata.com>",
28
- "Steven Ov <steven.ov@teradata.com>"
29
- ],
30
22
  "dependencies": {
31
- "highlight.js": "^9.13.1",
32
23
  "tslib": "^2.0.0"
33
24
  },
34
- "peerDependencies": {
35
- "@angular/common": "^9.0.0 || ^10.0.0-0 || ^11.0.0-0",
36
- "@angular/core": "^9.0.0 || ^10.0.0-0 || ^11.0.0-0",
37
- "@angular/platform-browser": "^9.0.0 || ^10.0.0-0 || ^11.0.0-0",
38
- "@angular/cdk": "^9.0.0 || ^10.0.0-0 || ^11.0.0-0",
39
- "@angular/material": "^9.0.0 || ^10.0.0-0 || ^11.0.0-0"
40
- },
41
- "main": "bundles/covalent-highlight.umd.js",
42
- "module": "fesm2015/covalent-highlight.js",
43
- "es2015": "fesm2015/covalent-highlight.js",
44
- "esm2015": "esm2015/covalent-highlight.js",
45
- "fesm2015": "fesm2015/covalent-highlight.js",
25
+ "module": "fesm2015/covalent-highlight.mjs",
26
+ "es2020": "fesm2020/covalent-highlight.mjs",
27
+ "esm2020": "esm2020/covalent-highlight.mjs",
28
+ "fesm2020": "fesm2020/covalent-highlight.mjs",
29
+ "fesm2015": "fesm2015/covalent-highlight.mjs",
46
30
  "typings": "covalent-highlight.d.ts",
47
- "metadata": "covalent-highlight.metadata.json",
31
+ "exports": {
32
+ "./package.json": {
33
+ "default": "./package.json"
34
+ },
35
+ ".": {
36
+ "types": "./covalent-highlight.d.ts",
37
+ "esm2020": "./esm2020/covalent-highlight.mjs",
38
+ "es2020": "./fesm2020/covalent-highlight.mjs",
39
+ "es2015": "./fesm2015/covalent-highlight.mjs",
40
+ "node": "./fesm2015/covalent-highlight.mjs",
41
+ "default": "./fesm2020/covalent-highlight.mjs"
42
+ }
43
+ },
48
44
  "sideEffects": false
49
- }
45
+ }
package/public_api.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './highlight.component';
2
- export * from './highlight.module';
3
- export * from './copy-code-button/copy-code-button.component';
1
+ export * from './lib/highlight.component';
2
+ export * from './lib/highlight.module';
3
+ export * from './lib/copy-code-button/copy-code-button.component';
@@ -1,444 +0,0 @@
1
- (function (global, factory) {
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';
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
- */
12
- /* tslint:disable-next-line */
13
- /** @type {?} */
14
- var hljs = require('highlight.js/lib');
15
- var TdHighlightComponent = /** @class */ (function () {
16
- /**
17
- * @param {?} _renderer
18
- * @param {?} _elementRef
19
- * @param {?} _domSanitizer
20
- * @param {?} cdr
21
- */
22
- function TdHighlightComponent(_renderer, _elementRef, _domSanitizer, cdr) {
23
- this._renderer = _renderer;
24
- this._elementRef = _elementRef;
25
- this._domSanitizer = _domSanitizer;
26
- this.cdr = cdr;
27
- this._initialized = false;
28
- this._lang = 'typescript';
29
- /**
30
- * copyCodeToClipboard?: boolean
31
- *
32
- * Display copy button on code snippets to copy code to clipboard.
33
- */
34
- this.copyCodeToClipboard = false;
35
- /**
36
- * copyCodeTooltips?: ICopyCodeTooltips
37
- *
38
- * Tooltips for copy button to copy and upon copying.
39
- */
40
- this.copyCodeTooltips = {};
41
- /**
42
- * contentReady?: function
43
- * Event emitted after the highlight content rendering is finished.
44
- */
45
- this.contentReady = new core.EventEmitter();
46
- }
47
- Object.defineProperty(TdHighlightComponent.prototype, "content", {
48
- /**
49
- * content?: string
50
- *
51
- * Code content to be parsed as highlighted html.
52
- * Used to load data dynamically.
53
- *
54
- * e.g. `.html`, `.ts` , etc.
55
- * @param {?} content
56
- * @return {?}
57
- */
58
- set: function (content) {
59
- this._content = content;
60
- if (this._initialized) {
61
- this._loadContent(this._content);
62
- }
63
- },
64
- enumerable: false,
65
- configurable: true
66
- });
67
- Object.defineProperty(TdHighlightComponent.prototype, "codeLang", {
68
- /**
69
- * lang?: string
70
- *
71
- * Language of the code content to be parsed as highlighted html.
72
- * Defaults to `typescript`
73
- *
74
- * e.g. `typescript`, `html` , etc.
75
- * @param {?} lang
76
- * @return {?}
77
- */
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
87
- * @param {?} lang
88
- * @return {?}
89
- */
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);
94
- },
95
- enumerable: false,
96
- configurable: true
97
- });
98
- /**
99
- * @return {?}
100
- */
101
- TdHighlightComponent.prototype.ngAfterViewChecked = function () {
102
- this.cdr.detectChanges();
103
- };
104
- /**
105
- * @return {?}
106
- */
107
- TdHighlightComponent.prototype.ngAfterViewInit = function () {
108
- if (!this._content) {
109
- this._loadContent((( /** @type {?} */(this.highlightComp.nativeElement))).textContent);
110
- }
111
- else {
112
- this._loadContent(this._content);
113
- }
114
- this._initialized = true;
115
- };
116
- /**
117
- * @param {?} lang
118
- * @return {?}
119
- */
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
- /**
130
- * General method to parse a string of code into HTML Elements and load them into the container
131
- * @private
132
- * @param {?} code
133
- * @return {?}
134
- */
135
- TdHighlightComponent.prototype._loadContent = function (code) {
136
- if (code && code.trim().length > 0) {
137
- // Clean container
138
- this._renderer.setProperty(this._elementRef.nativeElement, 'innerHTML', '');
139
- // Parse html string into actual HTML elements.
140
- this._elementFromString(this._render(code));
141
- if (this.copyCodeToClipboard) {
142
- this._renderer.appendChild(this._elementRef.nativeElement, this.copyComp.nativeElement);
143
- }
144
- }
145
- this.contentReady.emit();
146
- };
147
- /**
148
- * @private
149
- * @param {?} codeStr
150
- * @return {?}
151
- */
152
- TdHighlightComponent.prototype._elementFromString = function (codeStr) {
153
- // Renderer2 doesnt have a parsing method, so we have to sanitize and use [innerHTML]
154
- // to parse the string into DOM element for now.
155
- /** @type {?} */
156
- var preElement = this._renderer.createElement('pre');
157
- this._renderer.appendChild(this._elementRef.nativeElement, preElement);
158
- /** @type {?} */
159
- var codeElement = this._renderer.createElement('code');
160
- this._renderer.appendChild(preElement, codeElement);
161
- // Set .highlight class into <code> element
162
- this._renderer.addClass(codeElement, 'highlight');
163
- codeElement.innerHTML = this._domSanitizer.sanitize(core.SecurityContext.HTML, codeStr);
164
- return preElement;
165
- };
166
- /**
167
- * @private
168
- * @param {?} contents
169
- * @return {?}
170
- */
171
- TdHighlightComponent.prototype._render = function (contents) {
172
- // Trim leading and trailing newlines
173
- contents = contents.replace(/^(\s|\t)*\n+/g, '').replace(/(\s|\t)*\n+(\s|\t)*$/g, '');
174
- // Split markup by line characters
175
- /** @type {?} */
176
- var lines = contents.split('\n');
177
- // check how much indentation is used by the first actual code line
178
- /** @type {?} */
179
- var firstLineWhitespace = lines[0].match(/^(\s|\t)*/)[0];
180
- // Remove all indentation spaces so code can be parsed correctly
181
- /** @type {?} */
182
- var startingWhitespaceRegex = new RegExp('^' + firstLineWhitespace);
183
- lines = lines.map(( /**
184
- * @param {?} line
185
- * @return {?}
186
- */function (line) {
187
- return line
188
- .replace('=""', '') // remove empty values
189
- .replace(startingWhitespaceRegex, '')
190
- .replace(/\s+$/, ''); // remove trailing white spaces
191
- }));
192
- /** @type {?} */
193
- var codeToParse = lines
194
- .join('\n')
195
- .replace(/\{ \{/gi, '{{')
196
- .replace(/\} \}/gi, '}}')
197
- .replace(/&lt;/gi, '<')
198
- .replace(/&gt;/gi, '>');
199
- this.copyContent = codeToParse;
200
- // Parse code with highlight.js depending on language
201
- /** @type {?} */
202
- var highlightedCode = hljs.highlight(this._lang, codeToParse, true);
203
- highlightedCode.value = highlightedCode.value
204
- .replace(/=<span class="hljs-value">""<\/span>/gi, '')
205
- .replace('<head>', '')
206
- .replace('<head/>', '');
207
- return highlightedCode.value;
208
- };
209
- return TdHighlightComponent;
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
- };
236
- if (false) {
237
- /**
238
- * @type {?}
239
- * @private
240
- */
241
- TdHighlightComponent.prototype._initialized;
242
- /**
243
- * @type {?}
244
- * @private
245
- */
246
- TdHighlightComponent.prototype._content;
247
- /**
248
- * @type {?}
249
- * @private
250
- */
251
- TdHighlightComponent.prototype._lang;
252
- /**
253
- * copyCodeToClipboard?: boolean
254
- *
255
- * Display copy button on code snippets to copy code to clipboard.
256
- * @type {?}
257
- */
258
- TdHighlightComponent.prototype.copyCodeToClipboard;
259
- /**
260
- * copyCodeTooltips?: ICopyCodeTooltips
261
- *
262
- * Tooltips for copy button to copy and upon copying.
263
- * @type {?}
264
- */
265
- TdHighlightComponent.prototype.copyCodeTooltips;
266
- /** @type {?} */
267
- TdHighlightComponent.prototype.copyContent;
268
- /**
269
- * contentReady?: function
270
- * Event emitted after the highlight content rendering is finished.
271
- * @type {?}
272
- */
273
- TdHighlightComponent.prototype.contentReady;
274
- /** @type {?} */
275
- TdHighlightComponent.prototype.highlightComp;
276
- /** @type {?} */
277
- TdHighlightComponent.prototype.copyComp;
278
- /** @type {?} */
279
- TdHighlightComponent.prototype.tooltip;
280
- /**
281
- * @type {?}
282
- * @private
283
- */
284
- TdHighlightComponent.prototype._renderer;
285
- /**
286
- * @type {?}
287
- * @private
288
- */
289
- TdHighlightComponent.prototype._elementRef;
290
- /**
291
- * @type {?}
292
- * @private
293
- */
294
- TdHighlightComponent.prototype._domSanitizer;
295
- /**
296
- * @type {?}
297
- * @private
298
- */
299
- TdHighlightComponent.prototype.cdr;
300
- }
301
-
302
- /**
303
- * @fileoverview added by tsickle
304
- * Generated from: copy-code-button/copy-code-button.component.ts
305
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
306
- */
307
- /**
308
- * @record
309
- */
310
- function ICopyCodeTooltips() { }
311
- if (false) {
312
- /** @type {?|undefined} */
313
- ICopyCodeTooltips.prototype.copy;
314
- /** @type {?|undefined} */
315
- ICopyCodeTooltips.prototype.copied;
316
- }
317
- var TdCopyCodeButtonComponent = /** @class */ (function () {
318
- function TdCopyCodeButtonComponent() {
319
- this.copyCodeToClipboard = false;
320
- /**
321
- * copyCodeTooltips?: ICopyCodeTooltips
322
- *
323
- * Tooltips for copy button to copy and upon copying.
324
- */
325
- this.copyCodeTooltips = {};
326
- }
327
- Object.defineProperty(TdCopyCodeButtonComponent.prototype, "copyTooltip", {
328
- /**
329
- * @return {?}
330
- */
331
- get: function () {
332
- return (this.copyCodeTooltips && this.copyCodeTooltips.copy) || 'Copy';
333
- },
334
- enumerable: false,
335
- configurable: true
336
- });
337
- Object.defineProperty(TdCopyCodeButtonComponent.prototype, "copiedTooltip", {
338
- /**
339
- * @return {?}
340
- */
341
- get: function () {
342
- return (this.copyCodeTooltips && this.copyCodeTooltips.copied) || 'Copied';
343
- },
344
- enumerable: false,
345
- configurable: true
346
- });
347
- /**
348
- * @param {?} event
349
- * @return {?}
350
- */
351
- TdCopyCodeButtonComponent.prototype.textCopied = function (event) {
352
- if (event) {
353
- this.tooltip.hide();
354
- this.tooltip.message = this.copiedTooltip;
355
- this.tooltip.show();
356
- }
357
- };
358
- /**
359
- * @return {?}
360
- */
361
- TdCopyCodeButtonComponent.prototype.initializeTooltip = function () {
362
- var _this = this;
363
- setTimeout(( /**
364
- * @return {?}
365
- */function () {
366
- _this.tooltip.message = _this.copyTooltip;
367
- }), 200);
368
- };
369
- return TdCopyCodeButtonComponent;
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
- };
385
- if (false) {
386
- /** @type {?} */
387
- TdCopyCodeButtonComponent.prototype.copiedContent;
388
- /** @type {?} */
389
- TdCopyCodeButtonComponent.prototype.copyCodeToClipboard;
390
- /**
391
- * copyCodeTooltips?: ICopyCodeTooltips
392
- *
393
- * Tooltips for copy button to copy and upon copying.
394
- * @type {?}
395
- */
396
- TdCopyCodeButtonComponent.prototype.copyCodeTooltips;
397
- /** @type {?} */
398
- TdCopyCodeButtonComponent.prototype.tooltip;
399
- }
400
-
401
- /**
402
- * @fileoverview added by tsickle
403
- * Generated from: highlight.module.ts
404
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
405
- */
406
- var CovalentHighlightModule = /** @class */ (function () {
407
- function CovalentHighlightModule() {
408
- }
409
- return CovalentHighlightModule;
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
- */
436
-
437
- exports.CovalentHighlightModule = CovalentHighlightModule;
438
- exports.TdCopyCodeButtonComponent = TdCopyCodeButtonComponent;
439
- exports.TdHighlightComponent = TdHighlightComponent;
440
-
441
- Object.defineProperty(exports, '__esModule', { value: true });
442
-
443
- })));
444
- //# sourceMappingURL=covalent-highlight.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"covalent-highlight.umd.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":["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,GAAG,OAAO,CAAC;gBACxB,IAAI,IAAI,CAAC,YAAY,EAAE;oBACrB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;iBAClC;aACF;;;WAAA;QAyBD,sBACI,0CAAQ;;;;;;;;;;;iBADZ,UACa,IAAY;gBACvB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;aACxB;;;WAAA;QAED,sBACI,sCAAI;;;;;;iBADR,UACS,IAAY;;gBAEnB,OAAO,CAAC,IAAI,CAAC,oFAAoF,CAAC,CAAC;gBACnG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AC/D,OAAO,EAAE,CAAC,oBAAoB,CAAC;iBAChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,2 +0,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
- //# sourceMappingURL=covalent-highlight.umd.min.js.map