@covalent/markdown 4.0.0 → 4.1.0-develop.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -20
- package/_markdown-theme.scss +13 -1
- package/covalent-markdown.d.ts +2 -1
- package/esm2020/covalent-markdown.mjs +5 -0
- package/esm2020/lib/markdown-loader/markdown-loader.service.mjs +41 -0
- package/esm2020/lib/markdown-utils/markdown-utils.mjs +115 -0
- package/esm2020/lib/markdown.component.mjs +292 -0
- package/esm2020/lib/markdown.module.mjs +21 -0
- package/esm2020/public_api.mjs +5 -0
- package/fesm2015/covalent-markdown.mjs +467 -0
- package/fesm2015/covalent-markdown.mjs.map +1 -0
- package/fesm2020/covalent-markdown.mjs +464 -0
- package/fesm2020/covalent-markdown.mjs.map +1 -0
- package/{markdown-loader → lib/markdown-loader}/markdown-loader.service.d.ts +3 -0
- package/lib/markdown-utils/markdown-utils.d.ts +9 -0
- package/{markdown.component.d.ts → lib/markdown.component.d.ts} +9 -4
- package/lib/markdown.module.d.ts +9 -0
- package/package.json +27 -32
- package/public_api.d.ts +4 -4
- package/bundles/covalent-markdown.umd.js +0 -1055
- package/bundles/covalent-markdown.umd.js.map +0 -1
- package/bundles/covalent-markdown.umd.min.js +0 -16
- package/bundles/covalent-markdown.umd.min.js.map +0 -1
- package/covalent-markdown.metadata.json +0 -1
- package/esm2015/covalent-markdown.js +0 -10
- package/esm2015/index.js +0 -7
- package/esm2015/markdown-loader/markdown-loader.service.js +0 -69
- package/esm2015/markdown-utils/markdown-utils.js +0 -183
- package/esm2015/markdown.component.js +0 -439
- package/esm2015/markdown.module.js +0 -21
- package/esm2015/public_api.js +0 -10
- package/fesm2015/covalent-markdown.js +0 -724
- package/fesm2015/covalent-markdown.js.map +0 -1
- package/index.d.ts +0 -1
- package/markdown-utils/markdown-utils.d.ts +0 -9
- package/markdown.component.scss +0 -641
- package/markdown.module.d.ts +0 -2
|
@@ -1,724 +0,0 @@
|
|
|
1
|
-
import { EventEmitter, SecurityContext, Component, Renderer2, ElementRef, HostBinding, Input, Output, HostListener, Injectable, NgModule } from '@angular/core';
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
|
4
|
-
import { __awaiter } from 'tslib';
|
|
5
|
-
import { DomSanitizer } from '@angular/platform-browser';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @fileoverview added by tsickle
|
|
9
|
-
* Generated from: markdown-utils/markdown-utils.ts
|
|
10
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* @param {?} str
|
|
14
|
-
* @return {?}
|
|
15
|
-
*/
|
|
16
|
-
function removeLeadingHash(str) {
|
|
17
|
-
if (str) {
|
|
18
|
-
return str.replace(/^#+/, '');
|
|
19
|
-
}
|
|
20
|
-
return '';
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* @param {?} str
|
|
24
|
-
* @return {?}
|
|
25
|
-
*/
|
|
26
|
-
function removeTrailingHash(str) {
|
|
27
|
-
if (str) {
|
|
28
|
-
return str.replace(/\#.*/, '');
|
|
29
|
-
}
|
|
30
|
-
return '';
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* @param {?} str
|
|
34
|
-
* @return {?}
|
|
35
|
-
*/
|
|
36
|
-
function genHeadingId(str) {
|
|
37
|
-
if (str) {
|
|
38
|
-
return removeLeadingHash(str
|
|
39
|
-
.replace(/(_|-|\s)+/g, '')
|
|
40
|
-
// Remove certain special chars to create heading ids similar to those in github
|
|
41
|
-
// borrowed from showdown
|
|
42
|
-
// https://github.com/showdownjs/showdown/blob/develop/src/subParsers/makehtml/headers.js#L94
|
|
43
|
-
.replace(/[&+$,\/:;=?@"#{}|^¨~\[\]`\\*)(%.!'<>]/g, '')).toLowerCase();
|
|
44
|
-
}
|
|
45
|
-
return '';
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* @param {?} scope
|
|
49
|
-
* @param {?} anchor
|
|
50
|
-
* @param {?} tryParent
|
|
51
|
-
* @return {?}
|
|
52
|
-
*/
|
|
53
|
-
function scrollToAnchor(scope, anchor, tryParent) {
|
|
54
|
-
if (scope && anchor) {
|
|
55
|
-
/** @type {?} */
|
|
56
|
-
const normalizedAnchor = genHeadingId(anchor);
|
|
57
|
-
/** @type {?} */
|
|
58
|
-
let headingToJumpTo;
|
|
59
|
-
/** @type {?} */
|
|
60
|
-
const headingWithinComponent = scope.querySelector(`[id="${normalizedAnchor}"]`);
|
|
61
|
-
if (headingWithinComponent) {
|
|
62
|
-
headingToJumpTo = headingWithinComponent;
|
|
63
|
-
}
|
|
64
|
-
else if (tryParent) {
|
|
65
|
-
/** @type {?} */
|
|
66
|
-
const parent = scope.parentElement;
|
|
67
|
-
if (parent) {
|
|
68
|
-
headingToJumpTo = parent.querySelector(`[id="${normalizedAnchor}"]`);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (headingToJumpTo) {
|
|
72
|
-
headingToJumpTo.scrollIntoView({ behavior: 'auto' });
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* @param {?} anchor
|
|
80
|
-
* @return {?}
|
|
81
|
-
*/
|
|
82
|
-
function isAnchorLink(anchor) {
|
|
83
|
-
if (anchor) {
|
|
84
|
-
/** @type {?} */
|
|
85
|
-
const href = anchor.getAttribute('href');
|
|
86
|
-
if (href) {
|
|
87
|
-
return href.startsWith('#');
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
/** @type {?} */
|
|
93
|
-
const RAW_GITHUB_HOSTNAME = 'raw.githubusercontent.com';
|
|
94
|
-
/**
|
|
95
|
-
* @param {?} githubHref
|
|
96
|
-
* @return {?}
|
|
97
|
-
*/
|
|
98
|
-
function rawGithubHref(githubHref) {
|
|
99
|
-
if (githubHref) {
|
|
100
|
-
try {
|
|
101
|
-
/** @type {?} */
|
|
102
|
-
const url = new URL(githubHref);
|
|
103
|
-
if (url.hostname === RAW_GITHUB_HOSTNAME) {
|
|
104
|
-
return url.href;
|
|
105
|
-
}
|
|
106
|
-
else if (isGithubHref(githubHref)) {
|
|
107
|
-
url.hostname = RAW_GITHUB_HOSTNAME;
|
|
108
|
-
url.pathname = url.pathname.split('/blob', 2).join('');
|
|
109
|
-
return url.href;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
catch (_a) {
|
|
113
|
-
return '';
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return '';
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* @param {?} href
|
|
120
|
-
* @return {?}
|
|
121
|
-
*/
|
|
122
|
-
function isGithubHref(href) {
|
|
123
|
-
try {
|
|
124
|
-
/** @type {?} */
|
|
125
|
-
const temp = new URL(href);
|
|
126
|
-
return temp.hostname === 'github.com';
|
|
127
|
-
}
|
|
128
|
-
catch (_a) {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* @param {?} href
|
|
134
|
-
* @return {?}
|
|
135
|
-
*/
|
|
136
|
-
function isRawGithubHref(href) {
|
|
137
|
-
try {
|
|
138
|
-
/** @type {?} */
|
|
139
|
-
const temp = new URL(href);
|
|
140
|
-
return temp.hostname === RAW_GITHUB_HOSTNAME;
|
|
141
|
-
}
|
|
142
|
-
catch (_a) {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* @param {?} html
|
|
148
|
-
* @return {?}
|
|
149
|
-
*/
|
|
150
|
-
function renderVideoElements(html) {
|
|
151
|
-
/** @type {?} */
|
|
152
|
-
const ytLongEmbed = /!\[(?:(?:https?:)?(?:\/\/)?)(?:(?:www)?.)?youtube.(?:.+?)\/(?:(?:embed\/)([\w-]{11})(\?[\w%;-]+(?:=[\w%;-]+)?(?:&[\w%;-]+(?:=[\w%;-]+)?)*)?)]/gi;
|
|
153
|
-
/** @type {?} */
|
|
154
|
-
const ytLongWatch = /!\[(?:(?:https?:)?(?:\/\/)?)(?:(?:www)?.)?youtube.(?:.+?)\/(?:(?:watch\?v=)([\w-]{11})(&[\w%;-]+(?:=[\w%;-]+)?)*)]/gi;
|
|
155
|
-
/** @type {?} */
|
|
156
|
-
const ytShort = /!\[(?:(?:https?:)?(?:\/\/)?)?youtu.be\/([\w-]{11})\??([\w%;-]+(?:=[\w%;-]+)?(?:&[\w%;-]+(?:=[\w%;-]+)?)*)?]/gi;
|
|
157
|
-
/** @type {?} */
|
|
158
|
-
const ytPlaylist = /!\[(?:(?:https?:)?(?:\/\/)?)(?:(?:www)?.)?youtube.(?:.+?)\/(?:(?:playlist\?list=)([\w-]{34})(&[\w%;-]+(?:=[\w%;-]+)?)*)]/gi;
|
|
159
|
-
/**
|
|
160
|
-
* @param {?} match
|
|
161
|
-
* @param {?} id
|
|
162
|
-
* @param {?} flags
|
|
163
|
-
* @return {?}
|
|
164
|
-
*/
|
|
165
|
-
function convert(match, id, flags) {
|
|
166
|
-
if (flags) {
|
|
167
|
-
id += '?' + flags.replace(/&/gi, '&');
|
|
168
|
-
}
|
|
169
|
-
return `<iframe allow="fullscreen" frameborder="0" src="https://www.youtube.com/embed/${id}"></iframe>`;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* @param {?} match
|
|
173
|
-
* @param {?} id
|
|
174
|
-
* @param {?} flags
|
|
175
|
-
* @return {?}
|
|
176
|
-
*/
|
|
177
|
-
function convertPL(match, id, flags) {
|
|
178
|
-
if (flags) {
|
|
179
|
-
id += flags.replace(/&/gi, '&');
|
|
180
|
-
}
|
|
181
|
-
return `<iframe allow="fullscreen" frameborder="0" src="https://www.youtube.com/embed/videoseries?list=${id}"></iframe>`;
|
|
182
|
-
}
|
|
183
|
-
return html
|
|
184
|
-
.replace(ytLongWatch, convert)
|
|
185
|
-
.replace(ytLongEmbed, convert)
|
|
186
|
-
.replace(ytShort, convert)
|
|
187
|
-
.replace(ytPlaylist, convertPL);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* @fileoverview added by tsickle
|
|
192
|
-
* Generated from: markdown.component.ts
|
|
193
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
194
|
-
*/
|
|
195
|
-
/* tslint:disable-next-line */
|
|
196
|
-
/** @type {?} */
|
|
197
|
-
let showdown = require('showdown/dist/showdown.js');
|
|
198
|
-
// TODO: assumes it is a github url
|
|
199
|
-
// allow override somehow
|
|
200
|
-
/**
|
|
201
|
-
* @param {?} currentHref
|
|
202
|
-
* @param {?} relativeHref
|
|
203
|
-
* @return {?}
|
|
204
|
-
*/
|
|
205
|
-
function generateAbsoluteHref(currentHref, relativeHref) {
|
|
206
|
-
if (currentHref && relativeHref) {
|
|
207
|
-
/** @type {?} */
|
|
208
|
-
const currentUrl = new URL(currentHref);
|
|
209
|
-
/** @type {?} */
|
|
210
|
-
const path = currentUrl.pathname.split('/').slice(1, -1).join('/');
|
|
211
|
-
/** @type {?} */
|
|
212
|
-
const correctUrl = new URL(currentHref);
|
|
213
|
-
if (relativeHref.startsWith('/')) {
|
|
214
|
-
// url is relative to top level
|
|
215
|
-
/** @type {?} */
|
|
216
|
-
const orgAndRepo = path.split('/').slice(0, 3).join('/');
|
|
217
|
-
correctUrl.pathname = `${orgAndRepo}${relativeHref}`;
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
correctUrl.pathname = `${path}/${relativeHref}`;
|
|
221
|
-
}
|
|
222
|
-
return correctUrl.href;
|
|
223
|
-
}
|
|
224
|
-
return undefined;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* @param {?} html
|
|
228
|
-
* @param {?} currentHref
|
|
229
|
-
* @return {?}
|
|
230
|
-
*/
|
|
231
|
-
function normalizeHtmlHrefs(html, currentHref) {
|
|
232
|
-
if (currentHref) {
|
|
233
|
-
/** @type {?} */
|
|
234
|
-
const document = new DOMParser().parseFromString(html, 'text/html');
|
|
235
|
-
document.querySelectorAll('a[href]').forEach((/**
|
|
236
|
-
* @param {?} link
|
|
237
|
-
* @return {?}
|
|
238
|
-
*/
|
|
239
|
-
(link) => {
|
|
240
|
-
/** @type {?} */
|
|
241
|
-
const url = new URL(link.href);
|
|
242
|
-
/** @type {?} */
|
|
243
|
-
const originalHash = url.hash;
|
|
244
|
-
if (isAnchorLink(link)) {
|
|
245
|
-
if (originalHash) {
|
|
246
|
-
url.hash = genHeadingId(originalHash);
|
|
247
|
-
link.href = url.hash;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
else if (url.host === window.location.host) {
|
|
251
|
-
// hosts match, meaning URL MIGHT have been malformed by showdown
|
|
252
|
-
// url is a relative url or just a link to a part of the application
|
|
253
|
-
if (url.pathname.endsWith('.md')) {
|
|
254
|
-
// only check .md urls
|
|
255
|
-
/** @type {?} */
|
|
256
|
-
const hrefWithoutHash = removeTrailingHash(link.getAttribute('href'));
|
|
257
|
-
url.href = generateAbsoluteHref(currentHref, hrefWithoutHash);
|
|
258
|
-
if (originalHash) {
|
|
259
|
-
url.hash = genHeadingId(originalHash);
|
|
260
|
-
}
|
|
261
|
-
link.href = url.href;
|
|
262
|
-
}
|
|
263
|
-
link.target = '_blank';
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
// url is absolute
|
|
267
|
-
if (url.pathname.endsWith('.md')) {
|
|
268
|
-
if (originalHash) {
|
|
269
|
-
url.hash = genHeadingId(originalHash);
|
|
270
|
-
}
|
|
271
|
-
link.href = url.href;
|
|
272
|
-
}
|
|
273
|
-
link.target = '_blank';
|
|
274
|
-
}
|
|
275
|
-
}));
|
|
276
|
-
return new XMLSerializer().serializeToString(document);
|
|
277
|
-
}
|
|
278
|
-
return html;
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* @param {?} html
|
|
282
|
-
* @param {?} currentHref
|
|
283
|
-
* @return {?}
|
|
284
|
-
*/
|
|
285
|
-
function normalizeImageSrcs(html, currentHref) {
|
|
286
|
-
if (currentHref) {
|
|
287
|
-
/** @type {?} */
|
|
288
|
-
const document = new DOMParser().parseFromString(html, 'text/html');
|
|
289
|
-
document.querySelectorAll('img[src]').forEach((/**
|
|
290
|
-
* @param {?} image
|
|
291
|
-
* @return {?}
|
|
292
|
-
*/
|
|
293
|
-
(image) => {
|
|
294
|
-
/** @type {?} */
|
|
295
|
-
const src = image.getAttribute('src');
|
|
296
|
-
try {
|
|
297
|
-
/* tslint:disable-next-line:no-unused-expression */
|
|
298
|
-
new URL(src);
|
|
299
|
-
if (isGithubHref(src)) {
|
|
300
|
-
image.src = rawGithubHref(src);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
catch (_a) {
|
|
304
|
-
image.src = generateAbsoluteHref(isGithubHref(currentHref) ? rawGithubHref(currentHref) : currentHref, src);
|
|
305
|
-
}
|
|
306
|
-
// gh svgs need to have ?sanitize=true
|
|
307
|
-
if (isRawGithubHref(image.src)) {
|
|
308
|
-
/** @type {?} */
|
|
309
|
-
const url = new URL(image.src);
|
|
310
|
-
if (url.pathname.endsWith('.svg')) {
|
|
311
|
-
url.searchParams.set('sanitize', 'true');
|
|
312
|
-
image.src = url.href;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}));
|
|
316
|
-
return new XMLSerializer().serializeToString(document);
|
|
317
|
-
}
|
|
318
|
-
return html;
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* @param {?} html
|
|
322
|
-
* @return {?}
|
|
323
|
-
*/
|
|
324
|
-
function addIdsToHeadings(html) {
|
|
325
|
-
if (html) {
|
|
326
|
-
/** @type {?} */
|
|
327
|
-
const document = new DOMParser().parseFromString(html, 'text/html');
|
|
328
|
-
document.querySelectorAll('h1, h2, h3, h4, h5, h6').forEach((/**
|
|
329
|
-
* @param {?} heading
|
|
330
|
-
* @return {?}
|
|
331
|
-
*/
|
|
332
|
-
(heading) => {
|
|
333
|
-
/** @type {?} */
|
|
334
|
-
const id = genHeadingId(heading.innerHTML);
|
|
335
|
-
heading.setAttribute('id', id);
|
|
336
|
-
}));
|
|
337
|
-
return new XMLSerializer().serializeToString(document);
|
|
338
|
-
}
|
|
339
|
-
return html;
|
|
340
|
-
}
|
|
341
|
-
class TdMarkdownComponent {
|
|
342
|
-
/**
|
|
343
|
-
* @param {?} _renderer
|
|
344
|
-
* @param {?} _elementRef
|
|
345
|
-
* @param {?} _domSanitizer
|
|
346
|
-
*/
|
|
347
|
-
constructor(_renderer, _elementRef, _domSanitizer) {
|
|
348
|
-
this._renderer = _renderer;
|
|
349
|
-
this._elementRef = _elementRef;
|
|
350
|
-
this._domSanitizer = _domSanitizer;
|
|
351
|
-
this._simpleLineBreaks = false;
|
|
352
|
-
this._viewInit = false;
|
|
353
|
-
/**
|
|
354
|
-
* .td-markdown class added to host so ::ng-deep gets scoped.
|
|
355
|
-
*/
|
|
356
|
-
this.class = 'td-markdown';
|
|
357
|
-
/**
|
|
358
|
-
* contentReady?: function
|
|
359
|
-
* Event emitted after the markdown content rendering is finished.
|
|
360
|
-
*/
|
|
361
|
-
this.contentReady = new EventEmitter();
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* content?: string
|
|
365
|
-
*
|
|
366
|
-
* Markdown format content to be parsed as html markup.
|
|
367
|
-
*
|
|
368
|
-
* e.g. README.md content.
|
|
369
|
-
* @param {?} content
|
|
370
|
-
* @return {?}
|
|
371
|
-
*/
|
|
372
|
-
set content(content) {
|
|
373
|
-
this._content = content;
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* simpleLineBreaks?: string
|
|
377
|
-
*
|
|
378
|
-
* Sets whether newline characters inside paragraphs and spans are parsed as <br/>.
|
|
379
|
-
* Defaults to false.
|
|
380
|
-
* @param {?} simpleLineBreaks
|
|
381
|
-
* @return {?}
|
|
382
|
-
*/
|
|
383
|
-
set simpleLineBreaks(simpleLineBreaks) {
|
|
384
|
-
this._simpleLineBreaks = simpleLineBreaks;
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* hostedUrl?: string
|
|
388
|
-
*
|
|
389
|
-
* If markdown contains relative paths, this is required to generate correct urls.
|
|
390
|
-
*
|
|
391
|
-
* @param {?} hostedUrl
|
|
392
|
-
* @return {?}
|
|
393
|
-
*/
|
|
394
|
-
set hostedUrl(hostedUrl) {
|
|
395
|
-
this._hostedUrl = hostedUrl;
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* anchor?: string
|
|
399
|
-
*
|
|
400
|
-
* Anchor to jump to.
|
|
401
|
-
*
|
|
402
|
-
* @param {?} anchor
|
|
403
|
-
* @return {?}
|
|
404
|
-
*/
|
|
405
|
-
set anchor(anchor) {
|
|
406
|
-
this._anchor = anchor;
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* @param {?} event
|
|
410
|
-
* @return {?}
|
|
411
|
-
*/
|
|
412
|
-
clickListener(event) {
|
|
413
|
-
/** @type {?} */
|
|
414
|
-
const element = (/** @type {?} */ (event.srcElement));
|
|
415
|
-
if (element.matches('a[href]') && isAnchorLink((/** @type {?} */ (element)))) {
|
|
416
|
-
this.handleAnchorClicks(event);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
* @param {?} changes
|
|
421
|
-
* @return {?}
|
|
422
|
-
*/
|
|
423
|
-
ngOnChanges(changes) {
|
|
424
|
-
// only anchor changed
|
|
425
|
-
if (changes.anchor && !changes.content && !changes.simpleLineBreaks && !changes.hostedUrl) {
|
|
426
|
-
scrollToAnchor(this._elementRef.nativeElement, this._anchor, true);
|
|
427
|
-
}
|
|
428
|
-
else {
|
|
429
|
-
this.refresh();
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* @return {?}
|
|
434
|
-
*/
|
|
435
|
-
ngAfterViewInit() {
|
|
436
|
-
if (!this._content) {
|
|
437
|
-
this._loadContent(((/** @type {?} */ (this._elementRef.nativeElement))).textContent);
|
|
438
|
-
}
|
|
439
|
-
this._viewInit = true;
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* @return {?}
|
|
443
|
-
*/
|
|
444
|
-
refresh() {
|
|
445
|
-
if (this._content) {
|
|
446
|
-
this._loadContent(this._content);
|
|
447
|
-
}
|
|
448
|
-
else if (this._viewInit) {
|
|
449
|
-
this._loadContent(((/** @type {?} */ (this._elementRef.nativeElement))).textContent);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* General method to parse a string markdown into HTML Elements and load them into the container
|
|
454
|
-
* @private
|
|
455
|
-
* @param {?} markdown
|
|
456
|
-
* @return {?}
|
|
457
|
-
*/
|
|
458
|
-
_loadContent(markdown) {
|
|
459
|
-
if (markdown && markdown.trim().length > 0) {
|
|
460
|
-
// Clean container
|
|
461
|
-
this._renderer.setProperty(this._elementRef.nativeElement, 'innerHTML', '');
|
|
462
|
-
// Parse html string into actual HTML elements.
|
|
463
|
-
this._elementFromString(this._render(markdown));
|
|
464
|
-
}
|
|
465
|
-
// TODO: timeout required since resizing of html elements occurs which causes a change in the scroll position
|
|
466
|
-
setTimeout((/**
|
|
467
|
-
* @return {?}
|
|
468
|
-
*/
|
|
469
|
-
() => scrollToAnchor(this._elementRef.nativeElement, this._anchor, true)), 250);
|
|
470
|
-
this.contentReady.emit();
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* @private
|
|
474
|
-
* @param {?} event
|
|
475
|
-
* @return {?}
|
|
476
|
-
*/
|
|
477
|
-
handleAnchorClicks(event) {
|
|
478
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
479
|
-
event.preventDefault();
|
|
480
|
-
/** @type {?} */
|
|
481
|
-
const url = new URL(((/** @type {?} */ (event.target))).href);
|
|
482
|
-
/** @type {?} */
|
|
483
|
-
const hash = decodeURI(url.hash);
|
|
484
|
-
scrollToAnchor(this._elementRef.nativeElement, hash, true);
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
/**
|
|
488
|
-
* @private
|
|
489
|
-
* @param {?} markupStr
|
|
490
|
-
* @return {?}
|
|
491
|
-
*/
|
|
492
|
-
_elementFromString(markupStr) {
|
|
493
|
-
// Renderer2 doesnt have a parsing method, so we have to sanitize and use [innerHTML]
|
|
494
|
-
// to parse the string into DOM element for now.
|
|
495
|
-
/** @type {?} */
|
|
496
|
-
const div = this._renderer.createElement('div');
|
|
497
|
-
this._renderer.appendChild(this._elementRef.nativeElement, div);
|
|
498
|
-
/** @type {?} */
|
|
499
|
-
const html = this._domSanitizer.sanitize(SecurityContext.HTML, markupStr);
|
|
500
|
-
/** @type {?} */
|
|
501
|
-
const htmlWithAbsoluteHrefs = normalizeHtmlHrefs(html, this._hostedUrl);
|
|
502
|
-
/** @type {?} */
|
|
503
|
-
const htmlWithAbsoluteImgSrcs = normalizeImageSrcs(htmlWithAbsoluteHrefs, this._hostedUrl);
|
|
504
|
-
/** @type {?} */
|
|
505
|
-
const htmlWithHeadingIds = addIdsToHeadings(htmlWithAbsoluteImgSrcs);
|
|
506
|
-
/** @type {?} */
|
|
507
|
-
const htmlWithVideos = renderVideoElements(htmlWithHeadingIds);
|
|
508
|
-
this._renderer.setProperty(div, 'innerHTML', htmlWithVideos);
|
|
509
|
-
return div;
|
|
510
|
-
}
|
|
511
|
-
/**
|
|
512
|
-
* @private
|
|
513
|
-
* @param {?} markdown
|
|
514
|
-
* @return {?}
|
|
515
|
-
*/
|
|
516
|
-
_render(markdown) {
|
|
517
|
-
// Trim leading and trailing newlines
|
|
518
|
-
markdown = markdown.replace(/^(\s|\t)*\n+/g, '').replace(/(\s|\t)*\n+(\s|\t)*$/g, '');
|
|
519
|
-
// Split markdown by line characters
|
|
520
|
-
/** @type {?} */
|
|
521
|
-
let lines = markdown.split('\n');
|
|
522
|
-
// check how much indentation is used by the first actual markdown line
|
|
523
|
-
/** @type {?} */
|
|
524
|
-
const firstLineWhitespace = lines[0].match(/^(\s|\t)*/)[0];
|
|
525
|
-
// Remove all indentation spaces so markdown can be parsed correctly
|
|
526
|
-
/** @type {?} */
|
|
527
|
-
const startingWhitespaceRegex = new RegExp('^' + firstLineWhitespace);
|
|
528
|
-
lines = lines.map((/**
|
|
529
|
-
* @param {?} line
|
|
530
|
-
* @return {?}
|
|
531
|
-
*/
|
|
532
|
-
function (line) {
|
|
533
|
-
return line.replace(startingWhitespaceRegex, '');
|
|
534
|
-
}));
|
|
535
|
-
// Join lines again with line characters
|
|
536
|
-
/** @type {?} */
|
|
537
|
-
const markdownToParse = lines.join('\n');
|
|
538
|
-
// Convert markdown into html
|
|
539
|
-
/** @type {?} */
|
|
540
|
-
const converter = new showdown.Converter();
|
|
541
|
-
converter.setOption('ghCodeBlocks', true);
|
|
542
|
-
converter.setOption('tasklists', true);
|
|
543
|
-
converter.setOption('tables', true);
|
|
544
|
-
converter.setOption('literalMidWordUnderscores', true);
|
|
545
|
-
converter.setOption('simpleLineBreaks', this._simpleLineBreaks);
|
|
546
|
-
return converter.makeHtml(markdownToParse);
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
TdMarkdownComponent.decorators = [
|
|
550
|
-
{ type: Component, args: [{
|
|
551
|
-
selector: 'td-markdown',
|
|
552
|
-
template: "<ng-content></ng-content>\n",
|
|
553
|
-
styles: ["@font-face{:host.td-markdown::ng-deep{font-family:octicons-link;src:url(\"data:font/woff;charset=utf-8;base64,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\") format(\"woff\")}}:host.td-markdown::ng-deep a{-webkit-text-decoration-skip:objects;background-color:rgba(0,0,0,0)}:host.td-markdown::ng-deep a:active,:host.td-markdown::ng-deep a:hover{outline-width:0}:host.td-markdown::ng-deep strong{font-weight:inherit;font-weight:bolder}:host.td-markdown::ng-deep h1{font-size:2em;margin:.67em 0}:host.td-markdown::ng-deep img{border-style:none}:host.td-markdown::ng-deep svg:not(:root){overflow:hidden}:host.td-markdown::ng-deep code,:host.td-markdown::ng-deep kbd,:host.td-markdown::ng-deep pre{font-family:monospace;font-size:1em}:host.td-markdown::ng-deep hr{box-sizing:content-box;overflow:visible}:host.td-markdown::ng-deep input{font:inherit;margin:0;overflow:visible}:host.td-markdown::ng-deep [type=button]:-moz-focusring,:host.td-markdown::ng-deep [type=reset]:-moz-focusring,:host.td-markdown::ng-deep [type=submit]:-moz-focusring,:host.td-markdown::ng-deep button:-moz-focusring{outline:1px dotted ButtonText}:host.td-markdown::ng-deep [type=checkbox]{box-sizing:border-box;padding:0}:host.td-markdown::ng-deep table{border-collapse:collapse;border-spacing:0}:host.td-markdown::ng-deep td,:host.td-markdown::ng-deep th{padding:0}:host.td-markdown::ng-deep *{box-sizing:border-box}:host.td-markdown::ng-deep input{font:13px/1.4 Helvetica,arial,nimbussansl,liberationsans,freesans,clean,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol}:host.td-markdown::ng-deep a{text-decoration:none}:host.td-markdown::ng-deep a:active,:host.td-markdown::ng-deep a:hover{text-decoration:underline}:host.td-markdown::ng-deep hr{background:rgba(0,0,0,0);border-bottom-style:solid;border-bottom-width:1px;height:0;margin:15px 0;overflow:hidden}:host.td-markdown::ng-deep hr:before{content:\"\";display:table}:host.td-markdown::ng-deep hr:after{clear:both;content:\"\";display:table}:host.td-markdown::ng-deep h1,:host.td-markdown::ng-deep h2,:host.td-markdown::ng-deep h3,:host.td-markdown::ng-deep h4,:host.td-markdown::ng-deep h5,:host.td-markdown::ng-deep h6{line-height:1.5;margin-bottom:0;margin-top:0}:host.td-markdown::ng-deep h1{font-size:30px}:host.td-markdown::ng-deep h2{font-size:21px}:host.td-markdown::ng-deep h3{font-size:16px}:host.td-markdown::ng-deep h4{font-size:14px}:host.td-markdown::ng-deep h5{font-size:12px}:host.td-markdown::ng-deep h6{font-size:11px}:host.td-markdown::ng-deep p{margin-bottom:10px;margin-top:0}:host.td-markdown::ng-deep blockquote{margin:0}:host.td-markdown::ng-deep ol,:host.td-markdown::ng-deep ul{margin-bottom:0;margin-top:0;padding-left:0}:host.td-markdown::ng-deep ol ol,:host.td-markdown::ng-deep ul ol{list-style-type:lower-roman}:host.td-markdown::ng-deep ol ol ol,:host.td-markdown::ng-deep ol ul ol,:host.td-markdown::ng-deep ul ol ol,:host.td-markdown::ng-deep ul ul ol{list-style-type:lower-alpha}:host.td-markdown::ng-deep dd{margin-left:0}:host.td-markdown::ng-deep code{font-family:Consolas,Liberation Mono,Menlo,Courier,monospace;font-size:12px}:host.td-markdown::ng-deep pre{font:12px Consolas,Liberation Mono,Menlo,Courier,monospace;margin-bottom:0;margin-top:0}:host.td-markdown::ng-deep .pl-0{padding-left:0!important}:host.td-markdown::ng-deep .pl-1{padding-left:3px!important}:host.td-markdown::ng-deep .pl-2{padding-left:6px!important}:host.td-markdown::ng-deep .pl-3{padding-left:12px!important}:host.td-markdown::ng-deep .pl-4{padding-left:24px!important}:host.td-markdown::ng-deep .pl-5{padding-left:36px!important}:host.td-markdown::ng-deep .pl-6{padding-left:48px!important}:host.td-markdown::ng-deep .form-select::-ms-expand{opacity:0}:host.td-markdown::ng-deep a:not([href]){color:inherit;text-decoration:none}:host.td-markdown::ng-deep h1,:host.td-markdown::ng-deep h2,:host.td-markdown::ng-deep h3,:host.td-markdown::ng-deep h4,:host.td-markdown::ng-deep h5,:host.td-markdown::ng-deep h6{font-weight:700;line-height:1.4;margin-bottom:16px;margin-top:1em}:host.td-markdown::ng-deep h1 .octicon-link,:host.td-markdown::ng-deep h2 .octicon-link,:host.td-markdown::ng-deep h3 .octicon-link,:host.td-markdown::ng-deep h4 .octicon-link,:host.td-markdown::ng-deep h5 .octicon-link,:host.td-markdown::ng-deep h6 .octicon-link{color:#000;vertical-align:middle;visibility:hidden}:host.td-markdown::ng-deep h1:hover .anchor,:host.td-markdown::ng-deep h2:hover .anchor,:host.td-markdown::ng-deep h3:hover .anchor,:host.td-markdown::ng-deep h4:hover .anchor,:host.td-markdown::ng-deep h5:hover .anchor,:host.td-markdown::ng-deep h6:hover .anchor{text-decoration:none}:host.td-markdown::ng-deep h1:hover .anchor .octicon-link,:host.td-markdown::ng-deep h2:hover .anchor .octicon-link,:host.td-markdown::ng-deep h3:hover .anchor .octicon-link,:host.td-markdown::ng-deep h4:hover .anchor .octicon-link,:host.td-markdown::ng-deep h5:hover .anchor .octicon-link,:host.td-markdown::ng-deep h6:hover .anchor .octicon-link{visibility:visible}:host.td-markdown::ng-deep h1{border-bottom-style:solid;border-bottom-width:1px;font-size:2.25em;line-height:1.2;padding-bottom:.3em}:host.td-markdown::ng-deep h1 .anchor{line-height:1}:host.td-markdown::ng-deep h2{border-bottom-style:solid;border-bottom-width:1px;font-size:1.75em;line-height:1.225;padding-bottom:.3em}:host.td-markdown::ng-deep h2 .anchor{line-height:1}:host.td-markdown::ng-deep h3{font-size:1.5em;line-height:1.43}:host.td-markdown::ng-deep h3 .anchor{line-height:1.2}:host.td-markdown::ng-deep h4{font-size:1.25em}:host.td-markdown::ng-deep h4 .anchor{line-height:1.2}:host.td-markdown::ng-deep h5{font-size:1em}:host.td-markdown::ng-deep h5 .anchor{line-height:1.1}:host.td-markdown::ng-deep h6{font-size:1em}:host.td-markdown::ng-deep h6 .anchor{line-height:1.1}:host.td-markdown::ng-deep blockquote,:host.td-markdown::ng-deep dl,:host.td-markdown::ng-deep ol,:host.td-markdown::ng-deep p,:host.td-markdown::ng-deep pre,:host.td-markdown::ng-deep table,:host.td-markdown::ng-deep ul{margin-bottom:16px;margin-top:0}:host.td-markdown::ng-deep hr{margin:16px 0}:host.td-markdown::ng-deep ol,:host.td-markdown::ng-deep ul{padding-left:2em}:host.td-markdown::ng-deep ol ol,:host.td-markdown::ng-deep ol ul,:host.td-markdown::ng-deep ul ol,:host.td-markdown::ng-deep ul ul{margin-bottom:0;margin-top:0}:host.td-markdown::ng-deep li>p{margin-top:16px}:host.td-markdown::ng-deep dl{padding:0}:host.td-markdown::ng-deep dl dt{font-size:1em;font-style:italic;font-weight:700;margin-top:16px;padding:0}:host.td-markdown::ng-deep dl dd{margin-bottom:16px;padding:0 16px}:host.td-markdown::ng-deep blockquote{border-left-style:solid;border-left-width:4px;padding:0 15px}:host.td-markdown::ng-deep blockquote>:first-child{margin-top:0}:host.td-markdown::ng-deep blockquote>:last-child{margin-bottom:0}:host.td-markdown::ng-deep table{display:block;overflow:auto;width:100%;word-break:normal;word-break:keep-all}:host.td-markdown::ng-deep table th{font-weight:700}:host.td-markdown::ng-deep table td,:host.td-markdown::ng-deep table th{border-style:solid;border-width:1px;padding:6px 13px}:host.td-markdown::ng-deep table tr{border-top-style:solid;border-top-width:1px}:host.td-markdown::ng-deep img{box-sizing:content-box;max-width:100%}:host.td-markdown::ng-deep code{border-radius:3px;font-size:85%;margin:0;padding:.2em 0}:host.td-markdown::ng-deep code:after,:host.td-markdown::ng-deep code:before{letter-spacing:-.2em}:host.td-markdown::ng-deep pre>code{background:rgba(0,0,0,0);border:0;font-size:100%;margin:0;padding:0;white-space:pre;word-break:normal}:host.td-markdown::ng-deep .highlight{margin-bottom:16px}:host.td-markdown::ng-deep .highlight pre,:host.td-markdown::ng-deep pre{border-radius:3px;font-size:85%;line-height:1.45;overflow:auto;padding:16px}:host.td-markdown::ng-deep .highlight pre{margin-bottom:0;word-break:normal}:host.td-markdown::ng-deep pre{word-wrap:normal}:host.td-markdown::ng-deep pre code{background-color:rgba(0,0,0,0);border:0;display:inline;line-height:inherit;margin:0;max-width:none;overflow:initial;padding:0;word-wrap:normal}:host.td-markdown::ng-deep pre code:after,:host.td-markdown::ng-deep pre code:before{content:normal}:host.td-markdown::ng-deep kbd{border-style:solid;border-width:1px;font-size:11px}:host.td-markdown::ng-deep .pl-c{color:#969896}:host.td-markdown::ng-deep .pl-c1,:host.td-markdown::ng-deep .pl-s .pl-v{color:#0086b3}:host.td-markdown::ng-deep .pl-e,:host.td-markdown::ng-deep .pl-en{color:#795da3}:host.td-markdown::ng-deep .pl-s .pl-s1,:host.td-markdown::ng-deep .pl-smi{color:#333}:host.td-markdown::ng-deep .pl-ent{color:#63a35c}:host.td-markdown::ng-deep .pl-k{color:#a71d5d}:host.td-markdown::ng-deep .pl-pds,:host.td-markdown::ng-deep .pl-s,:host.td-markdown::ng-deep .pl-s .pl-pse .pl-s1,:host.td-markdown::ng-deep .pl-sr,:host.td-markdown::ng-deep .pl-sr .pl-cce,:host.td-markdown::ng-deep .pl-sr .pl-sra,:host.td-markdown::ng-deep .pl-sr .pl-sre{color:#183691}:host.td-markdown::ng-deep .pl-v{color:#ed6a43}:host.td-markdown::ng-deep .pl-id{color:#b52a1d}:host.td-markdown::ng-deep .pl-ii{background-color:#b52a1d;color:#f8f8f8}:host.td-markdown::ng-deep .pl-sr .pl-cce{color:#63a35c;font-weight:700}:host.td-markdown::ng-deep .pl-ml{color:#693a17}:host.td-markdown::ng-deep .pl-mh,:host.td-markdown::ng-deep .pl-mh .pl-en,:host.td-markdown::ng-deep .pl-ms{color:#1d3e81;font-weight:700}:host.td-markdown::ng-deep .pl-mq{color:teal}:host.td-markdown::ng-deep .pl-mi{color:#333;font-style:italic}:host.td-markdown::ng-deep .pl-mb{color:#333;font-weight:700}:host.td-markdown::ng-deep .pl-md{background-color:#ffecec;color:#bd2c00}:host.td-markdown::ng-deep .pl-mi1{background-color:#eaffea;color:#55a532}:host.td-markdown::ng-deep .pl-mdr{color:#795da3;font-weight:700}:host.td-markdown::ng-deep .pl-mo{color:#1d3e81}:host.td-markdown::ng-deep kbd{background-color:#fcfcfc;border:1px solid;border-color:#ccc #ccc #bbb;border-radius:3px;box-shadow:inset 0 -1px 0 #bbb;display:inline-block;font:11px Consolas,Liberation Mono,Menlo,Courier,monospace;line-height:10px;padding:3px 5px;vertical-align:middle}:host.td-markdown::ng-deep .full-commit .btn-outline:not(:disabled):hover{border:1px solid #4078c0;color:#4078c0}:host.td-markdown::ng-deep :checked+.radio-label{border-color:#4078c0;position:relative;z-index:1}:host.td-markdown::ng-deep .octicon{display:inline-block;fill:currentColor;vertical-align:text-top}:host.td-markdown::ng-deep .task-list-item{list-style-type:none}:host.td-markdown::ng-deep .task-list-item+.task-list-item{margin-top:3px}:host.td-markdown::ng-deep .task-list-item input{margin:0 .2em .25em -1.6em;vertical-align:middle}"]
|
|
554
|
-
}] }
|
|
555
|
-
];
|
|
556
|
-
/** @nocollapse */
|
|
557
|
-
TdMarkdownComponent.ctorParameters = () => [
|
|
558
|
-
{ type: Renderer2 },
|
|
559
|
-
{ type: ElementRef },
|
|
560
|
-
{ type: DomSanitizer }
|
|
561
|
-
];
|
|
562
|
-
TdMarkdownComponent.propDecorators = {
|
|
563
|
-
class: [{ type: HostBinding, args: ['class',] }],
|
|
564
|
-
content: [{ type: Input, args: ['content',] }],
|
|
565
|
-
simpleLineBreaks: [{ type: Input, args: ['simpleLineBreaks',] }],
|
|
566
|
-
hostedUrl: [{ type: Input, args: ['hostedUrl',] }],
|
|
567
|
-
anchor: [{ type: Input, args: ['anchor',] }],
|
|
568
|
-
contentReady: [{ type: Output }],
|
|
569
|
-
clickListener: [{ type: HostListener, args: ['click', ['$event'],] }]
|
|
570
|
-
};
|
|
571
|
-
if (false) {
|
|
572
|
-
/**
|
|
573
|
-
* @type {?}
|
|
574
|
-
* @private
|
|
575
|
-
*/
|
|
576
|
-
TdMarkdownComponent.prototype._content;
|
|
577
|
-
/**
|
|
578
|
-
* @type {?}
|
|
579
|
-
* @private
|
|
580
|
-
*/
|
|
581
|
-
TdMarkdownComponent.prototype._simpleLineBreaks;
|
|
582
|
-
/**
|
|
583
|
-
* @type {?}
|
|
584
|
-
* @private
|
|
585
|
-
*/
|
|
586
|
-
TdMarkdownComponent.prototype._hostedUrl;
|
|
587
|
-
/**
|
|
588
|
-
* @type {?}
|
|
589
|
-
* @private
|
|
590
|
-
*/
|
|
591
|
-
TdMarkdownComponent.prototype._anchor;
|
|
592
|
-
/**
|
|
593
|
-
* @type {?}
|
|
594
|
-
* @private
|
|
595
|
-
*/
|
|
596
|
-
TdMarkdownComponent.prototype._viewInit;
|
|
597
|
-
/**
|
|
598
|
-
* .td-markdown class added to host so ::ng-deep gets scoped.
|
|
599
|
-
* @type {?}
|
|
600
|
-
*/
|
|
601
|
-
TdMarkdownComponent.prototype.class;
|
|
602
|
-
/**
|
|
603
|
-
* contentReady?: function
|
|
604
|
-
* Event emitted after the markdown content rendering is finished.
|
|
605
|
-
* @type {?}
|
|
606
|
-
*/
|
|
607
|
-
TdMarkdownComponent.prototype.contentReady;
|
|
608
|
-
/**
|
|
609
|
-
* @type {?}
|
|
610
|
-
* @private
|
|
611
|
-
*/
|
|
612
|
-
TdMarkdownComponent.prototype._renderer;
|
|
613
|
-
/**
|
|
614
|
-
* @type {?}
|
|
615
|
-
* @private
|
|
616
|
-
*/
|
|
617
|
-
TdMarkdownComponent.prototype._elementRef;
|
|
618
|
-
/**
|
|
619
|
-
* @type {?}
|
|
620
|
-
* @private
|
|
621
|
-
*/
|
|
622
|
-
TdMarkdownComponent.prototype._domSanitizer;
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
/**
|
|
626
|
-
* @fileoverview added by tsickle
|
|
627
|
-
* Generated from: markdown-loader/markdown-loader.service.ts
|
|
628
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
629
|
-
*/
|
|
630
|
-
class TdMarkdownLoaderService {
|
|
631
|
-
/**
|
|
632
|
-
* @param {?} _http
|
|
633
|
-
* @param {?} _sanitizer
|
|
634
|
-
*/
|
|
635
|
-
constructor(_http, _sanitizer) {
|
|
636
|
-
this._http = _http;
|
|
637
|
-
this._sanitizer = _sanitizer;
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* @param {?} url
|
|
641
|
-
* @param {?=} httpOptions
|
|
642
|
-
* @return {?}
|
|
643
|
-
*/
|
|
644
|
-
load(url, httpOptions = {}) {
|
|
645
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
646
|
-
/** @type {?} */
|
|
647
|
-
const sanitizedUrl = this._sanitizer.sanitize(SecurityContext.URL, url);
|
|
648
|
-
/** @type {?} */
|
|
649
|
-
let urlToGet = sanitizedUrl;
|
|
650
|
-
if (isGithubHref(sanitizedUrl)) {
|
|
651
|
-
urlToGet = rawGithubHref(sanitizedUrl);
|
|
652
|
-
}
|
|
653
|
-
/** @type {?} */
|
|
654
|
-
const response = yield this._http
|
|
655
|
-
.get(urlToGet, Object.assign(Object.assign({}, httpOptions), { responseType: 'text', observe: 'response' }))
|
|
656
|
-
.toPromise();
|
|
657
|
-
/** @type {?} */
|
|
658
|
-
const contentType = response.headers.get('Content-Type');
|
|
659
|
-
if (contentType.includes('text/plain') || contentType.includes('text/markdown')) {
|
|
660
|
-
return response.body;
|
|
661
|
-
}
|
|
662
|
-
else {
|
|
663
|
-
throw Error(`${contentType} is not a handled content type`);
|
|
664
|
-
}
|
|
665
|
-
});
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
TdMarkdownLoaderService.decorators = [
|
|
669
|
-
{ type: Injectable }
|
|
670
|
-
];
|
|
671
|
-
/** @nocollapse */
|
|
672
|
-
TdMarkdownLoaderService.ctorParameters = () => [
|
|
673
|
-
{ type: HttpClient },
|
|
674
|
-
{ type: DomSanitizer }
|
|
675
|
-
];
|
|
676
|
-
if (false) {
|
|
677
|
-
/**
|
|
678
|
-
* @type {?}
|
|
679
|
-
* @private
|
|
680
|
-
*/
|
|
681
|
-
TdMarkdownLoaderService.prototype._http;
|
|
682
|
-
/**
|
|
683
|
-
* @type {?}
|
|
684
|
-
* @private
|
|
685
|
-
*/
|
|
686
|
-
TdMarkdownLoaderService.prototype._sanitizer;
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
/**
|
|
690
|
-
* @fileoverview added by tsickle
|
|
691
|
-
* Generated from: markdown.module.ts
|
|
692
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
693
|
-
*/
|
|
694
|
-
class CovalentMarkdownModule {
|
|
695
|
-
}
|
|
696
|
-
CovalentMarkdownModule.decorators = [
|
|
697
|
-
{ type: NgModule, args: [{
|
|
698
|
-
imports: [CommonModule, HttpClientModule],
|
|
699
|
-
declarations: [TdMarkdownComponent],
|
|
700
|
-
exports: [TdMarkdownComponent],
|
|
701
|
-
providers: [TdMarkdownLoaderService],
|
|
702
|
-
},] }
|
|
703
|
-
];
|
|
704
|
-
|
|
705
|
-
/**
|
|
706
|
-
* @fileoverview added by tsickle
|
|
707
|
-
* Generated from: public_api.ts
|
|
708
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
709
|
-
*/
|
|
710
|
-
|
|
711
|
-
/**
|
|
712
|
-
* @fileoverview added by tsickle
|
|
713
|
-
* Generated from: index.ts
|
|
714
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
715
|
-
*/
|
|
716
|
-
|
|
717
|
-
/**
|
|
718
|
-
* @fileoverview added by tsickle
|
|
719
|
-
* Generated from: covalent-markdown.ts
|
|
720
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
721
|
-
*/
|
|
722
|
-
|
|
723
|
-
export { CovalentMarkdownModule, TdMarkdownComponent, TdMarkdownLoaderService, genHeadingId, isAnchorLink, isGithubHref, isRawGithubHref, rawGithubHref, removeLeadingHash, removeTrailingHash, renderVideoElements, scrollToAnchor };
|
|
724
|
-
//# sourceMappingURL=covalent-markdown.js.map
|