|
1 this["wp"] = this["wp"] || {}; this["wp"]["blocks"] = |
|
2 /******/ (function(modules) { // webpackBootstrap |
|
3 /******/ // The module cache |
|
4 /******/ var installedModules = {}; |
|
5 /******/ |
|
6 /******/ // The require function |
|
7 /******/ function __webpack_require__(moduleId) { |
|
8 /******/ |
|
9 /******/ // Check if module is in cache |
|
10 /******/ if(installedModules[moduleId]) { |
|
11 /******/ return installedModules[moduleId].exports; |
|
12 /******/ } |
|
13 /******/ // Create a new module (and put it into the cache) |
|
14 /******/ var module = installedModules[moduleId] = { |
|
15 /******/ i: moduleId, |
|
16 /******/ l: false, |
|
17 /******/ exports: {} |
|
18 /******/ }; |
|
19 /******/ |
|
20 /******/ // Execute the module function |
|
21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
|
22 /******/ |
|
23 /******/ // Flag the module as loaded |
|
24 /******/ module.l = true; |
|
25 /******/ |
|
26 /******/ // Return the exports of the module |
|
27 /******/ return module.exports; |
|
28 /******/ } |
|
29 /******/ |
|
30 /******/ |
|
31 /******/ // expose the modules object (__webpack_modules__) |
|
32 /******/ __webpack_require__.m = modules; |
|
33 /******/ |
|
34 /******/ // expose the module cache |
|
35 /******/ __webpack_require__.c = installedModules; |
|
36 /******/ |
|
37 /******/ // define getter function for harmony exports |
|
38 /******/ __webpack_require__.d = function(exports, name, getter) { |
|
39 /******/ if(!__webpack_require__.o(exports, name)) { |
|
40 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); |
|
41 /******/ } |
|
42 /******/ }; |
|
43 /******/ |
|
44 /******/ // define __esModule on exports |
|
45 /******/ __webpack_require__.r = function(exports) { |
|
46 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
|
47 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
48 /******/ } |
|
49 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
50 /******/ }; |
|
51 /******/ |
|
52 /******/ // create a fake namespace object |
|
53 /******/ // mode & 1: value is a module id, require it |
|
54 /******/ // mode & 2: merge all properties of value into the ns |
|
55 /******/ // mode & 4: return value when already ns object |
|
56 /******/ // mode & 8|1: behave like require |
|
57 /******/ __webpack_require__.t = function(value, mode) { |
|
58 /******/ if(mode & 1) value = __webpack_require__(value); |
|
59 /******/ if(mode & 8) return value; |
|
60 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; |
|
61 /******/ var ns = Object.create(null); |
|
62 /******/ __webpack_require__.r(ns); |
|
63 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); |
|
64 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); |
|
65 /******/ return ns; |
|
66 /******/ }; |
|
67 /******/ |
|
68 /******/ // getDefaultExport function for compatibility with non-harmony modules |
|
69 /******/ __webpack_require__.n = function(module) { |
|
70 /******/ var getter = module && module.__esModule ? |
|
71 /******/ function getDefault() { return module['default']; } : |
|
72 /******/ function getModuleExports() { return module; }; |
|
73 /******/ __webpack_require__.d(getter, 'a', getter); |
|
74 /******/ return getter; |
|
75 /******/ }; |
|
76 /******/ |
|
77 /******/ // Object.prototype.hasOwnProperty.call |
|
78 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; |
|
79 /******/ |
|
80 /******/ // __webpack_public_path__ |
|
81 /******/ __webpack_require__.p = ""; |
|
82 /******/ |
|
83 /******/ |
|
84 /******/ // Load entry module and return exports |
|
85 /******/ return __webpack_require__(__webpack_require__.s = 362); |
|
86 /******/ }) |
|
87 /************************************************************************/ |
|
88 /******/ ({ |
|
89 |
|
90 /***/ 0: |
|
91 /***/ (function(module, exports) { |
|
92 |
|
93 (function() { module.exports = this["wp"]["element"]; }()); |
|
94 |
|
95 /***/ }), |
|
96 |
|
97 /***/ 1: |
|
98 /***/ (function(module, exports) { |
|
99 |
|
100 (function() { module.exports = this["wp"]["i18n"]; }()); |
|
101 |
|
102 /***/ }), |
|
103 |
|
104 /***/ 10: |
|
105 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
106 |
|
107 "use strict"; |
|
108 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; }); |
|
109 function _classCallCheck(instance, Constructor) { |
|
110 if (!(instance instanceof Constructor)) { |
|
111 throw new TypeError("Cannot call a class as a function"); |
|
112 } |
|
113 } |
|
114 |
|
115 /***/ }), |
|
116 |
|
117 /***/ 134: |
|
118 /***/ (function(module, exports) { |
|
119 |
|
120 (function() { module.exports = this["wp"]["shortcode"]; }()); |
|
121 |
|
122 /***/ }), |
|
123 |
|
124 /***/ 15: |
|
125 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
126 |
|
127 "use strict"; |
|
128 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); |
|
129 function _defineProperty(obj, key, value) { |
|
130 if (key in obj) { |
|
131 Object.defineProperty(obj, key, { |
|
132 value: value, |
|
133 enumerable: true, |
|
134 configurable: true, |
|
135 writable: true |
|
136 }); |
|
137 } else { |
|
138 obj[key] = value; |
|
139 } |
|
140 |
|
141 return obj; |
|
142 } |
|
143 |
|
144 /***/ }), |
|
145 |
|
146 /***/ 17: |
|
147 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
148 |
|
149 "use strict"; |
|
150 |
|
151 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js |
|
152 function _arrayWithoutHoles(arr) { |
|
153 if (Array.isArray(arr)) { |
|
154 for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { |
|
155 arr2[i] = arr[i]; |
|
156 } |
|
157 |
|
158 return arr2; |
|
159 } |
|
160 } |
|
161 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js |
|
162 var iterableToArray = __webpack_require__(34); |
|
163 |
|
164 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js |
|
165 function _nonIterableSpread() { |
|
166 throw new TypeError("Invalid attempt to spread non-iterable instance"); |
|
167 } |
|
168 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js |
|
169 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _toConsumableArray; }); |
|
170 |
|
171 |
|
172 |
|
173 function _toConsumableArray(arr) { |
|
174 return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || _nonIterableSpread(); |
|
175 } |
|
176 |
|
177 /***/ }), |
|
178 |
|
179 /***/ 19: |
|
180 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
181 |
|
182 "use strict"; |
|
183 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; }); |
|
184 function _extends() { |
|
185 _extends = Object.assign || function (target) { |
|
186 for (var i = 1; i < arguments.length; i++) { |
|
187 var source = arguments[i]; |
|
188 |
|
189 for (var key in source) { |
|
190 if (Object.prototype.hasOwnProperty.call(source, key)) { |
|
191 target[key] = source[key]; |
|
192 } |
|
193 } |
|
194 } |
|
195 |
|
196 return target; |
|
197 }; |
|
198 |
|
199 return _extends.apply(this, arguments); |
|
200 } |
|
201 |
|
202 /***/ }), |
|
203 |
|
204 /***/ 2: |
|
205 /***/ (function(module, exports) { |
|
206 |
|
207 (function() { module.exports = this["lodash"]; }()); |
|
208 |
|
209 /***/ }), |
|
210 |
|
211 /***/ 205: |
|
212 /***/ (function(module, exports) { |
|
213 |
|
214 (function() { module.exports = this["wp"]["blockSerializationDefaultParser"]; }()); |
|
215 |
|
216 /***/ }), |
|
217 |
|
218 /***/ 206: |
|
219 /***/ (function(module, exports, __webpack_require__) { |
|
220 |
|
221 var __WEBPACK_AMD_DEFINE_RESULT__;;/*! showdown v 1.9.0 - 10-11-2018 */ |
|
222 (function(){ |
|
223 /** |
|
224 * Created by Tivie on 13-07-2015. |
|
225 */ |
|
226 |
|
227 function getDefaultOpts (simple) { |
|
228 'use strict'; |
|
229 |
|
230 var defaultOptions = { |
|
231 omitExtraWLInCodeBlocks: { |
|
232 defaultValue: false, |
|
233 describe: 'Omit the default extra whiteline added to code blocks', |
|
234 type: 'boolean' |
|
235 }, |
|
236 noHeaderId: { |
|
237 defaultValue: false, |
|
238 describe: 'Turn on/off generated header id', |
|
239 type: 'boolean' |
|
240 }, |
|
241 prefixHeaderId: { |
|
242 defaultValue: false, |
|
243 describe: 'Add a prefix to the generated header ids. Passing a string will prefix that string to the header id. Setting to true will add a generic \'section-\' prefix', |
|
244 type: 'string' |
|
245 }, |
|
246 rawPrefixHeaderId: { |
|
247 defaultValue: false, |
|
248 describe: 'Setting this option to true will prevent showdown from modifying the prefix. This might result in malformed IDs (if, for instance, the " char is used in the prefix)', |
|
249 type: 'boolean' |
|
250 }, |
|
251 ghCompatibleHeaderId: { |
|
252 defaultValue: false, |
|
253 describe: 'Generate header ids compatible with github style (spaces are replaced with dashes, a bunch of non alphanumeric chars are removed)', |
|
254 type: 'boolean' |
|
255 }, |
|
256 rawHeaderId: { |
|
257 defaultValue: false, |
|
258 describe: 'Remove only spaces, \' and " from generated header ids (including prefixes), replacing them with dashes (-). WARNING: This might result in malformed ids', |
|
259 type: 'boolean' |
|
260 }, |
|
261 headerLevelStart: { |
|
262 defaultValue: false, |
|
263 describe: 'The header blocks level start', |
|
264 type: 'integer' |
|
265 }, |
|
266 parseImgDimensions: { |
|
267 defaultValue: false, |
|
268 describe: 'Turn on/off image dimension parsing', |
|
269 type: 'boolean' |
|
270 }, |
|
271 simplifiedAutoLink: { |
|
272 defaultValue: false, |
|
273 describe: 'Turn on/off GFM autolink style', |
|
274 type: 'boolean' |
|
275 }, |
|
276 excludeTrailingPunctuationFromURLs: { |
|
277 defaultValue: false, |
|
278 describe: 'Excludes trailing punctuation from links generated with autoLinking', |
|
279 type: 'boolean' |
|
280 }, |
|
281 literalMidWordUnderscores: { |
|
282 defaultValue: false, |
|
283 describe: 'Parse midword underscores as literal underscores', |
|
284 type: 'boolean' |
|
285 }, |
|
286 literalMidWordAsterisks: { |
|
287 defaultValue: false, |
|
288 describe: 'Parse midword asterisks as literal asterisks', |
|
289 type: 'boolean' |
|
290 }, |
|
291 strikethrough: { |
|
292 defaultValue: false, |
|
293 describe: 'Turn on/off strikethrough support', |
|
294 type: 'boolean' |
|
295 }, |
|
296 tables: { |
|
297 defaultValue: false, |
|
298 describe: 'Turn on/off tables support', |
|
299 type: 'boolean' |
|
300 }, |
|
301 tablesHeaderId: { |
|
302 defaultValue: false, |
|
303 describe: 'Add an id to table headers', |
|
304 type: 'boolean' |
|
305 }, |
|
306 ghCodeBlocks: { |
|
307 defaultValue: true, |
|
308 describe: 'Turn on/off GFM fenced code blocks support', |
|
309 type: 'boolean' |
|
310 }, |
|
311 tasklists: { |
|
312 defaultValue: false, |
|
313 describe: 'Turn on/off GFM tasklist support', |
|
314 type: 'boolean' |
|
315 }, |
|
316 smoothLivePreview: { |
|
317 defaultValue: false, |
|
318 describe: 'Prevents weird effects in live previews due to incomplete input', |
|
319 type: 'boolean' |
|
320 }, |
|
321 smartIndentationFix: { |
|
322 defaultValue: false, |
|
323 description: 'Tries to smartly fix indentation in es6 strings', |
|
324 type: 'boolean' |
|
325 }, |
|
326 disableForced4SpacesIndentedSublists: { |
|
327 defaultValue: false, |
|
328 description: 'Disables the requirement of indenting nested sublists by 4 spaces', |
|
329 type: 'boolean' |
|
330 }, |
|
331 simpleLineBreaks: { |
|
332 defaultValue: false, |
|
333 description: 'Parses simple line breaks as <br> (GFM Style)', |
|
334 type: 'boolean' |
|
335 }, |
|
336 requireSpaceBeforeHeadingText: { |
|
337 defaultValue: false, |
|
338 description: 'Makes adding a space between `#` and the header text mandatory (GFM Style)', |
|
339 type: 'boolean' |
|
340 }, |
|
341 ghMentions: { |
|
342 defaultValue: false, |
|
343 description: 'Enables github @mentions', |
|
344 type: 'boolean' |
|
345 }, |
|
346 ghMentionsLink: { |
|
347 defaultValue: 'https://github.com/{u}', |
|
348 description: 'Changes the link generated by @mentions. Only applies if ghMentions option is enabled.', |
|
349 type: 'string' |
|
350 }, |
|
351 encodeEmails: { |
|
352 defaultValue: true, |
|
353 description: 'Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities', |
|
354 type: 'boolean' |
|
355 }, |
|
356 openLinksInNewWindow: { |
|
357 defaultValue: false, |
|
358 description: 'Open all links in new windows', |
|
359 type: 'boolean' |
|
360 }, |
|
361 backslashEscapesHTMLTags: { |
|
362 defaultValue: false, |
|
363 description: 'Support for HTML Tag escaping. ex: \<div>foo\</div>', |
|
364 type: 'boolean' |
|
365 }, |
|
366 emoji: { |
|
367 defaultValue: false, |
|
368 description: 'Enable emoji support. Ex: `this is a :smile: emoji`', |
|
369 type: 'boolean' |
|
370 }, |
|
371 underline: { |
|
372 defaultValue: false, |
|
373 description: 'Enable support for underline. Syntax is double or triple underscores: `__underline word__`. With this option enabled, underscores no longer parses into `<em>` and `<strong>`', |
|
374 type: 'boolean' |
|
375 }, |
|
376 completeHTMLDocument: { |
|
377 defaultValue: false, |
|
378 description: 'Outputs a complete html document, including `<html>`, `<head>` and `<body>` tags', |
|
379 type: 'boolean' |
|
380 }, |
|
381 metadata: { |
|
382 defaultValue: false, |
|
383 description: 'Enable support for document metadata (defined at the top of the document between `«««` and `»»»` or between `---` and `---`).', |
|
384 type: 'boolean' |
|
385 }, |
|
386 splitAdjacentBlockquotes: { |
|
387 defaultValue: false, |
|
388 description: 'Split adjacent blockquote blocks', |
|
389 type: 'boolean' |
|
390 } |
|
391 }; |
|
392 if (simple === false) { |
|
393 return JSON.parse(JSON.stringify(defaultOptions)); |
|
394 } |
|
395 var ret = {}; |
|
396 for (var opt in defaultOptions) { |
|
397 if (defaultOptions.hasOwnProperty(opt)) { |
|
398 ret[opt] = defaultOptions[opt].defaultValue; |
|
399 } |
|
400 } |
|
401 return ret; |
|
402 } |
|
403 |
|
404 function allOptionsOn () { |
|
405 'use strict'; |
|
406 var options = getDefaultOpts(true), |
|
407 ret = {}; |
|
408 for (var opt in options) { |
|
409 if (options.hasOwnProperty(opt)) { |
|
410 ret[opt] = true; |
|
411 } |
|
412 } |
|
413 return ret; |
|
414 } |
|
415 |
|
416 /** |
|
417 * Created by Tivie on 06-01-2015. |
|
418 */ |
|
419 |
|
420 // Private properties |
|
421 var showdown = {}, |
|
422 parsers = {}, |
|
423 extensions = {}, |
|
424 globalOptions = getDefaultOpts(true), |
|
425 setFlavor = 'vanilla', |
|
426 flavor = { |
|
427 github: { |
|
428 omitExtraWLInCodeBlocks: true, |
|
429 simplifiedAutoLink: true, |
|
430 excludeTrailingPunctuationFromURLs: true, |
|
431 literalMidWordUnderscores: true, |
|
432 strikethrough: true, |
|
433 tables: true, |
|
434 tablesHeaderId: true, |
|
435 ghCodeBlocks: true, |
|
436 tasklists: true, |
|
437 disableForced4SpacesIndentedSublists: true, |
|
438 simpleLineBreaks: true, |
|
439 requireSpaceBeforeHeadingText: true, |
|
440 ghCompatibleHeaderId: true, |
|
441 ghMentions: true, |
|
442 backslashEscapesHTMLTags: true, |
|
443 emoji: true, |
|
444 splitAdjacentBlockquotes: true |
|
445 }, |
|
446 original: { |
|
447 noHeaderId: true, |
|
448 ghCodeBlocks: false |
|
449 }, |
|
450 ghost: { |
|
451 omitExtraWLInCodeBlocks: true, |
|
452 parseImgDimensions: true, |
|
453 simplifiedAutoLink: true, |
|
454 excludeTrailingPunctuationFromURLs: true, |
|
455 literalMidWordUnderscores: true, |
|
456 strikethrough: true, |
|
457 tables: true, |
|
458 tablesHeaderId: true, |
|
459 ghCodeBlocks: true, |
|
460 tasklists: true, |
|
461 smoothLivePreview: true, |
|
462 simpleLineBreaks: true, |
|
463 requireSpaceBeforeHeadingText: true, |
|
464 ghMentions: false, |
|
465 encodeEmails: true |
|
466 }, |
|
467 vanilla: getDefaultOpts(true), |
|
468 allOn: allOptionsOn() |
|
469 }; |
|
470 |
|
471 /** |
|
472 * helper namespace |
|
473 * @type {{}} |
|
474 */ |
|
475 showdown.helper = {}; |
|
476 |
|
477 /** |
|
478 * TODO LEGACY SUPPORT CODE |
|
479 * @type {{}} |
|
480 */ |
|
481 showdown.extensions = {}; |
|
482 |
|
483 /** |
|
484 * Set a global option |
|
485 * @static |
|
486 * @param {string} key |
|
487 * @param {*} value |
|
488 * @returns {showdown} |
|
489 */ |
|
490 showdown.setOption = function (key, value) { |
|
491 'use strict'; |
|
492 globalOptions[key] = value; |
|
493 return this; |
|
494 }; |
|
495 |
|
496 /** |
|
497 * Get a global option |
|
498 * @static |
|
499 * @param {string} key |
|
500 * @returns {*} |
|
501 */ |
|
502 showdown.getOption = function (key) { |
|
503 'use strict'; |
|
504 return globalOptions[key]; |
|
505 }; |
|
506 |
|
507 /** |
|
508 * Get the global options |
|
509 * @static |
|
510 * @returns {{}} |
|
511 */ |
|
512 showdown.getOptions = function () { |
|
513 'use strict'; |
|
514 return globalOptions; |
|
515 }; |
|
516 |
|
517 /** |
|
518 * Reset global options to the default values |
|
519 * @static |
|
520 */ |
|
521 showdown.resetOptions = function () { |
|
522 'use strict'; |
|
523 globalOptions = getDefaultOpts(true); |
|
524 }; |
|
525 |
|
526 /** |
|
527 * Set the flavor showdown should use as default |
|
528 * @param {string} name |
|
529 */ |
|
530 showdown.setFlavor = function (name) { |
|
531 'use strict'; |
|
532 if (!flavor.hasOwnProperty(name)) { |
|
533 throw Error(name + ' flavor was not found'); |
|
534 } |
|
535 showdown.resetOptions(); |
|
536 var preset = flavor[name]; |
|
537 setFlavor = name; |
|
538 for (var option in preset) { |
|
539 if (preset.hasOwnProperty(option)) { |
|
540 globalOptions[option] = preset[option]; |
|
541 } |
|
542 } |
|
543 }; |
|
544 |
|
545 /** |
|
546 * Get the currently set flavor |
|
547 * @returns {string} |
|
548 */ |
|
549 showdown.getFlavor = function () { |
|
550 'use strict'; |
|
551 return setFlavor; |
|
552 }; |
|
553 |
|
554 /** |
|
555 * Get the options of a specified flavor. Returns undefined if the flavor was not found |
|
556 * @param {string} name Name of the flavor |
|
557 * @returns {{}|undefined} |
|
558 */ |
|
559 showdown.getFlavorOptions = function (name) { |
|
560 'use strict'; |
|
561 if (flavor.hasOwnProperty(name)) { |
|
562 return flavor[name]; |
|
563 } |
|
564 }; |
|
565 |
|
566 /** |
|
567 * Get the default options |
|
568 * @static |
|
569 * @param {boolean} [simple=true] |
|
570 * @returns {{}} |
|
571 */ |
|
572 showdown.getDefaultOptions = function (simple) { |
|
573 'use strict'; |
|
574 return getDefaultOpts(simple); |
|
575 }; |
|
576 |
|
577 /** |
|
578 * Get or set a subParser |
|
579 * |
|
580 * subParser(name) - Get a registered subParser |
|
581 * subParser(name, func) - Register a subParser |
|
582 * @static |
|
583 * @param {string} name |
|
584 * @param {function} [func] |
|
585 * @returns {*} |
|
586 */ |
|
587 showdown.subParser = function (name, func) { |
|
588 'use strict'; |
|
589 if (showdown.helper.isString(name)) { |
|
590 if (typeof func !== 'undefined') { |
|
591 parsers[name] = func; |
|
592 } else { |
|
593 if (parsers.hasOwnProperty(name)) { |
|
594 return parsers[name]; |
|
595 } else { |
|
596 throw Error('SubParser named ' + name + ' not registered!'); |
|
597 } |
|
598 } |
|
599 } |
|
600 }; |
|
601 |
|
602 /** |
|
603 * Gets or registers an extension |
|
604 * @static |
|
605 * @param {string} name |
|
606 * @param {object|function=} ext |
|
607 * @returns {*} |
|
608 */ |
|
609 showdown.extension = function (name, ext) { |
|
610 'use strict'; |
|
611 |
|
612 if (!showdown.helper.isString(name)) { |
|
613 throw Error('Extension \'name\' must be a string'); |
|
614 } |
|
615 |
|
616 name = showdown.helper.stdExtName(name); |
|
617 |
|
618 // Getter |
|
619 if (showdown.helper.isUndefined(ext)) { |
|
620 if (!extensions.hasOwnProperty(name)) { |
|
621 throw Error('Extension named ' + name + ' is not registered!'); |
|
622 } |
|
623 return extensions[name]; |
|
624 |
|
625 // Setter |
|
626 } else { |
|
627 // Expand extension if it's wrapped in a function |
|
628 if (typeof ext === 'function') { |
|
629 ext = ext(); |
|
630 } |
|
631 |
|
632 // Ensure extension is an array |
|
633 if (!showdown.helper.isArray(ext)) { |
|
634 ext = [ext]; |
|
635 } |
|
636 |
|
637 var validExtension = validate(ext, name); |
|
638 |
|
639 if (validExtension.valid) { |
|
640 extensions[name] = ext; |
|
641 } else { |
|
642 throw Error(validExtension.error); |
|
643 } |
|
644 } |
|
645 }; |
|
646 |
|
647 /** |
|
648 * Gets all extensions registered |
|
649 * @returns {{}} |
|
650 */ |
|
651 showdown.getAllExtensions = function () { |
|
652 'use strict'; |
|
653 return extensions; |
|
654 }; |
|
655 |
|
656 /** |
|
657 * Remove an extension |
|
658 * @param {string} name |
|
659 */ |
|
660 showdown.removeExtension = function (name) { |
|
661 'use strict'; |
|
662 delete extensions[name]; |
|
663 }; |
|
664 |
|
665 /** |
|
666 * Removes all extensions |
|
667 */ |
|
668 showdown.resetExtensions = function () { |
|
669 'use strict'; |
|
670 extensions = {}; |
|
671 }; |
|
672 |
|
673 /** |
|
674 * Validate extension |
|
675 * @param {array} extension |
|
676 * @param {string} name |
|
677 * @returns {{valid: boolean, error: string}} |
|
678 */ |
|
679 function validate (extension, name) { |
|
680 'use strict'; |
|
681 |
|
682 var errMsg = (name) ? 'Error in ' + name + ' extension->' : 'Error in unnamed extension', |
|
683 ret = { |
|
684 valid: true, |
|
685 error: '' |
|
686 }; |
|
687 |
|
688 if (!showdown.helper.isArray(extension)) { |
|
689 extension = [extension]; |
|
690 } |
|
691 |
|
692 for (var i = 0; i < extension.length; ++i) { |
|
693 var baseMsg = errMsg + ' sub-extension ' + i + ': ', |
|
694 ext = extension[i]; |
|
695 if (typeof ext !== 'object') { |
|
696 ret.valid = false; |
|
697 ret.error = baseMsg + 'must be an object, but ' + typeof ext + ' given'; |
|
698 return ret; |
|
699 } |
|
700 |
|
701 if (!showdown.helper.isString(ext.type)) { |
|
702 ret.valid = false; |
|
703 ret.error = baseMsg + 'property "type" must be a string, but ' + typeof ext.type + ' given'; |
|
704 return ret; |
|
705 } |
|
706 |
|
707 var type = ext.type = ext.type.toLowerCase(); |
|
708 |
|
709 // normalize extension type |
|
710 if (type === 'language') { |
|
711 type = ext.type = 'lang'; |
|
712 } |
|
713 |
|
714 if (type === 'html') { |
|
715 type = ext.type = 'output'; |
|
716 } |
|
717 |
|
718 if (type !== 'lang' && type !== 'output' && type !== 'listener') { |
|
719 ret.valid = false; |
|
720 ret.error = baseMsg + 'type ' + type + ' is not recognized. Valid values: "lang/language", "output/html" or "listener"'; |
|
721 return ret; |
|
722 } |
|
723 |
|
724 if (type === 'listener') { |
|
725 if (showdown.helper.isUndefined(ext.listeners)) { |
|
726 ret.valid = false; |
|
727 ret.error = baseMsg + '. Extensions of type "listener" must have a property called "listeners"'; |
|
728 return ret; |
|
729 } |
|
730 } else { |
|
731 if (showdown.helper.isUndefined(ext.filter) && showdown.helper.isUndefined(ext.regex)) { |
|
732 ret.valid = false; |
|
733 ret.error = baseMsg + type + ' extensions must define either a "regex" property or a "filter" method'; |
|
734 return ret; |
|
735 } |
|
736 } |
|
737 |
|
738 if (ext.listeners) { |
|
739 if (typeof ext.listeners !== 'object') { |
|
740 ret.valid = false; |
|
741 ret.error = baseMsg + '"listeners" property must be an object but ' + typeof ext.listeners + ' given'; |
|
742 return ret; |
|
743 } |
|
744 for (var ln in ext.listeners) { |
|
745 if (ext.listeners.hasOwnProperty(ln)) { |
|
746 if (typeof ext.listeners[ln] !== 'function') { |
|
747 ret.valid = false; |
|
748 ret.error = baseMsg + '"listeners" property must be an hash of [event name]: [callback]. listeners.' + ln + |
|
749 ' must be a function but ' + typeof ext.listeners[ln] + ' given'; |
|
750 return ret; |
|
751 } |
|
752 } |
|
753 } |
|
754 } |
|
755 |
|
756 if (ext.filter) { |
|
757 if (typeof ext.filter !== 'function') { |
|
758 ret.valid = false; |
|
759 ret.error = baseMsg + '"filter" must be a function, but ' + typeof ext.filter + ' given'; |
|
760 return ret; |
|
761 } |
|
762 } else if (ext.regex) { |
|
763 if (showdown.helper.isString(ext.regex)) { |
|
764 ext.regex = new RegExp(ext.regex, 'g'); |
|
765 } |
|
766 if (!(ext.regex instanceof RegExp)) { |
|
767 ret.valid = false; |
|
768 ret.error = baseMsg + '"regex" property must either be a string or a RegExp object, but ' + typeof ext.regex + ' given'; |
|
769 return ret; |
|
770 } |
|
771 if (showdown.helper.isUndefined(ext.replace)) { |
|
772 ret.valid = false; |
|
773 ret.error = baseMsg + '"regex" extensions must implement a replace string or function'; |
|
774 return ret; |
|
775 } |
|
776 } |
|
777 } |
|
778 return ret; |
|
779 } |
|
780 |
|
781 /** |
|
782 * Validate extension |
|
783 * @param {object} ext |
|
784 * @returns {boolean} |
|
785 */ |
|
786 showdown.validateExtension = function (ext) { |
|
787 'use strict'; |
|
788 |
|
789 var validateExtension = validate(ext, null); |
|
790 if (!validateExtension.valid) { |
|
791 console.warn(validateExtension.error); |
|
792 return false; |
|
793 } |
|
794 return true; |
|
795 }; |
|
796 |
|
797 /** |
|
798 * showdownjs helper functions |
|
799 */ |
|
800 |
|
801 if (!showdown.hasOwnProperty('helper')) { |
|
802 showdown.helper = {}; |
|
803 } |
|
804 |
|
805 /** |
|
806 * Check if var is string |
|
807 * @static |
|
808 * @param {string} a |
|
809 * @returns {boolean} |
|
810 */ |
|
811 showdown.helper.isString = function (a) { |
|
812 'use strict'; |
|
813 return (typeof a === 'string' || a instanceof String); |
|
814 }; |
|
815 |
|
816 /** |
|
817 * Check if var is a function |
|
818 * @static |
|
819 * @param {*} a |
|
820 * @returns {boolean} |
|
821 */ |
|
822 showdown.helper.isFunction = function (a) { |
|
823 'use strict'; |
|
824 var getType = {}; |
|
825 return a && getType.toString.call(a) === '[object Function]'; |
|
826 }; |
|
827 |
|
828 /** |
|
829 * isArray helper function |
|
830 * @static |
|
831 * @param {*} a |
|
832 * @returns {boolean} |
|
833 */ |
|
834 showdown.helper.isArray = function (a) { |
|
835 'use strict'; |
|
836 return Array.isArray(a); |
|
837 }; |
|
838 |
|
839 /** |
|
840 * Check if value is undefined |
|
841 * @static |
|
842 * @param {*} value The value to check. |
|
843 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. |
|
844 */ |
|
845 showdown.helper.isUndefined = function (value) { |
|
846 'use strict'; |
|
847 return typeof value === 'undefined'; |
|
848 }; |
|
849 |
|
850 /** |
|
851 * ForEach helper function |
|
852 * Iterates over Arrays and Objects (own properties only) |
|
853 * @static |
|
854 * @param {*} obj |
|
855 * @param {function} callback Accepts 3 params: 1. value, 2. key, 3. the original array/object |
|
856 */ |
|
857 showdown.helper.forEach = function (obj, callback) { |
|
858 'use strict'; |
|
859 // check if obj is defined |
|
860 if (showdown.helper.isUndefined(obj)) { |
|
861 throw new Error('obj param is required'); |
|
862 } |
|
863 |
|
864 if (showdown.helper.isUndefined(callback)) { |
|
865 throw new Error('callback param is required'); |
|
866 } |
|
867 |
|
868 if (!showdown.helper.isFunction(callback)) { |
|
869 throw new Error('callback param must be a function/closure'); |
|
870 } |
|
871 |
|
872 if (typeof obj.forEach === 'function') { |
|
873 obj.forEach(callback); |
|
874 } else if (showdown.helper.isArray(obj)) { |
|
875 for (var i = 0; i < obj.length; i++) { |
|
876 callback(obj[i], i, obj); |
|
877 } |
|
878 } else if (typeof (obj) === 'object') { |
|
879 for (var prop in obj) { |
|
880 if (obj.hasOwnProperty(prop)) { |
|
881 callback(obj[prop], prop, obj); |
|
882 } |
|
883 } |
|
884 } else { |
|
885 throw new Error('obj does not seem to be an array or an iterable object'); |
|
886 } |
|
887 }; |
|
888 |
|
889 /** |
|
890 * Standardidize extension name |
|
891 * @static |
|
892 * @param {string} s extension name |
|
893 * @returns {string} |
|
894 */ |
|
895 showdown.helper.stdExtName = function (s) { |
|
896 'use strict'; |
|
897 return s.replace(/[_?*+\/\\.^-]/g, '').replace(/\s/g, '').toLowerCase(); |
|
898 }; |
|
899 |
|
900 function escapeCharactersCallback (wholeMatch, m1) { |
|
901 'use strict'; |
|
902 var charCodeToEscape = m1.charCodeAt(0); |
|
903 return '¨E' + charCodeToEscape + 'E'; |
|
904 } |
|
905 |
|
906 /** |
|
907 * Callback used to escape characters when passing through String.replace |
|
908 * @static |
|
909 * @param {string} wholeMatch |
|
910 * @param {string} m1 |
|
911 * @returns {string} |
|
912 */ |
|
913 showdown.helper.escapeCharactersCallback = escapeCharactersCallback; |
|
914 |
|
915 /** |
|
916 * Escape characters in a string |
|
917 * @static |
|
918 * @param {string} text |
|
919 * @param {string} charsToEscape |
|
920 * @param {boolean} afterBackslash |
|
921 * @returns {XML|string|void|*} |
|
922 */ |
|
923 showdown.helper.escapeCharacters = function (text, charsToEscape, afterBackslash) { |
|
924 'use strict'; |
|
925 // First we have to escape the escape characters so that |
|
926 // we can build a character class out of them |
|
927 var regexString = '([' + charsToEscape.replace(/([\[\]\\])/g, '\\$1') + '])'; |
|
928 |
|
929 if (afterBackslash) { |
|
930 regexString = '\\\\' + regexString; |
|
931 } |
|
932 |
|
933 var regex = new RegExp(regexString, 'g'); |
|
934 text = text.replace(regex, escapeCharactersCallback); |
|
935 |
|
936 return text; |
|
937 }; |
|
938 |
|
939 /** |
|
940 * Unescape HTML entities |
|
941 * @param txt |
|
942 * @returns {string} |
|
943 */ |
|
944 showdown.helper.unescapeHTMLEntities = function (txt) { |
|
945 'use strict'; |
|
946 |
|
947 return txt |
|
948 .replace(/"/g, '"') |
|
949 .replace(/</g, '<') |
|
950 .replace(/>/g, '>') |
|
951 .replace(/&/g, '&'); |
|
952 }; |
|
953 |
|
954 var rgxFindMatchPos = function (str, left, right, flags) { |
|
955 'use strict'; |
|
956 var f = flags || '', |
|
957 g = f.indexOf('g') > -1, |
|
958 x = new RegExp(left + '|' + right, 'g' + f.replace(/g/g, '')), |
|
959 l = new RegExp(left, f.replace(/g/g, '')), |
|
960 pos = [], |
|
961 t, s, m, start, end; |
|
962 |
|
963 do { |
|
964 t = 0; |
|
965 while ((m = x.exec(str))) { |
|
966 if (l.test(m[0])) { |
|
967 if (!(t++)) { |
|
968 s = x.lastIndex; |
|
969 start = s - m[0].length; |
|
970 } |
|
971 } else if (t) { |
|
972 if (!--t) { |
|
973 end = m.index + m[0].length; |
|
974 var obj = { |
|
975 left: {start: start, end: s}, |
|
976 match: {start: s, end: m.index}, |
|
977 right: {start: m.index, end: end}, |
|
978 wholeMatch: {start: start, end: end} |
|
979 }; |
|
980 pos.push(obj); |
|
981 if (!g) { |
|
982 return pos; |
|
983 } |
|
984 } |
|
985 } |
|
986 } |
|
987 } while (t && (x.lastIndex = s)); |
|
988 |
|
989 return pos; |
|
990 }; |
|
991 |
|
992 /** |
|
993 * matchRecursiveRegExp |
|
994 * |
|
995 * (c) 2007 Steven Levithan <stevenlevithan.com> |
|
996 * MIT License |
|
997 * |
|
998 * Accepts a string to search, a left and right format delimiter |
|
999 * as regex patterns, and optional regex flags. Returns an array |
|
1000 * of matches, allowing nested instances of left/right delimiters. |
|
1001 * Use the "g" flag to return all matches, otherwise only the |
|
1002 * first is returned. Be careful to ensure that the left and |
|
1003 * right format delimiters produce mutually exclusive matches. |
|
1004 * Backreferences are not supported within the right delimiter |
|
1005 * due to how it is internally combined with the left delimiter. |
|
1006 * When matching strings whose format delimiters are unbalanced |
|
1007 * to the left or right, the output is intentionally as a |
|
1008 * conventional regex library with recursion support would |
|
1009 * produce, e.g. "<<x>" and "<x>>" both produce ["x"] when using |
|
1010 * "<" and ">" as the delimiters (both strings contain a single, |
|
1011 * balanced instance of "<x>"). |
|
1012 * |
|
1013 * examples: |
|
1014 * matchRecursiveRegExp("test", "\\(", "\\)") |
|
1015 * returns: [] |
|
1016 * matchRecursiveRegExp("<t<<e>><s>>t<>", "<", ">", "g") |
|
1017 * returns: ["t<<e>><s>", ""] |
|
1018 * matchRecursiveRegExp("<div id=\"x\">test</div>", "<div\\b[^>]*>", "</div>", "gi") |
|
1019 * returns: ["test"] |
|
1020 */ |
|
1021 showdown.helper.matchRecursiveRegExp = function (str, left, right, flags) { |
|
1022 'use strict'; |
|
1023 |
|
1024 var matchPos = rgxFindMatchPos (str, left, right, flags), |
|
1025 results = []; |
|
1026 |
|
1027 for (var i = 0; i < matchPos.length; ++i) { |
|
1028 results.push([ |
|
1029 str.slice(matchPos[i].wholeMatch.start, matchPos[i].wholeMatch.end), |
|
1030 str.slice(matchPos[i].match.start, matchPos[i].match.end), |
|
1031 str.slice(matchPos[i].left.start, matchPos[i].left.end), |
|
1032 str.slice(matchPos[i].right.start, matchPos[i].right.end) |
|
1033 ]); |
|
1034 } |
|
1035 return results; |
|
1036 }; |
|
1037 |
|
1038 /** |
|
1039 * |
|
1040 * @param {string} str |
|
1041 * @param {string|function} replacement |
|
1042 * @param {string} left |
|
1043 * @param {string} right |
|
1044 * @param {string} flags |
|
1045 * @returns {string} |
|
1046 */ |
|
1047 showdown.helper.replaceRecursiveRegExp = function (str, replacement, left, right, flags) { |
|
1048 'use strict'; |
|
1049 |
|
1050 if (!showdown.helper.isFunction(replacement)) { |
|
1051 var repStr = replacement; |
|
1052 replacement = function () { |
|
1053 return repStr; |
|
1054 }; |
|
1055 } |
|
1056 |
|
1057 var matchPos = rgxFindMatchPos(str, left, right, flags), |
|
1058 finalStr = str, |
|
1059 lng = matchPos.length; |
|
1060 |
|
1061 if (lng > 0) { |
|
1062 var bits = []; |
|
1063 if (matchPos[0].wholeMatch.start !== 0) { |
|
1064 bits.push(str.slice(0, matchPos[0].wholeMatch.start)); |
|
1065 } |
|
1066 for (var i = 0; i < lng; ++i) { |
|
1067 bits.push( |
|
1068 replacement( |
|
1069 str.slice(matchPos[i].wholeMatch.start, matchPos[i].wholeMatch.end), |
|
1070 str.slice(matchPos[i].match.start, matchPos[i].match.end), |
|
1071 str.slice(matchPos[i].left.start, matchPos[i].left.end), |
|
1072 str.slice(matchPos[i].right.start, matchPos[i].right.end) |
|
1073 ) |
|
1074 ); |
|
1075 if (i < lng - 1) { |
|
1076 bits.push(str.slice(matchPos[i].wholeMatch.end, matchPos[i + 1].wholeMatch.start)); |
|
1077 } |
|
1078 } |
|
1079 if (matchPos[lng - 1].wholeMatch.end < str.length) { |
|
1080 bits.push(str.slice(matchPos[lng - 1].wholeMatch.end)); |
|
1081 } |
|
1082 finalStr = bits.join(''); |
|
1083 } |
|
1084 return finalStr; |
|
1085 }; |
|
1086 |
|
1087 /** |
|
1088 * Returns the index within the passed String object of the first occurrence of the specified regex, |
|
1089 * starting the search at fromIndex. Returns -1 if the value is not found. |
|
1090 * |
|
1091 * @param {string} str string to search |
|
1092 * @param {RegExp} regex Regular expression to search |
|
1093 * @param {int} [fromIndex = 0] Index to start the search |
|
1094 * @returns {Number} |
|
1095 * @throws InvalidArgumentError |
|
1096 */ |
|
1097 showdown.helper.regexIndexOf = function (str, regex, fromIndex) { |
|
1098 'use strict'; |
|
1099 if (!showdown.helper.isString(str)) { |
|
1100 throw 'InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string'; |
|
1101 } |
|
1102 if (regex instanceof RegExp === false) { |
|
1103 throw 'InvalidArgumentError: second parameter of showdown.helper.regexIndexOf function must be an instance of RegExp'; |
|
1104 } |
|
1105 var indexOf = str.substring(fromIndex || 0).search(regex); |
|
1106 return (indexOf >= 0) ? (indexOf + (fromIndex || 0)) : indexOf; |
|
1107 }; |
|
1108 |
|
1109 /** |
|
1110 * Splits the passed string object at the defined index, and returns an array composed of the two substrings |
|
1111 * @param {string} str string to split |
|
1112 * @param {int} index index to split string at |
|
1113 * @returns {[string,string]} |
|
1114 * @throws InvalidArgumentError |
|
1115 */ |
|
1116 showdown.helper.splitAtIndex = function (str, index) { |
|
1117 'use strict'; |
|
1118 if (!showdown.helper.isString(str)) { |
|
1119 throw 'InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string'; |
|
1120 } |
|
1121 return [str.substring(0, index), str.substring(index)]; |
|
1122 }; |
|
1123 |
|
1124 /** |
|
1125 * Obfuscate an e-mail address through the use of Character Entities, |
|
1126 * transforming ASCII characters into their equivalent decimal or hex entities. |
|
1127 * |
|
1128 * Since it has a random component, subsequent calls to this function produce different results |
|
1129 * |
|
1130 * @param {string} mail |
|
1131 * @returns {string} |
|
1132 */ |
|
1133 showdown.helper.encodeEmailAddress = function (mail) { |
|
1134 'use strict'; |
|
1135 var encode = [ |
|
1136 function (ch) { |
|
1137 return '&#' + ch.charCodeAt(0) + ';'; |
|
1138 }, |
|
1139 function (ch) { |
|
1140 return '&#x' + ch.charCodeAt(0).toString(16) + ';'; |
|
1141 }, |
|
1142 function (ch) { |
|
1143 return ch; |
|
1144 } |
|
1145 ]; |
|
1146 |
|
1147 mail = mail.replace(/./g, function (ch) { |
|
1148 if (ch === '@') { |
|
1149 // this *must* be encoded. I insist. |
|
1150 ch = encode[Math.floor(Math.random() * 2)](ch); |
|
1151 } else { |
|
1152 var r = Math.random(); |
|
1153 // roughly 10% raw, 45% hex, 45% dec |
|
1154 ch = ( |
|
1155 r > 0.9 ? encode[2](ch) : r > 0.45 ? encode[1](ch) : encode[0](ch) |
|
1156 ); |
|
1157 } |
|
1158 return ch; |
|
1159 }); |
|
1160 |
|
1161 return mail; |
|
1162 }; |
|
1163 |
|
1164 /** |
|
1165 * |
|
1166 * @param str |
|
1167 * @param targetLength |
|
1168 * @param padString |
|
1169 * @returns {string} |
|
1170 */ |
|
1171 showdown.helper.padEnd = function padEnd (str, targetLength, padString) { |
|
1172 'use strict'; |
|
1173 /*jshint bitwise: false*/ |
|
1174 // eslint-disable-next-line space-infix-ops |
|
1175 targetLength = targetLength>>0; //floor if number or convert non-number to 0; |
|
1176 /*jshint bitwise: true*/ |
|
1177 padString = String(padString || ' '); |
|
1178 if (str.length > targetLength) { |
|
1179 return String(str); |
|
1180 } else { |
|
1181 targetLength = targetLength - str.length; |
|
1182 if (targetLength > padString.length) { |
|
1183 padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed |
|
1184 } |
|
1185 return String(str) + padString.slice(0,targetLength); |
|
1186 } |
|
1187 }; |
|
1188 |
|
1189 /** |
|
1190 * POLYFILLS |
|
1191 */ |
|
1192 // use this instead of builtin is undefined for IE8 compatibility |
|
1193 if (typeof(console) === 'undefined') { |
|
1194 console = { |
|
1195 warn: function (msg) { |
|
1196 'use strict'; |
|
1197 alert(msg); |
|
1198 }, |
|
1199 log: function (msg) { |
|
1200 'use strict'; |
|
1201 alert(msg); |
|
1202 }, |
|
1203 error: function (msg) { |
|
1204 'use strict'; |
|
1205 throw msg; |
|
1206 } |
|
1207 }; |
|
1208 } |
|
1209 |
|
1210 /** |
|
1211 * Common regexes. |
|
1212 * We declare some common regexes to improve performance |
|
1213 */ |
|
1214 showdown.helper.regexes = { |
|
1215 asteriskDashAndColon: /([*_:~])/g |
|
1216 }; |
|
1217 |
|
1218 /** |
|
1219 * EMOJIS LIST |
|
1220 */ |
|
1221 showdown.helper.emojis = { |
|
1222 '+1':'\ud83d\udc4d', |
|
1223 '-1':'\ud83d\udc4e', |
|
1224 '100':'\ud83d\udcaf', |
|
1225 '1234':'\ud83d\udd22', |
|
1226 '1st_place_medal':'\ud83e\udd47', |
|
1227 '2nd_place_medal':'\ud83e\udd48', |
|
1228 '3rd_place_medal':'\ud83e\udd49', |
|
1229 '8ball':'\ud83c\udfb1', |
|
1230 'a':'\ud83c\udd70\ufe0f', |
|
1231 'ab':'\ud83c\udd8e', |
|
1232 'abc':'\ud83d\udd24', |
|
1233 'abcd':'\ud83d\udd21', |
|
1234 'accept':'\ud83c\ude51', |
|
1235 'aerial_tramway':'\ud83d\udea1', |
|
1236 'airplane':'\u2708\ufe0f', |
|
1237 'alarm_clock':'\u23f0', |
|
1238 'alembic':'\u2697\ufe0f', |
|
1239 'alien':'\ud83d\udc7d', |
|
1240 'ambulance':'\ud83d\ude91', |
|
1241 'amphora':'\ud83c\udffa', |
|
1242 'anchor':'\u2693\ufe0f', |
|
1243 'angel':'\ud83d\udc7c', |
|
1244 'anger':'\ud83d\udca2', |
|
1245 'angry':'\ud83d\ude20', |
|
1246 'anguished':'\ud83d\ude27', |
|
1247 'ant':'\ud83d\udc1c', |
|
1248 'apple':'\ud83c\udf4e', |
|
1249 'aquarius':'\u2652\ufe0f', |
|
1250 'aries':'\u2648\ufe0f', |
|
1251 'arrow_backward':'\u25c0\ufe0f', |
|
1252 'arrow_double_down':'\u23ec', |
|
1253 'arrow_double_up':'\u23eb', |
|
1254 'arrow_down':'\u2b07\ufe0f', |
|
1255 'arrow_down_small':'\ud83d\udd3d', |
|
1256 'arrow_forward':'\u25b6\ufe0f', |
|
1257 'arrow_heading_down':'\u2935\ufe0f', |
|
1258 'arrow_heading_up':'\u2934\ufe0f', |
|
1259 'arrow_left':'\u2b05\ufe0f', |
|
1260 'arrow_lower_left':'\u2199\ufe0f', |
|
1261 'arrow_lower_right':'\u2198\ufe0f', |
|
1262 'arrow_right':'\u27a1\ufe0f', |
|
1263 'arrow_right_hook':'\u21aa\ufe0f', |
|
1264 'arrow_up':'\u2b06\ufe0f', |
|
1265 'arrow_up_down':'\u2195\ufe0f', |
|
1266 'arrow_up_small':'\ud83d\udd3c', |
|
1267 'arrow_upper_left':'\u2196\ufe0f', |
|
1268 'arrow_upper_right':'\u2197\ufe0f', |
|
1269 'arrows_clockwise':'\ud83d\udd03', |
|
1270 'arrows_counterclockwise':'\ud83d\udd04', |
|
1271 'art':'\ud83c\udfa8', |
|
1272 'articulated_lorry':'\ud83d\ude9b', |
|
1273 'artificial_satellite':'\ud83d\udef0', |
|
1274 'astonished':'\ud83d\ude32', |
|
1275 'athletic_shoe':'\ud83d\udc5f', |
|
1276 'atm':'\ud83c\udfe7', |
|
1277 'atom_symbol':'\u269b\ufe0f', |
|
1278 'avocado':'\ud83e\udd51', |
|
1279 'b':'\ud83c\udd71\ufe0f', |
|
1280 'baby':'\ud83d\udc76', |
|
1281 'baby_bottle':'\ud83c\udf7c', |
|
1282 'baby_chick':'\ud83d\udc24', |
|
1283 'baby_symbol':'\ud83d\udebc', |
|
1284 'back':'\ud83d\udd19', |
|
1285 'bacon':'\ud83e\udd53', |
|
1286 'badminton':'\ud83c\udff8', |
|
1287 'baggage_claim':'\ud83d\udec4', |
|
1288 'baguette_bread':'\ud83e\udd56', |
|
1289 'balance_scale':'\u2696\ufe0f', |
|
1290 'balloon':'\ud83c\udf88', |
|
1291 'ballot_box':'\ud83d\uddf3', |
|
1292 'ballot_box_with_check':'\u2611\ufe0f', |
|
1293 'bamboo':'\ud83c\udf8d', |
|
1294 'banana':'\ud83c\udf4c', |
|
1295 'bangbang':'\u203c\ufe0f', |
|
1296 'bank':'\ud83c\udfe6', |
|
1297 'bar_chart':'\ud83d\udcca', |
|
1298 'barber':'\ud83d\udc88', |
|
1299 'baseball':'\u26be\ufe0f', |
|
1300 'basketball':'\ud83c\udfc0', |
|
1301 'basketball_man':'\u26f9\ufe0f', |
|
1302 'basketball_woman':'\u26f9\ufe0f‍\u2640\ufe0f', |
|
1303 'bat':'\ud83e\udd87', |
|
1304 'bath':'\ud83d\udec0', |
|
1305 'bathtub':'\ud83d\udec1', |
|
1306 'battery':'\ud83d\udd0b', |
|
1307 'beach_umbrella':'\ud83c\udfd6', |
|
1308 'bear':'\ud83d\udc3b', |
|
1309 'bed':'\ud83d\udecf', |
|
1310 'bee':'\ud83d\udc1d', |
|
1311 'beer':'\ud83c\udf7a', |
|
1312 'beers':'\ud83c\udf7b', |
|
1313 'beetle':'\ud83d\udc1e', |
|
1314 'beginner':'\ud83d\udd30', |
|
1315 'bell':'\ud83d\udd14', |
|
1316 'bellhop_bell':'\ud83d\udece', |
|
1317 'bento':'\ud83c\udf71', |
|
1318 'biking_man':'\ud83d\udeb4', |
|
1319 'bike':'\ud83d\udeb2', |
|
1320 'biking_woman':'\ud83d\udeb4‍\u2640\ufe0f', |
|
1321 'bikini':'\ud83d\udc59', |
|
1322 'biohazard':'\u2623\ufe0f', |
|
1323 'bird':'\ud83d\udc26', |
|
1324 'birthday':'\ud83c\udf82', |
|
1325 'black_circle':'\u26ab\ufe0f', |
|
1326 'black_flag':'\ud83c\udff4', |
|
1327 'black_heart':'\ud83d\udda4', |
|
1328 'black_joker':'\ud83c\udccf', |
|
1329 'black_large_square':'\u2b1b\ufe0f', |
|
1330 'black_medium_small_square':'\u25fe\ufe0f', |
|
1331 'black_medium_square':'\u25fc\ufe0f', |
|
1332 'black_nib':'\u2712\ufe0f', |
|
1333 'black_small_square':'\u25aa\ufe0f', |
|
1334 'black_square_button':'\ud83d\udd32', |
|
1335 'blonde_man':'\ud83d\udc71', |
|
1336 'blonde_woman':'\ud83d\udc71‍\u2640\ufe0f', |
|
1337 'blossom':'\ud83c\udf3c', |
|
1338 'blowfish':'\ud83d\udc21', |
|
1339 'blue_book':'\ud83d\udcd8', |
|
1340 'blue_car':'\ud83d\ude99', |
|
1341 'blue_heart':'\ud83d\udc99', |
|
1342 'blush':'\ud83d\ude0a', |
|
1343 'boar':'\ud83d\udc17', |
|
1344 'boat':'\u26f5\ufe0f', |
|
1345 'bomb':'\ud83d\udca3', |
|
1346 'book':'\ud83d\udcd6', |
|
1347 'bookmark':'\ud83d\udd16', |
|
1348 'bookmark_tabs':'\ud83d\udcd1', |
|
1349 'books':'\ud83d\udcda', |
|
1350 'boom':'\ud83d\udca5', |
|
1351 'boot':'\ud83d\udc62', |
|
1352 'bouquet':'\ud83d\udc90', |
|
1353 'bowing_man':'\ud83d\ude47', |
|
1354 'bow_and_arrow':'\ud83c\udff9', |
|
1355 'bowing_woman':'\ud83d\ude47‍\u2640\ufe0f', |
|
1356 'bowling':'\ud83c\udfb3', |
|
1357 'boxing_glove':'\ud83e\udd4a', |
|
1358 'boy':'\ud83d\udc66', |
|
1359 'bread':'\ud83c\udf5e', |
|
1360 'bride_with_veil':'\ud83d\udc70', |
|
1361 'bridge_at_night':'\ud83c\udf09', |
|
1362 'briefcase':'\ud83d\udcbc', |
|
1363 'broken_heart':'\ud83d\udc94', |
|
1364 'bug':'\ud83d\udc1b', |
|
1365 'building_construction':'\ud83c\udfd7', |
|
1366 'bulb':'\ud83d\udca1', |
|
1367 'bullettrain_front':'\ud83d\ude85', |
|
1368 'bullettrain_side':'\ud83d\ude84', |
|
1369 'burrito':'\ud83c\udf2f', |
|
1370 'bus':'\ud83d\ude8c', |
|
1371 'business_suit_levitating':'\ud83d\udd74', |
|
1372 'busstop':'\ud83d\ude8f', |
|
1373 'bust_in_silhouette':'\ud83d\udc64', |
|
1374 'busts_in_silhouette':'\ud83d\udc65', |
|
1375 'butterfly':'\ud83e\udd8b', |
|
1376 'cactus':'\ud83c\udf35', |
|
1377 'cake':'\ud83c\udf70', |
|
1378 'calendar':'\ud83d\udcc6', |
|
1379 'call_me_hand':'\ud83e\udd19', |
|
1380 'calling':'\ud83d\udcf2', |
|
1381 'camel':'\ud83d\udc2b', |
|
1382 'camera':'\ud83d\udcf7', |
|
1383 'camera_flash':'\ud83d\udcf8', |
|
1384 'camping':'\ud83c\udfd5', |
|
1385 'cancer':'\u264b\ufe0f', |
|
1386 'candle':'\ud83d\udd6f', |
|
1387 'candy':'\ud83c\udf6c', |
|
1388 'canoe':'\ud83d\udef6', |
|
1389 'capital_abcd':'\ud83d\udd20', |
|
1390 'capricorn':'\u2651\ufe0f', |
|
1391 'car':'\ud83d\ude97', |
|
1392 'card_file_box':'\ud83d\uddc3', |
|
1393 'card_index':'\ud83d\udcc7', |
|
1394 'card_index_dividers':'\ud83d\uddc2', |
|
1395 'carousel_horse':'\ud83c\udfa0', |
|
1396 'carrot':'\ud83e\udd55', |
|
1397 'cat':'\ud83d\udc31', |
|
1398 'cat2':'\ud83d\udc08', |
|
1399 'cd':'\ud83d\udcbf', |
|
1400 'chains':'\u26d3', |
|
1401 'champagne':'\ud83c\udf7e', |
|
1402 'chart':'\ud83d\udcb9', |
|
1403 'chart_with_downwards_trend':'\ud83d\udcc9', |
|
1404 'chart_with_upwards_trend':'\ud83d\udcc8', |
|
1405 'checkered_flag':'\ud83c\udfc1', |
|
1406 'cheese':'\ud83e\uddc0', |
|
1407 'cherries':'\ud83c\udf52', |
|
1408 'cherry_blossom':'\ud83c\udf38', |
|
1409 'chestnut':'\ud83c\udf30', |
|
1410 'chicken':'\ud83d\udc14', |
|
1411 'children_crossing':'\ud83d\udeb8', |
|
1412 'chipmunk':'\ud83d\udc3f', |
|
1413 'chocolate_bar':'\ud83c\udf6b', |
|
1414 'christmas_tree':'\ud83c\udf84', |
|
1415 'church':'\u26ea\ufe0f', |
|
1416 'cinema':'\ud83c\udfa6', |
|
1417 'circus_tent':'\ud83c\udfaa', |
|
1418 'city_sunrise':'\ud83c\udf07', |
|
1419 'city_sunset':'\ud83c\udf06', |
|
1420 'cityscape':'\ud83c\udfd9', |
|
1421 'cl':'\ud83c\udd91', |
|
1422 'clamp':'\ud83d\udddc', |
|
1423 'clap':'\ud83d\udc4f', |
|
1424 'clapper':'\ud83c\udfac', |
|
1425 'classical_building':'\ud83c\udfdb', |
|
1426 'clinking_glasses':'\ud83e\udd42', |
|
1427 'clipboard':'\ud83d\udccb', |
|
1428 'clock1':'\ud83d\udd50', |
|
1429 'clock10':'\ud83d\udd59', |
|
1430 'clock1030':'\ud83d\udd65', |
|
1431 'clock11':'\ud83d\udd5a', |
|
1432 'clock1130':'\ud83d\udd66', |
|
1433 'clock12':'\ud83d\udd5b', |
|
1434 'clock1230':'\ud83d\udd67', |
|
1435 'clock130':'\ud83d\udd5c', |
|
1436 'clock2':'\ud83d\udd51', |
|
1437 'clock230':'\ud83d\udd5d', |
|
1438 'clock3':'\ud83d\udd52', |
|
1439 'clock330':'\ud83d\udd5e', |
|
1440 'clock4':'\ud83d\udd53', |
|
1441 'clock430':'\ud83d\udd5f', |
|
1442 'clock5':'\ud83d\udd54', |
|
1443 'clock530':'\ud83d\udd60', |
|
1444 'clock6':'\ud83d\udd55', |
|
1445 'clock630':'\ud83d\udd61', |
|
1446 'clock7':'\ud83d\udd56', |
|
1447 'clock730':'\ud83d\udd62', |
|
1448 'clock8':'\ud83d\udd57', |
|
1449 'clock830':'\ud83d\udd63', |
|
1450 'clock9':'\ud83d\udd58', |
|
1451 'clock930':'\ud83d\udd64', |
|
1452 'closed_book':'\ud83d\udcd5', |
|
1453 'closed_lock_with_key':'\ud83d\udd10', |
|
1454 'closed_umbrella':'\ud83c\udf02', |
|
1455 'cloud':'\u2601\ufe0f', |
|
1456 'cloud_with_lightning':'\ud83c\udf29', |
|
1457 'cloud_with_lightning_and_rain':'\u26c8', |
|
1458 'cloud_with_rain':'\ud83c\udf27', |
|
1459 'cloud_with_snow':'\ud83c\udf28', |
|
1460 'clown_face':'\ud83e\udd21', |
|
1461 'clubs':'\u2663\ufe0f', |
|
1462 'cocktail':'\ud83c\udf78', |
|
1463 'coffee':'\u2615\ufe0f', |
|
1464 'coffin':'\u26b0\ufe0f', |
|
1465 'cold_sweat':'\ud83d\ude30', |
|
1466 'comet':'\u2604\ufe0f', |
|
1467 'computer':'\ud83d\udcbb', |
|
1468 'computer_mouse':'\ud83d\uddb1', |
|
1469 'confetti_ball':'\ud83c\udf8a', |
|
1470 'confounded':'\ud83d\ude16', |
|
1471 'confused':'\ud83d\ude15', |
|
1472 'congratulations':'\u3297\ufe0f', |
|
1473 'construction':'\ud83d\udea7', |
|
1474 'construction_worker_man':'\ud83d\udc77', |
|
1475 'construction_worker_woman':'\ud83d\udc77‍\u2640\ufe0f', |
|
1476 'control_knobs':'\ud83c\udf9b', |
|
1477 'convenience_store':'\ud83c\udfea', |
|
1478 'cookie':'\ud83c\udf6a', |
|
1479 'cool':'\ud83c\udd92', |
|
1480 'policeman':'\ud83d\udc6e', |
|
1481 'copyright':'\u00a9\ufe0f', |
|
1482 'corn':'\ud83c\udf3d', |
|
1483 'couch_and_lamp':'\ud83d\udecb', |
|
1484 'couple':'\ud83d\udc6b', |
|
1485 'couple_with_heart_woman_man':'\ud83d\udc91', |
|
1486 'couple_with_heart_man_man':'\ud83d\udc68‍\u2764\ufe0f‍\ud83d\udc68', |
|
1487 'couple_with_heart_woman_woman':'\ud83d\udc69‍\u2764\ufe0f‍\ud83d\udc69', |
|
1488 'couplekiss_man_man':'\ud83d\udc68‍\u2764\ufe0f‍\ud83d\udc8b‍\ud83d\udc68', |
|
1489 'couplekiss_man_woman':'\ud83d\udc8f', |
|
1490 'couplekiss_woman_woman':'\ud83d\udc69‍\u2764\ufe0f‍\ud83d\udc8b‍\ud83d\udc69', |
|
1491 'cow':'\ud83d\udc2e', |
|
1492 'cow2':'\ud83d\udc04', |
|
1493 'cowboy_hat_face':'\ud83e\udd20', |
|
1494 'crab':'\ud83e\udd80', |
|
1495 'crayon':'\ud83d\udd8d', |
|
1496 'credit_card':'\ud83d\udcb3', |
|
1497 'crescent_moon':'\ud83c\udf19', |
|
1498 'cricket':'\ud83c\udfcf', |
|
1499 'crocodile':'\ud83d\udc0a', |
|
1500 'croissant':'\ud83e\udd50', |
|
1501 'crossed_fingers':'\ud83e\udd1e', |
|
1502 'crossed_flags':'\ud83c\udf8c', |
|
1503 'crossed_swords':'\u2694\ufe0f', |
|
1504 'crown':'\ud83d\udc51', |
|
1505 'cry':'\ud83d\ude22', |
|
1506 'crying_cat_face':'\ud83d\ude3f', |
|
1507 'crystal_ball':'\ud83d\udd2e', |
|
1508 'cucumber':'\ud83e\udd52', |
|
1509 'cupid':'\ud83d\udc98', |
|
1510 'curly_loop':'\u27b0', |
|
1511 'currency_exchange':'\ud83d\udcb1', |
|
1512 'curry':'\ud83c\udf5b', |
|
1513 'custard':'\ud83c\udf6e', |
|
1514 'customs':'\ud83d\udec3', |
|
1515 'cyclone':'\ud83c\udf00', |
|
1516 'dagger':'\ud83d\udde1', |
|
1517 'dancer':'\ud83d\udc83', |
|
1518 'dancing_women':'\ud83d\udc6f', |
|
1519 'dancing_men':'\ud83d\udc6f‍\u2642\ufe0f', |
|
1520 'dango':'\ud83c\udf61', |
|
1521 'dark_sunglasses':'\ud83d\udd76', |
|
1522 'dart':'\ud83c\udfaf', |
|
1523 'dash':'\ud83d\udca8', |
|
1524 'date':'\ud83d\udcc5', |
|
1525 'deciduous_tree':'\ud83c\udf33', |
|
1526 'deer':'\ud83e\udd8c', |
|
1527 'department_store':'\ud83c\udfec', |
|
1528 'derelict_house':'\ud83c\udfda', |
|
1529 'desert':'\ud83c\udfdc', |
|
1530 'desert_island':'\ud83c\udfdd', |
|
1531 'desktop_computer':'\ud83d\udda5', |
|
1532 'male_detective':'\ud83d\udd75\ufe0f', |
|
1533 'diamond_shape_with_a_dot_inside':'\ud83d\udca0', |
|
1534 'diamonds':'\u2666\ufe0f', |
|
1535 'disappointed':'\ud83d\ude1e', |
|
1536 'disappointed_relieved':'\ud83d\ude25', |
|
1537 'dizzy':'\ud83d\udcab', |
|
1538 'dizzy_face':'\ud83d\ude35', |
|
1539 'do_not_litter':'\ud83d\udeaf', |
|
1540 'dog':'\ud83d\udc36', |
|
1541 'dog2':'\ud83d\udc15', |
|
1542 'dollar':'\ud83d\udcb5', |
|
1543 'dolls':'\ud83c\udf8e', |
|
1544 'dolphin':'\ud83d\udc2c', |
|
1545 'door':'\ud83d\udeaa', |
|
1546 'doughnut':'\ud83c\udf69', |
|
1547 'dove':'\ud83d\udd4a', |
|
1548 'dragon':'\ud83d\udc09', |
|
1549 'dragon_face':'\ud83d\udc32', |
|
1550 'dress':'\ud83d\udc57', |
|
1551 'dromedary_camel':'\ud83d\udc2a', |
|
1552 'drooling_face':'\ud83e\udd24', |
|
1553 'droplet':'\ud83d\udca7', |
|
1554 'drum':'\ud83e\udd41', |
|
1555 'duck':'\ud83e\udd86', |
|
1556 'dvd':'\ud83d\udcc0', |
|
1557 'e-mail':'\ud83d\udce7', |
|
1558 'eagle':'\ud83e\udd85', |
|
1559 'ear':'\ud83d\udc42', |
|
1560 'ear_of_rice':'\ud83c\udf3e', |
|
1561 'earth_africa':'\ud83c\udf0d', |
|
1562 'earth_americas':'\ud83c\udf0e', |
|
1563 'earth_asia':'\ud83c\udf0f', |
|
1564 'egg':'\ud83e\udd5a', |
|
1565 'eggplant':'\ud83c\udf46', |
|
1566 'eight_pointed_black_star':'\u2734\ufe0f', |
|
1567 'eight_spoked_asterisk':'\u2733\ufe0f', |
|
1568 'electric_plug':'\ud83d\udd0c', |
|
1569 'elephant':'\ud83d\udc18', |
|
1570 'email':'\u2709\ufe0f', |
|
1571 'end':'\ud83d\udd1a', |
|
1572 'envelope_with_arrow':'\ud83d\udce9', |
|
1573 'euro':'\ud83d\udcb6', |
|
1574 'european_castle':'\ud83c\udff0', |
|
1575 'european_post_office':'\ud83c\udfe4', |
|
1576 'evergreen_tree':'\ud83c\udf32', |
|
1577 'exclamation':'\u2757\ufe0f', |
|
1578 'expressionless':'\ud83d\ude11', |
|
1579 'eye':'\ud83d\udc41', |
|
1580 'eye_speech_bubble':'\ud83d\udc41‍\ud83d\udde8', |
|
1581 'eyeglasses':'\ud83d\udc53', |
|
1582 'eyes':'\ud83d\udc40', |
|
1583 'face_with_head_bandage':'\ud83e\udd15', |
|
1584 'face_with_thermometer':'\ud83e\udd12', |
|
1585 'fist_oncoming':'\ud83d\udc4a', |
|
1586 'factory':'\ud83c\udfed', |
|
1587 'fallen_leaf':'\ud83c\udf42', |
|
1588 'family_man_woman_boy':'\ud83d\udc6a', |
|
1589 'family_man_boy':'\ud83d\udc68‍\ud83d\udc66', |
|
1590 'family_man_boy_boy':'\ud83d\udc68‍\ud83d\udc66‍\ud83d\udc66', |
|
1591 'family_man_girl':'\ud83d\udc68‍\ud83d\udc67', |
|
1592 'family_man_girl_boy':'\ud83d\udc68‍\ud83d\udc67‍\ud83d\udc66', |
|
1593 'family_man_girl_girl':'\ud83d\udc68‍\ud83d\udc67‍\ud83d\udc67', |
|
1594 'family_man_man_boy':'\ud83d\udc68‍\ud83d\udc68‍\ud83d\udc66', |
|
1595 'family_man_man_boy_boy':'\ud83d\udc68‍\ud83d\udc68‍\ud83d\udc66‍\ud83d\udc66', |
|
1596 'family_man_man_girl':'\ud83d\udc68‍\ud83d\udc68‍\ud83d\udc67', |
|
1597 'family_man_man_girl_boy':'\ud83d\udc68‍\ud83d\udc68‍\ud83d\udc67‍\ud83d\udc66', |
|
1598 'family_man_man_girl_girl':'\ud83d\udc68‍\ud83d\udc68‍\ud83d\udc67‍\ud83d\udc67', |
|
1599 'family_man_woman_boy_boy':'\ud83d\udc68‍\ud83d\udc69‍\ud83d\udc66‍\ud83d\udc66', |
|
1600 'family_man_woman_girl':'\ud83d\udc68‍\ud83d\udc69‍\ud83d\udc67', |
|
1601 'family_man_woman_girl_boy':'\ud83d\udc68‍\ud83d\udc69‍\ud83d\udc67‍\ud83d\udc66', |
|
1602 'family_man_woman_girl_girl':'\ud83d\udc68‍\ud83d\udc69‍\ud83d\udc67‍\ud83d\udc67', |
|
1603 'family_woman_boy':'\ud83d\udc69‍\ud83d\udc66', |
|
1604 'family_woman_boy_boy':'\ud83d\udc69‍\ud83d\udc66‍\ud83d\udc66', |
|
1605 'family_woman_girl':'\ud83d\udc69‍\ud83d\udc67', |
|
1606 'family_woman_girl_boy':'\ud83d\udc69‍\ud83d\udc67‍\ud83d\udc66', |
|
1607 'family_woman_girl_girl':'\ud83d\udc69‍\ud83d\udc67‍\ud83d\udc67', |
|
1608 'family_woman_woman_boy':'\ud83d\udc69‍\ud83d\udc69‍\ud83d\udc66', |
|
1609 'family_woman_woman_boy_boy':'\ud83d\udc69‍\ud83d\udc69‍\ud83d\udc66‍\ud83d\udc66', |
|
1610 'family_woman_woman_girl':'\ud83d\udc69‍\ud83d\udc69‍\ud83d\udc67', |
|
1611 'family_woman_woman_girl_boy':'\ud83d\udc69‍\ud83d\udc69‍\ud83d\udc67‍\ud83d\udc66', |
|
1612 'family_woman_woman_girl_girl':'\ud83d\udc69‍\ud83d\udc69‍\ud83d\udc67‍\ud83d\udc67', |
|
1613 'fast_forward':'\u23e9', |
|
1614 'fax':'\ud83d\udce0', |
|
1615 'fearful':'\ud83d\ude28', |
|
1616 'feet':'\ud83d\udc3e', |
|
1617 'female_detective':'\ud83d\udd75\ufe0f‍\u2640\ufe0f', |
|
1618 'ferris_wheel':'\ud83c\udfa1', |
|
1619 'ferry':'\u26f4', |
|
1620 'field_hockey':'\ud83c\udfd1', |
|
1621 'file_cabinet':'\ud83d\uddc4', |
|
1622 'file_folder':'\ud83d\udcc1', |
|
1623 'film_projector':'\ud83d\udcfd', |
|
1624 'film_strip':'\ud83c\udf9e', |
|
1625 'fire':'\ud83d\udd25', |
|
1626 'fire_engine':'\ud83d\ude92', |
|
1627 'fireworks':'\ud83c\udf86', |
|
1628 'first_quarter_moon':'\ud83c\udf13', |
|
1629 'first_quarter_moon_with_face':'\ud83c\udf1b', |
|
1630 'fish':'\ud83d\udc1f', |
|
1631 'fish_cake':'\ud83c\udf65', |
|
1632 'fishing_pole_and_fish':'\ud83c\udfa3', |
|
1633 'fist_raised':'\u270a', |
|
1634 'fist_left':'\ud83e\udd1b', |
|
1635 'fist_right':'\ud83e\udd1c', |
|
1636 'flags':'\ud83c\udf8f', |
|
1637 'flashlight':'\ud83d\udd26', |
|
1638 'fleur_de_lis':'\u269c\ufe0f', |
|
1639 'flight_arrival':'\ud83d\udeec', |
|
1640 'flight_departure':'\ud83d\udeeb', |
|
1641 'floppy_disk':'\ud83d\udcbe', |
|
1642 'flower_playing_cards':'\ud83c\udfb4', |
|
1643 'flushed':'\ud83d\ude33', |
|
1644 'fog':'\ud83c\udf2b', |
|
1645 'foggy':'\ud83c\udf01', |
|
1646 'football':'\ud83c\udfc8', |
|
1647 'footprints':'\ud83d\udc63', |
|
1648 'fork_and_knife':'\ud83c\udf74', |
|
1649 'fountain':'\u26f2\ufe0f', |
|
1650 'fountain_pen':'\ud83d\udd8b', |
|
1651 'four_leaf_clover':'\ud83c\udf40', |
|
1652 'fox_face':'\ud83e\udd8a', |
|
1653 'framed_picture':'\ud83d\uddbc', |
|
1654 'free':'\ud83c\udd93', |
|
1655 'fried_egg':'\ud83c\udf73', |
|
1656 'fried_shrimp':'\ud83c\udf64', |
|
1657 'fries':'\ud83c\udf5f', |
|
1658 'frog':'\ud83d\udc38', |
|
1659 'frowning':'\ud83d\ude26', |
|
1660 'frowning_face':'\u2639\ufe0f', |
|
1661 'frowning_man':'\ud83d\ude4d‍\u2642\ufe0f', |
|
1662 'frowning_woman':'\ud83d\ude4d', |
|
1663 'middle_finger':'\ud83d\udd95', |
|
1664 'fuelpump':'\u26fd\ufe0f', |
|
1665 'full_moon':'\ud83c\udf15', |
|
1666 'full_moon_with_face':'\ud83c\udf1d', |
|
1667 'funeral_urn':'\u26b1\ufe0f', |
|
1668 'game_die':'\ud83c\udfb2', |
|
1669 'gear':'\u2699\ufe0f', |
|
1670 'gem':'\ud83d\udc8e', |
|
1671 'gemini':'\u264a\ufe0f', |
|
1672 'ghost':'\ud83d\udc7b', |
|
1673 'gift':'\ud83c\udf81', |
|
1674 'gift_heart':'\ud83d\udc9d', |
|
1675 'girl':'\ud83d\udc67', |
|
1676 'globe_with_meridians':'\ud83c\udf10', |
|
1677 'goal_net':'\ud83e\udd45', |
|
1678 'goat':'\ud83d\udc10', |
|
1679 'golf':'\u26f3\ufe0f', |
|
1680 'golfing_man':'\ud83c\udfcc\ufe0f', |
|
1681 'golfing_woman':'\ud83c\udfcc\ufe0f‍\u2640\ufe0f', |
|
1682 'gorilla':'\ud83e\udd8d', |
|
1683 'grapes':'\ud83c\udf47', |
|
1684 'green_apple':'\ud83c\udf4f', |
|
1685 'green_book':'\ud83d\udcd7', |
|
1686 'green_heart':'\ud83d\udc9a', |
|
1687 'green_salad':'\ud83e\udd57', |
|
1688 'grey_exclamation':'\u2755', |
|
1689 'grey_question':'\u2754', |
|
1690 'grimacing':'\ud83d\ude2c', |
|
1691 'grin':'\ud83d\ude01', |
|
1692 'grinning':'\ud83d\ude00', |
|
1693 'guardsman':'\ud83d\udc82', |
|
1694 'guardswoman':'\ud83d\udc82‍\u2640\ufe0f', |
|
1695 'guitar':'\ud83c\udfb8', |
|
1696 'gun':'\ud83d\udd2b', |
|
1697 'haircut_woman':'\ud83d\udc87', |
|
1698 'haircut_man':'\ud83d\udc87‍\u2642\ufe0f', |
|
1699 'hamburger':'\ud83c\udf54', |
|
1700 'hammer':'\ud83d\udd28', |
|
1701 'hammer_and_pick':'\u2692', |
|
1702 'hammer_and_wrench':'\ud83d\udee0', |
|
1703 'hamster':'\ud83d\udc39', |
|
1704 'hand':'\u270b', |
|
1705 'handbag':'\ud83d\udc5c', |
|
1706 'handshake':'\ud83e\udd1d', |
|
1707 'hankey':'\ud83d\udca9', |
|
1708 'hatched_chick':'\ud83d\udc25', |
|
1709 'hatching_chick':'\ud83d\udc23', |
|
1710 'headphones':'\ud83c\udfa7', |
|
1711 'hear_no_evil':'\ud83d\ude49', |
|
1712 'heart':'\u2764\ufe0f', |
|
1713 'heart_decoration':'\ud83d\udc9f', |
|
1714 'heart_eyes':'\ud83d\ude0d', |
|
1715 'heart_eyes_cat':'\ud83d\ude3b', |
|
1716 'heartbeat':'\ud83d\udc93', |
|
1717 'heartpulse':'\ud83d\udc97', |
|
1718 'hearts':'\u2665\ufe0f', |
|
1719 'heavy_check_mark':'\u2714\ufe0f', |
|
1720 'heavy_division_sign':'\u2797', |
|
1721 'heavy_dollar_sign':'\ud83d\udcb2', |
|
1722 'heavy_heart_exclamation':'\u2763\ufe0f', |
|
1723 'heavy_minus_sign':'\u2796', |
|
1724 'heavy_multiplication_x':'\u2716\ufe0f', |
|
1725 'heavy_plus_sign':'\u2795', |
|
1726 'helicopter':'\ud83d\ude81', |
|
1727 'herb':'\ud83c\udf3f', |
|
1728 'hibiscus':'\ud83c\udf3a', |
|
1729 'high_brightness':'\ud83d\udd06', |
|
1730 'high_heel':'\ud83d\udc60', |
|
1731 'hocho':'\ud83d\udd2a', |
|
1732 'hole':'\ud83d\udd73', |
|
1733 'honey_pot':'\ud83c\udf6f', |
|
1734 'horse':'\ud83d\udc34', |
|
1735 'horse_racing':'\ud83c\udfc7', |
|
1736 'hospital':'\ud83c\udfe5', |
|
1737 'hot_pepper':'\ud83c\udf36', |
|
1738 'hotdog':'\ud83c\udf2d', |
|
1739 'hotel':'\ud83c\udfe8', |
|
1740 'hotsprings':'\u2668\ufe0f', |
|
1741 'hourglass':'\u231b\ufe0f', |
|
1742 'hourglass_flowing_sand':'\u23f3', |
|
1743 'house':'\ud83c\udfe0', |
|
1744 'house_with_garden':'\ud83c\udfe1', |
|
1745 'houses':'\ud83c\udfd8', |
|
1746 'hugs':'\ud83e\udd17', |
|
1747 'hushed':'\ud83d\ude2f', |
|
1748 'ice_cream':'\ud83c\udf68', |
|
1749 'ice_hockey':'\ud83c\udfd2', |
|
1750 'ice_skate':'\u26f8', |
|
1751 'icecream':'\ud83c\udf66', |
|
1752 'id':'\ud83c\udd94', |
|
1753 'ideograph_advantage':'\ud83c\ude50', |
|
1754 'imp':'\ud83d\udc7f', |
|
1755 'inbox_tray':'\ud83d\udce5', |
|
1756 'incoming_envelope':'\ud83d\udce8', |
|
1757 'tipping_hand_woman':'\ud83d\udc81', |
|
1758 'information_source':'\u2139\ufe0f', |
|
1759 'innocent':'\ud83d\ude07', |
|
1760 'interrobang':'\u2049\ufe0f', |
|
1761 'iphone':'\ud83d\udcf1', |
|
1762 'izakaya_lantern':'\ud83c\udfee', |
|
1763 'jack_o_lantern':'\ud83c\udf83', |
|
1764 'japan':'\ud83d\uddfe', |
|
1765 'japanese_castle':'\ud83c\udfef', |
|
1766 'japanese_goblin':'\ud83d\udc7a', |
|
1767 'japanese_ogre':'\ud83d\udc79', |
|
1768 'jeans':'\ud83d\udc56', |
|
1769 'joy':'\ud83d\ude02', |
|
1770 'joy_cat':'\ud83d\ude39', |
|
1771 'joystick':'\ud83d\udd79', |
|
1772 'kaaba':'\ud83d\udd4b', |
|
1773 'key':'\ud83d\udd11', |
|
1774 'keyboard':'\u2328\ufe0f', |
|
1775 'keycap_ten':'\ud83d\udd1f', |
|
1776 'kick_scooter':'\ud83d\udef4', |
|
1777 'kimono':'\ud83d\udc58', |
|
1778 'kiss':'\ud83d\udc8b', |
|
1779 'kissing':'\ud83d\ude17', |
|
1780 'kissing_cat':'\ud83d\ude3d', |
|
1781 'kissing_closed_eyes':'\ud83d\ude1a', |
|
1782 'kissing_heart':'\ud83d\ude18', |
|
1783 'kissing_smiling_eyes':'\ud83d\ude19', |
|
1784 'kiwi_fruit':'\ud83e\udd5d', |
|
1785 'koala':'\ud83d\udc28', |
|
1786 'koko':'\ud83c\ude01', |
|
1787 'label':'\ud83c\udff7', |
|
1788 'large_blue_circle':'\ud83d\udd35', |
|
1789 'large_blue_diamond':'\ud83d\udd37', |
|
1790 'large_orange_diamond':'\ud83d\udd36', |
|
1791 'last_quarter_moon':'\ud83c\udf17', |
|
1792 'last_quarter_moon_with_face':'\ud83c\udf1c', |
|
1793 'latin_cross':'\u271d\ufe0f', |
|
1794 'laughing':'\ud83d\ude06', |
|
1795 'leaves':'\ud83c\udf43', |
|
1796 'ledger':'\ud83d\udcd2', |
|
1797 'left_luggage':'\ud83d\udec5', |
|
1798 'left_right_arrow':'\u2194\ufe0f', |
|
1799 'leftwards_arrow_with_hook':'\u21a9\ufe0f', |
|
1800 'lemon':'\ud83c\udf4b', |
|
1801 'leo':'\u264c\ufe0f', |
|
1802 'leopard':'\ud83d\udc06', |
|
1803 'level_slider':'\ud83c\udf9a', |
|
1804 'libra':'\u264e\ufe0f', |
|
1805 'light_rail':'\ud83d\ude88', |
|
1806 'link':'\ud83d\udd17', |
|
1807 'lion':'\ud83e\udd81', |
|
1808 'lips':'\ud83d\udc44', |
|
1809 'lipstick':'\ud83d\udc84', |
|
1810 'lizard':'\ud83e\udd8e', |
|
1811 'lock':'\ud83d\udd12', |
|
1812 'lock_with_ink_pen':'\ud83d\udd0f', |
|
1813 'lollipop':'\ud83c\udf6d', |
|
1814 'loop':'\u27bf', |
|
1815 'loud_sound':'\ud83d\udd0a', |
|
1816 'loudspeaker':'\ud83d\udce2', |
|
1817 'love_hotel':'\ud83c\udfe9', |
|
1818 'love_letter':'\ud83d\udc8c', |
|
1819 'low_brightness':'\ud83d\udd05', |
|
1820 'lying_face':'\ud83e\udd25', |
|
1821 'm':'\u24c2\ufe0f', |
|
1822 'mag':'\ud83d\udd0d', |
|
1823 'mag_right':'\ud83d\udd0e', |
|
1824 'mahjong':'\ud83c\udc04\ufe0f', |
|
1825 'mailbox':'\ud83d\udceb', |
|
1826 'mailbox_closed':'\ud83d\udcea', |
|
1827 'mailbox_with_mail':'\ud83d\udcec', |
|
1828 'mailbox_with_no_mail':'\ud83d\udced', |
|
1829 'man':'\ud83d\udc68', |
|
1830 'man_artist':'\ud83d\udc68‍\ud83c\udfa8', |
|
1831 'man_astronaut':'\ud83d\udc68‍\ud83d\ude80', |
|
1832 'man_cartwheeling':'\ud83e\udd38‍\u2642\ufe0f', |
|
1833 'man_cook':'\ud83d\udc68‍\ud83c\udf73', |
|
1834 'man_dancing':'\ud83d\udd7a', |
|
1835 'man_facepalming':'\ud83e\udd26‍\u2642\ufe0f', |
|
1836 'man_factory_worker':'\ud83d\udc68‍\ud83c\udfed', |
|
1837 'man_farmer':'\ud83d\udc68‍\ud83c\udf3e', |
|
1838 'man_firefighter':'\ud83d\udc68‍\ud83d\ude92', |
|
1839 'man_health_worker':'\ud83d\udc68‍\u2695\ufe0f', |
|
1840 'man_in_tuxedo':'\ud83e\udd35', |
|
1841 'man_judge':'\ud83d\udc68‍\u2696\ufe0f', |
|
1842 'man_juggling':'\ud83e\udd39‍\u2642\ufe0f', |
|
1843 'man_mechanic':'\ud83d\udc68‍\ud83d\udd27', |
|
1844 'man_office_worker':'\ud83d\udc68‍\ud83d\udcbc', |
|
1845 'man_pilot':'\ud83d\udc68‍\u2708\ufe0f', |
|
1846 'man_playing_handball':'\ud83e\udd3e‍\u2642\ufe0f', |
|
1847 'man_playing_water_polo':'\ud83e\udd3d‍\u2642\ufe0f', |
|
1848 'man_scientist':'\ud83d\udc68‍\ud83d\udd2c', |
|
1849 'man_shrugging':'\ud83e\udd37‍\u2642\ufe0f', |
|
1850 'man_singer':'\ud83d\udc68‍\ud83c\udfa4', |
|
1851 'man_student':'\ud83d\udc68‍\ud83c\udf93', |
|
1852 'man_teacher':'\ud83d\udc68‍\ud83c\udfeb', |
|
1853 'man_technologist':'\ud83d\udc68‍\ud83d\udcbb', |
|
1854 'man_with_gua_pi_mao':'\ud83d\udc72', |
|
1855 'man_with_turban':'\ud83d\udc73', |
|
1856 'tangerine':'\ud83c\udf4a', |
|
1857 'mans_shoe':'\ud83d\udc5e', |
|
1858 'mantelpiece_clock':'\ud83d\udd70', |
|
1859 'maple_leaf':'\ud83c\udf41', |
|
1860 'martial_arts_uniform':'\ud83e\udd4b', |
|
1861 'mask':'\ud83d\ude37', |
|
1862 'massage_woman':'\ud83d\udc86', |
|
1863 'massage_man':'\ud83d\udc86‍\u2642\ufe0f', |
|
1864 'meat_on_bone':'\ud83c\udf56', |
|
1865 'medal_military':'\ud83c\udf96', |
|
1866 'medal_sports':'\ud83c\udfc5', |
|
1867 'mega':'\ud83d\udce3', |
|
1868 'melon':'\ud83c\udf48', |
|
1869 'memo':'\ud83d\udcdd', |
|
1870 'men_wrestling':'\ud83e\udd3c‍\u2642\ufe0f', |
|
1871 'menorah':'\ud83d\udd4e', |
|
1872 'mens':'\ud83d\udeb9', |
|
1873 'metal':'\ud83e\udd18', |
|
1874 'metro':'\ud83d\ude87', |
|
1875 'microphone':'\ud83c\udfa4', |
|
1876 'microscope':'\ud83d\udd2c', |
|
1877 'milk_glass':'\ud83e\udd5b', |
|
1878 'milky_way':'\ud83c\udf0c', |
|
1879 'minibus':'\ud83d\ude90', |
|
1880 'minidisc':'\ud83d\udcbd', |
|
1881 'mobile_phone_off':'\ud83d\udcf4', |
|
1882 'money_mouth_face':'\ud83e\udd11', |
|
1883 'money_with_wings':'\ud83d\udcb8', |
|
1884 'moneybag':'\ud83d\udcb0', |
|
1885 'monkey':'\ud83d\udc12', |
|
1886 'monkey_face':'\ud83d\udc35', |
|
1887 'monorail':'\ud83d\ude9d', |
|
1888 'moon':'\ud83c\udf14', |
|
1889 'mortar_board':'\ud83c\udf93', |
|
1890 'mosque':'\ud83d\udd4c', |
|
1891 'motor_boat':'\ud83d\udee5', |
|
1892 'motor_scooter':'\ud83d\udef5', |
|
1893 'motorcycle':'\ud83c\udfcd', |
|
1894 'motorway':'\ud83d\udee3', |
|
1895 'mount_fuji':'\ud83d\uddfb', |
|
1896 'mountain':'\u26f0', |
|
1897 'mountain_biking_man':'\ud83d\udeb5', |
|
1898 'mountain_biking_woman':'\ud83d\udeb5‍\u2640\ufe0f', |
|
1899 'mountain_cableway':'\ud83d\udea0', |
|
1900 'mountain_railway':'\ud83d\ude9e', |
|
1901 'mountain_snow':'\ud83c\udfd4', |
|
1902 'mouse':'\ud83d\udc2d', |
|
1903 'mouse2':'\ud83d\udc01', |
|
1904 'movie_camera':'\ud83c\udfa5', |
|
1905 'moyai':'\ud83d\uddff', |
|
1906 'mrs_claus':'\ud83e\udd36', |
|
1907 'muscle':'\ud83d\udcaa', |
|
1908 'mushroom':'\ud83c\udf44', |
|
1909 'musical_keyboard':'\ud83c\udfb9', |
|
1910 'musical_note':'\ud83c\udfb5', |
|
1911 'musical_score':'\ud83c\udfbc', |
|
1912 'mute':'\ud83d\udd07', |
|
1913 'nail_care':'\ud83d\udc85', |
|
1914 'name_badge':'\ud83d\udcdb', |
|
1915 'national_park':'\ud83c\udfde', |
|
1916 'nauseated_face':'\ud83e\udd22', |
|
1917 'necktie':'\ud83d\udc54', |
|
1918 'negative_squared_cross_mark':'\u274e', |
|
1919 'nerd_face':'\ud83e\udd13', |
|
1920 'neutral_face':'\ud83d\ude10', |
|
1921 'new':'\ud83c\udd95', |
|
1922 'new_moon':'\ud83c\udf11', |
|
1923 'new_moon_with_face':'\ud83c\udf1a', |
|
1924 'newspaper':'\ud83d\udcf0', |
|
1925 'newspaper_roll':'\ud83d\uddde', |
|
1926 'next_track_button':'\u23ed', |
|
1927 'ng':'\ud83c\udd96', |
|
1928 'no_good_man':'\ud83d\ude45‍\u2642\ufe0f', |
|
1929 'no_good_woman':'\ud83d\ude45', |
|
1930 'night_with_stars':'\ud83c\udf03', |
|
1931 'no_bell':'\ud83d\udd15', |
|
1932 'no_bicycles':'\ud83d\udeb3', |
|
1933 'no_entry':'\u26d4\ufe0f', |
|
1934 'no_entry_sign':'\ud83d\udeab', |
|
1935 'no_mobile_phones':'\ud83d\udcf5', |
|
1936 'no_mouth':'\ud83d\ude36', |
|
1937 'no_pedestrians':'\ud83d\udeb7', |
|
1938 'no_smoking':'\ud83d\udead', |
|
1939 'non-potable_water':'\ud83d\udeb1', |
|
1940 'nose':'\ud83d\udc43', |
|
1941 'notebook':'\ud83d\udcd3', |
|
1942 'notebook_with_decorative_cover':'\ud83d\udcd4', |
|
1943 'notes':'\ud83c\udfb6', |
|
1944 'nut_and_bolt':'\ud83d\udd29', |
|
1945 'o':'\u2b55\ufe0f', |
|
1946 'o2':'\ud83c\udd7e\ufe0f', |
|
1947 'ocean':'\ud83c\udf0a', |
|
1948 'octopus':'\ud83d\udc19', |
|
1949 'oden':'\ud83c\udf62', |
|
1950 'office':'\ud83c\udfe2', |
|
1951 'oil_drum':'\ud83d\udee2', |
|
1952 'ok':'\ud83c\udd97', |
|
1953 'ok_hand':'\ud83d\udc4c', |
|
1954 'ok_man':'\ud83d\ude46‍\u2642\ufe0f', |
|
1955 'ok_woman':'\ud83d\ude46', |
|
1956 'old_key':'\ud83d\udddd', |
|
1957 'older_man':'\ud83d\udc74', |
|
1958 'older_woman':'\ud83d\udc75', |
|
1959 'om':'\ud83d\udd49', |
|
1960 'on':'\ud83d\udd1b', |
|
1961 'oncoming_automobile':'\ud83d\ude98', |
|
1962 'oncoming_bus':'\ud83d\ude8d', |
|
1963 'oncoming_police_car':'\ud83d\ude94', |
|
1964 'oncoming_taxi':'\ud83d\ude96', |
|
1965 'open_file_folder':'\ud83d\udcc2', |
|
1966 'open_hands':'\ud83d\udc50', |
|
1967 'open_mouth':'\ud83d\ude2e', |
|
1968 'open_umbrella':'\u2602\ufe0f', |
|
1969 'ophiuchus':'\u26ce', |
|
1970 'orange_book':'\ud83d\udcd9', |
|
1971 'orthodox_cross':'\u2626\ufe0f', |
|
1972 'outbox_tray':'\ud83d\udce4', |
|
1973 'owl':'\ud83e\udd89', |
|
1974 'ox':'\ud83d\udc02', |
|
1975 'package':'\ud83d\udce6', |
|
1976 'page_facing_up':'\ud83d\udcc4', |
|
1977 'page_with_curl':'\ud83d\udcc3', |
|
1978 'pager':'\ud83d\udcdf', |
|
1979 'paintbrush':'\ud83d\udd8c', |
|
1980 'palm_tree':'\ud83c\udf34', |
|
1981 'pancakes':'\ud83e\udd5e', |
|
1982 'panda_face':'\ud83d\udc3c', |
|
1983 'paperclip':'\ud83d\udcce', |
|
1984 'paperclips':'\ud83d\udd87', |
|
1985 'parasol_on_ground':'\u26f1', |
|
1986 'parking':'\ud83c\udd7f\ufe0f', |
|
1987 'part_alternation_mark':'\u303d\ufe0f', |
|
1988 'partly_sunny':'\u26c5\ufe0f', |
|
1989 'passenger_ship':'\ud83d\udef3', |
|
1990 'passport_control':'\ud83d\udec2', |
|
1991 'pause_button':'\u23f8', |
|
1992 'peace_symbol':'\u262e\ufe0f', |
|
1993 'peach':'\ud83c\udf51', |
|
1994 'peanuts':'\ud83e\udd5c', |
|
1995 'pear':'\ud83c\udf50', |
|
1996 'pen':'\ud83d\udd8a', |
|
1997 'pencil2':'\u270f\ufe0f', |
|
1998 'penguin':'\ud83d\udc27', |
|
1999 'pensive':'\ud83d\ude14', |
|
2000 'performing_arts':'\ud83c\udfad', |
|
2001 'persevere':'\ud83d\ude23', |
|
2002 'person_fencing':'\ud83e\udd3a', |
|
2003 'pouting_woman':'\ud83d\ude4e', |
|
2004 'phone':'\u260e\ufe0f', |
|
2005 'pick':'\u26cf', |
|
2006 'pig':'\ud83d\udc37', |
|
2007 'pig2':'\ud83d\udc16', |
|
2008 'pig_nose':'\ud83d\udc3d', |
|
2009 'pill':'\ud83d\udc8a', |
|
2010 'pineapple':'\ud83c\udf4d', |
|
2011 'ping_pong':'\ud83c\udfd3', |
|
2012 'pisces':'\u2653\ufe0f', |
|
2013 'pizza':'\ud83c\udf55', |
|
2014 'place_of_worship':'\ud83d\uded0', |
|
2015 'plate_with_cutlery':'\ud83c\udf7d', |
|
2016 'play_or_pause_button':'\u23ef', |
|
2017 'point_down':'\ud83d\udc47', |
|
2018 'point_left':'\ud83d\udc48', |
|
2019 'point_right':'\ud83d\udc49', |
|
2020 'point_up':'\u261d\ufe0f', |
|
2021 'point_up_2':'\ud83d\udc46', |
|
2022 'police_car':'\ud83d\ude93', |
|
2023 'policewoman':'\ud83d\udc6e‍\u2640\ufe0f', |
|
2024 'poodle':'\ud83d\udc29', |
|
2025 'popcorn':'\ud83c\udf7f', |
|
2026 'post_office':'\ud83c\udfe3', |
|
2027 'postal_horn':'\ud83d\udcef', |
|
2028 'postbox':'\ud83d\udcee', |
|
2029 'potable_water':'\ud83d\udeb0', |
|
2030 'potato':'\ud83e\udd54', |
|
2031 'pouch':'\ud83d\udc5d', |
|
2032 'poultry_leg':'\ud83c\udf57', |
|
2033 'pound':'\ud83d\udcb7', |
|
2034 'rage':'\ud83d\ude21', |
|
2035 'pouting_cat':'\ud83d\ude3e', |
|
2036 'pouting_man':'\ud83d\ude4e‍\u2642\ufe0f', |
|
2037 'pray':'\ud83d\ude4f', |
|
2038 'prayer_beads':'\ud83d\udcff', |
|
2039 'pregnant_woman':'\ud83e\udd30', |
|
2040 'previous_track_button':'\u23ee', |
|
2041 'prince':'\ud83e\udd34', |
|
2042 'princess':'\ud83d\udc78', |
|
2043 'printer':'\ud83d\udda8', |
|
2044 'purple_heart':'\ud83d\udc9c', |
|
2045 'purse':'\ud83d\udc5b', |
|
2046 'pushpin':'\ud83d\udccc', |
|
2047 'put_litter_in_its_place':'\ud83d\udeae', |
|
2048 'question':'\u2753', |
|
2049 'rabbit':'\ud83d\udc30', |
|
2050 'rabbit2':'\ud83d\udc07', |
|
2051 'racehorse':'\ud83d\udc0e', |
|
2052 'racing_car':'\ud83c\udfce', |
|
2053 'radio':'\ud83d\udcfb', |
|
2054 'radio_button':'\ud83d\udd18', |
|
2055 'radioactive':'\u2622\ufe0f', |
|
2056 'railway_car':'\ud83d\ude83', |
|
2057 'railway_track':'\ud83d\udee4', |
|
2058 'rainbow':'\ud83c\udf08', |
|
2059 'rainbow_flag':'\ud83c\udff3\ufe0f‍\ud83c\udf08', |
|
2060 'raised_back_of_hand':'\ud83e\udd1a', |
|
2061 'raised_hand_with_fingers_splayed':'\ud83d\udd90', |
|
2062 'raised_hands':'\ud83d\ude4c', |
|
2063 'raising_hand_woman':'\ud83d\ude4b', |
|
2064 'raising_hand_man':'\ud83d\ude4b‍\u2642\ufe0f', |
|
2065 'ram':'\ud83d\udc0f', |
|
2066 'ramen':'\ud83c\udf5c', |
|
2067 'rat':'\ud83d\udc00', |
|
2068 'record_button':'\u23fa', |
|
2069 'recycle':'\u267b\ufe0f', |
|
2070 'red_circle':'\ud83d\udd34', |
|
2071 'registered':'\u00ae\ufe0f', |
|
2072 'relaxed':'\u263a\ufe0f', |
|
2073 'relieved':'\ud83d\ude0c', |
|
2074 'reminder_ribbon':'\ud83c\udf97', |
|
2075 'repeat':'\ud83d\udd01', |
|
2076 'repeat_one':'\ud83d\udd02', |
|
2077 'rescue_worker_helmet':'\u26d1', |
|
2078 'restroom':'\ud83d\udebb', |
|
2079 'revolving_hearts':'\ud83d\udc9e', |
|
2080 'rewind':'\u23ea', |
|
2081 'rhinoceros':'\ud83e\udd8f', |
|
2082 'ribbon':'\ud83c\udf80', |
|
2083 'rice':'\ud83c\udf5a', |
|
2084 'rice_ball':'\ud83c\udf59', |
|
2085 'rice_cracker':'\ud83c\udf58', |
|
2086 'rice_scene':'\ud83c\udf91', |
|
2087 'right_anger_bubble':'\ud83d\uddef', |
|
2088 'ring':'\ud83d\udc8d', |
|
2089 'robot':'\ud83e\udd16', |
|
2090 'rocket':'\ud83d\ude80', |
|
2091 'rofl':'\ud83e\udd23', |
|
2092 'roll_eyes':'\ud83d\ude44', |
|
2093 'roller_coaster':'\ud83c\udfa2', |
|
2094 'rooster':'\ud83d\udc13', |
|
2095 'rose':'\ud83c\udf39', |
|
2096 'rosette':'\ud83c\udff5', |
|
2097 'rotating_light':'\ud83d\udea8', |
|
2098 'round_pushpin':'\ud83d\udccd', |
|
2099 'rowing_man':'\ud83d\udea3', |
|
2100 'rowing_woman':'\ud83d\udea3‍\u2640\ufe0f', |
|
2101 'rugby_football':'\ud83c\udfc9', |
|
2102 'running_man':'\ud83c\udfc3', |
|
2103 'running_shirt_with_sash':'\ud83c\udfbd', |
|
2104 'running_woman':'\ud83c\udfc3‍\u2640\ufe0f', |
|
2105 'sa':'\ud83c\ude02\ufe0f', |
|
2106 'sagittarius':'\u2650\ufe0f', |
|
2107 'sake':'\ud83c\udf76', |
|
2108 'sandal':'\ud83d\udc61', |
|
2109 'santa':'\ud83c\udf85', |
|
2110 'satellite':'\ud83d\udce1', |
|
2111 'saxophone':'\ud83c\udfb7', |
|
2112 'school':'\ud83c\udfeb', |
|
2113 'school_satchel':'\ud83c\udf92', |
|
2114 'scissors':'\u2702\ufe0f', |
|
2115 'scorpion':'\ud83e\udd82', |
|
2116 'scorpius':'\u264f\ufe0f', |
|
2117 'scream':'\ud83d\ude31', |
|
2118 'scream_cat':'\ud83d\ude40', |
|
2119 'scroll':'\ud83d\udcdc', |
|
2120 'seat':'\ud83d\udcba', |
|
2121 'secret':'\u3299\ufe0f', |
|
2122 'see_no_evil':'\ud83d\ude48', |
|
2123 'seedling':'\ud83c\udf31', |
|
2124 'selfie':'\ud83e\udd33', |
|
2125 'shallow_pan_of_food':'\ud83e\udd58', |
|
2126 'shamrock':'\u2618\ufe0f', |
|
2127 'shark':'\ud83e\udd88', |
|
2128 'shaved_ice':'\ud83c\udf67', |
|
2129 'sheep':'\ud83d\udc11', |
|
2130 'shell':'\ud83d\udc1a', |
|
2131 'shield':'\ud83d\udee1', |
|
2132 'shinto_shrine':'\u26e9', |
|
2133 'ship':'\ud83d\udea2', |
|
2134 'shirt':'\ud83d\udc55', |
|
2135 'shopping':'\ud83d\udecd', |
|
2136 'shopping_cart':'\ud83d\uded2', |
|
2137 'shower':'\ud83d\udebf', |
|
2138 'shrimp':'\ud83e\udd90', |
|
2139 'signal_strength':'\ud83d\udcf6', |
|
2140 'six_pointed_star':'\ud83d\udd2f', |
|
2141 'ski':'\ud83c\udfbf', |
|
2142 'skier':'\u26f7', |
|
2143 'skull':'\ud83d\udc80', |
|
2144 'skull_and_crossbones':'\u2620\ufe0f', |
|
2145 'sleeping':'\ud83d\ude34', |
|
2146 'sleeping_bed':'\ud83d\udecc', |
|
2147 'sleepy':'\ud83d\ude2a', |
|
2148 'slightly_frowning_face':'\ud83d\ude41', |
|
2149 'slightly_smiling_face':'\ud83d\ude42', |
|
2150 'slot_machine':'\ud83c\udfb0', |
|
2151 'small_airplane':'\ud83d\udee9', |
|
2152 'small_blue_diamond':'\ud83d\udd39', |
|
2153 'small_orange_diamond':'\ud83d\udd38', |
|
2154 'small_red_triangle':'\ud83d\udd3a', |
|
2155 'small_red_triangle_down':'\ud83d\udd3b', |
|
2156 'smile':'\ud83d\ude04', |
|
2157 'smile_cat':'\ud83d\ude38', |
|
2158 'smiley':'\ud83d\ude03', |
|
2159 'smiley_cat':'\ud83d\ude3a', |
|
2160 'smiling_imp':'\ud83d\ude08', |
|
2161 'smirk':'\ud83d\ude0f', |
|
2162 'smirk_cat':'\ud83d\ude3c', |
|
2163 'smoking':'\ud83d\udeac', |
|
2164 'snail':'\ud83d\udc0c', |
|
2165 'snake':'\ud83d\udc0d', |
|
2166 'sneezing_face':'\ud83e\udd27', |
|
2167 'snowboarder':'\ud83c\udfc2', |
|
2168 'snowflake':'\u2744\ufe0f', |
|
2169 'snowman':'\u26c4\ufe0f', |
|
2170 'snowman_with_snow':'\u2603\ufe0f', |
|
2171 'sob':'\ud83d\ude2d', |
|
2172 'soccer':'\u26bd\ufe0f', |
|
2173 'soon':'\ud83d\udd1c', |
|
2174 'sos':'\ud83c\udd98', |
|
2175 'sound':'\ud83d\udd09', |
|
2176 'space_invader':'\ud83d\udc7e', |
|
2177 'spades':'\u2660\ufe0f', |
|
2178 'spaghetti':'\ud83c\udf5d', |
|
2179 'sparkle':'\u2747\ufe0f', |
|
2180 'sparkler':'\ud83c\udf87', |
|
2181 'sparkles':'\u2728', |
|
2182 'sparkling_heart':'\ud83d\udc96', |
|
2183 'speak_no_evil':'\ud83d\ude4a', |
|
2184 'speaker':'\ud83d\udd08', |
|
2185 'speaking_head':'\ud83d\udde3', |
|
2186 'speech_balloon':'\ud83d\udcac', |
|
2187 'speedboat':'\ud83d\udea4', |
|
2188 'spider':'\ud83d\udd77', |
|
2189 'spider_web':'\ud83d\udd78', |
|
2190 'spiral_calendar':'\ud83d\uddd3', |
|
2191 'spiral_notepad':'\ud83d\uddd2', |
|
2192 'spoon':'\ud83e\udd44', |
|
2193 'squid':'\ud83e\udd91', |
|
2194 'stadium':'\ud83c\udfdf', |
|
2195 'star':'\u2b50\ufe0f', |
|
2196 'star2':'\ud83c\udf1f', |
|
2197 'star_and_crescent':'\u262a\ufe0f', |
|
2198 'star_of_david':'\u2721\ufe0f', |
|
2199 'stars':'\ud83c\udf20', |
|
2200 'station':'\ud83d\ude89', |
|
2201 'statue_of_liberty':'\ud83d\uddfd', |
|
2202 'steam_locomotive':'\ud83d\ude82', |
|
2203 'stew':'\ud83c\udf72', |
|
2204 'stop_button':'\u23f9', |
|
2205 'stop_sign':'\ud83d\uded1', |
|
2206 'stopwatch':'\u23f1', |
|
2207 'straight_ruler':'\ud83d\udccf', |
|
2208 'strawberry':'\ud83c\udf53', |
|
2209 'stuck_out_tongue':'\ud83d\ude1b', |
|
2210 'stuck_out_tongue_closed_eyes':'\ud83d\ude1d', |
|
2211 'stuck_out_tongue_winking_eye':'\ud83d\ude1c', |
|
2212 'studio_microphone':'\ud83c\udf99', |
|
2213 'stuffed_flatbread':'\ud83e\udd59', |
|
2214 'sun_behind_large_cloud':'\ud83c\udf25', |
|
2215 'sun_behind_rain_cloud':'\ud83c\udf26', |
|
2216 'sun_behind_small_cloud':'\ud83c\udf24', |
|
2217 'sun_with_face':'\ud83c\udf1e', |
|
2218 'sunflower':'\ud83c\udf3b', |
|
2219 'sunglasses':'\ud83d\ude0e', |
|
2220 'sunny':'\u2600\ufe0f', |
|
2221 'sunrise':'\ud83c\udf05', |
|
2222 'sunrise_over_mountains':'\ud83c\udf04', |
|
2223 'surfing_man':'\ud83c\udfc4', |
|
2224 'surfing_woman':'\ud83c\udfc4‍\u2640\ufe0f', |
|
2225 'sushi':'\ud83c\udf63', |
|
2226 'suspension_railway':'\ud83d\ude9f', |
|
2227 'sweat':'\ud83d\ude13', |
|
2228 'sweat_drops':'\ud83d\udca6', |
|
2229 'sweat_smile':'\ud83d\ude05', |
|
2230 'sweet_potato':'\ud83c\udf60', |
|
2231 'swimming_man':'\ud83c\udfca', |
|
2232 'swimming_woman':'\ud83c\udfca‍\u2640\ufe0f', |
|
2233 'symbols':'\ud83d\udd23', |
|
2234 'synagogue':'\ud83d\udd4d', |
|
2235 'syringe':'\ud83d\udc89', |
|
2236 'taco':'\ud83c\udf2e', |
|
2237 'tada':'\ud83c\udf89', |
|
2238 'tanabata_tree':'\ud83c\udf8b', |
|
2239 'taurus':'\u2649\ufe0f', |
|
2240 'taxi':'\ud83d\ude95', |
|
2241 'tea':'\ud83c\udf75', |
|
2242 'telephone_receiver':'\ud83d\udcde', |
|
2243 'telescope':'\ud83d\udd2d', |
|
2244 'tennis':'\ud83c\udfbe', |
|
2245 'tent':'\u26fa\ufe0f', |
|
2246 'thermometer':'\ud83c\udf21', |
|
2247 'thinking':'\ud83e\udd14', |
|
2248 'thought_balloon':'\ud83d\udcad', |
|
2249 'ticket':'\ud83c\udfab', |
|
2250 'tickets':'\ud83c\udf9f', |
|
2251 'tiger':'\ud83d\udc2f', |
|
2252 'tiger2':'\ud83d\udc05', |
|
2253 'timer_clock':'\u23f2', |
|
2254 'tipping_hand_man':'\ud83d\udc81‍\u2642\ufe0f', |
|
2255 'tired_face':'\ud83d\ude2b', |
|
2256 'tm':'\u2122\ufe0f', |
|
2257 'toilet':'\ud83d\udebd', |
|
2258 'tokyo_tower':'\ud83d\uddfc', |
|
2259 'tomato':'\ud83c\udf45', |
|
2260 'tongue':'\ud83d\udc45', |
|
2261 'top':'\ud83d\udd1d', |
|
2262 'tophat':'\ud83c\udfa9', |
|
2263 'tornado':'\ud83c\udf2a', |
|
2264 'trackball':'\ud83d\uddb2', |
|
2265 'tractor':'\ud83d\ude9c', |
|
2266 'traffic_light':'\ud83d\udea5', |
|
2267 'train':'\ud83d\ude8b', |
|
2268 'train2':'\ud83d\ude86', |
|
2269 'tram':'\ud83d\ude8a', |
|
2270 'triangular_flag_on_post':'\ud83d\udea9', |
|
2271 'triangular_ruler':'\ud83d\udcd0', |
|
2272 'trident':'\ud83d\udd31', |
|
2273 'triumph':'\ud83d\ude24', |
|
2274 'trolleybus':'\ud83d\ude8e', |
|
2275 'trophy':'\ud83c\udfc6', |
|
2276 'tropical_drink':'\ud83c\udf79', |
|
2277 'tropical_fish':'\ud83d\udc20', |
|
2278 'truck':'\ud83d\ude9a', |
|
2279 'trumpet':'\ud83c\udfba', |
|
2280 'tulip':'\ud83c\udf37', |
|
2281 'tumbler_glass':'\ud83e\udd43', |
|
2282 'turkey':'\ud83e\udd83', |
|
2283 'turtle':'\ud83d\udc22', |
|
2284 'tv':'\ud83d\udcfa', |
|
2285 'twisted_rightwards_arrows':'\ud83d\udd00', |
|
2286 'two_hearts':'\ud83d\udc95', |
|
2287 'two_men_holding_hands':'\ud83d\udc6c', |
|
2288 'two_women_holding_hands':'\ud83d\udc6d', |
|
2289 'u5272':'\ud83c\ude39', |
|
2290 'u5408':'\ud83c\ude34', |
|
2291 'u55b6':'\ud83c\ude3a', |
|
2292 'u6307':'\ud83c\ude2f\ufe0f', |
|
2293 'u6708':'\ud83c\ude37\ufe0f', |
|
2294 'u6709':'\ud83c\ude36', |
|
2295 'u6e80':'\ud83c\ude35', |
|
2296 'u7121':'\ud83c\ude1a\ufe0f', |
|
2297 'u7533':'\ud83c\ude38', |
|
2298 'u7981':'\ud83c\ude32', |
|
2299 'u7a7a':'\ud83c\ude33', |
|
2300 'umbrella':'\u2614\ufe0f', |
|
2301 'unamused':'\ud83d\ude12', |
|
2302 'underage':'\ud83d\udd1e', |
|
2303 'unicorn':'\ud83e\udd84', |
|
2304 'unlock':'\ud83d\udd13', |
|
2305 'up':'\ud83c\udd99', |
|
2306 'upside_down_face':'\ud83d\ude43', |
|
2307 'v':'\u270c\ufe0f', |
|
2308 'vertical_traffic_light':'\ud83d\udea6', |
|
2309 'vhs':'\ud83d\udcfc', |
|
2310 'vibration_mode':'\ud83d\udcf3', |
|
2311 'video_camera':'\ud83d\udcf9', |
|
2312 'video_game':'\ud83c\udfae', |
|
2313 'violin':'\ud83c\udfbb', |
|
2314 'virgo':'\u264d\ufe0f', |
|
2315 'volcano':'\ud83c\udf0b', |
|
2316 'volleyball':'\ud83c\udfd0', |
|
2317 'vs':'\ud83c\udd9a', |
|
2318 'vulcan_salute':'\ud83d\udd96', |
|
2319 'walking_man':'\ud83d\udeb6', |
|
2320 'walking_woman':'\ud83d\udeb6‍\u2640\ufe0f', |
|
2321 'waning_crescent_moon':'\ud83c\udf18', |
|
2322 'waning_gibbous_moon':'\ud83c\udf16', |
|
2323 'warning':'\u26a0\ufe0f', |
|
2324 'wastebasket':'\ud83d\uddd1', |
|
2325 'watch':'\u231a\ufe0f', |
|
2326 'water_buffalo':'\ud83d\udc03', |
|
2327 'watermelon':'\ud83c\udf49', |
|
2328 'wave':'\ud83d\udc4b', |
|
2329 'wavy_dash':'\u3030\ufe0f', |
|
2330 'waxing_crescent_moon':'\ud83c\udf12', |
|
2331 'wc':'\ud83d\udebe', |
|
2332 'weary':'\ud83d\ude29', |
|
2333 'wedding':'\ud83d\udc92', |
|
2334 'weight_lifting_man':'\ud83c\udfcb\ufe0f', |
|
2335 'weight_lifting_woman':'\ud83c\udfcb\ufe0f‍\u2640\ufe0f', |
|
2336 'whale':'\ud83d\udc33', |
|
2337 'whale2':'\ud83d\udc0b', |
|
2338 'wheel_of_dharma':'\u2638\ufe0f', |
|
2339 'wheelchair':'\u267f\ufe0f', |
|
2340 'white_check_mark':'\u2705', |
|
2341 'white_circle':'\u26aa\ufe0f', |
|
2342 'white_flag':'\ud83c\udff3\ufe0f', |
|
2343 'white_flower':'\ud83d\udcae', |
|
2344 'white_large_square':'\u2b1c\ufe0f', |
|
2345 'white_medium_small_square':'\u25fd\ufe0f', |
|
2346 'white_medium_square':'\u25fb\ufe0f', |
|
2347 'white_small_square':'\u25ab\ufe0f', |
|
2348 'white_square_button':'\ud83d\udd33', |
|
2349 'wilted_flower':'\ud83e\udd40', |
|
2350 'wind_chime':'\ud83c\udf90', |
|
2351 'wind_face':'\ud83c\udf2c', |
|
2352 'wine_glass':'\ud83c\udf77', |
|
2353 'wink':'\ud83d\ude09', |
|
2354 'wolf':'\ud83d\udc3a', |
|
2355 'woman':'\ud83d\udc69', |
|
2356 'woman_artist':'\ud83d\udc69‍\ud83c\udfa8', |
|
2357 'woman_astronaut':'\ud83d\udc69‍\ud83d\ude80', |
|
2358 'woman_cartwheeling':'\ud83e\udd38‍\u2640\ufe0f', |
|
2359 'woman_cook':'\ud83d\udc69‍\ud83c\udf73', |
|
2360 'woman_facepalming':'\ud83e\udd26‍\u2640\ufe0f', |
|
2361 'woman_factory_worker':'\ud83d\udc69‍\ud83c\udfed', |
|
2362 'woman_farmer':'\ud83d\udc69‍\ud83c\udf3e', |
|
2363 'woman_firefighter':'\ud83d\udc69‍\ud83d\ude92', |
|
2364 'woman_health_worker':'\ud83d\udc69‍\u2695\ufe0f', |
|
2365 'woman_judge':'\ud83d\udc69‍\u2696\ufe0f', |
|
2366 'woman_juggling':'\ud83e\udd39‍\u2640\ufe0f', |
|
2367 'woman_mechanic':'\ud83d\udc69‍\ud83d\udd27', |
|
2368 'woman_office_worker':'\ud83d\udc69‍\ud83d\udcbc', |
|
2369 'woman_pilot':'\ud83d\udc69‍\u2708\ufe0f', |
|
2370 'woman_playing_handball':'\ud83e\udd3e‍\u2640\ufe0f', |
|
2371 'woman_playing_water_polo':'\ud83e\udd3d‍\u2640\ufe0f', |
|
2372 'woman_scientist':'\ud83d\udc69‍\ud83d\udd2c', |
|
2373 'woman_shrugging':'\ud83e\udd37‍\u2640\ufe0f', |
|
2374 'woman_singer':'\ud83d\udc69‍\ud83c\udfa4', |
|
2375 'woman_student':'\ud83d\udc69‍\ud83c\udf93', |
|
2376 'woman_teacher':'\ud83d\udc69‍\ud83c\udfeb', |
|
2377 'woman_technologist':'\ud83d\udc69‍\ud83d\udcbb', |
|
2378 'woman_with_turban':'\ud83d\udc73‍\u2640\ufe0f', |
|
2379 'womans_clothes':'\ud83d\udc5a', |
|
2380 'womans_hat':'\ud83d\udc52', |
|
2381 'women_wrestling':'\ud83e\udd3c‍\u2640\ufe0f', |
|
2382 'womens':'\ud83d\udeba', |
|
2383 'world_map':'\ud83d\uddfa', |
|
2384 'worried':'\ud83d\ude1f', |
|
2385 'wrench':'\ud83d\udd27', |
|
2386 'writing_hand':'\u270d\ufe0f', |
|
2387 'x':'\u274c', |
|
2388 'yellow_heart':'\ud83d\udc9b', |
|
2389 'yen':'\ud83d\udcb4', |
|
2390 'yin_yang':'\u262f\ufe0f', |
|
2391 'yum':'\ud83d\ude0b', |
|
2392 'zap':'\u26a1\ufe0f', |
|
2393 'zipper_mouth_face':'\ud83e\udd10', |
|
2394 'zzz':'\ud83d\udca4', |
|
2395 |
|
2396 /* special emojis :P */ |
|
2397 'octocat': '<img alt=":octocat:" height="20" width="20" align="absmiddle" src="https://assets-cdn.github.com/images/icons/emoji/octocat.png">', |
|
2398 'showdown': '<span style="font-family: \'Anonymous Pro\', monospace; text-decoration: underline; text-decoration-style: dashed; text-decoration-color: #3e8b8a;text-underline-position: under;">S</span>' |
|
2399 }; |
|
2400 |
|
2401 /** |
|
2402 * Created by Estevao on 31-05-2015. |
|
2403 */ |
|
2404 |
|
2405 /** |
|
2406 * Showdown Converter class |
|
2407 * @class |
|
2408 * @param {object} [converterOptions] |
|
2409 * @returns {Converter} |
|
2410 */ |
|
2411 showdown.Converter = function (converterOptions) { |
|
2412 'use strict'; |
|
2413 |
|
2414 var |
|
2415 /** |
|
2416 * Options used by this converter |
|
2417 * @private |
|
2418 * @type {{}} |
|
2419 */ |
|
2420 options = {}, |
|
2421 |
|
2422 /** |
|
2423 * Language extensions used by this converter |
|
2424 * @private |
|
2425 * @type {Array} |
|
2426 */ |
|
2427 langExtensions = [], |
|
2428 |
|
2429 /** |
|
2430 * Output modifiers extensions used by this converter |
|
2431 * @private |
|
2432 * @type {Array} |
|
2433 */ |
|
2434 outputModifiers = [], |
|
2435 |
|
2436 /** |
|
2437 * Event listeners |
|
2438 * @private |
|
2439 * @type {{}} |
|
2440 */ |
|
2441 listeners = {}, |
|
2442 |
|
2443 /** |
|
2444 * The flavor set in this converter |
|
2445 */ |
|
2446 setConvFlavor = setFlavor, |
|
2447 |
|
2448 /** |
|
2449 * Metadata of the document |
|
2450 * @type {{parsed: {}, raw: string, format: string}} |
|
2451 */ |
|
2452 metadata = { |
|
2453 parsed: {}, |
|
2454 raw: '', |
|
2455 format: '' |
|
2456 }; |
|
2457 |
|
2458 _constructor(); |
|
2459 |
|
2460 /** |
|
2461 * Converter constructor |
|
2462 * @private |
|
2463 */ |
|
2464 function _constructor () { |
|
2465 converterOptions = converterOptions || {}; |
|
2466 |
|
2467 for (var gOpt in globalOptions) { |
|
2468 if (globalOptions.hasOwnProperty(gOpt)) { |
|
2469 options[gOpt] = globalOptions[gOpt]; |
|
2470 } |
|
2471 } |
|
2472 |
|
2473 // Merge options |
|
2474 if (typeof converterOptions === 'object') { |
|
2475 for (var opt in converterOptions) { |
|
2476 if (converterOptions.hasOwnProperty(opt)) { |
|
2477 options[opt] = converterOptions[opt]; |
|
2478 } |
|
2479 } |
|
2480 } else { |
|
2481 throw Error('Converter expects the passed parameter to be an object, but ' + typeof converterOptions + |
|
2482 ' was passed instead.'); |
|
2483 } |
|
2484 |
|
2485 if (options.extensions) { |
|
2486 showdown.helper.forEach(options.extensions, _parseExtension); |
|
2487 } |
|
2488 } |
|
2489 |
|
2490 /** |
|
2491 * Parse extension |
|
2492 * @param {*} ext |
|
2493 * @param {string} [name=''] |
|
2494 * @private |
|
2495 */ |
|
2496 function _parseExtension (ext, name) { |
|
2497 |
|
2498 name = name || null; |
|
2499 // If it's a string, the extension was previously loaded |
|
2500 if (showdown.helper.isString(ext)) { |
|
2501 ext = showdown.helper.stdExtName(ext); |
|
2502 name = ext; |
|
2503 |
|
2504 // LEGACY_SUPPORT CODE |
|
2505 if (showdown.extensions[ext]) { |
|
2506 console.warn('DEPRECATION WARNING: ' + ext + ' is an old extension that uses a deprecated loading method.' + |
|
2507 'Please inform the developer that the extension should be updated!'); |
|
2508 legacyExtensionLoading(showdown.extensions[ext], ext); |
|
2509 return; |
|
2510 // END LEGACY SUPPORT CODE |
|
2511 |
|
2512 } else if (!showdown.helper.isUndefined(extensions[ext])) { |
|
2513 ext = extensions[ext]; |
|
2514 |
|
2515 } else { |
|
2516 throw Error('Extension "' + ext + '" could not be loaded. It was either not found or is not a valid extension.'); |
|
2517 } |
|
2518 } |
|
2519 |
|
2520 if (typeof ext === 'function') { |
|
2521 ext = ext(); |
|
2522 } |
|
2523 |
|
2524 if (!showdown.helper.isArray(ext)) { |
|
2525 ext = [ext]; |
|
2526 } |
|
2527 |
|
2528 var validExt = validate(ext, name); |
|
2529 if (!validExt.valid) { |
|
2530 throw Error(validExt.error); |
|
2531 } |
|
2532 |
|
2533 for (var i = 0; i < ext.length; ++i) { |
|
2534 switch (ext[i].type) { |
|
2535 |
|
2536 case 'lang': |
|
2537 langExtensions.push(ext[i]); |
|
2538 break; |
|
2539 |
|
2540 case 'output': |
|
2541 outputModifiers.push(ext[i]); |
|
2542 break; |
|
2543 } |
|
2544 if (ext[i].hasOwnProperty('listeners')) { |
|
2545 for (var ln in ext[i].listeners) { |
|
2546 if (ext[i].listeners.hasOwnProperty(ln)) { |
|
2547 listen(ln, ext[i].listeners[ln]); |
|
2548 } |
|
2549 } |
|
2550 } |
|
2551 } |
|
2552 |
|
2553 } |
|
2554 |
|
2555 /** |
|
2556 * LEGACY_SUPPORT |
|
2557 * @param {*} ext |
|
2558 * @param {string} name |
|
2559 */ |
|
2560 function legacyExtensionLoading (ext, name) { |
|
2561 if (typeof ext === 'function') { |
|
2562 ext = ext(new showdown.Converter()); |
|
2563 } |
|
2564 if (!showdown.helper.isArray(ext)) { |
|
2565 ext = [ext]; |
|
2566 } |
|
2567 var valid = validate(ext, name); |
|
2568 |
|
2569 if (!valid.valid) { |
|
2570 throw Error(valid.error); |
|
2571 } |
|
2572 |
|
2573 for (var i = 0; i < ext.length; ++i) { |
|
2574 switch (ext[i].type) { |
|
2575 case 'lang': |
|
2576 langExtensions.push(ext[i]); |
|
2577 break; |
|
2578 case 'output': |
|
2579 outputModifiers.push(ext[i]); |
|
2580 break; |
|
2581 default:// should never reach here |
|
2582 throw Error('Extension loader error: Type unrecognized!!!'); |
|
2583 } |
|
2584 } |
|
2585 } |
|
2586 |
|
2587 /** |
|
2588 * Listen to an event |
|
2589 * @param {string} name |
|
2590 * @param {function} callback |
|
2591 */ |
|
2592 function listen (name, callback) { |
|
2593 if (!showdown.helper.isString(name)) { |
|
2594 throw Error('Invalid argument in converter.listen() method: name must be a string, but ' + typeof name + ' given'); |
|
2595 } |
|
2596 |
|
2597 if (typeof callback !== 'function') { |
|
2598 throw Error('Invalid argument in converter.listen() method: callback must be a function, but ' + typeof callback + ' given'); |
|
2599 } |
|
2600 |
|
2601 if (!listeners.hasOwnProperty(name)) { |
|
2602 listeners[name] = []; |
|
2603 } |
|
2604 listeners[name].push(callback); |
|
2605 } |
|
2606 |
|
2607 function rTrimInputText (text) { |
|
2608 var rsp = text.match(/^\s*/)[0].length, |
|
2609 rgx = new RegExp('^\\s{0,' + rsp + '}', 'gm'); |
|
2610 return text.replace(rgx, ''); |
|
2611 } |
|
2612 |
|
2613 /** |
|
2614 * Dispatch an event |
|
2615 * @private |
|
2616 * @param {string} evtName Event name |
|
2617 * @param {string} text Text |
|
2618 * @param {{}} options Converter Options |
|
2619 * @param {{}} globals |
|
2620 * @returns {string} |
|
2621 */ |
|
2622 this._dispatch = function dispatch (evtName, text, options, globals) { |
|
2623 if (listeners.hasOwnProperty(evtName)) { |
|
2624 for (var ei = 0; ei < listeners[evtName].length; ++ei) { |
|
2625 var nText = listeners[evtName][ei](evtName, text, this, options, globals); |
|
2626 if (nText && typeof nText !== 'undefined') { |
|
2627 text = nText; |
|
2628 } |
|
2629 } |
|
2630 } |
|
2631 return text; |
|
2632 }; |
|
2633 |
|
2634 /** |
|
2635 * Listen to an event |
|
2636 * @param {string} name |
|
2637 * @param {function} callback |
|
2638 * @returns {showdown.Converter} |
|
2639 */ |
|
2640 this.listen = function (name, callback) { |
|
2641 listen(name, callback); |
|
2642 return this; |
|
2643 }; |
|
2644 |
|
2645 /** |
|
2646 * Converts a markdown string into HTML |
|
2647 * @param {string} text |
|
2648 * @returns {*} |
|
2649 */ |
|
2650 this.makeHtml = function (text) { |
|
2651 //check if text is not falsy |
|
2652 if (!text) { |
|
2653 return text; |
|
2654 } |
|
2655 |
|
2656 var globals = { |
|
2657 gHtmlBlocks: [], |
|
2658 gHtmlMdBlocks: [], |
|
2659 gHtmlSpans: [], |
|
2660 gUrls: {}, |
|
2661 gTitles: {}, |
|
2662 gDimensions: {}, |
|
2663 gListLevel: 0, |
|
2664 hashLinkCounts: {}, |
|
2665 langExtensions: langExtensions, |
|
2666 outputModifiers: outputModifiers, |
|
2667 converter: this, |
|
2668 ghCodeBlocks: [], |
|
2669 metadata: { |
|
2670 parsed: {}, |
|
2671 raw: '', |
|
2672 format: '' |
|
2673 } |
|
2674 }; |
|
2675 |
|
2676 // This lets us use ¨ trema as an escape char to avoid md5 hashes |
|
2677 // The choice of character is arbitrary; anything that isn't |
|
2678 // magic in Markdown will work. |
|
2679 text = text.replace(/¨/g, '¨T'); |
|
2680 |
|
2681 // Replace $ with ¨D |
|
2682 // RegExp interprets $ as a special character |
|
2683 // when it's in a replacement string |
|
2684 text = text.replace(/\$/g, '¨D'); |
|
2685 |
|
2686 // Standardize line endings |
|
2687 text = text.replace(/\r\n/g, '\n'); // DOS to Unix |
|
2688 text = text.replace(/\r/g, '\n'); // Mac to Unix |
|
2689 |
|
2690 // Stardardize line spaces |
|
2691 text = text.replace(/\u00A0/g, ' '); |
|
2692 |
|
2693 if (options.smartIndentationFix) { |
|
2694 text = rTrimInputText(text); |
|
2695 } |
|
2696 |
|
2697 // Make sure text begins and ends with a couple of newlines: |
|
2698 text = '\n\n' + text + '\n\n'; |
|
2699 |
|
2700 // detab |
|
2701 text = showdown.subParser('detab')(text, options, globals); |
|
2702 |
|
2703 /** |
|
2704 * Strip any lines consisting only of spaces and tabs. |
|
2705 * This makes subsequent regexs easier to write, because we can |
|
2706 * match consecutive blank lines with /\n+/ instead of something |
|
2707 * contorted like /[ \t]*\n+/ |
|
2708 */ |
|
2709 text = text.replace(/^[ \t]+$/mg, ''); |
|
2710 |
|
2711 //run languageExtensions |
|
2712 showdown.helper.forEach(langExtensions, function (ext) { |
|
2713 text = showdown.subParser('runExtension')(ext, text, options, globals); |
|
2714 }); |
|
2715 |
|
2716 // run the sub parsers |
|
2717 text = showdown.subParser('metadata')(text, options, globals); |
|
2718 text = showdown.subParser('hashPreCodeTags')(text, options, globals); |
|
2719 text = showdown.subParser('githubCodeBlocks')(text, options, globals); |
|
2720 text = showdown.subParser('hashHTMLBlocks')(text, options, globals); |
|
2721 text = showdown.subParser('hashCodeTags')(text, options, globals); |
|
2722 text = showdown.subParser('stripLinkDefinitions')(text, options, globals); |
|
2723 text = showdown.subParser('blockGamut')(text, options, globals); |
|
2724 text = showdown.subParser('unhashHTMLSpans')(text, options, globals); |
|
2725 text = showdown.subParser('unescapeSpecialChars')(text, options, globals); |
|
2726 |
|
2727 // attacklab: Restore dollar signs |
|
2728 text = text.replace(/¨D/g, '$$'); |
|
2729 |
|
2730 // attacklab: Restore tremas |
|
2731 text = text.replace(/¨T/g, '¨'); |
|
2732 |
|
2733 // render a complete html document instead of a partial if the option is enabled |
|
2734 text = showdown.subParser('completeHTMLDocument')(text, options, globals); |
|
2735 |
|
2736 // Run output modifiers |
|
2737 showdown.helper.forEach(outputModifiers, function (ext) { |
|
2738 text = showdown.subParser('runExtension')(ext, text, options, globals); |
|
2739 }); |
|
2740 |
|
2741 // update metadata |
|
2742 metadata = globals.metadata; |
|
2743 return text; |
|
2744 }; |
|
2745 |
|
2746 /** |
|
2747 * Converts an HTML string into a markdown string |
|
2748 * @param src |
|
2749 * @param [HTMLParser] A WHATWG DOM and HTML parser, such as JSDOM. If none is supplied, window.document will be used. |
|
2750 * @returns {string} |
|
2751 */ |
|
2752 this.makeMarkdown = this.makeMd = function (src, HTMLParser) { |
|
2753 |
|
2754 // replace \r\n with \n |
|
2755 src = src.replace(/\r\n/g, '\n'); |
|
2756 src = src.replace(/\r/g, '\n'); // old macs |
|
2757 |
|
2758 // due to an edge case, we need to find this: > < |
|
2759 // to prevent removing of non silent white spaces |
|
2760 // ex: <em>this is</em> <strong>sparta</strong> |
|
2761 src = src.replace(/>[ \t]+</, '>¨NBSP;<'); |
|
2762 |
|
2763 if (!HTMLParser) { |
|
2764 if (window && window.document) { |
|
2765 HTMLParser = window.document; |
|
2766 } else { |
|
2767 throw new Error('HTMLParser is undefined. If in a webworker or nodejs environment, you need to provide a WHATWG DOM and HTML such as JSDOM'); |
|
2768 } |
|
2769 } |
|
2770 |
|
2771 var doc = HTMLParser.createElement('div'); |
|
2772 doc.innerHTML = src; |
|
2773 |
|
2774 var globals = { |
|
2775 preList: substitutePreCodeTags(doc) |
|
2776 }; |
|
2777 |
|
2778 // remove all newlines and collapse spaces |
|
2779 clean(doc); |
|
2780 |
|
2781 // some stuff, like accidental reference links must now be escaped |
|
2782 // TODO |
|
2783 // doc.innerHTML = doc.innerHTML.replace(/\[[\S\t ]]/); |
|
2784 |
|
2785 var nodes = doc.childNodes, |
|
2786 mdDoc = ''; |
|
2787 |
|
2788 for (var i = 0; i < nodes.length; i++) { |
|
2789 mdDoc += showdown.subParser('makeMarkdown.node')(nodes[i], globals); |
|
2790 } |
|
2791 |
|
2792 function clean (node) { |
|
2793 for (var n = 0; n < node.childNodes.length; ++n) { |
|
2794 var child = node.childNodes[n]; |
|
2795 if (child.nodeType === 3) { |
|
2796 if (!/\S/.test(child.nodeValue)) { |
|
2797 node.removeChild(child); |
|
2798 --n; |
|
2799 } else { |
|
2800 child.nodeValue = child.nodeValue.split('\n').join(' '); |
|
2801 child.nodeValue = child.nodeValue.replace(/(\s)+/g, '$1'); |
|
2802 } |
|
2803 } else if (child.nodeType === 1) { |
|
2804 clean(child); |
|
2805 } |
|
2806 } |
|
2807 } |
|
2808 |
|
2809 // find all pre tags and replace contents with placeholder |
|
2810 // we need this so that we can remove all indentation from html |
|
2811 // to ease up parsing |
|
2812 function substitutePreCodeTags (doc) { |
|
2813 |
|
2814 var pres = doc.querySelectorAll('pre'), |
|
2815 presPH = []; |
|
2816 |
|
2817 for (var i = 0; i < pres.length; ++i) { |
|
2818 |
|
2819 if (pres[i].childElementCount === 1 && pres[i].firstChild.tagName.toLowerCase() === 'code') { |
|
2820 var content = pres[i].firstChild.innerHTML.trim(), |
|
2821 language = pres[i].firstChild.getAttribute('data-language') || ''; |
|
2822 |
|
2823 // if data-language attribute is not defined, then we look for class language-* |
|
2824 if (language === '') { |
|
2825 var classes = pres[i].firstChild.className.split(' '); |
|
2826 for (var c = 0; c < classes.length; ++c) { |
|
2827 var matches = classes[c].match(/^language-(.+)$/); |
|
2828 if (matches !== null) { |
|
2829 language = matches[1]; |
|
2830 break; |
|
2831 } |
|
2832 } |
|
2833 } |
|
2834 |
|
2835 // unescape html entities in content |
|
2836 content = showdown.helper.unescapeHTMLEntities(content); |
|
2837 |
|
2838 presPH.push(content); |
|
2839 pres[i].outerHTML = '<precode language="' + language + '" precodenum="' + i.toString() + '"></precode>'; |
|
2840 } else { |
|
2841 presPH.push(pres[i].innerHTML); |
|
2842 pres[i].innerHTML = ''; |
|
2843 pres[i].setAttribute('prenum', i.toString()); |
|
2844 } |
|
2845 } |
|
2846 return presPH; |
|
2847 } |
|
2848 |
|
2849 return mdDoc; |
|
2850 }; |
|
2851 |
|
2852 /** |
|
2853 * Set an option of this Converter instance |
|
2854 * @param {string} key |
|
2855 * @param {*} value |
|
2856 */ |
|
2857 this.setOption = function (key, value) { |
|
2858 options[key] = value; |
|
2859 }; |
|
2860 |
|
2861 /** |
|
2862 * Get the option of this Converter instance |
|
2863 * @param {string} key |
|
2864 * @returns {*} |
|
2865 */ |
|
2866 this.getOption = function (key) { |
|
2867 return options[key]; |
|
2868 }; |
|
2869 |
|
2870 /** |
|
2871 * Get the options of this Converter instance |
|
2872 * @returns {{}} |
|
2873 */ |
|
2874 this.getOptions = function () { |
|
2875 return options; |
|
2876 }; |
|
2877 |
|
2878 /** |
|
2879 * Add extension to THIS converter |
|
2880 * @param {{}} extension |
|
2881 * @param {string} [name=null] |
|
2882 */ |
|
2883 this.addExtension = function (extension, name) { |
|
2884 name = name || null; |
|
2885 _parseExtension(extension, name); |
|
2886 }; |
|
2887 |
|
2888 /** |
|
2889 * Use a global registered extension with THIS converter |
|
2890 * @param {string} extensionName Name of the previously registered extension |
|
2891 */ |
|
2892 this.useExtension = function (extensionName) { |
|
2893 _parseExtension(extensionName); |
|
2894 }; |
|
2895 |
|
2896 /** |
|
2897 * Set the flavor THIS converter should use |
|
2898 * @param {string} name |
|
2899 */ |
|
2900 this.setFlavor = function (name) { |
|
2901 if (!flavor.hasOwnProperty(name)) { |
|
2902 throw Error(name + ' flavor was not found'); |
|
2903 } |
|
2904 var preset = flavor[name]; |
|
2905 setConvFlavor = name; |
|
2906 for (var option in preset) { |
|
2907 if (preset.hasOwnProperty(option)) { |
|
2908 options[option] = preset[option]; |
|
2909 } |
|
2910 } |
|
2911 }; |
|
2912 |
|
2913 /** |
|
2914 * Get the currently set flavor of this converter |
|
2915 * @returns {string} |
|
2916 */ |
|
2917 this.getFlavor = function () { |
|
2918 return setConvFlavor; |
|
2919 }; |
|
2920 |
|
2921 /** |
|
2922 * Remove an extension from THIS converter. |
|
2923 * Note: This is a costly operation. It's better to initialize a new converter |
|
2924 * and specify the extensions you wish to use |
|
2925 * @param {Array} extension |
|
2926 */ |
|
2927 this.removeExtension = function (extension) { |
|
2928 if (!showdown.helper.isArray(extension)) { |
|
2929 extension = [extension]; |
|
2930 } |
|
2931 for (var a = 0; a < extension.length; ++a) { |
|
2932 var ext = extension[a]; |
|
2933 for (var i = 0; i < langExtensions.length; ++i) { |
|
2934 if (langExtensions[i] === ext) { |
|
2935 langExtensions[i].splice(i, 1); |
|
2936 } |
|
2937 } |
|
2938 for (var ii = 0; ii < outputModifiers.length; ++i) { |
|
2939 if (outputModifiers[ii] === ext) { |
|
2940 outputModifiers[ii].splice(i, 1); |
|
2941 } |
|
2942 } |
|
2943 } |
|
2944 }; |
|
2945 |
|
2946 /** |
|
2947 * Get all extension of THIS converter |
|
2948 * @returns {{language: Array, output: Array}} |
|
2949 */ |
|
2950 this.getAllExtensions = function () { |
|
2951 return { |
|
2952 language: langExtensions, |
|
2953 output: outputModifiers |
|
2954 }; |
|
2955 }; |
|
2956 |
|
2957 /** |
|
2958 * Get the metadata of the previously parsed document |
|
2959 * @param raw |
|
2960 * @returns {string|{}} |
|
2961 */ |
|
2962 this.getMetadata = function (raw) { |
|
2963 if (raw) { |
|
2964 return metadata.raw; |
|
2965 } else { |
|
2966 return metadata.parsed; |
|
2967 } |
|
2968 }; |
|
2969 |
|
2970 /** |
|
2971 * Get the metadata format of the previously parsed document |
|
2972 * @returns {string} |
|
2973 */ |
|
2974 this.getMetadataFormat = function () { |
|
2975 return metadata.format; |
|
2976 }; |
|
2977 |
|
2978 /** |
|
2979 * Private: set a single key, value metadata pair |
|
2980 * @param {string} key |
|
2981 * @param {string} value |
|
2982 */ |
|
2983 this._setMetadataPair = function (key, value) { |
|
2984 metadata.parsed[key] = value; |
|
2985 }; |
|
2986 |
|
2987 /** |
|
2988 * Private: set metadata format |
|
2989 * @param {string} format |
|
2990 */ |
|
2991 this._setMetadataFormat = function (format) { |
|
2992 metadata.format = format; |
|
2993 }; |
|
2994 |
|
2995 /** |
|
2996 * Private: set metadata raw text |
|
2997 * @param {string} raw |
|
2998 */ |
|
2999 this._setMetadataRaw = function (raw) { |
|
3000 metadata.raw = raw; |
|
3001 }; |
|
3002 }; |
|
3003 |
|
3004 /** |
|
3005 * Turn Markdown link shortcuts into XHTML <a> tags. |
|
3006 */ |
|
3007 showdown.subParser('anchors', function (text, options, globals) { |
|
3008 'use strict'; |
|
3009 |
|
3010 text = globals.converter._dispatch('anchors.before', text, options, globals); |
|
3011 |
|
3012 var writeAnchorTag = function (wholeMatch, linkText, linkId, url, m5, m6, title) { |
|
3013 if (showdown.helper.isUndefined(title)) { |
|
3014 title = ''; |
|
3015 } |
|
3016 linkId = linkId.toLowerCase(); |
|
3017 |
|
3018 // Special case for explicit empty url |
|
3019 if (wholeMatch.search(/\(<?\s*>? ?(['"].*['"])?\)$/m) > -1) { |
|
3020 url = ''; |
|
3021 } else if (!url) { |
|
3022 if (!linkId) { |
|
3023 // lower-case and turn embedded newlines into spaces |
|
3024 linkId = linkText.toLowerCase().replace(/ ?\n/g, ' '); |
|
3025 } |
|
3026 url = '#' + linkId; |
|
3027 |
|
3028 if (!showdown.helper.isUndefined(globals.gUrls[linkId])) { |
|
3029 url = globals.gUrls[linkId]; |
|
3030 if (!showdown.helper.isUndefined(globals.gTitles[linkId])) { |
|
3031 title = globals.gTitles[linkId]; |
|
3032 } |
|
3033 } else { |
|
3034 return wholeMatch; |
|
3035 } |
|
3036 } |
|
3037 |
|
3038 //url = showdown.helper.escapeCharacters(url, '*_', false); // replaced line to improve performance |
|
3039 url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback); |
|
3040 |
|
3041 var result = '<a href="' + url + '"'; |
|
3042 |
|
3043 if (title !== '' && title !== null) { |
|
3044 title = title.replace(/"/g, '"'); |
|
3045 //title = showdown.helper.escapeCharacters(title, '*_', false); // replaced line to improve performance |
|
3046 title = title.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback); |
|
3047 result += ' title="' + title + '"'; |
|
3048 } |
|
3049 |
|
3050 // optionLinksInNewWindow only applies |
|
3051 // to external links. Hash links (#) open in same page |
|
3052 if (options.openLinksInNewWindow && !/^#/.test(url)) { |
|
3053 // escaped _ |
|
3054 result += ' target="¨E95Eblank"'; |
|
3055 } |
|
3056 |
|
3057 result += '>' + linkText + '</a>'; |
|
3058 |
|
3059 return result; |
|
3060 }; |
|
3061 |
|
3062 // First, handle reference-style links: [link text] [id] |
|
3063 text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)] ?(?:\n *)?\[(.*?)]()()()()/g, writeAnchorTag); |
|
3064 |
|
3065 // Next, inline-style links: [link text](url "optional title") |
|
3066 // cases with crazy urls like ./image/cat1).png |
|
3067 text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<([^>]*)>(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g, |
|
3068 writeAnchorTag); |
|
3069 |
|
3070 // normal cases |
|
3071 text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g, |
|
3072 writeAnchorTag); |
|
3073 |
|
3074 // handle reference-style shortcuts: [link text] |
|
3075 // These must come last in case you've also got [link test][1] |
|
3076 // or [link test](/foo) |
|
3077 text = text.replace(/\[([^\[\]]+)]()()()()()/g, writeAnchorTag); |
|
3078 |
|
3079 // Lastly handle GithubMentions if option is enabled |
|
3080 if (options.ghMentions) { |
|
3081 text = text.replace(/(^|\s)(\\)?(@([a-z\d]+(?:[a-z\d.-]+?[a-z\d]+)*))/gmi, function (wm, st, escape, mentions, username) { |
|
3082 if (escape === '\\') { |
|
3083 return st + mentions; |
|
3084 } |
|
3085 |
|
3086 //check if options.ghMentionsLink is a string |
|
3087 if (!showdown.helper.isString(options.ghMentionsLink)) { |
|
3088 throw new Error('ghMentionsLink option must be a string'); |
|
3089 } |
|
3090 var lnk = options.ghMentionsLink.replace(/\{u}/g, username), |
|
3091 target = ''; |
|
3092 if (options.openLinksInNewWindow) { |
|
3093 target = ' target="¨E95Eblank"'; |
|
3094 } |
|
3095 return st + '<a href="' + lnk + '"' + target + '>' + mentions + '</a>'; |
|
3096 }); |
|
3097 } |
|
3098 |
|
3099 text = globals.converter._dispatch('anchors.after', text, options, globals); |
|
3100 return text; |
|
3101 }); |
|
3102 |
|
3103 // url allowed chars [a-z\d_.~:/?#[]@!$&'()*+,;=-] |
|
3104 |
|
3105 var simpleURLRegex = /([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+?\.[^'">\s]+?)()(\1)?(?=\s|$)(?!["<>])/gi, |
|
3106 simpleURLRegex2 = /([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+?)([.!?,()\[\]])?(\1)?(?=\s|$)(?!["<>])/gi, |
|
3107 delimUrlRegex = /()<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)()>()/gi, |
|
3108 simpleMailRegex = /(^|\s)(?:mailto:)?([A-Za-z0-9!#$%&'*+-/=?^_`{|}~.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?=$|\s)/gmi, |
|
3109 delimMailRegex = /<()(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi, |
|
3110 |
|
3111 replaceLink = function (options) { |
|
3112 'use strict'; |
|
3113 return function (wm, leadingMagicChars, link, m2, m3, trailingPunctuation, trailingMagicChars) { |
|
3114 link = link.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback); |
|
3115 var lnkTxt = link, |
|
3116 append = '', |
|
3117 target = '', |
|
3118 lmc = leadingMagicChars || '', |
|
3119 tmc = trailingMagicChars || ''; |
|
3120 if (/^www\./i.test(link)) { |
|
3121 link = link.replace(/^www\./i, 'http://www.'); |
|
3122 } |
|
3123 if (options.excludeTrailingPunctuationFromURLs && trailingPunctuation) { |
|
3124 append = trailingPunctuation; |
|
3125 } |
|
3126 if (options.openLinksInNewWindow) { |
|
3127 target = ' target="¨E95Eblank"'; |
|
3128 } |
|
3129 return lmc + '<a href="' + link + '"' + target + '>' + lnkTxt + '</a>' + append + tmc; |
|
3130 }; |
|
3131 }, |
|
3132 |
|
3133 replaceMail = function (options, globals) { |
|
3134 'use strict'; |
|
3135 return function (wholeMatch, b, mail) { |
|
3136 var href = 'mailto:'; |
|
3137 b = b || ''; |
|
3138 mail = showdown.subParser('unescapeSpecialChars')(mail, options, globals); |
|
3139 if (options.encodeEmails) { |
|
3140 href = showdown.helper.encodeEmailAddress(href + mail); |
|
3141 mail = showdown.helper.encodeEmailAddress(mail); |
|
3142 } else { |
|
3143 href = href + mail; |
|
3144 } |
|
3145 return b + '<a href="' + href + '">' + mail + '</a>'; |
|
3146 }; |
|
3147 }; |
|
3148 |
|
3149 showdown.subParser('autoLinks', function (text, options, globals) { |
|
3150 'use strict'; |
|
3151 |
|
3152 text = globals.converter._dispatch('autoLinks.before', text, options, globals); |
|
3153 |
|
3154 text = text.replace(delimUrlRegex, replaceLink(options)); |
|
3155 text = text.replace(delimMailRegex, replaceMail(options, globals)); |
|
3156 |
|
3157 text = globals.converter._dispatch('autoLinks.after', text, options, globals); |
|
3158 |
|
3159 return text; |
|
3160 }); |
|
3161 |
|
3162 showdown.subParser('simplifiedAutoLinks', function (text, options, globals) { |
|
3163 'use strict'; |
|
3164 |
|
3165 if (!options.simplifiedAutoLink) { |
|
3166 return text; |
|
3167 } |
|
3168 |
|
3169 text = globals.converter._dispatch('simplifiedAutoLinks.before', text, options, globals); |
|
3170 |
|
3171 if (options.excludeTrailingPunctuationFromURLs) { |
|
3172 text = text.replace(simpleURLRegex2, replaceLink(options)); |
|
3173 } else { |
|
3174 text = text.replace(simpleURLRegex, replaceLink(options)); |
|
3175 } |
|
3176 text = text.replace(simpleMailRegex, replaceMail(options, globals)); |
|
3177 |
|
3178 text = globals.converter._dispatch('simplifiedAutoLinks.after', text, options, globals); |
|
3179 |
|
3180 return text; |
|
3181 }); |
|
3182 |
|
3183 /** |
|
3184 * These are all the transformations that form block-level |
|
3185 * tags like paragraphs, headers, and list items. |
|
3186 */ |
|
3187 showdown.subParser('blockGamut', function (text, options, globals) { |
|
3188 'use strict'; |
|
3189 |
|
3190 text = globals.converter._dispatch('blockGamut.before', text, options, globals); |
|
3191 |
|
3192 // we parse blockquotes first so that we can have headings and hrs |
|
3193 // inside blockquotes |
|
3194 text = showdown.subParser('blockQuotes')(text, options, globals); |
|
3195 text = showdown.subParser('headers')(text, options, globals); |
|
3196 |
|
3197 // Do Horizontal Rules: |
|
3198 text = showdown.subParser('horizontalRule')(text, options, globals); |
|
3199 |
|
3200 text = showdown.subParser('lists')(text, options, globals); |
|
3201 text = showdown.subParser('codeBlocks')(text, options, globals); |
|
3202 text = showdown.subParser('tables')(text, options, globals); |
|
3203 |
|
3204 // We already ran _HashHTMLBlocks() before, in Markdown(), but that |
|
3205 // was to escape raw HTML in the original Markdown source. This time, |
|
3206 // we're escaping the markup we've just created, so that we don't wrap |
|
3207 // <p> tags around block-level tags. |
|
3208 text = showdown.subParser('hashHTMLBlocks')(text, options, globals); |
|
3209 text = showdown.subParser('paragraphs')(text, options, globals); |
|
3210 |
|
3211 text = globals.converter._dispatch('blockGamut.after', text, options, globals); |
|
3212 |
|
3213 return text; |
|
3214 }); |
|
3215 |
|
3216 showdown.subParser('blockQuotes', function (text, options, globals) { |
|
3217 'use strict'; |
|
3218 |
|
3219 text = globals.converter._dispatch('blockQuotes.before', text, options, globals); |
|
3220 |
|
3221 // add a couple extra lines after the text and endtext mark |
|
3222 text = text + '\n\n'; |
|
3223 |
|
3224 var rgx = /(^ {0,3}>[ \t]?.+\n(.+\n)*\n*)+/gm; |
|
3225 |
|
3226 if (options.splitAdjacentBlockquotes) { |
|
3227 rgx = /^ {0,3}>[\s\S]*?(?:\n\n)/gm; |
|
3228 } |
|
3229 |
|
3230 text = text.replace(rgx, function (bq) { |
|
3231 // attacklab: hack around Konqueror 3.5.4 bug: |
|
3232 // "----------bug".replace(/^-/g,"") == "bug" |
|
3233 bq = bq.replace(/^[ \t]*>[ \t]?/gm, ''); // trim one level of quoting |
|
3234 |
|
3235 // attacklab: clean up hack |
|
3236 bq = bq.replace(/¨0/g, ''); |
|
3237 |
|
3238 bq = bq.replace(/^[ \t]+$/gm, ''); // trim whitespace-only lines |
|
3239 bq = showdown.subParser('githubCodeBlocks')(bq, options, globals); |
|
3240 bq = showdown.subParser('blockGamut')(bq, options, globals); // recurse |
|
3241 |
|
3242 bq = bq.replace(/(^|\n)/g, '$1 '); |
|
3243 // These leading spaces screw with <pre> content, so we need to fix that: |
|
3244 bq = bq.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm, function (wholeMatch, m1) { |
|
3245 var pre = m1; |
|
3246 // attacklab: hack around Konqueror 3.5.4 bug: |
|
3247 pre = pre.replace(/^ /mg, '¨0'); |
|
3248 pre = pre.replace(/¨0/g, ''); |
|
3249 return pre; |
|
3250 }); |
|
3251 |
|
3252 return showdown.subParser('hashBlock')('<blockquote>\n' + bq + '\n</blockquote>', options, globals); |
|
3253 }); |
|
3254 |
|
3255 text = globals.converter._dispatch('blockQuotes.after', text, options, globals); |
|
3256 return text; |
|
3257 }); |
|
3258 |
|
3259 /** |
|
3260 * Process Markdown `<pre><code>` blocks. |
|
3261 */ |
|
3262 showdown.subParser('codeBlocks', function (text, options, globals) { |
|
3263 'use strict'; |
|
3264 |
|
3265 text = globals.converter._dispatch('codeBlocks.before', text, options, globals); |
|
3266 |
|
3267 // sentinel workarounds for lack of \A and \Z, safari\khtml bug |
|
3268 text += '¨0'; |
|
3269 |
|
3270 var pattern = /(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=¨0))/g; |
|
3271 text = text.replace(pattern, function (wholeMatch, m1, m2) { |
|
3272 var codeblock = m1, |
|
3273 nextChar = m2, |
|
3274 end = '\n'; |
|
3275 |
|
3276 codeblock = showdown.subParser('outdent')(codeblock, options, globals); |
|
3277 codeblock = showdown.subParser('encodeCode')(codeblock, options, globals); |
|
3278 codeblock = showdown.subParser('detab')(codeblock, options, globals); |
|
3279 codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines |
|
3280 codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing newlines |
|
3281 |
|
3282 if (options.omitExtraWLInCodeBlocks) { |
|
3283 end = ''; |
|
3284 } |
|
3285 |
|
3286 codeblock = '<pre><code>' + codeblock + end + '</code></pre>'; |
|
3287 |
|
3288 return showdown.subParser('hashBlock')(codeblock, options, globals) + nextChar; |
|
3289 }); |
|
3290 |
|
3291 // strip sentinel |
|
3292 text = text.replace(/¨0/, ''); |
|
3293 |
|
3294 text = globals.converter._dispatch('codeBlocks.after', text, options, globals); |
|
3295 return text; |
|
3296 }); |
|
3297 |
|
3298 /** |
|
3299 * |
|
3300 * * Backtick quotes are used for <code></code> spans. |
|
3301 * |
|
3302 * * You can use multiple backticks as the delimiters if you want to |
|
3303 * include literal backticks in the code span. So, this input: |
|
3304 * |
|
3305 * Just type ``foo `bar` baz`` at the prompt. |
|
3306 * |
|
3307 * Will translate to: |
|
3308 * |
|
3309 * <p>Just type <code>foo `bar` baz</code> at the prompt.</p> |
|
3310 * |
|
3311 * There's no arbitrary limit to the number of backticks you |
|
3312 * can use as delimters. If you need three consecutive backticks |
|
3313 * in your code, use four for delimiters, etc. |
|
3314 * |
|
3315 * * You can use spaces to get literal backticks at the edges: |
|
3316 * |
|
3317 * ... type `` `bar` `` ... |
|
3318 * |
|
3319 * Turns to: |
|
3320 * |
|
3321 * ... type <code>`bar`</code> ... |
|
3322 */ |
|
3323 showdown.subParser('codeSpans', function (text, options, globals) { |
|
3324 'use strict'; |
|
3325 |
|
3326 text = globals.converter._dispatch('codeSpans.before', text, options, globals); |
|
3327 |
|
3328 if (typeof(text) === 'undefined') { |
|
3329 text = ''; |
|
3330 } |
|
3331 text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm, |
|
3332 function (wholeMatch, m1, m2, m3) { |
|
3333 var c = m3; |
|
3334 c = c.replace(/^([ \t]*)/g, ''); // leading whitespace |
|
3335 c = c.replace(/[ \t]*$/g, ''); // trailing whitespace |
|
3336 c = showdown.subParser('encodeCode')(c, options, globals); |
|
3337 c = m1 + '<code>' + c + '</code>'; |
|
3338 c = showdown.subParser('hashHTMLSpans')(c, options, globals); |
|
3339 return c; |
|
3340 } |
|
3341 ); |
|
3342 |
|
3343 text = globals.converter._dispatch('codeSpans.after', text, options, globals); |
|
3344 return text; |
|
3345 }); |
|
3346 |
|
3347 /** |
|
3348 * Create a full HTML document from the processed markdown |
|
3349 */ |
|
3350 showdown.subParser('completeHTMLDocument', function (text, options, globals) { |
|
3351 'use strict'; |
|
3352 |
|
3353 if (!options.completeHTMLDocument) { |
|
3354 return text; |
|
3355 } |
|
3356 |
|
3357 text = globals.converter._dispatch('completeHTMLDocument.before', text, options, globals); |
|
3358 |
|
3359 var doctype = 'html', |
|
3360 doctypeParsed = '<!DOCTYPE HTML>\n', |
|
3361 title = '', |
|
3362 charset = '<meta charset="utf-8">\n', |
|
3363 lang = '', |
|
3364 metadata = ''; |
|
3365 |
|
3366 if (typeof globals.metadata.parsed.doctype !== 'undefined') { |
|
3367 doctypeParsed = '<!DOCTYPE ' + globals.metadata.parsed.doctype + '>\n'; |
|
3368 doctype = globals.metadata.parsed.doctype.toString().toLowerCase(); |
|
3369 if (doctype === 'html' || doctype === 'html5') { |
|
3370 charset = '<meta charset="utf-8">'; |
|
3371 } |
|
3372 } |
|
3373 |
|
3374 for (var meta in globals.metadata.parsed) { |
|
3375 if (globals.metadata.parsed.hasOwnProperty(meta)) { |
|
3376 switch (meta.toLowerCase()) { |
|
3377 case 'doctype': |
|
3378 break; |
|
3379 |
|
3380 case 'title': |
|
3381 title = '<title>' + globals.metadata.parsed.title + '</title>\n'; |
|
3382 break; |
|
3383 |
|
3384 case 'charset': |
|
3385 if (doctype === 'html' || doctype === 'html5') { |
|
3386 charset = '<meta charset="' + globals.metadata.parsed.charset + '">\n'; |
|
3387 } else { |
|
3388 charset = '<meta name="charset" content="' + globals.metadata.parsed.charset + '">\n'; |
|
3389 } |
|
3390 break; |
|
3391 |
|
3392 case 'language': |
|
3393 case 'lang': |
|
3394 lang = ' lang="' + globals.metadata.parsed[meta] + '"'; |
|
3395 metadata += '<meta name="' + meta + '" content="' + globals.metadata.parsed[meta] + '">\n'; |
|
3396 break; |
|
3397 |
|
3398 default: |
|
3399 metadata += '<meta name="' + meta + '" content="' + globals.metadata.parsed[meta] + '">\n'; |
|
3400 } |
|
3401 } |
|
3402 } |
|
3403 |
|
3404 text = doctypeParsed + '<html' + lang + '>\n<head>\n' + title + charset + metadata + '</head>\n<body>\n' + text.trim() + '\n</body>\n</html>'; |
|
3405 |
|
3406 text = globals.converter._dispatch('completeHTMLDocument.after', text, options, globals); |
|
3407 return text; |
|
3408 }); |
|
3409 |
|
3410 /** |
|
3411 * Convert all tabs to spaces |
|
3412 */ |
|
3413 showdown.subParser('detab', function (text, options, globals) { |
|
3414 'use strict'; |
|
3415 text = globals.converter._dispatch('detab.before', text, options, globals); |
|
3416 |
|
3417 // expand first n-1 tabs |
|
3418 text = text.replace(/\t(?=\t)/g, ' '); // g_tab_width |
|
3419 |
|
3420 // replace the nth with two sentinels |
|
3421 text = text.replace(/\t/g, '¨A¨B'); |
|
3422 |
|
3423 // use the sentinel to anchor our regex so it doesn't explode |
|
3424 text = text.replace(/¨B(.+?)¨A/g, function (wholeMatch, m1) { |
|
3425 var leadingText = m1, |
|
3426 numSpaces = 4 - leadingText.length % 4; // g_tab_width |
|
3427 |
|
3428 // there *must* be a better way to do this: |
|
3429 for (var i = 0; i < numSpaces; i++) { |
|
3430 leadingText += ' '; |
|
3431 } |
|
3432 |
|
3433 return leadingText; |
|
3434 }); |
|
3435 |
|
3436 // clean up sentinels |
|
3437 text = text.replace(/¨A/g, ' '); // g_tab_width |
|
3438 text = text.replace(/¨B/g, ''); |
|
3439 |
|
3440 text = globals.converter._dispatch('detab.after', text, options, globals); |
|
3441 return text; |
|
3442 }); |
|
3443 |
|
3444 showdown.subParser('ellipsis', function (text, options, globals) { |
|
3445 'use strict'; |
|
3446 |
|
3447 text = globals.converter._dispatch('ellipsis.before', text, options, globals); |
|
3448 |
|
3449 text = text.replace(/\.\.\./g, '…'); |
|
3450 |
|
3451 text = globals.converter._dispatch('ellipsis.after', text, options, globals); |
|
3452 |
|
3453 return text; |
|
3454 }); |
|
3455 |
|
3456 /** |
|
3457 * Turn emoji codes into emojis |
|
3458 * |
|
3459 * List of supported emojis: https://github.com/showdownjs/showdown/wiki/Emojis |
|
3460 */ |
|
3461 showdown.subParser('emoji', function (text, options, globals) { |
|
3462 'use strict'; |
|
3463 |
|
3464 if (!options.emoji) { |
|
3465 return text; |
|
3466 } |
|
3467 |
|
3468 text = globals.converter._dispatch('emoji.before', text, options, globals); |
|
3469 |
|
3470 var emojiRgx = /:([\S]+?):/g; |
|
3471 |
|
3472 text = text.replace(emojiRgx, function (wm, emojiCode) { |
|
3473 if (showdown.helper.emojis.hasOwnProperty(emojiCode)) { |
|
3474 return showdown.helper.emojis[emojiCode]; |
|
3475 } |
|
3476 return wm; |
|
3477 }); |
|
3478 |
|
3479 text = globals.converter._dispatch('emoji.after', text, options, globals); |
|
3480 |
|
3481 return text; |
|
3482 }); |
|
3483 |
|
3484 /** |
|
3485 * Smart processing for ampersands and angle brackets that need to be encoded. |
|
3486 */ |
|
3487 showdown.subParser('encodeAmpsAndAngles', function (text, options, globals) { |
|
3488 'use strict'; |
|
3489 text = globals.converter._dispatch('encodeAmpsAndAngles.before', text, options, globals); |
|
3490 |
|
3491 // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin: |
|
3492 // http://bumppo.net/projects/amputator/ |
|
3493 text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, '&'); |
|
3494 |
|
3495 // Encode naked <'s |
|
3496 text = text.replace(/<(?![a-z\/?$!])/gi, '<'); |
|
3497 |
|
3498 // Encode < |
|
3499 text = text.replace(/</g, '<'); |
|
3500 |
|
3501 // Encode > |
|
3502 text = text.replace(/>/g, '>'); |
|
3503 |
|
3504 text = globals.converter._dispatch('encodeAmpsAndAngles.after', text, options, globals); |
|
3505 return text; |
|
3506 }); |
|
3507 |
|
3508 /** |
|
3509 * Returns the string, with after processing the following backslash escape sequences. |
|
3510 * |
|
3511 * attacklab: The polite way to do this is with the new escapeCharacters() function: |
|
3512 * |
|
3513 * text = escapeCharacters(text,"\\",true); |
|
3514 * text = escapeCharacters(text,"`*_{}[]()>#+-.!",true); |
|
3515 * |
|
3516 * ...but we're sidestepping its use of the (slow) RegExp constructor |
|
3517 * as an optimization for Firefox. This function gets called a LOT. |
|
3518 */ |
|
3519 showdown.subParser('encodeBackslashEscapes', function (text, options, globals) { |
|
3520 'use strict'; |
|
3521 text = globals.converter._dispatch('encodeBackslashEscapes.before', text, options, globals); |
|
3522 |
|
3523 text = text.replace(/\\(\\)/g, showdown.helper.escapeCharactersCallback); |
|
3524 text = text.replace(/\\([`*_{}\[\]()>#+.!~=|-])/g, showdown.helper.escapeCharactersCallback); |
|
3525 |
|
3526 text = globals.converter._dispatch('encodeBackslashEscapes.after', text, options, globals); |
|
3527 return text; |
|
3528 }); |
|
3529 |
|
3530 /** |
|
3531 * Encode/escape certain characters inside Markdown code runs. |
|
3532 * The point is that in code, these characters are literals, |
|
3533 * and lose their special Markdown meanings. |
|
3534 */ |
|
3535 showdown.subParser('encodeCode', function (text, options, globals) { |
|
3536 'use strict'; |
|
3537 |
|
3538 text = globals.converter._dispatch('encodeCode.before', text, options, globals); |
|
3539 |
|
3540 // Encode all ampersands; HTML entities are not |
|
3541 // entities within a Markdown code span. |
|
3542 text = text |
|
3543 .replace(/&/g, '&') |
|
3544 // Do the angle bracket song and dance: |
|
3545 .replace(/</g, '<') |
|
3546 .replace(/>/g, '>') |
|
3547 // Now, escape characters that are magic in Markdown: |
|
3548 .replace(/([*_{}\[\]\\=~-])/g, showdown.helper.escapeCharactersCallback); |
|
3549 |
|
3550 text = globals.converter._dispatch('encodeCode.after', text, options, globals); |
|
3551 return text; |
|
3552 }); |
|
3553 |
|
3554 /** |
|
3555 * Within tags -- meaning between < and > -- encode [\ ` * _ ~ =] so they |
|
3556 * don't conflict with their use in Markdown for code, italics and strong. |
|
3557 */ |
|
3558 showdown.subParser('escapeSpecialCharsWithinTagAttributes', function (text, options, globals) { |
|
3559 'use strict'; |
|
3560 text = globals.converter._dispatch('escapeSpecialCharsWithinTagAttributes.before', text, options, globals); |
|
3561 |
|
3562 // Build a regex to find HTML tags. |
|
3563 var tags = /<\/?[a-z\d_:-]+(?:[\s]+[\s\S]+?)?>/gi, |
|
3564 comments = /<!(--(?:(?:[^>-]|-[^>])(?:[^-]|-[^-])*)--)>/gi; |
|
3565 |
|
3566 text = text.replace(tags, function (wholeMatch) { |
|
3567 return wholeMatch |
|
3568 .replace(/(.)<\/?code>(?=.)/g, '$1`') |
|
3569 .replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback); |
|
3570 }); |
|
3571 |
|
3572 text = text.replace(comments, function (wholeMatch) { |
|
3573 return wholeMatch |
|
3574 .replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback); |
|
3575 }); |
|
3576 |
|
3577 text = globals.converter._dispatch('escapeSpecialCharsWithinTagAttributes.after', text, options, globals); |
|
3578 return text; |
|
3579 }); |
|
3580 |
|
3581 /** |
|
3582 * Handle github codeblocks prior to running HashHTML so that |
|
3583 * HTML contained within the codeblock gets escaped properly |
|
3584 * Example: |
|
3585 * ```ruby |
|
3586 * def hello_world(x) |
|
3587 * puts "Hello, #{x}" |
|
3588 * end |
|
3589 * ``` |
|
3590 */ |
|
3591 showdown.subParser('githubCodeBlocks', function (text, options, globals) { |
|
3592 'use strict'; |
|
3593 |
|
3594 // early exit if option is not enabled |
|
3595 if (!options.ghCodeBlocks) { |
|
3596 return text; |
|
3597 } |
|
3598 |
|
3599 text = globals.converter._dispatch('githubCodeBlocks.before', text, options, globals); |
|
3600 |
|
3601 text += '¨0'; |
|
3602 |
|
3603 text = text.replace(/(?:^|\n)(?: {0,3})(```+|~~~+)(?: *)([^\s`~]*)\n([\s\S]*?)\n(?: {0,3})\1/g, function (wholeMatch, delim, language, codeblock) { |
|
3604 var end = (options.omitExtraWLInCodeBlocks) ? '' : '\n'; |
|
3605 |
|
3606 // First parse the github code block |
|
3607 codeblock = showdown.subParser('encodeCode')(codeblock, options, globals); |
|
3608 codeblock = showdown.subParser('detab')(codeblock, options, globals); |
|
3609 codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines |
|
3610 codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace |
|
3611 |
|
3612 codeblock = '<pre><code' + (language ? ' class="' + language + ' language-' + language + '"' : '') + '>' + codeblock + end + '</code></pre>'; |
|
3613 |
|
3614 codeblock = showdown.subParser('hashBlock')(codeblock, options, globals); |
|
3615 |
|
3616 // Since GHCodeblocks can be false positives, we need to |
|
3617 // store the primitive text and the parsed text in a global var, |
|
3618 // and then return a token |
|
3619 return '\n\n¨G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n'; |
|
3620 }); |
|
3621 |
|
3622 // attacklab: strip sentinel |
|
3623 text = text.replace(/¨0/, ''); |
|
3624 |
|
3625 return globals.converter._dispatch('githubCodeBlocks.after', text, options, globals); |
|
3626 }); |
|
3627 |
|
3628 showdown.subParser('hashBlock', function (text, options, globals) { |
|
3629 'use strict'; |
|
3630 text = globals.converter._dispatch('hashBlock.before', text, options, globals); |
|
3631 text = text.replace(/(^\n+|\n+$)/g, ''); |
|
3632 text = '\n\n¨K' + (globals.gHtmlBlocks.push(text) - 1) + 'K\n\n'; |
|
3633 text = globals.converter._dispatch('hashBlock.after', text, options, globals); |
|
3634 return text; |
|
3635 }); |
|
3636 |
|
3637 /** |
|
3638 * Hash and escape <code> elements that should not be parsed as markdown |
|
3639 */ |
|
3640 showdown.subParser('hashCodeTags', function (text, options, globals) { |
|
3641 'use strict'; |
|
3642 text = globals.converter._dispatch('hashCodeTags.before', text, options, globals); |
|
3643 |
|
3644 var repFunc = function (wholeMatch, match, left, right) { |
|
3645 var codeblock = left + showdown.subParser('encodeCode')(match, options, globals) + right; |
|
3646 return '¨C' + (globals.gHtmlSpans.push(codeblock) - 1) + 'C'; |
|
3647 }; |
|
3648 |
|
3649 // Hash naked <code> |
|
3650 text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '<code\\b[^>]*>', '</code>', 'gim'); |
|
3651 |
|
3652 text = globals.converter._dispatch('hashCodeTags.after', text, options, globals); |
|
3653 return text; |
|
3654 }); |
|
3655 |
|
3656 showdown.subParser('hashElement', function (text, options, globals) { |
|
3657 'use strict'; |
|
3658 |
|
3659 return function (wholeMatch, m1) { |
|
3660 var blockText = m1; |
|
3661 |
|
3662 // Undo double lines |
|
3663 blockText = blockText.replace(/\n\n/g, '\n'); |
|
3664 blockText = blockText.replace(/^\n/, ''); |
|
3665 |
|
3666 // strip trailing blank lines |
|
3667 blockText = blockText.replace(/\n+$/g, ''); |
|
3668 |
|
3669 // Replace the element text with a marker ("¨KxK" where x is its key) |
|
3670 blockText = '\n\n¨K' + (globals.gHtmlBlocks.push(blockText) - 1) + 'K\n\n'; |
|
3671 |
|
3672 return blockText; |
|
3673 }; |
|
3674 }); |
|
3675 |
|
3676 showdown.subParser('hashHTMLBlocks', function (text, options, globals) { |
|
3677 'use strict'; |
|
3678 text = globals.converter._dispatch('hashHTMLBlocks.before', text, options, globals); |
|
3679 |
|
3680 var blockTags = [ |
|
3681 'pre', |
|
3682 'div', |
|
3683 'h1', |
|
3684 'h2', |
|
3685 'h3', |
|
3686 'h4', |
|
3687 'h5', |
|
3688 'h6', |
|
3689 'blockquote', |
|
3690 'table', |
|
3691 'dl', |
|
3692 'ol', |
|
3693 'ul', |
|
3694 'script', |
|
3695 'noscript', |
|
3696 'form', |
|
3697 'fieldset', |
|
3698 'iframe', |
|
3699 'math', |
|
3700 'style', |
|
3701 'section', |
|
3702 'header', |
|
3703 'footer', |
|
3704 'nav', |
|
3705 'article', |
|
3706 'aside', |
|
3707 'address', |
|
3708 'audio', |
|
3709 'canvas', |
|
3710 'figure', |
|
3711 'hgroup', |
|
3712 'output', |
|
3713 'video', |
|
3714 'p' |
|
3715 ], |
|
3716 repFunc = function (wholeMatch, match, left, right) { |
|
3717 var txt = wholeMatch; |
|
3718 // check if this html element is marked as markdown |
|
3719 // if so, it's contents should be parsed as markdown |
|
3720 if (left.search(/\bmarkdown\b/) !== -1) { |
|
3721 txt = left + globals.converter.makeHtml(match) + right; |
|
3722 } |
|
3723 return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n'; |
|
3724 }; |
|
3725 |
|
3726 if (options.backslashEscapesHTMLTags) { |
|
3727 // encode backslash escaped HTML tags |
|
3728 text = text.replace(/\\<(\/?[^>]+?)>/g, function (wm, inside) { |
|
3729 return '<' + inside + '>'; |
|
3730 }); |
|
3731 } |
|
3732 |
|
3733 // hash HTML Blocks |
|
3734 for (var i = 0; i < blockTags.length; ++i) { |
|
3735 |
|
3736 var opTagPos, |
|
3737 rgx1 = new RegExp('^ {0,3}(<' + blockTags[i] + '\\b[^>]*>)', 'im'), |
|
3738 patLeft = '<' + blockTags[i] + '\\b[^>]*>', |
|
3739 patRight = '</' + blockTags[i] + '>'; |
|
3740 // 1. Look for the first position of the first opening HTML tag in the text |
|
3741 while ((opTagPos = showdown.helper.regexIndexOf(text, rgx1)) !== -1) { |
|
3742 |
|
3743 // if the HTML tag is \ escaped, we need to escape it and break |
|
3744 |
|
3745 |
|
3746 //2. Split the text in that position |
|
3747 var subTexts = showdown.helper.splitAtIndex(text, opTagPos), |
|
3748 //3. Match recursively |
|
3749 newSubText1 = showdown.helper.replaceRecursiveRegExp(subTexts[1], repFunc, patLeft, patRight, 'im'); |
|
3750 |
|
3751 // prevent an infinite loop |
|
3752 if (newSubText1 === subTexts[1]) { |
|
3753 break; |
|
3754 } |
|
3755 text = subTexts[0].concat(newSubText1); |
|
3756 } |
|
3757 } |
|
3758 // HR SPECIAL CASE |
|
3759 text = text.replace(/(\n {0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g, |
|
3760 showdown.subParser('hashElement')(text, options, globals)); |
|
3761 |
|
3762 // Special case for standalone HTML comments |
|
3763 text = showdown.helper.replaceRecursiveRegExp(text, function (txt) { |
|
3764 return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n'; |
|
3765 }, '^ {0,3}<!--', '-->', 'gm'); |
|
3766 |
|
3767 // PHP and ASP-style processor instructions (<?...?> and <%...%>) |
|
3768 text = text.replace(/(?:\n\n)( {0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g, |
|
3769 showdown.subParser('hashElement')(text, options, globals)); |
|
3770 |
|
3771 text = globals.converter._dispatch('hashHTMLBlocks.after', text, options, globals); |
|
3772 return text; |
|
3773 }); |
|
3774 |
|
3775 /** |
|
3776 * Hash span elements that should not be parsed as markdown |
|
3777 */ |
|
3778 showdown.subParser('hashHTMLSpans', function (text, options, globals) { |
|
3779 'use strict'; |
|
3780 text = globals.converter._dispatch('hashHTMLSpans.before', text, options, globals); |
|
3781 |
|
3782 function hashHTMLSpan (html) { |
|
3783 return '¨C' + (globals.gHtmlSpans.push(html) - 1) + 'C'; |
|
3784 } |
|
3785 |
|
3786 // Hash Self Closing tags |
|
3787 text = text.replace(/<[^>]+?\/>/gi, function (wm) { |
|
3788 return hashHTMLSpan(wm); |
|
3789 }); |
|
3790 |
|
3791 // Hash tags without properties |
|
3792 text = text.replace(/<([^>]+?)>[\s\S]*?<\/\1>/g, function (wm) { |
|
3793 return hashHTMLSpan(wm); |
|
3794 }); |
|
3795 |
|
3796 // Hash tags with properties |
|
3797 text = text.replace(/<([^>]+?)\s[^>]+?>[\s\S]*?<\/\1>/g, function (wm) { |
|
3798 return hashHTMLSpan(wm); |
|
3799 }); |
|
3800 |
|
3801 // Hash self closing tags without /> |
|
3802 text = text.replace(/<[^>]+?>/gi, function (wm) { |
|
3803 return hashHTMLSpan(wm); |
|
3804 }); |
|
3805 |
|
3806 /*showdown.helper.matchRecursiveRegExp(text, '<code\\b[^>]*>', '</code>', 'gi');*/ |
|
3807 |
|
3808 text = globals.converter._dispatch('hashHTMLSpans.after', text, options, globals); |
|
3809 return text; |
|
3810 }); |
|
3811 |
|
3812 /** |
|
3813 * Unhash HTML spans |
|
3814 */ |
|
3815 showdown.subParser('unhashHTMLSpans', function (text, options, globals) { |
|
3816 'use strict'; |
|
3817 text = globals.converter._dispatch('unhashHTMLSpans.before', text, options, globals); |
|
3818 |
|
3819 for (var i = 0; i < globals.gHtmlSpans.length; ++i) { |
|
3820 var repText = globals.gHtmlSpans[i], |
|
3821 // limiter to prevent infinite loop (assume 10 as limit for recurse) |
|
3822 limit = 0; |
|
3823 |
|
3824 while (/¨C(\d+)C/.test(repText)) { |
|
3825 var num = RegExp.$1; |
|
3826 repText = repText.replace('¨C' + num + 'C', globals.gHtmlSpans[num]); |
|
3827 if (limit === 10) { |
|
3828 console.error('maximum nesting of 10 spans reached!!!'); |
|
3829 break; |
|
3830 } |
|
3831 ++limit; |
|
3832 } |
|
3833 text = text.replace('¨C' + i + 'C', repText); |
|
3834 } |
|
3835 |
|
3836 text = globals.converter._dispatch('unhashHTMLSpans.after', text, options, globals); |
|
3837 return text; |
|
3838 }); |
|
3839 |
|
3840 /** |
|
3841 * Hash and escape <pre><code> elements that should not be parsed as markdown |
|
3842 */ |
|
3843 showdown.subParser('hashPreCodeTags', function (text, options, globals) { |
|
3844 'use strict'; |
|
3845 text = globals.converter._dispatch('hashPreCodeTags.before', text, options, globals); |
|
3846 |
|
3847 var repFunc = function (wholeMatch, match, left, right) { |
|
3848 // encode html entities |
|
3849 var codeblock = left + showdown.subParser('encodeCode')(match, options, globals) + right; |
|
3850 return '\n\n¨G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n'; |
|
3851 }; |
|
3852 |
|
3853 // Hash <pre><code> |
|
3854 text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '^ {0,3}<pre\\b[^>]*>\\s*<code\\b[^>]*>', '^ {0,3}</code>\\s*</pre>', 'gim'); |
|
3855 |
|
3856 text = globals.converter._dispatch('hashPreCodeTags.after', text, options, globals); |
|
3857 return text; |
|
3858 }); |
|
3859 |
|
3860 showdown.subParser('headers', function (text, options, globals) { |
|
3861 'use strict'; |
|
3862 |
|
3863 text = globals.converter._dispatch('headers.before', text, options, globals); |
|
3864 |
|
3865 var headerLevelStart = (isNaN(parseInt(options.headerLevelStart))) ? 1 : parseInt(options.headerLevelStart), |
|
3866 |
|
3867 // Set text-style headers: |
|
3868 // Header 1 |
|
3869 // ======== |
|
3870 // |
|
3871 // Header 2 |
|
3872 // -------- |
|
3873 // |
|
3874 setextRegexH1 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n={2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n=+[ \t]*\n+/gm, |
|
3875 setextRegexH2 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n-+[ \t]*\n+/gm; |
|
3876 |
|
3877 text = text.replace(setextRegexH1, function (wholeMatch, m1) { |
|
3878 |
|
3879 var spanGamut = showdown.subParser('spanGamut')(m1, options, globals), |
|
3880 hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"', |
|
3881 hLevel = headerLevelStart, |
|
3882 hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>'; |
|
3883 return showdown.subParser('hashBlock')(hashBlock, options, globals); |
|
3884 }); |
|
3885 |
|
3886 text = text.replace(setextRegexH2, function (matchFound, m1) { |
|
3887 var spanGamut = showdown.subParser('spanGamut')(m1, options, globals), |
|
3888 hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"', |
|
3889 hLevel = headerLevelStart + 1, |
|
3890 hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>'; |
|
3891 return showdown.subParser('hashBlock')(hashBlock, options, globals); |
|
3892 }); |
|
3893 |
|
3894 // atx-style headers: |
|
3895 // # Header 1 |
|
3896 // ## Header 2 |
|
3897 // ## Header 2 with closing hashes ## |
|
3898 // ... |
|
3899 // ###### Header 6 |
|
3900 // |
|
3901 var atxStyle = (options.requireSpaceBeforeHeadingText) ? /^(#{1,6})[ \t]+(.+?)[ \t]*#*\n+/gm : /^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm; |
|
3902 |
|
3903 text = text.replace(atxStyle, function (wholeMatch, m1, m2) { |
|
3904 var hText = m2; |
|
3905 if (options.customizedHeaderId) { |
|
3906 hText = m2.replace(/\s?\{([^{]+?)}\s*$/, ''); |
|
3907 } |
|
3908 |
|
3909 var span = showdown.subParser('spanGamut')(hText, options, globals), |
|
3910 hID = (options.noHeaderId) ? '' : ' id="' + headerId(m2) + '"', |
|
3911 hLevel = headerLevelStart - 1 + m1.length, |
|
3912 header = '<h' + hLevel + hID + '>' + span + '</h' + hLevel + '>'; |
|
3913 |
|
3914 return showdown.subParser('hashBlock')(header, options, globals); |
|
3915 }); |
|
3916 |
|
3917 function headerId (m) { |
|
3918 var title, |
|
3919 prefix; |
|
3920 |
|
3921 // It is separate from other options to allow combining prefix and customized |
|
3922 if (options.customizedHeaderId) { |
|
3923 var match = m.match(/\{([^{]+?)}\s*$/); |
|
3924 if (match && match[1]) { |
|
3925 m = match[1]; |
|
3926 } |
|
3927 } |
|
3928 |
|
3929 title = m; |
|
3930 |
|
3931 // Prefix id to prevent causing inadvertent pre-existing style matches. |
|
3932 if (showdown.helper.isString(options.prefixHeaderId)) { |
|
3933 prefix = options.prefixHeaderId; |
|
3934 } else if (options.prefixHeaderId === true) { |
|
3935 prefix = 'section-'; |
|
3936 } else { |
|
3937 prefix = ''; |
|
3938 } |
|
3939 |
|
3940 if (!options.rawPrefixHeaderId) { |
|
3941 title = prefix + title; |
|
3942 } |
|
3943 |
|
3944 if (options.ghCompatibleHeaderId) { |
|
3945 title = title |
|
3946 .replace(/ /g, '-') |
|
3947 // replace previously escaped chars (&, ¨ and $) |
|
3948 .replace(/&/g, '') |
|
3949 .replace(/¨T/g, '') |
|
3950 .replace(/¨D/g, '') |
|
3951 // replace rest of the chars (&~$ are repeated as they might have been escaped) |
|
3952 // borrowed from github's redcarpet (some they should produce similar results) |
|
3953 .replace(/[&+$,\/:;=?@"#{}|^¨~\[\]`\\*)(%.!'<>]/g, '') |
|
3954 .toLowerCase(); |
|
3955 } else if (options.rawHeaderId) { |
|
3956 title = title |
|
3957 .replace(/ /g, '-') |
|
3958 // replace previously escaped chars (&, ¨ and $) |
|
3959 .replace(/&/g, '&') |
|
3960 .replace(/¨T/g, '¨') |
|
3961 .replace(/¨D/g, '$') |
|
3962 // replace " and ' |
|
3963 .replace(/["']/g, '-') |
|
3964 .toLowerCase(); |
|
3965 } else { |
|
3966 title = title |
|
3967 .replace(/[^\w]/g, '') |
|
3968 .toLowerCase(); |
|
3969 } |
|
3970 |
|
3971 if (options.rawPrefixHeaderId) { |
|
3972 title = prefix + title; |
|
3973 } |
|
3974 |
|
3975 if (globals.hashLinkCounts[title]) { |
|
3976 title = title + '-' + (globals.hashLinkCounts[title]++); |
|
3977 } else { |
|
3978 globals.hashLinkCounts[title] = 1; |
|
3979 } |
|
3980 return title; |
|
3981 } |
|
3982 |
|
3983 text = globals.converter._dispatch('headers.after', text, options, globals); |
|
3984 return text; |
|
3985 }); |
|
3986 |
|
3987 /** |
|
3988 * Turn Markdown link shortcuts into XHTML <a> tags. |
|
3989 */ |
|
3990 showdown.subParser('horizontalRule', function (text, options, globals) { |
|
3991 'use strict'; |
|
3992 text = globals.converter._dispatch('horizontalRule.before', text, options, globals); |
|
3993 |
|
3994 var key = showdown.subParser('hashBlock')('<hr />', options, globals); |
|
3995 text = text.replace(/^ {0,2}( ?-){3,}[ \t]*$/gm, key); |
|
3996 text = text.replace(/^ {0,2}( ?\*){3,}[ \t]*$/gm, key); |
|
3997 text = text.replace(/^ {0,2}( ?_){3,}[ \t]*$/gm, key); |
|
3998 |
|
3999 text = globals.converter._dispatch('horizontalRule.after', text, options, globals); |
|
4000 return text; |
|
4001 }); |
|
4002 |
|
4003 /** |
|
4004 * Turn Markdown image shortcuts into <img> tags. |
|
4005 */ |
|
4006 showdown.subParser('images', function (text, options, globals) { |
|
4007 'use strict'; |
|
4008 |
|
4009 text = globals.converter._dispatch('images.before', text, options, globals); |
|
4010 |
|
4011 var inlineRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g, |
|
4012 crazyRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<([^>]*)>(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(?:(["'])([^"]*?)\6))?[ \t]?\)/g, |
|
4013 base64RegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g, |
|
4014 referenceRegExp = /!\[([^\]]*?)] ?(?:\n *)?\[([\s\S]*?)]()()()()()/g, |
|
4015 refShortcutRegExp = /!\[([^\[\]]+)]()()()()()/g; |
|
4016 |
|
4017 function writeImageTagBase64 (wholeMatch, altText, linkId, url, width, height, m5, title) { |
|
4018 url = url.replace(/\s/g, ''); |
|
4019 return writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title); |
|
4020 } |
|
4021 |
|
4022 function writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title) { |
|
4023 |
|
4024 var gUrls = globals.gUrls, |
|
4025 gTitles = globals.gTitles, |
|
4026 gDims = globals.gDimensions; |
|
4027 |
|
4028 linkId = linkId.toLowerCase(); |
|
4029 |
|
4030 if (!title) { |
|
4031 title = ''; |
|
4032 } |
|
4033 // Special case for explicit empty url |
|
4034 if (wholeMatch.search(/\(<?\s*>? ?(['"].*['"])?\)$/m) > -1) { |
|
4035 url = ''; |
|
4036 |
|
4037 } else if (url === '' || url === null) { |
|
4038 if (linkId === '' || linkId === null) { |
|
4039 // lower-case and turn embedded newlines into spaces |
|
4040 linkId = altText.toLowerCase().replace(/ ?\n/g, ' '); |
|
4041 } |
|
4042 url = '#' + linkId; |
|
4043 |
|
4044 if (!showdown.helper.isUndefined(gUrls[linkId])) { |
|
4045 url = gUrls[linkId]; |
|
4046 if (!showdown.helper.isUndefined(gTitles[linkId])) { |
|
4047 title = gTitles[linkId]; |
|
4048 } |
|
4049 if (!showdown.helper.isUndefined(gDims[linkId])) { |
|
4050 width = gDims[linkId].width; |
|
4051 height = gDims[linkId].height; |
|
4052 } |
|
4053 } else { |
|
4054 return wholeMatch; |
|
4055 } |
|
4056 } |
|
4057 |
|
4058 altText = altText |
|
4059 .replace(/"/g, '"') |
|
4060 //altText = showdown.helper.escapeCharacters(altText, '*_', false); |
|
4061 .replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback); |
|
4062 //url = showdown.helper.escapeCharacters(url, '*_', false); |
|
4063 url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback); |
|
4064 var result = '<img src="' + url + '" alt="' + altText + '"'; |
|
4065 |
|
4066 if (title && showdown.helper.isString(title)) { |
|
4067 title = title |
|
4068 .replace(/"/g, '"') |
|
4069 //title = showdown.helper.escapeCharacters(title, '*_', false); |
|
4070 .replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback); |
|
4071 result += ' title="' + title + '"'; |
|
4072 } |
|
4073 |
|
4074 if (width && height) { |
|
4075 width = (width === '*') ? 'auto' : width; |
|
4076 height = (height === '*') ? 'auto' : height; |
|
4077 |
|
4078 result += ' width="' + width + '"'; |
|
4079 result += ' height="' + height + '"'; |
|
4080 } |
|
4081 |
|
4082 result += ' />'; |
|
4083 |
|
4084 return result; |
|
4085 } |
|
4086 |
|
4087 // First, handle reference-style labeled images: ![alt text][id] |
|
4088 text = text.replace(referenceRegExp, writeImageTag); |
|
4089 |
|
4090 // Next, handle inline images:  |
|
4091 |
|
4092 // base64 encoded images |
|
4093 text = text.replace(base64RegExp, writeImageTagBase64); |
|
4094 |
|
4095 // cases with crazy urls like ./image/cat1).png |
|
4096 text = text.replace(crazyRegExp, writeImageTag); |
|
4097 |
|
4098 // normal cases |
|
4099 text = text.replace(inlineRegExp, writeImageTag); |
|
4100 |
|
4101 // handle reference-style shortcuts: ![img text] |
|
4102 text = text.replace(refShortcutRegExp, writeImageTag); |
|
4103 |
|
4104 text = globals.converter._dispatch('images.after', text, options, globals); |
|
4105 return text; |
|
4106 }); |
|
4107 |
|
4108 showdown.subParser('italicsAndBold', function (text, options, globals) { |
|
4109 'use strict'; |
|
4110 |
|
4111 text = globals.converter._dispatch('italicsAndBold.before', text, options, globals); |
|
4112 |
|
4113 // it's faster to have 3 separate regexes for each case than have just one |
|
4114 // because of backtracing, in some cases, it could lead to an exponential effect |
|
4115 // called "catastrophic backtrace". Ominous! |
|
4116 |
|
4117 function parseInside (txt, left, right) { |
|
4118 /* |
|
4119 if (options.simplifiedAutoLink) { |
|
4120 txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals); |
|
4121 } |
|
4122 */ |
|
4123 return left + txt + right; |
|
4124 } |
|
4125 |
|
4126 // Parse underscores |
|
4127 if (options.literalMidWordUnderscores) { |
|
4128 text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function (wm, txt) { |
|
4129 return parseInside (txt, '<strong><em>', '</em></strong>'); |
|
4130 }); |
|
4131 text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function (wm, txt) { |
|
4132 return parseInside (txt, '<strong>', '</strong>'); |
|
4133 }); |
|
4134 text = text.replace(/\b_(\S[\s\S]*?)_\b/g, function (wm, txt) { |
|
4135 return parseInside (txt, '<em>', '</em>'); |
|
4136 }); |
|
4137 } else { |
|
4138 text = text.replace(/___(\S[\s\S]*?)___/g, function (wm, m) { |
|
4139 return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm; |
|
4140 }); |
|
4141 text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) { |
|
4142 return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm; |
|
4143 }); |
|
4144 text = text.replace(/_([^\s_][\s\S]*?)_/g, function (wm, m) { |
|
4145 // !/^_[^_]/.test(m) - test if it doesn't start with __ (since it seems redundant, we removed it) |
|
4146 return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm; |
|
4147 }); |
|
4148 } |
|
4149 |
|
4150 // Now parse asterisks |
|
4151 if (options.literalMidWordAsterisks) { |
|
4152 text = text.replace(/([^*]|^)\B\*\*\*(\S[\s\S]*?)\*\*\*\B(?!\*)/g, function (wm, lead, txt) { |
|
4153 return parseInside (txt, lead + '<strong><em>', '</em></strong>'); |
|
4154 }); |
|
4155 text = text.replace(/([^*]|^)\B\*\*(\S[\s\S]*?)\*\*\B(?!\*)/g, function (wm, lead, txt) { |
|
4156 return parseInside (txt, lead + '<strong>', '</strong>'); |
|
4157 }); |
|
4158 text = text.replace(/([^*]|^)\B\*(\S[\s\S]*?)\*\B(?!\*)/g, function (wm, lead, txt) { |
|
4159 return parseInside (txt, lead + '<em>', '</em>'); |
|
4160 }); |
|
4161 } else { |
|
4162 text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) { |
|
4163 return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm; |
|
4164 }); |
|
4165 text = text.replace(/\*\*(\S[\s\S]*?)\*\*/g, function (wm, m) { |
|
4166 return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm; |
|
4167 }); |
|
4168 text = text.replace(/\*([^\s*][\s\S]*?)\*/g, function (wm, m) { |
|
4169 // !/^\*[^*]/.test(m) - test if it doesn't start with ** (since it seems redundant, we removed it) |
|
4170 return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm; |
|
4171 }); |
|
4172 } |
|
4173 |
|
4174 |
|
4175 text = globals.converter._dispatch('italicsAndBold.after', text, options, globals); |
|
4176 return text; |
|
4177 }); |
|
4178 |
|
4179 /** |
|
4180 * Form HTML ordered (numbered) and unordered (bulleted) lists. |
|
4181 */ |
|
4182 showdown.subParser('lists', function (text, options, globals) { |
|
4183 'use strict'; |
|
4184 |
|
4185 /** |
|
4186 * Process the contents of a single ordered or unordered list, splitting it |
|
4187 * into individual list items. |
|
4188 * @param {string} listStr |
|
4189 * @param {boolean} trimTrailing |
|
4190 * @returns {string} |
|
4191 */ |
|
4192 function processListItems (listStr, trimTrailing) { |
|
4193 // The $g_list_level global keeps track of when we're inside a list. |
|
4194 // Each time we enter a list, we increment it; when we leave a list, |
|
4195 // we decrement. If it's zero, we're not in a list anymore. |
|
4196 // |
|
4197 // We do this because when we're not inside a list, we want to treat |
|
4198 // something like this: |
|
4199 // |
|
4200 // I recommend upgrading to version |
|
4201 // 8. Oops, now this line is treated |
|
4202 // as a sub-list. |
|
4203 // |
|
4204 // As a single paragraph, despite the fact that the second line starts |
|
4205 // with a digit-period-space sequence. |
|
4206 // |
|
4207 // Whereas when we're inside a list (or sub-list), that line will be |
|
4208 // treated as the start of a sub-list. What a kludge, huh? This is |
|
4209 // an aspect of Markdown's syntax that's hard to parse perfectly |
|
4210 // without resorting to mind-reading. Perhaps the solution is to |
|
4211 // change the syntax rules such that sub-lists must start with a |
|
4212 // starting cardinal number; e.g. "1." or "a.". |
|
4213 globals.gListLevel++; |
|
4214 |
|
4215 // trim trailing blank lines: |
|
4216 listStr = listStr.replace(/\n{2,}$/, '\n'); |
|
4217 |
|
4218 // attacklab: add sentinel to emulate \z |
|
4219 listStr += '¨0'; |
|
4220 |
|
4221 var rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0| {0,3}([*+-]|\d+[.])[ \t]+))/gm, |
|
4222 isParagraphed = (/\n[ \t]*\n(?!¨0)/.test(listStr)); |
|
4223 |
|
4224 // Since version 1.5, nesting sublists requires 4 spaces (or 1 tab) indentation, |
|
4225 // which is a syntax breaking change |
|
4226 // activating this option reverts to old behavior |
|
4227 if (options.disableForced4SpacesIndentedSublists) { |
|
4228 rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0|\2([*+-]|\d+[.])[ \t]+))/gm; |
|
4229 } |
|
4230 |
|
4231 listStr = listStr.replace(rgx, function (wholeMatch, m1, m2, m3, m4, taskbtn, checked) { |
|
4232 checked = (checked && checked.trim() !== ''); |
|
4233 |
|
4234 var item = showdown.subParser('outdent')(m4, options, globals), |
|
4235 bulletStyle = ''; |
|
4236 |
|
4237 // Support for github tasklists |
|
4238 if (taskbtn && options.tasklists) { |
|
4239 bulletStyle = ' class="task-list-item" style="list-style-type: none;"'; |
|
4240 item = item.replace(/^[ \t]*\[(x|X| )?]/m, function () { |
|
4241 var otp = '<input type="checkbox" disabled style="margin: 0px 0.35em 0.25em -1.6em; vertical-align: middle;"'; |
|
4242 if (checked) { |
|
4243 otp += ' checked'; |
|
4244 } |
|
4245 otp += '>'; |
|
4246 return otp; |
|
4247 }); |
|
4248 } |
|
4249 |
|
4250 // ISSUE #312 |
|
4251 // This input: - - - a |
|
4252 // causes trouble to the parser, since it interprets it as: |
|
4253 // <ul><li><li><li>a</li></li></li></ul> |
|
4254 // instead of: |
|
4255 // <ul><li>- - a</li></ul> |
|
4256 // So, to prevent it, we will put a marker (¨A)in the beginning of the line |
|
4257 // Kind of hackish/monkey patching, but seems more effective than overcomplicating the list parser |
|
4258 item = item.replace(/^([-*+]|\d\.)[ \t]+[\S\n ]*/g, function (wm2) { |
|
4259 return '¨A' + wm2; |
|
4260 }); |
|
4261 |
|
4262 // m1 - Leading line or |
|
4263 // Has a double return (multi paragraph) or |
|
4264 // Has sublist |
|
4265 if (m1 || (item.search(/\n{2,}/) > -1)) { |
|
4266 item = showdown.subParser('githubCodeBlocks')(item, options, globals); |
|
4267 item = showdown.subParser('blockGamut')(item, options, globals); |
|
4268 } else { |
|
4269 // Recursion for sub-lists: |
|
4270 item = showdown.subParser('lists')(item, options, globals); |
|
4271 item = item.replace(/\n$/, ''); // chomp(item) |
|
4272 item = showdown.subParser('hashHTMLBlocks')(item, options, globals); |
|
4273 |
|
4274 // Colapse double linebreaks |
|
4275 item = item.replace(/\n\n+/g, '\n\n'); |
|
4276 if (isParagraphed) { |
|
4277 item = showdown.subParser('paragraphs')(item, options, globals); |
|
4278 } else { |
|
4279 item = showdown.subParser('spanGamut')(item, options, globals); |
|
4280 } |
|
4281 } |
|
4282 |
|
4283 // now we need to remove the marker (¨A) |
|
4284 item = item.replace('¨A', ''); |
|
4285 // we can finally wrap the line in list item tags |
|
4286 item = '<li' + bulletStyle + '>' + item + '</li>\n'; |
|
4287 |
|
4288 return item; |
|
4289 }); |
|
4290 |
|
4291 // attacklab: strip sentinel |
|
4292 listStr = listStr.replace(/¨0/g, ''); |
|
4293 |
|
4294 globals.gListLevel--; |
|
4295 |
|
4296 if (trimTrailing) { |
|
4297 listStr = listStr.replace(/\s+$/, ''); |
|
4298 } |
|
4299 |
|
4300 return listStr; |
|
4301 } |
|
4302 |
|
4303 function styleStartNumber (list, listType) { |
|
4304 // check if ol and starts by a number different than 1 |
|
4305 if (listType === 'ol') { |
|
4306 var res = list.match(/^ *(\d+)\./); |
|
4307 if (res && res[1] !== '1') { |
|
4308 return ' start="' + res[1] + '"'; |
|
4309 } |
|
4310 } |
|
4311 return ''; |
|
4312 } |
|
4313 |
|
4314 /** |
|
4315 * Check and parse consecutive lists (better fix for issue #142) |
|
4316 * @param {string} list |
|
4317 * @param {string} listType |
|
4318 * @param {boolean} trimTrailing |
|
4319 * @returns {string} |
|
4320 */ |
|
4321 function parseConsecutiveLists (list, listType, trimTrailing) { |
|
4322 // check if we caught 2 or more consecutive lists by mistake |
|
4323 // we use the counterRgx, meaning if listType is UL we look for OL and vice versa |
|
4324 var olRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?\d+\.[ \t]/gm : /^ {0,3}\d+\.[ \t]/gm, |
|
4325 ulRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?[*+-][ \t]/gm : /^ {0,3}[*+-][ \t]/gm, |
|
4326 counterRxg = (listType === 'ul') ? olRgx : ulRgx, |
|
4327 result = ''; |
|
4328 |
|
4329 if (list.search(counterRxg) !== -1) { |
|
4330 (function parseCL (txt) { |
|
4331 var pos = txt.search(counterRxg), |
|
4332 style = styleStartNumber(list, listType); |
|
4333 if (pos !== -1) { |
|
4334 // slice |
|
4335 result += '\n\n<' + listType + style + '>\n' + processListItems(txt.slice(0, pos), !!trimTrailing) + '</' + listType + '>\n'; |
|
4336 |
|
4337 // invert counterType and listType |
|
4338 listType = (listType === 'ul') ? 'ol' : 'ul'; |
|
4339 counterRxg = (listType === 'ul') ? olRgx : ulRgx; |
|
4340 |
|
4341 //recurse |
|
4342 parseCL(txt.slice(pos)); |
|
4343 } else { |
|
4344 result += '\n\n<' + listType + style + '>\n' + processListItems(txt, !!trimTrailing) + '</' + listType + '>\n'; |
|
4345 } |
|
4346 })(list); |
|
4347 } else { |
|
4348 var style = styleStartNumber(list, listType); |
|
4349 result = '\n\n<' + listType + style + '>\n' + processListItems(list, !!trimTrailing) + '</' + listType + '>\n'; |
|
4350 } |
|
4351 |
|
4352 return result; |
|
4353 } |
|
4354 |
|
4355 /** Start of list parsing **/ |
|
4356 text = globals.converter._dispatch('lists.before', text, options, globals); |
|
4357 // add sentinel to hack around khtml/safari bug: |
|
4358 // http://bugs.webkit.org/show_bug.cgi?id=11231 |
|
4359 text += '¨0'; |
|
4360 |
|
4361 if (globals.gListLevel) { |
|
4362 text = text.replace(/^(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm, |
|
4363 function (wholeMatch, list, m2) { |
|
4364 var listType = (m2.search(/[*+-]/g) > -1) ? 'ul' : 'ol'; |
|
4365 return parseConsecutiveLists(list, listType, true); |
|
4366 } |
|
4367 ); |
|
4368 } else { |
|
4369 text = text.replace(/(\n\n|^\n?)(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm, |
|
4370 function (wholeMatch, m1, list, m3) { |
|
4371 var listType = (m3.search(/[*+-]/g) > -1) ? 'ul' : 'ol'; |
|
4372 return parseConsecutiveLists(list, listType, false); |
|
4373 } |
|
4374 ); |
|
4375 } |
|
4376 |
|
4377 // strip sentinel |
|
4378 text = text.replace(/¨0/, ''); |
|
4379 text = globals.converter._dispatch('lists.after', text, options, globals); |
|
4380 return text; |
|
4381 }); |
|
4382 |
|
4383 /** |
|
4384 * Parse metadata at the top of the document |
|
4385 */ |
|
4386 showdown.subParser('metadata', function (text, options, globals) { |
|
4387 'use strict'; |
|
4388 |
|
4389 if (!options.metadata) { |
|
4390 return text; |
|
4391 } |
|
4392 |
|
4393 text = globals.converter._dispatch('metadata.before', text, options, globals); |
|
4394 |
|
4395 function parseMetadataContents (content) { |
|
4396 // raw is raw so it's not changed in any way |
|
4397 globals.metadata.raw = content; |
|
4398 |
|
4399 // escape chars forbidden in html attributes |
|
4400 // double quotes |
|
4401 content = content |
|
4402 // ampersand first |
|
4403 .replace(/&/g, '&') |
|
4404 // double quotes |
|
4405 .replace(/"/g, '"'); |
|
4406 |
|
4407 content = content.replace(/\n {4}/g, ' '); |
|
4408 content.replace(/^([\S ]+): +([\s\S]+?)$/gm, function (wm, key, value) { |
|
4409 globals.metadata.parsed[key] = value; |
|
4410 return ''; |
|
4411 }); |
|
4412 } |
|
4413 |
|
4414 text = text.replace(/^\s*«««+(\S*?)\n([\s\S]+?)\n»»»+\n/, function (wholematch, format, content) { |
|
4415 parseMetadataContents(content); |
|
4416 return '¨M'; |
|
4417 }); |
|
4418 |
|
4419 text = text.replace(/^\s*---+(\S*?)\n([\s\S]+?)\n---+\n/, function (wholematch, format, content) { |
|
4420 if (format) { |
|
4421 globals.metadata.format = format; |
|
4422 } |
|
4423 parseMetadataContents(content); |
|
4424 return '¨M'; |
|
4425 }); |
|
4426 |
|
4427 text = text.replace(/¨M/g, ''); |
|
4428 |
|
4429 text = globals.converter._dispatch('metadata.after', text, options, globals); |
|
4430 return text; |
|
4431 }); |
|
4432 |
|
4433 /** |
|
4434 * Remove one level of line-leading tabs or spaces |
|
4435 */ |
|
4436 showdown.subParser('outdent', function (text, options, globals) { |
|
4437 'use strict'; |
|
4438 text = globals.converter._dispatch('outdent.before', text, options, globals); |
|
4439 |
|
4440 // attacklab: hack around Konqueror 3.5.4 bug: |
|
4441 // "----------bug".replace(/^-/g,"") == "bug" |
|
4442 text = text.replace(/^(\t|[ ]{1,4})/gm, '¨0'); // attacklab: g_tab_width |
|
4443 |
|
4444 // attacklab: clean up hack |
|
4445 text = text.replace(/¨0/g, ''); |
|
4446 |
|
4447 text = globals.converter._dispatch('outdent.after', text, options, globals); |
|
4448 return text; |
|
4449 }); |
|
4450 |
|
4451 /** |
|
4452 * |
|
4453 */ |
|
4454 showdown.subParser('paragraphs', function (text, options, globals) { |
|
4455 'use strict'; |
|
4456 |
|
4457 text = globals.converter._dispatch('paragraphs.before', text, options, globals); |
|
4458 // Strip leading and trailing lines: |
|
4459 text = text.replace(/^\n+/g, ''); |
|
4460 text = text.replace(/\n+$/g, ''); |
|
4461 |
|
4462 var grafs = text.split(/\n{2,}/g), |
|
4463 grafsOut = [], |
|
4464 end = grafs.length; // Wrap <p> tags |
|
4465 |
|
4466 for (var i = 0; i < end; i++) { |
|
4467 var str = grafs[i]; |
|
4468 // if this is an HTML marker, copy it |
|
4469 if (str.search(/¨(K|G)(\d+)\1/g) >= 0) { |
|
4470 grafsOut.push(str); |
|
4471 |
|
4472 // test for presence of characters to prevent empty lines being parsed |
|
4473 // as paragraphs (resulting in undesired extra empty paragraphs) |
|
4474 } else if (str.search(/\S/) >= 0) { |
|
4475 str = showdown.subParser('spanGamut')(str, options, globals); |
|
4476 str = str.replace(/^([ \t]*)/g, '<p>'); |
|
4477 str += '</p>'; |
|
4478 grafsOut.push(str); |
|
4479 } |
|
4480 } |
|
4481 |
|
4482 /** Unhashify HTML blocks */ |
|
4483 end = grafsOut.length; |
|
4484 for (i = 0; i < end; i++) { |
|
4485 var blockText = '', |
|
4486 grafsOutIt = grafsOut[i], |
|
4487 codeFlag = false; |
|
4488 // if this is a marker for an html block... |
|
4489 // use RegExp.test instead of string.search because of QML bug |
|
4490 while (/¨(K|G)(\d+)\1/.test(grafsOutIt)) { |
|
4491 var delim = RegExp.$1, |
|
4492 num = RegExp.$2; |
|
4493 |
|
4494 if (delim === 'K') { |
|
4495 blockText = globals.gHtmlBlocks[num]; |
|
4496 } else { |
|
4497 // we need to check if ghBlock is a false positive |
|
4498 if (codeFlag) { |
|
4499 // use encoded version of all text |
|
4500 blockText = showdown.subParser('encodeCode')(globals.ghCodeBlocks[num].text, options, globals); |
|
4501 } else { |
|
4502 blockText = globals.ghCodeBlocks[num].codeblock; |
|
4503 } |
|
4504 } |
|
4505 blockText = blockText.replace(/\$/g, '$$$$'); // Escape any dollar signs |
|
4506 |
|
4507 grafsOutIt = grafsOutIt.replace(/(\n\n)?¨(K|G)\d+\2(\n\n)?/, blockText); |
|
4508 // Check if grafsOutIt is a pre->code |
|
4509 if (/^<pre\b[^>]*>\s*<code\b[^>]*>/.test(grafsOutIt)) { |
|
4510 codeFlag = true; |
|
4511 } |
|
4512 } |
|
4513 grafsOut[i] = grafsOutIt; |
|
4514 } |
|
4515 text = grafsOut.join('\n'); |
|
4516 // Strip leading and trailing lines: |
|
4517 text = text.replace(/^\n+/g, ''); |
|
4518 text = text.replace(/\n+$/g, ''); |
|
4519 return globals.converter._dispatch('paragraphs.after', text, options, globals); |
|
4520 }); |
|
4521 |
|
4522 /** |
|
4523 * Run extension |
|
4524 */ |
|
4525 showdown.subParser('runExtension', function (ext, text, options, globals) { |
|
4526 'use strict'; |
|
4527 |
|
4528 if (ext.filter) { |
|
4529 text = ext.filter(text, globals.converter, options); |
|
4530 |
|
4531 } else if (ext.regex) { |
|
4532 // TODO remove this when old extension loading mechanism is deprecated |
|
4533 var re = ext.regex; |
|
4534 if (!(re instanceof RegExp)) { |
|
4535 re = new RegExp(re, 'g'); |
|
4536 } |
|
4537 text = text.replace(re, ext.replace); |
|
4538 } |
|
4539 |
|
4540 return text; |
|
4541 }); |
|
4542 |
|
4543 /** |
|
4544 * These are all the transformations that occur *within* block-level |
|
4545 * tags like paragraphs, headers, and list items. |
|
4546 */ |
|
4547 showdown.subParser('spanGamut', function (text, options, globals) { |
|
4548 'use strict'; |
|
4549 |
|
4550 text = globals.converter._dispatch('spanGamut.before', text, options, globals); |
|
4551 text = showdown.subParser('codeSpans')(text, options, globals); |
|
4552 text = showdown.subParser('escapeSpecialCharsWithinTagAttributes')(text, options, globals); |
|
4553 text = showdown.subParser('encodeBackslashEscapes')(text, options, globals); |
|
4554 |
|
4555 // Process anchor and image tags. Images must come first, |
|
4556 // because ![foo][f] looks like an anchor. |
|
4557 text = showdown.subParser('images')(text, options, globals); |
|
4558 text = showdown.subParser('anchors')(text, options, globals); |
|
4559 |
|
4560 // Make links out of things like `<http://example.com/>` |
|
4561 // Must come after anchors, because you can use < and > |
|
4562 // delimiters in inline links like [this](<url>). |
|
4563 text = showdown.subParser('autoLinks')(text, options, globals); |
|
4564 text = showdown.subParser('simplifiedAutoLinks')(text, options, globals); |
|
4565 text = showdown.subParser('emoji')(text, options, globals); |
|
4566 text = showdown.subParser('underline')(text, options, globals); |
|
4567 text = showdown.subParser('italicsAndBold')(text, options, globals); |
|
4568 text = showdown.subParser('strikethrough')(text, options, globals); |
|
4569 text = showdown.subParser('ellipsis')(text, options, globals); |
|
4570 |
|
4571 // we need to hash HTML tags inside spans |
|
4572 text = showdown.subParser('hashHTMLSpans')(text, options, globals); |
|
4573 |
|
4574 // now we encode amps and angles |
|
4575 text = showdown.subParser('encodeAmpsAndAngles')(text, options, globals); |
|
4576 |
|
4577 // Do hard breaks |
|
4578 if (options.simpleLineBreaks) { |
|
4579 // GFM style hard breaks |
|
4580 // only add line breaks if the text does not contain a block (special case for lists) |
|
4581 if (!/\n\n¨K/.test(text)) { |
|
4582 text = text.replace(/\n+/g, '<br />\n'); |
|
4583 } |
|
4584 } else { |
|
4585 // Vanilla hard breaks |
|
4586 text = text.replace(/ +\n/g, '<br />\n'); |
|
4587 } |
|
4588 |
|
4589 text = globals.converter._dispatch('spanGamut.after', text, options, globals); |
|
4590 return text; |
|
4591 }); |
|
4592 |
|
4593 showdown.subParser('strikethrough', function (text, options, globals) { |
|
4594 'use strict'; |
|
4595 |
|
4596 function parseInside (txt) { |
|
4597 if (options.simplifiedAutoLink) { |
|
4598 txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals); |
|
4599 } |
|
4600 return '<del>' + txt + '</del>'; |
|
4601 } |
|
4602 |
|
4603 if (options.strikethrough) { |
|
4604 text = globals.converter._dispatch('strikethrough.before', text, options, globals); |
|
4605 text = text.replace(/(?:~){2}([\s\S]+?)(?:~){2}/g, function (wm, txt) { return parseInside(txt); }); |
|
4606 text = globals.converter._dispatch('strikethrough.after', text, options, globals); |
|
4607 } |
|
4608 |
|
4609 return text; |
|
4610 }); |
|
4611 |
|
4612 /** |
|
4613 * Strips link definitions from text, stores the URLs and titles in |
|
4614 * hash references. |
|
4615 * Link defs are in the form: ^[id]: url "optional title" |
|
4616 */ |
|
4617 showdown.subParser('stripLinkDefinitions', function (text, options, globals) { |
|
4618 'use strict'; |
|
4619 |
|
4620 var regex = /^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*<?([^>\s]+)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=¨0))/gm, |
|
4621 base64Regex = /^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*<?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n\n|(?=¨0)|(?=\n\[))/gm; |
|
4622 |
|
4623 // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug |
|
4624 text += '¨0'; |
|
4625 |
|
4626 var replaceFunc = function (wholeMatch, linkId, url, width, height, blankLines, title) { |
|
4627 linkId = linkId.toLowerCase(); |
|
4628 if (url.match(/^data:.+?\/.+?;base64,/)) { |
|
4629 // remove newlines |
|
4630 globals.gUrls[linkId] = url.replace(/\s/g, ''); |
|
4631 } else { |
|
4632 globals.gUrls[linkId] = showdown.subParser('encodeAmpsAndAngles')(url, options, globals); // Link IDs are case-insensitive |
|
4633 } |
|
4634 |
|
4635 if (blankLines) { |
|
4636 // Oops, found blank lines, so it's not a title. |
|
4637 // Put back the parenthetical statement we stole. |
|
4638 return blankLines + title; |
|
4639 |
|
4640 } else { |
|
4641 if (title) { |
|
4642 globals.gTitles[linkId] = title.replace(/"|'/g, '"'); |
|
4643 } |
|
4644 if (options.parseImgDimensions && width && height) { |
|
4645 globals.gDimensions[linkId] = { |
|
4646 width: width, |
|
4647 height: height |
|
4648 }; |
|
4649 } |
|
4650 } |
|
4651 // Completely remove the definition from the text |
|
4652 return ''; |
|
4653 }; |
|
4654 |
|
4655 // first we try to find base64 link references |
|
4656 text = text.replace(base64Regex, replaceFunc); |
|
4657 |
|
4658 text = text.replace(regex, replaceFunc); |
|
4659 |
|
4660 // attacklab: strip sentinel |
|
4661 text = text.replace(/¨0/, ''); |
|
4662 |
|
4663 return text; |
|
4664 }); |
|
4665 |
|
4666 showdown.subParser('tables', function (text, options, globals) { |
|
4667 'use strict'; |
|
4668 |
|
4669 if (!options.tables) { |
|
4670 return text; |
|
4671 } |
|
4672 |
|
4673 var tableRgx = /^ {0,3}\|?.+\|.+\n {0,3}\|?[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:[-=]){2,}[\s\S]+?(?:\n\n|¨0)/gm, |
|
4674 //singeColTblRgx = /^ {0,3}\|.+\|\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n(?: {0,3}\|.+\|\n)+(?:\n\n|¨0)/gm; |
|
4675 singeColTblRgx = /^ {0,3}\|.+\|[ \t]*\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n( {0,3}\|.+\|[ \t]*\n)*(?:\n|¨0)/gm; |
|
4676 |
|
4677 function parseStyles (sLine) { |
|
4678 if (/^:[ \t]*--*$/.test(sLine)) { |
|
4679 return ' style="text-align:left;"'; |
|
4680 } else if (/^--*[ \t]*:[ \t]*$/.test(sLine)) { |
|
4681 return ' style="text-align:right;"'; |
|
4682 } else if (/^:[ \t]*--*[ \t]*:$/.test(sLine)) { |
|
4683 return ' style="text-align:center;"'; |
|
4684 } else { |
|
4685 return ''; |
|
4686 } |
|
4687 } |
|
4688 |
|
4689 function parseHeaders (header, style) { |
|
4690 var id = ''; |
|
4691 header = header.trim(); |
|
4692 // support both tablesHeaderId and tableHeaderId due to error in documentation so we don't break backwards compatibility |
|
4693 if (options.tablesHeaderId || options.tableHeaderId) { |
|
4694 id = ' id="' + header.replace(/ /g, '_').toLowerCase() + '"'; |
|
4695 } |
|
4696 header = showdown.subParser('spanGamut')(header, options, globals); |
|
4697 |
|
4698 return '<th' + id + style + '>' + header + '</th>\n'; |
|
4699 } |
|
4700 |
|
4701 function parseCells (cell, style) { |
|
4702 var subText = showdown.subParser('spanGamut')(cell, options, globals); |
|
4703 return '<td' + style + '>' + subText + '</td>\n'; |
|
4704 } |
|
4705 |
|
4706 function buildTable (headers, cells) { |
|
4707 var tb = '<table>\n<thead>\n<tr>\n', |
|
4708 tblLgn = headers.length; |
|
4709 |
|
4710 for (var i = 0; i < tblLgn; ++i) { |
|
4711 tb += headers[i]; |
|
4712 } |
|
4713 tb += '</tr>\n</thead>\n<tbody>\n'; |
|
4714 |
|
4715 for (i = 0; i < cells.length; ++i) { |
|
4716 tb += '<tr>\n'; |
|
4717 for (var ii = 0; ii < tblLgn; ++ii) { |
|
4718 tb += cells[i][ii]; |
|
4719 } |
|
4720 tb += '</tr>\n'; |
|
4721 } |
|
4722 tb += '</tbody>\n</table>\n'; |
|
4723 return tb; |
|
4724 } |
|
4725 |
|
4726 function parseTable (rawTable) { |
|
4727 var i, tableLines = rawTable.split('\n'); |
|
4728 |
|
4729 for (i = 0; i < tableLines.length; ++i) { |
|
4730 // strip wrong first and last column if wrapped tables are used |
|
4731 if (/^ {0,3}\|/.test(tableLines[i])) { |
|
4732 tableLines[i] = tableLines[i].replace(/^ {0,3}\|/, ''); |
|
4733 } |
|
4734 if (/\|[ \t]*$/.test(tableLines[i])) { |
|
4735 tableLines[i] = tableLines[i].replace(/\|[ \t]*$/, ''); |
|
4736 } |
|
4737 // parse code spans first, but we only support one line code spans |
|
4738 tableLines[i] = showdown.subParser('codeSpans')(tableLines[i], options, globals); |
|
4739 } |
|
4740 |
|
4741 var rawHeaders = tableLines[0].split('|').map(function (s) { return s.trim();}), |
|
4742 rawStyles = tableLines[1].split('|').map(function (s) { return s.trim();}), |
|
4743 rawCells = [], |
|
4744 headers = [], |
|
4745 styles = [], |
|
4746 cells = []; |
|
4747 |
|
4748 tableLines.shift(); |
|
4749 tableLines.shift(); |
|
4750 |
|
4751 for (i = 0; i < tableLines.length; ++i) { |
|
4752 if (tableLines[i].trim() === '') { |
|
4753 continue; |
|
4754 } |
|
4755 rawCells.push( |
|
4756 tableLines[i] |
|
4757 .split('|') |
|
4758 .map(function (s) { |
|
4759 return s.trim(); |
|
4760 }) |
|
4761 ); |
|
4762 } |
|
4763 |
|
4764 if (rawHeaders.length < rawStyles.length) { |
|
4765 return rawTable; |
|
4766 } |
|
4767 |
|
4768 for (i = 0; i < rawStyles.length; ++i) { |
|
4769 styles.push(parseStyles(rawStyles[i])); |
|
4770 } |
|
4771 |
|
4772 for (i = 0; i < rawHeaders.length; ++i) { |
|
4773 if (showdown.helper.isUndefined(styles[i])) { |
|
4774 styles[i] = ''; |
|
4775 } |
|
4776 headers.push(parseHeaders(rawHeaders[i], styles[i])); |
|
4777 } |
|
4778 |
|
4779 for (i = 0; i < rawCells.length; ++i) { |
|
4780 var row = []; |
|
4781 for (var ii = 0; ii < headers.length; ++ii) { |
|
4782 if (showdown.helper.isUndefined(rawCells[i][ii])) { |
|
4783 |
|
4784 } |
|
4785 row.push(parseCells(rawCells[i][ii], styles[ii])); |
|
4786 } |
|
4787 cells.push(row); |
|
4788 } |
|
4789 |
|
4790 return buildTable(headers, cells); |
|
4791 } |
|
4792 |
|
4793 text = globals.converter._dispatch('tables.before', text, options, globals); |
|
4794 |
|
4795 // find escaped pipe characters |
|
4796 text = text.replace(/\\(\|)/g, showdown.helper.escapeCharactersCallback); |
|
4797 |
|
4798 // parse multi column tables |
|
4799 text = text.replace(tableRgx, parseTable); |
|
4800 |
|
4801 // parse one column tables |
|
4802 text = text.replace(singeColTblRgx, parseTable); |
|
4803 |
|
4804 text = globals.converter._dispatch('tables.after', text, options, globals); |
|
4805 |
|
4806 return text; |
|
4807 }); |
|
4808 |
|
4809 showdown.subParser('underline', function (text, options, globals) { |
|
4810 'use strict'; |
|
4811 |
|
4812 if (!options.underline) { |
|
4813 return text; |
|
4814 } |
|
4815 |
|
4816 text = globals.converter._dispatch('underline.before', text, options, globals); |
|
4817 |
|
4818 if (options.literalMidWordUnderscores) { |
|
4819 text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function (wm, txt) { |
|
4820 return '<u>' + txt + '</u>'; |
|
4821 }); |
|
4822 text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function (wm, txt) { |
|
4823 return '<u>' + txt + '</u>'; |
|
4824 }); |
|
4825 } else { |
|
4826 text = text.replace(/___(\S[\s\S]*?)___/g, function (wm, m) { |
|
4827 return (/\S$/.test(m)) ? '<u>' + m + '</u>' : wm; |
|
4828 }); |
|
4829 text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) { |
|
4830 return (/\S$/.test(m)) ? '<u>' + m + '</u>' : wm; |
|
4831 }); |
|
4832 } |
|
4833 |
|
4834 // escape remaining underscores to prevent them being parsed by italic and bold |
|
4835 text = text.replace(/(_)/g, showdown.helper.escapeCharactersCallback); |
|
4836 |
|
4837 text = globals.converter._dispatch('underline.after', text, options, globals); |
|
4838 |
|
4839 return text; |
|
4840 }); |
|
4841 |
|
4842 /** |
|
4843 * Swap back in all the special characters we've hidden. |
|
4844 */ |
|
4845 showdown.subParser('unescapeSpecialChars', function (text, options, globals) { |
|
4846 'use strict'; |
|
4847 text = globals.converter._dispatch('unescapeSpecialChars.before', text, options, globals); |
|
4848 |
|
4849 text = text.replace(/¨E(\d+)E/g, function (wholeMatch, m1) { |
|
4850 var charCodeToReplace = parseInt(m1); |
|
4851 return String.fromCharCode(charCodeToReplace); |
|
4852 }); |
|
4853 |
|
4854 text = globals.converter._dispatch('unescapeSpecialChars.after', text, options, globals); |
|
4855 return text; |
|
4856 }); |
|
4857 |
|
4858 showdown.subParser('makeMarkdown.blockquote', function (node, globals) { |
|
4859 'use strict'; |
|
4860 |
|
4861 var txt = ''; |
|
4862 if (node.hasChildNodes()) { |
|
4863 var children = node.childNodes, |
|
4864 childrenLength = children.length; |
|
4865 |
|
4866 for (var i = 0; i < childrenLength; ++i) { |
|
4867 var innerTxt = showdown.subParser('makeMarkdown.node')(children[i], globals); |
|
4868 |
|
4869 if (innerTxt === '') { |
|
4870 continue; |
|
4871 } |
|
4872 txt += innerTxt; |
|
4873 } |
|
4874 } |
|
4875 // cleanup |
|
4876 txt = txt.trim(); |
|
4877 txt = '> ' + txt.split('\n').join('\n> '); |
|
4878 return txt; |
|
4879 }); |
|
4880 |
|
4881 showdown.subParser('makeMarkdown.codeBlock', function (node, globals) { |
|
4882 'use strict'; |
|
4883 |
|
4884 var lang = node.getAttribute('language'), |
|
4885 num = node.getAttribute('precodenum'); |
|
4886 return '```' + lang + '\n' + globals.preList[num] + '\n```'; |
|
4887 }); |
|
4888 |
|
4889 showdown.subParser('makeMarkdown.codeSpan', function (node) { |
|
4890 'use strict'; |
|
4891 |
|
4892 return '`' + node.innerHTML + '`'; |
|
4893 }); |
|
4894 |
|
4895 showdown.subParser('makeMarkdown.emphasis', function (node, globals) { |
|
4896 'use strict'; |
|
4897 |
|
4898 var txt = ''; |
|
4899 if (node.hasChildNodes()) { |
|
4900 txt += '*'; |
|
4901 var children = node.childNodes, |
|
4902 childrenLength = children.length; |
|
4903 for (var i = 0; i < childrenLength; ++i) { |
|
4904 txt += showdown.subParser('makeMarkdown.node')(children[i], globals); |
|
4905 } |
|
4906 txt += '*'; |
|
4907 } |
|
4908 return txt; |
|
4909 }); |
|
4910 |
|
4911 showdown.subParser('makeMarkdown.header', function (node, globals, headerLevel) { |
|
4912 'use strict'; |
|
4913 |
|
4914 var headerMark = new Array(headerLevel + 1).join('#'), |
|
4915 txt = ''; |
|
4916 |
|
4917 if (node.hasChildNodes()) { |
|
4918 txt = headerMark + ' '; |
|
4919 var children = node.childNodes, |
|
4920 childrenLength = children.length; |
|
4921 |
|
4922 for (var i = 0; i < childrenLength; ++i) { |
|
4923 txt += showdown.subParser('makeMarkdown.node')(children[i], globals); |
|
4924 } |
|
4925 } |
|
4926 return txt; |
|
4927 }); |
|
4928 |
|
4929 showdown.subParser('makeMarkdown.hr', function () { |
|
4930 'use strict'; |
|
4931 |
|
4932 return '---'; |
|
4933 }); |
|
4934 |
|
4935 showdown.subParser('makeMarkdown.image', function (node) { |
|
4936 'use strict'; |
|
4937 |
|
4938 var txt = ''; |
|
4939 if (node.hasAttribute('src')) { |
|
4940 txt += ' + '>'; |
|
4942 if (node.hasAttribute('width') && node.hasAttribute('height')) { |
|
4943 txt += ' =' + node.getAttribute('width') + 'x' + node.getAttribute('height'); |
|
4944 } |
|
4945 |
|
4946 if (node.hasAttribute('title')) { |
|
4947 txt += ' "' + node.getAttribute('title') + '"'; |
|
4948 } |
|
4949 txt += ')'; |
|
4950 } |
|
4951 return txt; |
|
4952 }); |
|
4953 |
|
4954 showdown.subParser('makeMarkdown.links', function (node, globals) { |
|
4955 'use strict'; |
|
4956 |
|
4957 var txt = ''; |
|
4958 if (node.hasChildNodes() && node.hasAttribute('href')) { |
|
4959 var children = node.childNodes, |
|
4960 childrenLength = children.length; |
|
4961 txt = '['; |
|
4962 for (var i = 0; i < childrenLength; ++i) { |
|
4963 txt += showdown.subParser('makeMarkdown.node')(children[i], globals); |
|
4964 } |
|
4965 txt += ']('; |
|
4966 txt += '<' + node.getAttribute('href') + '>'; |
|
4967 if (node.hasAttribute('title')) { |
|
4968 txt += ' "' + node.getAttribute('title') + '"'; |
|
4969 } |
|
4970 txt += ')'; |
|
4971 } |
|
4972 return txt; |
|
4973 }); |
|
4974 |
|
4975 showdown.subParser('makeMarkdown.list', function (node, globals, type) { |
|
4976 'use strict'; |
|
4977 |
|
4978 var txt = ''; |
|
4979 if (!node.hasChildNodes()) { |
|
4980 return ''; |
|
4981 } |
|
4982 var listItems = node.childNodes, |
|
4983 listItemsLenght = listItems.length, |
|
4984 listNum = node.getAttribute('start') || 1; |
|
4985 |
|
4986 for (var i = 0; i < listItemsLenght; ++i) { |
|
4987 if (typeof listItems[i].tagName === 'undefined' || listItems[i].tagName.toLowerCase() !== 'li') { |
|
4988 continue; |
|
4989 } |
|
4990 |
|
4991 // define the bullet to use in list |
|
4992 var bullet = ''; |
|
4993 if (type === 'ol') { |
|
4994 bullet = listNum.toString() + '. '; |
|
4995 } else { |
|
4996 bullet = '- '; |
|
4997 } |
|
4998 |
|
4999 // parse list item |
|
5000 txt += bullet + showdown.subParser('makeMarkdown.listItem')(listItems[i], globals); |
|
5001 ++listNum; |
|
5002 } |
|
5003 |
|
5004 // add comment at the end to prevent consecutive lists to be parsed as one |
|
5005 txt += '\n<!-- -->\n'; |
|
5006 return txt.trim(); |
|
5007 }); |
|
5008 |
|
5009 showdown.subParser('makeMarkdown.listItem', function (node, globals) { |
|
5010 'use strict'; |
|
5011 |
|
5012 var listItemTxt = ''; |
|
5013 |
|
5014 var children = node.childNodes, |
|
5015 childrenLenght = children.length; |
|
5016 |
|
5017 for (var i = 0; i < childrenLenght; ++i) { |
|
5018 listItemTxt += showdown.subParser('makeMarkdown.node')(children[i], globals); |
|
5019 } |
|
5020 // if it's only one liner, we need to add a newline at the end |
|
5021 if (!/\n$/.test(listItemTxt)) { |
|
5022 listItemTxt += '\n'; |
|
5023 } else { |
|
5024 // it's multiparagraph, so we need to indent |
|
5025 listItemTxt = listItemTxt |
|
5026 .split('\n') |
|
5027 .join('\n ') |
|
5028 .replace(/^ {4}$/gm, '') |
|
5029 .replace(/\n\n+/g, '\n\n'); |
|
5030 } |
|
5031 |
|
5032 return listItemTxt; |
|
5033 }); |
|
5034 |
|
5035 |
|
5036 |
|
5037 showdown.subParser('makeMarkdown.node', function (node, globals, spansOnly) { |
|
5038 'use strict'; |
|
5039 |
|
5040 spansOnly = spansOnly || false; |
|
5041 |
|
5042 var txt = ''; |
|
5043 |
|
5044 // edge case of text without wrapper paragraph |
|
5045 if (node.nodeType === 3) { |
|
5046 return showdown.subParser('makeMarkdown.txt')(node, globals); |
|
5047 } |
|
5048 |
|
5049 // HTML comment |
|
5050 if (node.nodeType === 8) { |
|
5051 return '<!--' + node.data + '-->\n\n'; |
|
5052 } |
|
5053 |
|
5054 // process only node elements |
|
5055 if (node.nodeType !== 1) { |
|
5056 return ''; |
|
5057 } |
|
5058 |
|
5059 var tagName = node.tagName.toLowerCase(); |
|
5060 |
|
5061 switch (tagName) { |
|
5062 |
|
5063 // |
|
5064 // BLOCKS |
|
5065 // |
|
5066 case 'h1': |
|
5067 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 1) + '\n\n'; } |
|
5068 break; |
|
5069 case 'h2': |
|
5070 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 2) + '\n\n'; } |
|
5071 break; |
|
5072 case 'h3': |
|
5073 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 3) + '\n\n'; } |
|
5074 break; |
|
5075 case 'h4': |
|
5076 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 4) + '\n\n'; } |
|
5077 break; |
|
5078 case 'h5': |
|
5079 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 5) + '\n\n'; } |
|
5080 break; |
|
5081 case 'h6': |
|
5082 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 6) + '\n\n'; } |
|
5083 break; |
|
5084 |
|
5085 case 'p': |
|
5086 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.paragraph')(node, globals) + '\n\n'; } |
|
5087 break; |
|
5088 |
|
5089 case 'blockquote': |
|
5090 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.blockquote')(node, globals) + '\n\n'; } |
|
5091 break; |
|
5092 |
|
5093 case 'hr': |
|
5094 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.hr')(node, globals) + '\n\n'; } |
|
5095 break; |
|
5096 |
|
5097 case 'ol': |
|
5098 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.list')(node, globals, 'ol') + '\n\n'; } |
|
5099 break; |
|
5100 |
|
5101 case 'ul': |
|
5102 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.list')(node, globals, 'ul') + '\n\n'; } |
|
5103 break; |
|
5104 |
|
5105 case 'precode': |
|
5106 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.codeBlock')(node, globals) + '\n\n'; } |
|
5107 break; |
|
5108 |
|
5109 case 'pre': |
|
5110 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.pre')(node, globals) + '\n\n'; } |
|
5111 break; |
|
5112 |
|
5113 case 'table': |
|
5114 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.table')(node, globals) + '\n\n'; } |
|
5115 break; |
|
5116 |
|
5117 // |
|
5118 // SPANS |
|
5119 // |
|
5120 case 'code': |
|
5121 txt = showdown.subParser('makeMarkdown.codeSpan')(node, globals); |
|
5122 break; |
|
5123 |
|
5124 case 'em': |
|
5125 case 'i': |
|
5126 txt = showdown.subParser('makeMarkdown.emphasis')(node, globals); |
|
5127 break; |
|
5128 |
|
5129 case 'strong': |
|
5130 case 'b': |
|
5131 txt = showdown.subParser('makeMarkdown.strong')(node, globals); |
|
5132 break; |
|
5133 |
|
5134 case 'del': |
|
5135 txt = showdown.subParser('makeMarkdown.strikethrough')(node, globals); |
|
5136 break; |
|
5137 |
|
5138 case 'a': |
|
5139 txt = showdown.subParser('makeMarkdown.links')(node, globals); |
|
5140 break; |
|
5141 |
|
5142 case 'img': |
|
5143 txt = showdown.subParser('makeMarkdown.image')(node, globals); |
|
5144 break; |
|
5145 |
|
5146 default: |
|
5147 txt = node.outerHTML + '\n\n'; |
|
5148 } |
|
5149 |
|
5150 // common normalization |
|
5151 // TODO eventually |
|
5152 |
|
5153 return txt; |
|
5154 }); |
|
5155 |
|
5156 showdown.subParser('makeMarkdown.paragraph', function (node, globals) { |
|
5157 'use strict'; |
|
5158 |
|
5159 var txt = ''; |
|
5160 if (node.hasChildNodes()) { |
|
5161 var children = node.childNodes, |
|
5162 childrenLength = children.length; |
|
5163 for (var i = 0; i < childrenLength; ++i) { |
|
5164 txt += showdown.subParser('makeMarkdown.node')(children[i], globals); |
|
5165 } |
|
5166 } |
|
5167 |
|
5168 // some text normalization |
|
5169 txt = txt.trim(); |
|
5170 |
|
5171 return txt; |
|
5172 }); |
|
5173 |
|
5174 showdown.subParser('makeMarkdown.pre', function (node, globals) { |
|
5175 'use strict'; |
|
5176 |
|
5177 var num = node.getAttribute('prenum'); |
|
5178 return '<pre>' + globals.preList[num] + '</pre>'; |
|
5179 }); |
|
5180 |
|
5181 showdown.subParser('makeMarkdown.strikethrough', function (node, globals) { |
|
5182 'use strict'; |
|
5183 |
|
5184 var txt = ''; |
|
5185 if (node.hasChildNodes()) { |
|
5186 txt += '~~'; |
|
5187 var children = node.childNodes, |
|
5188 childrenLength = children.length; |
|
5189 for (var i = 0; i < childrenLength; ++i) { |
|
5190 txt += showdown.subParser('makeMarkdown.node')(children[i], globals); |
|
5191 } |
|
5192 txt += '~~'; |
|
5193 } |
|
5194 return txt; |
|
5195 }); |
|
5196 |
|
5197 showdown.subParser('makeMarkdown.strong', function (node, globals) { |
|
5198 'use strict'; |
|
5199 |
|
5200 var txt = ''; |
|
5201 if (node.hasChildNodes()) { |
|
5202 txt += '**'; |
|
5203 var children = node.childNodes, |
|
5204 childrenLength = children.length; |
|
5205 for (var i = 0; i < childrenLength; ++i) { |
|
5206 txt += showdown.subParser('makeMarkdown.node')(children[i], globals); |
|
5207 } |
|
5208 txt += '**'; |
|
5209 } |
|
5210 return txt; |
|
5211 }); |
|
5212 |
|
5213 showdown.subParser('makeMarkdown.table', function (node, globals) { |
|
5214 'use strict'; |
|
5215 |
|
5216 var txt = '', |
|
5217 tableArray = [[], []], |
|
5218 headings = node.querySelectorAll('thead>tr>th'), |
|
5219 rows = node.querySelectorAll('tbody>tr'), |
|
5220 i, ii; |
|
5221 for (i = 0; i < headings.length; ++i) { |
|
5222 var headContent = showdown.subParser('makeMarkdown.tableCell')(headings[i], globals), |
|
5223 allign = '---'; |
|
5224 |
|
5225 if (headings[i].hasAttribute('style')) { |
|
5226 var style = headings[i].getAttribute('style').toLowerCase().replace(/\s/g, ''); |
|
5227 switch (style) { |
|
5228 case 'text-align:left;': |
|
5229 allign = ':---'; |
|
5230 break; |
|
5231 case 'text-align:right;': |
|
5232 allign = '---:'; |
|
5233 break; |
|
5234 case 'text-align:center;': |
|
5235 allign = ':---:'; |
|
5236 break; |
|
5237 } |
|
5238 } |
|
5239 tableArray[0][i] = headContent.trim(); |
|
5240 tableArray[1][i] = allign; |
|
5241 } |
|
5242 |
|
5243 for (i = 0; i < rows.length; ++i) { |
|
5244 var r = tableArray.push([]) - 1, |
|
5245 cols = rows[i].getElementsByTagName('td'); |
|
5246 |
|
5247 for (ii = 0; ii < headings.length; ++ii) { |
|
5248 var cellContent = ' '; |
|
5249 if (typeof cols[ii] !== 'undefined') { |
|
5250 cellContent = showdown.subParser('makeMarkdown.tableCell')(cols[ii], globals); |
|
5251 } |
|
5252 tableArray[r].push(cellContent); |
|
5253 } |
|
5254 } |
|
5255 |
|
5256 var cellSpacesCount = 3; |
|
5257 for (i = 0; i < tableArray.length; ++i) { |
|
5258 for (ii = 0; ii < tableArray[i].length; ++ii) { |
|
5259 var strLen = tableArray[i][ii].length; |
|
5260 if (strLen > cellSpacesCount) { |
|
5261 cellSpacesCount = strLen; |
|
5262 } |
|
5263 } |
|
5264 } |
|
5265 |
|
5266 for (i = 0; i < tableArray.length; ++i) { |
|
5267 for (ii = 0; ii < tableArray[i].length; ++ii) { |
|
5268 if (i === 1) { |
|
5269 if (tableArray[i][ii].slice(-1) === ':') { |
|
5270 tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii].slice(-1), cellSpacesCount - 1, '-') + ':'; |
|
5271 } else { |
|
5272 tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii], cellSpacesCount, '-'); |
|
5273 } |
|
5274 } else { |
|
5275 tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii], cellSpacesCount); |
|
5276 } |
|
5277 } |
|
5278 txt += '| ' + tableArray[i].join(' | ') + ' |\n'; |
|
5279 } |
|
5280 |
|
5281 return txt.trim(); |
|
5282 }); |
|
5283 |
|
5284 showdown.subParser('makeMarkdown.tableCell', function (node, globals) { |
|
5285 'use strict'; |
|
5286 |
|
5287 var txt = ''; |
|
5288 if (!node.hasChildNodes()) { |
|
5289 return ''; |
|
5290 } |
|
5291 var children = node.childNodes, |
|
5292 childrenLength = children.length; |
|
5293 |
|
5294 for (var i = 0; i < childrenLength; ++i) { |
|
5295 txt += showdown.subParser('makeMarkdown.node')(children[i], globals, true); |
|
5296 } |
|
5297 return txt.trim(); |
|
5298 }); |
|
5299 |
|
5300 showdown.subParser('makeMarkdown.txt', function (node) { |
|
5301 'use strict'; |
|
5302 |
|
5303 var txt = node.nodeValue; |
|
5304 |
|
5305 // multiple spaces are collapsed |
|
5306 txt = txt.replace(/ +/g, ' '); |
|
5307 |
|
5308 // replace the custom ¨NBSP; with a space |
|
5309 txt = txt.replace(/¨NBSP;/g, ' '); |
|
5310 |
|
5311 // ", <, > and & should replace escaped html entities |
|
5312 txt = showdown.helper.unescapeHTMLEntities(txt); |
|
5313 |
|
5314 // escape markdown magic characters |
|
5315 // emphasis, strong and strikethrough - can appear everywhere |
|
5316 // we also escape pipe (|) because of tables |
|
5317 // and escape ` because of code blocks and spans |
|
5318 txt = txt.replace(/([*_~|`])/g, '\\$1'); |
|
5319 |
|
5320 // escape > because of blockquotes |
|
5321 txt = txt.replace(/^(\s*)>/g, '\\$1>'); |
|
5322 |
|
5323 // hash character, only troublesome at the beginning of a line because of headers |
|
5324 txt = txt.replace(/^#/gm, '\\#'); |
|
5325 |
|
5326 // horizontal rules |
|
5327 txt = txt.replace(/^(\s*)([-=]{3,})(\s*)$/, '$1\\$2$3'); |
|
5328 |
|
5329 // dot, because of ordered lists, only troublesome at the beginning of a line when preceded by an integer |
|
5330 txt = txt.replace(/^( {0,3}\d+)\./gm, '$1\\.'); |
|
5331 |
|
5332 // +, * and -, at the beginning of a line becomes a list, so we need to escape them also (asterisk was already escaped) |
|
5333 txt = txt.replace(/^( {0,3})([+-])/gm, '$1\\$2'); |
|
5334 |
|
5335 // images and links, ] followed by ( is problematic, so we escape it |
|
5336 txt = txt.replace(/]([\s]*)\(/g, '\\]$1\\('); |
|
5337 |
|
5338 // reference URIs must also be escaped |
|
5339 txt = txt.replace(/^ {0,3}\[([\S \t]*?)]:/gm, '\\[$1]:'); |
|
5340 |
|
5341 return txt; |
|
5342 }); |
|
5343 |
|
5344 var root = this; |
|
5345 |
|
5346 // AMD Loader |
|
5347 if (true) { |
|
5348 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () { |
|
5349 'use strict'; |
|
5350 return showdown; |
|
5351 }).call(exports, __webpack_require__, exports, module), |
|
5352 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
|
5353 |
|
5354 // CommonJS/nodeJS Loader |
|
5355 } else {} |
|
5356 }).call(this); |
|
5357 |
|
5358 |
|
5359 |
|
5360 /***/ }), |
|
5361 |
|
5362 /***/ 24: |
|
5363 /***/ (function(module, exports) { |
|
5364 |
|
5365 (function() { module.exports = this["wp"]["dom"]; }()); |
|
5366 |
|
5367 /***/ }), |
|
5368 |
|
5369 /***/ 26: |
|
5370 /***/ (function(module, exports) { |
|
5371 |
|
5372 (function() { module.exports = this["wp"]["hooks"]; }()); |
|
5373 |
|
5374 /***/ }), |
|
5375 |
|
5376 /***/ 28: |
|
5377 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
5378 |
|
5379 "use strict"; |
|
5380 |
|
5381 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js |
|
5382 var arrayWithHoles = __webpack_require__(37); |
|
5383 |
|
5384 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js |
|
5385 function _iterableToArrayLimit(arr, i) { |
|
5386 var _arr = []; |
|
5387 var _n = true; |
|
5388 var _d = false; |
|
5389 var _e = undefined; |
|
5390 |
|
5391 try { |
|
5392 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { |
|
5393 _arr.push(_s.value); |
|
5394 |
|
5395 if (i && _arr.length === i) break; |
|
5396 } |
|
5397 } catch (err) { |
|
5398 _d = true; |
|
5399 _e = err; |
|
5400 } finally { |
|
5401 try { |
|
5402 if (!_n && _i["return"] != null) _i["return"](); |
|
5403 } finally { |
|
5404 if (_d) throw _e; |
|
5405 } |
|
5406 } |
|
5407 |
|
5408 return _arr; |
|
5409 } |
|
5410 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js |
|
5411 var nonIterableRest = __webpack_require__(38); |
|
5412 |
|
5413 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js |
|
5414 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _slicedToArray; }); |
|
5415 |
|
5416 |
|
5417 |
|
5418 function _slicedToArray(arr, i) { |
|
5419 return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(nonIterableRest["a" /* default */])(); |
|
5420 } |
|
5421 |
|
5422 /***/ }), |
|
5423 |
|
5424 /***/ 30: |
|
5425 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
5426 |
|
5427 "use strict"; |
|
5428 |
|
5429 |
|
5430 var LEAF_KEY, hasWeakMap; |
|
5431 |
|
5432 /** |
|
5433 * Arbitrary value used as key for referencing cache object in WeakMap tree. |
|
5434 * |
|
5435 * @type {Object} |
|
5436 */ |
|
5437 LEAF_KEY = {}; |
|
5438 |
|
5439 /** |
|
5440 * Whether environment supports WeakMap. |
|
5441 * |
|
5442 * @type {boolean} |
|
5443 */ |
|
5444 hasWeakMap = typeof WeakMap !== 'undefined'; |
|
5445 |
|
5446 /** |
|
5447 * Returns the first argument as the sole entry in an array. |
|
5448 * |
|
5449 * @param {*} value Value to return. |
|
5450 * |
|
5451 * @return {Array} Value returned as entry in array. |
|
5452 */ |
|
5453 function arrayOf( value ) { |
|
5454 return [ value ]; |
|
5455 } |
|
5456 |
|
5457 /** |
|
5458 * Returns true if the value passed is object-like, or false otherwise. A value |
|
5459 * is object-like if it can support property assignment, e.g. object or array. |
|
5460 * |
|
5461 * @param {*} value Value to test. |
|
5462 * |
|
5463 * @return {boolean} Whether value is object-like. |
|
5464 */ |
|
5465 function isObjectLike( value ) { |
|
5466 return !! value && 'object' === typeof value; |
|
5467 } |
|
5468 |
|
5469 /** |
|
5470 * Creates and returns a new cache object. |
|
5471 * |
|
5472 * @return {Object} Cache object. |
|
5473 */ |
|
5474 function createCache() { |
|
5475 var cache = { |
|
5476 clear: function() { |
|
5477 cache.head = null; |
|
5478 }, |
|
5479 }; |
|
5480 |
|
5481 return cache; |
|
5482 } |
|
5483 |
|
5484 /** |
|
5485 * Returns true if entries within the two arrays are strictly equal by |
|
5486 * reference from a starting index. |
|
5487 * |
|
5488 * @param {Array} a First array. |
|
5489 * @param {Array} b Second array. |
|
5490 * @param {number} fromIndex Index from which to start comparison. |
|
5491 * |
|
5492 * @return {boolean} Whether arrays are shallowly equal. |
|
5493 */ |
|
5494 function isShallowEqual( a, b, fromIndex ) { |
|
5495 var i; |
|
5496 |
|
5497 if ( a.length !== b.length ) { |
|
5498 return false; |
|
5499 } |
|
5500 |
|
5501 for ( i = fromIndex; i < a.length; i++ ) { |
|
5502 if ( a[ i ] !== b[ i ] ) { |
|
5503 return false; |
|
5504 } |
|
5505 } |
|
5506 |
|
5507 return true; |
|
5508 } |
|
5509 |
|
5510 /** |
|
5511 * Returns a memoized selector function. The getDependants function argument is |
|
5512 * called before the memoized selector and is expected to return an immutable |
|
5513 * reference or array of references on which the selector depends for computing |
|
5514 * its own return value. The memoize cache is preserved only as long as those |
|
5515 * dependant references remain the same. If getDependants returns a different |
|
5516 * reference(s), the cache is cleared and the selector value regenerated. |
|
5517 * |
|
5518 * @param {Function} selector Selector function. |
|
5519 * @param {Function} getDependants Dependant getter returning an immutable |
|
5520 * reference or array of reference used in |
|
5521 * cache bust consideration. |
|
5522 * |
|
5523 * @return {Function} Memoized selector. |
|
5524 */ |
|
5525 /* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) { |
|
5526 var rootCache, getCache; |
|
5527 |
|
5528 // Use object source as dependant if getter not provided |
|
5529 if ( ! getDependants ) { |
|
5530 getDependants = arrayOf; |
|
5531 } |
|
5532 |
|
5533 /** |
|
5534 * Returns the root cache. If WeakMap is supported, this is assigned to the |
|
5535 * root WeakMap cache set, otherwise it is a shared instance of the default |
|
5536 * cache object. |
|
5537 * |
|
5538 * @return {(WeakMap|Object)} Root cache object. |
|
5539 */ |
|
5540 function getRootCache() { |
|
5541 return rootCache; |
|
5542 } |
|
5543 |
|
5544 /** |
|
5545 * Returns the cache for a given dependants array. When possible, a WeakMap |
|
5546 * will be used to create a unique cache for each set of dependants. This |
|
5547 * is feasible due to the nature of WeakMap in allowing garbage collection |
|
5548 * to occur on entries where the key object is no longer referenced. Since |
|
5549 * WeakMap requires the key to be an object, this is only possible when the |
|
5550 * dependant is object-like. The root cache is created as a hierarchy where |
|
5551 * each top-level key is the first entry in a dependants set, the value a |
|
5552 * WeakMap where each key is the next dependant, and so on. This continues |
|
5553 * so long as the dependants are object-like. If no dependants are object- |
|
5554 * like, then the cache is shared across all invocations. |
|
5555 * |
|
5556 * @see isObjectLike |
|
5557 * |
|
5558 * @param {Array} dependants Selector dependants. |
|
5559 * |
|
5560 * @return {Object} Cache object. |
|
5561 */ |
|
5562 function getWeakMapCache( dependants ) { |
|
5563 var caches = rootCache, |
|
5564 isUniqueByDependants = true, |
|
5565 i, dependant, map, cache; |
|
5566 |
|
5567 for ( i = 0; i < dependants.length; i++ ) { |
|
5568 dependant = dependants[ i ]; |
|
5569 |
|
5570 // Can only compose WeakMap from object-like key. |
|
5571 if ( ! isObjectLike( dependant ) ) { |
|
5572 isUniqueByDependants = false; |
|
5573 break; |
|
5574 } |
|
5575 |
|
5576 // Does current segment of cache already have a WeakMap? |
|
5577 if ( caches.has( dependant ) ) { |
|
5578 // Traverse into nested WeakMap. |
|
5579 caches = caches.get( dependant ); |
|
5580 } else { |
|
5581 // Create, set, and traverse into a new one. |
|
5582 map = new WeakMap(); |
|
5583 caches.set( dependant, map ); |
|
5584 caches = map; |
|
5585 } |
|
5586 } |
|
5587 |
|
5588 // We use an arbitrary (but consistent) object as key for the last item |
|
5589 // in the WeakMap to serve as our running cache. |
|
5590 if ( ! caches.has( LEAF_KEY ) ) { |
|
5591 cache = createCache(); |
|
5592 cache.isUniqueByDependants = isUniqueByDependants; |
|
5593 caches.set( LEAF_KEY, cache ); |
|
5594 } |
|
5595 |
|
5596 return caches.get( LEAF_KEY ); |
|
5597 } |
|
5598 |
|
5599 // Assign cache handler by availability of WeakMap |
|
5600 getCache = hasWeakMap ? getWeakMapCache : getRootCache; |
|
5601 |
|
5602 /** |
|
5603 * Resets root memoization cache. |
|
5604 */ |
|
5605 function clear() { |
|
5606 rootCache = hasWeakMap ? new WeakMap() : createCache(); |
|
5607 } |
|
5608 |
|
5609 // eslint-disable-next-line jsdoc/check-param-names |
|
5610 /** |
|
5611 * The augmented selector call, considering first whether dependants have |
|
5612 * changed before passing it to underlying memoize function. |
|
5613 * |
|
5614 * @param {Object} source Source object for derivation. |
|
5615 * @param {...*} extraArgs Additional arguments to pass to selector. |
|
5616 * |
|
5617 * @return {*} Selector result. |
|
5618 */ |
|
5619 function callSelector( /* source, ...extraArgs */ ) { |
|
5620 var len = arguments.length, |
|
5621 cache, node, i, args, dependants; |
|
5622 |
|
5623 // Create copy of arguments (avoid leaking deoptimization). |
|
5624 args = new Array( len ); |
|
5625 for ( i = 0; i < len; i++ ) { |
|
5626 args[ i ] = arguments[ i ]; |
|
5627 } |
|
5628 |
|
5629 dependants = getDependants.apply( null, args ); |
|
5630 cache = getCache( dependants ); |
|
5631 |
|
5632 // If not guaranteed uniqueness by dependants (primitive type or lack |
|
5633 // of WeakMap support), shallow compare against last dependants and, if |
|
5634 // references have changed, destroy cache to recalculate result. |
|
5635 if ( ! cache.isUniqueByDependants ) { |
|
5636 if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) { |
|
5637 cache.clear(); |
|
5638 } |
|
5639 |
|
5640 cache.lastDependants = dependants; |
|
5641 } |
|
5642 |
|
5643 node = cache.head; |
|
5644 while ( node ) { |
|
5645 // Check whether node arguments match arguments |
|
5646 if ( ! isShallowEqual( node.args, args, 1 ) ) { |
|
5647 node = node.next; |
|
5648 continue; |
|
5649 } |
|
5650 |
|
5651 // At this point we can assume we've found a match |
|
5652 |
|
5653 // Surface matched node to head if not already |
|
5654 if ( node !== cache.head ) { |
|
5655 // Adjust siblings to point to each other. |
|
5656 node.prev.next = node.next; |
|
5657 if ( node.next ) { |
|
5658 node.next.prev = node.prev; |
|
5659 } |
|
5660 |
|
5661 node.next = cache.head; |
|
5662 node.prev = null; |
|
5663 cache.head.prev = node; |
|
5664 cache.head = node; |
|
5665 } |
|
5666 |
|
5667 // Return immediately |
|
5668 return node.val; |
|
5669 } |
|
5670 |
|
5671 // No cached value found. Continue to insertion phase: |
|
5672 |
|
5673 node = { |
|
5674 // Generate the result from original function |
|
5675 val: selector.apply( null, args ), |
|
5676 }; |
|
5677 |
|
5678 // Avoid including the source object in the cache. |
|
5679 args[ 0 ] = null; |
|
5680 node.args = args; |
|
5681 |
|
5682 // Don't need to check whether node is already head, since it would |
|
5683 // have been returned above already if it was |
|
5684 |
|
5685 // Shift existing head down list |
|
5686 if ( cache.head ) { |
|
5687 cache.head.prev = node; |
|
5688 node.next = cache.head; |
|
5689 } |
|
5690 |
|
5691 cache.head = node; |
|
5692 |
|
5693 return node.val; |
|
5694 } |
|
5695 |
|
5696 callSelector.getDependants = getDependants; |
|
5697 callSelector.clear = clear; |
|
5698 clear(); |
|
5699 |
|
5700 return callSelector; |
|
5701 }); |
|
5702 |
|
5703 |
|
5704 /***/ }), |
|
5705 |
|
5706 /***/ 34: |
|
5707 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
5708 |
|
5709 "use strict"; |
|
5710 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; }); |
|
5711 function _iterableToArray(iter) { |
|
5712 if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); |
|
5713 } |
|
5714 |
|
5715 /***/ }), |
|
5716 |
|
5717 /***/ 35: |
|
5718 /***/ (function(module, exports) { |
|
5719 |
|
5720 (function() { module.exports = this["wp"]["blob"]; }()); |
|
5721 |
|
5722 /***/ }), |
|
5723 |
|
5724 /***/ 362: |
|
5725 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
5726 |
|
5727 "use strict"; |
|
5728 __webpack_require__.r(__webpack_exports__); |
|
5729 var selectors_namespaceObject = {}; |
|
5730 __webpack_require__.r(selectors_namespaceObject); |
|
5731 __webpack_require__.d(selectors_namespaceObject, "getBlockTypes", function() { return getBlockTypes; }); |
|
5732 __webpack_require__.d(selectors_namespaceObject, "getBlockType", function() { return getBlockType; }); |
|
5733 __webpack_require__.d(selectors_namespaceObject, "getBlockStyles", function() { return getBlockStyles; }); |
|
5734 __webpack_require__.d(selectors_namespaceObject, "getCategories", function() { return getCategories; }); |
|
5735 __webpack_require__.d(selectors_namespaceObject, "getDefaultBlockName", function() { return getDefaultBlockName; }); |
|
5736 __webpack_require__.d(selectors_namespaceObject, "getFreeformFallbackBlockName", function() { return getFreeformFallbackBlockName; }); |
|
5737 __webpack_require__.d(selectors_namespaceObject, "getUnregisteredFallbackBlockName", function() { return getUnregisteredFallbackBlockName; }); |
|
5738 __webpack_require__.d(selectors_namespaceObject, "getChildBlockNames", function() { return selectors_getChildBlockNames; }); |
|
5739 __webpack_require__.d(selectors_namespaceObject, "getBlockSupport", function() { return selectors_getBlockSupport; }); |
|
5740 __webpack_require__.d(selectors_namespaceObject, "hasBlockSupport", function() { return hasBlockSupport; }); |
|
5741 __webpack_require__.d(selectors_namespaceObject, "isMatchingSearchTerm", function() { return isMatchingSearchTerm; }); |
|
5742 __webpack_require__.d(selectors_namespaceObject, "hasChildBlocks", function() { return selectors_hasChildBlocks; }); |
|
5743 __webpack_require__.d(selectors_namespaceObject, "hasChildBlocksWithInserterSupport", function() { return selectors_hasChildBlocksWithInserterSupport; }); |
|
5744 var actions_namespaceObject = {}; |
|
5745 __webpack_require__.r(actions_namespaceObject); |
|
5746 __webpack_require__.d(actions_namespaceObject, "addBlockTypes", function() { return addBlockTypes; }); |
|
5747 __webpack_require__.d(actions_namespaceObject, "removeBlockTypes", function() { return removeBlockTypes; }); |
|
5748 __webpack_require__.d(actions_namespaceObject, "addBlockStyles", function() { return addBlockStyles; }); |
|
5749 __webpack_require__.d(actions_namespaceObject, "removeBlockStyles", function() { return removeBlockStyles; }); |
|
5750 __webpack_require__.d(actions_namespaceObject, "setDefaultBlockName", function() { return setDefaultBlockName; }); |
|
5751 __webpack_require__.d(actions_namespaceObject, "setFreeformFallbackBlockName", function() { return setFreeformFallbackBlockName; }); |
|
5752 __webpack_require__.d(actions_namespaceObject, "setUnregisteredFallbackBlockName", function() { return setUnregisteredFallbackBlockName; }); |
|
5753 __webpack_require__.d(actions_namespaceObject, "setCategories", function() { return setCategories; }); |
|
5754 __webpack_require__.d(actions_namespaceObject, "updateCategory", function() { return updateCategory; }); |
|
5755 |
|
5756 // EXTERNAL MODULE: external {"this":["wp","data"]} |
|
5757 var external_this_wp_data_ = __webpack_require__(5); |
|
5758 |
|
5759 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js |
|
5760 var defineProperty = __webpack_require__(15); |
|
5761 |
|
5762 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules |
|
5763 var toConsumableArray = __webpack_require__(17); |
|
5764 |
|
5765 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread.js |
|
5766 var objectSpread = __webpack_require__(7); |
|
5767 |
|
5768 // EXTERNAL MODULE: external "lodash" |
|
5769 var external_lodash_ = __webpack_require__(2); |
|
5770 |
|
5771 // EXTERNAL MODULE: external {"this":["wp","i18n"]} |
|
5772 var external_this_wp_i18n_ = __webpack_require__(1); |
|
5773 |
|
5774 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/reducer.js |
|
5775 |
|
5776 |
|
5777 |
|
5778 |
|
5779 /** |
|
5780 * External dependencies |
|
5781 */ |
|
5782 |
|
5783 /** |
|
5784 * WordPress dependencies |
|
5785 */ |
|
5786 |
|
5787 |
|
5788 |
|
5789 /** |
|
5790 * Module Constants |
|
5791 */ |
|
5792 |
|
5793 var DEFAULT_CATEGORIES = [{ |
|
5794 slug: 'common', |
|
5795 title: Object(external_this_wp_i18n_["__"])('Common Blocks') |
|
5796 }, { |
|
5797 slug: 'formatting', |
|
5798 title: Object(external_this_wp_i18n_["__"])('Formatting') |
|
5799 }, { |
|
5800 slug: 'layout', |
|
5801 title: Object(external_this_wp_i18n_["__"])('Layout Elements') |
|
5802 }, { |
|
5803 slug: 'widgets', |
|
5804 title: Object(external_this_wp_i18n_["__"])('Widgets') |
|
5805 }, { |
|
5806 slug: 'embed', |
|
5807 title: Object(external_this_wp_i18n_["__"])('Embeds') |
|
5808 }, { |
|
5809 slug: 'reusable', |
|
5810 title: Object(external_this_wp_i18n_["__"])('Reusable Blocks') |
|
5811 }]; |
|
5812 /** |
|
5813 * Reducer managing the block types |
|
5814 * |
|
5815 * @param {Object} state Current state. |
|
5816 * @param {Object} action Dispatched action. |
|
5817 * |
|
5818 * @return {Object} Updated state. |
|
5819 */ |
|
5820 |
|
5821 function reducer_blockTypes() { |
|
5822 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
5823 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
5824 |
|
5825 switch (action.type) { |
|
5826 case 'ADD_BLOCK_TYPES': |
|
5827 return Object(objectSpread["a" /* default */])({}, state, Object(external_lodash_["keyBy"])(Object(external_lodash_["map"])(action.blockTypes, function (blockType) { |
|
5828 return Object(external_lodash_["omit"])(blockType, 'styles '); |
|
5829 }), 'name')); |
|
5830 |
|
5831 case 'REMOVE_BLOCK_TYPES': |
|
5832 return Object(external_lodash_["omit"])(state, action.names); |
|
5833 } |
|
5834 |
|
5835 return state; |
|
5836 } |
|
5837 /** |
|
5838 * Reducer managing the block style variations. |
|
5839 * |
|
5840 * @param {Object} state Current state. |
|
5841 * @param {Object} action Dispatched action. |
|
5842 * |
|
5843 * @return {Object} Updated state. |
|
5844 */ |
|
5845 |
|
5846 function blockStyles() { |
|
5847 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
5848 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
5849 |
|
5850 switch (action.type) { |
|
5851 case 'ADD_BLOCK_TYPES': |
|
5852 return Object(objectSpread["a" /* default */])({}, state, Object(external_lodash_["mapValues"])(Object(external_lodash_["keyBy"])(action.blockTypes, 'name'), function (blockType) { |
|
5853 return Object(external_lodash_["uniqBy"])([].concat(Object(toConsumableArray["a" /* default */])(Object(external_lodash_["get"])(blockType, ['styles'], [])), Object(toConsumableArray["a" /* default */])(Object(external_lodash_["get"])(state, [blockType.name], []))), function (style) { |
|
5854 return style.name; |
|
5855 }); |
|
5856 })); |
|
5857 |
|
5858 case 'ADD_BLOCK_STYLES': |
|
5859 return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, action.blockName, Object(external_lodash_["uniqBy"])([].concat(Object(toConsumableArray["a" /* default */])(Object(external_lodash_["get"])(state, [action.blockName], [])), Object(toConsumableArray["a" /* default */])(action.styles)), function (style) { |
|
5860 return style.name; |
|
5861 }))); |
|
5862 |
|
5863 case 'REMOVE_BLOCK_STYLES': |
|
5864 return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, action.blockName, Object(external_lodash_["filter"])(Object(external_lodash_["get"])(state, [action.blockName], []), function (style) { |
|
5865 return action.styleNames.indexOf(style.name) === -1; |
|
5866 }))); |
|
5867 } |
|
5868 |
|
5869 return state; |
|
5870 } |
|
5871 /** |
|
5872 * Higher-order Reducer creating a reducer keeping track of given block name. |
|
5873 * |
|
5874 * @param {string} setActionType Action type. |
|
5875 * |
|
5876 * @return {function} Reducer. |
|
5877 */ |
|
5878 |
|
5879 function createBlockNameSetterReducer(setActionType) { |
|
5880 return function () { |
|
5881 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; |
|
5882 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
5883 |
|
5884 switch (action.type) { |
|
5885 case 'REMOVE_BLOCK_TYPES': |
|
5886 if (action.names.indexOf(state) !== -1) { |
|
5887 return null; |
|
5888 } |
|
5889 |
|
5890 return state; |
|
5891 |
|
5892 case setActionType: |
|
5893 return action.name || null; |
|
5894 } |
|
5895 |
|
5896 return state; |
|
5897 }; |
|
5898 } |
|
5899 var reducer_defaultBlockName = createBlockNameSetterReducer('SET_DEFAULT_BLOCK_NAME'); |
|
5900 var freeformFallbackBlockName = createBlockNameSetterReducer('SET_FREEFORM_FALLBACK_BLOCK_NAME'); |
|
5901 var unregisteredFallbackBlockName = createBlockNameSetterReducer('SET_UNREGISTERED_FALLBACK_BLOCK_NAME'); |
|
5902 /** |
|
5903 * Reducer managing the categories |
|
5904 * |
|
5905 * @param {Object} state Current state. |
|
5906 * @param {Object} action Dispatched action. |
|
5907 * |
|
5908 * @return {Object} Updated state. |
|
5909 */ |
|
5910 |
|
5911 function reducer_categories() { |
|
5912 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_CATEGORIES; |
|
5913 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
5914 |
|
5915 switch (action.type) { |
|
5916 case 'SET_CATEGORIES': |
|
5917 return action.categories || []; |
|
5918 |
|
5919 case 'UPDATE_CATEGORY': |
|
5920 { |
|
5921 if (!action.category || Object(external_lodash_["isEmpty"])(action.category)) { |
|
5922 return state; |
|
5923 } |
|
5924 |
|
5925 var categoryToChange = Object(external_lodash_["find"])(state, ['slug', action.slug]); |
|
5926 |
|
5927 if (categoryToChange) { |
|
5928 return Object(external_lodash_["map"])(state, function (category) { |
|
5929 if (category.slug === action.slug) { |
|
5930 return Object(objectSpread["a" /* default */])({}, category, action.category); |
|
5931 } |
|
5932 |
|
5933 return category; |
|
5934 }); |
|
5935 } |
|
5936 } |
|
5937 } |
|
5938 |
|
5939 return state; |
|
5940 } |
|
5941 /* harmony default export */ var reducer = (Object(external_this_wp_data_["combineReducers"])({ |
|
5942 blockTypes: reducer_blockTypes, |
|
5943 blockStyles: blockStyles, |
|
5944 defaultBlockName: reducer_defaultBlockName, |
|
5945 freeformFallbackBlockName: freeformFallbackBlockName, |
|
5946 unregisteredFallbackBlockName: unregisteredFallbackBlockName, |
|
5947 categories: reducer_categories |
|
5948 })); |
|
5949 |
|
5950 // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js |
|
5951 var rememo = __webpack_require__(30); |
|
5952 |
|
5953 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/selectors.js |
|
5954 /** |
|
5955 * External dependencies |
|
5956 */ |
|
5957 |
|
5958 |
|
5959 /** |
|
5960 * Given a block name or block type object, returns the corresponding |
|
5961 * normalized block type object. |
|
5962 * |
|
5963 * @param {Object} state Blocks state. |
|
5964 * @param {(string|Object)} nameOrType Block name or type object |
|
5965 * |
|
5966 * @return {Object} Block type object. |
|
5967 */ |
|
5968 |
|
5969 var getNormalizedBlockType = function getNormalizedBlockType(state, nameOrType) { |
|
5970 return 'string' === typeof nameOrType ? getBlockType(state, nameOrType) : nameOrType; |
|
5971 }; |
|
5972 /** |
|
5973 * Returns all the available block types. |
|
5974 * |
|
5975 * @param {Object} state Data state. |
|
5976 * |
|
5977 * @return {Array} Block Types. |
|
5978 */ |
|
5979 |
|
5980 |
|
5981 var getBlockTypes = Object(rememo["a" /* default */])(function (state) { |
|
5982 return Object.values(state.blockTypes); |
|
5983 }, function (state) { |
|
5984 return [state.blockTypes]; |
|
5985 }); |
|
5986 /** |
|
5987 * Returns a block type by name. |
|
5988 * |
|
5989 * @param {Object} state Data state. |
|
5990 * @param {string} name Block type name. |
|
5991 * |
|
5992 * @return {Object?} Block Type. |
|
5993 */ |
|
5994 |
|
5995 function getBlockType(state, name) { |
|
5996 return state.blockTypes[name]; |
|
5997 } |
|
5998 /** |
|
5999 * Returns block styles by block name. |
|
6000 * |
|
6001 * @param {Object} state Data state. |
|
6002 * @param {string} name Block type name. |
|
6003 * |
|
6004 * @return {Array?} Block Styles. |
|
6005 */ |
|
6006 |
|
6007 function getBlockStyles(state, name) { |
|
6008 return state.blockStyles[name]; |
|
6009 } |
|
6010 /** |
|
6011 * Returns all the available categories. |
|
6012 * |
|
6013 * @param {Object} state Data state. |
|
6014 * |
|
6015 * @return {Array} Categories list. |
|
6016 */ |
|
6017 |
|
6018 function getCategories(state) { |
|
6019 return state.categories; |
|
6020 } |
|
6021 /** |
|
6022 * Returns the name of the default block name. |
|
6023 * |
|
6024 * @param {Object} state Data state. |
|
6025 * |
|
6026 * @return {string?} Default block name. |
|
6027 */ |
|
6028 |
|
6029 function getDefaultBlockName(state) { |
|
6030 return state.defaultBlockName; |
|
6031 } |
|
6032 /** |
|
6033 * Returns the name of the block for handling non-block content. |
|
6034 * |
|
6035 * @param {Object} state Data state. |
|
6036 * |
|
6037 * @return {string?} Name of the block for handling non-block content. |
|
6038 */ |
|
6039 |
|
6040 function getFreeformFallbackBlockName(state) { |
|
6041 return state.freeformFallbackBlockName; |
|
6042 } |
|
6043 /** |
|
6044 * Returns the name of the block for handling unregistered blocks. |
|
6045 * |
|
6046 * @param {Object} state Data state. |
|
6047 * |
|
6048 * @return {string?} Name of the block for handling unregistered blocks. |
|
6049 */ |
|
6050 |
|
6051 function getUnregisteredFallbackBlockName(state) { |
|
6052 return state.unregisteredFallbackBlockName; |
|
6053 } |
|
6054 /** |
|
6055 * Returns an array with the child blocks of a given block. |
|
6056 * |
|
6057 * @param {Object} state Data state. |
|
6058 * @param {string} blockName Block type name. |
|
6059 * |
|
6060 * @return {Array} Array of child block names. |
|
6061 */ |
|
6062 |
|
6063 var selectors_getChildBlockNames = Object(rememo["a" /* default */])(function (state, blockName) { |
|
6064 return Object(external_lodash_["map"])(Object(external_lodash_["filter"])(state.blockTypes, function (blockType) { |
|
6065 return Object(external_lodash_["includes"])(blockType.parent, blockName); |
|
6066 }), function (_ref) { |
|
6067 var name = _ref.name; |
|
6068 return name; |
|
6069 }); |
|
6070 }, function (state) { |
|
6071 return [state.blockTypes]; |
|
6072 }); |
|
6073 /** |
|
6074 * Returns the block support value for a feature, if defined. |
|
6075 * |
|
6076 * @param {Object} state Data state. |
|
6077 * @param {(string|Object)} nameOrType Block name or type object |
|
6078 * @param {string} feature Feature to retrieve |
|
6079 * @param {*} defaultSupports Default value to return if not |
|
6080 * explicitly defined |
|
6081 * |
|
6082 * @return {?*} Block support value |
|
6083 */ |
|
6084 |
|
6085 var selectors_getBlockSupport = function getBlockSupport(state, nameOrType, feature, defaultSupports) { |
|
6086 var blockType = getNormalizedBlockType(state, nameOrType); |
|
6087 return Object(external_lodash_["get"])(blockType, ['supports', feature], defaultSupports); |
|
6088 }; |
|
6089 /** |
|
6090 * Returns true if the block defines support for a feature, or false otherwise. |
|
6091 * |
|
6092 * @param {Object} state Data state. |
|
6093 * @param {(string|Object)} nameOrType Block name or type object. |
|
6094 * @param {string} feature Feature to test. |
|
6095 * @param {boolean} defaultSupports Whether feature is supported by |
|
6096 * default if not explicitly defined. |
|
6097 * |
|
6098 * @return {boolean} Whether block supports feature. |
|
6099 */ |
|
6100 |
|
6101 function hasBlockSupport(state, nameOrType, feature, defaultSupports) { |
|
6102 return !!selectors_getBlockSupport(state, nameOrType, feature, defaultSupports); |
|
6103 } |
|
6104 /** |
|
6105 * Returns true if the block type by the given name or object value matches a |
|
6106 * search term, or false otherwise. |
|
6107 * |
|
6108 * @param {Object} state Blocks state. |
|
6109 * @param {(string|Object)} nameOrType Block name or type object. |
|
6110 * @param {string} searchTerm Search term by which to filter. |
|
6111 * |
|
6112 * @return {Object[]} Wheter block type matches search term. |
|
6113 */ |
|
6114 |
|
6115 function isMatchingSearchTerm(state, nameOrType, searchTerm) { |
|
6116 var blockType = getNormalizedBlockType(state, nameOrType); |
|
6117 var getNormalizedSearchTerm = Object(external_lodash_["flow"])([// Disregard diacritics. |
|
6118 // Input: "média" |
|
6119 external_lodash_["deburr"], // Lowercase. |
|
6120 // Input: "MEDIA" |
|
6121 function (term) { |
|
6122 return term.toLowerCase(); |
|
6123 }, // Strip leading and trailing whitespace. |
|
6124 // Input: " media " |
|
6125 function (term) { |
|
6126 return term.trim(); |
|
6127 }]); |
|
6128 var normalizedSearchTerm = getNormalizedSearchTerm(searchTerm); |
|
6129 var isSearchMatch = Object(external_lodash_["flow"])([getNormalizedSearchTerm, function (normalizedCandidate) { |
|
6130 return Object(external_lodash_["includes"])(normalizedCandidate, normalizedSearchTerm); |
|
6131 }]); |
|
6132 return isSearchMatch(blockType.title) || Object(external_lodash_["some"])(blockType.keywords, isSearchMatch) || isSearchMatch(blockType.category); |
|
6133 } |
|
6134 /** |
|
6135 * Returns a boolean indicating if a block has child blocks or not. |
|
6136 * |
|
6137 * @param {Object} state Data state. |
|
6138 * @param {string} blockName Block type name. |
|
6139 * |
|
6140 * @return {boolean} True if a block contains child blocks and false otherwise. |
|
6141 */ |
|
6142 |
|
6143 var selectors_hasChildBlocks = function hasChildBlocks(state, blockName) { |
|
6144 return selectors_getChildBlockNames(state, blockName).length > 0; |
|
6145 }; |
|
6146 /** |
|
6147 * Returns a boolean indicating if a block has at least one child block with inserter support. |
|
6148 * |
|
6149 * @param {Object} state Data state. |
|
6150 * @param {string} blockName Block type name. |
|
6151 * |
|
6152 * @return {boolean} True if a block contains at least one child blocks with inserter support |
|
6153 * and false otherwise. |
|
6154 */ |
|
6155 |
|
6156 var selectors_hasChildBlocksWithInserterSupport = function hasChildBlocksWithInserterSupport(state, blockName) { |
|
6157 return Object(external_lodash_["some"])(selectors_getChildBlockNames(state, blockName), function (childBlockName) { |
|
6158 return hasBlockSupport(state, childBlockName, 'inserter', true); |
|
6159 }); |
|
6160 }; |
|
6161 |
|
6162 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/actions.js |
|
6163 /** |
|
6164 * External dependencies |
|
6165 */ |
|
6166 |
|
6167 /** |
|
6168 * Returns an action object used in signalling that block types have been added. |
|
6169 * |
|
6170 * @param {Array|Object} blockTypes Block types received. |
|
6171 * |
|
6172 * @return {Object} Action object. |
|
6173 */ |
|
6174 |
|
6175 function addBlockTypes(blockTypes) { |
|
6176 return { |
|
6177 type: 'ADD_BLOCK_TYPES', |
|
6178 blockTypes: Object(external_lodash_["castArray"])(blockTypes) |
|
6179 }; |
|
6180 } |
|
6181 /** |
|
6182 * Returns an action object used to remove a registered block type. |
|
6183 * |
|
6184 * @param {string|Array} names Block name. |
|
6185 * |
|
6186 * @return {Object} Action object. |
|
6187 */ |
|
6188 |
|
6189 function removeBlockTypes(names) { |
|
6190 return { |
|
6191 type: 'REMOVE_BLOCK_TYPES', |
|
6192 names: Object(external_lodash_["castArray"])(names) |
|
6193 }; |
|
6194 } |
|
6195 /** |
|
6196 * Returns an action object used in signalling that new block styles have been added. |
|
6197 * |
|
6198 * @param {string} blockName Block name. |
|
6199 * @param {Array|Object} styles Block styles. |
|
6200 * |
|
6201 * @return {Object} Action object. |
|
6202 */ |
|
6203 |
|
6204 function addBlockStyles(blockName, styles) { |
|
6205 return { |
|
6206 type: 'ADD_BLOCK_STYLES', |
|
6207 styles: Object(external_lodash_["castArray"])(styles), |
|
6208 blockName: blockName |
|
6209 }; |
|
6210 } |
|
6211 /** |
|
6212 * Returns an action object used in signalling that block styles have been removed. |
|
6213 * |
|
6214 * @param {string} blockName Block name. |
|
6215 * @param {Array|string} styleNames Block style names. |
|
6216 * |
|
6217 * @return {Object} Action object. |
|
6218 */ |
|
6219 |
|
6220 function removeBlockStyles(blockName, styleNames) { |
|
6221 return { |
|
6222 type: 'REMOVE_BLOCK_STYLES', |
|
6223 styleNames: Object(external_lodash_["castArray"])(styleNames), |
|
6224 blockName: blockName |
|
6225 }; |
|
6226 } |
|
6227 /** |
|
6228 * Returns an action object used to set the default block name. |
|
6229 * |
|
6230 * @param {string} name Block name. |
|
6231 * |
|
6232 * @return {Object} Action object. |
|
6233 */ |
|
6234 |
|
6235 function setDefaultBlockName(name) { |
|
6236 return { |
|
6237 type: 'SET_DEFAULT_BLOCK_NAME', |
|
6238 name: name |
|
6239 }; |
|
6240 } |
|
6241 /** |
|
6242 * Returns an action object used to set the name of the block used as a fallback |
|
6243 * for non-block content. |
|
6244 * |
|
6245 * @param {string} name Block name. |
|
6246 * |
|
6247 * @return {Object} Action object. |
|
6248 */ |
|
6249 |
|
6250 function setFreeformFallbackBlockName(name) { |
|
6251 return { |
|
6252 type: 'SET_FREEFORM_FALLBACK_BLOCK_NAME', |
|
6253 name: name |
|
6254 }; |
|
6255 } |
|
6256 /** |
|
6257 * Returns an action object used to set the name of the block used as a fallback |
|
6258 * for unregistered blocks. |
|
6259 * |
|
6260 * @param {string} name Block name. |
|
6261 * |
|
6262 * @return {Object} Action object. |
|
6263 */ |
|
6264 |
|
6265 function setUnregisteredFallbackBlockName(name) { |
|
6266 return { |
|
6267 type: 'SET_UNREGISTERED_FALLBACK_BLOCK_NAME', |
|
6268 name: name |
|
6269 }; |
|
6270 } |
|
6271 /** |
|
6272 * Returns an action object used to set block categories. |
|
6273 * |
|
6274 * @param {Object[]} categories Block categories. |
|
6275 * |
|
6276 * @return {Object} Action object. |
|
6277 */ |
|
6278 |
|
6279 function setCategories(categories) { |
|
6280 return { |
|
6281 type: 'SET_CATEGORIES', |
|
6282 categories: categories |
|
6283 }; |
|
6284 } |
|
6285 /** |
|
6286 * Returns an action object used to update a category. |
|
6287 * |
|
6288 * @param {string} slug Block category slug. |
|
6289 * @param {Object} category Object containing the category properties that should be updated. |
|
6290 * |
|
6291 * @return {Object} Action object. |
|
6292 */ |
|
6293 |
|
6294 function updateCategory(slug, category) { |
|
6295 return { |
|
6296 type: 'UPDATE_CATEGORY', |
|
6297 slug: slug, |
|
6298 category: category |
|
6299 }; |
|
6300 } |
|
6301 |
|
6302 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/index.js |
|
6303 /** |
|
6304 * WordPress dependencies |
|
6305 */ |
|
6306 |
|
6307 /** |
|
6308 * Internal dependencies |
|
6309 */ |
|
6310 |
|
6311 |
|
6312 |
|
6313 |
|
6314 Object(external_this_wp_data_["registerStore"])('core/blocks', { |
|
6315 reducer: reducer, |
|
6316 selectors: selectors_namespaceObject, |
|
6317 actions: actions_namespaceObject |
|
6318 }); |
|
6319 |
|
6320 // EXTERNAL MODULE: ./node_modules/uuid/v4.js |
|
6321 var v4 = __webpack_require__(65); |
|
6322 var v4_default = /*#__PURE__*/__webpack_require__.n(v4); |
|
6323 |
|
6324 // EXTERNAL MODULE: external {"this":["wp","hooks"]} |
|
6325 var external_this_wp_hooks_ = __webpack_require__(26); |
|
6326 |
|
6327 // EXTERNAL MODULE: ./node_modules/tinycolor2/tinycolor.js |
|
6328 var tinycolor = __webpack_require__(45); |
|
6329 var tinycolor_default = /*#__PURE__*/__webpack_require__.n(tinycolor); |
|
6330 |
|
6331 // EXTERNAL MODULE: external {"this":["wp","element"]} |
|
6332 var external_this_wp_element_ = __webpack_require__(0); |
|
6333 |
|
6334 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/utils.js |
|
6335 |
|
6336 |
|
6337 /** |
|
6338 * External dependencies |
|
6339 */ |
|
6340 |
|
6341 |
|
6342 /** |
|
6343 * WordPress dependencies |
|
6344 */ |
|
6345 |
|
6346 |
|
6347 /** |
|
6348 * Internal dependencies |
|
6349 */ |
|
6350 |
|
6351 |
|
6352 |
|
6353 /** |
|
6354 * Array of icon colors containing a color to be used if the icon color |
|
6355 * was not explicitly set but the icon background color was. |
|
6356 * |
|
6357 * @type {Object} |
|
6358 */ |
|
6359 |
|
6360 var ICON_COLORS = ['#191e23', '#f8f9f9']; |
|
6361 /** |
|
6362 * Determines whether the block is a default block |
|
6363 * and its attributes are equal to the default attributes |
|
6364 * which means the block is unmodified. |
|
6365 * |
|
6366 * @param {WPBlock} block Block Object |
|
6367 * |
|
6368 * @return {boolean} Whether the block is an unmodified default block |
|
6369 */ |
|
6370 |
|
6371 function isUnmodifiedDefaultBlock(block) { |
|
6372 var defaultBlockName = registration_getDefaultBlockName(); |
|
6373 |
|
6374 if (block.name !== defaultBlockName) { |
|
6375 return false; |
|
6376 } // Cache a created default block if no cache exists or the default block |
|
6377 // name changed. |
|
6378 |
|
6379 |
|
6380 if (!isUnmodifiedDefaultBlock.block || isUnmodifiedDefaultBlock.block.name !== defaultBlockName) { |
|
6381 isUnmodifiedDefaultBlock.block = createBlock(defaultBlockName); |
|
6382 } |
|
6383 |
|
6384 var newDefaultBlock = isUnmodifiedDefaultBlock.block; |
|
6385 var blockType = registration_getBlockType(defaultBlockName); |
|
6386 return Object(external_lodash_["every"])(blockType.attributes, function (value, key) { |
|
6387 return newDefaultBlock.attributes[key] === block.attributes[key]; |
|
6388 }); |
|
6389 } |
|
6390 /** |
|
6391 * Function that checks if the parameter is a valid icon. |
|
6392 * |
|
6393 * @param {*} icon Parameter to be checked. |
|
6394 * |
|
6395 * @return {boolean} True if the parameter is a valid icon and false otherwise. |
|
6396 */ |
|
6397 |
|
6398 function isValidIcon(icon) { |
|
6399 return !!icon && (Object(external_lodash_["isString"])(icon) || Object(external_this_wp_element_["isValidElement"])(icon) || Object(external_lodash_["isFunction"])(icon) || icon instanceof external_this_wp_element_["Component"]); |
|
6400 } |
|
6401 /** |
|
6402 * Function that receives an icon as set by the blocks during the registration |
|
6403 * and returns a new icon object that is normalized so we can rely on just on possible icon structure |
|
6404 * in the codebase. |
|
6405 * |
|
6406 * @param {(Object|string|WPElement)} icon Slug of the Dashicon to be shown |
|
6407 * as the icon for the block in the |
|
6408 * inserter, or element or an object describing the icon. |
|
6409 * |
|
6410 * @return {Object} Object describing the icon. |
|
6411 */ |
|
6412 |
|
6413 function normalizeIconObject(icon) { |
|
6414 if (!icon) { |
|
6415 icon = 'block-default'; |
|
6416 } |
|
6417 |
|
6418 if (isValidIcon(icon)) { |
|
6419 return { |
|
6420 src: icon |
|
6421 }; |
|
6422 } |
|
6423 |
|
6424 if (Object(external_lodash_["has"])(icon, ['background'])) { |
|
6425 var tinyBgColor = tinycolor_default()(icon.background); |
|
6426 return Object(objectSpread["a" /* default */])({}, icon, { |
|
6427 foreground: icon.foreground ? icon.foreground : Object(tinycolor["mostReadable"])(tinyBgColor, ICON_COLORS, { |
|
6428 includeFallbackColors: true, |
|
6429 level: 'AA', |
|
6430 size: 'large' |
|
6431 }).toHexString(), |
|
6432 shadowColor: tinyBgColor.setAlpha(0.3).toRgbString() |
|
6433 }); |
|
6434 } |
|
6435 |
|
6436 return icon; |
|
6437 } |
|
6438 /** |
|
6439 * Normalizes block type passed as param. When string is passed then |
|
6440 * it converts it to the matching block type object. |
|
6441 * It passes the original object otherwise. |
|
6442 * |
|
6443 * @param {string|Object} blockTypeOrName Block type or name. |
|
6444 * |
|
6445 * @return {?Object} Block type. |
|
6446 */ |
|
6447 |
|
6448 function normalizeBlockType(blockTypeOrName) { |
|
6449 if (Object(external_lodash_["isString"])(blockTypeOrName)) { |
|
6450 return registration_getBlockType(blockTypeOrName); |
|
6451 } |
|
6452 |
|
6453 return blockTypeOrName; |
|
6454 } |
|
6455 |
|
6456 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/registration.js |
|
6457 |
|
6458 |
|
6459 /* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */ |
|
6460 |
|
6461 /** |
|
6462 * External dependencies |
|
6463 */ |
|
6464 |
|
6465 /** |
|
6466 * WordPress dependencies |
|
6467 */ |
|
6468 |
|
6469 |
|
6470 |
|
6471 /** |
|
6472 * Internal dependencies |
|
6473 */ |
|
6474 |
|
6475 |
|
6476 /** |
|
6477 * Defined behavior of a block type. |
|
6478 * |
|
6479 * @typedef {WPBlockType} |
|
6480 * |
|
6481 * @property {string} name Block's namespaced name. |
|
6482 * @property {string} title Human-readable label for a block. |
|
6483 * Shown in the block inserter. |
|
6484 * @property {string} category Category classification of block, |
|
6485 * impacting where block is shown in |
|
6486 * inserter results. |
|
6487 * @property {(Object|string|WPElement)} icon Slug of the Dashicon to be shown |
|
6488 * as the icon for the block in the |
|
6489 * inserter, or element or an object describing the icon. |
|
6490 * @property {?string[]} keywords Additional keywords to produce |
|
6491 * block as inserter search result. |
|
6492 * @property {?Object} attributes Block attributes. |
|
6493 * @property {Function} save Serialize behavior of a block, |
|
6494 * returning an element describing |
|
6495 * structure of the block's post |
|
6496 * content markup. |
|
6497 * @property {WPComponent} edit Component rendering element to be |
|
6498 * interacted with in an editor. |
|
6499 */ |
|
6500 |
|
6501 var serverSideBlockDefinitions = {}; |
|
6502 /** |
|
6503 * Set the server side block definition of blocks. |
|
6504 * |
|
6505 * @param {Object} definitions Server-side block definitions |
|
6506 */ |
|
6507 |
|
6508 function unstable__bootstrapServerSideBlockDefinitions(definitions) { |
|
6509 // eslint-disable-line camelcase |
|
6510 serverSideBlockDefinitions = definitions; |
|
6511 } |
|
6512 /** |
|
6513 * Registers a new block provided a unique name and an object defining its |
|
6514 * behavior. Once registered, the block is made available as an option to any |
|
6515 * editor interface where blocks are implemented. |
|
6516 * |
|
6517 * @param {string} name Block name. |
|
6518 * @param {Object} settings Block settings. |
|
6519 * |
|
6520 * @return {?WPBlock} The block, if it has been successfully registered; |
|
6521 * otherwise `undefined`. |
|
6522 */ |
|
6523 |
|
6524 function registerBlockType(name, settings) { |
|
6525 settings = Object(objectSpread["a" /* default */])({ |
|
6526 name: name |
|
6527 }, Object(external_lodash_["get"])(serverSideBlockDefinitions, name), settings); |
|
6528 |
|
6529 if (typeof name !== 'string') { |
|
6530 console.error('Block names must be strings.'); |
|
6531 return; |
|
6532 } |
|
6533 |
|
6534 if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(name)) { |
|
6535 console.error('Block names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-block'); |
|
6536 return; |
|
6537 } |
|
6538 |
|
6539 if (Object(external_this_wp_data_["select"])('core/blocks').getBlockType(name)) { |
|
6540 console.error('Block "' + name + '" is already registered.'); |
|
6541 return; |
|
6542 } |
|
6543 |
|
6544 settings = Object(external_this_wp_hooks_["applyFilters"])('blocks.registerBlockType', settings, name); |
|
6545 |
|
6546 if (!settings || !Object(external_lodash_["isFunction"])(settings.save)) { |
|
6547 console.error('The "save" property must be specified and must be a valid function.'); |
|
6548 return; |
|
6549 } |
|
6550 |
|
6551 if ('edit' in settings && !Object(external_lodash_["isFunction"])(settings.edit)) { |
|
6552 console.error('The "edit" property must be a valid function.'); |
|
6553 return; |
|
6554 } |
|
6555 |
|
6556 if (!('category' in settings)) { |
|
6557 console.error('The block "' + name + '" must have a category.'); |
|
6558 return; |
|
6559 } |
|
6560 |
|
6561 if ('category' in settings && !Object(external_lodash_["some"])(Object(external_this_wp_data_["select"])('core/blocks').getCategories(), { |
|
6562 slug: settings.category |
|
6563 })) { |
|
6564 console.error('The block "' + name + '" must have a registered category.'); |
|
6565 return; |
|
6566 } |
|
6567 |
|
6568 if (!('title' in settings) || settings.title === '') { |
|
6569 console.error('The block "' + name + '" must have a title.'); |
|
6570 return; |
|
6571 } |
|
6572 |
|
6573 if (typeof settings.title !== 'string') { |
|
6574 console.error('Block titles must be strings.'); |
|
6575 return; |
|
6576 } |
|
6577 |
|
6578 settings.icon = normalizeIconObject(settings.icon); |
|
6579 |
|
6580 if (!isValidIcon(settings.icon.src)) { |
|
6581 console.error('The icon passed is invalid. ' + 'The icon should be a string, an element, a function, or an object following the specifications documented in https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-registration/#icon-optional'); |
|
6582 return; |
|
6583 } |
|
6584 |
|
6585 Object(external_this_wp_data_["dispatch"])('core/blocks').addBlockTypes(settings); |
|
6586 return settings; |
|
6587 } |
|
6588 /** |
|
6589 * Unregisters a block. |
|
6590 * |
|
6591 * @param {string} name Block name. |
|
6592 * |
|
6593 * @return {?WPBlock} The previous block value, if it has been successfully |
|
6594 * unregistered; otherwise `undefined`. |
|
6595 */ |
|
6596 |
|
6597 function unregisterBlockType(name) { |
|
6598 var oldBlock = Object(external_this_wp_data_["select"])('core/blocks').getBlockType(name); |
|
6599 |
|
6600 if (!oldBlock) { |
|
6601 console.error('Block "' + name + '" is not registered.'); |
|
6602 return; |
|
6603 } |
|
6604 |
|
6605 Object(external_this_wp_data_["dispatch"])('core/blocks').removeBlockTypes(name); |
|
6606 return oldBlock; |
|
6607 } |
|
6608 /** |
|
6609 * Assigns name of block for handling non-block content. |
|
6610 * |
|
6611 * @param {string} blockName Block name. |
|
6612 */ |
|
6613 |
|
6614 function setFreeformContentHandlerName(blockName) { |
|
6615 Object(external_this_wp_data_["dispatch"])('core/blocks').setFreeformFallbackBlockName(blockName); |
|
6616 } |
|
6617 /** |
|
6618 * Retrieves name of block handling non-block content, or undefined if no |
|
6619 * handler has been defined. |
|
6620 * |
|
6621 * @return {?string} Blog name. |
|
6622 */ |
|
6623 |
|
6624 function getFreeformContentHandlerName() { |
|
6625 return Object(external_this_wp_data_["select"])('core/blocks').getFreeformFallbackBlockName(); |
|
6626 } |
|
6627 /** |
|
6628 * Assigns name of block handling unregistered block types. |
|
6629 * |
|
6630 * @param {string} blockName Block name. |
|
6631 */ |
|
6632 |
|
6633 function setUnregisteredTypeHandlerName(blockName) { |
|
6634 Object(external_this_wp_data_["dispatch"])('core/blocks').setUnregisteredFallbackBlockName(blockName); |
|
6635 } |
|
6636 /** |
|
6637 * Retrieves name of block handling unregistered block types, or undefined if no |
|
6638 * handler has been defined. |
|
6639 * |
|
6640 * @return {?string} Blog name. |
|
6641 */ |
|
6642 |
|
6643 function getUnregisteredTypeHandlerName() { |
|
6644 return Object(external_this_wp_data_["select"])('core/blocks').getUnregisteredFallbackBlockName(); |
|
6645 } |
|
6646 /** |
|
6647 * Assigns the default block name. |
|
6648 * |
|
6649 * @param {string} name Block name. |
|
6650 */ |
|
6651 |
|
6652 function registration_setDefaultBlockName(name) { |
|
6653 Object(external_this_wp_data_["dispatch"])('core/blocks').setDefaultBlockName(name); |
|
6654 } |
|
6655 /** |
|
6656 * Retrieves the default block name. |
|
6657 * |
|
6658 * @return {?string} Block name. |
|
6659 */ |
|
6660 |
|
6661 function registration_getDefaultBlockName() { |
|
6662 return Object(external_this_wp_data_["select"])('core/blocks').getDefaultBlockName(); |
|
6663 } |
|
6664 /** |
|
6665 * Returns a registered block type. |
|
6666 * |
|
6667 * @param {string} name Block name. |
|
6668 * |
|
6669 * @return {?Object} Block type. |
|
6670 */ |
|
6671 |
|
6672 function registration_getBlockType(name) { |
|
6673 return Object(external_this_wp_data_["select"])('core/blocks').getBlockType(name); |
|
6674 } |
|
6675 /** |
|
6676 * Returns all registered blocks. |
|
6677 * |
|
6678 * @return {Array} Block settings. |
|
6679 */ |
|
6680 |
|
6681 function registration_getBlockTypes() { |
|
6682 return Object(external_this_wp_data_["select"])('core/blocks').getBlockTypes(); |
|
6683 } |
|
6684 /** |
|
6685 * Returns the block support value for a feature, if defined. |
|
6686 * |
|
6687 * @param {(string|Object)} nameOrType Block name or type object |
|
6688 * @param {string} feature Feature to retrieve |
|
6689 * @param {*} defaultSupports Default value to return if not |
|
6690 * explicitly defined |
|
6691 * |
|
6692 * @return {?*} Block support value |
|
6693 */ |
|
6694 |
|
6695 function registration_getBlockSupport(nameOrType, feature, defaultSupports) { |
|
6696 return Object(external_this_wp_data_["select"])('core/blocks').getBlockSupport(nameOrType, feature, defaultSupports); |
|
6697 } |
|
6698 /** |
|
6699 * Returns true if the block defines support for a feature, or false otherwise. |
|
6700 * |
|
6701 * @param {(string|Object)} nameOrType Block name or type object. |
|
6702 * @param {string} feature Feature to test. |
|
6703 * @param {boolean} defaultSupports Whether feature is supported by |
|
6704 * default if not explicitly defined. |
|
6705 * |
|
6706 * @return {boolean} Whether block supports feature. |
|
6707 */ |
|
6708 |
|
6709 function registration_hasBlockSupport(nameOrType, feature, defaultSupports) { |
|
6710 return Object(external_this_wp_data_["select"])('core/blocks').hasBlockSupport(nameOrType, feature, defaultSupports); |
|
6711 } |
|
6712 /** |
|
6713 * Determines whether or not the given block is a reusable block. This is a |
|
6714 * special block type that is used to point to a global block stored via the |
|
6715 * API. |
|
6716 * |
|
6717 * @param {Object} blockOrType Block or Block Type to test. |
|
6718 * |
|
6719 * @return {boolean} Whether the given block is a reusable block. |
|
6720 */ |
|
6721 |
|
6722 function isReusableBlock(blockOrType) { |
|
6723 return blockOrType.name === 'core/block'; |
|
6724 } |
|
6725 /** |
|
6726 * Returns an array with the child blocks of a given block. |
|
6727 * |
|
6728 * @param {string} blockName Name of block (example: “latest-posts”). |
|
6729 * |
|
6730 * @return {Array} Array of child block names. |
|
6731 */ |
|
6732 |
|
6733 var registration_getChildBlockNames = function getChildBlockNames(blockName) { |
|
6734 return Object(external_this_wp_data_["select"])('core/blocks').getChildBlockNames(blockName); |
|
6735 }; |
|
6736 /** |
|
6737 * Returns a boolean indicating if a block has child blocks or not. |
|
6738 * |
|
6739 * @param {string} blockName Name of block (example: “latest-posts”). |
|
6740 * |
|
6741 * @return {boolean} True if a block contains child blocks and false otherwise. |
|
6742 */ |
|
6743 |
|
6744 var registration_hasChildBlocks = function hasChildBlocks(blockName) { |
|
6745 return Object(external_this_wp_data_["select"])('core/blocks').hasChildBlocks(blockName); |
|
6746 }; |
|
6747 /** |
|
6748 * Returns a boolean indicating if a block has at least one child block with inserter support. |
|
6749 * |
|
6750 * @param {string} blockName Block type name. |
|
6751 * |
|
6752 * @return {boolean} True if a block contains at least one child blocks with inserter support |
|
6753 * and false otherwise. |
|
6754 */ |
|
6755 |
|
6756 var registration_hasChildBlocksWithInserterSupport = function hasChildBlocksWithInserterSupport(blockName) { |
|
6757 return Object(external_this_wp_data_["select"])('core/blocks').hasChildBlocksWithInserterSupport(blockName); |
|
6758 }; |
|
6759 /** |
|
6760 * Registers a new block style variation for the given block. |
|
6761 * |
|
6762 * @param {string} blockName Name of block (example: “core/latest-posts”). |
|
6763 * @param {Object} styleVariation Object containing `name` which is the class name applied to the block and `label` which identifies the variation to the user. |
|
6764 */ |
|
6765 |
|
6766 var registration_registerBlockStyle = function registerBlockStyle(blockName, styleVariation) { |
|
6767 Object(external_this_wp_data_["dispatch"])('core/blocks').addBlockStyles(blockName, styleVariation); |
|
6768 }; |
|
6769 /** |
|
6770 * Unregisters a block style variation for the given block. |
|
6771 * |
|
6772 * @param {string} blockName Name of block (example: “core/latest-posts”). |
|
6773 * @param {string} styleVariationName Name of class applied to the block. |
|
6774 */ |
|
6775 |
|
6776 var registration_unregisterBlockStyle = function unregisterBlockStyle(blockName, styleVariationName) { |
|
6777 Object(external_this_wp_data_["dispatch"])('core/blocks').removeBlockStyles(blockName, styleVariationName); |
|
6778 }; |
|
6779 |
|
6780 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/factory.js |
|
6781 |
|
6782 |
|
6783 |
|
6784 /** |
|
6785 * External dependencies |
|
6786 */ |
|
6787 |
|
6788 |
|
6789 /** |
|
6790 * WordPress dependencies |
|
6791 */ |
|
6792 |
|
6793 |
|
6794 /** |
|
6795 * Internal dependencies |
|
6796 */ |
|
6797 |
|
6798 |
|
6799 |
|
6800 /** |
|
6801 * Returns a block object given its type and attributes. |
|
6802 * |
|
6803 * @param {string} name Block name. |
|
6804 * @param {Object} attributes Block attributes. |
|
6805 * @param {?Array} innerBlocks Nested blocks. |
|
6806 * |
|
6807 * @return {Object} Block object. |
|
6808 */ |
|
6809 |
|
6810 function createBlock(name) { |
|
6811 var attributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
6812 var innerBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; |
|
6813 // Get the type definition associated with a registered block. |
|
6814 var blockType = registration_getBlockType(name); // Ensure attributes contains only values defined by block type, and merge |
|
6815 // default values for missing attributes. |
|
6816 |
|
6817 var sanitizedAttributes = Object(external_lodash_["reduce"])(blockType.attributes, function (result, schema, key) { |
|
6818 var value = attributes[key]; |
|
6819 |
|
6820 if (undefined !== value) { |
|
6821 result[key] = value; |
|
6822 } else if (schema.hasOwnProperty('default')) { |
|
6823 result[key] = schema.default; |
|
6824 } |
|
6825 |
|
6826 if (['node', 'children'].indexOf(schema.source) !== -1) { |
|
6827 // Ensure value passed is always an array, which we're expecting in |
|
6828 // the RichText component to handle the deprecated value. |
|
6829 if (typeof result[key] === 'string') { |
|
6830 result[key] = [result[key]]; |
|
6831 } else if (!Array.isArray(result[key])) { |
|
6832 result[key] = []; |
|
6833 } |
|
6834 } |
|
6835 |
|
6836 return result; |
|
6837 }, {}); |
|
6838 var clientId = v4_default()(); // Blocks are stored with a unique ID, the assigned type name, the block |
|
6839 // attributes, and their inner blocks. |
|
6840 |
|
6841 return { |
|
6842 clientId: clientId, |
|
6843 name: name, |
|
6844 isValid: true, |
|
6845 attributes: sanitizedAttributes, |
|
6846 innerBlocks: innerBlocks |
|
6847 }; |
|
6848 } |
|
6849 /** |
|
6850 * Given a block object, returns a copy of the block object, optionally merging |
|
6851 * new attributes and/or replacing its inner blocks. |
|
6852 * |
|
6853 * @param {Object} block Block instance. |
|
6854 * @param {Object} mergeAttributes Block attributes. |
|
6855 * @param {?Array} newInnerBlocks Nested blocks. |
|
6856 * |
|
6857 * @return {Object} A cloned block. |
|
6858 */ |
|
6859 |
|
6860 function cloneBlock(block) { |
|
6861 var mergeAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
6862 var newInnerBlocks = arguments.length > 2 ? arguments[2] : undefined; |
|
6863 var clientId = v4_default()(); |
|
6864 return Object(objectSpread["a" /* default */])({}, block, { |
|
6865 clientId: clientId, |
|
6866 attributes: Object(objectSpread["a" /* default */])({}, block.attributes, mergeAttributes), |
|
6867 innerBlocks: newInnerBlocks || block.innerBlocks.map(function (innerBlock) { |
|
6868 return cloneBlock(innerBlock); |
|
6869 }) |
|
6870 }); |
|
6871 } |
|
6872 /** |
|
6873 * Returns a boolean indicating whether a transform is possible based on |
|
6874 * various bits of context. |
|
6875 * |
|
6876 * @param {Object} transform The transform object to validate. |
|
6877 * @param {string} direction Is this a 'from' or 'to' transform. |
|
6878 * @param {Array} blocks The blocks to transform from. |
|
6879 * |
|
6880 * @return {boolean} Is the transform possible? |
|
6881 */ |
|
6882 |
|
6883 var factory_isPossibleTransformForSource = function isPossibleTransformForSource(transform, direction, blocks) { |
|
6884 if (Object(external_lodash_["isEmpty"])(blocks)) { |
|
6885 return false; |
|
6886 } // If multiple blocks are selected, only multi block transforms are allowed. |
|
6887 |
|
6888 |
|
6889 var isMultiBlock = blocks.length > 1; |
|
6890 var isValidForMultiBlocks = !isMultiBlock || transform.isMultiBlock; |
|
6891 |
|
6892 if (!isValidForMultiBlocks) { |
|
6893 return false; |
|
6894 } // Only consider 'block' type transforms as valid. |
|
6895 |
|
6896 |
|
6897 var isBlockType = transform.type === 'block'; |
|
6898 |
|
6899 if (!isBlockType) { |
|
6900 return false; |
|
6901 } // Check if the transform's block name matches the source block only if this is a transform 'from'. |
|
6902 |
|
6903 |
|
6904 var sourceBlock = Object(external_lodash_["first"])(blocks); |
|
6905 var hasMatchingName = direction !== 'from' || transform.blocks.indexOf(sourceBlock.name) !== -1; |
|
6906 |
|
6907 if (!hasMatchingName) { |
|
6908 return false; |
|
6909 } // If the transform has a `isMatch` function specified, check that it returns true. |
|
6910 |
|
6911 |
|
6912 if (Object(external_lodash_["isFunction"])(transform.isMatch)) { |
|
6913 var attributes = transform.isMultiBlock ? blocks.map(function (block) { |
|
6914 return block.attributes; |
|
6915 }) : sourceBlock.attributes; |
|
6916 |
|
6917 if (!transform.isMatch(attributes)) { |
|
6918 return false; |
|
6919 } |
|
6920 } |
|
6921 |
|
6922 return true; |
|
6923 }; |
|
6924 /** |
|
6925 * Returns block types that the 'blocks' can be transformed into, based on |
|
6926 * 'from' transforms on other blocks. |
|
6927 * |
|
6928 * @param {Array} blocks The blocks to transform from. |
|
6929 * |
|
6930 * @return {Array} Block types that the blocks can be transformed into. |
|
6931 */ |
|
6932 |
|
6933 |
|
6934 var factory_getBlockTypesForPossibleFromTransforms = function getBlockTypesForPossibleFromTransforms(blocks) { |
|
6935 if (Object(external_lodash_["isEmpty"])(blocks)) { |
|
6936 return []; |
|
6937 } |
|
6938 |
|
6939 var allBlockTypes = registration_getBlockTypes(); // filter all blocks to find those with a 'from' transform. |
|
6940 |
|
6941 var blockTypesWithPossibleFromTransforms = Object(external_lodash_["filter"])(allBlockTypes, function (blockType) { |
|
6942 var fromTransforms = getBlockTransforms('from', blockType.name); |
|
6943 return !!findTransform(fromTransforms, function (transform) { |
|
6944 return factory_isPossibleTransformForSource(transform, 'from', blocks); |
|
6945 }); |
|
6946 }); |
|
6947 return blockTypesWithPossibleFromTransforms; |
|
6948 }; |
|
6949 /** |
|
6950 * Returns block types that the 'blocks' can be transformed into, based on |
|
6951 * the source block's own 'to' transforms. |
|
6952 * |
|
6953 * @param {Array} blocks The blocks to transform from. |
|
6954 * |
|
6955 * @return {Array} Block types that the source can be transformed into. |
|
6956 */ |
|
6957 |
|
6958 |
|
6959 var factory_getBlockTypesForPossibleToTransforms = function getBlockTypesForPossibleToTransforms(blocks) { |
|
6960 if (Object(external_lodash_["isEmpty"])(blocks)) { |
|
6961 return []; |
|
6962 } |
|
6963 |
|
6964 var sourceBlock = Object(external_lodash_["first"])(blocks); |
|
6965 var blockType = registration_getBlockType(sourceBlock.name); |
|
6966 var transformsTo = getBlockTransforms('to', blockType.name); // filter all 'to' transforms to find those that are possible. |
|
6967 |
|
6968 var possibleTransforms = Object(external_lodash_["filter"])(transformsTo, function (transform) { |
|
6969 return factory_isPossibleTransformForSource(transform, 'to', blocks); |
|
6970 }); // Build a list of block names using the possible 'to' transforms. |
|
6971 |
|
6972 var blockNames = Object(external_lodash_["flatMap"])(possibleTransforms, function (transformation) { |
|
6973 return transformation.blocks; |
|
6974 }); // Map block names to block types. |
|
6975 |
|
6976 return blockNames.map(function (name) { |
|
6977 return registration_getBlockType(name); |
|
6978 }); |
|
6979 }; |
|
6980 /** |
|
6981 * Returns an array of block types that the set of blocks received as argument |
|
6982 * can be transformed into. |
|
6983 * |
|
6984 * @param {Array} blocks Blocks array. |
|
6985 * |
|
6986 * @return {Array} Block types that the blocks argument can be transformed to. |
|
6987 */ |
|
6988 |
|
6989 |
|
6990 function getPossibleBlockTransformations(blocks) { |
|
6991 if (Object(external_lodash_["isEmpty"])(blocks)) { |
|
6992 return []; |
|
6993 } |
|
6994 |
|
6995 var sourceBlock = Object(external_lodash_["first"])(blocks); |
|
6996 var isMultiBlock = blocks.length > 1; |
|
6997 |
|
6998 if (isMultiBlock && !Object(external_lodash_["every"])(blocks, { |
|
6999 name: sourceBlock.name |
|
7000 })) { |
|
7001 return []; |
|
7002 } |
|
7003 |
|
7004 var blockTypesForFromTransforms = factory_getBlockTypesForPossibleFromTransforms(blocks); |
|
7005 var blockTypesForToTransforms = factory_getBlockTypesForPossibleToTransforms(blocks); |
|
7006 return Object(external_lodash_["uniq"])([].concat(Object(toConsumableArray["a" /* default */])(blockTypesForFromTransforms), Object(toConsumableArray["a" /* default */])(blockTypesForToTransforms))); |
|
7007 } |
|
7008 /** |
|
7009 * Given an array of transforms, returns the highest-priority transform where |
|
7010 * the predicate function returns a truthy value. A higher-priority transform |
|
7011 * is one with a lower priority value (i.e. first in priority order). Returns |
|
7012 * null if the transforms set is empty or the predicate function returns a |
|
7013 * falsey value for all entries. |
|
7014 * |
|
7015 * @param {Object[]} transforms Transforms to search. |
|
7016 * @param {Function} predicate Function returning true on matching transform. |
|
7017 * |
|
7018 * @return {?Object} Highest-priority transform candidate. |
|
7019 */ |
|
7020 |
|
7021 function findTransform(transforms, predicate) { |
|
7022 // The hooks library already has built-in mechanisms for managing priority |
|
7023 // queue, so leverage via locally-defined instance. |
|
7024 var hooks = Object(external_this_wp_hooks_["createHooks"])(); |
|
7025 |
|
7026 var _loop = function _loop(i) { |
|
7027 var candidate = transforms[i]; |
|
7028 |
|
7029 if (predicate(candidate)) { |
|
7030 hooks.addFilter('transform', 'transform/' + i.toString(), function (result) { |
|
7031 return result ? result : candidate; |
|
7032 }, candidate.priority); |
|
7033 } |
|
7034 }; |
|
7035 |
|
7036 for (var i = 0; i < transforms.length; i++) { |
|
7037 _loop(i); |
|
7038 } // Filter name is arbitrarily chosen but consistent with above aggregation. |
|
7039 |
|
7040 |
|
7041 return hooks.applyFilters('transform', null); |
|
7042 } |
|
7043 /** |
|
7044 * Returns normal block transforms for a given transform direction, optionally |
|
7045 * for a specific block by name, or an empty array if there are no transforms. |
|
7046 * If no block name is provided, returns transforms for all blocks. A normal |
|
7047 * transform object includes `blockName` as a property. |
|
7048 * |
|
7049 * @param {string} direction Transform direction ("to", "from"). |
|
7050 * @param {string|Object} blockTypeOrName Block type or name. |
|
7051 * |
|
7052 * @return {Array} Block transforms for direction. |
|
7053 */ |
|
7054 |
|
7055 function getBlockTransforms(direction, blockTypeOrName) { |
|
7056 // When retrieving transforms for all block types, recurse into self. |
|
7057 if (blockTypeOrName === undefined) { |
|
7058 return Object(external_lodash_["flatMap"])(registration_getBlockTypes(), function (_ref) { |
|
7059 var name = _ref.name; |
|
7060 return getBlockTransforms(direction, name); |
|
7061 }); |
|
7062 } // Validate that block type exists and has array of direction. |
|
7063 |
|
7064 |
|
7065 var blockType = normalizeBlockType(blockTypeOrName); |
|
7066 |
|
7067 var _ref2 = blockType || {}, |
|
7068 blockName = _ref2.name, |
|
7069 transforms = _ref2.transforms; |
|
7070 |
|
7071 if (!transforms || !Array.isArray(transforms[direction])) { |
|
7072 return []; |
|
7073 } // Map transforms to normal form. |
|
7074 |
|
7075 |
|
7076 return transforms[direction].map(function (transform) { |
|
7077 return Object(objectSpread["a" /* default */])({}, transform, { |
|
7078 blockName: blockName |
|
7079 }); |
|
7080 }); |
|
7081 } |
|
7082 /** |
|
7083 * Switch one or more blocks into one or more blocks of the new block type. |
|
7084 * |
|
7085 * @param {Array|Object} blocks Blocks array or block object. |
|
7086 * @param {string} name Block name. |
|
7087 * |
|
7088 * @return {Array} Array of blocks. |
|
7089 */ |
|
7090 |
|
7091 function switchToBlockType(blocks, name) { |
|
7092 var blocksArray = Object(external_lodash_["castArray"])(blocks); |
|
7093 var isMultiBlock = blocksArray.length > 1; |
|
7094 var firstBlock = blocksArray[0]; |
|
7095 var sourceName = firstBlock.name; |
|
7096 |
|
7097 if (isMultiBlock && !Object(external_lodash_["every"])(blocksArray, function (block) { |
|
7098 return block.name === sourceName; |
|
7099 })) { |
|
7100 return null; |
|
7101 } // Find the right transformation by giving priority to the "to" |
|
7102 // transformation. |
|
7103 |
|
7104 |
|
7105 var transformationsFrom = getBlockTransforms('from', name); |
|
7106 var transformationsTo = getBlockTransforms('to', sourceName); |
|
7107 var transformation = findTransform(transformationsTo, function (t) { |
|
7108 return t.type === 'block' && t.blocks.indexOf(name) !== -1 && (!isMultiBlock || t.isMultiBlock); |
|
7109 }) || findTransform(transformationsFrom, function (t) { |
|
7110 return t.type === 'block' && t.blocks.indexOf(sourceName) !== -1 && (!isMultiBlock || t.isMultiBlock); |
|
7111 }); // Stop if there is no valid transformation. |
|
7112 |
|
7113 if (!transformation) { |
|
7114 return null; |
|
7115 } |
|
7116 |
|
7117 var transformationResults; |
|
7118 |
|
7119 if (transformation.isMultiBlock) { |
|
7120 transformationResults = transformation.transform(blocksArray.map(function (currentBlock) { |
|
7121 return currentBlock.attributes; |
|
7122 }), blocksArray.map(function (currentBlock) { |
|
7123 return currentBlock.innerBlocks; |
|
7124 })); |
|
7125 } else { |
|
7126 transformationResults = transformation.transform(firstBlock.attributes, firstBlock.innerBlocks); |
|
7127 } // Ensure that the transformation function returned an object or an array |
|
7128 // of objects. |
|
7129 |
|
7130 |
|
7131 if (!Object(external_lodash_["isObjectLike"])(transformationResults)) { |
|
7132 return null; |
|
7133 } // If the transformation function returned a single object, we want to work |
|
7134 // with an array instead. |
|
7135 |
|
7136 |
|
7137 transformationResults = Object(external_lodash_["castArray"])(transformationResults); // Ensure that every block object returned by the transformation has a |
|
7138 // valid block type. |
|
7139 |
|
7140 if (transformationResults.some(function (result) { |
|
7141 return !registration_getBlockType(result.name); |
|
7142 })) { |
|
7143 return null; |
|
7144 } |
|
7145 |
|
7146 var firstSwitchedBlock = Object(external_lodash_["findIndex"])(transformationResults, function (result) { |
|
7147 return result.name === name; |
|
7148 }); // Ensure that at least one block object returned by the transformation has |
|
7149 // the expected "destination" block type. |
|
7150 |
|
7151 if (firstSwitchedBlock < 0) { |
|
7152 return null; |
|
7153 } |
|
7154 |
|
7155 return transformationResults.map(function (result, index) { |
|
7156 var transformedBlock = Object(objectSpread["a" /* default */])({}, result, { |
|
7157 // The first transformed block whose type matches the "destination" |
|
7158 // type gets to keep the existing client ID of the first block. |
|
7159 clientId: index === firstSwitchedBlock ? firstBlock.clientId : result.clientId |
|
7160 }); |
|
7161 /** |
|
7162 * Filters an individual transform result from block transformation. |
|
7163 * All of the original blocks are passed, since transformations are |
|
7164 * many-to-many, not one-to-one. |
|
7165 * |
|
7166 * @param {Object} transformedBlock The transformed block. |
|
7167 * @param {Object[]} blocks Original blocks transformed. |
|
7168 */ |
|
7169 |
|
7170 |
|
7171 return Object(external_this_wp_hooks_["applyFilters"])('blocks.switchToBlockType.transformedBlock', transformedBlock, blocks); |
|
7172 }); |
|
7173 } |
|
7174 |
|
7175 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules |
|
7176 var slicedToArray = __webpack_require__(28); |
|
7177 |
|
7178 // CONCATENATED MODULE: ./node_modules/hpq/es/get-path.js |
|
7179 /** |
|
7180 * Given object and string of dot-delimited path segments, returns value at |
|
7181 * path or undefined if path cannot be resolved. |
|
7182 * |
|
7183 * @param {Object} object Lookup object |
|
7184 * @param {string} path Path to resolve |
|
7185 * @return {?*} Resolved value |
|
7186 */ |
|
7187 function getPath(object, path) { |
|
7188 var segments = path.split('.'); |
|
7189 var segment; |
|
7190 |
|
7191 while (segment = segments.shift()) { |
|
7192 if (!(segment in object)) { |
|
7193 return; |
|
7194 } |
|
7195 |
|
7196 object = object[segment]; |
|
7197 } |
|
7198 |
|
7199 return object; |
|
7200 } |
|
7201 // CONCATENATED MODULE: ./node_modules/hpq/es/index.js |
|
7202 /** |
|
7203 * Internal dependencies |
|
7204 */ |
|
7205 |
|
7206 /** |
|
7207 * Function returning a DOM document created by `createHTMLDocument`. The same |
|
7208 * document is returned between invocations. |
|
7209 * |
|
7210 * @return {Document} DOM document. |
|
7211 */ |
|
7212 |
|
7213 var getDocument = function () { |
|
7214 var doc; |
|
7215 return function () { |
|
7216 if (!doc) { |
|
7217 doc = document.implementation.createHTMLDocument(''); |
|
7218 } |
|
7219 |
|
7220 return doc; |
|
7221 }; |
|
7222 }(); |
|
7223 /** |
|
7224 * Given a markup string or DOM element, creates an object aligning with the |
|
7225 * shape of the matchers object, or the value returned by the matcher. |
|
7226 * |
|
7227 * @param {(string|Element)} source Source content |
|
7228 * @param {(Object|Function)} matchers Matcher function or object of matchers |
|
7229 * @return {(Object|*)} Matched value(s), shaped by object |
|
7230 */ |
|
7231 |
|
7232 |
|
7233 function es_parse(source, matchers) { |
|
7234 if (!matchers) { |
|
7235 return; |
|
7236 } // Coerce to element |
|
7237 |
|
7238 |
|
7239 if ('string' === typeof source) { |
|
7240 var doc = getDocument(); |
|
7241 doc.body.innerHTML = source; |
|
7242 source = doc.body; |
|
7243 } // Return singular value |
|
7244 |
|
7245 |
|
7246 if ('function' === typeof matchers) { |
|
7247 return matchers(source); |
|
7248 } // Bail if we can't handle matchers |
|
7249 |
|
7250 |
|
7251 if (Object !== matchers.constructor) { |
|
7252 return; |
|
7253 } // Shape result by matcher object |
|
7254 |
|
7255 |
|
7256 return Object.keys(matchers).reduce(function (memo, key) { |
|
7257 memo[key] = es_parse(source, matchers[key]); |
|
7258 return memo; |
|
7259 }, {}); |
|
7260 } |
|
7261 /** |
|
7262 * Generates a function which matches node of type selector, returning an |
|
7263 * attribute by property if the attribute exists. If no selector is passed, |
|
7264 * returns property of the query element. |
|
7265 * |
|
7266 * @param {?string} selector Optional selector |
|
7267 * @param {string} name Property name |
|
7268 * @return {*} Property value |
|
7269 */ |
|
7270 |
|
7271 function prop(selector, name) { |
|
7272 if (1 === arguments.length) { |
|
7273 name = selector; |
|
7274 selector = undefined; |
|
7275 } |
|
7276 |
|
7277 return function (node) { |
|
7278 var match = node; |
|
7279 |
|
7280 if (selector) { |
|
7281 match = node.querySelector(selector); |
|
7282 } |
|
7283 |
|
7284 if (match) { |
|
7285 return getPath(match, name); |
|
7286 } |
|
7287 }; |
|
7288 } |
|
7289 /** |
|
7290 * Generates a function which matches node of type selector, returning an |
|
7291 * attribute by name if the attribute exists. If no selector is passed, |
|
7292 * returns attribute of the query element. |
|
7293 * |
|
7294 * @param {?string} selector Optional selector |
|
7295 * @param {string} name Attribute name |
|
7296 * @return {?string} Attribute value |
|
7297 */ |
|
7298 |
|
7299 function attr(selector, name) { |
|
7300 if (1 === arguments.length) { |
|
7301 name = selector; |
|
7302 selector = undefined; |
|
7303 } |
|
7304 |
|
7305 return function (node) { |
|
7306 var attributes = prop(selector, 'attributes')(node); |
|
7307 |
|
7308 if (attributes && attributes.hasOwnProperty(name)) { |
|
7309 return attributes[name].value; |
|
7310 } |
|
7311 }; |
|
7312 } |
|
7313 /** |
|
7314 * Convenience for `prop( selector, 'innerHTML' )`. |
|
7315 * |
|
7316 * @see prop() |
|
7317 * |
|
7318 * @param {?string} selector Optional selector |
|
7319 * @return {string} Inner HTML |
|
7320 */ |
|
7321 |
|
7322 function es_html(selector) { |
|
7323 return prop(selector, 'innerHTML'); |
|
7324 } |
|
7325 /** |
|
7326 * Convenience for `prop( selector, 'textContent' )`. |
|
7327 * |
|
7328 * @see prop() |
|
7329 * |
|
7330 * @param {?string} selector Optional selector |
|
7331 * @return {string} Text content |
|
7332 */ |
|
7333 |
|
7334 function es_text(selector) { |
|
7335 return prop(selector, 'textContent'); |
|
7336 } |
|
7337 /** |
|
7338 * Creates a new matching context by first finding elements matching selector |
|
7339 * using querySelectorAll before then running another `parse` on `matchers` |
|
7340 * scoped to the matched elements. |
|
7341 * |
|
7342 * @see parse() |
|
7343 * |
|
7344 * @param {string} selector Selector to match |
|
7345 * @param {(Object|Function)} matchers Matcher function or object of matchers |
|
7346 * @return {Array.<*,Object>} Array of matched value(s) |
|
7347 */ |
|
7348 |
|
7349 function query(selector, matchers) { |
|
7350 return function (node) { |
|
7351 var matches = node.querySelectorAll(selector); |
|
7352 return [].map.call(matches, function (match) { |
|
7353 return es_parse(match, matchers); |
|
7354 }); |
|
7355 }; |
|
7356 } |
|
7357 // EXTERNAL MODULE: external {"this":["wp","autop"]} |
|
7358 var external_this_wp_autop_ = __webpack_require__(66); |
|
7359 |
|
7360 // EXTERNAL MODULE: external {"this":["wp","blockSerializationDefaultParser"]} |
|
7361 var external_this_wp_blockSerializationDefaultParser_ = __webpack_require__(205); |
|
7362 |
|
7363 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js |
|
7364 var arrayWithHoles = __webpack_require__(37); |
|
7365 |
|
7366 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js |
|
7367 var iterableToArray = __webpack_require__(34); |
|
7368 |
|
7369 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js |
|
7370 var nonIterableRest = __webpack_require__(38); |
|
7371 |
|
7372 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toArray.js |
|
7373 |
|
7374 |
|
7375 |
|
7376 function _toArray(arr) { |
|
7377 return Object(arrayWithHoles["a" /* default */])(arr) || Object(iterableToArray["a" /* default */])(arr) || Object(nonIterableRest["a" /* default */])(); |
|
7378 } |
|
7379 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js |
|
7380 var classCallCheck = __webpack_require__(10); |
|
7381 |
|
7382 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js |
|
7383 var createClass = __webpack_require__(9); |
|
7384 |
|
7385 // CONCATENATED MODULE: ./node_modules/simple-html-tokenizer/dist/es6/utils.js |
|
7386 var WSP = /[\t\n\f ]/; |
|
7387 var ALPHA = /[A-Za-z]/; |
|
7388 var CRLF = /\r\n?/g; |
|
7389 function isSpace(char) { |
|
7390 return WSP.test(char); |
|
7391 } |
|
7392 function isAlpha(char) { |
|
7393 return ALPHA.test(char); |
|
7394 } |
|
7395 function preprocessInput(input) { |
|
7396 return input.replace(CRLF, "\n"); |
|
7397 } |
|
7398 function unwrap(maybe, msg) { |
|
7399 if (!maybe) |
|
7400 throw new Error((msg || 'value') + " was null"); |
|
7401 return maybe; |
|
7402 } |
|
7403 function or(maybe, otherwise) { |
|
7404 return maybe || otherwise; |
|
7405 } |
|
7406 |
|
7407 // CONCATENATED MODULE: ./node_modules/simple-html-tokenizer/dist/es6/evented-tokenizer.js |
|
7408 |
|
7409 var evented_tokenizer_EventedTokenizer = /** @class */ (function () { |
|
7410 function EventedTokenizer(delegate, entityParser) { |
|
7411 this.delegate = delegate; |
|
7412 this.entityParser = entityParser; |
|
7413 this.state = null; |
|
7414 this.input = null; |
|
7415 this.index = -1; |
|
7416 this.tagLine = -1; |
|
7417 this.tagColumn = -1; |
|
7418 this.line = -1; |
|
7419 this.column = -1; |
|
7420 this.states = { |
|
7421 beforeData: function () { |
|
7422 var char = this.peek(); |
|
7423 if (char === "<") { |
|
7424 this.state = 'tagOpen'; |
|
7425 this.markTagStart(); |
|
7426 this.consume(); |
|
7427 } |
|
7428 else { |
|
7429 this.state = 'data'; |
|
7430 this.delegate.beginData(); |
|
7431 } |
|
7432 }, |
|
7433 data: function () { |
|
7434 var char = this.peek(); |
|
7435 if (char === "<") { |
|
7436 this.delegate.finishData(); |
|
7437 this.state = 'tagOpen'; |
|
7438 this.markTagStart(); |
|
7439 this.consume(); |
|
7440 } |
|
7441 else if (char === "&") { |
|
7442 this.consume(); |
|
7443 this.delegate.appendToData(this.consumeCharRef() || "&"); |
|
7444 } |
|
7445 else { |
|
7446 this.consume(); |
|
7447 this.delegate.appendToData(char); |
|
7448 } |
|
7449 }, |
|
7450 tagOpen: function () { |
|
7451 var char = this.consume(); |
|
7452 if (char === "!") { |
|
7453 this.state = 'markupDeclaration'; |
|
7454 } |
|
7455 else if (char === "/") { |
|
7456 this.state = 'endTagOpen'; |
|
7457 } |
|
7458 else if (isAlpha(char)) { |
|
7459 this.state = 'tagName'; |
|
7460 this.delegate.beginStartTag(); |
|
7461 this.delegate.appendToTagName(char.toLowerCase()); |
|
7462 } |
|
7463 }, |
|
7464 markupDeclaration: function () { |
|
7465 var char = this.consume(); |
|
7466 if (char === "-" && this.input.charAt(this.index) === "-") { |
|
7467 this.consume(); |
|
7468 this.state = 'commentStart'; |
|
7469 this.delegate.beginComment(); |
|
7470 } |
|
7471 }, |
|
7472 commentStart: function () { |
|
7473 var char = this.consume(); |
|
7474 if (char === "-") { |
|
7475 this.state = 'commentStartDash'; |
|
7476 } |
|
7477 else if (char === ">") { |
|
7478 this.delegate.finishComment(); |
|
7479 this.state = 'beforeData'; |
|
7480 } |
|
7481 else { |
|
7482 this.delegate.appendToCommentData(char); |
|
7483 this.state = 'comment'; |
|
7484 } |
|
7485 }, |
|
7486 commentStartDash: function () { |
|
7487 var char = this.consume(); |
|
7488 if (char === "-") { |
|
7489 this.state = 'commentEnd'; |
|
7490 } |
|
7491 else if (char === ">") { |
|
7492 this.delegate.finishComment(); |
|
7493 this.state = 'beforeData'; |
|
7494 } |
|
7495 else { |
|
7496 this.delegate.appendToCommentData("-"); |
|
7497 this.state = 'comment'; |
|
7498 } |
|
7499 }, |
|
7500 comment: function () { |
|
7501 var char = this.consume(); |
|
7502 if (char === "-") { |
|
7503 this.state = 'commentEndDash'; |
|
7504 } |
|
7505 else { |
|
7506 this.delegate.appendToCommentData(char); |
|
7507 } |
|
7508 }, |
|
7509 commentEndDash: function () { |
|
7510 var char = this.consume(); |
|
7511 if (char === "-") { |
|
7512 this.state = 'commentEnd'; |
|
7513 } |
|
7514 else { |
|
7515 this.delegate.appendToCommentData("-" + char); |
|
7516 this.state = 'comment'; |
|
7517 } |
|
7518 }, |
|
7519 commentEnd: function () { |
|
7520 var char = this.consume(); |
|
7521 if (char === ">") { |
|
7522 this.delegate.finishComment(); |
|
7523 this.state = 'beforeData'; |
|
7524 } |
|
7525 else { |
|
7526 this.delegate.appendToCommentData("--" + char); |
|
7527 this.state = 'comment'; |
|
7528 } |
|
7529 }, |
|
7530 tagName: function () { |
|
7531 var char = this.consume(); |
|
7532 if (isSpace(char)) { |
|
7533 this.state = 'beforeAttributeName'; |
|
7534 } |
|
7535 else if (char === "/") { |
|
7536 this.state = 'selfClosingStartTag'; |
|
7537 } |
|
7538 else if (char === ">") { |
|
7539 this.delegate.finishTag(); |
|
7540 this.state = 'beforeData'; |
|
7541 } |
|
7542 else { |
|
7543 this.delegate.appendToTagName(char); |
|
7544 } |
|
7545 }, |
|
7546 beforeAttributeName: function () { |
|
7547 var char = this.peek(); |
|
7548 if (isSpace(char)) { |
|
7549 this.consume(); |
|
7550 return; |
|
7551 } |
|
7552 else if (char === "/") { |
|
7553 this.state = 'selfClosingStartTag'; |
|
7554 this.consume(); |
|
7555 } |
|
7556 else if (char === ">") { |
|
7557 this.consume(); |
|
7558 this.delegate.finishTag(); |
|
7559 this.state = 'beforeData'; |
|
7560 } |
|
7561 else if (char === '=') { |
|
7562 this.delegate.reportSyntaxError("attribute name cannot start with equals sign"); |
|
7563 this.state = 'attributeName'; |
|
7564 this.delegate.beginAttribute(); |
|
7565 this.consume(); |
|
7566 this.delegate.appendToAttributeName(char); |
|
7567 } |
|
7568 else { |
|
7569 this.state = 'attributeName'; |
|
7570 this.delegate.beginAttribute(); |
|
7571 } |
|
7572 }, |
|
7573 attributeName: function () { |
|
7574 var char = this.peek(); |
|
7575 if (isSpace(char)) { |
|
7576 this.state = 'afterAttributeName'; |
|
7577 this.consume(); |
|
7578 } |
|
7579 else if (char === "/") { |
|
7580 this.delegate.beginAttributeValue(false); |
|
7581 this.delegate.finishAttributeValue(); |
|
7582 this.consume(); |
|
7583 this.state = 'selfClosingStartTag'; |
|
7584 } |
|
7585 else if (char === "=") { |
|
7586 this.state = 'beforeAttributeValue'; |
|
7587 this.consume(); |
|
7588 } |
|
7589 else if (char === ">") { |
|
7590 this.delegate.beginAttributeValue(false); |
|
7591 this.delegate.finishAttributeValue(); |
|
7592 this.consume(); |
|
7593 this.delegate.finishTag(); |
|
7594 this.state = 'beforeData'; |
|
7595 } |
|
7596 else if (char === '"' || char === "'" || char === '<') { |
|
7597 this.delegate.reportSyntaxError(char + " is not a valid character within attribute names"); |
|
7598 this.consume(); |
|
7599 this.delegate.appendToAttributeName(char); |
|
7600 } |
|
7601 else { |
|
7602 this.consume(); |
|
7603 this.delegate.appendToAttributeName(char); |
|
7604 } |
|
7605 }, |
|
7606 afterAttributeName: function () { |
|
7607 var char = this.peek(); |
|
7608 if (isSpace(char)) { |
|
7609 this.consume(); |
|
7610 return; |
|
7611 } |
|
7612 else if (char === "/") { |
|
7613 this.delegate.beginAttributeValue(false); |
|
7614 this.delegate.finishAttributeValue(); |
|
7615 this.consume(); |
|
7616 this.state = 'selfClosingStartTag'; |
|
7617 } |
|
7618 else if (char === "=") { |
|
7619 this.consume(); |
|
7620 this.state = 'beforeAttributeValue'; |
|
7621 } |
|
7622 else if (char === ">") { |
|
7623 this.delegate.beginAttributeValue(false); |
|
7624 this.delegate.finishAttributeValue(); |
|
7625 this.consume(); |
|
7626 this.delegate.finishTag(); |
|
7627 this.state = 'beforeData'; |
|
7628 } |
|
7629 else { |
|
7630 this.delegate.beginAttributeValue(false); |
|
7631 this.delegate.finishAttributeValue(); |
|
7632 this.consume(); |
|
7633 this.state = 'attributeName'; |
|
7634 this.delegate.beginAttribute(); |
|
7635 this.delegate.appendToAttributeName(char); |
|
7636 } |
|
7637 }, |
|
7638 beforeAttributeValue: function () { |
|
7639 var char = this.peek(); |
|
7640 if (isSpace(char)) { |
|
7641 this.consume(); |
|
7642 } |
|
7643 else if (char === '"') { |
|
7644 this.state = 'attributeValueDoubleQuoted'; |
|
7645 this.delegate.beginAttributeValue(true); |
|
7646 this.consume(); |
|
7647 } |
|
7648 else if (char === "'") { |
|
7649 this.state = 'attributeValueSingleQuoted'; |
|
7650 this.delegate.beginAttributeValue(true); |
|
7651 this.consume(); |
|
7652 } |
|
7653 else if (char === ">") { |
|
7654 this.delegate.beginAttributeValue(false); |
|
7655 this.delegate.finishAttributeValue(); |
|
7656 this.consume(); |
|
7657 this.delegate.finishTag(); |
|
7658 this.state = 'beforeData'; |
|
7659 } |
|
7660 else { |
|
7661 this.state = 'attributeValueUnquoted'; |
|
7662 this.delegate.beginAttributeValue(false); |
|
7663 this.consume(); |
|
7664 this.delegate.appendToAttributeValue(char); |
|
7665 } |
|
7666 }, |
|
7667 attributeValueDoubleQuoted: function () { |
|
7668 var char = this.consume(); |
|
7669 if (char === '"') { |
|
7670 this.delegate.finishAttributeValue(); |
|
7671 this.state = 'afterAttributeValueQuoted'; |
|
7672 } |
|
7673 else if (char === "&") { |
|
7674 this.delegate.appendToAttributeValue(this.consumeCharRef('"') || "&"); |
|
7675 } |
|
7676 else { |
|
7677 this.delegate.appendToAttributeValue(char); |
|
7678 } |
|
7679 }, |
|
7680 attributeValueSingleQuoted: function () { |
|
7681 var char = this.consume(); |
|
7682 if (char === "'") { |
|
7683 this.delegate.finishAttributeValue(); |
|
7684 this.state = 'afterAttributeValueQuoted'; |
|
7685 } |
|
7686 else if (char === "&") { |
|
7687 this.delegate.appendToAttributeValue(this.consumeCharRef("'") || "&"); |
|
7688 } |
|
7689 else { |
|
7690 this.delegate.appendToAttributeValue(char); |
|
7691 } |
|
7692 }, |
|
7693 attributeValueUnquoted: function () { |
|
7694 var char = this.peek(); |
|
7695 if (isSpace(char)) { |
|
7696 this.delegate.finishAttributeValue(); |
|
7697 this.consume(); |
|
7698 this.state = 'beforeAttributeName'; |
|
7699 } |
|
7700 else if (char === "&") { |
|
7701 this.consume(); |
|
7702 this.delegate.appendToAttributeValue(this.consumeCharRef(">") || "&"); |
|
7703 } |
|
7704 else if (char === ">") { |
|
7705 this.delegate.finishAttributeValue(); |
|
7706 this.consume(); |
|
7707 this.delegate.finishTag(); |
|
7708 this.state = 'beforeData'; |
|
7709 } |
|
7710 else { |
|
7711 this.consume(); |
|
7712 this.delegate.appendToAttributeValue(char); |
|
7713 } |
|
7714 }, |
|
7715 afterAttributeValueQuoted: function () { |
|
7716 var char = this.peek(); |
|
7717 if (isSpace(char)) { |
|
7718 this.consume(); |
|
7719 this.state = 'beforeAttributeName'; |
|
7720 } |
|
7721 else if (char === "/") { |
|
7722 this.consume(); |
|
7723 this.state = 'selfClosingStartTag'; |
|
7724 } |
|
7725 else if (char === ">") { |
|
7726 this.consume(); |
|
7727 this.delegate.finishTag(); |
|
7728 this.state = 'beforeData'; |
|
7729 } |
|
7730 else { |
|
7731 this.state = 'beforeAttributeName'; |
|
7732 } |
|
7733 }, |
|
7734 selfClosingStartTag: function () { |
|
7735 var char = this.peek(); |
|
7736 if (char === ">") { |
|
7737 this.consume(); |
|
7738 this.delegate.markTagAsSelfClosing(); |
|
7739 this.delegate.finishTag(); |
|
7740 this.state = 'beforeData'; |
|
7741 } |
|
7742 else { |
|
7743 this.state = 'beforeAttributeName'; |
|
7744 } |
|
7745 }, |
|
7746 endTagOpen: function () { |
|
7747 var char = this.consume(); |
|
7748 if (isAlpha(char)) { |
|
7749 this.state = 'tagName'; |
|
7750 this.delegate.beginEndTag(); |
|
7751 this.delegate.appendToTagName(char.toLowerCase()); |
|
7752 } |
|
7753 } |
|
7754 }; |
|
7755 this.reset(); |
|
7756 } |
|
7757 EventedTokenizer.prototype.reset = function () { |
|
7758 this.state = 'beforeData'; |
|
7759 this.input = ''; |
|
7760 this.index = 0; |
|
7761 this.line = 1; |
|
7762 this.column = 0; |
|
7763 this.tagLine = -1; |
|
7764 this.tagColumn = -1; |
|
7765 this.delegate.reset(); |
|
7766 }; |
|
7767 EventedTokenizer.prototype.tokenize = function (input) { |
|
7768 this.reset(); |
|
7769 this.tokenizePart(input); |
|
7770 this.tokenizeEOF(); |
|
7771 }; |
|
7772 EventedTokenizer.prototype.tokenizePart = function (input) { |
|
7773 this.input += preprocessInput(input); |
|
7774 while (this.index < this.input.length) { |
|
7775 this.states[this.state].call(this); |
|
7776 } |
|
7777 }; |
|
7778 EventedTokenizer.prototype.tokenizeEOF = function () { |
|
7779 this.flushData(); |
|
7780 }; |
|
7781 EventedTokenizer.prototype.flushData = function () { |
|
7782 if (this.state === 'data') { |
|
7783 this.delegate.finishData(); |
|
7784 this.state = 'beforeData'; |
|
7785 } |
|
7786 }; |
|
7787 EventedTokenizer.prototype.peek = function () { |
|
7788 return this.input.charAt(this.index); |
|
7789 }; |
|
7790 EventedTokenizer.prototype.consume = function () { |
|
7791 var char = this.peek(); |
|
7792 this.index++; |
|
7793 if (char === "\n") { |
|
7794 this.line++; |
|
7795 this.column = 0; |
|
7796 } |
|
7797 else { |
|
7798 this.column++; |
|
7799 } |
|
7800 return char; |
|
7801 }; |
|
7802 EventedTokenizer.prototype.consumeCharRef = function () { |
|
7803 var endIndex = this.input.indexOf(';', this.index); |
|
7804 if (endIndex === -1) { |
|
7805 return; |
|
7806 } |
|
7807 var entity = this.input.slice(this.index, endIndex); |
|
7808 var chars = this.entityParser.parse(entity); |
|
7809 if (chars) { |
|
7810 var count = entity.length; |
|
7811 // consume the entity chars |
|
7812 while (count) { |
|
7813 this.consume(); |
|
7814 count--; |
|
7815 } |
|
7816 // consume the `;` |
|
7817 this.consume(); |
|
7818 return chars; |
|
7819 } |
|
7820 }; |
|
7821 EventedTokenizer.prototype.markTagStart = function () { |
|
7822 // these properties to be removed in next major bump |
|
7823 this.tagLine = this.line; |
|
7824 this.tagColumn = this.column; |
|
7825 if (this.delegate.tagOpen) { |
|
7826 this.delegate.tagOpen(); |
|
7827 } |
|
7828 }; |
|
7829 return EventedTokenizer; |
|
7830 }()); |
|
7831 /* harmony default export */ var evented_tokenizer = (evented_tokenizer_EventedTokenizer); |
|
7832 |
|
7833 // CONCATENATED MODULE: ./node_modules/simple-html-tokenizer/dist/es6/tokenizer.js |
|
7834 |
|
7835 |
|
7836 ; |
|
7837 var tokenizer_Tokenizer = /** @class */ (function () { |
|
7838 function Tokenizer(entityParser, options) { |
|
7839 if (options === void 0) { options = {}; } |
|
7840 this.options = options; |
|
7841 this._token = null; |
|
7842 this.startLine = 1; |
|
7843 this.startColumn = 0; |
|
7844 this.tokens = []; |
|
7845 this.currentAttribute = null; |
|
7846 this.tokenizer = new evented_tokenizer(this, entityParser); |
|
7847 } |
|
7848 Object.defineProperty(Tokenizer.prototype, "token", { |
|
7849 get: function () { |
|
7850 return unwrap(this._token); |
|
7851 }, |
|
7852 set: function (value) { |
|
7853 this._token = value; |
|
7854 }, |
|
7855 enumerable: true, |
|
7856 configurable: true |
|
7857 }); |
|
7858 Tokenizer.prototype.tokenize = function (input) { |
|
7859 this.tokens = []; |
|
7860 this.tokenizer.tokenize(input); |
|
7861 return this.tokens; |
|
7862 }; |
|
7863 Tokenizer.prototype.tokenizePart = function (input) { |
|
7864 this.tokens = []; |
|
7865 this.tokenizer.tokenizePart(input); |
|
7866 return this.tokens; |
|
7867 }; |
|
7868 Tokenizer.prototype.tokenizeEOF = function () { |
|
7869 this.tokens = []; |
|
7870 this.tokenizer.tokenizeEOF(); |
|
7871 return this.tokens[0]; |
|
7872 }; |
|
7873 Tokenizer.prototype.reset = function () { |
|
7874 this._token = null; |
|
7875 this.startLine = 1; |
|
7876 this.startColumn = 0; |
|
7877 }; |
|
7878 Tokenizer.prototype.addLocInfo = function () { |
|
7879 if (this.options.loc) { |
|
7880 this.token.loc = { |
|
7881 start: { |
|
7882 line: this.startLine, |
|
7883 column: this.startColumn |
|
7884 }, |
|
7885 end: { |
|
7886 line: this.tokenizer.line, |
|
7887 column: this.tokenizer.column |
|
7888 } |
|
7889 }; |
|
7890 } |
|
7891 this.startLine = this.tokenizer.line; |
|
7892 this.startColumn = this.tokenizer.column; |
|
7893 }; |
|
7894 // Data |
|
7895 Tokenizer.prototype.beginData = function () { |
|
7896 this.token = { |
|
7897 type: 'Chars', |
|
7898 chars: '' |
|
7899 }; |
|
7900 this.tokens.push(this.token); |
|
7901 }; |
|
7902 Tokenizer.prototype.appendToData = function (char) { |
|
7903 this.token.chars += char; |
|
7904 }; |
|
7905 Tokenizer.prototype.finishData = function () { |
|
7906 this.addLocInfo(); |
|
7907 }; |
|
7908 // Comment |
|
7909 Tokenizer.prototype.beginComment = function () { |
|
7910 this.token = { |
|
7911 type: 'Comment', |
|
7912 chars: '' |
|
7913 }; |
|
7914 this.tokens.push(this.token); |
|
7915 }; |
|
7916 Tokenizer.prototype.appendToCommentData = function (char) { |
|
7917 this.token.chars += char; |
|
7918 }; |
|
7919 Tokenizer.prototype.finishComment = function () { |
|
7920 this.addLocInfo(); |
|
7921 }; |
|
7922 // Tags - basic |
|
7923 Tokenizer.prototype.beginStartTag = function () { |
|
7924 this.token = { |
|
7925 type: 'StartTag', |
|
7926 tagName: '', |
|
7927 attributes: [], |
|
7928 selfClosing: false |
|
7929 }; |
|
7930 this.tokens.push(this.token); |
|
7931 }; |
|
7932 Tokenizer.prototype.beginEndTag = function () { |
|
7933 this.token = { |
|
7934 type: 'EndTag', |
|
7935 tagName: '' |
|
7936 }; |
|
7937 this.tokens.push(this.token); |
|
7938 }; |
|
7939 Tokenizer.prototype.finishTag = function () { |
|
7940 this.addLocInfo(); |
|
7941 }; |
|
7942 Tokenizer.prototype.markTagAsSelfClosing = function () { |
|
7943 this.token.selfClosing = true; |
|
7944 }; |
|
7945 // Tags - name |
|
7946 Tokenizer.prototype.appendToTagName = function (char) { |
|
7947 this.token.tagName += char; |
|
7948 }; |
|
7949 // Tags - attributes |
|
7950 Tokenizer.prototype.beginAttribute = function () { |
|
7951 var attributes = unwrap(this.token.attributes, "current token's attributs"); |
|
7952 this.currentAttribute = ["", "", false]; |
|
7953 attributes.push(this.currentAttribute); |
|
7954 }; |
|
7955 Tokenizer.prototype.appendToAttributeName = function (char) { |
|
7956 var currentAttribute = unwrap(this.currentAttribute); |
|
7957 currentAttribute[0] += char; |
|
7958 }; |
|
7959 Tokenizer.prototype.beginAttributeValue = function (isQuoted) { |
|
7960 var currentAttribute = unwrap(this.currentAttribute); |
|
7961 currentAttribute[2] = isQuoted; |
|
7962 }; |
|
7963 Tokenizer.prototype.appendToAttributeValue = function (char) { |
|
7964 var currentAttribute = unwrap(this.currentAttribute); |
|
7965 currentAttribute[1] = currentAttribute[1] || ""; |
|
7966 currentAttribute[1] += char; |
|
7967 }; |
|
7968 Tokenizer.prototype.finishAttributeValue = function () { |
|
7969 }; |
|
7970 Tokenizer.prototype.reportSyntaxError = function (message) { |
|
7971 this.token.syntaxError = message; |
|
7972 }; |
|
7973 return Tokenizer; |
|
7974 }()); |
|
7975 /* harmony default export */ var tokenizer = (tokenizer_Tokenizer); |
|
7976 |
|
7977 // EXTERNAL MODULE: external {"this":["wp","htmlEntities"]} |
|
7978 var external_this_wp_htmlEntities_ = __webpack_require__(57); |
|
7979 |
|
7980 // EXTERNAL MODULE: external {"this":["wp","isShallowEqual"]} |
|
7981 var external_this_wp_isShallowEqual_ = __webpack_require__(42); |
|
7982 var external_this_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_isShallowEqual_); |
|
7983 |
|
7984 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js |
|
7985 var esm_extends = __webpack_require__(19); |
|
7986 |
|
7987 // EXTERNAL MODULE: external {"this":["wp","compose"]} |
|
7988 var external_this_wp_compose_ = __webpack_require__(6); |
|
7989 |
|
7990 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/block-content-provider/index.js |
|
7991 |
|
7992 |
|
7993 |
|
7994 /** |
|
7995 * WordPress dependencies |
|
7996 */ |
|
7997 |
|
7998 |
|
7999 /** |
|
8000 * Internal dependencies |
|
8001 */ |
|
8002 |
|
8003 |
|
8004 |
|
8005 var _createContext = Object(external_this_wp_element_["createContext"])(function () {}), |
|
8006 Consumer = _createContext.Consumer, |
|
8007 Provider = _createContext.Provider; |
|
8008 /** |
|
8009 * An internal block component used in block content serialization to inject |
|
8010 * nested block content within the `save` implementation of the ancestor |
|
8011 * component in which it is nested. The component provides a pre-bound |
|
8012 * `BlockContent` component via context, which is used by the developer-facing |
|
8013 * `InnerBlocks.Content` component to render block content. |
|
8014 * |
|
8015 * @example |
|
8016 * |
|
8017 * ```jsx |
|
8018 * <BlockContentProvider innerBlocks={ innerBlocks }> |
|
8019 * { blockSaveElement } |
|
8020 * </BlockContentProvider> |
|
8021 * ``` |
|
8022 * |
|
8023 * @return {WPElement} Element with BlockContent injected via context. |
|
8024 */ |
|
8025 |
|
8026 |
|
8027 var block_content_provider_BlockContentProvider = function BlockContentProvider(_ref) { |
|
8028 var children = _ref.children, |
|
8029 innerBlocks = _ref.innerBlocks; |
|
8030 |
|
8031 var BlockContent = function BlockContent() { |
|
8032 // Value is an array of blocks, so defer to block serializer |
|
8033 var html = serialize(innerBlocks); // Use special-cased raw HTML tag to avoid default escaping |
|
8034 |
|
8035 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["RawHTML"], null, html); |
|
8036 }; |
|
8037 |
|
8038 return Object(external_this_wp_element_["createElement"])(Provider, { |
|
8039 value: BlockContent |
|
8040 }, children); |
|
8041 }; |
|
8042 /** |
|
8043 * A Higher Order Component used to inject BlockContent using context to the |
|
8044 * wrapped component. |
|
8045 * |
|
8046 * @return {Component} Enhanced component with injected BlockContent as prop. |
|
8047 */ |
|
8048 |
|
8049 |
|
8050 var withBlockContentContext = Object(external_this_wp_compose_["createHigherOrderComponent"])(function (OriginalComponent) { |
|
8051 return function (props) { |
|
8052 return Object(external_this_wp_element_["createElement"])(Consumer, null, function (context) { |
|
8053 return Object(external_this_wp_element_["createElement"])(OriginalComponent, Object(esm_extends["a" /* default */])({}, props, { |
|
8054 BlockContent: context |
|
8055 })); |
|
8056 }); |
|
8057 }; |
|
8058 }, 'withBlockContentContext'); |
|
8059 /* harmony default export */ var block_content_provider = (block_content_provider_BlockContentProvider); |
|
8060 |
|
8061 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/serializer.js |
|
8062 |
|
8063 |
|
8064 |
|
8065 /** |
|
8066 * External dependencies |
|
8067 */ |
|
8068 |
|
8069 /** |
|
8070 * WordPress dependencies |
|
8071 */ |
|
8072 |
|
8073 |
|
8074 |
|
8075 |
|
8076 /** |
|
8077 * Internal dependencies |
|
8078 */ |
|
8079 |
|
8080 |
|
8081 |
|
8082 |
|
8083 /** |
|
8084 * Returns the block's default classname from its name. |
|
8085 * |
|
8086 * @param {string} blockName The block name. |
|
8087 * |
|
8088 * @return {string} The block's default class. |
|
8089 */ |
|
8090 |
|
8091 function getBlockDefaultClassName(blockName) { |
|
8092 // Generated HTML classes for blocks follow the `wp-block-{name}` nomenclature. |
|
8093 // Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (used in 'core-embed/'). |
|
8094 var className = 'wp-block-' + blockName.replace(/\//, '-').replace(/^core-/, ''); |
|
8095 return Object(external_this_wp_hooks_["applyFilters"])('blocks.getBlockDefaultClassName', className, blockName); |
|
8096 } |
|
8097 /** |
|
8098 * Returns the block's default menu item classname from its name. |
|
8099 * |
|
8100 * @param {string} blockName The block name. |
|
8101 * |
|
8102 * @return {string} The block's default menu item class. |
|
8103 */ |
|
8104 |
|
8105 function getBlockMenuDefaultClassName(blockName) { |
|
8106 // Generated HTML classes for blocks follow the `editor-block-list-item-{name}` nomenclature. |
|
8107 // Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (used in 'core-embed/'). |
|
8108 var className = 'editor-block-list-item-' + blockName.replace(/\//, '-').replace(/^core-/, ''); |
|
8109 return Object(external_this_wp_hooks_["applyFilters"])('blocks.getBlockMenuDefaultClassName', className, blockName); |
|
8110 } |
|
8111 /** |
|
8112 * Given a block type containing a save render implementation and attributes, returns the |
|
8113 * enhanced element to be saved or string when raw HTML expected. |
|
8114 * |
|
8115 * @param {string|Object} blockTypeOrName Block type or name. |
|
8116 * @param {Object} attributes Block attributes. |
|
8117 * @param {?Array} innerBlocks Nested blocks. |
|
8118 * |
|
8119 * @return {Object|string} Save element or raw HTML string. |
|
8120 */ |
|
8121 |
|
8122 function getSaveElement(blockTypeOrName, attributes) { |
|
8123 var innerBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; |
|
8124 var blockType = normalizeBlockType(blockTypeOrName); |
|
8125 var save = blockType.save; // Component classes are unsupported for save since serialization must |
|
8126 // occur synchronously. For improved interoperability with higher-order |
|
8127 // components which often return component class, emulate basic support. |
|
8128 |
|
8129 if (save.prototype instanceof external_this_wp_element_["Component"]) { |
|
8130 var instance = new save({ |
|
8131 attributes: attributes |
|
8132 }); |
|
8133 save = instance.render.bind(instance); |
|
8134 } |
|
8135 |
|
8136 var element = save({ |
|
8137 attributes: attributes, |
|
8138 innerBlocks: innerBlocks |
|
8139 }); |
|
8140 |
|
8141 if (Object(external_lodash_["isObject"])(element) && Object(external_this_wp_hooks_["hasFilter"])('blocks.getSaveContent.extraProps')) { |
|
8142 /** |
|
8143 * Filters the props applied to the block save result element. |
|
8144 * |
|
8145 * @param {Object} props Props applied to save element. |
|
8146 * @param {WPBlockType} blockType Block type definition. |
|
8147 * @param {Object} attributes Block attributes. |
|
8148 */ |
|
8149 var props = Object(external_this_wp_hooks_["applyFilters"])('blocks.getSaveContent.extraProps', Object(objectSpread["a" /* default */])({}, element.props), blockType, attributes); |
|
8150 |
|
8151 if (!external_this_wp_isShallowEqual_default()(props, element.props)) { |
|
8152 element = Object(external_this_wp_element_["cloneElement"])(element, props); |
|
8153 } |
|
8154 } |
|
8155 /** |
|
8156 * Filters the save result of a block during serialization. |
|
8157 * |
|
8158 * @param {WPElement} element Block save result. |
|
8159 * @param {WPBlockType} blockType Block type definition. |
|
8160 * @param {Object} attributes Block attributes. |
|
8161 */ |
|
8162 |
|
8163 |
|
8164 element = Object(external_this_wp_hooks_["applyFilters"])('blocks.getSaveElement', element, blockType, attributes); |
|
8165 return Object(external_this_wp_element_["createElement"])(block_content_provider, { |
|
8166 innerBlocks: innerBlocks |
|
8167 }, element); |
|
8168 } |
|
8169 /** |
|
8170 * Given a block type containing a save render implementation and attributes, returns the |
|
8171 * static markup to be saved. |
|
8172 * |
|
8173 * @param {string|Object} blockTypeOrName Block type or name. |
|
8174 * @param {Object} attributes Block attributes. |
|
8175 * @param {?Array} innerBlocks Nested blocks. |
|
8176 * |
|
8177 * @return {string} Save content. |
|
8178 */ |
|
8179 |
|
8180 function getSaveContent(blockTypeOrName, attributes, innerBlocks) { |
|
8181 var blockType = normalizeBlockType(blockTypeOrName); |
|
8182 return Object(external_this_wp_element_["renderToString"])(getSaveElement(blockType, attributes, innerBlocks)); |
|
8183 } |
|
8184 /** |
|
8185 * Returns attributes which are to be saved and serialized into the block |
|
8186 * comment delimiter. |
|
8187 * |
|
8188 * When a block exists in memory it contains as its attributes both those |
|
8189 * parsed the block comment delimiter _and_ those which matched from the |
|
8190 * contents of the block. |
|
8191 * |
|
8192 * This function returns only those attributes which are needed to persist and |
|
8193 * which cannot be matched from the block content. |
|
8194 * |
|
8195 * @param {Object<string,*>} blockType Block type. |
|
8196 * @param {Object<string,*>} attributes Attributes from in-memory block data. |
|
8197 * |
|
8198 * @return {Object<string,*>} Subset of attributes for comment serialization. |
|
8199 */ |
|
8200 |
|
8201 function getCommentAttributes(blockType, attributes) { |
|
8202 return Object(external_lodash_["reduce"])(blockType.attributes, function (result, attributeSchema, key) { |
|
8203 var value = attributes[key]; // Ignore undefined values. |
|
8204 |
|
8205 if (undefined === value) { |
|
8206 return result; |
|
8207 } // Ignore all attributes but the ones with an "undefined" source |
|
8208 // "undefined" source refers to attributes saved in the block comment. |
|
8209 |
|
8210 |
|
8211 if (attributeSchema.source !== undefined) { |
|
8212 return result; |
|
8213 } // Ignore default value. |
|
8214 |
|
8215 |
|
8216 if ('default' in attributeSchema && attributeSchema.default === value) { |
|
8217 return result; |
|
8218 } // Otherwise, include in comment set. |
|
8219 |
|
8220 |
|
8221 result[key] = value; |
|
8222 return result; |
|
8223 }, {}); |
|
8224 } |
|
8225 /** |
|
8226 * Given an attributes object, returns a string in the serialized attributes |
|
8227 * format prepared for post content. |
|
8228 * |
|
8229 * @param {Object} attributes Attributes object. |
|
8230 * |
|
8231 * @return {string} Serialized attributes. |
|
8232 */ |
|
8233 |
|
8234 function serializeAttributes(attributes) { |
|
8235 return JSON.stringify(attributes) // Don't break HTML comments. |
|
8236 .replace(/--/g, "\\u002d\\u002d") // Don't break non-standard-compliant tools. |
|
8237 .replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026") // Bypass server stripslashes behavior which would unescape stringify's |
|
8238 // escaping of quotation mark. |
|
8239 // |
|
8240 // See: https://developer.wordpress.org/reference/functions/wp_kses_stripslashes/ |
|
8241 .replace(/\\"/g, "\\u0022"); |
|
8242 } |
|
8243 /** |
|
8244 * Given a block object, returns the Block's Inner HTML markup. |
|
8245 * |
|
8246 * @param {Object} block Block instance. |
|
8247 * |
|
8248 * @return {string} HTML. |
|
8249 */ |
|
8250 |
|
8251 function getBlockContent(block) { |
|
8252 // @todo why not getBlockInnerHtml? |
|
8253 // If block was parsed as invalid or encounters an error while generating |
|
8254 // save content, use original content instead to avoid content loss. If a |
|
8255 // block contains nested content, exempt it from this condition because we |
|
8256 // otherwise have no access to its original content and content loss would |
|
8257 // still occur. |
|
8258 var saveContent = block.originalContent; |
|
8259 |
|
8260 if (block.isValid || block.innerBlocks.length) { |
|
8261 try { |
|
8262 saveContent = getSaveContent(block.name, block.attributes, block.innerBlocks); |
|
8263 } catch (error) {} |
|
8264 } |
|
8265 |
|
8266 return saveContent; |
|
8267 } |
|
8268 /** |
|
8269 * Returns the content of a block, including comment delimiters. |
|
8270 * |
|
8271 * @param {string} rawBlockName Block name. |
|
8272 * @param {Object} attributes Block attributes. |
|
8273 * @param {string} content Block save content. |
|
8274 * |
|
8275 * @return {string} Comment-delimited block content. |
|
8276 */ |
|
8277 |
|
8278 function getCommentDelimitedContent(rawBlockName, attributes, content) { |
|
8279 var serializedAttributes = !Object(external_lodash_["isEmpty"])(attributes) ? serializeAttributes(attributes) + ' ' : ''; // Strip core blocks of their namespace prefix. |
|
8280 |
|
8281 var blockName = Object(external_lodash_["startsWith"])(rawBlockName, 'core/') ? rawBlockName.slice(5) : rawBlockName; // @todo make the `wp:` prefix potentially configurable. |
|
8282 |
|
8283 if (!content) { |
|
8284 return "<!-- wp:".concat(blockName, " ").concat(serializedAttributes, "/-->"); |
|
8285 } |
|
8286 |
|
8287 return "<!-- wp:".concat(blockName, " ").concat(serializedAttributes, "-->\n") + content + "\n<!-- /wp:".concat(blockName, " -->"); |
|
8288 } |
|
8289 /** |
|
8290 * Returns the content of a block, including comment delimiters, determining |
|
8291 * serialized attributes and content form from the current state of the block. |
|
8292 * |
|
8293 * @param {Object} block Block instance. |
|
8294 * |
|
8295 * @return {string} Serialized block. |
|
8296 */ |
|
8297 |
|
8298 function serializeBlock(block) { |
|
8299 var blockName = block.name; |
|
8300 var saveContent = getBlockContent(block); |
|
8301 |
|
8302 switch (blockName) { |
|
8303 case getFreeformContentHandlerName(): |
|
8304 case getUnregisteredTypeHandlerName(): |
|
8305 return saveContent; |
|
8306 |
|
8307 default: |
|
8308 { |
|
8309 var blockType = registration_getBlockType(blockName); |
|
8310 var saveAttributes = getCommentAttributes(blockType, block.attributes); |
|
8311 return getCommentDelimitedContent(blockName, saveAttributes, saveContent); |
|
8312 } |
|
8313 } |
|
8314 } |
|
8315 /** |
|
8316 * Takes a block or set of blocks and returns the serialized post content. |
|
8317 * |
|
8318 * @param {Array} blocks Block(s) to serialize. |
|
8319 * |
|
8320 * @return {string} The post content. |
|
8321 */ |
|
8322 |
|
8323 function serialize(blocks) { |
|
8324 return Object(external_lodash_["castArray"])(blocks).map(serializeBlock).join('\n\n'); |
|
8325 } |
|
8326 |
|
8327 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation.js |
|
8328 |
|
8329 |
|
8330 |
|
8331 |
|
8332 |
|
8333 |
|
8334 |
|
8335 /** |
|
8336 * External dependencies |
|
8337 */ |
|
8338 |
|
8339 |
|
8340 /** |
|
8341 * WordPress dependencies |
|
8342 */ |
|
8343 |
|
8344 |
|
8345 /** |
|
8346 * Internal dependencies |
|
8347 */ |
|
8348 |
|
8349 |
|
8350 |
|
8351 /** |
|
8352 * Globally matches any consecutive whitespace |
|
8353 * |
|
8354 * @type {RegExp} |
|
8355 */ |
|
8356 |
|
8357 var REGEXP_WHITESPACE = /[\t\n\r\v\f ]+/g; |
|
8358 /** |
|
8359 * Matches a string containing only whitespace |
|
8360 * |
|
8361 * @type {RegExp} |
|
8362 */ |
|
8363 |
|
8364 var REGEXP_ONLY_WHITESPACE = /^[\t\n\r\v\f ]*$/; |
|
8365 /** |
|
8366 * Matches a CSS URL type value |
|
8367 * |
|
8368 * @type {RegExp} |
|
8369 */ |
|
8370 |
|
8371 var REGEXP_STYLE_URL_TYPE = /^url\s*\(['"\s]*(.*?)['"\s]*\)$/; |
|
8372 /** |
|
8373 * Boolean attributes are attributes whose presence as being assigned is |
|
8374 * meaningful, even if only empty. |
|
8375 * |
|
8376 * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes |
|
8377 * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3 |
|
8378 * |
|
8379 * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ] |
|
8380 * .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 ) |
|
8381 * .reduce( ( result, tr ) => Object.assign( result, { |
|
8382 * [ tr.firstChild.textContent.trim() ]: true |
|
8383 * } ), {} ) ).sort(); |
|
8384 * |
|
8385 * @type {Array} |
|
8386 */ |
|
8387 |
|
8388 var BOOLEAN_ATTRIBUTES = ['allowfullscreen', 'allowpaymentrequest', 'allowusermedia', 'async', 'autofocus', 'autoplay', 'checked', 'controls', 'default', 'defer', 'disabled', 'download', 'formnovalidate', 'hidden', 'ismap', 'itemscope', 'loop', 'multiple', 'muted', 'nomodule', 'novalidate', 'open', 'playsinline', 'readonly', 'required', 'reversed', 'selected', 'typemustmatch']; |
|
8389 /** |
|
8390 * Enumerated attributes are attributes which must be of a specific value form. |
|
8391 * Like boolean attributes, these are meaningful if specified, even if not of a |
|
8392 * valid enumerated value. |
|
8393 * |
|
8394 * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute |
|
8395 * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3 |
|
8396 * |
|
8397 * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ] |
|
8398 * .filter( ( tr ) => /^("(.+?)";?\s*)+/.test( tr.lastChild.textContent.trim() ) ) |
|
8399 * .reduce( ( result, tr ) => Object.assign( result, { |
|
8400 * [ tr.firstChild.textContent.trim() ]: true |
|
8401 * } ), {} ) ).sort(); |
|
8402 * |
|
8403 * @type {Array} |
|
8404 */ |
|
8405 |
|
8406 var ENUMERATED_ATTRIBUTES = ['autocapitalize', 'autocomplete', 'charset', 'contenteditable', 'crossorigin', 'decoding', 'dir', 'draggable', 'enctype', 'formenctype', 'formmethod', 'http-equiv', 'inputmode', 'kind', 'method', 'preload', 'scope', 'shape', 'spellcheck', 'translate', 'type', 'wrap']; |
|
8407 /** |
|
8408 * Meaningful attributes are those who cannot be safely ignored when omitted in |
|
8409 * one HTML markup string and not another. |
|
8410 * |
|
8411 * @type {Array} |
|
8412 */ |
|
8413 |
|
8414 var MEANINGFUL_ATTRIBUTES = [].concat(BOOLEAN_ATTRIBUTES, ENUMERATED_ATTRIBUTES); |
|
8415 /** |
|
8416 * Array of functions which receive a text string on which to apply normalizing |
|
8417 * behavior for consideration in text token equivalence, carefully ordered from |
|
8418 * least-to-most expensive operations. |
|
8419 * |
|
8420 * @type {Array} |
|
8421 */ |
|
8422 |
|
8423 var TEXT_NORMALIZATIONS = [external_lodash_["identity"], getTextWithCollapsedWhitespace]; |
|
8424 /** |
|
8425 * Regular expression matching a named character reference. In lieu of bundling |
|
8426 * a full set of references, the pattern covers the minimal necessary to test |
|
8427 * positively against the full set. |
|
8428 * |
|
8429 * "The ampersand must be followed by one of the names given in the named |
|
8430 * character references section, using the same case." |
|
8431 * |
|
8432 * Tested aginst "12.5 Named character references": |
|
8433 * |
|
8434 * ``` |
|
8435 * const references = [ ...document.querySelectorAll( |
|
8436 * '#named-character-references-table tr[id^=entity-] td:first-child' |
|
8437 * ) ].map( ( code ) => code.textContent ) |
|
8438 * references.every( ( reference ) => /^[\da-z]+$/i.test( reference ) ) |
|
8439 * ``` |
|
8440 * |
|
8441 * @link https://html.spec.whatwg.org/multipage/syntax.html#character-references |
|
8442 * @link https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references |
|
8443 * |
|
8444 * @type {RegExp} |
|
8445 */ |
|
8446 |
|
8447 var REGEXP_NAMED_CHARACTER_REFERENCE = /^[\da-z]+$/i; |
|
8448 /** |
|
8449 * Regular expression matching a decimal character reference. |
|
8450 * |
|
8451 * "The ampersand must be followed by a U+0023 NUMBER SIGN character (#), |
|
8452 * followed by one or more ASCII digits, representing a base-ten integer" |
|
8453 * |
|
8454 * @link https://html.spec.whatwg.org/multipage/syntax.html#character-references |
|
8455 * |
|
8456 * @type {RegExp} |
|
8457 */ |
|
8458 |
|
8459 var REGEXP_DECIMAL_CHARACTER_REFERENCE = /^#\d+$/; |
|
8460 /** |
|
8461 * Regular expression matching a hexadecimal character reference. |
|
8462 * |
|
8463 * "The ampersand must be followed by a U+0023 NUMBER SIGN character (#), which |
|
8464 * must be followed by either a U+0078 LATIN SMALL LETTER X character (x) or a |
|
8465 * U+0058 LATIN CAPITAL LETTER X character (X), which must then be followed by |
|
8466 * one or more ASCII hex digits, representing a hexadecimal integer" |
|
8467 * |
|
8468 * @link https://html.spec.whatwg.org/multipage/syntax.html#character-references |
|
8469 * |
|
8470 * @type {RegExp} |
|
8471 */ |
|
8472 |
|
8473 var REGEXP_HEXADECIMAL_CHARACTER_REFERENCE = /^#x[\da-f]+$/i; |
|
8474 /** |
|
8475 * Returns true if the given string is a valid character reference segment, or |
|
8476 * false otherwise. The text should be stripped of `&` and `;` demarcations. |
|
8477 * |
|
8478 * @param {string} text Text to test. |
|
8479 * |
|
8480 * @return {boolean} Whether text is valid character reference. |
|
8481 */ |
|
8482 |
|
8483 function isValidCharacterReference(text) { |
|
8484 return REGEXP_NAMED_CHARACTER_REFERENCE.test(text) || REGEXP_DECIMAL_CHARACTER_REFERENCE.test(text) || REGEXP_HEXADECIMAL_CHARACTER_REFERENCE.test(text); |
|
8485 } |
|
8486 /** |
|
8487 * Subsitute EntityParser class for `simple-html-tokenizer` which uses the |
|
8488 * implementation of `decodeEntities` from `html-entities`, in order to avoid |
|
8489 * bundling a massive named character reference. |
|
8490 * |
|
8491 * @see https://github.com/tildeio/simple-html-tokenizer/tree/master/src/entity-parser.ts |
|
8492 */ |
|
8493 |
|
8494 var validation_DecodeEntityParser = |
|
8495 /*#__PURE__*/ |
|
8496 function () { |
|
8497 function DecodeEntityParser() { |
|
8498 Object(classCallCheck["a" /* default */])(this, DecodeEntityParser); |
|
8499 } |
|
8500 |
|
8501 Object(createClass["a" /* default */])(DecodeEntityParser, [{ |
|
8502 key: "parse", |
|
8503 |
|
8504 /** |
|
8505 * Returns a substitute string for an entity string sequence between `&` |
|
8506 * and `;`, or undefined if no substitution should occur. |
|
8507 * |
|
8508 * @param {string} entity Entity fragment discovered in HTML. |
|
8509 * |
|
8510 * @return {?string} Entity substitute value. |
|
8511 */ |
|
8512 value: function parse(entity) { |
|
8513 if (isValidCharacterReference(entity)) { |
|
8514 return Object(external_this_wp_htmlEntities_["decodeEntities"])('&' + entity + ';'); |
|
8515 } |
|
8516 } |
|
8517 }]); |
|
8518 |
|
8519 return DecodeEntityParser; |
|
8520 }(); |
|
8521 /** |
|
8522 * Object of logger functions. |
|
8523 */ |
|
8524 |
|
8525 var log = function () { |
|
8526 /** |
|
8527 * Creates a logger with block validation prefix. |
|
8528 * |
|
8529 * @param {Function} logger Original logger function. |
|
8530 * |
|
8531 * @return {Function} Augmented logger function. |
|
8532 */ |
|
8533 function createLogger(logger) { |
|
8534 // In test environments, pre-process the sprintf message to improve |
|
8535 // readability of error messages. We'd prefer to avoid pulling in this |
|
8536 // dependency in runtime environments, and it can be dropped by a combo |
|
8537 // of Webpack env substitution + UglifyJS dead code elimination. |
|
8538 if (false) {} |
|
8539 |
|
8540 return function (message) { |
|
8541 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|
8542 args[_key - 1] = arguments[_key]; |
|
8543 } |
|
8544 |
|
8545 return logger.apply(void 0, ['Block validation: ' + message].concat(args)); |
|
8546 }; |
|
8547 } |
|
8548 |
|
8549 return { |
|
8550 /* eslint-disable no-console */ |
|
8551 error: createLogger(console.error), |
|
8552 warning: createLogger(console.warn) |
|
8553 /* eslint-enable no-console */ |
|
8554 |
|
8555 }; |
|
8556 }(); |
|
8557 /** |
|
8558 * Given a specified string, returns an array of strings split by consecutive |
|
8559 * whitespace, ignoring leading or trailing whitespace. |
|
8560 * |
|
8561 * @param {string} text Original text. |
|
8562 * |
|
8563 * @return {string[]} Text pieces split on whitespace. |
|
8564 */ |
|
8565 |
|
8566 |
|
8567 function getTextPiecesSplitOnWhitespace(text) { |
|
8568 return text.trim().split(REGEXP_WHITESPACE); |
|
8569 } |
|
8570 /** |
|
8571 * Given a specified string, returns a new trimmed string where all consecutive |
|
8572 * whitespace is collapsed to a single space. |
|
8573 * |
|
8574 * @param {string} text Original text. |
|
8575 * |
|
8576 * @return {string} Trimmed text with consecutive whitespace collapsed. |
|
8577 */ |
|
8578 |
|
8579 function getTextWithCollapsedWhitespace(text) { |
|
8580 // This is an overly simplified whitespace comparison. The specification is |
|
8581 // more prescriptive of whitespace behavior in inline and block contexts. |
|
8582 // |
|
8583 // See: https://medium.com/@patrickbrosset/when-does-white-space-matter-in-html-b90e8a7cdd33 |
|
8584 return getTextPiecesSplitOnWhitespace(text).join(' '); |
|
8585 } |
|
8586 /** |
|
8587 * Returns attribute pairs of the given StartTag token, including only pairs |
|
8588 * where the value is non-empty or the attribute is a boolean attribute, an |
|
8589 * enumerated attribute, or a custom data- attribute. |
|
8590 * |
|
8591 * @see MEANINGFUL_ATTRIBUTES |
|
8592 * |
|
8593 * @param {Object} token StartTag token. |
|
8594 * |
|
8595 * @return {Array[]} Attribute pairs. |
|
8596 */ |
|
8597 |
|
8598 function getMeaningfulAttributePairs(token) { |
|
8599 return token.attributes.filter(function (pair) { |
|
8600 var _pair = Object(slicedToArray["a" /* default */])(pair, 2), |
|
8601 key = _pair[0], |
|
8602 value = _pair[1]; |
|
8603 |
|
8604 return value || key.indexOf('data-') === 0 || Object(external_lodash_["includes"])(MEANINGFUL_ATTRIBUTES, key); |
|
8605 }); |
|
8606 } |
|
8607 /** |
|
8608 * Returns true if two text tokens (with `chars` property) are equivalent, or |
|
8609 * false otherwise. |
|
8610 * |
|
8611 * @param {Object} actual Actual token. |
|
8612 * @param {Object} expected Expected token. |
|
8613 * |
|
8614 * @return {boolean} Whether two text tokens are equivalent. |
|
8615 */ |
|
8616 |
|
8617 function isEquivalentTextTokens(actual, expected) { |
|
8618 // This function is intentionally written as syntactically "ugly" as a hot |
|
8619 // path optimization. Text is progressively normalized in order from least- |
|
8620 // to-most operationally expensive, until the earliest point at which text |
|
8621 // can be confidently inferred as being equal. |
|
8622 var actualChars = actual.chars; |
|
8623 var expectedChars = expected.chars; |
|
8624 |
|
8625 for (var i = 0; i < TEXT_NORMALIZATIONS.length; i++) { |
|
8626 var normalize = TEXT_NORMALIZATIONS[i]; |
|
8627 actualChars = normalize(actualChars); |
|
8628 expectedChars = normalize(expectedChars); |
|
8629 |
|
8630 if (actualChars === expectedChars) { |
|
8631 return true; |
|
8632 } |
|
8633 } |
|
8634 |
|
8635 log.warning('Expected text `%s`, saw `%s`.', expected.chars, actual.chars); |
|
8636 return false; |
|
8637 } |
|
8638 /** |
|
8639 * Given a style value, returns a normalized style value for strict equality |
|
8640 * comparison. |
|
8641 * |
|
8642 * @param {string} value Style value. |
|
8643 * |
|
8644 * @return {string} Normalized style value. |
|
8645 */ |
|
8646 |
|
8647 function getNormalizedStyleValue(value) { |
|
8648 return value // Normalize URL type to omit whitespace or quotes |
|
8649 .replace(REGEXP_STYLE_URL_TYPE, 'url($1)'); |
|
8650 } |
|
8651 /** |
|
8652 * Given a style attribute string, returns an object of style properties. |
|
8653 * |
|
8654 * @param {string} text Style attribute. |
|
8655 * |
|
8656 * @return {Object} Style properties. |
|
8657 */ |
|
8658 |
|
8659 function getStyleProperties(text) { |
|
8660 var pairs = text // Trim ending semicolon (avoid including in split) |
|
8661 .replace(/;?\s*$/, '') // Split on property assignment |
|
8662 .split(';') // For each property assignment... |
|
8663 .map(function (style) { |
|
8664 // ...split further into key-value pairs |
|
8665 var _style$split = style.split(':'), |
|
8666 _style$split2 = _toArray(_style$split), |
|
8667 key = _style$split2[0], |
|
8668 valueParts = _style$split2.slice(1); |
|
8669 |
|
8670 var value = valueParts.join(':'); |
|
8671 return [key.trim(), getNormalizedStyleValue(value.trim())]; |
|
8672 }); |
|
8673 return Object(external_lodash_["fromPairs"])(pairs); |
|
8674 } |
|
8675 /** |
|
8676 * Attribute-specific equality handlers |
|
8677 * |
|
8678 * @type {Object} |
|
8679 */ |
|
8680 |
|
8681 var isEqualAttributesOfName = Object(objectSpread["a" /* default */])({ |
|
8682 class: function _class(actual, expected) { |
|
8683 // Class matches if members are the same, even if out of order or |
|
8684 // superfluous whitespace between. |
|
8685 return !external_lodash_["xor"].apply(void 0, Object(toConsumableArray["a" /* default */])([actual, expected].map(getTextPiecesSplitOnWhitespace))).length; |
|
8686 }, |
|
8687 style: function style(actual, expected) { |
|
8688 return external_lodash_["isEqual"].apply(void 0, Object(toConsumableArray["a" /* default */])([actual, expected].map(getStyleProperties))); |
|
8689 } |
|
8690 }, Object(external_lodash_["fromPairs"])(BOOLEAN_ATTRIBUTES.map(function (attribute) { |
|
8691 return [attribute, external_lodash_["stubTrue"]]; |
|
8692 }))); |
|
8693 /** |
|
8694 * Given two sets of attribute tuples, returns true if the attribute sets are |
|
8695 * equivalent. |
|
8696 * |
|
8697 * @param {Array[]} actual Actual attributes tuples. |
|
8698 * @param {Array[]} expected Expected attributes tuples. |
|
8699 * |
|
8700 * @return {boolean} Whether attributes are equivalent. |
|
8701 */ |
|
8702 |
|
8703 function isEqualTagAttributePairs(actual, expected) { |
|
8704 // Attributes is tokenized as tuples. Their lengths should match. This also |
|
8705 // avoids us needing to check both attributes sets, since if A has any keys |
|
8706 // which do not exist in B, we know the sets to be different. |
|
8707 if (actual.length !== expected.length) { |
|
8708 log.warning('Expected attributes %o, instead saw %o.', expected, actual); |
|
8709 return false; |
|
8710 } // Convert tuples to object for ease of lookup |
|
8711 |
|
8712 |
|
8713 var _map = [actual, expected].map(external_lodash_["fromPairs"]), |
|
8714 _map2 = Object(slicedToArray["a" /* default */])(_map, 2), |
|
8715 actualAttributes = _map2[0], |
|
8716 expectedAttributes = _map2[1]; |
|
8717 |
|
8718 for (var name in actualAttributes) { |
|
8719 // As noted above, if missing member in B, assume different |
|
8720 if (!expectedAttributes.hasOwnProperty(name)) { |
|
8721 log.warning('Encountered unexpected attribute `%s`.', name); |
|
8722 return false; |
|
8723 } |
|
8724 |
|
8725 var actualValue = actualAttributes[name]; |
|
8726 var expectedValue = expectedAttributes[name]; |
|
8727 var isEqualAttributes = isEqualAttributesOfName[name]; |
|
8728 |
|
8729 if (isEqualAttributes) { |
|
8730 // Defer custom attribute equality handling |
|
8731 if (!isEqualAttributes(actualValue, expectedValue)) { |
|
8732 log.warning('Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue); |
|
8733 return false; |
|
8734 } |
|
8735 } else if (actualValue !== expectedValue) { |
|
8736 // Otherwise strict inequality should bail |
|
8737 log.warning('Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue); |
|
8738 return false; |
|
8739 } |
|
8740 } |
|
8741 |
|
8742 return true; |
|
8743 } |
|
8744 /** |
|
8745 * Token-type-specific equality handlers |
|
8746 * |
|
8747 * @type {Object} |
|
8748 */ |
|
8749 |
|
8750 var isEqualTokensOfType = { |
|
8751 StartTag: function StartTag(actual, expected) { |
|
8752 if (actual.tagName !== expected.tagName) { |
|
8753 log.warning('Expected tag name `%s`, instead saw `%s`.', expected.tagName, actual.tagName); |
|
8754 return false; |
|
8755 } |
|
8756 |
|
8757 return isEqualTagAttributePairs.apply(void 0, Object(toConsumableArray["a" /* default */])([actual, expected].map(getMeaningfulAttributePairs))); |
|
8758 }, |
|
8759 Chars: isEquivalentTextTokens, |
|
8760 Comment: isEquivalentTextTokens |
|
8761 }; |
|
8762 /** |
|
8763 * Given an array of tokens, returns the first token which is not purely |
|
8764 * whitespace. |
|
8765 * |
|
8766 * Mutates the tokens array. |
|
8767 * |
|
8768 * @param {Object[]} tokens Set of tokens to search. |
|
8769 * |
|
8770 * @return {Object} Next non-whitespace token. |
|
8771 */ |
|
8772 |
|
8773 function getNextNonWhitespaceToken(tokens) { |
|
8774 var token; |
|
8775 |
|
8776 while (token = tokens.shift()) { |
|
8777 if (token.type !== 'Chars') { |
|
8778 return token; |
|
8779 } |
|
8780 |
|
8781 if (!REGEXP_ONLY_WHITESPACE.test(token.chars)) { |
|
8782 return token; |
|
8783 } |
|
8784 } |
|
8785 } |
|
8786 /** |
|
8787 * Tokenize an HTML string, gracefully handling any errors thrown during |
|
8788 * underlying tokenization. |
|
8789 * |
|
8790 * @param {string} html HTML string to tokenize. |
|
8791 * |
|
8792 * @return {Object[]|null} Array of valid tokenized HTML elements, or null on error |
|
8793 */ |
|
8794 |
|
8795 function getHTMLTokens(html) { |
|
8796 try { |
|
8797 return new tokenizer(new validation_DecodeEntityParser()).tokenize(html); |
|
8798 } catch (e) { |
|
8799 log.warning('Malformed HTML detected: %s', html); |
|
8800 } |
|
8801 |
|
8802 return null; |
|
8803 } |
|
8804 /** |
|
8805 * Returns true if the next HTML token closes the current token. |
|
8806 * |
|
8807 * @param {Object} currentToken Current token to compare with. |
|
8808 * @param {Object|undefined} nextToken Next token to compare against. |
|
8809 * |
|
8810 * @return {boolean} true if `nextToken` closes `currentToken`, false otherwise |
|
8811 */ |
|
8812 |
|
8813 |
|
8814 function isClosedByToken(currentToken, nextToken) { |
|
8815 // Ensure this is a self closed token |
|
8816 if (!currentToken.selfClosing) { |
|
8817 return false; |
|
8818 } // Check token names and determine if nextToken is the closing tag for currentToken |
|
8819 |
|
8820 |
|
8821 if (nextToken && nextToken.tagName === currentToken.tagName && nextToken.type === 'EndTag') { |
|
8822 return true; |
|
8823 } |
|
8824 |
|
8825 return false; |
|
8826 } |
|
8827 /** |
|
8828 * Returns true if the given HTML strings are effectively equivalent, or |
|
8829 * false otherwise. Invalid HTML is not considered equivalent, even if the |
|
8830 * strings directly match. |
|
8831 * |
|
8832 * @param {string} actual Actual HTML string. |
|
8833 * @param {string} expected Expected HTML string. |
|
8834 * |
|
8835 * @return {boolean} Whether HTML strings are equivalent. |
|
8836 */ |
|
8837 |
|
8838 function isEquivalentHTML(actual, expected) { |
|
8839 // Tokenize input content and reserialized save content |
|
8840 var _map3 = [actual, expected].map(getHTMLTokens), |
|
8841 _map4 = Object(slicedToArray["a" /* default */])(_map3, 2), |
|
8842 actualTokens = _map4[0], |
|
8843 expectedTokens = _map4[1]; // If either is malformed then stop comparing - the strings are not equivalent |
|
8844 |
|
8845 |
|
8846 if (!actualTokens || !expectedTokens) { |
|
8847 return false; |
|
8848 } |
|
8849 |
|
8850 var actualToken, expectedToken; |
|
8851 |
|
8852 while (actualToken = getNextNonWhitespaceToken(actualTokens)) { |
|
8853 expectedToken = getNextNonWhitespaceToken(expectedTokens); // Inequal if exhausted all expected tokens |
|
8854 |
|
8855 if (!expectedToken) { |
|
8856 log.warning('Expected end of content, instead saw %o.', actualToken); |
|
8857 return false; |
|
8858 } // Inequal if next non-whitespace token of each set are not same type |
|
8859 |
|
8860 |
|
8861 if (actualToken.type !== expectedToken.type) { |
|
8862 log.warning('Expected token of type `%s` (%o), instead saw `%s` (%o).', expectedToken.type, expectedToken, actualToken.type, actualToken); |
|
8863 return false; |
|
8864 } // Defer custom token type equality handling, otherwise continue and |
|
8865 // assume as equal |
|
8866 |
|
8867 |
|
8868 var isEqualTokens = isEqualTokensOfType[actualToken.type]; |
|
8869 |
|
8870 if (isEqualTokens && !isEqualTokens(actualToken, expectedToken)) { |
|
8871 return false; |
|
8872 } // Peek at the next tokens (actual and expected) to see if they close |
|
8873 // a self-closing tag |
|
8874 |
|
8875 |
|
8876 if (isClosedByToken(actualToken, expectedTokens[0])) { |
|
8877 // Consume the next expected token that closes the current actual |
|
8878 // self-closing token |
|
8879 getNextNonWhitespaceToken(expectedTokens); |
|
8880 } else if (isClosedByToken(expectedToken, actualTokens[0])) { |
|
8881 // Consume the next actual token that closes the current expected |
|
8882 // self-closing token |
|
8883 getNextNonWhitespaceToken(actualTokens); |
|
8884 } |
|
8885 } |
|
8886 |
|
8887 if (expectedToken = getNextNonWhitespaceToken(expectedTokens)) { |
|
8888 // If any non-whitespace tokens remain in expected token set, this |
|
8889 // indicates inequality |
|
8890 log.warning('Expected %o, instead saw end of content.', expectedToken); |
|
8891 return false; |
|
8892 } |
|
8893 |
|
8894 return true; |
|
8895 } |
|
8896 /** |
|
8897 * Returns true if the parsed block is valid given the input content. A block |
|
8898 * is considered valid if, when serialized with assumed attributes, the content |
|
8899 * matches the original value. |
|
8900 * |
|
8901 * Logs to console in development environments when invalid. |
|
8902 * |
|
8903 * @param {string|Object} blockTypeOrName Block type. |
|
8904 * @param {Object} attributes Parsed block attributes. |
|
8905 * @param {string} originalBlockContent Original block content. |
|
8906 * |
|
8907 * @return {boolean} Whether block is valid. |
|
8908 */ |
|
8909 |
|
8910 function isValidBlockContent(blockTypeOrName, attributes, originalBlockContent) { |
|
8911 var blockType = normalizeBlockType(blockTypeOrName); |
|
8912 var generatedBlockContent; |
|
8913 |
|
8914 try { |
|
8915 generatedBlockContent = getSaveContent(blockType, attributes); |
|
8916 } catch (error) { |
|
8917 log.error('Block validation failed because an error occurred while generating block content:\n\n%s', error.toString()); |
|
8918 return false; |
|
8919 } |
|
8920 |
|
8921 var isValid = isEquivalentHTML(originalBlockContent, generatedBlockContent); |
|
8922 |
|
8923 if (!isValid) { |
|
8924 log.error('Block validation failed for `%s` (%o).\n\nContent generated by `save` function:\n\n%s\n\nContent retrieved from post body:\n\n%s', blockType.name, blockType, generatedBlockContent, originalBlockContent); |
|
8925 } |
|
8926 |
|
8927 return isValid; |
|
8928 } |
|
8929 |
|
8930 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/children.js |
|
8931 /** |
|
8932 * External dependencies |
|
8933 */ |
|
8934 |
|
8935 /** |
|
8936 * WordPress dependencies |
|
8937 */ |
|
8938 |
|
8939 |
|
8940 /** |
|
8941 * Internal dependencies |
|
8942 */ |
|
8943 |
|
8944 |
|
8945 /** |
|
8946 * A representation of a block's rich text value. |
|
8947 * |
|
8948 * @typedef {WPBlockNode[]} WPBlockChildren |
|
8949 */ |
|
8950 |
|
8951 /** |
|
8952 * Given block children, returns a serialize-capable WordPress element. |
|
8953 * |
|
8954 * @param {WPBlockChildren} children Block children object to convert. |
|
8955 * |
|
8956 * @return {WPElement} A serialize-capable element. |
|
8957 */ |
|
8958 |
|
8959 function getSerializeCapableElement(children) { |
|
8960 // The fact that block children are compatible with the element serializer is |
|
8961 // merely an implementation detail that currently serves to be true, but |
|
8962 // should not be mistaken as being a guarantee on the external API. The |
|
8963 // public API only offers guarantees to work with strings (toHTML) and DOM |
|
8964 // elements (fromDOM), and should provide utilities to manipulate the value |
|
8965 // rather than expect consumers to inspect or construct its shape (concat). |
|
8966 return children; |
|
8967 } |
|
8968 /** |
|
8969 * Given block children, returns an array of block nodes. |
|
8970 * |
|
8971 * @param {WPBlockChildren} children Block children object to convert. |
|
8972 * |
|
8973 * @return {Array<WPBlockNode>} An array of individual block nodes. |
|
8974 */ |
|
8975 |
|
8976 function getChildrenArray(children) { |
|
8977 // The fact that block children are compatible with the element serializer |
|
8978 // is merely an implementation detail that currently serves to be true, but |
|
8979 // should not be mistaken as being a guarantee on the external API. |
|
8980 return children; |
|
8981 } |
|
8982 /** |
|
8983 * Given two or more block nodes, returns a new block node representing a |
|
8984 * concatenation of its values. |
|
8985 * |
|
8986 * @param {...WPBlockChildren} blockNodes Block nodes to concatenate. |
|
8987 * |
|
8988 * @return {WPBlockChildren} Concatenated block node. |
|
8989 */ |
|
8990 |
|
8991 |
|
8992 function concat() { |
|
8993 var result = []; |
|
8994 |
|
8995 for (var i = 0; i < arguments.length; i++) { |
|
8996 var blockNode = Object(external_lodash_["castArray"])(i < 0 || arguments.length <= i ? undefined : arguments[i]); |
|
8997 |
|
8998 for (var j = 0; j < blockNode.length; j++) { |
|
8999 var child = blockNode[j]; |
|
9000 var canConcatToPreviousString = typeof child === 'string' && typeof result[result.length - 1] === 'string'; |
|
9001 |
|
9002 if (canConcatToPreviousString) { |
|
9003 result[result.length - 1] += child; |
|
9004 } else { |
|
9005 result.push(child); |
|
9006 } |
|
9007 } |
|
9008 } |
|
9009 |
|
9010 return result; |
|
9011 } |
|
9012 /** |
|
9013 * Given an iterable set of DOM nodes, returns equivalent block children. |
|
9014 * Ignores any non-element/text nodes included in set. |
|
9015 * |
|
9016 * @param {Iterable.<Node>} domNodes Iterable set of DOM nodes to convert. |
|
9017 * |
|
9018 * @return {WPBlockChildren} Block children equivalent to DOM nodes. |
|
9019 */ |
|
9020 |
|
9021 function fromDOM(domNodes) { |
|
9022 var result = []; |
|
9023 |
|
9024 for (var i = 0; i < domNodes.length; i++) { |
|
9025 try { |
|
9026 result.push(node_fromDOM(domNodes[i])); |
|
9027 } catch (error) {// Simply ignore if DOM node could not be converted. |
|
9028 } |
|
9029 } |
|
9030 |
|
9031 return result; |
|
9032 } |
|
9033 /** |
|
9034 * Given a block node, returns its HTML string representation. |
|
9035 * |
|
9036 * @param {WPBlockChildren} children Block node(s) to convert to string. |
|
9037 * |
|
9038 * @return {string} String HTML representation of block node. |
|
9039 */ |
|
9040 |
|
9041 function toHTML(children) { |
|
9042 var element = getSerializeCapableElement(children); |
|
9043 return Object(external_this_wp_element_["renderToString"])(element); |
|
9044 } |
|
9045 /** |
|
9046 * Given a selector, returns an hpq matcher generating a WPBlockChildren value |
|
9047 * matching the selector result. |
|
9048 * |
|
9049 * @param {string} selector DOM selector. |
|
9050 * |
|
9051 * @return {Function} hpq matcher. |
|
9052 */ |
|
9053 |
|
9054 function children_matcher(selector) { |
|
9055 return function (domNode) { |
|
9056 var match = domNode; |
|
9057 |
|
9058 if (selector) { |
|
9059 match = domNode.querySelector(selector); |
|
9060 } |
|
9061 |
|
9062 if (match) { |
|
9063 return fromDOM(match.childNodes); |
|
9064 } |
|
9065 |
|
9066 return []; |
|
9067 }; |
|
9068 } |
|
9069 /* harmony default export */ var api_children = ({ |
|
9070 concat: concat, |
|
9071 getChildrenArray: getChildrenArray, |
|
9072 fromDOM: fromDOM, |
|
9073 toHTML: toHTML, |
|
9074 matcher: children_matcher |
|
9075 }); |
|
9076 |
|
9077 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/node.js |
|
9078 |
|
9079 |
|
9080 /** |
|
9081 * Internal dependencies |
|
9082 */ |
|
9083 |
|
9084 /** |
|
9085 * Browser dependencies |
|
9086 */ |
|
9087 |
|
9088 var _window$Node = window.Node, |
|
9089 TEXT_NODE = _window$Node.TEXT_NODE, |
|
9090 ELEMENT_NODE = _window$Node.ELEMENT_NODE; |
|
9091 /** |
|
9092 * A representation of a single node within a block's rich text value. If |
|
9093 * representing a text node, the value is simply a string of the node value. |
|
9094 * As representing an element node, it is an object of: |
|
9095 * |
|
9096 * 1. `type` (string): Tag name. |
|
9097 * 2. `props` (object): Attributes and children array of WPBlockNode. |
|
9098 * |
|
9099 * @typedef {string|Object} WPBlockNode |
|
9100 */ |
|
9101 |
|
9102 /** |
|
9103 * Given a single node and a node type (e.g. `'br'`), returns true if the node |
|
9104 * corresponds to that type, false otherwise. |
|
9105 * |
|
9106 * @param {WPBlockNode} node Block node to test |
|
9107 * @param {string} type Node to type to test against. |
|
9108 * |
|
9109 * @return {boolean} Whether node is of intended type. |
|
9110 */ |
|
9111 |
|
9112 function isNodeOfType(node, type) { |
|
9113 return node && node.type === type; |
|
9114 } |
|
9115 /** |
|
9116 * Given an object implementing the NamedNodeMap interface, returns a plain |
|
9117 * object equivalent value of name, value key-value pairs. |
|
9118 * |
|
9119 * @see https://dom.spec.whatwg.org/#interface-namednodemap |
|
9120 * |
|
9121 * @param {NamedNodeMap} nodeMap NamedNodeMap to convert to object. |
|
9122 * |
|
9123 * @return {Object} Object equivalent value of NamedNodeMap. |
|
9124 */ |
|
9125 |
|
9126 |
|
9127 function getNamedNodeMapAsObject(nodeMap) { |
|
9128 var result = {}; |
|
9129 |
|
9130 for (var i = 0; i < nodeMap.length; i++) { |
|
9131 var _nodeMap$i = nodeMap[i], |
|
9132 name = _nodeMap$i.name, |
|
9133 value = _nodeMap$i.value; |
|
9134 result[name] = value; |
|
9135 } |
|
9136 |
|
9137 return result; |
|
9138 } |
|
9139 /** |
|
9140 * Given a DOM Element or Text node, returns an equivalent block node. Throws |
|
9141 * if passed any node type other than element or text. |
|
9142 * |
|
9143 * @throws {TypeError} If non-element/text node is passed. |
|
9144 * |
|
9145 * @param {Node} domNode DOM node to convert. |
|
9146 * |
|
9147 * @return {WPBlockNode} Block node equivalent to DOM node. |
|
9148 */ |
|
9149 |
|
9150 function node_fromDOM(domNode) { |
|
9151 if (domNode.nodeType === TEXT_NODE) { |
|
9152 return domNode.nodeValue; |
|
9153 } |
|
9154 |
|
9155 if (domNode.nodeType !== ELEMENT_NODE) { |
|
9156 throw new TypeError('A block node can only be created from a node of type text or ' + 'element.'); |
|
9157 } |
|
9158 |
|
9159 return { |
|
9160 type: domNode.nodeName.toLowerCase(), |
|
9161 props: Object(objectSpread["a" /* default */])({}, getNamedNodeMapAsObject(domNode.attributes), { |
|
9162 children: fromDOM(domNode.childNodes) |
|
9163 }) |
|
9164 }; |
|
9165 } |
|
9166 /** |
|
9167 * Given a block node, returns its HTML string representation. |
|
9168 * |
|
9169 * @param {WPBlockNode} node Block node to convert to string. |
|
9170 * |
|
9171 * @return {string} String HTML representation of block node. |
|
9172 */ |
|
9173 |
|
9174 function node_toHTML(node) { |
|
9175 return toHTML([node]); |
|
9176 } |
|
9177 /** |
|
9178 * Given a selector, returns an hpq matcher generating a WPBlockNode value |
|
9179 * matching the selector result. |
|
9180 * |
|
9181 * @param {string} selector DOM selector. |
|
9182 * |
|
9183 * @return {Function} hpq matcher. |
|
9184 */ |
|
9185 |
|
9186 function node_matcher(selector) { |
|
9187 return function (domNode) { |
|
9188 var match = domNode; |
|
9189 |
|
9190 if (selector) { |
|
9191 match = domNode.querySelector(selector); |
|
9192 } |
|
9193 |
|
9194 try { |
|
9195 return node_fromDOM(match); |
|
9196 } catch (error) { |
|
9197 return null; |
|
9198 } |
|
9199 }; |
|
9200 } |
|
9201 /* harmony default export */ var api_node = ({ |
|
9202 isNodeOfType: isNodeOfType, |
|
9203 fromDOM: node_fromDOM, |
|
9204 toHTML: node_toHTML, |
|
9205 matcher: node_matcher |
|
9206 }); |
|
9207 |
|
9208 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/matchers.js |
|
9209 /** |
|
9210 * External dependencies |
|
9211 */ |
|
9212 |
|
9213 /** |
|
9214 * Internal dependencies |
|
9215 */ |
|
9216 |
|
9217 |
|
9218 |
|
9219 function matchers_html(selector, multilineTag) { |
|
9220 return function (domNode) { |
|
9221 var match = domNode; |
|
9222 |
|
9223 if (selector) { |
|
9224 match = domNode.querySelector(selector); |
|
9225 } |
|
9226 |
|
9227 if (!match) { |
|
9228 return ''; |
|
9229 } |
|
9230 |
|
9231 if (multilineTag) { |
|
9232 var value = ''; |
|
9233 var length = match.children.length; |
|
9234 |
|
9235 for (var index = 0; index < length; index++) { |
|
9236 var child = match.children[index]; |
|
9237 |
|
9238 if (child.nodeName.toLowerCase() !== multilineTag) { |
|
9239 continue; |
|
9240 } |
|
9241 |
|
9242 value += child.outerHTML; |
|
9243 } |
|
9244 |
|
9245 return value; |
|
9246 } |
|
9247 |
|
9248 return match.innerHTML; |
|
9249 }; |
|
9250 } |
|
9251 |
|
9252 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser.js |
|
9253 |
|
9254 |
|
9255 |
|
9256 /** |
|
9257 * External dependencies |
|
9258 */ |
|
9259 |
|
9260 |
|
9261 /** |
|
9262 * WordPress dependencies |
|
9263 */ |
|
9264 |
|
9265 |
|
9266 |
|
9267 |
|
9268 /** |
|
9269 * Internal dependencies |
|
9270 */ |
|
9271 |
|
9272 |
|
9273 |
|
9274 |
|
9275 |
|
9276 |
|
9277 |
|
9278 /** |
|
9279 * Sources which are guaranteed to return a string value. |
|
9280 * |
|
9281 * @type {Set} |
|
9282 */ |
|
9283 |
|
9284 var STRING_SOURCES = new Set(['attribute', 'html', 'text', 'tag']); |
|
9285 /** |
|
9286 * Higher-order hpq matcher which enhances an attribute matcher to return true |
|
9287 * or false depending on whether the original matcher returns undefined. This |
|
9288 * is useful for boolean attributes (e.g. disabled) whose attribute values may |
|
9289 * be technically falsey (empty string), though their mere presence should be |
|
9290 * enough to infer as true. |
|
9291 * |
|
9292 * @param {Function} matcher Original hpq matcher. |
|
9293 * |
|
9294 * @return {Function} Enhanced hpq matcher. |
|
9295 */ |
|
9296 |
|
9297 var parser_toBooleanAttributeMatcher = function toBooleanAttributeMatcher(matcher) { |
|
9298 return Object(external_lodash_["flow"])([matcher, // Expected values from `attr( 'disabled' )`: |
|
9299 // |
|
9300 // <input> |
|
9301 // - Value: `undefined` |
|
9302 // - Transformed: `false` |
|
9303 // |
|
9304 // <input disabled> |
|
9305 // - Value: `''` |
|
9306 // - Transformed: `true` |
|
9307 // |
|
9308 // <input disabled="disabled"> |
|
9309 // - Value: `'disabled'` |
|
9310 // - Transformed: `true` |
|
9311 function (value) { |
|
9312 return value !== undefined; |
|
9313 }]); |
|
9314 }; |
|
9315 /** |
|
9316 * Returns true if value is of the given JSON schema type, or false otherwise. |
|
9317 * |
|
9318 * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25 |
|
9319 * |
|
9320 * @param {*} value Value to test. |
|
9321 * @param {string} type Type to test. |
|
9322 * |
|
9323 * @return {boolean} Whether value is of type. |
|
9324 */ |
|
9325 |
|
9326 function isOfType(value, type) { |
|
9327 switch (type) { |
|
9328 case 'string': |
|
9329 return typeof value === 'string'; |
|
9330 |
|
9331 case 'boolean': |
|
9332 return typeof value === 'boolean'; |
|
9333 |
|
9334 case 'object': |
|
9335 return !!value && value.constructor === Object; |
|
9336 |
|
9337 case 'null': |
|
9338 return value === null; |
|
9339 |
|
9340 case 'array': |
|
9341 return Array.isArray(value); |
|
9342 |
|
9343 case 'integer': |
|
9344 case 'number': |
|
9345 return typeof value === 'number'; |
|
9346 } |
|
9347 |
|
9348 return true; |
|
9349 } |
|
9350 /** |
|
9351 * Returns true if value is of an array of given JSON schema types, or false |
|
9352 * otherwise. |
|
9353 * |
|
9354 * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25 |
|
9355 * |
|
9356 * @param {*} value Value to test. |
|
9357 * @param {string[]} types Types to test. |
|
9358 * |
|
9359 * @return {boolean} Whether value is of types. |
|
9360 */ |
|
9361 |
|
9362 function isOfTypes(value, types) { |
|
9363 return types.some(function (type) { |
|
9364 return isOfType(value, type); |
|
9365 }); |
|
9366 } |
|
9367 /** |
|
9368 * Returns true if the given attribute schema describes a value which may be |
|
9369 * an ambiguous string. |
|
9370 * |
|
9371 * Some sources are ambiguously serialized as strings, for which value casting |
|
9372 * is enabled. This is only possible when a singular type is assigned to the |
|
9373 * attribute schema, since the string ambiguity makes it impossible to know the |
|
9374 * correct type of multiple to which to cast. |
|
9375 * |
|
9376 * @param {Object} attributeSchema Attribute's schema. |
|
9377 * |
|
9378 * @return {boolean} Whether attribute schema defines an ambiguous string |
|
9379 * source. |
|
9380 */ |
|
9381 |
|
9382 function isAmbiguousStringSource(attributeSchema) { |
|
9383 var source = attributeSchema.source, |
|
9384 type = attributeSchema.type; |
|
9385 var isStringSource = STRING_SOURCES.has(source); |
|
9386 var isSingleType = typeof type === 'string'; |
|
9387 return isStringSource && isSingleType; |
|
9388 } |
|
9389 /** |
|
9390 * Returns value coerced to the specified JSON schema type string. |
|
9391 * |
|
9392 * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25 |
|
9393 * |
|
9394 * @param {*} value Original value. |
|
9395 * @param {string} type Type to coerce. |
|
9396 * |
|
9397 * @return {*} Coerced value. |
|
9398 */ |
|
9399 |
|
9400 function asType(value, type) { |
|
9401 switch (type) { |
|
9402 case 'string': |
|
9403 return String(value); |
|
9404 |
|
9405 case 'boolean': |
|
9406 return Boolean(value); |
|
9407 |
|
9408 case 'object': |
|
9409 return Object(value); |
|
9410 |
|
9411 case 'null': |
|
9412 return null; |
|
9413 |
|
9414 case 'array': |
|
9415 if (Array.isArray(value)) { |
|
9416 return value; |
|
9417 } |
|
9418 |
|
9419 return Array.from(value); |
|
9420 |
|
9421 case 'integer': |
|
9422 case 'number': |
|
9423 return Number(value); |
|
9424 } |
|
9425 |
|
9426 return value; |
|
9427 } |
|
9428 /** |
|
9429 * Returns an hpq matcher given a source object. |
|
9430 * |
|
9431 * @param {Object} sourceConfig Attribute Source object. |
|
9432 * |
|
9433 * @return {Function} A hpq Matcher. |
|
9434 */ |
|
9435 |
|
9436 function matcherFromSource(sourceConfig) { |
|
9437 switch (sourceConfig.source) { |
|
9438 case 'attribute': |
|
9439 var matcher = attr(sourceConfig.selector, sourceConfig.attribute); |
|
9440 |
|
9441 if (sourceConfig.type === 'boolean') { |
|
9442 matcher = parser_toBooleanAttributeMatcher(matcher); |
|
9443 } |
|
9444 |
|
9445 return matcher; |
|
9446 |
|
9447 case 'html': |
|
9448 return matchers_html(sourceConfig.selector, sourceConfig.multiline); |
|
9449 |
|
9450 case 'text': |
|
9451 return es_text(sourceConfig.selector); |
|
9452 |
|
9453 case 'children': |
|
9454 return children_matcher(sourceConfig.selector); |
|
9455 |
|
9456 case 'node': |
|
9457 return node_matcher(sourceConfig.selector); |
|
9458 |
|
9459 case 'query': |
|
9460 var subMatchers = Object(external_lodash_["mapValues"])(sourceConfig.query, matcherFromSource); |
|
9461 return query(sourceConfig.selector, subMatchers); |
|
9462 |
|
9463 case 'tag': |
|
9464 return Object(external_lodash_["flow"])([prop(sourceConfig.selector, 'nodeName'), function (value) { |
|
9465 return value.toLowerCase(); |
|
9466 }]); |
|
9467 |
|
9468 default: |
|
9469 // eslint-disable-next-line no-console |
|
9470 console.error("Unknown source type \"".concat(sourceConfig.source, "\"")); |
|
9471 } |
|
9472 } |
|
9473 /** |
|
9474 * Given a block's raw content and an attribute's schema returns the attribute's |
|
9475 * value depending on its source. |
|
9476 * |
|
9477 * @param {string} innerHTML Block's raw content. |
|
9478 * @param {Object} attributeSchema Attribute's schema. |
|
9479 * |
|
9480 * @return {*} Attribute value. |
|
9481 */ |
|
9482 |
|
9483 function parseWithAttributeSchema(innerHTML, attributeSchema) { |
|
9484 return es_parse(innerHTML, matcherFromSource(attributeSchema)); |
|
9485 } |
|
9486 /** |
|
9487 * Given an attribute key, an attribute's schema, a block's raw content and the |
|
9488 * commentAttributes returns the attribute value depending on its source |
|
9489 * definition of the given attribute key. |
|
9490 * |
|
9491 * @param {string} attributeKey Attribute key. |
|
9492 * @param {Object} attributeSchema Attribute's schema. |
|
9493 * @param {string} innerHTML Block's raw content. |
|
9494 * @param {Object} commentAttributes Block's comment attributes. |
|
9495 * |
|
9496 * @return {*} Attribute value. |
|
9497 */ |
|
9498 |
|
9499 function getBlockAttribute(attributeKey, attributeSchema, innerHTML, commentAttributes) { |
|
9500 var type = attributeSchema.type; |
|
9501 var value; |
|
9502 |
|
9503 switch (attributeSchema.source) { |
|
9504 // undefined source means that it's an attribute serialized to the block's "comment" |
|
9505 case undefined: |
|
9506 value = commentAttributes ? commentAttributes[attributeKey] : undefined; |
|
9507 break; |
|
9508 |
|
9509 case 'attribute': |
|
9510 case 'property': |
|
9511 case 'html': |
|
9512 case 'text': |
|
9513 case 'children': |
|
9514 case 'node': |
|
9515 case 'query': |
|
9516 case 'tag': |
|
9517 value = parseWithAttributeSchema(innerHTML, attributeSchema); |
|
9518 break; |
|
9519 } |
|
9520 |
|
9521 if (type !== undefined && !isOfTypes(value, Object(external_lodash_["castArray"])(type))) { |
|
9522 // Reject the value if it is not valid of type. Reverting to the |
|
9523 // undefined value ensures the default is restored, if applicable. |
|
9524 value = undefined; |
|
9525 } |
|
9526 |
|
9527 if (value === undefined) { |
|
9528 return attributeSchema.default; |
|
9529 } |
|
9530 |
|
9531 return value; |
|
9532 } |
|
9533 /** |
|
9534 * Returns the block attributes of a registered block node given its type. |
|
9535 * |
|
9536 * @param {string|Object} blockTypeOrName Block type or name. |
|
9537 * @param {string} innerHTML Raw block content. |
|
9538 * @param {?Object} attributes Known block attributes (from delimiters). |
|
9539 * |
|
9540 * @return {Object} All block attributes. |
|
9541 */ |
|
9542 |
|
9543 function getBlockAttributes(blockTypeOrName, innerHTML) { |
|
9544 var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; |
|
9545 var blockType = normalizeBlockType(blockTypeOrName); |
|
9546 var blockAttributes = Object(external_lodash_["mapValues"])(blockType.attributes, function (attributeSchema, attributeKey) { |
|
9547 return getBlockAttribute(attributeKey, attributeSchema, innerHTML, attributes); |
|
9548 }); |
|
9549 return Object(external_this_wp_hooks_["applyFilters"])('blocks.getBlockAttributes', blockAttributes, blockType, innerHTML, attributes); |
|
9550 } |
|
9551 /** |
|
9552 * Given a block object, returns a new copy of the block with any applicable |
|
9553 * deprecated migrations applied, or the original block if it was both valid |
|
9554 * and no eligible migrations exist. |
|
9555 * |
|
9556 * @param {WPBlock} block Original block object. |
|
9557 * @param {Object} parsedAttributes Attributes as parsed from the initial |
|
9558 * block markup. |
|
9559 * |
|
9560 * @return {WPBlock} Migrated block object. |
|
9561 */ |
|
9562 |
|
9563 function getMigratedBlock(block, parsedAttributes) { |
|
9564 var blockType = registration_getBlockType(block.name); |
|
9565 var deprecatedDefinitions = blockType.deprecated; |
|
9566 |
|
9567 if (!deprecatedDefinitions || !deprecatedDefinitions.length) { |
|
9568 return block; |
|
9569 } |
|
9570 |
|
9571 var _block = block, |
|
9572 originalContent = _block.originalContent, |
|
9573 innerBlocks = _block.innerBlocks; |
|
9574 |
|
9575 for (var i = 0; i < deprecatedDefinitions.length; i++) { |
|
9576 // A block can opt into a migration even if the block is valid by |
|
9577 // defining isEligible on its deprecation. If the block is both valid |
|
9578 // and does not opt to migrate, skip. |
|
9579 var _deprecatedDefinition = deprecatedDefinitions[i].isEligible, |
|
9580 isEligible = _deprecatedDefinition === void 0 ? external_lodash_["stubFalse"] : _deprecatedDefinition; |
|
9581 |
|
9582 if (block.isValid && !isEligible(parsedAttributes, innerBlocks)) { |
|
9583 continue; |
|
9584 } // Block type properties which could impact either serialization or |
|
9585 // parsing are not considered in the deprecated block type by default, |
|
9586 // and must be explicitly provided. |
|
9587 |
|
9588 |
|
9589 var deprecatedBlockType = Object.assign(Object(external_lodash_["omit"])(blockType, ['attributes', 'save', 'supports']), deprecatedDefinitions[i]); |
|
9590 var migratedAttributes = getBlockAttributes(deprecatedBlockType, originalContent, parsedAttributes); // Ignore the deprecation if it produces a block which is not valid. |
|
9591 |
|
9592 var isValid = isValidBlockContent(deprecatedBlockType, migratedAttributes, originalContent); |
|
9593 |
|
9594 if (!isValid) { |
|
9595 continue; |
|
9596 } |
|
9597 |
|
9598 block = Object(objectSpread["a" /* default */])({}, block, { |
|
9599 isValid: true |
|
9600 }); |
|
9601 var migratedInnerBlocks = innerBlocks; // A block may provide custom behavior to assign new attributes and/or |
|
9602 // inner blocks. |
|
9603 |
|
9604 var migrate = deprecatedBlockType.migrate; |
|
9605 |
|
9606 if (migrate) { |
|
9607 var _castArray = Object(external_lodash_["castArray"])(migrate(migratedAttributes, innerBlocks)); |
|
9608 |
|
9609 var _castArray2 = Object(slicedToArray["a" /* default */])(_castArray, 2); |
|
9610 |
|
9611 var _castArray2$ = _castArray2[0]; |
|
9612 migratedAttributes = _castArray2$ === void 0 ? parsedAttributes : _castArray2$; |
|
9613 var _castArray2$2 = _castArray2[1]; |
|
9614 migratedInnerBlocks = _castArray2$2 === void 0 ? innerBlocks : _castArray2$2; |
|
9615 } |
|
9616 |
|
9617 block.attributes = migratedAttributes; |
|
9618 block.innerBlocks = migratedInnerBlocks; |
|
9619 } |
|
9620 |
|
9621 return block; |
|
9622 } |
|
9623 /** |
|
9624 * Creates a block with fallback to the unknown type handler. |
|
9625 * |
|
9626 * @param {Object} blockNode Parsed block node. |
|
9627 * |
|
9628 * @return {?Object} An initialized block object (if possible). |
|
9629 */ |
|
9630 |
|
9631 function createBlockWithFallback(blockNode) { |
|
9632 var originalName = blockNode.blockName; |
|
9633 var attributes = blockNode.attrs, |
|
9634 _blockNode$innerBlock = blockNode.innerBlocks, |
|
9635 innerBlocks = _blockNode$innerBlock === void 0 ? [] : _blockNode$innerBlock, |
|
9636 innerHTML = blockNode.innerHTML; |
|
9637 var freeformContentFallbackBlock = getFreeformContentHandlerName(); |
|
9638 var unregisteredFallbackBlock = getUnregisteredTypeHandlerName() || freeformContentFallbackBlock; |
|
9639 attributes = attributes || {}; // Trim content to avoid creation of intermediary freeform segments. |
|
9640 |
|
9641 innerHTML = innerHTML.trim(); // Use type from block content if available. Otherwise, default to the |
|
9642 // freeform content fallback. |
|
9643 |
|
9644 var name = originalName || freeformContentFallbackBlock; // Convert 'core/cover-image' block in existing content to 'core/cover'. |
|
9645 |
|
9646 if ('core/cover-image' === name) { |
|
9647 name = 'core/cover'; |
|
9648 } // Convert 'core/text' blocks in existing content to 'core/paragraph'. |
|
9649 |
|
9650 |
|
9651 if ('core/text' === name || 'core/cover-text' === name) { |
|
9652 name = 'core/paragraph'; |
|
9653 } // Fallback content may be upgraded from classic editor expecting implicit |
|
9654 // automatic paragraphs, so preserve them. Assumes wpautop is idempotent, |
|
9655 // meaning there are no negative consequences to repeated autop calls. |
|
9656 |
|
9657 |
|
9658 if (name === freeformContentFallbackBlock) { |
|
9659 innerHTML = Object(external_this_wp_autop_["autop"])(innerHTML).trim(); |
|
9660 } // Try finding the type for known block name, else fall back again. |
|
9661 |
|
9662 |
|
9663 var blockType = registration_getBlockType(name); |
|
9664 |
|
9665 if (!blockType) { |
|
9666 // Preserve undelimited content for use by the unregistered type handler. |
|
9667 var originalUndelimitedContent = innerHTML; // If detected as a block which is not registered, preserve comment |
|
9668 // delimiters in content of unregistered type handler. |
|
9669 |
|
9670 if (name) { |
|
9671 innerHTML = getCommentDelimitedContent(name, attributes, innerHTML); |
|
9672 } |
|
9673 |
|
9674 name = unregisteredFallbackBlock; |
|
9675 attributes = { |
|
9676 originalName: originalName, |
|
9677 originalUndelimitedContent: originalUndelimitedContent |
|
9678 }; |
|
9679 blockType = registration_getBlockType(name); |
|
9680 } // Coerce inner blocks from parsed form to canonical form. |
|
9681 |
|
9682 |
|
9683 innerBlocks = innerBlocks.map(createBlockWithFallback); |
|
9684 var isFallbackBlock = name === freeformContentFallbackBlock || name === unregisteredFallbackBlock; // Include in set only if type was determined. |
|
9685 |
|
9686 if (!blockType || !innerHTML && isFallbackBlock) { |
|
9687 return; |
|
9688 } |
|
9689 |
|
9690 var block = createBlock(name, getBlockAttributes(blockType, innerHTML, attributes), innerBlocks); // Block validation assumes an idempotent operation from source block to serialized block |
|
9691 // provided there are no changes in attributes. The validation procedure thus compares the |
|
9692 // provided source value with the serialized output before there are any modifications to |
|
9693 // the block. When both match, the block is marked as valid. |
|
9694 |
|
9695 if (!isFallbackBlock) { |
|
9696 block.isValid = isValidBlockContent(blockType, block.attributes, innerHTML); |
|
9697 } // Preserve original content for future use in case the block is parsed as |
|
9698 // invalid, or future serialization attempt results in an error. |
|
9699 |
|
9700 |
|
9701 block.originalContent = innerHTML; |
|
9702 block = getMigratedBlock(block, attributes); |
|
9703 return block; |
|
9704 } |
|
9705 /** |
|
9706 * Creates a parse implementation for the post content which returns a list of blocks. |
|
9707 * |
|
9708 * @param {Function} parseImplementation Parse implementation. |
|
9709 * |
|
9710 * @return {Function} An implementation which parses the post content. |
|
9711 */ |
|
9712 |
|
9713 var createParse = function createParse(parseImplementation) { |
|
9714 return function (content) { |
|
9715 return parseImplementation(content).reduce(function (memo, blockNode) { |
|
9716 var block = createBlockWithFallback(blockNode); |
|
9717 |
|
9718 if (block) { |
|
9719 memo.push(block); |
|
9720 } |
|
9721 |
|
9722 return memo; |
|
9723 }, []); |
|
9724 }; |
|
9725 }; |
|
9726 /** |
|
9727 * Parses the post content with a PegJS grammar and returns a list of blocks. |
|
9728 * |
|
9729 * @param {string} content The post content. |
|
9730 * |
|
9731 * @return {Array} Block list. |
|
9732 */ |
|
9733 |
|
9734 |
|
9735 var parseWithGrammar = createParse(external_this_wp_blockSerializationDefaultParser_["parse"]); |
|
9736 /* harmony default export */ var parser = (parseWithGrammar); |
|
9737 |
|
9738 // EXTERNAL MODULE: external {"this":["wp","dom"]} |
|
9739 var external_this_wp_dom_ = __webpack_require__(24); |
|
9740 |
|
9741 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/phrasing-content.js |
|
9742 /** |
|
9743 * External dependencies |
|
9744 */ |
|
9745 |
|
9746 var phrasing_content_phrasingContentSchema = { |
|
9747 strong: {}, |
|
9748 em: {}, |
|
9749 s: {}, |
|
9750 del: {}, |
|
9751 ins: {}, |
|
9752 a: { |
|
9753 attributes: ['href', 'target', 'rel'] |
|
9754 }, |
|
9755 code: {}, |
|
9756 abbr: { |
|
9757 attributes: ['title'] |
|
9758 }, |
|
9759 sub: {}, |
|
9760 sup: {}, |
|
9761 br: {}, |
|
9762 '#text': {} |
|
9763 }; // Recursion is needed. |
|
9764 // Possible: strong > em > strong. |
|
9765 // Impossible: strong > strong. |
|
9766 |
|
9767 ['strong', 'em', 's', 'del', 'ins', 'a', 'code', 'abbr', 'sub', 'sup'].forEach(function (tag) { |
|
9768 phrasing_content_phrasingContentSchema[tag].children = Object(external_lodash_["omit"])(phrasing_content_phrasingContentSchema, tag); |
|
9769 }); |
|
9770 /** |
|
9771 * Get schema of possible paths for phrasing content. |
|
9772 * |
|
9773 * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content |
|
9774 * |
|
9775 * @return {Object} Schema. |
|
9776 */ |
|
9777 |
|
9778 function getPhrasingContentSchema() { |
|
9779 return phrasing_content_phrasingContentSchema; |
|
9780 } |
|
9781 /** |
|
9782 * Find out whether or not the given node is phrasing content. |
|
9783 * |
|
9784 * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content |
|
9785 * |
|
9786 * @param {Element} node The node to test. |
|
9787 * |
|
9788 * @return {boolean} True if phrasing content, false if not. |
|
9789 */ |
|
9790 |
|
9791 function isPhrasingContent(node) { |
|
9792 var tag = node.nodeName.toLowerCase(); |
|
9793 return getPhrasingContentSchema().hasOwnProperty(tag) || tag === 'span'; |
|
9794 } |
|
9795 |
|
9796 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/utils.js |
|
9797 |
|
9798 |
|
9799 |
|
9800 /** |
|
9801 * External dependencies |
|
9802 */ |
|
9803 |
|
9804 /** |
|
9805 * WordPress dependencies |
|
9806 */ |
|
9807 |
|
9808 |
|
9809 /** |
|
9810 * Internal dependencies |
|
9811 */ |
|
9812 |
|
9813 |
|
9814 |
|
9815 /** |
|
9816 * Browser dependencies |
|
9817 */ |
|
9818 |
|
9819 var utils_window$Node = window.Node, |
|
9820 utils_ELEMENT_NODE = utils_window$Node.ELEMENT_NODE, |
|
9821 utils_TEXT_NODE = utils_window$Node.TEXT_NODE; |
|
9822 /** |
|
9823 * Given raw transforms from blocks, merges all schemas into one. |
|
9824 * |
|
9825 * @param {Array} transforms Block transforms, of the `raw` type. |
|
9826 * |
|
9827 * @return {Object} A complete block content schema. |
|
9828 */ |
|
9829 |
|
9830 function getBlockContentSchema(transforms) { |
|
9831 var schemas = transforms.map(function (_ref) { |
|
9832 var isMatch = _ref.isMatch, |
|
9833 blockName = _ref.blockName, |
|
9834 schema = _ref.schema; |
|
9835 var hasAnchorSupport = registration_hasBlockSupport(blockName, 'anchor'); // If the block does not has anchor support and the transform does not |
|
9836 // provides an isMatch we can return the schema right away. |
|
9837 |
|
9838 if (!hasAnchorSupport && !isMatch) { |
|
9839 return schema; |
|
9840 } |
|
9841 |
|
9842 return Object(external_lodash_["mapValues"])(schema, function (value) { |
|
9843 var attributes = value.attributes || []; // If the block supports the "anchor" functionality, it needs to keep its ID attribute. |
|
9844 |
|
9845 if (hasAnchorSupport) { |
|
9846 attributes = [].concat(Object(toConsumableArray["a" /* default */])(attributes), ['id']); |
|
9847 } |
|
9848 |
|
9849 return Object(objectSpread["a" /* default */])({}, value, { |
|
9850 attributes: attributes, |
|
9851 isMatch: isMatch ? isMatch : undefined |
|
9852 }); |
|
9853 }); |
|
9854 }); |
|
9855 return external_lodash_["mergeWith"].apply(void 0, [{}].concat(Object(toConsumableArray["a" /* default */])(schemas), [function (objValue, srcValue, key) { |
|
9856 switch (key) { |
|
9857 case 'children': |
|
9858 { |
|
9859 if (objValue === '*' || srcValue === '*') { |
|
9860 return '*'; |
|
9861 } |
|
9862 |
|
9863 return Object(objectSpread["a" /* default */])({}, objValue, srcValue); |
|
9864 } |
|
9865 |
|
9866 case 'attributes': |
|
9867 case 'require': |
|
9868 { |
|
9869 return [].concat(Object(toConsumableArray["a" /* default */])(objValue || []), Object(toConsumableArray["a" /* default */])(srcValue || [])); |
|
9870 } |
|
9871 |
|
9872 case 'isMatch': |
|
9873 { |
|
9874 // If one of the values being merge is undefined (matches everything), |
|
9875 // the result of the merge will be undefined. |
|
9876 if (!objValue || !srcValue) { |
|
9877 return undefined; |
|
9878 } // When merging two isMatch functions, the result is a new function |
|
9879 // that returns if one of the source functions returns true. |
|
9880 |
|
9881 |
|
9882 return function () { |
|
9883 return objValue.apply(void 0, arguments) || srcValue.apply(void 0, arguments); |
|
9884 }; |
|
9885 } |
|
9886 } |
|
9887 }])); |
|
9888 } |
|
9889 /** |
|
9890 * Recursively checks if an element is empty. An element is not empty if it |
|
9891 * contains text or contains elements with attributes such as images. |
|
9892 * |
|
9893 * @param {Element} element The element to check. |
|
9894 * |
|
9895 * @return {boolean} Wether or not the element is empty. |
|
9896 */ |
|
9897 |
|
9898 function isEmpty(element) { |
|
9899 if (!element.hasChildNodes()) { |
|
9900 return true; |
|
9901 } |
|
9902 |
|
9903 return Array.from(element.childNodes).every(function (node) { |
|
9904 if (node.nodeType === utils_TEXT_NODE) { |
|
9905 return !node.nodeValue.trim(); |
|
9906 } |
|
9907 |
|
9908 if (node.nodeType === utils_ELEMENT_NODE) { |
|
9909 if (node.nodeName === 'BR') { |
|
9910 return true; |
|
9911 } else if (node.hasAttributes()) { |
|
9912 return false; |
|
9913 } |
|
9914 |
|
9915 return isEmpty(node); |
|
9916 } |
|
9917 |
|
9918 return true; |
|
9919 }); |
|
9920 } |
|
9921 /** |
|
9922 * Checks wether HTML can be considered plain text. That is, it does not contain |
|
9923 * any elements that are not line breaks. |
|
9924 * |
|
9925 * @param {string} HTML The HTML to check. |
|
9926 * |
|
9927 * @return {boolean} Wether the HTML can be considered plain text. |
|
9928 */ |
|
9929 |
|
9930 function isPlain(HTML) { |
|
9931 return !/<(?!br[ />])/i.test(HTML); |
|
9932 } |
|
9933 /** |
|
9934 * Given node filters, deeply filters and mutates a NodeList. |
|
9935 * |
|
9936 * @param {NodeList} nodeList The nodeList to filter. |
|
9937 * @param {Array} filters An array of functions that can mutate with the provided node. |
|
9938 * @param {Document} doc The document of the nodeList. |
|
9939 * @param {Object} schema The schema to use. |
|
9940 */ |
|
9941 |
|
9942 function deepFilterNodeList(nodeList, filters, doc, schema) { |
|
9943 Array.from(nodeList).forEach(function (node) { |
|
9944 deepFilterNodeList(node.childNodes, filters, doc, schema); |
|
9945 filters.forEach(function (item) { |
|
9946 // Make sure the node is still attached to the document. |
|
9947 if (!doc.contains(node)) { |
|
9948 return; |
|
9949 } |
|
9950 |
|
9951 item(node, doc, schema); |
|
9952 }); |
|
9953 }); |
|
9954 } |
|
9955 /** |
|
9956 * Given node filters, deeply filters HTML tags. |
|
9957 * Filters from the deepest nodes to the top. |
|
9958 * |
|
9959 * @param {string} HTML The HTML to filter. |
|
9960 * @param {Array} filters An array of functions that can mutate with the provided node. |
|
9961 * @param {Object} schema The schema to use. |
|
9962 * |
|
9963 * @return {string} The filtered HTML. |
|
9964 */ |
|
9965 |
|
9966 function deepFilterHTML(HTML) { |
|
9967 var filters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; |
|
9968 var schema = arguments.length > 2 ? arguments[2] : undefined; |
|
9969 var doc = document.implementation.createHTMLDocument(''); |
|
9970 doc.body.innerHTML = HTML; |
|
9971 deepFilterNodeList(doc.body.childNodes, filters, doc, schema); |
|
9972 return doc.body.innerHTML; |
|
9973 } |
|
9974 /** |
|
9975 * Given a schema, unwraps or removes nodes, attributes and classes on a node |
|
9976 * list. |
|
9977 * |
|
9978 * @param {NodeList} nodeList The nodeList to filter. |
|
9979 * @param {Document} doc The document of the nodeList. |
|
9980 * @param {Object} schema An array of functions that can mutate with the provided node. |
|
9981 * @param {Object} inline Whether to clean for inline mode. |
|
9982 */ |
|
9983 |
|
9984 function cleanNodeList(nodeList, doc, schema, inline) { |
|
9985 Array.from(nodeList).forEach(function (node) { |
|
9986 var tag = node.nodeName.toLowerCase(); // It's a valid child, if the tag exists in the schema without an isMatch |
|
9987 // function, or with an isMatch function that matches the node. |
|
9988 |
|
9989 if (schema.hasOwnProperty(tag) && (!schema[tag].isMatch || schema[tag].isMatch(node))) { |
|
9990 if (node.nodeType === utils_ELEMENT_NODE) { |
|
9991 var _schema$tag = schema[tag], |
|
9992 _schema$tag$attribute = _schema$tag.attributes, |
|
9993 attributes = _schema$tag$attribute === void 0 ? [] : _schema$tag$attribute, |
|
9994 _schema$tag$classes = _schema$tag.classes, |
|
9995 classes = _schema$tag$classes === void 0 ? [] : _schema$tag$classes, |
|
9996 children = _schema$tag.children, |
|
9997 _schema$tag$require = _schema$tag.require, |
|
9998 require = _schema$tag$require === void 0 ? [] : _schema$tag$require, |
|
9999 allowEmpty = _schema$tag.allowEmpty; // If the node is empty and it's supposed to have children, |
|
10000 // remove the node. |
|
10001 |
|
10002 |
|
10003 if (children && !allowEmpty && isEmpty(node)) { |
|
10004 Object(external_this_wp_dom_["remove"])(node); |
|
10005 return; |
|
10006 } |
|
10007 |
|
10008 if (node.hasAttributes()) { |
|
10009 // Strip invalid attributes. |
|
10010 Array.from(node.attributes).forEach(function (_ref2) { |
|
10011 var name = _ref2.name; |
|
10012 |
|
10013 if (name !== 'class' && !Object(external_lodash_["includes"])(attributes, name)) { |
|
10014 node.removeAttribute(name); |
|
10015 } |
|
10016 }); // Strip invalid classes. |
|
10017 // In jsdom-jscore, 'node.classList' can be undefined. |
|
10018 // TODO: Explore patching this in jsdom-jscore. |
|
10019 |
|
10020 if (node.classList && node.classList.length) { |
|
10021 var mattchers = classes.map(function (item) { |
|
10022 if (typeof item === 'string') { |
|
10023 return function (className) { |
|
10024 return className === item; |
|
10025 }; |
|
10026 } else if (item instanceof RegExp) { |
|
10027 return function (className) { |
|
10028 return item.test(className); |
|
10029 }; |
|
10030 } |
|
10031 |
|
10032 return external_lodash_["noop"]; |
|
10033 }); |
|
10034 Array.from(node.classList).forEach(function (name) { |
|
10035 if (!mattchers.some(function (isMatch) { |
|
10036 return isMatch(name); |
|
10037 })) { |
|
10038 node.classList.remove(name); |
|
10039 } |
|
10040 }); |
|
10041 |
|
10042 if (!node.classList.length) { |
|
10043 node.removeAttribute('class'); |
|
10044 } |
|
10045 } |
|
10046 } |
|
10047 |
|
10048 if (node.hasChildNodes()) { |
|
10049 // Do not filter any content. |
|
10050 if (children === '*') { |
|
10051 return; |
|
10052 } // Continue if the node is supposed to have children. |
|
10053 |
|
10054 |
|
10055 if (children) { |
|
10056 // If a parent requires certain children, but it does |
|
10057 // not have them, drop the parent and continue. |
|
10058 if (require.length && !node.querySelector(require.join(','))) { |
|
10059 cleanNodeList(node.childNodes, doc, schema, inline); |
|
10060 Object(external_this_wp_dom_["unwrap"])(node); // If the node is at the top, phrasing content, and |
|
10061 // contains children that are block content, unwrap |
|
10062 // the node because it is invalid. |
|
10063 } else if (node.parentNode.nodeName === 'BODY' && isPhrasingContent(node)) { |
|
10064 cleanNodeList(node.childNodes, doc, schema, inline); |
|
10065 |
|
10066 if (Array.from(node.childNodes).some(function (child) { |
|
10067 return !isPhrasingContent(child); |
|
10068 })) { |
|
10069 Object(external_this_wp_dom_["unwrap"])(node); |
|
10070 } |
|
10071 } else { |
|
10072 cleanNodeList(node.childNodes, doc, children, inline); |
|
10073 } // Remove children if the node is not supposed to have any. |
|
10074 |
|
10075 } else { |
|
10076 while (node.firstChild) { |
|
10077 Object(external_this_wp_dom_["remove"])(node.firstChild); |
|
10078 } |
|
10079 } |
|
10080 } |
|
10081 } // Invalid child. Continue with schema at the same place and unwrap. |
|
10082 |
|
10083 } else { |
|
10084 cleanNodeList(node.childNodes, doc, schema, inline); // For inline mode, insert a line break when unwrapping nodes that |
|
10085 // are not phrasing content. |
|
10086 |
|
10087 if (inline && !isPhrasingContent(node) && node.nextElementSibling) { |
|
10088 Object(external_this_wp_dom_["insertAfter"])(doc.createElement('br'), node); |
|
10089 } |
|
10090 |
|
10091 Object(external_this_wp_dom_["unwrap"])(node); |
|
10092 } |
|
10093 }); |
|
10094 } |
|
10095 /** |
|
10096 * Given a schema, unwraps or removes nodes, attributes and classes on HTML. |
|
10097 * |
|
10098 * @param {string} HTML The HTML to clean up. |
|
10099 * @param {Object} schema Schema for the HTML. |
|
10100 * @param {Object} inline Whether to clean for inline mode. |
|
10101 * |
|
10102 * @return {string} The cleaned up HTML. |
|
10103 */ |
|
10104 |
|
10105 |
|
10106 function removeInvalidHTML(HTML, schema, inline) { |
|
10107 var doc = document.implementation.createHTMLDocument(''); |
|
10108 doc.body.innerHTML = HTML; |
|
10109 cleanNodeList(doc.body.childNodes, doc, schema, inline); |
|
10110 return doc.body.innerHTML; |
|
10111 } |
|
10112 |
|
10113 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/normalise-blocks.js |
|
10114 /** |
|
10115 * Internal dependencies |
|
10116 */ |
|
10117 |
|
10118 |
|
10119 /** |
|
10120 * Browser dependencies |
|
10121 */ |
|
10122 |
|
10123 var normalise_blocks_window$Node = window.Node, |
|
10124 normalise_blocks_ELEMENT_NODE = normalise_blocks_window$Node.ELEMENT_NODE, |
|
10125 normalise_blocks_TEXT_NODE = normalise_blocks_window$Node.TEXT_NODE; |
|
10126 /* harmony default export */ var normalise_blocks = (function (HTML) { |
|
10127 var decuDoc = document.implementation.createHTMLDocument(''); |
|
10128 var accuDoc = document.implementation.createHTMLDocument(''); |
|
10129 var decu = decuDoc.body; |
|
10130 var accu = accuDoc.body; |
|
10131 decu.innerHTML = HTML; |
|
10132 |
|
10133 while (decu.firstChild) { |
|
10134 var node = decu.firstChild; // Text nodes: wrap in a paragraph, or append to previous. |
|
10135 |
|
10136 if (node.nodeType === normalise_blocks_TEXT_NODE) { |
|
10137 if (!node.nodeValue.trim()) { |
|
10138 decu.removeChild(node); |
|
10139 } else { |
|
10140 if (!accu.lastChild || accu.lastChild.nodeName !== 'P') { |
|
10141 accu.appendChild(accuDoc.createElement('P')); |
|
10142 } |
|
10143 |
|
10144 accu.lastChild.appendChild(node); |
|
10145 } // Element nodes. |
|
10146 |
|
10147 } else if (node.nodeType === normalise_blocks_ELEMENT_NODE) { |
|
10148 // BR nodes: create a new paragraph on double, or append to previous. |
|
10149 if (node.nodeName === 'BR') { |
|
10150 if (node.nextSibling && node.nextSibling.nodeName === 'BR') { |
|
10151 accu.appendChild(accuDoc.createElement('P')); |
|
10152 decu.removeChild(node.nextSibling); |
|
10153 } // Don't append to an empty paragraph. |
|
10154 |
|
10155 |
|
10156 if (accu.lastChild && accu.lastChild.nodeName === 'P' && accu.lastChild.hasChildNodes()) { |
|
10157 accu.lastChild.appendChild(node); |
|
10158 } else { |
|
10159 decu.removeChild(node); |
|
10160 } |
|
10161 } else if (node.nodeName === 'P') { |
|
10162 // Only append non-empty paragraph nodes. |
|
10163 if (isEmpty(node)) { |
|
10164 decu.removeChild(node); |
|
10165 } else { |
|
10166 accu.appendChild(node); |
|
10167 } |
|
10168 } else if (isPhrasingContent(node)) { |
|
10169 if (!accu.lastChild || accu.lastChild.nodeName !== 'P') { |
|
10170 accu.appendChild(accuDoc.createElement('P')); |
|
10171 } |
|
10172 |
|
10173 accu.lastChild.appendChild(node); |
|
10174 } else { |
|
10175 accu.appendChild(node); |
|
10176 } |
|
10177 } else { |
|
10178 decu.removeChild(node); |
|
10179 } |
|
10180 } |
|
10181 |
|
10182 return accu.innerHTML; |
|
10183 }); |
|
10184 |
|
10185 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/special-comment-converter.js |
|
10186 /** |
|
10187 * WordPress dependencies |
|
10188 */ |
|
10189 |
|
10190 /** |
|
10191 * Browser dependencies |
|
10192 */ |
|
10193 |
|
10194 var COMMENT_NODE = window.Node.COMMENT_NODE; |
|
10195 /** |
|
10196 * Looks for `<!--nextpage-->` and `<!--more-->` comments, as well as the |
|
10197 * `<!--more Some text-->` variant and its `<!--noteaser-->` companion, |
|
10198 * and replaces them with a custom element representing a future block. |
|
10199 * |
|
10200 * The custom element is a way to bypass the rest of the `raw-handling` |
|
10201 * transforms, which would eliminate other kinds of node with which to carry |
|
10202 * `<!--more-->`'s data: nodes with `data` attributes, empty paragraphs, etc. |
|
10203 * |
|
10204 * The custom element is then expected to be recognized by any registered |
|
10205 * block's `raw` transform. |
|
10206 * |
|
10207 * @param {Node} node The node to be processed. |
|
10208 * @param {Document} doc The document of the node. |
|
10209 * @return {void} |
|
10210 */ |
|
10211 |
|
10212 /* harmony default export */ var special_comment_converter = (function (node, doc) { |
|
10213 if (node.nodeType !== COMMENT_NODE) { |
|
10214 return; |
|
10215 } |
|
10216 |
|
10217 if (node.nodeValue === 'nextpage') { |
|
10218 Object(external_this_wp_dom_["replace"])(node, createNextpage(doc)); |
|
10219 return; |
|
10220 } |
|
10221 |
|
10222 if (node.nodeValue.indexOf('more') === 0) { |
|
10223 // Grab any custom text in the comment. |
|
10224 var customText = node.nodeValue.slice(4).trim(); |
|
10225 /* |
|
10226 * When a `<!--more-->` comment is found, we need to look for any |
|
10227 * `<!--noteaser-->` sibling, but it may not be a direct sibling |
|
10228 * (whitespace typically lies in between) |
|
10229 */ |
|
10230 |
|
10231 var sibling = node; |
|
10232 var noTeaser = false; |
|
10233 |
|
10234 while (sibling = sibling.nextSibling) { |
|
10235 if (sibling.nodeType === COMMENT_NODE && sibling.nodeValue === 'noteaser') { |
|
10236 noTeaser = true; |
|
10237 Object(external_this_wp_dom_["remove"])(sibling); |
|
10238 break; |
|
10239 } |
|
10240 } |
|
10241 |
|
10242 Object(external_this_wp_dom_["replace"])(node, createMore(customText, noTeaser, doc)); |
|
10243 } |
|
10244 }); |
|
10245 |
|
10246 function createMore(customText, noTeaser, doc) { |
|
10247 var node = doc.createElement('wp-block'); |
|
10248 node.dataset.block = 'core/more'; |
|
10249 |
|
10250 if (customText) { |
|
10251 node.dataset.customText = customText; |
|
10252 } |
|
10253 |
|
10254 if (noTeaser) { |
|
10255 // "Boolean" data attribute |
|
10256 node.dataset.noTeaser = ''; |
|
10257 } |
|
10258 |
|
10259 return node; |
|
10260 } |
|
10261 |
|
10262 function createNextpage(doc) { |
|
10263 var node = doc.createElement('wp-block'); |
|
10264 node.dataset.block = 'core/nextpage'; |
|
10265 return node; |
|
10266 } |
|
10267 |
|
10268 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/list-reducer.js |
|
10269 |
|
10270 |
|
10271 /** |
|
10272 * WordPress dependencies |
|
10273 */ |
|
10274 |
|
10275 |
|
10276 function isList(node) { |
|
10277 return node.nodeName === 'OL' || node.nodeName === 'UL'; |
|
10278 } |
|
10279 |
|
10280 function shallowTextContent(element) { |
|
10281 return Object(toConsumableArray["a" /* default */])(element.childNodes).map(function (_ref) { |
|
10282 var _ref$nodeValue = _ref.nodeValue, |
|
10283 nodeValue = _ref$nodeValue === void 0 ? '' : _ref$nodeValue; |
|
10284 return nodeValue; |
|
10285 }).join(''); |
|
10286 } |
|
10287 |
|
10288 /* harmony default export */ var list_reducer = (function (node) { |
|
10289 if (!isList(node)) { |
|
10290 return; |
|
10291 } |
|
10292 |
|
10293 var list = node; |
|
10294 var prevElement = node.previousElementSibling; // Merge with previous list if: |
|
10295 // * There is a previous list of the same type. |
|
10296 // * There is only one list item. |
|
10297 |
|
10298 if (prevElement && prevElement.nodeName === node.nodeName && list.children.length === 1) { |
|
10299 // Move all child nodes, including any text nodes, if any. |
|
10300 while (list.firstChild) { |
|
10301 prevElement.appendChild(list.firstChild); |
|
10302 } |
|
10303 |
|
10304 list.parentNode.removeChild(list); |
|
10305 } |
|
10306 |
|
10307 var parentElement = node.parentNode; // Nested list with empty parent item. |
|
10308 |
|
10309 if (parentElement && parentElement.nodeName === 'LI' && parentElement.children.length === 1 && !/\S/.test(shallowTextContent(parentElement))) { |
|
10310 var parentListItem = parentElement; |
|
10311 var prevListItem = parentListItem.previousElementSibling; |
|
10312 var parentList = parentListItem.parentNode; |
|
10313 |
|
10314 if (prevListItem) { |
|
10315 prevListItem.appendChild(list); |
|
10316 parentList.removeChild(parentListItem); |
|
10317 } else { |
|
10318 parentList.parentNode.insertBefore(list, parentList); |
|
10319 parentList.parentNode.removeChild(parentList); |
|
10320 } |
|
10321 } // Invalid: OL/UL > OL/UL. |
|
10322 |
|
10323 |
|
10324 if (parentElement && isList(parentElement)) { |
|
10325 var _prevListItem = node.previousElementSibling; |
|
10326 |
|
10327 if (_prevListItem) { |
|
10328 _prevListItem.appendChild(node); |
|
10329 } else { |
|
10330 Object(external_this_wp_dom_["unwrap"])(node); |
|
10331 } |
|
10332 } |
|
10333 }); |
|
10334 |
|
10335 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/blockquote-normaliser.js |
|
10336 /** |
|
10337 * Internal dependencies |
|
10338 */ |
|
10339 |
|
10340 /* harmony default export */ var blockquote_normaliser = (function (node) { |
|
10341 if (node.nodeName !== 'BLOCKQUOTE') { |
|
10342 return; |
|
10343 } |
|
10344 |
|
10345 node.innerHTML = normalise_blocks(node.innerHTML); |
|
10346 }); |
|
10347 |
|
10348 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/figure-content-reducer.js |
|
10349 /** |
|
10350 * External dependencies |
|
10351 */ |
|
10352 |
|
10353 /** |
|
10354 * Internal dependencies |
|
10355 */ |
|
10356 |
|
10357 |
|
10358 /** |
|
10359 * Whether or not the given node is figure content. |
|
10360 * |
|
10361 * @param {Node} node The node to check. |
|
10362 * @param {Object} schema The schema to use. |
|
10363 * |
|
10364 * @return {boolean} True if figure content, false if not. |
|
10365 */ |
|
10366 |
|
10367 function isFigureContent(node, schema) { |
|
10368 var tag = node.nodeName.toLowerCase(); // We are looking for tags that can be a child of the figure tag, excluding |
|
10369 // `figcaption` and any phrasing content. |
|
10370 |
|
10371 if (tag === 'figcaption' || isPhrasingContent(node)) { |
|
10372 return false; |
|
10373 } |
|
10374 |
|
10375 return Object(external_lodash_["has"])(schema, ['figure', 'children', tag]); |
|
10376 } |
|
10377 /** |
|
10378 * Whether or not the given node can have an anchor. |
|
10379 * |
|
10380 * @param {Node} node The node to check. |
|
10381 * @param {Object} schema The schema to use. |
|
10382 * |
|
10383 * @return {boolean} True if it can, false if not. |
|
10384 */ |
|
10385 |
|
10386 |
|
10387 function canHaveAnchor(node, schema) { |
|
10388 var tag = node.nodeName.toLowerCase(); |
|
10389 return Object(external_lodash_["has"])(schema, ['figure', 'children', 'a', 'children', tag]); |
|
10390 } |
|
10391 /** |
|
10392 * This filter takes figure content out of paragraphs, wraps it in a figure |
|
10393 * element, and moves any anchors with it if needed. |
|
10394 * |
|
10395 * @param {Node} node The node to filter. |
|
10396 * @param {Document} doc The document of the node. |
|
10397 * @param {Object} schema The schema to use. |
|
10398 * |
|
10399 * @return {void} |
|
10400 */ |
|
10401 |
|
10402 |
|
10403 /* harmony default export */ var figure_content_reducer = (function (node, doc, schema) { |
|
10404 if (!isFigureContent(node, schema)) { |
|
10405 return; |
|
10406 } |
|
10407 |
|
10408 var nodeToInsert = node; |
|
10409 var parentNode = node.parentNode; // If the figure content can have an anchor and its parent is an anchor with |
|
10410 // only the figure content, take the anchor out instead of just the content. |
|
10411 |
|
10412 if (canHaveAnchor(node, schema) && parentNode.nodeName === 'A' && parentNode.childNodes.length === 1) { |
|
10413 nodeToInsert = node.parentNode; |
|
10414 } |
|
10415 |
|
10416 var wrapper = nodeToInsert; |
|
10417 |
|
10418 while (wrapper && wrapper.nodeName !== 'P') { |
|
10419 wrapper = wrapper.parentElement; |
|
10420 } |
|
10421 |
|
10422 var figure = doc.createElement('figure'); |
|
10423 |
|
10424 if (wrapper) { |
|
10425 wrapper.parentNode.insertBefore(figure, wrapper); |
|
10426 } else { |
|
10427 nodeToInsert.parentNode.insertBefore(figure, nodeToInsert); |
|
10428 } |
|
10429 |
|
10430 figure.appendChild(nodeToInsert); |
|
10431 }); |
|
10432 |
|
10433 // EXTERNAL MODULE: external {"this":["wp","shortcode"]} |
|
10434 var external_this_wp_shortcode_ = __webpack_require__(134); |
|
10435 |
|
10436 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/shortcode-converter.js |
|
10437 |
|
10438 |
|
10439 |
|
10440 /** |
|
10441 * External dependencies |
|
10442 */ |
|
10443 |
|
10444 /** |
|
10445 * WordPress dependencies |
|
10446 */ |
|
10447 |
|
10448 |
|
10449 /** |
|
10450 * Internal dependencies |
|
10451 */ |
|
10452 |
|
10453 |
|
10454 |
|
10455 |
|
10456 |
|
10457 function segmentHTMLToShortcodeBlock(HTML) { |
|
10458 var lastIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; |
|
10459 // Get all matches. |
|
10460 var transformsFrom = getBlockTransforms('from'); |
|
10461 var transformation = findTransform(transformsFrom, function (transform) { |
|
10462 return transform.type === 'shortcode' && Object(external_lodash_["some"])(Object(external_lodash_["castArray"])(transform.tag), function (tag) { |
|
10463 return Object(external_this_wp_shortcode_["regexp"])(tag).test(HTML); |
|
10464 }); |
|
10465 }); |
|
10466 |
|
10467 if (!transformation) { |
|
10468 return [HTML]; |
|
10469 } |
|
10470 |
|
10471 var transformTags = Object(external_lodash_["castArray"])(transformation.tag); |
|
10472 var transformTag = Object(external_lodash_["first"])(transformTags); |
|
10473 var match; |
|
10474 |
|
10475 if (match = Object(external_this_wp_shortcode_["next"])(transformTag, HTML, lastIndex)) { |
|
10476 var beforeHTML = HTML.substr(0, match.index); |
|
10477 lastIndex = match.index + match.content.length; // If the shortcode content does not contain HTML and the shortcode is |
|
10478 // not on a new line (or in paragraph from Markdown converter), |
|
10479 // consider the shortcode as inline text, and thus skip conversion for |
|
10480 // this segment. |
|
10481 |
|
10482 if (!Object(external_lodash_["includes"])(match.shortcode.content || '', '<') && !/(\n|<p>)\s*$/.test(beforeHTML)) { |
|
10483 return segmentHTMLToShortcodeBlock(HTML, lastIndex); |
|
10484 } |
|
10485 |
|
10486 var attributes = Object(external_lodash_["mapValues"])(Object(external_lodash_["pickBy"])(transformation.attributes, function (schema) { |
|
10487 return schema.shortcode; |
|
10488 }), // Passing all of `match` as second argument is intentionally broad |
|
10489 // but shouldn't be too relied upon. |
|
10490 // |
|
10491 // See: https://github.com/WordPress/gutenberg/pull/3610#discussion_r152546926 |
|
10492 function (schema) { |
|
10493 return schema.shortcode(match.shortcode.attrs, match); |
|
10494 }); |
|
10495 var block = createBlock(transformation.blockName, getBlockAttributes(Object(objectSpread["a" /* default */])({}, registration_getBlockType(transformation.blockName), { |
|
10496 attributes: transformation.attributes |
|
10497 }), match.shortcode.content, attributes)); |
|
10498 return [beforeHTML, block].concat(Object(toConsumableArray["a" /* default */])(segmentHTMLToShortcodeBlock(HTML.substr(lastIndex)))); |
|
10499 } |
|
10500 |
|
10501 return [HTML]; |
|
10502 } |
|
10503 |
|
10504 /* harmony default export */ var shortcode_converter = (segmentHTMLToShortcodeBlock); |
|
10505 |
|
10506 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/comment-remover.js |
|
10507 /** |
|
10508 * WordPress dependencies |
|
10509 */ |
|
10510 |
|
10511 /** |
|
10512 * Browser dependencies |
|
10513 */ |
|
10514 |
|
10515 var comment_remover_COMMENT_NODE = window.Node.COMMENT_NODE; |
|
10516 /** |
|
10517 * Looks for comments, and removes them. |
|
10518 * |
|
10519 * @param {Node} node The node to be processed. |
|
10520 * @return {void} |
|
10521 */ |
|
10522 |
|
10523 /* harmony default export */ var comment_remover = (function (node) { |
|
10524 if (node.nodeType === comment_remover_COMMENT_NODE) { |
|
10525 Object(external_this_wp_dom_["remove"])(node); |
|
10526 } |
|
10527 }); |
|
10528 |
|
10529 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/is-inline-content.js |
|
10530 /** |
|
10531 * External dependencies |
|
10532 */ |
|
10533 |
|
10534 /** |
|
10535 * Internal dependencies |
|
10536 */ |
|
10537 |
|
10538 |
|
10539 /** |
|
10540 * Checks if the given node should be considered inline content, optionally |
|
10541 * depending on a context tag. |
|
10542 * |
|
10543 * @param {Node} node Node name. |
|
10544 * @param {string} contextTag Tag name. |
|
10545 * |
|
10546 * @return {boolean} True if the node is inline content, false if nohe. |
|
10547 */ |
|
10548 |
|
10549 function isInline(node, contextTag) { |
|
10550 if (isPhrasingContent(node)) { |
|
10551 return true; |
|
10552 } |
|
10553 |
|
10554 if (!contextTag) { |
|
10555 return false; |
|
10556 } |
|
10557 |
|
10558 var tag = node.nodeName.toLowerCase(); |
|
10559 var inlineWhitelistTagGroups = [['ul', 'li', 'ol'], ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']]; |
|
10560 return inlineWhitelistTagGroups.some(function (tagGroup) { |
|
10561 return Object(external_lodash_["difference"])([tag, contextTag], tagGroup).length === 0; |
|
10562 }); |
|
10563 } |
|
10564 |
|
10565 function deepCheck(nodes, contextTag) { |
|
10566 return nodes.every(function (node) { |
|
10567 return isInline(node, contextTag) && deepCheck(Array.from(node.children), contextTag); |
|
10568 }); |
|
10569 } |
|
10570 |
|
10571 function isDoubleBR(node) { |
|
10572 return node.nodeName === 'BR' && node.previousSibling && node.previousSibling.nodeName === 'BR'; |
|
10573 } |
|
10574 |
|
10575 /* harmony default export */ var is_inline_content = (function (HTML, contextTag) { |
|
10576 var doc = document.implementation.createHTMLDocument(''); |
|
10577 doc.body.innerHTML = HTML; |
|
10578 var nodes = Array.from(doc.body.children); |
|
10579 return !nodes.some(isDoubleBR) && deepCheck(nodes, contextTag); |
|
10580 }); |
|
10581 |
|
10582 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/phrasing-content-reducer.js |
|
10583 /** |
|
10584 * WordPress dependencies |
|
10585 */ |
|
10586 |
|
10587 /* harmony default export */ var phrasing_content_reducer = (function (node, doc) { |
|
10588 // In jsdom-jscore, 'node.style' can be null. |
|
10589 // TODO: Explore fixing this by patching jsdom-jscore. |
|
10590 if (node.nodeName === 'SPAN' && node.style) { |
|
10591 var _node$style = node.style, |
|
10592 fontWeight = _node$style.fontWeight, |
|
10593 fontStyle = _node$style.fontStyle, |
|
10594 textDecorationLine = _node$style.textDecorationLine, |
|
10595 verticalAlign = _node$style.verticalAlign; |
|
10596 |
|
10597 if (fontWeight === 'bold' || fontWeight === '700') { |
|
10598 Object(external_this_wp_dom_["wrap"])(doc.createElement('strong'), node); |
|
10599 } |
|
10600 |
|
10601 if (fontStyle === 'italic') { |
|
10602 Object(external_this_wp_dom_["wrap"])(doc.createElement('em'), node); |
|
10603 } |
|
10604 |
|
10605 if (textDecorationLine === 'line-through') { |
|
10606 Object(external_this_wp_dom_["wrap"])(doc.createElement('s'), node); |
|
10607 } |
|
10608 |
|
10609 if (verticalAlign === 'super') { |
|
10610 Object(external_this_wp_dom_["wrap"])(doc.createElement('sup'), node); |
|
10611 } else if (verticalAlign === 'sub') { |
|
10612 Object(external_this_wp_dom_["wrap"])(doc.createElement('sub'), node); |
|
10613 } |
|
10614 } else if (node.nodeName === 'B') { |
|
10615 node = Object(external_this_wp_dom_["replaceTag"])(node, 'strong'); |
|
10616 } else if (node.nodeName === 'I') { |
|
10617 node = Object(external_this_wp_dom_["replaceTag"])(node, 'em'); |
|
10618 } else if (node.nodeName === 'A') { |
|
10619 // In jsdom-jscore, 'node.target' can be null. |
|
10620 // TODO: Explore fixing this by patching jsdom-jscore. |
|
10621 if (node.target && node.target.toLowerCase() === '_blank') { |
|
10622 node.rel = 'noreferrer noopener'; |
|
10623 } else { |
|
10624 node.removeAttribute('target'); |
|
10625 node.removeAttribute('rel'); |
|
10626 } |
|
10627 } |
|
10628 }); |
|
10629 |
|
10630 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/head-remover.js |
|
10631 /* harmony default export */ var head_remover = (function (node) { |
|
10632 if (node.nodeName !== 'SCRIPT' && node.nodeName !== 'NOSCRIPT' && node.nodeName !== 'TEMPLATE' && node.nodeName !== 'STYLE') { |
|
10633 return; |
|
10634 } |
|
10635 |
|
10636 node.parentNode.removeChild(node); |
|
10637 }); |
|
10638 |
|
10639 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/ms-list-converter.js |
|
10640 /** |
|
10641 * Browser dependencies |
|
10642 */ |
|
10643 var _window = window, |
|
10644 ms_list_converter_parseInt = _window.parseInt; |
|
10645 |
|
10646 function ms_list_converter_isList(node) { |
|
10647 return node.nodeName === 'OL' || node.nodeName === 'UL'; |
|
10648 } |
|
10649 |
|
10650 /* harmony default export */ var ms_list_converter = (function (node, doc) { |
|
10651 if (node.nodeName !== 'P') { |
|
10652 return; |
|
10653 } |
|
10654 |
|
10655 var style = node.getAttribute('style'); |
|
10656 |
|
10657 if (!style) { |
|
10658 return; |
|
10659 } // Quick check. |
|
10660 |
|
10661 |
|
10662 if (style.indexOf('mso-list') === -1) { |
|
10663 return; |
|
10664 } |
|
10665 |
|
10666 var matches = /mso-list\s*:[^;]+level([0-9]+)/i.exec(style); |
|
10667 |
|
10668 if (!matches) { |
|
10669 return; |
|
10670 } |
|
10671 |
|
10672 var level = ms_list_converter_parseInt(matches[1], 10) - 1 || 0; |
|
10673 var prevNode = node.previousElementSibling; // Add new list if no previous. |
|
10674 |
|
10675 if (!prevNode || !ms_list_converter_isList(prevNode)) { |
|
10676 // See https://html.spec.whatwg.org/multipage/grouping-content.html#attr-ol-type. |
|
10677 var type = node.textContent.trim().slice(0, 1); |
|
10678 var isNumeric = /[1iIaA]/.test(type); |
|
10679 var newListNode = doc.createElement(isNumeric ? 'ol' : 'ul'); |
|
10680 |
|
10681 if (isNumeric) { |
|
10682 newListNode.setAttribute('type', type); |
|
10683 } |
|
10684 |
|
10685 node.parentNode.insertBefore(newListNode, node); |
|
10686 } |
|
10687 |
|
10688 var listNode = node.previousElementSibling; |
|
10689 var listType = listNode.nodeName; |
|
10690 var listItem = doc.createElement('li'); |
|
10691 var receivingNode = listNode; // Remove the first span with list info. |
|
10692 |
|
10693 node.removeChild(node.firstElementChild); // Add content. |
|
10694 |
|
10695 while (node.firstChild) { |
|
10696 listItem.appendChild(node.firstChild); |
|
10697 } // Change pointer depending on indentation level. |
|
10698 |
|
10699 |
|
10700 while (level--) { |
|
10701 receivingNode = receivingNode.lastElementChild || receivingNode; // If it's a list, move pointer to the last item. |
|
10702 |
|
10703 if (ms_list_converter_isList(receivingNode)) { |
|
10704 receivingNode = receivingNode.lastElementChild || receivingNode; |
|
10705 } |
|
10706 } // Make sure we append to a list. |
|
10707 |
|
10708 |
|
10709 if (!ms_list_converter_isList(receivingNode)) { |
|
10710 receivingNode = receivingNode.appendChild(doc.createElement(listType)); |
|
10711 } // Append the list item to the list. |
|
10712 |
|
10713 |
|
10714 receivingNode.appendChild(listItem); // Remove the wrapper paragraph. |
|
10715 |
|
10716 node.parentNode.removeChild(node); |
|
10717 }); |
|
10718 |
|
10719 // EXTERNAL MODULE: external {"this":["wp","blob"]} |
|
10720 var external_this_wp_blob_ = __webpack_require__(35); |
|
10721 |
|
10722 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/image-corrector.js |
|
10723 |
|
10724 |
|
10725 /** |
|
10726 * WordPress dependencies |
|
10727 */ |
|
10728 |
|
10729 /** |
|
10730 * Browser dependencies |
|
10731 */ |
|
10732 |
|
10733 var image_corrector_window = window, |
|
10734 atob = image_corrector_window.atob, |
|
10735 File = image_corrector_window.File; |
|
10736 /* harmony default export */ var image_corrector = (function (node) { |
|
10737 if (node.nodeName !== 'IMG') { |
|
10738 return; |
|
10739 } |
|
10740 |
|
10741 if (node.src.indexOf('file:') === 0) { |
|
10742 node.src = ''; |
|
10743 } // This piece cannot be tested outside a browser env. |
|
10744 |
|
10745 |
|
10746 if (node.src.indexOf('data:') === 0) { |
|
10747 var _node$src$split = node.src.split(','), |
|
10748 _node$src$split2 = Object(slicedToArray["a" /* default */])(_node$src$split, 2), |
|
10749 properties = _node$src$split2[0], |
|
10750 data = _node$src$split2[1]; |
|
10751 |
|
10752 var _properties$slice$spl = properties.slice(5).split(';'), |
|
10753 _properties$slice$spl2 = Object(slicedToArray["a" /* default */])(_properties$slice$spl, 1), |
|
10754 type = _properties$slice$spl2[0]; |
|
10755 |
|
10756 if (!data || !type) { |
|
10757 node.src = ''; |
|
10758 return; |
|
10759 } |
|
10760 |
|
10761 var decoded; // Can throw DOMException! |
|
10762 |
|
10763 try { |
|
10764 decoded = atob(data); |
|
10765 } catch (e) { |
|
10766 node.src = ''; |
|
10767 return; |
|
10768 } |
|
10769 |
|
10770 var uint8Array = new Uint8Array(decoded.length); |
|
10771 |
|
10772 for (var i = 0; i < uint8Array.length; i++) { |
|
10773 uint8Array[i] = decoded.charCodeAt(i); |
|
10774 } |
|
10775 |
|
10776 var name = type.replace('/', '.'); |
|
10777 var file = new File([uint8Array], name, { |
|
10778 type: type |
|
10779 }); |
|
10780 node.src = Object(external_this_wp_blob_["createBlobURL"])(file); |
|
10781 } // Remove trackers and hardly visible images. |
|
10782 |
|
10783 |
|
10784 if (node.height === 1 || node.width === 1) { |
|
10785 node.parentNode.removeChild(node); |
|
10786 } |
|
10787 }); |
|
10788 |
|
10789 // EXTERNAL MODULE: ./node_modules/showdown/dist/showdown.js |
|
10790 var showdown = __webpack_require__(206); |
|
10791 var showdown_default = /*#__PURE__*/__webpack_require__.n(showdown); |
|
10792 |
|
10793 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/markdown-converter.js |
|
10794 /** |
|
10795 * External dependencies |
|
10796 */ |
|
10797 // Reuse the same showdown converter. |
|
10798 |
|
10799 var converter = new showdown_default.a.Converter({ |
|
10800 noHeaderId: true, |
|
10801 tables: true, |
|
10802 literalMidWordUnderscores: true, |
|
10803 omitExtraWLInCodeBlocks: true, |
|
10804 simpleLineBreaks: true, |
|
10805 strikethrough: true |
|
10806 }); |
|
10807 /** |
|
10808 * Corrects the Slack Markdown variant of the code block. |
|
10809 * If uncorrected, it will be converted to inline code. |
|
10810 * |
|
10811 * @see https://get.slack.help/hc/en-us/articles/202288908-how-can-i-add-formatting-to-my-messages-#code-blocks |
|
10812 * |
|
10813 * @param {string} text The potential Markdown text to correct. |
|
10814 * |
|
10815 * @return {string} The corrected Markdown. |
|
10816 */ |
|
10817 |
|
10818 function slackMarkdownVariantCorrector(text) { |
|
10819 return text.replace(/((?:^|\n)```)([^\n`]+)(```(?:$|\n))/, function (match, p1, p2, p3) { |
|
10820 return "".concat(p1, "\n").concat(p2, "\n").concat(p3); |
|
10821 }); |
|
10822 } |
|
10823 /** |
|
10824 * Converts a piece of text into HTML based on any Markdown present. |
|
10825 * Also decodes any encoded HTML. |
|
10826 * |
|
10827 * @param {string} text The plain text to convert. |
|
10828 * |
|
10829 * @return {string} HTML. |
|
10830 */ |
|
10831 |
|
10832 |
|
10833 /* harmony default export */ var markdown_converter = (function (text) { |
|
10834 return converter.makeHtml(slackMarkdownVariantCorrector(text)); |
|
10835 }); |
|
10836 |
|
10837 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/iframe-remover.js |
|
10838 /** |
|
10839 * WordPress dependencies |
|
10840 */ |
|
10841 |
|
10842 /** |
|
10843 * Removes iframes. |
|
10844 * |
|
10845 * @param {Node} node The node to check. |
|
10846 * |
|
10847 * @return {void} |
|
10848 */ |
|
10849 |
|
10850 /* harmony default export */ var iframe_remover = (function (node) { |
|
10851 if (node.nodeName === 'IFRAME') { |
|
10852 Object(external_this_wp_dom_["remove"])(node); |
|
10853 } |
|
10854 }); |
|
10855 |
|
10856 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/google-docs-uid-remover.js |
|
10857 /** |
|
10858 * WordPress dependencies |
|
10859 */ |
|
10860 |
|
10861 /* harmony default export */ var google_docs_uid_remover = (function (node) { |
|
10862 if (!node.id || node.id.indexOf('docs-internal-guid-') !== 0) { |
|
10863 return; |
|
10864 } |
|
10865 |
|
10866 Object(external_this_wp_dom_["unwrap"])(node); |
|
10867 }); |
|
10868 |
|
10869 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/paste-handler.js |
|
10870 |
|
10871 |
|
10872 /** |
|
10873 * External dependencies |
|
10874 */ |
|
10875 |
|
10876 /** |
|
10877 * Internal dependencies |
|
10878 */ |
|
10879 |
|
10880 |
|
10881 |
|
10882 |
|
10883 |
|
10884 |
|
10885 |
|
10886 |
|
10887 |
|
10888 |
|
10889 |
|
10890 |
|
10891 |
|
10892 |
|
10893 |
|
10894 |
|
10895 |
|
10896 |
|
10897 |
|
10898 |
|
10899 |
|
10900 /** |
|
10901 * Browser dependencies |
|
10902 */ |
|
10903 |
|
10904 var paste_handler_window = window, |
|
10905 paste_handler_console = paste_handler_window.console; |
|
10906 /** |
|
10907 * Filters HTML to only contain phrasing content. |
|
10908 * |
|
10909 * @param {string} HTML The HTML to filter. |
|
10910 * |
|
10911 * @return {string} HTML only containing phrasing content. |
|
10912 */ |
|
10913 |
|
10914 function filterInlineHTML(HTML) { |
|
10915 HTML = deepFilterHTML(HTML, [google_docs_uid_remover, phrasing_content_reducer, comment_remover]); |
|
10916 HTML = removeInvalidHTML(HTML, getPhrasingContentSchema(), { |
|
10917 inline: true |
|
10918 }); // Allows us to ask for this information when we get a report. |
|
10919 |
|
10920 paste_handler_console.log('Processed inline HTML:\n\n', HTML); |
|
10921 return HTML; |
|
10922 } |
|
10923 |
|
10924 function getRawTransformations() { |
|
10925 return Object(external_lodash_["filter"])(getBlockTransforms('from'), { |
|
10926 type: 'raw' |
|
10927 }).map(function (transform) { |
|
10928 return transform.isMatch ? transform : Object(objectSpread["a" /* default */])({}, transform, { |
|
10929 isMatch: function isMatch(node) { |
|
10930 return transform.selector && node.matches(transform.selector); |
|
10931 } |
|
10932 }); |
|
10933 }); |
|
10934 } |
|
10935 /** |
|
10936 * Converts HTML directly to blocks. Looks for a matching transform for each |
|
10937 * top-level tag. The HTML should be filtered to not have any text between |
|
10938 * top-level tags and formatted in a way that blocks can handle the HTML. |
|
10939 * |
|
10940 * @param {Object} $1 Named parameters. |
|
10941 * @param {string} $1.html HTML to convert. |
|
10942 * @param {Array} $1.rawTransforms Transforms that can be used. |
|
10943 * |
|
10944 * @return {Array} An array of blocks. |
|
10945 */ |
|
10946 |
|
10947 |
|
10948 function htmlToBlocks(_ref) { |
|
10949 var html = _ref.html, |
|
10950 rawTransforms = _ref.rawTransforms; |
|
10951 var doc = document.implementation.createHTMLDocument(''); |
|
10952 doc.body.innerHTML = html; |
|
10953 return Array.from(doc.body.children).map(function (node) { |
|
10954 var rawTransform = findTransform(rawTransforms, function (_ref2) { |
|
10955 var isMatch = _ref2.isMatch; |
|
10956 return isMatch(node); |
|
10957 }); |
|
10958 |
|
10959 if (!rawTransform) { |
|
10960 return createBlock( // Should not be hardcoded. |
|
10961 'core/html', getBlockAttributes('core/html', node.outerHTML)); |
|
10962 } |
|
10963 |
|
10964 var transform = rawTransform.transform, |
|
10965 blockName = rawTransform.blockName; |
|
10966 |
|
10967 if (transform) { |
|
10968 return transform(node); |
|
10969 } |
|
10970 |
|
10971 return createBlock(blockName, getBlockAttributes(blockName, node.outerHTML)); |
|
10972 }); |
|
10973 } |
|
10974 /** |
|
10975 * Converts an HTML string to known blocks. Strips everything else. |
|
10976 * |
|
10977 * @param {string} [options.HTML] The HTML to convert. |
|
10978 * @param {string} [options.plainText] Plain text version. |
|
10979 * @param {string} [options.mode] Handle content as blocks or inline content. |
|
10980 * * 'AUTO': Decide based on the content passed. |
|
10981 * * 'INLINE': Always handle as inline content, and return string. |
|
10982 * * 'BLOCKS': Always handle as blocks, and return array of blocks. |
|
10983 * @param {Array} [options.tagName] The tag into which content will be inserted. |
|
10984 * @param {boolean} [options.canUserUseUnfilteredHTML] Whether or not the user can use unfiltered HTML. |
|
10985 * |
|
10986 * @return {Array|string} A list of blocks or a string, depending on `handlerMode`. |
|
10987 */ |
|
10988 |
|
10989 |
|
10990 function pasteHandler(_ref3) { |
|
10991 var _ref3$HTML = _ref3.HTML, |
|
10992 HTML = _ref3$HTML === void 0 ? '' : _ref3$HTML, |
|
10993 _ref3$plainText = _ref3.plainText, |
|
10994 plainText = _ref3$plainText === void 0 ? '' : _ref3$plainText, |
|
10995 _ref3$mode = _ref3.mode, |
|
10996 mode = _ref3$mode === void 0 ? 'AUTO' : _ref3$mode, |
|
10997 tagName = _ref3.tagName, |
|
10998 _ref3$canUserUseUnfil = _ref3.canUserUseUnfilteredHTML, |
|
10999 canUserUseUnfilteredHTML = _ref3$canUserUseUnfil === void 0 ? false : _ref3$canUserUseUnfil; |
|
11000 // First of all, strip any meta tags. |
|
11001 HTML = HTML.replace(/<meta[^>]+>/, ''); // If we detect block delimiters in HTML, parse entirely as blocks. |
|
11002 |
|
11003 if (mode !== 'INLINE') { |
|
11004 // Check plain text if there is no HTML. |
|
11005 var content = HTML ? HTML : plainText; |
|
11006 |
|
11007 if (content.indexOf('<!-- wp:') !== -1) { |
|
11008 return parseWithGrammar(content); |
|
11009 } |
|
11010 } // Normalize unicode to use composed characters. |
|
11011 // This is unsupported in IE 11 but it's a nice-to-have feature, not mandatory. |
|
11012 // Not normalizing the content will only affect older browsers and won't |
|
11013 // entirely break the app. |
|
11014 // See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize |
|
11015 // See: https://core.trac.wordpress.org/ticket/30130 |
|
11016 // See: https://github.com/WordPress/gutenberg/pull/6983#pullrequestreview-125151075 |
|
11017 |
|
11018 |
|
11019 if (String.prototype.normalize) { |
|
11020 HTML = HTML.normalize(); |
|
11021 } // Parse Markdown (and encoded HTML) if: |
|
11022 // * There is a plain text version. |
|
11023 // * There is no HTML version, or it has no formatting. |
|
11024 |
|
11025 |
|
11026 if (plainText && (!HTML || isPlain(HTML))) { |
|
11027 HTML = markdown_converter(plainText); // Switch to inline mode if: |
|
11028 // * The current mode is AUTO. |
|
11029 // * The original plain text had no line breaks. |
|
11030 // * The original plain text was not an HTML paragraph. |
|
11031 // * The converted text is just a paragraph. |
|
11032 |
|
11033 if (mode === 'AUTO' && plainText.indexOf('\n') === -1 && plainText.indexOf('<p>') !== 0 && HTML.indexOf('<p>') === 0) { |
|
11034 mode = 'INLINE'; |
|
11035 } |
|
11036 } |
|
11037 |
|
11038 if (mode === 'INLINE') { |
|
11039 return filterInlineHTML(HTML); |
|
11040 } // An array of HTML strings and block objects. The blocks replace matched |
|
11041 // shortcodes. |
|
11042 |
|
11043 |
|
11044 var pieces = shortcode_converter(HTML); // The call to shortcodeConverter will always return more than one element |
|
11045 // if shortcodes are matched. The reason is when shortcodes are matched |
|
11046 // empty HTML strings are included. |
|
11047 |
|
11048 var hasShortcodes = pieces.length > 1; |
|
11049 |
|
11050 if (mode === 'AUTO' && !hasShortcodes && is_inline_content(HTML, tagName)) { |
|
11051 return filterInlineHTML(HTML); |
|
11052 } |
|
11053 |
|
11054 var rawTransforms = getRawTransformations(); |
|
11055 var phrasingContentSchema = getPhrasingContentSchema(); |
|
11056 var blockContentSchema = getBlockContentSchema(rawTransforms); |
|
11057 var blocks = Object(external_lodash_["compact"])(Object(external_lodash_["flatMap"])(pieces, function (piece) { |
|
11058 // Already a block from shortcode. |
|
11059 if (typeof piece !== 'string') { |
|
11060 return piece; |
|
11061 } |
|
11062 |
|
11063 var filters = [google_docs_uid_remover, ms_list_converter, head_remover, list_reducer, image_corrector, phrasing_content_reducer, special_comment_converter, comment_remover, figure_content_reducer, blockquote_normaliser]; |
|
11064 |
|
11065 if (!canUserUseUnfilteredHTML) { |
|
11066 // Should run before `figureContentReducer`. |
|
11067 filters.unshift(iframe_remover); |
|
11068 } |
|
11069 |
|
11070 var schema = Object(objectSpread["a" /* default */])({}, blockContentSchema, phrasingContentSchema); |
|
11071 |
|
11072 piece = deepFilterHTML(piece, filters, blockContentSchema); |
|
11073 piece = removeInvalidHTML(piece, schema); |
|
11074 piece = normalise_blocks(piece); // Allows us to ask for this information when we get a report. |
|
11075 |
|
11076 paste_handler_console.log('Processed HTML piece:\n\n', piece); |
|
11077 return htmlToBlocks({ |
|
11078 html: piece, |
|
11079 rawTransforms: rawTransforms |
|
11080 }); |
|
11081 })); // If we're allowed to return inline content and there is only one block |
|
11082 // and the original plain text content does not have any line breaks, then |
|
11083 // treat it as inline paste. |
|
11084 |
|
11085 if (mode === 'AUTO' && blocks.length === 1) { |
|
11086 var trimmedPlainText = plainText.trim(); |
|
11087 |
|
11088 if (trimmedPlainText !== '' && trimmedPlainText.indexOf('\n') === -1) { |
|
11089 return removeInvalidHTML(getBlockContent(blocks[0]), phrasingContentSchema); |
|
11090 } |
|
11091 } |
|
11092 |
|
11093 return blocks; |
|
11094 } |
|
11095 |
|
11096 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/index.js |
|
11097 |
|
11098 |
|
11099 /** |
|
11100 * External dependencies |
|
11101 */ |
|
11102 |
|
11103 /** |
|
11104 * Internal dependencies |
|
11105 */ |
|
11106 |
|
11107 |
|
11108 |
|
11109 |
|
11110 |
|
11111 |
|
11112 |
|
11113 |
|
11114 |
|
11115 |
|
11116 |
|
11117 |
|
11118 |
|
11119 function raw_handling_getRawTransformations() { |
|
11120 return Object(external_lodash_["filter"])(getBlockTransforms('from'), { |
|
11121 type: 'raw' |
|
11122 }).map(function (transform) { |
|
11123 return transform.isMatch ? transform : Object(objectSpread["a" /* default */])({}, transform, { |
|
11124 isMatch: function isMatch(node) { |
|
11125 return transform.selector && node.matches(transform.selector); |
|
11126 } |
|
11127 }); |
|
11128 }); |
|
11129 } |
|
11130 /** |
|
11131 * Converts HTML directly to blocks. Looks for a matching transform for each |
|
11132 * top-level tag. The HTML should be filtered to not have any text between |
|
11133 * top-level tags and formatted in a way that blocks can handle the HTML. |
|
11134 * |
|
11135 * @param {Object} $1 Named parameters. |
|
11136 * @param {string} $1.html HTML to convert. |
|
11137 * @param {Array} $1.rawTransforms Transforms that can be used. |
|
11138 * |
|
11139 * @return {Array} An array of blocks. |
|
11140 */ |
|
11141 |
|
11142 |
|
11143 function raw_handling_htmlToBlocks(_ref) { |
|
11144 var html = _ref.html, |
|
11145 rawTransforms = _ref.rawTransforms; |
|
11146 var doc = document.implementation.createHTMLDocument(''); |
|
11147 doc.body.innerHTML = html; |
|
11148 return Array.from(doc.body.children).map(function (node) { |
|
11149 var rawTransform = findTransform(rawTransforms, function (_ref2) { |
|
11150 var isMatch = _ref2.isMatch; |
|
11151 return isMatch(node); |
|
11152 }); |
|
11153 |
|
11154 if (!rawTransform) { |
|
11155 return createBlock( // Should not be hardcoded. |
|
11156 'core/html', getBlockAttributes('core/html', node.outerHTML)); |
|
11157 } |
|
11158 |
|
11159 var transform = rawTransform.transform, |
|
11160 blockName = rawTransform.blockName; |
|
11161 |
|
11162 if (transform) { |
|
11163 return transform(node); |
|
11164 } |
|
11165 |
|
11166 return createBlock(blockName, getBlockAttributes(blockName, node.outerHTML)); |
|
11167 }); |
|
11168 } |
|
11169 /** |
|
11170 * Converts an HTML string to known blocks. |
|
11171 * |
|
11172 * @param {string} $1.HTML The HTML to convert. |
|
11173 * |
|
11174 * @return {Array} A list of blocks. |
|
11175 */ |
|
11176 |
|
11177 |
|
11178 function rawHandler(_ref3) { |
|
11179 var _ref3$HTML = _ref3.HTML, |
|
11180 HTML = _ref3$HTML === void 0 ? '' : _ref3$HTML; |
|
11181 |
|
11182 // If we detect block delimiters, parse entirely as blocks. |
|
11183 if (HTML.indexOf('<!-- wp:') !== -1) { |
|
11184 return parseWithGrammar(HTML); |
|
11185 } // An array of HTML strings and block objects. The blocks replace matched |
|
11186 // shortcodes. |
|
11187 |
|
11188 |
|
11189 var pieces = shortcode_converter(HTML); |
|
11190 var rawTransforms = raw_handling_getRawTransformations(); |
|
11191 var blockContentSchema = getBlockContentSchema(rawTransforms); |
|
11192 return Object(external_lodash_["compact"])(Object(external_lodash_["flatMap"])(pieces, function (piece) { |
|
11193 // Already a block from shortcode. |
|
11194 if (typeof piece !== 'string') { |
|
11195 return piece; |
|
11196 } // These filters are essential for some blocks to be able to transform |
|
11197 // from raw HTML. These filters move around some content or add |
|
11198 // additional tags, they do not remove any content. |
|
11199 |
|
11200 |
|
11201 var filters = [// Needed to adjust invalid lists. |
|
11202 list_reducer, // Needed to create more and nextpage blocks. |
|
11203 special_comment_converter, // Needed to create media blocks. |
|
11204 figure_content_reducer, // Needed to create the quote block, which cannot handle text |
|
11205 // without wrapper paragraphs. |
|
11206 blockquote_normaliser]; |
|
11207 piece = deepFilterHTML(piece, filters, blockContentSchema); |
|
11208 piece = normalise_blocks(piece); |
|
11209 return raw_handling_htmlToBlocks({ |
|
11210 html: piece, |
|
11211 rawTransforms: rawTransforms |
|
11212 }); |
|
11213 })); |
|
11214 } |
|
11215 |
|
11216 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/categories.js |
|
11217 /** |
|
11218 * WordPress dependencies |
|
11219 */ |
|
11220 |
|
11221 /** |
|
11222 * Returns all the block categories. |
|
11223 * |
|
11224 * @return {Object[]} Block categories. |
|
11225 */ |
|
11226 |
|
11227 function categories_getCategories() { |
|
11228 return Object(external_this_wp_data_["select"])('core/blocks').getCategories(); |
|
11229 } |
|
11230 /** |
|
11231 * Sets the block categories. |
|
11232 * |
|
11233 * @param {Object[]} categories Block categories. |
|
11234 */ |
|
11235 |
|
11236 function categories_setCategories(categories) { |
|
11237 Object(external_this_wp_data_["dispatch"])('core/blocks').setCategories(categories); |
|
11238 } |
|
11239 /** |
|
11240 * Updates a category. |
|
11241 * |
|
11242 * @param {string} slug Block category slug. |
|
11243 * @param {Object} category Object containing the category properties that should be updated. |
|
11244 */ |
|
11245 |
|
11246 function categories_updateCategory(slug, category) { |
|
11247 Object(external_this_wp_data_["dispatch"])('core/blocks').updateCategory(slug, category); |
|
11248 } |
|
11249 |
|
11250 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/templates.js |
|
11251 |
|
11252 |
|
11253 |
|
11254 /** |
|
11255 * External dependencies |
|
11256 */ |
|
11257 |
|
11258 /** |
|
11259 * WordPress dependencies |
|
11260 */ |
|
11261 |
|
11262 |
|
11263 /** |
|
11264 * Internal dependencies |
|
11265 */ |
|
11266 |
|
11267 |
|
11268 |
|
11269 /** |
|
11270 * Checks whether a list of blocks matches a template by comparing the block names. |
|
11271 * |
|
11272 * @param {Array} blocks Block list. |
|
11273 * @param {Array} template Block template. |
|
11274 * |
|
11275 * @return {boolean} Whether the list of blocks matches a templates |
|
11276 */ |
|
11277 |
|
11278 function doBlocksMatchTemplate() { |
|
11279 var blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
11280 var template = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; |
|
11281 return blocks.length === template.length && Object(external_lodash_["every"])(template, function (_ref, index) { |
|
11282 var _ref2 = Object(slicedToArray["a" /* default */])(_ref, 3), |
|
11283 name = _ref2[0], |
|
11284 innerBlocksTemplate = _ref2[2]; |
|
11285 |
|
11286 var block = blocks[index]; |
|
11287 return name === block.name && doBlocksMatchTemplate(block.innerBlocks, innerBlocksTemplate); |
|
11288 }); |
|
11289 } |
|
11290 /** |
|
11291 * Synchronize a block list with a block template. |
|
11292 * |
|
11293 * Synchronizing a block list with a block template means that we loop over the blocks |
|
11294 * keep the block as is if it matches the block at the same position in the template |
|
11295 * (If it has the same name) and if doesn't match, we create a new block based on the template. |
|
11296 * Extra blocks not present in the template are removed. |
|
11297 * |
|
11298 * @param {Array} blocks Block list. |
|
11299 * @param {Array} template Block template. |
|
11300 * |
|
11301 * @return {Array} Updated Block list. |
|
11302 */ |
|
11303 |
|
11304 function synchronizeBlocksWithTemplate() { |
|
11305 var blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
11306 var template = arguments.length > 1 ? arguments[1] : undefined; |
|
11307 |
|
11308 // If no template is provided, return blocks unmodified. |
|
11309 if (!template) { |
|
11310 return blocks; |
|
11311 } |
|
11312 |
|
11313 return Object(external_lodash_["map"])(template, function (_ref3, index) { |
|
11314 var _ref4 = Object(slicedToArray["a" /* default */])(_ref3, 3), |
|
11315 name = _ref4[0], |
|
11316 attributes = _ref4[1], |
|
11317 innerBlocksTemplate = _ref4[2]; |
|
11318 |
|
11319 var block = blocks[index]; |
|
11320 |
|
11321 if (block && block.name === name) { |
|
11322 var innerBlocks = synchronizeBlocksWithTemplate(block.innerBlocks, innerBlocksTemplate); |
|
11323 return Object(objectSpread["a" /* default */])({}, block, { |
|
11324 innerBlocks: innerBlocks |
|
11325 }); |
|
11326 } // To support old templates that were using the "children" format |
|
11327 // for the attributes using "html" strings now, we normalize the template attributes |
|
11328 // before creating the blocks. |
|
11329 |
|
11330 |
|
11331 var blockType = registration_getBlockType(name); |
|
11332 |
|
11333 var isHTMLAttribute = function isHTMLAttribute(attributeDefinition) { |
|
11334 return Object(external_lodash_["get"])(attributeDefinition, ['source']) === 'html'; |
|
11335 }; |
|
11336 |
|
11337 var isQueryAttribute = function isQueryAttribute(attributeDefinition) { |
|
11338 return Object(external_lodash_["get"])(attributeDefinition, ['source']) === 'query'; |
|
11339 }; |
|
11340 |
|
11341 var normalizeAttributes = function normalizeAttributes(schema, values) { |
|
11342 return Object(external_lodash_["mapValues"])(values, function (value, key) { |
|
11343 return normalizeAttribute(schema[key], value); |
|
11344 }); |
|
11345 }; |
|
11346 |
|
11347 var normalizeAttribute = function normalizeAttribute(definition, value) { |
|
11348 if (isHTMLAttribute(definition) && Object(external_lodash_["isArray"])(value)) { |
|
11349 // Introduce a deprecated call at this point |
|
11350 // When we're confident that "children" format should be removed from the templates. |
|
11351 return Object(external_this_wp_element_["renderToString"])(value); |
|
11352 } |
|
11353 |
|
11354 if (isQueryAttribute(definition) && value) { |
|
11355 return value.map(function (subValues) { |
|
11356 return normalizeAttributes(definition.query, subValues); |
|
11357 }); |
|
11358 } |
|
11359 |
|
11360 return value; |
|
11361 }; |
|
11362 |
|
11363 var normalizedAttributes = normalizeAttributes(Object(external_lodash_["get"])(blockType, ['attributes'], {}), attributes); |
|
11364 return createBlock(name, normalizedAttributes, synchronizeBlocksWithTemplate([], innerBlocksTemplate)); |
|
11365 }); |
|
11366 } |
|
11367 |
|
11368 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/index.js |
|
11369 |
|
11370 |
|
11371 |
|
11372 |
|
11373 |
|
11374 |
|
11375 |
|
11376 |
|
11377 |
|
11378 |
|
11379 |
|
11380 |
|
11381 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/index.js |
|
11382 /* concated harmony reexport createBlock */__webpack_require__.d(__webpack_exports__, "createBlock", function() { return createBlock; }); |
|
11383 /* concated harmony reexport cloneBlock */__webpack_require__.d(__webpack_exports__, "cloneBlock", function() { return cloneBlock; }); |
|
11384 /* concated harmony reexport getPossibleBlockTransformations */__webpack_require__.d(__webpack_exports__, "getPossibleBlockTransformations", function() { return getPossibleBlockTransformations; }); |
|
11385 /* concated harmony reexport switchToBlockType */__webpack_require__.d(__webpack_exports__, "switchToBlockType", function() { return switchToBlockType; }); |
|
11386 /* concated harmony reexport getBlockTransforms */__webpack_require__.d(__webpack_exports__, "getBlockTransforms", function() { return getBlockTransforms; }); |
|
11387 /* concated harmony reexport findTransform */__webpack_require__.d(__webpack_exports__, "findTransform", function() { return findTransform; }); |
|
11388 /* concated harmony reexport parse */__webpack_require__.d(__webpack_exports__, "parse", function() { return parser; }); |
|
11389 /* concated harmony reexport getBlockAttributes */__webpack_require__.d(__webpack_exports__, "getBlockAttributes", function() { return getBlockAttributes; }); |
|
11390 /* concated harmony reexport parseWithAttributeSchema */__webpack_require__.d(__webpack_exports__, "parseWithAttributeSchema", function() { return parseWithAttributeSchema; }); |
|
11391 /* concated harmony reexport pasteHandler */__webpack_require__.d(__webpack_exports__, "pasteHandler", function() { return pasteHandler; }); |
|
11392 /* concated harmony reexport rawHandler */__webpack_require__.d(__webpack_exports__, "rawHandler", function() { return rawHandler; }); |
|
11393 /* concated harmony reexport getPhrasingContentSchema */__webpack_require__.d(__webpack_exports__, "getPhrasingContentSchema", function() { return getPhrasingContentSchema; }); |
|
11394 /* concated harmony reexport serialize */__webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; }); |
|
11395 /* concated harmony reexport getBlockContent */__webpack_require__.d(__webpack_exports__, "getBlockContent", function() { return getBlockContent; }); |
|
11396 /* concated harmony reexport getBlockDefaultClassName */__webpack_require__.d(__webpack_exports__, "getBlockDefaultClassName", function() { return getBlockDefaultClassName; }); |
|
11397 /* concated harmony reexport getBlockMenuDefaultClassName */__webpack_require__.d(__webpack_exports__, "getBlockMenuDefaultClassName", function() { return getBlockMenuDefaultClassName; }); |
|
11398 /* concated harmony reexport getSaveElement */__webpack_require__.d(__webpack_exports__, "getSaveElement", function() { return getSaveElement; }); |
|
11399 /* concated harmony reexport getSaveContent */__webpack_require__.d(__webpack_exports__, "getSaveContent", function() { return getSaveContent; }); |
|
11400 /* concated harmony reexport isValidBlockContent */__webpack_require__.d(__webpack_exports__, "isValidBlockContent", function() { return isValidBlockContent; }); |
|
11401 /* concated harmony reexport getCategories */__webpack_require__.d(__webpack_exports__, "getCategories", function() { return categories_getCategories; }); |
|
11402 /* concated harmony reexport setCategories */__webpack_require__.d(__webpack_exports__, "setCategories", function() { return categories_setCategories; }); |
|
11403 /* concated harmony reexport updateCategory */__webpack_require__.d(__webpack_exports__, "updateCategory", function() { return categories_updateCategory; }); |
|
11404 /* concated harmony reexport registerBlockType */__webpack_require__.d(__webpack_exports__, "registerBlockType", function() { return registerBlockType; }); |
|
11405 /* concated harmony reexport unregisterBlockType */__webpack_require__.d(__webpack_exports__, "unregisterBlockType", function() { return unregisterBlockType; }); |
|
11406 /* concated harmony reexport setFreeformContentHandlerName */__webpack_require__.d(__webpack_exports__, "setFreeformContentHandlerName", function() { return setFreeformContentHandlerName; }); |
|
11407 /* concated harmony reexport getFreeformContentHandlerName */__webpack_require__.d(__webpack_exports__, "getFreeformContentHandlerName", function() { return getFreeformContentHandlerName; }); |
|
11408 /* concated harmony reexport setUnregisteredTypeHandlerName */__webpack_require__.d(__webpack_exports__, "setUnregisteredTypeHandlerName", function() { return setUnregisteredTypeHandlerName; }); |
|
11409 /* concated harmony reexport getUnregisteredTypeHandlerName */__webpack_require__.d(__webpack_exports__, "getUnregisteredTypeHandlerName", function() { return getUnregisteredTypeHandlerName; }); |
|
11410 /* concated harmony reexport setDefaultBlockName */__webpack_require__.d(__webpack_exports__, "setDefaultBlockName", function() { return registration_setDefaultBlockName; }); |
|
11411 /* concated harmony reexport getDefaultBlockName */__webpack_require__.d(__webpack_exports__, "getDefaultBlockName", function() { return registration_getDefaultBlockName; }); |
|
11412 /* concated harmony reexport getBlockType */__webpack_require__.d(__webpack_exports__, "getBlockType", function() { return registration_getBlockType; }); |
|
11413 /* concated harmony reexport getBlockTypes */__webpack_require__.d(__webpack_exports__, "getBlockTypes", function() { return registration_getBlockTypes; }); |
|
11414 /* concated harmony reexport getBlockSupport */__webpack_require__.d(__webpack_exports__, "getBlockSupport", function() { return registration_getBlockSupport; }); |
|
11415 /* concated harmony reexport hasBlockSupport */__webpack_require__.d(__webpack_exports__, "hasBlockSupport", function() { return registration_hasBlockSupport; }); |
|
11416 /* concated harmony reexport isReusableBlock */__webpack_require__.d(__webpack_exports__, "isReusableBlock", function() { return isReusableBlock; }); |
|
11417 /* concated harmony reexport getChildBlockNames */__webpack_require__.d(__webpack_exports__, "getChildBlockNames", function() { return registration_getChildBlockNames; }); |
|
11418 /* concated harmony reexport hasChildBlocks */__webpack_require__.d(__webpack_exports__, "hasChildBlocks", function() { return registration_hasChildBlocks; }); |
|
11419 /* concated harmony reexport hasChildBlocksWithInserterSupport */__webpack_require__.d(__webpack_exports__, "hasChildBlocksWithInserterSupport", function() { return registration_hasChildBlocksWithInserterSupport; }); |
|
11420 /* concated harmony reexport unstable__bootstrapServerSideBlockDefinitions */__webpack_require__.d(__webpack_exports__, "unstable__bootstrapServerSideBlockDefinitions", function() { return unstable__bootstrapServerSideBlockDefinitions; }); |
|
11421 /* concated harmony reexport registerBlockStyle */__webpack_require__.d(__webpack_exports__, "registerBlockStyle", function() { return registration_registerBlockStyle; }); |
|
11422 /* concated harmony reexport unregisterBlockStyle */__webpack_require__.d(__webpack_exports__, "unregisterBlockStyle", function() { return registration_unregisterBlockStyle; }); |
|
11423 /* concated harmony reexport isUnmodifiedDefaultBlock */__webpack_require__.d(__webpack_exports__, "isUnmodifiedDefaultBlock", function() { return isUnmodifiedDefaultBlock; }); |
|
11424 /* concated harmony reexport normalizeIconObject */__webpack_require__.d(__webpack_exports__, "normalizeIconObject", function() { return normalizeIconObject; }); |
|
11425 /* concated harmony reexport isValidIcon */__webpack_require__.d(__webpack_exports__, "isValidIcon", function() { return isValidIcon; }); |
|
11426 /* concated harmony reexport doBlocksMatchTemplate */__webpack_require__.d(__webpack_exports__, "doBlocksMatchTemplate", function() { return doBlocksMatchTemplate; }); |
|
11427 /* concated harmony reexport synchronizeBlocksWithTemplate */__webpack_require__.d(__webpack_exports__, "synchronizeBlocksWithTemplate", function() { return synchronizeBlocksWithTemplate; }); |
|
11428 /* concated harmony reexport children */__webpack_require__.d(__webpack_exports__, "children", function() { return api_children; }); |
|
11429 /* concated harmony reexport node */__webpack_require__.d(__webpack_exports__, "node", function() { return api_node; }); |
|
11430 /* concated harmony reexport withBlockContentContext */__webpack_require__.d(__webpack_exports__, "withBlockContentContext", function() { return withBlockContentContext; }); |
|
11431 // A "block" is the abstract term used to describe units of markup that, |
|
11432 // when composed together, form the content or layout of a page. |
|
11433 // The API for blocks is exposed via `wp.blocks`. |
|
11434 // |
|
11435 // Supported blocks are registered by calling `registerBlockType`. Once registered, |
|
11436 // the block is made available as an option to the editor interface. |
|
11437 // |
|
11438 // Blocks are inferred from the HTML source of a post through a parsing mechanism |
|
11439 // and then stored as objects in state, from which it is then rendered for editing. |
|
11440 |
|
11441 /** |
|
11442 * Internal dependencies |
|
11443 */ |
|
11444 |
|
11445 |
|
11446 |
|
11447 |
|
11448 |
|
11449 /***/ }), |
|
11450 |
|
11451 /***/ 37: |
|
11452 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
11453 |
|
11454 "use strict"; |
|
11455 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; }); |
|
11456 function _arrayWithHoles(arr) { |
|
11457 if (Array.isArray(arr)) return arr; |
|
11458 } |
|
11459 |
|
11460 /***/ }), |
|
11461 |
|
11462 /***/ 38: |
|
11463 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
11464 |
|
11465 "use strict"; |
|
11466 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; }); |
|
11467 function _nonIterableRest() { |
|
11468 throw new TypeError("Invalid attempt to destructure non-iterable instance"); |
|
11469 } |
|
11470 |
|
11471 /***/ }), |
|
11472 |
|
11473 /***/ 42: |
|
11474 /***/ (function(module, exports) { |
|
11475 |
|
11476 (function() { module.exports = this["wp"]["isShallowEqual"]; }()); |
|
11477 |
|
11478 /***/ }), |
|
11479 |
|
11480 /***/ 45: |
|
11481 /***/ (function(module, exports, __webpack_require__) { |
|
11482 |
|
11483 var __WEBPACK_AMD_DEFINE_RESULT__;// TinyColor v1.4.1 |
|
11484 // https://github.com/bgrins/TinyColor |
|
11485 // Brian Grinstead, MIT License |
|
11486 |
|
11487 (function(Math) { |
|
11488 |
|
11489 var trimLeft = /^\s+/, |
|
11490 trimRight = /\s+$/, |
|
11491 tinyCounter = 0, |
|
11492 mathRound = Math.round, |
|
11493 mathMin = Math.min, |
|
11494 mathMax = Math.max, |
|
11495 mathRandom = Math.random; |
|
11496 |
|
11497 function tinycolor (color, opts) { |
|
11498 |
|
11499 color = (color) ? color : ''; |
|
11500 opts = opts || { }; |
|
11501 |
|
11502 // If input is already a tinycolor, return itself |
|
11503 if (color instanceof tinycolor) { |
|
11504 return color; |
|
11505 } |
|
11506 // If we are called as a function, call using new instead |
|
11507 if (!(this instanceof tinycolor)) { |
|
11508 return new tinycolor(color, opts); |
|
11509 } |
|
11510 |
|
11511 var rgb = inputToRGB(color); |
|
11512 this._originalInput = color, |
|
11513 this._r = rgb.r, |
|
11514 this._g = rgb.g, |
|
11515 this._b = rgb.b, |
|
11516 this._a = rgb.a, |
|
11517 this._roundA = mathRound(100*this._a) / 100, |
|
11518 this._format = opts.format || rgb.format; |
|
11519 this._gradientType = opts.gradientType; |
|
11520 |
|
11521 // Don't let the range of [0,255] come back in [0,1]. |
|
11522 // Potentially lose a little bit of precision here, but will fix issues where |
|
11523 // .5 gets interpreted as half of the total, instead of half of 1 |
|
11524 // If it was supposed to be 128, this was already taken care of by `inputToRgb` |
|
11525 if (this._r < 1) { this._r = mathRound(this._r); } |
|
11526 if (this._g < 1) { this._g = mathRound(this._g); } |
|
11527 if (this._b < 1) { this._b = mathRound(this._b); } |
|
11528 |
|
11529 this._ok = rgb.ok; |
|
11530 this._tc_id = tinyCounter++; |
|
11531 } |
|
11532 |
|
11533 tinycolor.prototype = { |
|
11534 isDark: function() { |
|
11535 return this.getBrightness() < 128; |
|
11536 }, |
|
11537 isLight: function() { |
|
11538 return !this.isDark(); |
|
11539 }, |
|
11540 isValid: function() { |
|
11541 return this._ok; |
|
11542 }, |
|
11543 getOriginalInput: function() { |
|
11544 return this._originalInput; |
|
11545 }, |
|
11546 getFormat: function() { |
|
11547 return this._format; |
|
11548 }, |
|
11549 getAlpha: function() { |
|
11550 return this._a; |
|
11551 }, |
|
11552 getBrightness: function() { |
|
11553 //http://www.w3.org/TR/AERT#color-contrast |
|
11554 var rgb = this.toRgb(); |
|
11555 return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000; |
|
11556 }, |
|
11557 getLuminance: function() { |
|
11558 //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef |
|
11559 var rgb = this.toRgb(); |
|
11560 var RsRGB, GsRGB, BsRGB, R, G, B; |
|
11561 RsRGB = rgb.r/255; |
|
11562 GsRGB = rgb.g/255; |
|
11563 BsRGB = rgb.b/255; |
|
11564 |
|
11565 if (RsRGB <= 0.03928) {R = RsRGB / 12.92;} else {R = Math.pow(((RsRGB + 0.055) / 1.055), 2.4);} |
|
11566 if (GsRGB <= 0.03928) {G = GsRGB / 12.92;} else {G = Math.pow(((GsRGB + 0.055) / 1.055), 2.4);} |
|
11567 if (BsRGB <= 0.03928) {B = BsRGB / 12.92;} else {B = Math.pow(((BsRGB + 0.055) / 1.055), 2.4);} |
|
11568 return (0.2126 * R) + (0.7152 * G) + (0.0722 * B); |
|
11569 }, |
|
11570 setAlpha: function(value) { |
|
11571 this._a = boundAlpha(value); |
|
11572 this._roundA = mathRound(100*this._a) / 100; |
|
11573 return this; |
|
11574 }, |
|
11575 toHsv: function() { |
|
11576 var hsv = rgbToHsv(this._r, this._g, this._b); |
|
11577 return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a }; |
|
11578 }, |
|
11579 toHsvString: function() { |
|
11580 var hsv = rgbToHsv(this._r, this._g, this._b); |
|
11581 var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100); |
|
11582 return (this._a == 1) ? |
|
11583 "hsv(" + h + ", " + s + "%, " + v + "%)" : |
|
11584 "hsva(" + h + ", " + s + "%, " + v + "%, "+ this._roundA + ")"; |
|
11585 }, |
|
11586 toHsl: function() { |
|
11587 var hsl = rgbToHsl(this._r, this._g, this._b); |
|
11588 return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a }; |
|
11589 }, |
|
11590 toHslString: function() { |
|
11591 var hsl = rgbToHsl(this._r, this._g, this._b); |
|
11592 var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100); |
|
11593 return (this._a == 1) ? |
|
11594 "hsl(" + h + ", " + s + "%, " + l + "%)" : |
|
11595 "hsla(" + h + ", " + s + "%, " + l + "%, "+ this._roundA + ")"; |
|
11596 }, |
|
11597 toHex: function(allow3Char) { |
|
11598 return rgbToHex(this._r, this._g, this._b, allow3Char); |
|
11599 }, |
|
11600 toHexString: function(allow3Char) { |
|
11601 return '#' + this.toHex(allow3Char); |
|
11602 }, |
|
11603 toHex8: function(allow4Char) { |
|
11604 return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char); |
|
11605 }, |
|
11606 toHex8String: function(allow4Char) { |
|
11607 return '#' + this.toHex8(allow4Char); |
|
11608 }, |
|
11609 toRgb: function() { |
|
11610 return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a }; |
|
11611 }, |
|
11612 toRgbString: function() { |
|
11613 return (this._a == 1) ? |
|
11614 "rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" : |
|
11615 "rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")"; |
|
11616 }, |
|
11617 toPercentageRgb: function() { |
|
11618 return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a }; |
|
11619 }, |
|
11620 toPercentageRgbString: function() { |
|
11621 return (this._a == 1) ? |
|
11622 "rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" : |
|
11623 "rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")"; |
|
11624 }, |
|
11625 toName: function() { |
|
11626 if (this._a === 0) { |
|
11627 return "transparent"; |
|
11628 } |
|
11629 |
|
11630 if (this._a < 1) { |
|
11631 return false; |
|
11632 } |
|
11633 |
|
11634 return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false; |
|
11635 }, |
|
11636 toFilter: function(secondColor) { |
|
11637 var hex8String = '#' + rgbaToArgbHex(this._r, this._g, this._b, this._a); |
|
11638 var secondHex8String = hex8String; |
|
11639 var gradientType = this._gradientType ? "GradientType = 1, " : ""; |
|
11640 |
|
11641 if (secondColor) { |
|
11642 var s = tinycolor(secondColor); |
|
11643 secondHex8String = '#' + rgbaToArgbHex(s._r, s._g, s._b, s._a); |
|
11644 } |
|
11645 |
|
11646 return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")"; |
|
11647 }, |
|
11648 toString: function(format) { |
|
11649 var formatSet = !!format; |
|
11650 format = format || this._format; |
|
11651 |
|
11652 var formattedString = false; |
|
11653 var hasAlpha = this._a < 1 && this._a >= 0; |
|
11654 var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name"); |
|
11655 |
|
11656 if (needsAlphaFormat) { |
|
11657 // Special case for "transparent", all other non-alpha formats |
|
11658 // will return rgba when there is transparency. |
|
11659 if (format === "name" && this._a === 0) { |
|
11660 return this.toName(); |
|
11661 } |
|
11662 return this.toRgbString(); |
|
11663 } |
|
11664 if (format === "rgb") { |
|
11665 formattedString = this.toRgbString(); |
|
11666 } |
|
11667 if (format === "prgb") { |
|
11668 formattedString = this.toPercentageRgbString(); |
|
11669 } |
|
11670 if (format === "hex" || format === "hex6") { |
|
11671 formattedString = this.toHexString(); |
|
11672 } |
|
11673 if (format === "hex3") { |
|
11674 formattedString = this.toHexString(true); |
|
11675 } |
|
11676 if (format === "hex4") { |
|
11677 formattedString = this.toHex8String(true); |
|
11678 } |
|
11679 if (format === "hex8") { |
|
11680 formattedString = this.toHex8String(); |
|
11681 } |
|
11682 if (format === "name") { |
|
11683 formattedString = this.toName(); |
|
11684 } |
|
11685 if (format === "hsl") { |
|
11686 formattedString = this.toHslString(); |
|
11687 } |
|
11688 if (format === "hsv") { |
|
11689 formattedString = this.toHsvString(); |
|
11690 } |
|
11691 |
|
11692 return formattedString || this.toHexString(); |
|
11693 }, |
|
11694 clone: function() { |
|
11695 return tinycolor(this.toString()); |
|
11696 }, |
|
11697 |
|
11698 _applyModification: function(fn, args) { |
|
11699 var color = fn.apply(null, [this].concat([].slice.call(args))); |
|
11700 this._r = color._r; |
|
11701 this._g = color._g; |
|
11702 this._b = color._b; |
|
11703 this.setAlpha(color._a); |
|
11704 return this; |
|
11705 }, |
|
11706 lighten: function() { |
|
11707 return this._applyModification(lighten, arguments); |
|
11708 }, |
|
11709 brighten: function() { |
|
11710 return this._applyModification(brighten, arguments); |
|
11711 }, |
|
11712 darken: function() { |
|
11713 return this._applyModification(darken, arguments); |
|
11714 }, |
|
11715 desaturate: function() { |
|
11716 return this._applyModification(desaturate, arguments); |
|
11717 }, |
|
11718 saturate: function() { |
|
11719 return this._applyModification(saturate, arguments); |
|
11720 }, |
|
11721 greyscale: function() { |
|
11722 return this._applyModification(greyscale, arguments); |
|
11723 }, |
|
11724 spin: function() { |
|
11725 return this._applyModification(spin, arguments); |
|
11726 }, |
|
11727 |
|
11728 _applyCombination: function(fn, args) { |
|
11729 return fn.apply(null, [this].concat([].slice.call(args))); |
|
11730 }, |
|
11731 analogous: function() { |
|
11732 return this._applyCombination(analogous, arguments); |
|
11733 }, |
|
11734 complement: function() { |
|
11735 return this._applyCombination(complement, arguments); |
|
11736 }, |
|
11737 monochromatic: function() { |
|
11738 return this._applyCombination(monochromatic, arguments); |
|
11739 }, |
|
11740 splitcomplement: function() { |
|
11741 return this._applyCombination(splitcomplement, arguments); |
|
11742 }, |
|
11743 triad: function() { |
|
11744 return this._applyCombination(triad, arguments); |
|
11745 }, |
|
11746 tetrad: function() { |
|
11747 return this._applyCombination(tetrad, arguments); |
|
11748 } |
|
11749 }; |
|
11750 |
|
11751 // If input is an object, force 1 into "1.0" to handle ratios properly |
|
11752 // String input requires "1.0" as input, so 1 will be treated as 1 |
|
11753 tinycolor.fromRatio = function(color, opts) { |
|
11754 if (typeof color == "object") { |
|
11755 var newColor = {}; |
|
11756 for (var i in color) { |
|
11757 if (color.hasOwnProperty(i)) { |
|
11758 if (i === "a") { |
|
11759 newColor[i] = color[i]; |
|
11760 } |
|
11761 else { |
|
11762 newColor[i] = convertToPercentage(color[i]); |
|
11763 } |
|
11764 } |
|
11765 } |
|
11766 color = newColor; |
|
11767 } |
|
11768 |
|
11769 return tinycolor(color, opts); |
|
11770 }; |
|
11771 |
|
11772 // Given a string or object, convert that input to RGB |
|
11773 // Possible string inputs: |
|
11774 // |
|
11775 // "red" |
|
11776 // "#f00" or "f00" |
|
11777 // "#ff0000" or "ff0000" |
|
11778 // "#ff000000" or "ff000000" |
|
11779 // "rgb 255 0 0" or "rgb (255, 0, 0)" |
|
11780 // "rgb 1.0 0 0" or "rgb (1, 0, 0)" |
|
11781 // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1" |
|
11782 // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1" |
|
11783 // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%" |
|
11784 // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1" |
|
11785 // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%" |
|
11786 // |
|
11787 function inputToRGB(color) { |
|
11788 |
|
11789 var rgb = { r: 0, g: 0, b: 0 }; |
|
11790 var a = 1; |
|
11791 var s = null; |
|
11792 var v = null; |
|
11793 var l = null; |
|
11794 var ok = false; |
|
11795 var format = false; |
|
11796 |
|
11797 if (typeof color == "string") { |
|
11798 color = stringInputToObject(color); |
|
11799 } |
|
11800 |
|
11801 if (typeof color == "object") { |
|
11802 if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) { |
|
11803 rgb = rgbToRgb(color.r, color.g, color.b); |
|
11804 ok = true; |
|
11805 format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; |
|
11806 } |
|
11807 else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) { |
|
11808 s = convertToPercentage(color.s); |
|
11809 v = convertToPercentage(color.v); |
|
11810 rgb = hsvToRgb(color.h, s, v); |
|
11811 ok = true; |
|
11812 format = "hsv"; |
|
11813 } |
|
11814 else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) { |
|
11815 s = convertToPercentage(color.s); |
|
11816 l = convertToPercentage(color.l); |
|
11817 rgb = hslToRgb(color.h, s, l); |
|
11818 ok = true; |
|
11819 format = "hsl"; |
|
11820 } |
|
11821 |
|
11822 if (color.hasOwnProperty("a")) { |
|
11823 a = color.a; |
|
11824 } |
|
11825 } |
|
11826 |
|
11827 a = boundAlpha(a); |
|
11828 |
|
11829 return { |
|
11830 ok: ok, |
|
11831 format: color.format || format, |
|
11832 r: mathMin(255, mathMax(rgb.r, 0)), |
|
11833 g: mathMin(255, mathMax(rgb.g, 0)), |
|
11834 b: mathMin(255, mathMax(rgb.b, 0)), |
|
11835 a: a |
|
11836 }; |
|
11837 } |
|
11838 |
|
11839 |
|
11840 // Conversion Functions |
|
11841 // -------------------- |
|
11842 |
|
11843 // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from: |
|
11844 // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript> |
|
11845 |
|
11846 // `rgbToRgb` |
|
11847 // Handle bounds / percentage checking to conform to CSS color spec |
|
11848 // <http://www.w3.org/TR/css3-color/> |
|
11849 // *Assumes:* r, g, b in [0, 255] or [0, 1] |
|
11850 // *Returns:* { r, g, b } in [0, 255] |
|
11851 function rgbToRgb(r, g, b){ |
|
11852 return { |
|
11853 r: bound01(r, 255) * 255, |
|
11854 g: bound01(g, 255) * 255, |
|
11855 b: bound01(b, 255) * 255 |
|
11856 }; |
|
11857 } |
|
11858 |
|
11859 // `rgbToHsl` |
|
11860 // Converts an RGB color value to HSL. |
|
11861 // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1] |
|
11862 // *Returns:* { h, s, l } in [0,1] |
|
11863 function rgbToHsl(r, g, b) { |
|
11864 |
|
11865 r = bound01(r, 255); |
|
11866 g = bound01(g, 255); |
|
11867 b = bound01(b, 255); |
|
11868 |
|
11869 var max = mathMax(r, g, b), min = mathMin(r, g, b); |
|
11870 var h, s, l = (max + min) / 2; |
|
11871 |
|
11872 if(max == min) { |
|
11873 h = s = 0; // achromatic |
|
11874 } |
|
11875 else { |
|
11876 var d = max - min; |
|
11877 s = l > 0.5 ? d / (2 - max - min) : d / (max + min); |
|
11878 switch(max) { |
|
11879 case r: h = (g - b) / d + (g < b ? 6 : 0); break; |
|
11880 case g: h = (b - r) / d + 2; break; |
|
11881 case b: h = (r - g) / d + 4; break; |
|
11882 } |
|
11883 |
|
11884 h /= 6; |
|
11885 } |
|
11886 |
|
11887 return { h: h, s: s, l: l }; |
|
11888 } |
|
11889 |
|
11890 // `hslToRgb` |
|
11891 // Converts an HSL color value to RGB. |
|
11892 // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100] |
|
11893 // *Returns:* { r, g, b } in the set [0, 255] |
|
11894 function hslToRgb(h, s, l) { |
|
11895 var r, g, b; |
|
11896 |
|
11897 h = bound01(h, 360); |
|
11898 s = bound01(s, 100); |
|
11899 l = bound01(l, 100); |
|
11900 |
|
11901 function hue2rgb(p, q, t) { |
|
11902 if(t < 0) t += 1; |
|
11903 if(t > 1) t -= 1; |
|
11904 if(t < 1/6) return p + (q - p) * 6 * t; |
|
11905 if(t < 1/2) return q; |
|
11906 if(t < 2/3) return p + (q - p) * (2/3 - t) * 6; |
|
11907 return p; |
|
11908 } |
|
11909 |
|
11910 if(s === 0) { |
|
11911 r = g = b = l; // achromatic |
|
11912 } |
|
11913 else { |
|
11914 var q = l < 0.5 ? l * (1 + s) : l + s - l * s; |
|
11915 var p = 2 * l - q; |
|
11916 r = hue2rgb(p, q, h + 1/3); |
|
11917 g = hue2rgb(p, q, h); |
|
11918 b = hue2rgb(p, q, h - 1/3); |
|
11919 } |
|
11920 |
|
11921 return { r: r * 255, g: g * 255, b: b * 255 }; |
|
11922 } |
|
11923 |
|
11924 // `rgbToHsv` |
|
11925 // Converts an RGB color value to HSV |
|
11926 // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1] |
|
11927 // *Returns:* { h, s, v } in [0,1] |
|
11928 function rgbToHsv(r, g, b) { |
|
11929 |
|
11930 r = bound01(r, 255); |
|
11931 g = bound01(g, 255); |
|
11932 b = bound01(b, 255); |
|
11933 |
|
11934 var max = mathMax(r, g, b), min = mathMin(r, g, b); |
|
11935 var h, s, v = max; |
|
11936 |
|
11937 var d = max - min; |
|
11938 s = max === 0 ? 0 : d / max; |
|
11939 |
|
11940 if(max == min) { |
|
11941 h = 0; // achromatic |
|
11942 } |
|
11943 else { |
|
11944 switch(max) { |
|
11945 case r: h = (g - b) / d + (g < b ? 6 : 0); break; |
|
11946 case g: h = (b - r) / d + 2; break; |
|
11947 case b: h = (r - g) / d + 4; break; |
|
11948 } |
|
11949 h /= 6; |
|
11950 } |
|
11951 return { h: h, s: s, v: v }; |
|
11952 } |
|
11953 |
|
11954 // `hsvToRgb` |
|
11955 // Converts an HSV color value to RGB. |
|
11956 // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100] |
|
11957 // *Returns:* { r, g, b } in the set [0, 255] |
|
11958 function hsvToRgb(h, s, v) { |
|
11959 |
|
11960 h = bound01(h, 360) * 6; |
|
11961 s = bound01(s, 100); |
|
11962 v = bound01(v, 100); |
|
11963 |
|
11964 var i = Math.floor(h), |
|
11965 f = h - i, |
|
11966 p = v * (1 - s), |
|
11967 q = v * (1 - f * s), |
|
11968 t = v * (1 - (1 - f) * s), |
|
11969 mod = i % 6, |
|
11970 r = [v, q, p, p, t, v][mod], |
|
11971 g = [t, v, v, q, p, p][mod], |
|
11972 b = [p, p, t, v, v, q][mod]; |
|
11973 |
|
11974 return { r: r * 255, g: g * 255, b: b * 255 }; |
|
11975 } |
|
11976 |
|
11977 // `rgbToHex` |
|
11978 // Converts an RGB color to hex |
|
11979 // Assumes r, g, and b are contained in the set [0, 255] |
|
11980 // Returns a 3 or 6 character hex |
|
11981 function rgbToHex(r, g, b, allow3Char) { |
|
11982 |
|
11983 var hex = [ |
|
11984 pad2(mathRound(r).toString(16)), |
|
11985 pad2(mathRound(g).toString(16)), |
|
11986 pad2(mathRound(b).toString(16)) |
|
11987 ]; |
|
11988 |
|
11989 // Return a 3 character hex if possible |
|
11990 if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) { |
|
11991 return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0); |
|
11992 } |
|
11993 |
|
11994 return hex.join(""); |
|
11995 } |
|
11996 |
|
11997 // `rgbaToHex` |
|
11998 // Converts an RGBA color plus alpha transparency to hex |
|
11999 // Assumes r, g, b are contained in the set [0, 255] and |
|
12000 // a in [0, 1]. Returns a 4 or 8 character rgba hex |
|
12001 function rgbaToHex(r, g, b, a, allow4Char) { |
|
12002 |
|
12003 var hex = [ |
|
12004 pad2(mathRound(r).toString(16)), |
|
12005 pad2(mathRound(g).toString(16)), |
|
12006 pad2(mathRound(b).toString(16)), |
|
12007 pad2(convertDecimalToHex(a)) |
|
12008 ]; |
|
12009 |
|
12010 // Return a 4 character hex if possible |
|
12011 if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) { |
|
12012 return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0); |
|
12013 } |
|
12014 |
|
12015 return hex.join(""); |
|
12016 } |
|
12017 |
|
12018 // `rgbaToArgbHex` |
|
12019 // Converts an RGBA color to an ARGB Hex8 string |
|
12020 // Rarely used, but required for "toFilter()" |
|
12021 function rgbaToArgbHex(r, g, b, a) { |
|
12022 |
|
12023 var hex = [ |
|
12024 pad2(convertDecimalToHex(a)), |
|
12025 pad2(mathRound(r).toString(16)), |
|
12026 pad2(mathRound(g).toString(16)), |
|
12027 pad2(mathRound(b).toString(16)) |
|
12028 ]; |
|
12029 |
|
12030 return hex.join(""); |
|
12031 } |
|
12032 |
|
12033 // `equals` |
|
12034 // Can be called with any tinycolor input |
|
12035 tinycolor.equals = function (color1, color2) { |
|
12036 if (!color1 || !color2) { return false; } |
|
12037 return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString(); |
|
12038 }; |
|
12039 |
|
12040 tinycolor.random = function() { |
|
12041 return tinycolor.fromRatio({ |
|
12042 r: mathRandom(), |
|
12043 g: mathRandom(), |
|
12044 b: mathRandom() |
|
12045 }); |
|
12046 }; |
|
12047 |
|
12048 |
|
12049 // Modification Functions |
|
12050 // ---------------------- |
|
12051 // Thanks to less.js for some of the basics here |
|
12052 // <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js> |
|
12053 |
|
12054 function desaturate(color, amount) { |
|
12055 amount = (amount === 0) ? 0 : (amount || 10); |
|
12056 var hsl = tinycolor(color).toHsl(); |
|
12057 hsl.s -= amount / 100; |
|
12058 hsl.s = clamp01(hsl.s); |
|
12059 return tinycolor(hsl); |
|
12060 } |
|
12061 |
|
12062 function saturate(color, amount) { |
|
12063 amount = (amount === 0) ? 0 : (amount || 10); |
|
12064 var hsl = tinycolor(color).toHsl(); |
|
12065 hsl.s += amount / 100; |
|
12066 hsl.s = clamp01(hsl.s); |
|
12067 return tinycolor(hsl); |
|
12068 } |
|
12069 |
|
12070 function greyscale(color) { |
|
12071 return tinycolor(color).desaturate(100); |
|
12072 } |
|
12073 |
|
12074 function lighten (color, amount) { |
|
12075 amount = (amount === 0) ? 0 : (amount || 10); |
|
12076 var hsl = tinycolor(color).toHsl(); |
|
12077 hsl.l += amount / 100; |
|
12078 hsl.l = clamp01(hsl.l); |
|
12079 return tinycolor(hsl); |
|
12080 } |
|
12081 |
|
12082 function brighten(color, amount) { |
|
12083 amount = (amount === 0) ? 0 : (amount || 10); |
|
12084 var rgb = tinycolor(color).toRgb(); |
|
12085 rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100)))); |
|
12086 rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100)))); |
|
12087 rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100)))); |
|
12088 return tinycolor(rgb); |
|
12089 } |
|
12090 |
|
12091 function darken (color, amount) { |
|
12092 amount = (amount === 0) ? 0 : (amount || 10); |
|
12093 var hsl = tinycolor(color).toHsl(); |
|
12094 hsl.l -= amount / 100; |
|
12095 hsl.l = clamp01(hsl.l); |
|
12096 return tinycolor(hsl); |
|
12097 } |
|
12098 |
|
12099 // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue. |
|
12100 // Values outside of this range will be wrapped into this range. |
|
12101 function spin(color, amount) { |
|
12102 var hsl = tinycolor(color).toHsl(); |
|
12103 var hue = (hsl.h + amount) % 360; |
|
12104 hsl.h = hue < 0 ? 360 + hue : hue; |
|
12105 return tinycolor(hsl); |
|
12106 } |
|
12107 |
|
12108 // Combination Functions |
|
12109 // --------------------- |
|
12110 // Thanks to jQuery xColor for some of the ideas behind these |
|
12111 // <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js> |
|
12112 |
|
12113 function complement(color) { |
|
12114 var hsl = tinycolor(color).toHsl(); |
|
12115 hsl.h = (hsl.h + 180) % 360; |
|
12116 return tinycolor(hsl); |
|
12117 } |
|
12118 |
|
12119 function triad(color) { |
|
12120 var hsl = tinycolor(color).toHsl(); |
|
12121 var h = hsl.h; |
|
12122 return [ |
|
12123 tinycolor(color), |
|
12124 tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }), |
|
12125 tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l }) |
|
12126 ]; |
|
12127 } |
|
12128 |
|
12129 function tetrad(color) { |
|
12130 var hsl = tinycolor(color).toHsl(); |
|
12131 var h = hsl.h; |
|
12132 return [ |
|
12133 tinycolor(color), |
|
12134 tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }), |
|
12135 tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }), |
|
12136 tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l }) |
|
12137 ]; |
|
12138 } |
|
12139 |
|
12140 function splitcomplement(color) { |
|
12141 var hsl = tinycolor(color).toHsl(); |
|
12142 var h = hsl.h; |
|
12143 return [ |
|
12144 tinycolor(color), |
|
12145 tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}), |
|
12146 tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l}) |
|
12147 ]; |
|
12148 } |
|
12149 |
|
12150 function analogous(color, results, slices) { |
|
12151 results = results || 6; |
|
12152 slices = slices || 30; |
|
12153 |
|
12154 var hsl = tinycolor(color).toHsl(); |
|
12155 var part = 360 / slices; |
|
12156 var ret = [tinycolor(color)]; |
|
12157 |
|
12158 for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) { |
|
12159 hsl.h = (hsl.h + part) % 360; |
|
12160 ret.push(tinycolor(hsl)); |
|
12161 } |
|
12162 return ret; |
|
12163 } |
|
12164 |
|
12165 function monochromatic(color, results) { |
|
12166 results = results || 6; |
|
12167 var hsv = tinycolor(color).toHsv(); |
|
12168 var h = hsv.h, s = hsv.s, v = hsv.v; |
|
12169 var ret = []; |
|
12170 var modification = 1 / results; |
|
12171 |
|
12172 while (results--) { |
|
12173 ret.push(tinycolor({ h: h, s: s, v: v})); |
|
12174 v = (v + modification) % 1; |
|
12175 } |
|
12176 |
|
12177 return ret; |
|
12178 } |
|
12179 |
|
12180 // Utility Functions |
|
12181 // --------------------- |
|
12182 |
|
12183 tinycolor.mix = function(color1, color2, amount) { |
|
12184 amount = (amount === 0) ? 0 : (amount || 50); |
|
12185 |
|
12186 var rgb1 = tinycolor(color1).toRgb(); |
|
12187 var rgb2 = tinycolor(color2).toRgb(); |
|
12188 |
|
12189 var p = amount / 100; |
|
12190 |
|
12191 var rgba = { |
|
12192 r: ((rgb2.r - rgb1.r) * p) + rgb1.r, |
|
12193 g: ((rgb2.g - rgb1.g) * p) + rgb1.g, |
|
12194 b: ((rgb2.b - rgb1.b) * p) + rgb1.b, |
|
12195 a: ((rgb2.a - rgb1.a) * p) + rgb1.a |
|
12196 }; |
|
12197 |
|
12198 return tinycolor(rgba); |
|
12199 }; |
|
12200 |
|
12201 |
|
12202 // Readability Functions |
|
12203 // --------------------- |
|
12204 // <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2) |
|
12205 |
|
12206 // `contrast` |
|
12207 // Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2) |
|
12208 tinycolor.readability = function(color1, color2) { |
|
12209 var c1 = tinycolor(color1); |
|
12210 var c2 = tinycolor(color2); |
|
12211 return (Math.max(c1.getLuminance(),c2.getLuminance())+0.05) / (Math.min(c1.getLuminance(),c2.getLuminance())+0.05); |
|
12212 }; |
|
12213 |
|
12214 // `isReadable` |
|
12215 // Ensure that foreground and background color combinations meet WCAG2 guidelines. |
|
12216 // The third argument is an optional Object. |
|
12217 // the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA'; |
|
12218 // the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'. |
|
12219 // If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}. |
|
12220 |
|
12221 // *Example* |
|
12222 // tinycolor.isReadable("#000", "#111") => false |
|
12223 // tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false |
|
12224 tinycolor.isReadable = function(color1, color2, wcag2) { |
|
12225 var readability = tinycolor.readability(color1, color2); |
|
12226 var wcag2Parms, out; |
|
12227 |
|
12228 out = false; |
|
12229 |
|
12230 wcag2Parms = validateWCAG2Parms(wcag2); |
|
12231 switch (wcag2Parms.level + wcag2Parms.size) { |
|
12232 case "AAsmall": |
|
12233 case "AAAlarge": |
|
12234 out = readability >= 4.5; |
|
12235 break; |
|
12236 case "AAlarge": |
|
12237 out = readability >= 3; |
|
12238 break; |
|
12239 case "AAAsmall": |
|
12240 out = readability >= 7; |
|
12241 break; |
|
12242 } |
|
12243 return out; |
|
12244 |
|
12245 }; |
|
12246 |
|
12247 // `mostReadable` |
|
12248 // Given a base color and a list of possible foreground or background |
|
12249 // colors for that base, returns the most readable color. |
|
12250 // Optionally returns Black or White if the most readable color is unreadable. |
|
12251 // *Example* |
|
12252 // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255" |
|
12253 // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff" |
|
12254 // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3" |
|
12255 // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff" |
|
12256 tinycolor.mostReadable = function(baseColor, colorList, args) { |
|
12257 var bestColor = null; |
|
12258 var bestScore = 0; |
|
12259 var readability; |
|
12260 var includeFallbackColors, level, size ; |
|
12261 args = args || {}; |
|
12262 includeFallbackColors = args.includeFallbackColors ; |
|
12263 level = args.level; |
|
12264 size = args.size; |
|
12265 |
|
12266 for (var i= 0; i < colorList.length ; i++) { |
|
12267 readability = tinycolor.readability(baseColor, colorList[i]); |
|
12268 if (readability > bestScore) { |
|
12269 bestScore = readability; |
|
12270 bestColor = tinycolor(colorList[i]); |
|
12271 } |
|
12272 } |
|
12273 |
|
12274 if (tinycolor.isReadable(baseColor, bestColor, {"level":level,"size":size}) || !includeFallbackColors) { |
|
12275 return bestColor; |
|
12276 } |
|
12277 else { |
|
12278 args.includeFallbackColors=false; |
|
12279 return tinycolor.mostReadable(baseColor,["#fff", "#000"],args); |
|
12280 } |
|
12281 }; |
|
12282 |
|
12283 |
|
12284 // Big List of Colors |
|
12285 // ------------------ |
|
12286 // <http://www.w3.org/TR/css3-color/#svg-color> |
|
12287 var names = tinycolor.names = { |
|
12288 aliceblue: "f0f8ff", |
|
12289 antiquewhite: "faebd7", |
|
12290 aqua: "0ff", |
|
12291 aquamarine: "7fffd4", |
|
12292 azure: "f0ffff", |
|
12293 beige: "f5f5dc", |
|
12294 bisque: "ffe4c4", |
|
12295 black: "000", |
|
12296 blanchedalmond: "ffebcd", |
|
12297 blue: "00f", |
|
12298 blueviolet: "8a2be2", |
|
12299 brown: "a52a2a", |
|
12300 burlywood: "deb887", |
|
12301 burntsienna: "ea7e5d", |
|
12302 cadetblue: "5f9ea0", |
|
12303 chartreuse: "7fff00", |
|
12304 chocolate: "d2691e", |
|
12305 coral: "ff7f50", |
|
12306 cornflowerblue: "6495ed", |
|
12307 cornsilk: "fff8dc", |
|
12308 crimson: "dc143c", |
|
12309 cyan: "0ff", |
|
12310 darkblue: "00008b", |
|
12311 darkcyan: "008b8b", |
|
12312 darkgoldenrod: "b8860b", |
|
12313 darkgray: "a9a9a9", |
|
12314 darkgreen: "006400", |
|
12315 darkgrey: "a9a9a9", |
|
12316 darkkhaki: "bdb76b", |
|
12317 darkmagenta: "8b008b", |
|
12318 darkolivegreen: "556b2f", |
|
12319 darkorange: "ff8c00", |
|
12320 darkorchid: "9932cc", |
|
12321 darkred: "8b0000", |
|
12322 darksalmon: "e9967a", |
|
12323 darkseagreen: "8fbc8f", |
|
12324 darkslateblue: "483d8b", |
|
12325 darkslategray: "2f4f4f", |
|
12326 darkslategrey: "2f4f4f", |
|
12327 darkturquoise: "00ced1", |
|
12328 darkviolet: "9400d3", |
|
12329 deeppink: "ff1493", |
|
12330 deepskyblue: "00bfff", |
|
12331 dimgray: "696969", |
|
12332 dimgrey: "696969", |
|
12333 dodgerblue: "1e90ff", |
|
12334 firebrick: "b22222", |
|
12335 floralwhite: "fffaf0", |
|
12336 forestgreen: "228b22", |
|
12337 fuchsia: "f0f", |
|
12338 gainsboro: "dcdcdc", |
|
12339 ghostwhite: "f8f8ff", |
|
12340 gold: "ffd700", |
|
12341 goldenrod: "daa520", |
|
12342 gray: "808080", |
|
12343 green: "008000", |
|
12344 greenyellow: "adff2f", |
|
12345 grey: "808080", |
|
12346 honeydew: "f0fff0", |
|
12347 hotpink: "ff69b4", |
|
12348 indianred: "cd5c5c", |
|
12349 indigo: "4b0082", |
|
12350 ivory: "fffff0", |
|
12351 khaki: "f0e68c", |
|
12352 lavender: "e6e6fa", |
|
12353 lavenderblush: "fff0f5", |
|
12354 lawngreen: "7cfc00", |
|
12355 lemonchiffon: "fffacd", |
|
12356 lightblue: "add8e6", |
|
12357 lightcoral: "f08080", |
|
12358 lightcyan: "e0ffff", |
|
12359 lightgoldenrodyellow: "fafad2", |
|
12360 lightgray: "d3d3d3", |
|
12361 lightgreen: "90ee90", |
|
12362 lightgrey: "d3d3d3", |
|
12363 lightpink: "ffb6c1", |
|
12364 lightsalmon: "ffa07a", |
|
12365 lightseagreen: "20b2aa", |
|
12366 lightskyblue: "87cefa", |
|
12367 lightslategray: "789", |
|
12368 lightslategrey: "789", |
|
12369 lightsteelblue: "b0c4de", |
|
12370 lightyellow: "ffffe0", |
|
12371 lime: "0f0", |
|
12372 limegreen: "32cd32", |
|
12373 linen: "faf0e6", |
|
12374 magenta: "f0f", |
|
12375 maroon: "800000", |
|
12376 mediumaquamarine: "66cdaa", |
|
12377 mediumblue: "0000cd", |
|
12378 mediumorchid: "ba55d3", |
|
12379 mediumpurple: "9370db", |
|
12380 mediumseagreen: "3cb371", |
|
12381 mediumslateblue: "7b68ee", |
|
12382 mediumspringgreen: "00fa9a", |
|
12383 mediumturquoise: "48d1cc", |
|
12384 mediumvioletred: "c71585", |
|
12385 midnightblue: "191970", |
|
12386 mintcream: "f5fffa", |
|
12387 mistyrose: "ffe4e1", |
|
12388 moccasin: "ffe4b5", |
|
12389 navajowhite: "ffdead", |
|
12390 navy: "000080", |
|
12391 oldlace: "fdf5e6", |
|
12392 olive: "808000", |
|
12393 olivedrab: "6b8e23", |
|
12394 orange: "ffa500", |
|
12395 orangered: "ff4500", |
|
12396 orchid: "da70d6", |
|
12397 palegoldenrod: "eee8aa", |
|
12398 palegreen: "98fb98", |
|
12399 paleturquoise: "afeeee", |
|
12400 palevioletred: "db7093", |
|
12401 papayawhip: "ffefd5", |
|
12402 peachpuff: "ffdab9", |
|
12403 peru: "cd853f", |
|
12404 pink: "ffc0cb", |
|
12405 plum: "dda0dd", |
|
12406 powderblue: "b0e0e6", |
|
12407 purple: "800080", |
|
12408 rebeccapurple: "663399", |
|
12409 red: "f00", |
|
12410 rosybrown: "bc8f8f", |
|
12411 royalblue: "4169e1", |
|
12412 saddlebrown: "8b4513", |
|
12413 salmon: "fa8072", |
|
12414 sandybrown: "f4a460", |
|
12415 seagreen: "2e8b57", |
|
12416 seashell: "fff5ee", |
|
12417 sienna: "a0522d", |
|
12418 silver: "c0c0c0", |
|
12419 skyblue: "87ceeb", |
|
12420 slateblue: "6a5acd", |
|
12421 slategray: "708090", |
|
12422 slategrey: "708090", |
|
12423 snow: "fffafa", |
|
12424 springgreen: "00ff7f", |
|
12425 steelblue: "4682b4", |
|
12426 tan: "d2b48c", |
|
12427 teal: "008080", |
|
12428 thistle: "d8bfd8", |
|
12429 tomato: "ff6347", |
|
12430 turquoise: "40e0d0", |
|
12431 violet: "ee82ee", |
|
12432 wheat: "f5deb3", |
|
12433 white: "fff", |
|
12434 whitesmoke: "f5f5f5", |
|
12435 yellow: "ff0", |
|
12436 yellowgreen: "9acd32" |
|
12437 }; |
|
12438 |
|
12439 // Make it easy to access colors via `hexNames[hex]` |
|
12440 var hexNames = tinycolor.hexNames = flip(names); |
|
12441 |
|
12442 |
|
12443 // Utilities |
|
12444 // --------- |
|
12445 |
|
12446 // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }` |
|
12447 function flip(o) { |
|
12448 var flipped = { }; |
|
12449 for (var i in o) { |
|
12450 if (o.hasOwnProperty(i)) { |
|
12451 flipped[o[i]] = i; |
|
12452 } |
|
12453 } |
|
12454 return flipped; |
|
12455 } |
|
12456 |
|
12457 // Return a valid alpha value [0,1] with all invalid values being set to 1 |
|
12458 function boundAlpha(a) { |
|
12459 a = parseFloat(a); |
|
12460 |
|
12461 if (isNaN(a) || a < 0 || a > 1) { |
|
12462 a = 1; |
|
12463 } |
|
12464 |
|
12465 return a; |
|
12466 } |
|
12467 |
|
12468 // Take input from [0, n] and return it as [0, 1] |
|
12469 function bound01(n, max) { |
|
12470 if (isOnePointZero(n)) { n = "100%"; } |
|
12471 |
|
12472 var processPercent = isPercentage(n); |
|
12473 n = mathMin(max, mathMax(0, parseFloat(n))); |
|
12474 |
|
12475 // Automatically convert percentage into number |
|
12476 if (processPercent) { |
|
12477 n = parseInt(n * max, 10) / 100; |
|
12478 } |
|
12479 |
|
12480 // Handle floating point rounding errors |
|
12481 if ((Math.abs(n - max) < 0.000001)) { |
|
12482 return 1; |
|
12483 } |
|
12484 |
|
12485 // Convert into [0, 1] range if it isn't already |
|
12486 return (n % max) / parseFloat(max); |
|
12487 } |
|
12488 |
|
12489 // Force a number between 0 and 1 |
|
12490 function clamp01(val) { |
|
12491 return mathMin(1, mathMax(0, val)); |
|
12492 } |
|
12493 |
|
12494 // Parse a base-16 hex value into a base-10 integer |
|
12495 function parseIntFromHex(val) { |
|
12496 return parseInt(val, 16); |
|
12497 } |
|
12498 |
|
12499 // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1 |
|
12500 // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0> |
|
12501 function isOnePointZero(n) { |
|
12502 return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1; |
|
12503 } |
|
12504 |
|
12505 // Check to see if string passed in is a percentage |
|
12506 function isPercentage(n) { |
|
12507 return typeof n === "string" && n.indexOf('%') != -1; |
|
12508 } |
|
12509 |
|
12510 // Force a hex value to have 2 characters |
|
12511 function pad2(c) { |
|
12512 return c.length == 1 ? '0' + c : '' + c; |
|
12513 } |
|
12514 |
|
12515 // Replace a decimal with it's percentage value |
|
12516 function convertToPercentage(n) { |
|
12517 if (n <= 1) { |
|
12518 n = (n * 100) + "%"; |
|
12519 } |
|
12520 |
|
12521 return n; |
|
12522 } |
|
12523 |
|
12524 // Converts a decimal to a hex value |
|
12525 function convertDecimalToHex(d) { |
|
12526 return Math.round(parseFloat(d) * 255).toString(16); |
|
12527 } |
|
12528 // Converts a hex value to a decimal |
|
12529 function convertHexToDecimal(h) { |
|
12530 return (parseIntFromHex(h) / 255); |
|
12531 } |
|
12532 |
|
12533 var matchers = (function() { |
|
12534 |
|
12535 // <http://www.w3.org/TR/css3-values/#integers> |
|
12536 var CSS_INTEGER = "[-\\+]?\\d+%?"; |
|
12537 |
|
12538 // <http://www.w3.org/TR/css3-values/#number-value> |
|
12539 var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?"; |
|
12540 |
|
12541 // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome. |
|
12542 var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")"; |
|
12543 |
|
12544 // Actual matching. |
|
12545 // Parentheses and commas are optional, but not required. |
|
12546 // Whitespace can take the place of commas or opening paren |
|
12547 var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; |
|
12548 var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; |
|
12549 |
|
12550 return { |
|
12551 CSS_UNIT: new RegExp(CSS_UNIT), |
|
12552 rgb: new RegExp("rgb" + PERMISSIVE_MATCH3), |
|
12553 rgba: new RegExp("rgba" + PERMISSIVE_MATCH4), |
|
12554 hsl: new RegExp("hsl" + PERMISSIVE_MATCH3), |
|
12555 hsla: new RegExp("hsla" + PERMISSIVE_MATCH4), |
|
12556 hsv: new RegExp("hsv" + PERMISSIVE_MATCH3), |
|
12557 hsva: new RegExp("hsva" + PERMISSIVE_MATCH4), |
|
12558 hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, |
|
12559 hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, |
|
12560 hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, |
|
12561 hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/ |
|
12562 }; |
|
12563 })(); |
|
12564 |
|
12565 // `isValidCSSUnit` |
|
12566 // Take in a single string / number and check to see if it looks like a CSS unit |
|
12567 // (see `matchers` above for definition). |
|
12568 function isValidCSSUnit(color) { |
|
12569 return !!matchers.CSS_UNIT.exec(color); |
|
12570 } |
|
12571 |
|
12572 // `stringInputToObject` |
|
12573 // Permissive string parsing. Take in a number of formats, and output an object |
|
12574 // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` |
|
12575 function stringInputToObject(color) { |
|
12576 |
|
12577 color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase(); |
|
12578 var named = false; |
|
12579 if (names[color]) { |
|
12580 color = names[color]; |
|
12581 named = true; |
|
12582 } |
|
12583 else if (color == 'transparent') { |
|
12584 return { r: 0, g: 0, b: 0, a: 0, format: "name" }; |
|
12585 } |
|
12586 |
|
12587 // Try to match string input using regular expressions. |
|
12588 // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360] |
|
12589 // Just return an object and let the conversion functions handle that. |
|
12590 // This way the result will be the same whether the tinycolor is initialized with string or object. |
|
12591 var match; |
|
12592 if ((match = matchers.rgb.exec(color))) { |
|
12593 return { r: match[1], g: match[2], b: match[3] }; |
|
12594 } |
|
12595 if ((match = matchers.rgba.exec(color))) { |
|
12596 return { r: match[1], g: match[2], b: match[3], a: match[4] }; |
|
12597 } |
|
12598 if ((match = matchers.hsl.exec(color))) { |
|
12599 return { h: match[1], s: match[2], l: match[3] }; |
|
12600 } |
|
12601 if ((match = matchers.hsla.exec(color))) { |
|
12602 return { h: match[1], s: match[2], l: match[3], a: match[4] }; |
|
12603 } |
|
12604 if ((match = matchers.hsv.exec(color))) { |
|
12605 return { h: match[1], s: match[2], v: match[3] }; |
|
12606 } |
|
12607 if ((match = matchers.hsva.exec(color))) { |
|
12608 return { h: match[1], s: match[2], v: match[3], a: match[4] }; |
|
12609 } |
|
12610 if ((match = matchers.hex8.exec(color))) { |
|
12611 return { |
|
12612 r: parseIntFromHex(match[1]), |
|
12613 g: parseIntFromHex(match[2]), |
|
12614 b: parseIntFromHex(match[3]), |
|
12615 a: convertHexToDecimal(match[4]), |
|
12616 format: named ? "name" : "hex8" |
|
12617 }; |
|
12618 } |
|
12619 if ((match = matchers.hex6.exec(color))) { |
|
12620 return { |
|
12621 r: parseIntFromHex(match[1]), |
|
12622 g: parseIntFromHex(match[2]), |
|
12623 b: parseIntFromHex(match[3]), |
|
12624 format: named ? "name" : "hex" |
|
12625 }; |
|
12626 } |
|
12627 if ((match = matchers.hex4.exec(color))) { |
|
12628 return { |
|
12629 r: parseIntFromHex(match[1] + '' + match[1]), |
|
12630 g: parseIntFromHex(match[2] + '' + match[2]), |
|
12631 b: parseIntFromHex(match[3] + '' + match[3]), |
|
12632 a: convertHexToDecimal(match[4] + '' + match[4]), |
|
12633 format: named ? "name" : "hex8" |
|
12634 }; |
|
12635 } |
|
12636 if ((match = matchers.hex3.exec(color))) { |
|
12637 return { |
|
12638 r: parseIntFromHex(match[1] + '' + match[1]), |
|
12639 g: parseIntFromHex(match[2] + '' + match[2]), |
|
12640 b: parseIntFromHex(match[3] + '' + match[3]), |
|
12641 format: named ? "name" : "hex" |
|
12642 }; |
|
12643 } |
|
12644 |
|
12645 return false; |
|
12646 } |
|
12647 |
|
12648 function validateWCAG2Parms(parms) { |
|
12649 // return valid WCAG2 parms for isReadable. |
|
12650 // If input parms are invalid, return {"level":"AA", "size":"small"} |
|
12651 var level, size; |
|
12652 parms = parms || {"level":"AA", "size":"small"}; |
|
12653 level = (parms.level || "AA").toUpperCase(); |
|
12654 size = (parms.size || "small").toLowerCase(); |
|
12655 if (level !== "AA" && level !== "AAA") { |
|
12656 level = "AA"; |
|
12657 } |
|
12658 if (size !== "small" && size !== "large") { |
|
12659 size = "small"; |
|
12660 } |
|
12661 return {"level":level, "size":size}; |
|
12662 } |
|
12663 |
|
12664 // Node: Export function |
|
12665 if ( true && module.exports) { |
|
12666 module.exports = tinycolor; |
|
12667 } |
|
12668 // AMD/requirejs: Define the module |
|
12669 else if (true) { |
|
12670 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {return tinycolor;}).call(exports, __webpack_require__, exports, module), |
|
12671 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
|
12672 } |
|
12673 // Browser: Expose to window |
|
12674 else {} |
|
12675 |
|
12676 })(Math); |
|
12677 |
|
12678 |
|
12679 /***/ }), |
|
12680 |
|
12681 /***/ 5: |
|
12682 /***/ (function(module, exports) { |
|
12683 |
|
12684 (function() { module.exports = this["wp"]["data"]; }()); |
|
12685 |
|
12686 /***/ }), |
|
12687 |
|
12688 /***/ 57: |
|
12689 /***/ (function(module, exports) { |
|
12690 |
|
12691 (function() { module.exports = this["wp"]["htmlEntities"]; }()); |
|
12692 |
|
12693 /***/ }), |
|
12694 |
|
12695 /***/ 6: |
|
12696 /***/ (function(module, exports) { |
|
12697 |
|
12698 (function() { module.exports = this["wp"]["compose"]; }()); |
|
12699 |
|
12700 /***/ }), |
|
12701 |
|
12702 /***/ 65: |
|
12703 /***/ (function(module, exports, __webpack_require__) { |
|
12704 |
|
12705 var rng = __webpack_require__(87); |
|
12706 var bytesToUuid = __webpack_require__(88); |
|
12707 |
|
12708 function v4(options, buf, offset) { |
|
12709 var i = buf && offset || 0; |
|
12710 |
|
12711 if (typeof(options) == 'string') { |
|
12712 buf = options === 'binary' ? new Array(16) : null; |
|
12713 options = null; |
|
12714 } |
|
12715 options = options || {}; |
|
12716 |
|
12717 var rnds = options.random || (options.rng || rng)(); |
|
12718 |
|
12719 // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` |
|
12720 rnds[6] = (rnds[6] & 0x0f) | 0x40; |
|
12721 rnds[8] = (rnds[8] & 0x3f) | 0x80; |
|
12722 |
|
12723 // Copy bytes to buffer, if provided |
|
12724 if (buf) { |
|
12725 for (var ii = 0; ii < 16; ++ii) { |
|
12726 buf[i + ii] = rnds[ii]; |
|
12727 } |
|
12728 } |
|
12729 |
|
12730 return buf || bytesToUuid(rnds); |
|
12731 } |
|
12732 |
|
12733 module.exports = v4; |
|
12734 |
|
12735 |
|
12736 /***/ }), |
|
12737 |
|
12738 /***/ 66: |
|
12739 /***/ (function(module, exports) { |
|
12740 |
|
12741 (function() { module.exports = this["wp"]["autop"]; }()); |
|
12742 |
|
12743 /***/ }), |
|
12744 |
|
12745 /***/ 7: |
|
12746 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
12747 |
|
12748 "use strict"; |
|
12749 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectSpread; }); |
|
12750 /* harmony import */ var _defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15); |
|
12751 |
|
12752 function _objectSpread(target) { |
|
12753 for (var i = 1; i < arguments.length; i++) { |
|
12754 var source = arguments[i] != null ? arguments[i] : {}; |
|
12755 var ownKeys = Object.keys(source); |
|
12756 |
|
12757 if (typeof Object.getOwnPropertySymbols === 'function') { |
|
12758 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { |
|
12759 return Object.getOwnPropertyDescriptor(source, sym).enumerable; |
|
12760 })); |
|
12761 } |
|
12762 |
|
12763 ownKeys.forEach(function (key) { |
|
12764 Object(_defineProperty__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(target, key, source[key]); |
|
12765 }); |
|
12766 } |
|
12767 |
|
12768 return target; |
|
12769 } |
|
12770 |
|
12771 /***/ }), |
|
12772 |
|
12773 /***/ 87: |
|
12774 /***/ (function(module, exports) { |
|
12775 |
|
12776 // Unique ID creation requires a high quality random # generator. In the |
|
12777 // browser this is a little complicated due to unknown quality of Math.random() |
|
12778 // and inconsistent support for the `crypto` API. We do the best we can via |
|
12779 // feature-detection |
|
12780 |
|
12781 // getRandomValues needs to be invoked in a context where "this" is a Crypto |
|
12782 // implementation. Also, find the complete implementation of crypto on IE11. |
|
12783 var getRandomValues = (typeof(crypto) != 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto)) || |
|
12784 (typeof(msCrypto) != 'undefined' && typeof window.msCrypto.getRandomValues == 'function' && msCrypto.getRandomValues.bind(msCrypto)); |
|
12785 |
|
12786 if (getRandomValues) { |
|
12787 // WHATWG crypto RNG - http://wiki.whatwg.org/wiki/Crypto |
|
12788 var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef |
|
12789 |
|
12790 module.exports = function whatwgRNG() { |
|
12791 getRandomValues(rnds8); |
|
12792 return rnds8; |
|
12793 }; |
|
12794 } else { |
|
12795 // Math.random()-based (RNG) |
|
12796 // |
|
12797 // If all else fails, use Math.random(). It's fast, but is of unspecified |
|
12798 // quality. |
|
12799 var rnds = new Array(16); |
|
12800 |
|
12801 module.exports = function mathRNG() { |
|
12802 for (var i = 0, r; i < 16; i++) { |
|
12803 if ((i & 0x03) === 0) r = Math.random() * 0x100000000; |
|
12804 rnds[i] = r >>> ((i & 0x03) << 3) & 0xff; |
|
12805 } |
|
12806 |
|
12807 return rnds; |
|
12808 }; |
|
12809 } |
|
12810 |
|
12811 |
|
12812 /***/ }), |
|
12813 |
|
12814 /***/ 88: |
|
12815 /***/ (function(module, exports) { |
|
12816 |
|
12817 /** |
|
12818 * Convert array of 16 byte values to UUID string format of the form: |
|
12819 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX |
|
12820 */ |
|
12821 var byteToHex = []; |
|
12822 for (var i = 0; i < 256; ++i) { |
|
12823 byteToHex[i] = (i + 0x100).toString(16).substr(1); |
|
12824 } |
|
12825 |
|
12826 function bytesToUuid(buf, offset) { |
|
12827 var i = offset || 0; |
|
12828 var bth = byteToHex; |
|
12829 // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4 |
|
12830 return ([bth[buf[i++]], bth[buf[i++]], |
|
12831 bth[buf[i++]], bth[buf[i++]], '-', |
|
12832 bth[buf[i++]], bth[buf[i++]], '-', |
|
12833 bth[buf[i++]], bth[buf[i++]], '-', |
|
12834 bth[buf[i++]], bth[buf[i++]], '-', |
|
12835 bth[buf[i++]], bth[buf[i++]], |
|
12836 bth[buf[i++]], bth[buf[i++]], |
|
12837 bth[buf[i++]], bth[buf[i++]]]).join(''); |
|
12838 } |
|
12839 |
|
12840 module.exports = bytesToUuid; |
|
12841 |
|
12842 |
|
12843 /***/ }), |
|
12844 |
|
12845 /***/ 9: |
|
12846 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
12847 |
|
12848 "use strict"; |
|
12849 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; }); |
|
12850 function _defineProperties(target, props) { |
|
12851 for (var i = 0; i < props.length; i++) { |
|
12852 var descriptor = props[i]; |
|
12853 descriptor.enumerable = descriptor.enumerable || false; |
|
12854 descriptor.configurable = true; |
|
12855 if ("value" in descriptor) descriptor.writable = true; |
|
12856 Object.defineProperty(target, descriptor.key, descriptor); |
|
12857 } |
|
12858 } |
|
12859 |
|
12860 function _createClass(Constructor, protoProps, staticProps) { |
|
12861 if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
|
12862 if (staticProps) _defineProperties(Constructor, staticProps); |
|
12863 return Constructor; |
|
12864 } |
|
12865 |
|
12866 /***/ }) |
|
12867 |
|
12868 /******/ }); |