@covalent/flavored-markdown 3.1.2 → 4.0.0-beta.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 (35) hide show
  1. package/README.md +1 -1
  2. package/_flavored-markdown-theme.scss +1 -0
  3. package/cfm-list/cfm-list.component.d.ts +3 -0
  4. package/covalent-flavored-markdown.d.ts +1 -1
  5. package/esm2020/cfm-list/cfm-list.component.mjs +60 -0
  6. package/esm2020/covalent-flavored-markdown.mjs +5 -0
  7. package/esm2020/flavored-markdown-loader/flavored-markdown-loader.component.mjs +102 -0
  8. package/esm2020/flavored-markdown.component.mjs +476 -0
  9. package/esm2020/flavored-markdown.module.mjs +69 -0
  10. package/esm2020/index.mjs +2 -0
  11. package/esm2020/public_api.mjs +4 -0
  12. package/fesm2015/covalent-flavored-markdown.mjs +763 -0
  13. package/fesm2015/covalent-flavored-markdown.mjs.map +1 -0
  14. package/fesm2020/covalent-flavored-markdown.mjs +695 -0
  15. package/fesm2020/covalent-flavored-markdown.mjs.map +1 -0
  16. package/flavored-markdown-loader/flavored-markdown-loader.component.d.ts +3 -0
  17. package/flavored-markdown-loader/flavored-markdown-loader.component.scss +4 -2
  18. package/flavored-markdown.component.d.ts +26 -1
  19. package/flavored-markdown.component.scss +2 -0
  20. package/flavored-markdown.module.d.ts +16 -0
  21. package/package.json +35 -20
  22. package/bundles/covalent-flavored-markdown.umd.js +0 -1305
  23. package/bundles/covalent-flavored-markdown.umd.js.map +0 -1
  24. package/bundles/covalent-flavored-markdown.umd.min.js +0 -16
  25. package/bundles/covalent-flavored-markdown.umd.min.js.map +0 -1
  26. package/covalent-flavored-markdown.metadata.json +0 -1
  27. package/esm2015/cfm-list/cfm-list.component.js +0 -39
  28. package/esm2015/covalent-flavored-markdown.js +0 -11
  29. package/esm2015/flavored-markdown-loader/flavored-markdown-loader.component.js +0 -159
  30. package/esm2015/flavored-markdown.component.js +0 -741
  31. package/esm2015/flavored-markdown.module.js +0 -42
  32. package/esm2015/index.js +0 -7
  33. package/esm2015/public_api.js +0 -9
  34. package/fesm2015/covalent-flavored-markdown.js +0 -990
  35. package/fesm2015/covalent-flavored-markdown.js.map +0 -1
