@covalent/flavored-markdown 4.0.0-alpha.0 → 4.0.0-beta.4

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