1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | (function webpackUniversalModuleDefinition(root, factory) {
|
8 | if(typeof exports === 'object' && typeof module === 'object')
|
9 | module.exports = factory(require("babel-runtime/core-js/get-iterator"), require("babel-runtime/core-js/object/keys"), require("markdown-it"), require("markdown-it-emoji"), require("markdown-it-sub"), require("markdown-it-sup"), require("markdown-it-footnote"), require("markdown-it-deflist"), require("markdown-it-abbr"), require("markdown-it-ins"), require("markdown-it-mark"), require("markdown-it-toc-and-anchor"), require("markdown-it-katex"), require("markdown-it-task-lists"));
|
10 | else if(typeof define === 'function' && define.amd)
|
11 | define(["babel-runtime/core-js/get-iterator", "babel-runtime/core-js/object/keys", "markdown-it", "markdown-it-emoji", "markdown-it-sub", "markdown-it-sup", "markdown-it-footnote", "markdown-it-deflist", "markdown-it-abbr", "markdown-it-ins", "markdown-it-mark", "markdown-it-toc-and-anchor", "markdown-it-katex", "markdown-it-task-lists"], factory);
|
12 | else if(typeof exports === 'object')
|
13 | exports["VueMarkdown"] = factory(require("babel-runtime/core-js/get-iterator"), require("babel-runtime/core-js/object/keys"), require("markdown-it"), require("markdown-it-emoji"), require("markdown-it-sub"), require("markdown-it-sup"), require("markdown-it-footnote"), require("markdown-it-deflist"), require("markdown-it-abbr"), require("markdown-it-ins"), require("markdown-it-mark"), require("markdown-it-toc-and-anchor"), require("markdown-it-katex"), require("markdown-it-task-lists"));
|
14 | else
|
15 | root["VueMarkdown"] = factory(root["babel-runtime/core-js/get-iterator"], root["babel-runtime/core-js/object/keys"], root["markdown-it"], root["markdown-it-emoji"], root["markdown-it-sub"], root["markdown-it-sup"], root["markdown-it-footnote"], root["markdown-it-deflist"], root["markdown-it-abbr"], root["markdown-it-ins"], root["markdown-it-mark"], root["markdown-it-toc-and-anchor"], root["markdown-it-katex"], root["markdown-it-task-lists"]);
|
16 | })(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_3__, __WEBPACK_EXTERNAL_MODULE_4__, __WEBPACK_EXTERNAL_MODULE_5__, __WEBPACK_EXTERNAL_MODULE_6__, __WEBPACK_EXTERNAL_MODULE_7__, __WEBPACK_EXTERNAL_MODULE_8__, __WEBPACK_EXTERNAL_MODULE_9__, __WEBPACK_EXTERNAL_MODULE_10__, __WEBPACK_EXTERNAL_MODULE_11__, __WEBPACK_EXTERNAL_MODULE_12__, __WEBPACK_EXTERNAL_MODULE_13__, __WEBPACK_EXTERNAL_MODULE_14__) {
|
17 | return (function(modules) {
|
18 |
|
19 | var installedModules = {};
|
20 |
|
21 |
|
22 | function __webpack_require__(moduleId) {
|
23 |
|
24 |
|
25 | if(installedModules[moduleId])
|
26 | return installedModules[moduleId].exports;
|
27 |
|
28 |
|
29 | var module = installedModules[moduleId] = {
|
30 | exports: {},
|
31 | id: moduleId,
|
32 | loaded: false
|
33 | };
|
34 |
|
35 |
|
36 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
37 |
|
38 |
|
39 | module.loaded = true;
|
40 |
|
41 |
|
42 | return module.exports;
|
43 | }
|
44 |
|
45 |
|
46 |
|
47 | __webpack_require__.m = modules;
|
48 |
|
49 |
|
50 | __webpack_require__.c = installedModules;
|
51 |
|
52 |
|
53 | __webpack_require__.p = "";
|
54 |
|
55 |
|
56 | return __webpack_require__(0);
|
57 | })
|
58 |
|
59 | ([
|
60 |
|
61 | (function(module, exports, __webpack_require__) {
|
62 |
|
63 | 'use strict';
|
64 |
|
65 | Object.defineProperty(exports, "__esModule", {
|
66 | value: true
|
67 | });
|
68 |
|
69 | var _getIterator2 = __webpack_require__(1);
|
70 |
|
71 | var _getIterator3 = _interopRequireDefault(_getIterator2);
|
72 |
|
73 | var _keys = __webpack_require__(2);
|
74 |
|
75 | var _keys2 = _interopRequireDefault(_keys);
|
76 |
|
77 | var _markdownIt = __webpack_require__(3);
|
78 |
|
79 | var _markdownIt2 = _interopRequireDefault(_markdownIt);
|
80 |
|
81 | var _markdownItEmoji = __webpack_require__(4);
|
82 |
|
83 | var _markdownItEmoji2 = _interopRequireDefault(_markdownItEmoji);
|
84 |
|
85 | var _markdownItSub = __webpack_require__(5);
|
86 |
|
87 | var _markdownItSub2 = _interopRequireDefault(_markdownItSub);
|
88 |
|
89 | var _markdownItSup = __webpack_require__(6);
|
90 |
|
91 | var _markdownItSup2 = _interopRequireDefault(_markdownItSup);
|
92 |
|
93 | var _markdownItFootnote = __webpack_require__(7);
|
94 |
|
95 | var _markdownItFootnote2 = _interopRequireDefault(_markdownItFootnote);
|
96 |
|
97 | var _markdownItDeflist = __webpack_require__(8);
|
98 |
|
99 | var _markdownItDeflist2 = _interopRequireDefault(_markdownItDeflist);
|
100 |
|
101 | var _markdownItAbbr = __webpack_require__(9);
|
102 |
|
103 | var _markdownItAbbr2 = _interopRequireDefault(_markdownItAbbr);
|
104 |
|
105 | var _markdownItIns = __webpack_require__(10);
|
106 |
|
107 | var _markdownItIns2 = _interopRequireDefault(_markdownItIns);
|
108 |
|
109 | var _markdownItMark = __webpack_require__(11);
|
110 |
|
111 | var _markdownItMark2 = _interopRequireDefault(_markdownItMark);
|
112 |
|
113 | var _markdownItTocAndAnchor = __webpack_require__(12);
|
114 |
|
115 | var _markdownItTocAndAnchor2 = _interopRequireDefault(_markdownItTocAndAnchor);
|
116 |
|
117 | var _markdownItKatex = __webpack_require__(13);
|
118 |
|
119 | var _markdownItKatex2 = _interopRequireDefault(_markdownItKatex);
|
120 |
|
121 | var _markdownItTaskLists = __webpack_require__(14);
|
122 |
|
123 | var _markdownItTaskLists2 = _interopRequireDefault(_markdownItTaskLists);
|
124 |
|
125 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
126 |
|
127 | exports.default = {
|
128 | md: new _markdownIt2.default(),
|
129 |
|
130 | template: '<div><slot></slot></div>',
|
131 |
|
132 | data: function data() {
|
133 | return {
|
134 | sourceData: this.source
|
135 | };
|
136 | },
|
137 |
|
138 |
|
139 | props: {
|
140 | watches: {
|
141 | type: Array,
|
142 | default: function _default() {
|
143 | return ['source', 'show', 'toc'];
|
144 | }
|
145 | },
|
146 | source: {
|
147 | type: String,
|
148 | default: ''
|
149 | },
|
150 | show: {
|
151 | type: Boolean,
|
152 | default: true
|
153 | },
|
154 | highlight: {
|
155 | type: Boolean,
|
156 | default: true
|
157 | },
|
158 | html: {
|
159 | type: Boolean,
|
160 | default: true
|
161 | },
|
162 | xhtmlOut: {
|
163 | type: Boolean,
|
164 | default: true
|
165 | },
|
166 | breaks: {
|
167 | type: Boolean,
|
168 | default: true
|
169 | },
|
170 | linkify: {
|
171 | type: Boolean,
|
172 | default: true
|
173 | },
|
174 | emoji: {
|
175 | type: Boolean,
|
176 | default: true
|
177 | },
|
178 | typographer: {
|
179 | type: Boolean,
|
180 | default: true
|
181 | },
|
182 | langPrefix: {
|
183 | type: String,
|
184 | default: 'language-'
|
185 | },
|
186 | quotes: {
|
187 | type: String,
|
188 | default: '“”‘’'
|
189 | },
|
190 | tableClass: {
|
191 | type: String,
|
192 | default: 'table'
|
193 | },
|
194 | taskLists: {
|
195 | type: Boolean,
|
196 | default: true
|
197 | },
|
198 | toc: {
|
199 | type: Boolean,
|
200 | default: false
|
201 | },
|
202 | tocId: {
|
203 | type: String
|
204 | },
|
205 | tocClass: {
|
206 | type: String,
|
207 | default: 'table-of-contents'
|
208 | },
|
209 | tocFirstLevel: {
|
210 | type: Number,
|
211 | default: 2
|
212 | },
|
213 | tocLastLevel: {
|
214 | type: Number
|
215 | },
|
216 | tocAnchorLink: {
|
217 | type: Boolean,
|
218 | default: true
|
219 | },
|
220 | tocAnchorClass: {
|
221 | type: String,
|
222 | default: 'toc-anchor'
|
223 | },
|
224 | tocAnchorLinkSymbol: {
|
225 | type: String,
|
226 | default: '#'
|
227 | },
|
228 | tocAnchorLinkSpace: {
|
229 | type: Boolean,
|
230 | default: true
|
231 | },
|
232 | tocAnchorLinkClass: {
|
233 | type: String,
|
234 | default: 'toc-anchor-link'
|
235 | },
|
236 | anchorAttributes: {
|
237 | type: Object,
|
238 | default: function _default() {
|
239 | return {};
|
240 | }
|
241 | },
|
242 | prerender: {
|
243 | type: Function,
|
244 | default: function _default(sourceData) {
|
245 | return sourceData;
|
246 | }
|
247 | },
|
248 | postrender: {
|
249 | type: Function,
|
250 | default: function _default(htmlData) {
|
251 | return htmlData;
|
252 | }
|
253 | }
|
254 | },
|
255 |
|
256 | computed: {
|
257 | tocLastLevelComputed: function tocLastLevelComputed() {
|
258 | return this.tocLastLevel > this.tocFirstLevel ? this.tocLastLevel : this.tocFirstLevel + 1;
|
259 | }
|
260 | },
|
261 |
|
262 | render: function render(createElement) {
|
263 | var _this = this;
|
264 |
|
265 | this.md = new _markdownIt2.default().use(_markdownItSub2.default).use(_markdownItSup2.default).use(_markdownItFootnote2.default).use(_markdownItDeflist2.default).use(_markdownItAbbr2.default).use(_markdownItIns2.default).use(_markdownItMark2.default).use(_markdownItKatex2.default, { "throwOnError": false, "errorColor": " #cc0000" }).use(_markdownItTaskLists2.default, { enabled: this.taskLists });
|
266 |
|
267 | if (this.emoji) {
|
268 | this.md.use(_markdownItEmoji2.default);
|
269 | }
|
270 |
|
271 | this.md.set({
|
272 | html: this.html,
|
273 | xhtmlOut: this.xhtmlOut,
|
274 | breaks: this.breaks,
|
275 | linkify: this.linkify,
|
276 | typographer: this.typographer,
|
277 | langPrefix: this.langPrefix,
|
278 | quotes: this.quotes
|
279 | });
|
280 | this.md.renderer.rules.table_open = function () {
|
281 | return '<table class="' + _this.tableClass + '">\n';
|
282 | };
|
283 | var defaultLinkRenderer = this.md.renderer.rules.link_open || function (tokens, idx, options, env, self) {
|
284 | return self.renderToken(tokens, idx, options);
|
285 | };
|
286 | this.md.renderer.rules.link_open = function (tokens, idx, options, env, self) {
|
287 | (0, _keys2.default)(_this.anchorAttributes).map(function (attribute) {
|
288 | var aIndex = tokens[idx].attrIndex(attribute);
|
289 | var value = _this.anchorAttributes[attribute];
|
290 | if (aIndex < 0) {
|
291 | tokens[idx].attrPush([attribute, value]);
|
292 | } else {
|
293 | tokens[idx].attrs[aIndex][1] = value;
|
294 | }
|
295 | });
|
296 | return defaultLinkRenderer(tokens, idx, options, env, self);
|
297 | };
|
298 |
|
299 | if (this.toc) {
|
300 | this.md.use(_markdownItTocAndAnchor2.default, {
|
301 | tocClassName: this.tocClass,
|
302 | tocFirstLevel: this.tocFirstLevel,
|
303 | tocLastLevel: this.tocLastLevelComputed,
|
304 | anchorLink: this.tocAnchorLink,
|
305 | anchorLinkSymbol: this.tocAnchorLinkSymbol,
|
306 | anchorLinkSpace: this.tocAnchorLinkSpace,
|
307 | anchorClassName: this.tocAnchorClass,
|
308 | anchorLinkSymbolClassName: this.tocAnchorLinkClass,
|
309 | tocCallback: function tocCallback(tocMarkdown, tocArray, tocHtml) {
|
310 | if (tocHtml) {
|
311 | if (_this.tocId && document.getElementById(_this.tocId)) {
|
312 | document.getElementById(_this.tocId).innerHTML = tocHtml;
|
313 | }
|
314 |
|
315 | _this.$emit('toc-rendered', tocHtml);
|
316 | }
|
317 | }
|
318 | });
|
319 | }
|
320 |
|
321 | var outHtml = this.show ? this.md.render(this.prerender(this.sourceData)) : '';
|
322 | outHtml = this.postrender(outHtml);
|
323 |
|
324 | this.$emit('rendered', outHtml);
|
325 | return createElement('div', {
|
326 | domProps: {
|
327 | innerHTML: outHtml
|
328 | }
|
329 | });
|
330 | },
|
331 | beforeMount: function beforeMount() {
|
332 | var _this2 = this;
|
333 |
|
334 | if (this.$slots.default) {
|
335 | this.sourceData = '';
|
336 | var _iteratorNormalCompletion = true;
|
337 | var _didIteratorError = false;
|
338 | var _iteratorError = undefined;
|
339 |
|
340 | try {
|
341 | for (var _iterator = (0, _getIterator3.default)(this.$slots.default), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
342 | var slot = _step.value;
|
343 |
|
344 | this.sourceData += slot.text;
|
345 | }
|
346 | } catch (err) {
|
347 | _didIteratorError = true;
|
348 | _iteratorError = err;
|
349 | } finally {
|
350 | try {
|
351 | if (!_iteratorNormalCompletion && _iterator.return) {
|
352 | _iterator.return();
|
353 | }
|
354 | } finally {
|
355 | if (_didIteratorError) {
|
356 | throw _iteratorError;
|
357 | }
|
358 | }
|
359 | }
|
360 | }
|
361 |
|
362 | this.$watch('source', function () {
|
363 | _this2.sourceData = _this2.prerender(_this2.source);
|
364 | _this2.$forceUpdate();
|
365 | });
|
366 |
|
367 | this.watches.forEach(function (v) {
|
368 | _this2.$watch(v, function () {
|
369 | _this2.$forceUpdate();
|
370 | });
|
371 | });
|
372 | }
|
373 | };
|
374 |
|
375 | }),
|
376 |
|
377 | (function(module, exports) {
|
378 |
|
379 | module.exports = __WEBPACK_EXTERNAL_MODULE_1__;
|
380 |
|
381 | }),
|
382 |
|
383 | (function(module, exports) {
|
384 |
|
385 | module.exports = __WEBPACK_EXTERNAL_MODULE_2__;
|
386 |
|
387 | }),
|
388 |
|
389 | (function(module, exports) {
|
390 |
|
391 | module.exports = __WEBPACK_EXTERNAL_MODULE_3__;
|
392 |
|
393 | }),
|
394 |
|
395 | (function(module, exports) {
|
396 |
|
397 | module.exports = __WEBPACK_EXTERNAL_MODULE_4__;
|
398 |
|
399 | }),
|
400 |
|
401 | (function(module, exports) {
|
402 |
|
403 | module.exports = __WEBPACK_EXTERNAL_MODULE_5__;
|
404 |
|
405 | }),
|
406 |
|
407 | (function(module, exports) {
|
408 |
|
409 | module.exports = __WEBPACK_EXTERNAL_MODULE_6__;
|
410 |
|
411 | }),
|
412 |
|
413 | (function(module, exports) {
|
414 |
|
415 | module.exports = __WEBPACK_EXTERNAL_MODULE_7__;
|
416 |
|
417 | }),
|
418 |
|
419 | (function(module, exports) {
|
420 |
|
421 | module.exports = __WEBPACK_EXTERNAL_MODULE_8__;
|
422 |
|
423 | }),
|
424 |
|
425 | (function(module, exports) {
|
426 |
|
427 | module.exports = __WEBPACK_EXTERNAL_MODULE_9__;
|
428 |
|
429 | }),
|
430 |
|
431 | (function(module, exports) {
|
432 |
|
433 | module.exports = __WEBPACK_EXTERNAL_MODULE_10__;
|
434 |
|
435 | }),
|
436 |
|
437 | (function(module, exports) {
|
438 |
|
439 | module.exports = __WEBPACK_EXTERNAL_MODULE_11__;
|
440 |
|
441 | }),
|
442 |
|
443 | (function(module, exports) {
|
444 |
|
445 | module.exports = __WEBPACK_EXTERNAL_MODULE_12__;
|
446 |
|
447 | }),
|
448 |
|
449 | (function(module, exports) {
|
450 |
|
451 | module.exports = __WEBPACK_EXTERNAL_MODULE_13__;
|
452 |
|
453 | }),
|
454 |
|
455 | (function(module, exports) {
|
456 |
|
457 | module.exports = __WEBPACK_EXTERNAL_MODULE_14__;
|
458 |
|
459 | })
|
460 | ])
|
461 | });
|
462 | ; |
\ | No newline at end of file |