@@ -1,990 +0,0 @@
1
- import { Component, Input, EventEmitter, HostBinding, Output, Directive, ViewContainerRef, Renderer2, ChangeDetectionStrategy, ComponentFactoryResolver, ChangeDetectorRef, Injector, ElementRef, ViewChild, NgModule } from '@angular/core';
2
- import { MatCheckbox, MatCheckboxModule } from '@angular/material/checkbox';
3
- import { TdHighlightComponent, CovalentHighlightModule } from '@covalent/highlight';
4
- import { scrollToAnchor, TdMarkdownComponent, TdMarkdownLoaderService, CovalentMarkdownModule } from '@covalent/markdown';
5
- import { TdDataTableComponent, TdDataTableSortingOrder, CovalentDataTableModule } from '@covalent/core/data-table';
6
- import { CommonModule } from '@angular/common';
7
- import { MatListModule } from '@angular/material/list';
8
- import { __awaiter } from 'tslib';
9
- import { MatProgressBarModule } from '@angular/material/progress-bar';
10
- import { MatButtonModule } from '@angular/material/button';
11
-
12
- /**
13
- * @fileoverview added by tsickle
14
- * Generated from: cfm-list/cfm-list.component.ts
15
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
16
- */
17
- /**
18
- * @record
19
- */
20
- function IFlavoredListItem() { }
21
- if (false) {
22
- /** @type {?} */
23
- IFlavoredListItem.prototype.line;
24
- /** @type {?|undefined} */
25
- IFlavoredListItem.prototype.sublines;
26
- }
27
- class TdFlavoredListComponent {
28
- constructor() {
29
- this.dense = false;
30
- }
31
- }
32
- TdFlavoredListComponent.decorators = [
33
- { type: Component, args: [{
34
- selector: 'cfm-list',
35
- template: "<mat-list [attr.dense]=\"dense ? true : null\">\n <ng-template let-line let-last=\"last\" ngFor [ngForOf]=\"lines\">\n <mat-list-item>\n <h4 matLine>\n {{ line.line }}\n </h4>\n <p *ngFor=\"let subline of line.sublines\" matLine>\n {{ subline }}\n </p>\n <mat-divider *ngIf=\"!last\"></mat-divider>\n </mat-list-item>\n </ng-template>\n</mat-list>\n",
36
- styles: [""]
37
- }] }
38
- ];
39
- TdFlavoredListComponent.propDecorators = {
40
- lines: [{ type: Input }],
41
- dense: [{ type: Input }]
42
- };
43
- if (false) {
44
- /** @type {?} */
45
- TdFlavoredListComponent.prototype.lines;
46
- /** @type {?} */
47
- TdFlavoredListComponent.prototype.dense;
48
- }
49
-
50
- /**
51
- * @fileoverview added by tsickle
52
- * Generated from: flavored-markdown.component.ts
53
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
54
- */
55
- /**
56
- * @record
57
- */
58
- function ITdFlavoredMarkdownButtonClickEvent() { }
59
- if (false) {
60
- /** @type {?} */
61
- ITdFlavoredMarkdownButtonClickEvent.prototype.text;
62
- /** @type {?} */
63
- ITdFlavoredMarkdownButtonClickEvent.prototype.data;
64
- }
65
- class TdFlavoredMarkdownButtonComponent {
66
- constructor() {
67
- this.display = 'inline-block';
68
- this.text = '';
69
- this.data = '';
70
- this.clicked = new EventEmitter();
71
- }
72
- /**
73
- * @return {?}
74
- */
75
- emitClick() {
76
- this.clicked.emit({ text: this.text, data: this.data });
77
- }
78
- }
79
- TdFlavoredMarkdownButtonComponent.decorators = [
80
- { type: Component, args: [{
81
- template: `
82
- <button mat-raised-button (click)="emitClick()">
83
- {{ text }}
84
- </button>
85
- `
86
- }] }
87
- ];
88
- TdFlavoredMarkdownButtonComponent.propDecorators = {
89
- display: [{ type: HostBinding, args: ['style.display',] }],
90
- text: [{ type: Input }],
91
- data: [{ type: Input }],
92
- clicked: [{ type: Output }]
93
- };
94
- if (false) {
95
- /** @type {?} */
96
- TdFlavoredMarkdownButtonComponent.prototype.display;
97
- /** @type {?} */
98
- TdFlavoredMarkdownButtonComponent.prototype.text;
99
- /** @type {?} */
100
- TdFlavoredMarkdownButtonComponent.prototype.data;
101
- /** @type {?} */
102
- TdFlavoredMarkdownButtonComponent.prototype.clicked;
103
- }
104
- class TdFlavoredMarkdownContainerDirective {
105
- /**
106
- * @param {?} viewContainerRef
107
- * @param {?} _renderer
108
- */
109
- constructor(viewContainerRef, _renderer) {
110
- this.viewContainerRef = viewContainerRef;
111
- this._renderer = _renderer;
112
- }
113
- /**
114
- * @return {?}
115
- */
116
- clear() {
117
- this._renderer.setProperty(this.viewContainerRef.element.nativeElement, 'innerHTML', '');
118
- this.viewContainerRef.clear();
119
- }
120
- }
121
- TdFlavoredMarkdownContainerDirective.decorators = [
122
- { type: Directive, args: [{
123
- selector: '[tdFlavoredMarkdownContainer]',
124
- },] }
125
- ];
126
- /** @nocollapse */
127
- TdFlavoredMarkdownContainerDirective.ctorParameters = () => [
128
- { type: ViewContainerRef },
129
- { type: Renderer2 }
130
- ];
131
- if (false) {
132
- /** @type {?} */
133
- TdFlavoredMarkdownContainerDirective.prototype.viewContainerRef;
134
- /**
135
- * @type {?}
136
- * @private
137
- */
138
- TdFlavoredMarkdownContainerDirective.prototype._renderer;
139
- }
140
- class TdFlavoredMarkdownComponent {
141
- /**
142
- * @param {?} _componentFactoryResolver
143
- * @param {?} _renderer
144
- * @param {?} _changeDetectorRef
145
- * @param {?} _injector
146
- * @param {?} _elementRef
147
- */
148
- constructor(_componentFactoryResolver, _renderer, _changeDetectorRef, _injector, _elementRef) {
149
- this._componentFactoryResolver = _componentFactoryResolver;
150
- this._renderer = _renderer;
151
- this._changeDetectorRef = _changeDetectorRef;
152
- this._injector = _injector;
153
- this._elementRef = _elementRef;
154
- this._simpleLineBreaks = false;
155
- this._components = {};
156
- this._viewInit = false;
157
- /**
158
- * copyCodeToClipboard?: boolean
159
- *
160
- * Display copy button on code snippets to copy code to clipboard.
161
- *
162
- */
163
- this.copyCodeToClipboard = false;
164
- /**
165
- * copyCodeTooltips?: ICopyCodeTooltips
166
- *
167
- * Tooltips for copy button to copy and upon copying.
168
- */
169
- this.copyCodeTooltips = {};
170
- /**
171
- * contentReady?: function
172
- * Event emitted after the markdown content rendering is finished.
173
- */
174
- this.contentReady = new EventEmitter();
175
- /**
176
- * buttonClicked?: ITdFlavoredMarkdownButtonClickEvent
177
- * Event emitted when a button is clicked
178
- * Is an object containing text and data of button
179
- */
180
- this.buttonClicked = new EventEmitter();
181
- }
182
- /**
183
- * content?: string
184
- *
185
- * Markdown format content to be parsed as material/covalent markup.
186
- *
187
- * e.g. README.md content.
188
- * @param {?} content
189
- * @return {?}
190
- */
191
- set content(content) {
192
- this._content = content;
193
- }
194
- /**
195
- * simpleLineBreaks?: string
196
- *
197
- * Sets whether newline characters inside paragraphs and spans are parsed as <br/>.
198
- * Defaults to false.
199
- * @param {?} simpleLineBreaks
200
- * @return {?}
201
- */
202
- set simpleLineBreaks(simpleLineBreaks) {
203
- this._simpleLineBreaks = simpleLineBreaks;
204
- }
205
- /**
206
- * hostedUrl?: string
207
- *
208
- * If markdown contains relative paths, this is required to generate correct urls
209
- *
210
- * @param {?} hostedUrl
211
- * @return {?}
212
- */
213
- set hostedUrl(hostedUrl) {
214
- this._hostedUrl = hostedUrl;
215
- }
216
- /**
217
- * anchor?: string
218
- *
219
- * Anchor to jump to
220
- *
221
- * @param {?} anchor
222
- * @return {?}
223
- */
224
- set anchor(anchor) {
225
- this._anchor = anchor;
226
- }
227
- /**
228
- * @param {?} changes
229
- * @return {?}
230
- */
231
- ngOnChanges(changes) {
232
- // only anchor changed
233
- if (changes.anchor && !changes.content && !changes.simpleLineBreaks && !changes.hostedUrl) {
234
- scrollToAnchor(this._elementRef.nativeElement, this._anchor, false);
235
- }
236
- else {
237
- this.refresh();
238
- }
239
- }
240
- /**
241
- * @return {?}
242
- */
243
- ngAfterViewInit() {
244
- if (!this._content) {
245
- this._loadContent(((/** @type {?} */ (this.container.viewContainerRef.element.nativeElement))).textContent);
246
- Promise.resolve().then((/**
247
- * @return {?}
248
- */
249
- () => {
250
- this._viewInit = true;
251
- this._changeDetectorRef.markForCheck();
252
- }));
253
- }
254
- }
255
- /**
256
- * @return {?}
257
- */
258
- refresh() {
259
- if (this._content) {
260
- this._loadContent(this._content);
261
- }
262
- else if (this._viewInit) {
263
- this._loadContent(((/** @type {?} */ (this.container.viewContainerRef.element.nativeElement))).textContent);
264
- }
265
- this._changeDetectorRef.markForCheck();
266
- }
267
- /**
268
- * @private
269
- * @param {?} markdown
270
- * @return {?}
271
- */
272
- _loadContent(markdown) {
273
- if (markdown && markdown.trim().length > 0) {
274
- this.container.clear();
275
- markdown = markdown.replace(/^(\s|\t)*\n+/g, '').replace(/(\s|\t)*\n+(\s|\t)*$/g, '');
276
- // Split markdown by line characters
277
- /** @type {?} */
278
- let lines = markdown.split('\n');
279
- // check how much indentation is used by the first actual markdown line
280
- /** @type {?} */
281
- const firstLineWhitespace = lines[0].match(/^(\s|\t)*/)[0];
282
- // Remove all indentation spaces so markdown can be parsed correctly
283
- /** @type {?} */
284
- const startingWhitespaceRegex = new RegExp('^' + firstLineWhitespace);
285
- lines = lines.map((/**
286
- * @param {?} line
287
- * @return {?}
288
- */
289
- function (line) {
290
- return line.replace(startingWhitespaceRegex, '');
291
- }));
292
- // Join lines again with line characters
293
- markdown = [...lines, '', ''].join('\n');
294
- markdown = this._replaceCodeBlocks(markdown);
295
- markdown = this._replaceCheckbox(markdown);
296
- markdown = this._replaceTables(markdown);
297
- markdown = this._replaceLists(markdown);
298
- markdown = this._replaceButtons(markdown);
299
- /** @type {?} */
300
- const keys = Object.keys(this._components);
301
- // need to sort the placeholders in order of encounter in markdown content
302
- keys.sort((/**
303
- * @param {?} compA
304
- * @param {?} compB
305
- * @return {?}
306
- */
307
- (compA, compB) => {
308
- return markdown.indexOf(compA) > markdown.indexOf(compB) ? 1 : -1;
309
- }));
310
- this._render(markdown, keys[0], keys);
311
- // TODO: timeout required since resizing of html elements occurs which causes a change in the scroll position
312
- setTimeout((/**
313
- * @return {?}
314
- */
315
- () => scrollToAnchor(this._elementRef.nativeElement, this._anchor, false)), 250);
316
- this.contentReady.emit();
317
- Promise.resolve().then((/**
318
- * @return {?}
319
- */
320
- () => {
321
- this._changeDetectorRef.markForCheck();
322
- }));
323
- }
324
- }
325
- /**
326
- * @private
327
- * @param {?} markdown
328
- * @param {?} key
329
- * @param {?} keys
330
- * @return {?}
331
- */
332
- _render(markdown, key, keys) {
333
- if (!markdown) {
334
- return;
335
- }
336
- if (key && markdown.indexOf(key) > -1) {
337
- /** @type {?} */
338
- const markdownParts = markdown.split(key);
339
- keys.shift();
340
- this._render(markdownParts[0], undefined, undefined);
341
- this.container.viewContainerRef.insert(this._components[key].hostView, this.container.viewContainerRef.length);
342
- this._components[key] = undefined;
343
- delete this._components[key];
344
- this._render(markdownParts[1], keys[0], keys);
345
- }
346
- else {
347
- /** @type {?} */
348
- const contentRef = this._componentFactoryResolver
349
- .resolveComponentFactory(TdMarkdownComponent)
350
- .create(this._injector);
351
- contentRef.instance.content = markdown;
352
- contentRef.instance.hostedUrl = this._hostedUrl;
353
- contentRef.instance.simpleLineBreaks = this._simpleLineBreaks;
354
- contentRef.instance.refresh();
355
- this.container.viewContainerRef.insert(contentRef.hostView, this.container.viewContainerRef.length);
356
- }
357
- }
358
- /**
359
- * @private
360
- * @template T
361
- * @param {?} markdown
362
- * @param {?} type
363
- * @param {?} regExp
364
- * @param {?} replacerFunc
365
- * @return {?}
366
- */
367
- _replaceComponent(markdown, type, regExp, replacerFunc) {
368
- /** @type {?} */
369
- let componentIndex = 0;
370
- return markdown.replace(regExp, (/**
371
- * @param {...?} args
372
- * @return {?}
373
- */
374
- (...args) => {
375
- /** @type {?} */
376
- const componentFactory = this._componentFactoryResolver.resolveComponentFactory(type);
377
- /** @type {?} */
378
- const componentRef = componentFactory.create(this._injector);
379
- replacerFunc(componentRef, ...args);
380
- /** @type {?} */
381
- const key = '[' + componentFactory.selector + '-placeholder-' + componentIndex++ + ']';
382
- this._components[key] = componentRef;
383
- return key;
384
- }));
385
- }
386
- /**
387
- * @private
388
- * @param {?} markdown
389
- * @return {?}
390
- */
391
- _replaceCheckbox(markdown) {
392
- /** @type {?} */
393
- const checkboxRegExp = /(?:^|\n)- \[(x| )\](.*)/gi;
394
- return this._replaceComponent(markdown, MatCheckbox, checkboxRegExp, (/**
395
- * @param {?} componentRef
396
- * @param {?} match
397
- * @param {?} checked
398
- * @param {?} label
399
- * @return {?}
400
- */
401
- (componentRef, match, checked, label) => {
402
- componentRef.instance.checked = !!checked.trim();
403
- componentRef.instance.disabled = true;
404
- componentRef.instance.labelPosition = 'after';
405
- this._renderer.setProperty(((/** @type {?} */ (componentRef.instance._elementRef.nativeElement))).getElementsByClassName('mat-checkbox-label')[0], 'innerHTML', label);
406
- }));
407
- }
408
- /**
409
- * @private
410
- * @param {?} markdown
411
- * @return {?}
412
- */
413
- _replaceButtons(markdown) {
414
- /** @type {?} */
415
- const buttonRegExp = /\[([^\[]+)\](\(#data=(.*)\))/i;
416
- /** @type {?} */
417
- const globalButtonRegExp = new RegExp(buttonRegExp.source, buttonRegExp.flags + 'g');
418
- return this._replaceComponent(markdown, TdFlavoredMarkdownButtonComponent, globalButtonRegExp, (/**
419
- * @param {?} componentRef
420
- * @param {?} match
421
- * @return {?}
422
- */
423
- (componentRef, match) => {
424
- /** @type {?} */
425
- const matches = buttonRegExp.exec(match);
426
- /** @type {?} */
427
- const text = matches[1];
428
- /** @type {?} */
429
- const data = matches[3];
430
- componentRef.instance.text = text;
431
- componentRef.instance.data = data;
432
- componentRef.instance.clicked.subscribe((/**
433
- * @param {?} clickEvent
434
- * @return {?}
435
- */
436
- (clickEvent) => this.buttonClicked.emit(clickEvent)));
437
- }));
438
- }
439
- /**
440
- * @private
441
- * @param {?} markdown
442
- * @return {?}
443
- */
444
- _replaceCodeBlocks(markdown) {
445
- /** @type {?} */
446
- const codeBlockRegExp = /(?:^|\n)```(.*)\n([\s\S]*?)\n```/g;
447
- return this._replaceComponent(markdown, TdHighlightComponent, codeBlockRegExp, (/**
448
- * @param {?} componentRef
449
- * @param {?} match
450
- * @param {?} language
451
- * @param {?} codeblock
452
- * @return {?}
453
- */
454
- (componentRef, match, language, codeblock) => {
455
- if (language) {
456
- componentRef.instance.codeLang = language;
457
- }
458
- componentRef.instance.copyCodeToClipboard = this.copyCodeToClipboard;
459
- componentRef.instance.copyCodeTooltips = this.copyCodeTooltips;
460
- componentRef.instance.content = codeblock;
461
- }));
462
- }
463
- /**
464
- * @private
465
- * @param {?} markdown
466
- * @return {?}
467
- */
468
- _replaceTables(markdown) {
469
- /** @type {?} */
470
- const tableRgx = /^ {0,3}\|?.+\|.+\n[ \t]{0,3}\|?[ \t]*:?[ \t]*(?:-|=){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:-|=){2,}[\s\S]+?(?:\n\n|~0)/gm;
471
- return this._replaceComponent(markdown, TdDataTableComponent, tableRgx, (/**
472
- * @param {?} componentRef
473
- * @param {?} match
474
- * @return {?}
475
- */
476
- (componentRef, match) => {
477
- /** @type {?} */
478
- const dataTableLines = match.replace(/(\s|\t)*\n+(\s|\t)*$/g, '').split('\n');
479
- /** @type {?} */
480
- const columns = dataTableLines[0]
481
- .split('|')
482
- .filter((/**
483
- * @param {?} col
484
- * @return {?}
485
- */
486
- (col) => {
487
- return col;
488
- }))
489
- .map((/**
490
- * @param {?} s
491
- * @return {?}
492
- */
493
- (s) => {
494
- return s.trim();
495
- }));
496
- /** @type {?} */
497
- const alignment = dataTableLines[1]
498
- .split('|')
499
- .filter((/**
500
- * @param {?} v
501
- * @return {?}
502
- */
503
- (v) => {
504
- return v;
505
- }))
506
- .map((/**
507
- * @param {?} s
508
- * @return {?}
509
- */
510
- (s) => {
511
- return s.trim();
512
- }));
513
- componentRef.instance.columns = columns.map((/**
514
- * @param {?} col
515
- * @param {?} index
516
- * @return {?}
517
- */
518
- (col, index) => {
519
- /** @type {?} */
520
- const widths = alignment[index].split('---');
521
- /** @type {?} */
522
- const min = parseInt(widths[0], 10);
523
- /** @type {?} */
524
- const max = parseInt(widths[1], 10);
525
- /** @type {?} */
526
- let width = { min, max };
527
- if (isNaN(min) && isNaN(max)) {
528
- width = undefined;
529
- }
530
- else if (isNaN(max)) {
531
- width.max = undefined;
532
- }
533
- else if (isNaN(min)) {
534
- width.min = undefined;
535
- }
536
- return {
537
- label: col,
538
- name: col.toLowerCase().trim(),
539
- numeric: /^--*[ \t]*:[ \t]*$/.test(alignment[index]),
540
- width,
541
- };
542
- }));
543
- /** @type {?} */
544
- const data = [];
545
- for (let i = 2; i < dataTableLines.length; i++) {
546
- /** @type {?} */
547
- const rowSplit = dataTableLines[i]
548
- .split('|')
549
- .filter((/**
550
- * @param {?} cell
551
- * @return {?}
552
- */
553
- (cell) => {
554
- return cell;
555
- }))
556
- .map((/**
557
- * @param {?} s
558
- * @return {?}
559
- */
560
- (s) => {
561
- return s.trim();
562
- }));
563
- /** @type {?} */
564
- const row = {};
565
- columns.forEach((/**
566
- * @param {?} col
567
- * @param {?} index
568
- * @return {?}
569
- */
570
- (col, index) => {
571
- /** @type {?} */
572
- const rowSplitCell = rowSplit[index];
573
- if (rowSplitCell) {
574
- row[col.toLowerCase().trim()] = rowSplitCell.replace(/`(.*)`/, (/**
575
- * @param {?} m
576
- * @param {?} value
577
- * @return {?}
578
- */
579
- (m, value) => {
580
- return value;
581
- }));
582
- }
583
- }));
584
- data.push(row);
585
- }
586
- componentRef.instance.data = data;
587
- componentRef.instance.sortable = true;
588
- componentRef.instance.sortChange.subscribe((/**
589
- * @param {?} event
590
- * @return {?}
591
- */
592
- (event) => {
593
- componentRef.instance.data.sort((/**
594
- * @param {?} a
595
- * @param {?} b
596
- * @return {?}
597
- */
598
- (a, b) => {
599
- /** @type {?} */
600
- const compA = a[event.name];
601
- /** @type {?} */
602
- const compB = b[event.name];
603
- /** @type {?} */
604
- let direction = 0;
605
- if (!Number.isNaN(Number.parseFloat(compA)) && !Number.isNaN(Number.parseFloat(compB))) {
606
- direction = Number.parseFloat(compA) - Number.parseFloat(compB);
607
- }
608
- else {
609
- if (compA < compB) {
610
- direction = -1;
611
- }
612
- else if (compA > compB) {
613
- direction = 1;
614
- }
615
- }
616
- return direction * (event.order === TdDataTableSortingOrder.Descending ? -1 : 1);
617
- }));
618
- componentRef.instance.refresh();
619
- }));
620
- setTimeout((/**
621
- * @return {?}
622
- */
623
- () => {
624
- componentRef.instance.refresh();
625
- }));
626
- }));
627
- }
628
- /**
629
- * @private
630
- * @param {?} markdown
631
- * @return {?}
632
- */
633
- _replaceLists(markdown) {
634
- /** @type {?} */
635
- const listRegExp = /(?:^|\n)(( *\+)[ |\t](.*)\n)+/g;
636
- return this._replaceComponent(markdown, TdFlavoredListComponent, listRegExp, (/**
637
- * @param {?} componentRef
638
- * @param {?} match
639
- * @return {?}
640
- */
641
- (componentRef, match) => {
642
- /** @type {?} */
643
- const lineTexts = match.split(new RegExp('\\n {' + (match.indexOf('+') - 1).toString() + '}\\+[ |\\t]'));
644
- lineTexts.shift();
645
- /** @type {?} */
646
- const lines = [];
647
- lineTexts.forEach((/**
648
- * @param {?} text
649
- * @param {?} index
650
- * @return {?}
651
- */
652
- (text, index) => {
653
- /** @type {?} */
654
- const sublineTexts = text.split(/\n *\+ /);
655
- lines.push({
656
- line: sublineTexts.shift(),
657
- sublines: sublineTexts.map((/**
658
- * @param {?} subline
659
- * @return {?}
660
- */
661
- (subline) => {
662
- return subline.trim();
663
- })),
664
- });
665
- }));
666
- componentRef.instance.lines = lines;
667
- }));
668
- }
669
- }
670
- TdFlavoredMarkdownComponent.decorators = [
671
- { type: Component, args: [{
672
- selector: 'td-flavored-markdown',
673
- template: "<div tdFlavoredMarkdownContainer>\n <ng-content></ng-content>\n</div>\n",
674
- changeDetection: ChangeDetectionStrategy.OnPush,
675
- styles: [":host ::ng-deep td-markdown:first-of-type>div:first-of-type>h1:first-of-type,:host ::ng-deep td-markdown:first-of-type>div:first-of-type>h2:first-of-type{margin-top:0}:host ::ng-deep mat-checkbox,:host ::ng-deep td-data-table{display:block}:host ::ng-deep mat-checkbox:last-of-type,:host ::ng-deep td-data-table,:host ::ng-deep td-highlight{margin-bottom:16px}:host ::ng-deep :not(pre)>code{font-family:Menlo,Monaco,Andale Mono,lucida console,Courier New,monospace;padding-left:2px;padding-right:2px}:host ::ng-deep td-highlight{-ms-flex-direction:row;-ms-flex-pack:justify;display:-ms-flexbox;display:flex;flex-direction:row;justify-content:space-between}"]
676
- }] }
677
- ];
678
- /** @nocollapse */
679
- TdFlavoredMarkdownComponent.ctorParameters = () => [
680
- { type: ComponentFactoryResolver },
681
- { type: Renderer2 },
682
- { type: ChangeDetectorRef },
683
- { type: Injector },
684
- { type: ElementRef }
685
- ];
686
- TdFlavoredMarkdownComponent.propDecorators = {
687
- content: [{ type: Input, args: ['content',] }],
688
- simpleLineBreaks: [{ type: Input, args: ['simpleLineBreaks',] }],
689
- hostedUrl: [{ type: Input, args: ['hostedUrl',] }],
690
- anchor: [{ type: Input, args: ['anchor',] }],
691
- copyCodeToClipboard: [{ type: Input }],
692
- copyCodeTooltips: [{ type: Input }],
693
- contentReady: [{ type: Output }],
694
- buttonClicked: [{ type: Output }],
695
- container: [{ type: ViewChild, args: [TdFlavoredMarkdownContainerDirective, { static: true },] }]
696
- };
697
- if (false) {
698
- /**
699
- * @type {?}
700
- * @private
701
- */
702
- TdFlavoredMarkdownComponent.prototype._content;
703
- /**
704
- * @type {?}
705
- * @private
706
- */
707
- TdFlavoredMarkdownComponent.prototype._simpleLineBreaks;
708
- /**
709
- * @type {?}
710
- * @private
711
- */
712
- TdFlavoredMarkdownComponent.prototype._hostedUrl;
713
- /**
714
- * @type {?}
715
- * @private
716
- */
717
- TdFlavoredMarkdownComponent.prototype._anchor;
718
- /**
719
- * @type {?}
720
- * @private
721
- */
722
- TdFlavoredMarkdownComponent.prototype._components;
723
- /**
724
- * @type {?}
725
- * @private
726
- */
727
- TdFlavoredMarkdownComponent.prototype._viewInit;
728
- /**
729
- * copyCodeToClipboard?: boolean
730
- *
731
- * Display copy button on code snippets to copy code to clipboard.
732
- *
733
- * @type {?}
734
- */
735
- TdFlavoredMarkdownComponent.prototype.copyCodeToClipboard;
736
- /**
737
- * copyCodeTooltips?: ICopyCodeTooltips
738
- *
739
- * Tooltips for copy button to copy and upon copying.
740
- * @type {?}
741
- */
742
- TdFlavoredMarkdownComponent.prototype.copyCodeTooltips;
743
- /**
744
- * contentReady?: function
745
- * Event emitted after the markdown content rendering is finished.
746
- * @type {?}
747
- */
748
- TdFlavoredMarkdownComponent.prototype.contentReady;
749
- /**
750
- * buttonClicked?: ITdFlavoredMarkdownButtonClickEvent
751
- * Event emitted when a button is clicked
752
- * Is an object containing text and data of button
753
- * @type {?}
754
- */
755
- TdFlavoredMarkdownComponent.prototype.buttonClicked;
756
- /** @type {?} */
757
- TdFlavoredMarkdownComponent.prototype.container;
758
- /**
759
- * @type {?}
760
- * @private
761
- */
762
- TdFlavoredMarkdownComponent.prototype._componentFactoryResolver;
763
- /**
764
- * @type {?}
765
- * @private
766
- */
767
- TdFlavoredMarkdownComponent.prototype._renderer;
768
- /**
769
- * @type {?}
770
- * @private
771
- */
772
- TdFlavoredMarkdownComponent.prototype._changeDetectorRef;
773
- /**
774
- * @type {?}
775
- * @private
776
- */
777
- TdFlavoredMarkdownComponent.prototype._injector;
778
- /**
779
- * @type {?}
780
- * @private
781
- */
782
- TdFlavoredMarkdownComponent.prototype._elementRef;
783
- }
784
-
785
- /**
786
- * @fileoverview added by tsickle
787
- * Generated from: flavored-markdown-loader/flavored-markdown-loader.component.ts
788
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
789
- */
790
- // TODO: make a td-markdown-loader component
791
- class TdFlavoredMarkdownLoaderComponent {
792
- /**
793
- * @param {?} _changeDetectorRef
794
- * @param {?} _markdownUrlLoaderService
795
- */
796
- constructor(_changeDetectorRef, _markdownUrlLoaderService) {
797
- this._changeDetectorRef = _changeDetectorRef;
798
- this._markdownUrlLoaderService = _markdownUrlLoaderService;
799
- /**
800
- * copyCodeToClipboard?: boolean
801
- *
802
- * Display copy button on code snippets to copy code to clipboard.
803
- *
804
- */
805
- this.copyCodeToClipboard = false;
806
- /**
807
- * copyCodeTooltips?: ICopyCodeTooltips
808
- *
809
- * Tooltips for copy button to copy and upon copying.
810
- */
811
- this.copyCodeTooltips = {};
812
- /**
813
- * contentReady: void
814
- * Emitted when markdown rendering is finished.
815
- */
816
- this.contentReady = new EventEmitter();
817
- /**
818
- * loadFailed: Error
819
- * Emitted when loading of markdown file fails.
820
- */
821
- this.loadFailed = new EventEmitter();
822
- this.buttonClicked = new EventEmitter();
823
- this.loading = true;
824
- }
825
- /**
826
- * @param {?} changes
827
- * @return {?}
828
- */
829
- ngOnChanges(changes) {
830
- if (changes.url || changes.httpOptions) {
831
- this.loadMarkdown();
832
- }
833
- }
834
- /**
835
- * @return {?}
836
- */
837
- loadMarkdown() {
838
- return __awaiter(this, void 0, void 0, function* () {
839
- this.loading = true;
840
- this._changeDetectorRef.markForCheck();
841
- try {
842
- this.content = yield this._markdownUrlLoaderService.load(this.url, this.httpOptions);
843
- }
844
- catch (error) {
845
- this.loadFailed.emit(error);
846
- }
847
- finally {
848
- this.loading = false;
849
- this._changeDetectorRef.markForCheck();
850
- }
851
- });
852
- }
853
- }
854
- TdFlavoredMarkdownLoaderComponent.decorators = [
855
- { type: Component, args: [{
856
- selector: 'td-flavored-markdown-loader',
857
- template: "<mat-progress-bar\n [ngClass]=\"'delay'\"\n *ngIf=\"loading\"\n mode=\"indeterminate\"\n color=\"accent\"\n class=\"sticky\"\n></mat-progress-bar>\n<td-flavored-markdown\n *ngIf=\"!loading\"\n [content]=\"content\"\n [hostedUrl]=\"url\"\n [anchor]=\"anchor\"\n [copyCodeToClipboard]=\"copyCodeToClipboard\"\n [copyCodeTooltips]=\"copyCodeTooltips\"\n (contentReady)=\"contentReady.emit()\"\n (buttonClicked)=\"buttonClicked.emit($event)\"\n></td-flavored-markdown>\n",
858
- changeDetection: ChangeDetectionStrategy.OnPush,
859
- styles: [":host{display:block}.sticky{position:absolute;top:0}.delay{animation:delayAnimation;animation-duration:.6s}@keyframes delayAnimation{0%{opacity:0}99%{opacity:0}to{opacity:1}}"]
860
- }] }
861
- ];
862
- /** @nocollapse */
863
- TdFlavoredMarkdownLoaderComponent.ctorParameters = () => [
864
- { type: ChangeDetectorRef },
865
- { type: TdMarkdownLoaderService }
866
- ];
867
- TdFlavoredMarkdownLoaderComponent.propDecorators = {
868
- url: [{ type: Input }],
869
- httpOptions: [{ type: Input }],
870
- anchor: [{ type: Input }],
871
- copyCodeToClipboard: [{ type: Input }],
872
- copyCodeTooltips: [{ type: Input }],
873
- contentReady: [{ type: Output }],
874
- loadFailed: [{ type: Output }],
875
- buttonClicked: [{ type: Output }]
876
- };
877
- if (false) {
878
- /**
879
- * url: string
880
- * The url of the markdown file.
881
- * @type {?}
882
- */
883
- TdFlavoredMarkdownLoaderComponent.prototype.url;
884
- /**
885
- * httpOptions: object
886
- * HTTP options that can be part of the request.
887
- * @type {?}
888
- */
889
- TdFlavoredMarkdownLoaderComponent.prototype.httpOptions;
890
- /**
891
- * anchor: string
892
- * Anchor to jump to.
893
- * @type {?}
894
- */
895
- TdFlavoredMarkdownLoaderComponent.prototype.anchor;
896
- /**
897
- * copyCodeToClipboard?: boolean
898
- *
899
- * Display copy button on code snippets to copy code to clipboard.
900
- *
901
- * @type {?}
902
- */
903
- TdFlavoredMarkdownLoaderComponent.prototype.copyCodeToClipboard;
904
- /**
905
- * copyCodeTooltips?: ICopyCodeTooltips
906
- *
907
- * Tooltips for copy button to copy and upon copying.
908
- * @type {?}
909
- */
910
- TdFlavoredMarkdownLoaderComponent.prototype.copyCodeTooltips;
911
- /**
912
- * contentReady: void
913
- * Emitted when markdown rendering is finished.
914
- * @type {?}
915
- */
916
- TdFlavoredMarkdownLoaderComponent.prototype.contentReady;
917
- /**
918
- * loadFailed: Error
919
- * Emitted when loading of markdown file fails.
920
- * @type {?}
921
- */
922
- TdFlavoredMarkdownLoaderComponent.prototype.loadFailed;
923
- /** @type {?} */
924
- TdFlavoredMarkdownLoaderComponent.prototype.buttonClicked;
925
- /** @type {?} */
926
- TdFlavoredMarkdownLoaderComponent.prototype.content;
927
- /** @type {?} */
928
- TdFlavoredMarkdownLoaderComponent.prototype.loading;
929
- /**
930
- * @type {?}
931
- * @private
932
- */
933
- TdFlavoredMarkdownLoaderComponent.prototype._changeDetectorRef;
934
- /**
935
- * @type {?}
936
- * @private
937
- */
938
- TdFlavoredMarkdownLoaderComponent.prototype._markdownUrlLoaderService;
939
- }
940
-
941
- /**
942
- * @fileoverview added by tsickle
943
- * Generated from: flavored-markdown.module.ts
944
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
945
- */
946
- class CovalentFlavoredMarkdownModule {
947
- }
948
- CovalentFlavoredMarkdownModule.decorators = [
949
- { type: NgModule, args: [{
950
- imports: [
951
- CommonModule,
952
- MatCheckboxModule,
953
- MatListModule,
954
- MatProgressBarModule,
955
- CovalentDataTableModule,
956
- CovalentHighlightModule,
957
- CovalentMarkdownModule,
958
- MatButtonModule,
959
- ],
960
- declarations: [
961
- TdFlavoredListComponent,
962
- TdFlavoredMarkdownComponent,
963
- TdFlavoredMarkdownContainerDirective,
964
- TdFlavoredMarkdownLoaderComponent,
965
- TdFlavoredMarkdownButtonComponent,
966
- ],
967
- exports: [TdFlavoredMarkdownComponent, TdFlavoredMarkdownLoaderComponent],
968
- },] }
969
- ];
970
-
971
- /**
972
- * @fileoverview added by tsickle
973
- * Generated from: public_api.ts
974
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
975
- */
976
-
977
- /**
978
- * @fileoverview added by tsickle
979
- * Generated from: index.ts
980
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
981
- */
982
-
983
- /**
984
- * @fileoverview added by tsickle
985
- * Generated from: covalent-flavored-markdown.ts
986
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
987
- */
988
-
989
- export { CovalentFlavoredMarkdownModule, TdFlavoredMarkdownButtonComponent, TdFlavoredMarkdownComponent, TdFlavoredMarkdownContainerDirective, TdFlavoredMarkdownLoaderComponent, TdFlavoredListComponent as ɵa };
990
- //# sourceMappingURL=covalent-flavored-markdown.js.map