@covalent/markdown 4.0.0 → 4.1.0-develop.10
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 +28 -24
- 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,1055 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/common/http'), require('@angular/platform-browser')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@covalent/markdown', ['exports', '@angular/core', '@angular/common', '@angular/common/http', '@angular/platform-browser'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.covalent = global.covalent || {}, global.covalent.markdown = {}), global.ng.core, global.ng.common, global.ng.common.http, global.ng.platformBrowser));
|
|
5
|
-
}(this, (function (exports, core, common, http, platformBrowser) { 'use strict';
|
|
6
|
-
|
|
7
|
-
/*! *****************************************************************************
|
|
8
|
-
Copyright (c) Microsoft Corporation.
|
|
9
|
-
|
|
10
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
-
purpose with or without fee is hereby granted.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
-
***************************************************************************** */
|
|
21
|
-
/* global Reflect, Promise */
|
|
22
|
-
var extendStatics = function (d, b) {
|
|
23
|
-
extendStatics = Object.setPrototypeOf ||
|
|
24
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
25
|
-
function (d, b) { for (var p in b)
|
|
26
|
-
if (Object.prototype.hasOwnProperty.call(b, p))
|
|
27
|
-
d[p] = b[p]; };
|
|
28
|
-
return extendStatics(d, b);
|
|
29
|
-
};
|
|
30
|
-
function __extends(d, b) {
|
|
31
|
-
extendStatics(d, b);
|
|
32
|
-
function __() { this.constructor = d; }
|
|
33
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
34
|
-
}
|
|
35
|
-
var __assign = function () {
|
|
36
|
-
__assign = Object.assign || function __assign(t) {
|
|
37
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
38
|
-
s = arguments[i];
|
|
39
|
-
for (var p in s)
|
|
40
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
41
|
-
t[p] = s[p];
|
|
42
|
-
}
|
|
43
|
-
return t;
|
|
44
|
-
};
|
|
45
|
-
return __assign.apply(this, arguments);
|
|
46
|
-
};
|
|
47
|
-
function __rest(s, e) {
|
|
48
|
-
var t = {};
|
|
49
|
-
for (var p in s)
|
|
50
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
51
|
-
t[p] = s[p];
|
|
52
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
53
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
55
|
-
t[p[i]] = s[p[i]];
|
|
56
|
-
}
|
|
57
|
-
return t;
|
|
58
|
-
}
|
|
59
|
-
function __decorate(decorators, target, key, desc) {
|
|
60
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
61
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
62
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
63
|
-
else
|
|
64
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
65
|
-
if (d = decorators[i])
|
|
66
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
67
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
68
|
-
}
|
|
69
|
-
function __param(paramIndex, decorator) {
|
|
70
|
-
return function (target, key) { decorator(target, key, paramIndex); };
|
|
71
|
-
}
|
|
72
|
-
function __metadata(metadataKey, metadataValue) {
|
|
73
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
74
|
-
return Reflect.metadata(metadataKey, metadataValue);
|
|
75
|
-
}
|
|
76
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
77
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
78
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
79
|
-
function fulfilled(value) { try {
|
|
80
|
-
step(generator.next(value));
|
|
81
|
-
}
|
|
82
|
-
catch (e) {
|
|
83
|
-
reject(e);
|
|
84
|
-
} }
|
|
85
|
-
function rejected(value) { try {
|
|
86
|
-
step(generator["throw"](value));
|
|
87
|
-
}
|
|
88
|
-
catch (e) {
|
|
89
|
-
reject(e);
|
|
90
|
-
} }
|
|
91
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
92
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
function __generator(thisArg, body) {
|
|
96
|
-
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
97
|
-
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
98
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
99
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
100
|
-
function step(op) {
|
|
101
|
-
if (f)
|
|
102
|
-
throw new TypeError("Generator is already executing.");
|
|
103
|
-
while (_)
|
|
104
|
-
try {
|
|
105
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
106
|
-
return t;
|
|
107
|
-
if (y = 0, t)
|
|
108
|
-
op = [op[0] & 2, t.value];
|
|
109
|
-
switch (op[0]) {
|
|
110
|
-
case 0:
|
|
111
|
-
case 1:
|
|
112
|
-
t = op;
|
|
113
|
-
break;
|
|
114
|
-
case 4:
|
|
115
|
-
_.label++;
|
|
116
|
-
return { value: op[1], done: false };
|
|
117
|
-
case 5:
|
|
118
|
-
_.label++;
|
|
119
|
-
y = op[1];
|
|
120
|
-
op = [0];
|
|
121
|
-
continue;
|
|
122
|
-
case 7:
|
|
123
|
-
op = _.ops.pop();
|
|
124
|
-
_.trys.pop();
|
|
125
|
-
continue;
|
|
126
|
-
default:
|
|
127
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
128
|
-
_ = 0;
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
132
|
-
_.label = op[1];
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
136
|
-
_.label = t[1];
|
|
137
|
-
t = op;
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
if (t && _.label < t[2]) {
|
|
141
|
-
_.label = t[2];
|
|
142
|
-
_.ops.push(op);
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
if (t[2])
|
|
146
|
-
_.ops.pop();
|
|
147
|
-
_.trys.pop();
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
op = body.call(thisArg, _);
|
|
151
|
-
}
|
|
152
|
-
catch (e) {
|
|
153
|
-
op = [6, e];
|
|
154
|
-
y = 0;
|
|
155
|
-
}
|
|
156
|
-
finally {
|
|
157
|
-
f = t = 0;
|
|
158
|
-
}
|
|
159
|
-
if (op[0] & 5)
|
|
160
|
-
throw op[1];
|
|
161
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
|
165
|
-
if (k2 === undefined)
|
|
166
|
-
k2 = k;
|
|
167
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
|
168
|
-
}) : (function (o, m, k, k2) {
|
|
169
|
-
if (k2 === undefined)
|
|
170
|
-
k2 = k;
|
|
171
|
-
o[k2] = m[k];
|
|
172
|
-
});
|
|
173
|
-
function __exportStar(m, o) {
|
|
174
|
-
for (var p in m)
|
|
175
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
|
176
|
-
__createBinding(o, m, p);
|
|
177
|
-
}
|
|
178
|
-
function __values(o) {
|
|
179
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
180
|
-
if (m)
|
|
181
|
-
return m.call(o);
|
|
182
|
-
if (o && typeof o.length === "number")
|
|
183
|
-
return {
|
|
184
|
-
next: function () {
|
|
185
|
-
if (o && i >= o.length)
|
|
186
|
-
o = void 0;
|
|
187
|
-
return { value: o && o[i++], done: !o };
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
191
|
-
}
|
|
192
|
-
function __read(o, n) {
|
|
193
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
194
|
-
if (!m)
|
|
195
|
-
return o;
|
|
196
|
-
var i = m.call(o), r, ar = [], e;
|
|
197
|
-
try {
|
|
198
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
199
|
-
ar.push(r.value);
|
|
200
|
-
}
|
|
201
|
-
catch (error) {
|
|
202
|
-
e = { error: error };
|
|
203
|
-
}
|
|
204
|
-
finally {
|
|
205
|
-
try {
|
|
206
|
-
if (r && !r.done && (m = i["return"]))
|
|
207
|
-
m.call(i);
|
|
208
|
-
}
|
|
209
|
-
finally {
|
|
210
|
-
if (e)
|
|
211
|
-
throw e.error;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
return ar;
|
|
215
|
-
}
|
|
216
|
-
function __spread() {
|
|
217
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
218
|
-
ar = ar.concat(__read(arguments[i]));
|
|
219
|
-
return ar;
|
|
220
|
-
}
|
|
221
|
-
function __spreadArrays() {
|
|
222
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
223
|
-
s += arguments[i].length;
|
|
224
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
225
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
226
|
-
r[k] = a[j];
|
|
227
|
-
return r;
|
|
228
|
-
}
|
|
229
|
-
;
|
|
230
|
-
function __await(v) {
|
|
231
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
232
|
-
}
|
|
233
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
234
|
-
if (!Symbol.asyncIterator)
|
|
235
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
236
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
237
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
238
|
-
function verb(n) { if (g[n])
|
|
239
|
-
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
240
|
-
function resume(n, v) { try {
|
|
241
|
-
step(g[n](v));
|
|
242
|
-
}
|
|
243
|
-
catch (e) {
|
|
244
|
-
settle(q[0][3], e);
|
|
245
|
-
} }
|
|
246
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
247
|
-
function fulfill(value) { resume("next", value); }
|
|
248
|
-
function reject(value) { resume("throw", value); }
|
|
249
|
-
function settle(f, v) { if (f(v), q.shift(), q.length)
|
|
250
|
-
resume(q[0][0], q[0][1]); }
|
|
251
|
-
}
|
|
252
|
-
function __asyncDelegator(o) {
|
|
253
|
-
var i, p;
|
|
254
|
-
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
255
|
-
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
256
|
-
}
|
|
257
|
-
function __asyncValues(o) {
|
|
258
|
-
if (!Symbol.asyncIterator)
|
|
259
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
260
|
-
var m = o[Symbol.asyncIterator], i;
|
|
261
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
262
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
263
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
|
264
|
-
}
|
|
265
|
-
function __makeTemplateObject(cooked, raw) {
|
|
266
|
-
if (Object.defineProperty) {
|
|
267
|
-
Object.defineProperty(cooked, "raw", { value: raw });
|
|
268
|
-
}
|
|
269
|
-
else {
|
|
270
|
-
cooked.raw = raw;
|
|
271
|
-
}
|
|
272
|
-
return cooked;
|
|
273
|
-
}
|
|
274
|
-
;
|
|
275
|
-
var __setModuleDefault = Object.create ? (function (o, v) {
|
|
276
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
277
|
-
}) : function (o, v) {
|
|
278
|
-
o["default"] = v;
|
|
279
|
-
};
|
|
280
|
-
function __importStar(mod) {
|
|
281
|
-
if (mod && mod.__esModule)
|
|
282
|
-
return mod;
|
|
283
|
-
var result = {};
|
|
284
|
-
if (mod != null)
|
|
285
|
-
for (var k in mod)
|
|
286
|
-
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
287
|
-
__createBinding(result, mod, k);
|
|
288
|
-
__setModuleDefault(result, mod);
|
|
289
|
-
return result;
|
|
290
|
-
}
|
|
291
|
-
function __importDefault(mod) {
|
|
292
|
-
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
293
|
-
}
|
|
294
|
-
function __classPrivateFieldGet(receiver, privateMap) {
|
|
295
|
-
if (!privateMap.has(receiver)) {
|
|
296
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
297
|
-
}
|
|
298
|
-
return privateMap.get(receiver);
|
|
299
|
-
}
|
|
300
|
-
function __classPrivateFieldSet(receiver, privateMap, value) {
|
|
301
|
-
if (!privateMap.has(receiver)) {
|
|
302
|
-
throw new TypeError("attempted to set private field on non-instance");
|
|
303
|
-
}
|
|
304
|
-
privateMap.set(receiver, value);
|
|
305
|
-
return value;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* @fileoverview added by tsickle
|
|
310
|
-
* Generated from: markdown-utils/markdown-utils.ts
|
|
311
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
312
|
-
*/
|
|
313
|
-
/**
|
|
314
|
-
* @param {?} str
|
|
315
|
-
* @return {?}
|
|
316
|
-
*/
|
|
317
|
-
function removeLeadingHash(str) {
|
|
318
|
-
if (str) {
|
|
319
|
-
return str.replace(/^#+/, '');
|
|
320
|
-
}
|
|
321
|
-
return '';
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* @param {?} str
|
|
325
|
-
* @return {?}
|
|
326
|
-
*/
|
|
327
|
-
function removeTrailingHash(str) {
|
|
328
|
-
if (str) {
|
|
329
|
-
return str.replace(/\#.*/, '');
|
|
330
|
-
}
|
|
331
|
-
return '';
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* @param {?} str
|
|
335
|
-
* @return {?}
|
|
336
|
-
*/
|
|
337
|
-
function genHeadingId(str) {
|
|
338
|
-
if (str) {
|
|
339
|
-
return removeLeadingHash(str
|
|
340
|
-
.replace(/(_|-|\s)+/g, '')
|
|
341
|
-
// Remove certain special chars to create heading ids similar to those in github
|
|
342
|
-
// borrowed from showdown
|
|
343
|
-
// https://github.com/showdownjs/showdown/blob/develop/src/subParsers/makehtml/headers.js#L94
|
|
344
|
-
.replace(/[&+$,\/:;=?@"#{}|^¨~\[\]`\\*)(%.!'<>]/g, '')).toLowerCase();
|
|
345
|
-
}
|
|
346
|
-
return '';
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* @param {?} scope
|
|
350
|
-
* @param {?} anchor
|
|
351
|
-
* @param {?} tryParent
|
|
352
|
-
* @return {?}
|
|
353
|
-
*/
|
|
354
|
-
function scrollToAnchor(scope, anchor, tryParent) {
|
|
355
|
-
if (scope && anchor) {
|
|
356
|
-
/** @type {?} */
|
|
357
|
-
var normalizedAnchor = genHeadingId(anchor);
|
|
358
|
-
/** @type {?} */
|
|
359
|
-
var headingToJumpTo = void 0;
|
|
360
|
-
/** @type {?} */
|
|
361
|
-
var headingWithinComponent = scope.querySelector("[id=\"" + normalizedAnchor + "\"]");
|
|
362
|
-
if (headingWithinComponent) {
|
|
363
|
-
headingToJumpTo = headingWithinComponent;
|
|
364
|
-
}
|
|
365
|
-
else if (tryParent) {
|
|
366
|
-
/** @type {?} */
|
|
367
|
-
var parent = scope.parentElement;
|
|
368
|
-
if (parent) {
|
|
369
|
-
headingToJumpTo = parent.querySelector("[id=\"" + normalizedAnchor + "\"]");
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
if (headingToJumpTo) {
|
|
373
|
-
headingToJumpTo.scrollIntoView({ behavior: 'auto' });
|
|
374
|
-
return true;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
return false;
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* @param {?} anchor
|
|
381
|
-
* @return {?}
|
|
382
|
-
*/
|
|
383
|
-
function isAnchorLink(anchor) {
|
|
384
|
-
if (anchor) {
|
|
385
|
-
/** @type {?} */
|
|
386
|
-
var href = anchor.getAttribute('href');
|
|
387
|
-
if (href) {
|
|
388
|
-
return href.startsWith('#');
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
return false;
|
|
392
|
-
}
|
|
393
|
-
/** @type {?} */
|
|
394
|
-
var RAW_GITHUB_HOSTNAME = 'raw.githubusercontent.com';
|
|
395
|
-
/**
|
|
396
|
-
* @param {?} githubHref
|
|
397
|
-
* @return {?}
|
|
398
|
-
*/
|
|
399
|
-
function rawGithubHref(githubHref) {
|
|
400
|
-
if (githubHref) {
|
|
401
|
-
try {
|
|
402
|
-
/** @type {?} */
|
|
403
|
-
var url = new URL(githubHref);
|
|
404
|
-
if (url.hostname === RAW_GITHUB_HOSTNAME) {
|
|
405
|
-
return url.href;
|
|
406
|
-
}
|
|
407
|
-
else if (isGithubHref(githubHref)) {
|
|
408
|
-
url.hostname = RAW_GITHUB_HOSTNAME;
|
|
409
|
-
url.pathname = url.pathname.split('/blob', 2).join('');
|
|
410
|
-
return url.href;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
catch (_a) {
|
|
414
|
-
return '';
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
return '';
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
* @param {?} href
|
|
421
|
-
* @return {?}
|
|
422
|
-
*/
|
|
423
|
-
function isGithubHref(href) {
|
|
424
|
-
try {
|
|
425
|
-
/** @type {?} */
|
|
426
|
-
var temp = new URL(href);
|
|
427
|
-
return temp.hostname === 'github.com';
|
|
428
|
-
}
|
|
429
|
-
catch (_a) {
|
|
430
|
-
return false;
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* @param {?} href
|
|
435
|
-
* @return {?}
|
|
436
|
-
*/
|
|
437
|
-
function isRawGithubHref(href) {
|
|
438
|
-
try {
|
|
439
|
-
/** @type {?} */
|
|
440
|
-
var temp = new URL(href);
|
|
441
|
-
return temp.hostname === RAW_GITHUB_HOSTNAME;
|
|
442
|
-
}
|
|
443
|
-
catch (_a) {
|
|
444
|
-
return false;
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* @param {?} html
|
|
449
|
-
* @return {?}
|
|
450
|
-
*/
|
|
451
|
-
function renderVideoElements(html) {
|
|
452
|
-
/** @type {?} */
|
|
453
|
-
var ytLongEmbed = /!\[(?:(?:https?:)?(?:\/\/)?)(?:(?:www)?.)?youtube.(?:.+?)\/(?:(?:embed\/)([\w-]{11})(\?[\w%;-]+(?:=[\w%;-]+)?(?:&[\w%;-]+(?:=[\w%;-]+)?)*)?)]/gi;
|
|
454
|
-
/** @type {?} */
|
|
455
|
-
var ytLongWatch = /!\[(?:(?:https?:)?(?:\/\/)?)(?:(?:www)?.)?youtube.(?:.+?)\/(?:(?:watch\?v=)([\w-]{11})(&[\w%;-]+(?:=[\w%;-]+)?)*)]/gi;
|
|
456
|
-
/** @type {?} */
|
|
457
|
-
var ytShort = /!\[(?:(?:https?:)?(?:\/\/)?)?youtu.be\/([\w-]{11})\??([\w%;-]+(?:=[\w%;-]+)?(?:&[\w%;-]+(?:=[\w%;-]+)?)*)?]/gi;
|
|
458
|
-
/** @type {?} */
|
|
459
|
-
var ytPlaylist = /!\[(?:(?:https?:)?(?:\/\/)?)(?:(?:www)?.)?youtube.(?:.+?)\/(?:(?:playlist\?list=)([\w-]{34})(&[\w%;-]+(?:=[\w%;-]+)?)*)]/gi;
|
|
460
|
-
/**
|
|
461
|
-
* @param {?} match
|
|
462
|
-
* @param {?} id
|
|
463
|
-
* @param {?} flags
|
|
464
|
-
* @return {?}
|
|
465
|
-
*/
|
|
466
|
-
function convert(match, id, flags) {
|
|
467
|
-
if (flags) {
|
|
468
|
-
id += '?' + flags.replace(/&/gi, '&');
|
|
469
|
-
}
|
|
470
|
-
return "<iframe allow=\"fullscreen\" frameborder=\"0\" src=\"https://www.youtube.com/embed/" + id + "\"></iframe>";
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* @param {?} match
|
|
474
|
-
* @param {?} id
|
|
475
|
-
* @param {?} flags
|
|
476
|
-
* @return {?}
|
|
477
|
-
*/
|
|
478
|
-
function convertPL(match, id, flags) {
|
|
479
|
-
if (flags) {
|
|
480
|
-
id += flags.replace(/&/gi, '&');
|
|
481
|
-
}
|
|
482
|
-
return "<iframe allow=\"fullscreen\" frameborder=\"0\" src=\"https://www.youtube.com/embed/videoseries?list=" + id + "\"></iframe>";
|
|
483
|
-
}
|
|
484
|
-
return html
|
|
485
|
-
.replace(ytLongWatch, convert)
|
|
486
|
-
.replace(ytLongEmbed, convert)
|
|
487
|
-
.replace(ytShort, convert)
|
|
488
|
-
.replace(ytPlaylist, convertPL);
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
/* tslint:disable-next-line */
|
|
492
|
-
/** @type {?} */
|
|
493
|
-
var showdown = require('showdown/dist/showdown.js');
|
|
494
|
-
// TODO: assumes it is a github url
|
|
495
|
-
// allow override somehow
|
|
496
|
-
/**
|
|
497
|
-
* @param {?} currentHref
|
|
498
|
-
* @param {?} relativeHref
|
|
499
|
-
* @return {?}
|
|
500
|
-
*/
|
|
501
|
-
function generateAbsoluteHref(currentHref, relativeHref) {
|
|
502
|
-
if (currentHref && relativeHref) {
|
|
503
|
-
/** @type {?} */
|
|
504
|
-
var currentUrl = new URL(currentHref);
|
|
505
|
-
/** @type {?} */
|
|
506
|
-
var path = currentUrl.pathname.split('/').slice(1, -1).join('/');
|
|
507
|
-
/** @type {?} */
|
|
508
|
-
var correctUrl = new URL(currentHref);
|
|
509
|
-
if (relativeHref.startsWith('/')) {
|
|
510
|
-
// url is relative to top level
|
|
511
|
-
/** @type {?} */
|
|
512
|
-
var orgAndRepo = path.split('/').slice(0, 3).join('/');
|
|
513
|
-
correctUrl.pathname = "" + orgAndRepo + relativeHref;
|
|
514
|
-
}
|
|
515
|
-
else {
|
|
516
|
-
correctUrl.pathname = path + "/" + relativeHref;
|
|
517
|
-
}
|
|
518
|
-
return correctUrl.href;
|
|
519
|
-
}
|
|
520
|
-
return undefined;
|
|
521
|
-
}
|
|
522
|
-
/**
|
|
523
|
-
* @param {?} html
|
|
524
|
-
* @param {?} currentHref
|
|
525
|
-
* @return {?}
|
|
526
|
-
*/
|
|
527
|
-
function normalizeHtmlHrefs(html, currentHref) {
|
|
528
|
-
if (currentHref) {
|
|
529
|
-
/** @type {?} */
|
|
530
|
-
var document = new DOMParser().parseFromString(html, 'text/html');
|
|
531
|
-
document.querySelectorAll('a[href]').forEach(( /**
|
|
532
|
-
* @param {?} link
|
|
533
|
-
* @return {?}
|
|
534
|
-
*/function (link) {
|
|
535
|
-
/** @type {?} */
|
|
536
|
-
var url = new URL(link.href);
|
|
537
|
-
/** @type {?} */
|
|
538
|
-
var originalHash = url.hash;
|
|
539
|
-
if (isAnchorLink(link)) {
|
|
540
|
-
if (originalHash) {
|
|
541
|
-
url.hash = genHeadingId(originalHash);
|
|
542
|
-
link.href = url.hash;
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
else if (url.host === window.location.host) {
|
|
546
|
-
// hosts match, meaning URL MIGHT have been malformed by showdown
|
|
547
|
-
// url is a relative url or just a link to a part of the application
|
|
548
|
-
if (url.pathname.endsWith('.md')) {
|
|
549
|
-
// only check .md urls
|
|
550
|
-
/** @type {?} */
|
|
551
|
-
var hrefWithoutHash = removeTrailingHash(link.getAttribute('href'));
|
|
552
|
-
url.href = generateAbsoluteHref(currentHref, hrefWithoutHash);
|
|
553
|
-
if (originalHash) {
|
|
554
|
-
url.hash = genHeadingId(originalHash);
|
|
555
|
-
}
|
|
556
|
-
link.href = url.href;
|
|
557
|
-
}
|
|
558
|
-
link.target = '_blank';
|
|
559
|
-
}
|
|
560
|
-
else {
|
|
561
|
-
// url is absolute
|
|
562
|
-
if (url.pathname.endsWith('.md')) {
|
|
563
|
-
if (originalHash) {
|
|
564
|
-
url.hash = genHeadingId(originalHash);
|
|
565
|
-
}
|
|
566
|
-
link.href = url.href;
|
|
567
|
-
}
|
|
568
|
-
link.target = '_blank';
|
|
569
|
-
}
|
|
570
|
-
}));
|
|
571
|
-
return new XMLSerializer().serializeToString(document);
|
|
572
|
-
}
|
|
573
|
-
return html;
|
|
574
|
-
}
|
|
575
|
-
/**
|
|
576
|
-
* @param {?} html
|
|
577
|
-
* @param {?} currentHref
|
|
578
|
-
* @return {?}
|
|
579
|
-
*/
|
|
580
|
-
function normalizeImageSrcs(html, currentHref) {
|
|
581
|
-
if (currentHref) {
|
|
582
|
-
/** @type {?} */
|
|
583
|
-
var document = new DOMParser().parseFromString(html, 'text/html');
|
|
584
|
-
document.querySelectorAll('img[src]').forEach(( /**
|
|
585
|
-
* @param {?} image
|
|
586
|
-
* @return {?}
|
|
587
|
-
*/function (image) {
|
|
588
|
-
/** @type {?} */
|
|
589
|
-
var src = image.getAttribute('src');
|
|
590
|
-
try {
|
|
591
|
-
/* tslint:disable-next-line:no-unused-expression */
|
|
592
|
-
new URL(src);
|
|
593
|
-
if (isGithubHref(src)) {
|
|
594
|
-
image.src = rawGithubHref(src);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
catch (_a) {
|
|
598
|
-
image.src = generateAbsoluteHref(isGithubHref(currentHref) ? rawGithubHref(currentHref) : currentHref, src);
|
|
599
|
-
}
|
|
600
|
-
// gh svgs need to have ?sanitize=true
|
|
601
|
-
if (isRawGithubHref(image.src)) {
|
|
602
|
-
/** @type {?} */
|
|
603
|
-
var url = new URL(image.src);
|
|
604
|
-
if (url.pathname.endsWith('.svg')) {
|
|
605
|
-
url.searchParams.set('sanitize', 'true');
|
|
606
|
-
image.src = url.href;
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
}));
|
|
610
|
-
return new XMLSerializer().serializeToString(document);
|
|
611
|
-
}
|
|
612
|
-
return html;
|
|
613
|
-
}
|
|
614
|
-
/**
|
|
615
|
-
* @param {?} html
|
|
616
|
-
* @return {?}
|
|
617
|
-
*/
|
|
618
|
-
function addIdsToHeadings(html) {
|
|
619
|
-
if (html) {
|
|
620
|
-
/** @type {?} */
|
|
621
|
-
var document = new DOMParser().parseFromString(html, 'text/html');
|
|
622
|
-
document.querySelectorAll('h1, h2, h3, h4, h5, h6').forEach(( /**
|
|
623
|
-
* @param {?} heading
|
|
624
|
-
* @return {?}
|
|
625
|
-
*/function (heading) {
|
|
626
|
-
/** @type {?} */
|
|
627
|
-
var id = genHeadingId(heading.innerHTML);
|
|
628
|
-
heading.setAttribute('id', id);
|
|
629
|
-
}));
|
|
630
|
-
return new XMLSerializer().serializeToString(document);
|
|
631
|
-
}
|
|
632
|
-
return html;
|
|
633
|
-
}
|
|
634
|
-
var TdMarkdownComponent = /** @class */ (function () {
|
|
635
|
-
/**
|
|
636
|
-
* @param {?} _renderer
|
|
637
|
-
* @param {?} _elementRef
|
|
638
|
-
* @param {?} _domSanitizer
|
|
639
|
-
*/
|
|
640
|
-
function TdMarkdownComponent(_renderer, _elementRef, _domSanitizer) {
|
|
641
|
-
this._renderer = _renderer;
|
|
642
|
-
this._elementRef = _elementRef;
|
|
643
|
-
this._domSanitizer = _domSanitizer;
|
|
644
|
-
this._simpleLineBreaks = false;
|
|
645
|
-
this._viewInit = false;
|
|
646
|
-
/**
|
|
647
|
-
* .td-markdown class added to host so ::ng-deep gets scoped.
|
|
648
|
-
*/
|
|
649
|
-
this.class = 'td-markdown';
|
|
650
|
-
/**
|
|
651
|
-
* contentReady?: function
|
|
652
|
-
* Event emitted after the markdown content rendering is finished.
|
|
653
|
-
*/
|
|
654
|
-
this.contentReady = new core.EventEmitter();
|
|
655
|
-
}
|
|
656
|
-
Object.defineProperty(TdMarkdownComponent.prototype, "content", {
|
|
657
|
-
/**
|
|
658
|
-
* content?: string
|
|
659
|
-
*
|
|
660
|
-
* Markdown format content to be parsed as html markup.
|
|
661
|
-
*
|
|
662
|
-
* e.g. README.md content.
|
|
663
|
-
* @param {?} content
|
|
664
|
-
* @return {?}
|
|
665
|
-
*/
|
|
666
|
-
set: function (content) {
|
|
667
|
-
this._content = content;
|
|
668
|
-
},
|
|
669
|
-
enumerable: false,
|
|
670
|
-
configurable: true
|
|
671
|
-
});
|
|
672
|
-
Object.defineProperty(TdMarkdownComponent.prototype, "simpleLineBreaks", {
|
|
673
|
-
/**
|
|
674
|
-
* simpleLineBreaks?: string
|
|
675
|
-
*
|
|
676
|
-
* Sets whether newline characters inside paragraphs and spans are parsed as <br/>.
|
|
677
|
-
* Defaults to false.
|
|
678
|
-
* @param {?} simpleLineBreaks
|
|
679
|
-
* @return {?}
|
|
680
|
-
*/
|
|
681
|
-
set: function (simpleLineBreaks) {
|
|
682
|
-
this._simpleLineBreaks = simpleLineBreaks;
|
|
683
|
-
},
|
|
684
|
-
enumerable: false,
|
|
685
|
-
configurable: true
|
|
686
|
-
});
|
|
687
|
-
Object.defineProperty(TdMarkdownComponent.prototype, "hostedUrl", {
|
|
688
|
-
/**
|
|
689
|
-
* hostedUrl?: string
|
|
690
|
-
*
|
|
691
|
-
* If markdown contains relative paths, this is required to generate correct urls.
|
|
692
|
-
*
|
|
693
|
-
* @param {?} hostedUrl
|
|
694
|
-
* @return {?}
|
|
695
|
-
*/
|
|
696
|
-
set: function (hostedUrl) {
|
|
697
|
-
this._hostedUrl = hostedUrl;
|
|
698
|
-
},
|
|
699
|
-
enumerable: false,
|
|
700
|
-
configurable: true
|
|
701
|
-
});
|
|
702
|
-
Object.defineProperty(TdMarkdownComponent.prototype, "anchor", {
|
|
703
|
-
/**
|
|
704
|
-
* anchor?: string
|
|
705
|
-
*
|
|
706
|
-
* Anchor to jump to.
|
|
707
|
-
*
|
|
708
|
-
* @param {?} anchor
|
|
709
|
-
* @return {?}
|
|
710
|
-
*/
|
|
711
|
-
set: function (anchor) {
|
|
712
|
-
this._anchor = anchor;
|
|
713
|
-
},
|
|
714
|
-
enumerable: false,
|
|
715
|
-
configurable: true
|
|
716
|
-
});
|
|
717
|
-
/**
|
|
718
|
-
* @param {?} event
|
|
719
|
-
* @return {?}
|
|
720
|
-
*/
|
|
721
|
-
TdMarkdownComponent.prototype.clickListener = function (event) {
|
|
722
|
-
/** @type {?} */
|
|
723
|
-
var element = ( /** @type {?} */(event.srcElement));
|
|
724
|
-
if (element.matches('a[href]') && isAnchorLink(( /** @type {?} */(element)))) {
|
|
725
|
-
this.handleAnchorClicks(event);
|
|
726
|
-
}
|
|
727
|
-
};
|
|
728
|
-
/**
|
|
729
|
-
* @param {?} changes
|
|
730
|
-
* @return {?}
|
|
731
|
-
*/
|
|
732
|
-
TdMarkdownComponent.prototype.ngOnChanges = function (changes) {
|
|
733
|
-
// only anchor changed
|
|
734
|
-
if (changes.anchor && !changes.content && !changes.simpleLineBreaks && !changes.hostedUrl) {
|
|
735
|
-
scrollToAnchor(this._elementRef.nativeElement, this._anchor, true);
|
|
736
|
-
}
|
|
737
|
-
else {
|
|
738
|
-
this.refresh();
|
|
739
|
-
}
|
|
740
|
-
};
|
|
741
|
-
/**
|
|
742
|
-
* @return {?}
|
|
743
|
-
*/
|
|
744
|
-
TdMarkdownComponent.prototype.ngAfterViewInit = function () {
|
|
745
|
-
if (!this._content) {
|
|
746
|
-
this._loadContent((( /** @type {?} */(this._elementRef.nativeElement))).textContent);
|
|
747
|
-
}
|
|
748
|
-
this._viewInit = true;
|
|
749
|
-
};
|
|
750
|
-
/**
|
|
751
|
-
* @return {?}
|
|
752
|
-
*/
|
|
753
|
-
TdMarkdownComponent.prototype.refresh = function () {
|
|
754
|
-
if (this._content) {
|
|
755
|
-
this._loadContent(this._content);
|
|
756
|
-
}
|
|
757
|
-
else if (this._viewInit) {
|
|
758
|
-
this._loadContent((( /** @type {?} */(this._elementRef.nativeElement))).textContent);
|
|
759
|
-
}
|
|
760
|
-
};
|
|
761
|
-
/**
|
|
762
|
-
* General method to parse a string markdown into HTML Elements and load them into the container
|
|
763
|
-
* @private
|
|
764
|
-
* @param {?} markdown
|
|
765
|
-
* @return {?}
|
|
766
|
-
*/
|
|
767
|
-
TdMarkdownComponent.prototype._loadContent = function (markdown) {
|
|
768
|
-
var _this = this;
|
|
769
|
-
if (markdown && markdown.trim().length > 0) {
|
|
770
|
-
// Clean container
|
|
771
|
-
this._renderer.setProperty(this._elementRef.nativeElement, 'innerHTML', '');
|
|
772
|
-
// Parse html string into actual HTML elements.
|
|
773
|
-
this._elementFromString(this._render(markdown));
|
|
774
|
-
}
|
|
775
|
-
// TODO: timeout required since resizing of html elements occurs which causes a change in the scroll position
|
|
776
|
-
setTimeout(( /**
|
|
777
|
-
* @return {?}
|
|
778
|
-
*/function () { return scrollToAnchor(_this._elementRef.nativeElement, _this._anchor, true); }), 250);
|
|
779
|
-
this.contentReady.emit();
|
|
780
|
-
};
|
|
781
|
-
/**
|
|
782
|
-
* @private
|
|
783
|
-
* @param {?} event
|
|
784
|
-
* @return {?}
|
|
785
|
-
*/
|
|
786
|
-
TdMarkdownComponent.prototype.handleAnchorClicks = function (event) {
|
|
787
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
788
|
-
var url, hash;
|
|
789
|
-
return __generator(this, function (_b) {
|
|
790
|
-
event.preventDefault();
|
|
791
|
-
url = new URL((( /** @type {?} */(event.target))).href);
|
|
792
|
-
hash = decodeURI(url.hash);
|
|
793
|
-
scrollToAnchor(this._elementRef.nativeElement, hash, true);
|
|
794
|
-
return [2 /*return*/];
|
|
795
|
-
});
|
|
796
|
-
});
|
|
797
|
-
};
|
|
798
|
-
/**
|
|
799
|
-
* @private
|
|
800
|
-
* @param {?} markupStr
|
|
801
|
-
* @return {?}
|
|
802
|
-
*/
|
|
803
|
-
TdMarkdownComponent.prototype._elementFromString = function (markupStr) {
|
|
804
|
-
// Renderer2 doesnt have a parsing method, so we have to sanitize and use [innerHTML]
|
|
805
|
-
// to parse the string into DOM element for now.
|
|
806
|
-
/** @type {?} */
|
|
807
|
-
var div = this._renderer.createElement('div');
|
|
808
|
-
this._renderer.appendChild(this._elementRef.nativeElement, div);
|
|
809
|
-
/** @type {?} */
|
|
810
|
-
var html = this._domSanitizer.sanitize(core.SecurityContext.HTML, markupStr);
|
|
811
|
-
/** @type {?} */
|
|
812
|
-
var htmlWithAbsoluteHrefs = normalizeHtmlHrefs(html, this._hostedUrl);
|
|
813
|
-
/** @type {?} */
|
|
814
|
-
var htmlWithAbsoluteImgSrcs = normalizeImageSrcs(htmlWithAbsoluteHrefs, this._hostedUrl);
|
|
815
|
-
/** @type {?} */
|
|
816
|
-
var htmlWithHeadingIds = addIdsToHeadings(htmlWithAbsoluteImgSrcs);
|
|
817
|
-
/** @type {?} */
|
|
818
|
-
var htmlWithVideos = renderVideoElements(htmlWithHeadingIds);
|
|
819
|
-
this._renderer.setProperty(div, 'innerHTML', htmlWithVideos);
|
|
820
|
-
return div;
|
|
821
|
-
};
|
|
822
|
-
/**
|
|
823
|
-
* @private
|
|
824
|
-
* @param {?} markdown
|
|
825
|
-
* @return {?}
|
|
826
|
-
*/
|
|
827
|
-
TdMarkdownComponent.prototype._render = function (markdown) {
|
|
828
|
-
// Trim leading and trailing newlines
|
|
829
|
-
markdown = markdown.replace(/^(\s|\t)*\n+/g, '').replace(/(\s|\t)*\n+(\s|\t)*$/g, '');
|
|
830
|
-
// Split markdown by line characters
|
|
831
|
-
/** @type {?} */
|
|
832
|
-
var lines = markdown.split('\n');
|
|
833
|
-
// check how much indentation is used by the first actual markdown line
|
|
834
|
-
/** @type {?} */
|
|
835
|
-
var firstLineWhitespace = lines[0].match(/^(\s|\t)*/)[0];
|
|
836
|
-
// Remove all indentation spaces so markdown can be parsed correctly
|
|
837
|
-
/** @type {?} */
|
|
838
|
-
var startingWhitespaceRegex = new RegExp('^' + firstLineWhitespace);
|
|
839
|
-
lines = lines.map(( /**
|
|
840
|
-
* @param {?} line
|
|
841
|
-
* @return {?}
|
|
842
|
-
*/function (line) {
|
|
843
|
-
return line.replace(startingWhitespaceRegex, '');
|
|
844
|
-
}));
|
|
845
|
-
// Join lines again with line characters
|
|
846
|
-
/** @type {?} */
|
|
847
|
-
var markdownToParse = lines.join('\n');
|
|
848
|
-
// Convert markdown into html
|
|
849
|
-
/** @type {?} */
|
|
850
|
-
var converter = new showdown.Converter();
|
|
851
|
-
converter.setOption('ghCodeBlocks', true);
|
|
852
|
-
converter.setOption('tasklists', true);
|
|
853
|
-
converter.setOption('tables', true);
|
|
854
|
-
converter.setOption('literalMidWordUnderscores', true);
|
|
855
|
-
converter.setOption('simpleLineBreaks', this._simpleLineBreaks);
|
|
856
|
-
return converter.makeHtml(markdownToParse);
|
|
857
|
-
};
|
|
858
|
-
return TdMarkdownComponent;
|
|
859
|
-
}());
|
|
860
|
-
TdMarkdownComponent.decorators = [
|
|
861
|
-
{ type: core.Component, args: [{
|
|
862
|
-
selector: 'td-markdown',
|
|
863
|
-
template: "<ng-content></ng-content>\n",
|
|
864
|
-
styles: ["@font-face{:host.td-markdown::ng-deep{font-family:octicons-link;src:url(\"data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAZwABAAAAAACFQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEU0lHAAAGaAAAAAgAAAAIAAAAAUdTVUIAAAZcAAAACgAAAAoAAQAAT1MvMgAAAyQAAABJAAAAYFYEU3RjbWFwAAADcAAAAEUAAACAAJThvmN2dCAAAATkAAAABAAAAAQAAAAAZnBnbQAAA7gAAACyAAABCUM+8IhnYXNwAAAGTAAAABAAAAAQABoAI2dseWYAAAFsAAABPAAAAZwcEq9taGVhZAAAAsgAAAA0AAAANgh4a91oaGVhAAADCAAAABoAAAAkCA8DRGhtdHgAAAL8AAAADAAAAAwGAACfbG9jYQAAAsAAAAAIAAAACABiATBtYXhwAAACqAAAABgAAAAgAA8ASm5hbWUAAAToAAABQgAAAlXu73sOcG9zdAAABiwAAAAeAAAAME3QpOBwcmVwAAAEbAAAAHYAAAB/aFGpk3jaTY6xa8JAGMW/O62BDi0tJLYQincXEypYIiGJjSgHniQ6umTsUEyLm5BV6NDBP8Tpts6F0v+k/0an2i+itHDw3v2+9+DBKTzsJNnWJNTgHEy4BgG3EMI9DCEDOGEXzDADU5hBKMIgNPZqoD3SilVaXZCER3/I7AtxEJLtzzuZfI+VVkprxTlXShWKb3TBecG11rwoNlmmn1P2WYcJczl32etSpKnziC7lQyWe1smVPy/Lt7Kc+0vWY/gAgIIEqAN9we0pwKXreiMasxvabDQMM4riO+qxM2ogwDGOZTXxwxDiycQIcoYFBLj5K3EIaSctAq2kTYiw+ymhce7vwM9jSqO8JyVd5RH9gyTt2+J/yUmYlIR0s04n6+7Vm1ozezUeLEaUjhaDSuXHwVRgvLJn1tQ7xiuVv/ocTRF42mNgZGBgYGbwZOBiAAFGJBIMAAizAFoAAABiAGIAznjaY2BkYGAA4in8zwXi+W2+MjCzMIDApSwvXzC97Z4Ig8N/BxYGZgcgl52BCSQKAA3jCV8CAABfAAAAAAQAAEB42mNgZGBg4f3vACQZQABIMjKgAmYAKEgBXgAAeNpjYGY6wTiBgZWBg2kmUxoDA4MPhGZMYzBi1AHygVLYQUCaawqDA4PChxhmh/8ODDEsvAwHgMKMIDnGL0x7gJQCAwMAJd4MFwAAAHjaY2BgYGaA4DAGRgYQkAHyGMF8NgYrIM3JIAGVYYDT+AEjAwuDFpBmA9KMDEwMCh9i/v8H8sH0/4dQc1iAmAkALaUKLgAAAHjaTY9LDsIgEIbtgqHUPpDi3gPoBVyRTmTddOmqTXThEXqrob2gQ1FjwpDvfwCBdmdXC5AVKFu3e5MfNFJ29KTQT48Ob9/lqYwOGZxeUelN2U2R6+cArgtCJpauW7UQBqnFkUsjAY/kOU1cP+DAgvxwn1chZDwUbd6CFimGXwzwF6tPbFIcjEl+vvmM/byA48e6tWrKArm4ZJlCbdsrxksL1AwWn/yBSJKpYbq8AXaaTb8AAHja28jAwOC00ZrBeQNDQOWO//sdBBgYGRiYWYAEELEwMTE4uzo5Zzo5b2BxdnFOcALxNjA6b2ByTswC8jYwg0VlNuoCTWAMqNzMzsoK1rEhNqByEyerg5PMJlYuVueETKcd/89uBpnpvIEVomeHLoMsAAe1Id4AAAAAAAB42oWQT07CQBTGv0JBhagk7HQzKxca2sJCE1hDt4QF+9JOS0nbaaYDCQfwCJ7Au3AHj+LO13FMmm6cl7785vven0kBjHCBhfpYuNa5Ph1c0e2Xu3jEvWG7UdPDLZ4N92nOm+EBXuAbHmIMSRMs+4aUEd4Nd3CHD8NdvOLTsA2GL8M9PODbcL+hD7C1xoaHeLJSEao0FEW14ckxC+TU8TxvsY6X0eLPmRhry2WVioLpkrbp84LLQPGI7c6sOiUzpWIWS5GzlSgUzzLBSikOPFTOXqly7rqx0Z1Q5BAIoZBSFihQYQOOBEdkCOgXTOHA07HAGjGWiIjaPZNW13/+lm6S9FT7rLHFJ6fQbkATOG1j2OFMucKJJsxIVfQORl+9Jyda6Sl1dUYhSCm1dyClfoeDve4qMYdLEbfqHf3O/AdDumsjAAB42mNgYoAAZQYjBmyAGYQZmdhL8zLdDEydARfoAqIAAAABAAMABwAKABMAB///AA8AAQAAAAAAAAAAAAAAAAABAAAAAA==\") 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}"]
|
|
865
|
-
}] }
|
|
866
|
-
];
|
|
867
|
-
/** @nocollapse */
|
|
868
|
-
TdMarkdownComponent.ctorParameters = function () { return [
|
|
869
|
-
{ type: core.Renderer2 },
|
|
870
|
-
{ type: core.ElementRef },
|
|
871
|
-
{ type: platformBrowser.DomSanitizer }
|
|
872
|
-
]; };
|
|
873
|
-
TdMarkdownComponent.propDecorators = {
|
|
874
|
-
class: [{ type: core.HostBinding, args: ['class',] }],
|
|
875
|
-
content: [{ type: core.Input, args: ['content',] }],
|
|
876
|
-
simpleLineBreaks: [{ type: core.Input, args: ['simpleLineBreaks',] }],
|
|
877
|
-
hostedUrl: [{ type: core.Input, args: ['hostedUrl',] }],
|
|
878
|
-
anchor: [{ type: core.Input, args: ['anchor',] }],
|
|
879
|
-
contentReady: [{ type: core.Output }],
|
|
880
|
-
clickListener: [{ type: core.HostListener, args: ['click', ['$event'],] }]
|
|
881
|
-
};
|
|
882
|
-
if (false) {
|
|
883
|
-
/**
|
|
884
|
-
* @type {?}
|
|
885
|
-
* @private
|
|
886
|
-
*/
|
|
887
|
-
TdMarkdownComponent.prototype._content;
|
|
888
|
-
/**
|
|
889
|
-
* @type {?}
|
|
890
|
-
* @private
|
|
891
|
-
*/
|
|
892
|
-
TdMarkdownComponent.prototype._simpleLineBreaks;
|
|
893
|
-
/**
|
|
894
|
-
* @type {?}
|
|
895
|
-
* @private
|
|
896
|
-
*/
|
|
897
|
-
TdMarkdownComponent.prototype._hostedUrl;
|
|
898
|
-
/**
|
|
899
|
-
* @type {?}
|
|
900
|
-
* @private
|
|
901
|
-
*/
|
|
902
|
-
TdMarkdownComponent.prototype._anchor;
|
|
903
|
-
/**
|
|
904
|
-
* @type {?}
|
|
905
|
-
* @private
|
|
906
|
-
*/
|
|
907
|
-
TdMarkdownComponent.prototype._viewInit;
|
|
908
|
-
/**
|
|
909
|
-
* .td-markdown class added to host so ::ng-deep gets scoped.
|
|
910
|
-
* @type {?}
|
|
911
|
-
*/
|
|
912
|
-
TdMarkdownComponent.prototype.class;
|
|
913
|
-
/**
|
|
914
|
-
* contentReady?: function
|
|
915
|
-
* Event emitted after the markdown content rendering is finished.
|
|
916
|
-
* @type {?}
|
|
917
|
-
*/
|
|
918
|
-
TdMarkdownComponent.prototype.contentReady;
|
|
919
|
-
/**
|
|
920
|
-
* @type {?}
|
|
921
|
-
* @private
|
|
922
|
-
*/
|
|
923
|
-
TdMarkdownComponent.prototype._renderer;
|
|
924
|
-
/**
|
|
925
|
-
* @type {?}
|
|
926
|
-
* @private
|
|
927
|
-
*/
|
|
928
|
-
TdMarkdownComponent.prototype._elementRef;
|
|
929
|
-
/**
|
|
930
|
-
* @type {?}
|
|
931
|
-
* @private
|
|
932
|
-
*/
|
|
933
|
-
TdMarkdownComponent.prototype._domSanitizer;
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
var TdMarkdownLoaderService = /** @class */ (function () {
|
|
937
|
-
/**
|
|
938
|
-
* @param {?} _http
|
|
939
|
-
* @param {?} _sanitizer
|
|
940
|
-
*/
|
|
941
|
-
function TdMarkdownLoaderService(_http, _sanitizer) {
|
|
942
|
-
this._http = _http;
|
|
943
|
-
this._sanitizer = _sanitizer;
|
|
944
|
-
}
|
|
945
|
-
/**
|
|
946
|
-
* @param {?} url
|
|
947
|
-
* @param {?=} httpOptions
|
|
948
|
-
* @return {?}
|
|
949
|
-
*/
|
|
950
|
-
TdMarkdownLoaderService.prototype.load = function (url, httpOptions) {
|
|
951
|
-
if (httpOptions === void 0) { httpOptions = {}; }
|
|
952
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
953
|
-
var sanitizedUrl, urlToGet, response, contentType;
|
|
954
|
-
return __generator(this, function (_a) {
|
|
955
|
-
switch (_a.label) {
|
|
956
|
-
case 0:
|
|
957
|
-
sanitizedUrl = this._sanitizer.sanitize(core.SecurityContext.URL, url);
|
|
958
|
-
urlToGet = sanitizedUrl;
|
|
959
|
-
if (isGithubHref(sanitizedUrl)) {
|
|
960
|
-
urlToGet = rawGithubHref(sanitizedUrl);
|
|
961
|
-
}
|
|
962
|
-
return [4 /*yield*/, this._http
|
|
963
|
-
.get(urlToGet, Object.assign(Object.assign({}, httpOptions), { responseType: 'text', observe: 'response' }))
|
|
964
|
-
.toPromise()];
|
|
965
|
-
case 1:
|
|
966
|
-
response = _a.sent();
|
|
967
|
-
contentType = response.headers.get('Content-Type');
|
|
968
|
-
if (contentType.includes('text/plain') || contentType.includes('text/markdown')) {
|
|
969
|
-
return [2 /*return*/, response.body];
|
|
970
|
-
}
|
|
971
|
-
else {
|
|
972
|
-
throw Error(contentType + " is not a handled content type");
|
|
973
|
-
}
|
|
974
|
-
return [2 /*return*/];
|
|
975
|
-
}
|
|
976
|
-
});
|
|
977
|
-
});
|
|
978
|
-
};
|
|
979
|
-
return TdMarkdownLoaderService;
|
|
980
|
-
}());
|
|
981
|
-
TdMarkdownLoaderService.decorators = [
|
|
982
|
-
{ type: core.Injectable }
|
|
983
|
-
];
|
|
984
|
-
/** @nocollapse */
|
|
985
|
-
TdMarkdownLoaderService.ctorParameters = function () { return [
|
|
986
|
-
{ type: http.HttpClient },
|
|
987
|
-
{ type: platformBrowser.DomSanitizer }
|
|
988
|
-
]; };
|
|
989
|
-
if (false) {
|
|
990
|
-
/**
|
|
991
|
-
* @type {?}
|
|
992
|
-
* @private
|
|
993
|
-
*/
|
|
994
|
-
TdMarkdownLoaderService.prototype._http;
|
|
995
|
-
/**
|
|
996
|
-
* @type {?}
|
|
997
|
-
* @private
|
|
998
|
-
*/
|
|
999
|
-
TdMarkdownLoaderService.prototype._sanitizer;
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
/**
|
|
1003
|
-
* @fileoverview added by tsickle
|
|
1004
|
-
* Generated from: markdown.module.ts
|
|
1005
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1006
|
-
*/
|
|
1007
|
-
var CovalentMarkdownModule = /** @class */ (function () {
|
|
1008
|
-
function CovalentMarkdownModule() {
|
|
1009
|
-
}
|
|
1010
|
-
return CovalentMarkdownModule;
|
|
1011
|
-
}());
|
|
1012
|
-
CovalentMarkdownModule.decorators = [
|
|
1013
|
-
{ type: core.NgModule, args: [{
|
|
1014
|
-
imports: [common.CommonModule, http.HttpClientModule],
|
|
1015
|
-
declarations: [TdMarkdownComponent],
|
|
1016
|
-
exports: [TdMarkdownComponent],
|
|
1017
|
-
providers: [TdMarkdownLoaderService],
|
|
1018
|
-
},] }
|
|
1019
|
-
];
|
|
1020
|
-
|
|
1021
|
-
/**
|
|
1022
|
-
* @fileoverview added by tsickle
|
|
1023
|
-
* Generated from: public_api.ts
|
|
1024
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1025
|
-
*/
|
|
1026
|
-
|
|
1027
|
-
/**
|
|
1028
|
-
* @fileoverview added by tsickle
|
|
1029
|
-
* Generated from: index.ts
|
|
1030
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1031
|
-
*/
|
|
1032
|
-
|
|
1033
|
-
/**
|
|
1034
|
-
* @fileoverview added by tsickle
|
|
1035
|
-
* Generated from: covalent-markdown.ts
|
|
1036
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1037
|
-
*/
|
|
1038
|
-
|
|
1039
|
-
exports.CovalentMarkdownModule = CovalentMarkdownModule;
|
|
1040
|
-
exports.TdMarkdownComponent = TdMarkdownComponent;
|
|
1041
|
-
exports.TdMarkdownLoaderService = TdMarkdownLoaderService;
|
|
1042
|
-
exports.genHeadingId = genHeadingId;
|
|
1043
|
-
exports.isAnchorLink = isAnchorLink;
|
|
1044
|
-
exports.isGithubHref = isGithubHref;
|
|
1045
|
-
exports.isRawGithubHref = isRawGithubHref;
|
|
1046
|
-
exports.rawGithubHref = rawGithubHref;
|
|
1047
|
-
exports.removeLeadingHash = removeLeadingHash;
|
|
1048
|
-
exports.removeTrailingHash = removeTrailingHash;
|
|
1049
|
-
exports.renderVideoElements = renderVideoElements;
|
|
1050
|
-
exports.scrollToAnchor = scrollToAnchor;
|
|
1051
|
-
|
|
1052
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1053
|
-
|
|
1054
|
-
})));
|
|
1055
|
-
//# sourceMappingURL=covalent-markdown.umd.js.map
|