80 /******/ // __webpack_public_path__ |
80 /******/ // __webpack_public_path__ |
81 /******/ __webpack_require__.p = ""; |
81 /******/ __webpack_require__.p = ""; |
82 /******/ |
82 /******/ |
83 /******/ |
83 /******/ |
84 /******/ // Load entry module and return exports |
84 /******/ // Load entry module and return exports |
85 /******/ return __webpack_require__(__webpack_require__.s = 431); |
85 /******/ return __webpack_require__(__webpack_require__.s = "/2FX"); |
86 /******/ }) |
86 /******/ }) |
87 /************************************************************************/ |
87 /************************************************************************/ |
88 /******/ ({ |
88 /******/ ({ |
89 |
89 |
90 /***/ 2: |
90 /***/ "/2FX": |
91 /***/ (function(module, exports) { |
|
92 |
|
93 (function() { module.exports = this["lodash"]; }()); |
|
94 |
|
95 /***/ }), |
|
96 |
|
97 /***/ 431: |
|
98 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
91 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
99 |
92 |
100 "use strict"; |
93 "use strict"; |
101 __webpack_require__.r(__webpack_exports__); |
94 __webpack_require__.r(__webpack_exports__); |
102 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "next", function() { return next; }); |
95 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "next", function() { return next; }); |
103 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "replace", function() { return replace; }); |
96 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "replace", function() { return replace; }); |
104 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "string", function() { return string; }); |
97 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "string", function() { return string; }); |
105 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "regexp", function() { return regexp; }); |
98 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "regexp", function() { return regexp; }); |
106 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "attrs", function() { return attrs; }); |
99 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "attrs", function() { return attrs; }); |
107 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromMatch", function() { return fromMatch; }); |
100 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromMatch", function() { return fromMatch; }); |
108 /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); |
101 /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("YLtl"); |
109 /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_0__); |
102 /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_0__); |
110 /* harmony import */ var memize__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(60); |
103 /* harmony import */ var memize__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("4eJC"); |
111 /* harmony import */ var memize__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(memize__WEBPACK_IMPORTED_MODULE_1__); |
104 /* harmony import */ var memize__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(memize__WEBPACK_IMPORTED_MODULE_1__); |
112 /** |
105 /** |
113 * External dependencies |
106 * External dependencies |
114 */ |
107 */ |
115 |
108 |
151 * @param {number} index Index to start search from. |
144 * @param {number} index Index to start search from. |
152 * |
145 * |
153 * @return {?WPShortcodeMatch} Matched information. |
146 * @return {?WPShortcodeMatch} Matched information. |
154 */ |
147 */ |
155 |
148 |
156 function next(tag, text) { |
149 function next(tag, text, index = 0) { |
157 var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; |
150 const re = regexp(tag); |
158 var re = regexp(tag); |
|
159 re.lastIndex = index; |
151 re.lastIndex = index; |
160 var match = re.exec(text); |
152 const match = re.exec(text); |
161 |
153 |
162 if (!match) { |
154 if (!match) { |
163 return; |
155 return; |
164 } // If we matched an escaped shortcode, try again. |
156 } // If we matched an escaped shortcode, try again. |
165 |
157 |
166 |
158 |
167 if ('[' === match[1] && ']' === match[7]) { |
159 if ('[' === match[1] && ']' === match[7]) { |
168 return next(tag, text, re.lastIndex); |
160 return next(tag, text, re.lastIndex); |
169 } |
161 } |
170 |
162 |
171 var result = { |
163 const result = { |
172 index: match.index, |
164 index: match.index, |
173 content: match[0], |
165 content: match[0], |
174 shortcode: fromMatch(match) |
166 shortcode: fromMatch(match) |
175 }; // If we matched a leading `[`, strip it from the match and increment the |
167 }; // If we matched a leading `[`, strip it from the match and increment the |
176 // index accordingly. |
168 // index accordingly. |
205 if (left === '[' && right === ']') { |
197 if (left === '[' && right === ']') { |
206 return match; |
198 return match; |
207 } // Create the match object and pass it through the callback. |
199 } // Create the match object and pass it through the callback. |
208 |
200 |
209 |
201 |
210 var result = callback(fromMatch(arguments)); // Make sure to return any of the extra brackets if they weren't used to |
202 const result = callback(fromMatch(arguments)); // Make sure to return any of the extra brackets if they weren't used to |
211 // escape the shortcode. |
203 // escape the shortcode. |
212 |
204 |
213 return result ? left + result + right : match; |
205 return result || result === '' ? left + result + right : match; |
214 }); |
206 }); |
215 } |
207 } |
216 /** |
208 /** |
217 * Generate a string from shortcode parameters. |
209 * Generate a string from shortcode parameters. |
218 * |
210 * |
270 * @param {string} text Serialised shortcode attributes. |
262 * @param {string} text Serialised shortcode attributes. |
271 * |
263 * |
272 * @return {WPShortcodeAttrs} Parsed shortcode attributes. |
264 * @return {WPShortcodeAttrs} Parsed shortcode attributes. |
273 */ |
265 */ |
274 |
266 |
275 var attrs = memize__WEBPACK_IMPORTED_MODULE_1___default()(function (text) { |
267 const attrs = memize__WEBPACK_IMPORTED_MODULE_1___default()(text => { |
276 var named = {}; |
268 const named = {}; |
277 var numeric = []; // This regular expression is reused from `shortcode_parse_atts()` in |
269 const numeric = []; // This regular expression is reused from `shortcode_parse_atts()` in |
278 // `wp-includes/shortcodes.php`. |
270 // `wp-includes/shortcodes.php`. |
279 // |
271 // |
280 // Capture groups: |
272 // Capture groups: |
281 // |
273 // |
282 // 1. An attribute name, that corresponds to... |
274 // 1. An attribute name, that corresponds to... |
287 // 6. an unquoted value. |
279 // 6. an unquoted value. |
288 // 7. A numeric attribute in double quotes. |
280 // 7. A numeric attribute in double quotes. |
289 // 8. A numeric attribute in single quotes. |
281 // 8. A numeric attribute in single quotes. |
290 // 9. An unquoted numeric attribute. |
282 // 9. An unquoted numeric attribute. |
291 |
283 |
292 var pattern = /([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*'([^']*)'(?:\s|$)|([\w-]+)\s*=\s*([^\s'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|'([^']*)'(?:\s|$)|(\S+)(?:\s|$)/g; // Map zero-width spaces to actual spaces. |
284 const pattern = /([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*'([^']*)'(?:\s|$)|([\w-]+)\s*=\s*([^\s'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|'([^']*)'(?:\s|$)|(\S+)(?:\s|$)/g; // Map zero-width spaces to actual spaces. |
293 |
285 |
294 text = text.replace(/[\u00a0\u200b]/g, ' '); |
286 text = text.replace(/[\u00a0\u200b]/g, ' '); |
295 var match; // Match and normalize attributes. |
287 let match; // Match and normalize attributes. |
296 |
288 |
297 while (match = pattern.exec(text)) { |
289 while (match = pattern.exec(text)) { |
298 if (match[1]) { |
290 if (match[1]) { |
299 named[match[1].toLowerCase()] = match[2]; |
291 named[match[1].toLowerCase()] = match[2]; |
300 } else if (match[3]) { |
292 } else if (match[3]) { |
356 * @param {Object} options Options as described. |
348 * @param {Object} options Options as described. |
357 * |
349 * |
358 * @return {WPShortcode} Shortcode instance. |
350 * @return {WPShortcode} Shortcode instance. |
359 */ |
351 */ |
360 |
352 |
361 var shortcode = Object(lodash__WEBPACK_IMPORTED_MODULE_0__["extend"])(function (options) { |
353 const shortcode = Object(lodash__WEBPACK_IMPORTED_MODULE_0__["extend"])(function (options) { |
362 var _this = this; |
|
363 |
|
364 Object(lodash__WEBPACK_IMPORTED_MODULE_0__["extend"])(this, Object(lodash__WEBPACK_IMPORTED_MODULE_0__["pick"])(options || {}, 'tag', 'attrs', 'type', 'content')); |
354 Object(lodash__WEBPACK_IMPORTED_MODULE_0__["extend"])(this, Object(lodash__WEBPACK_IMPORTED_MODULE_0__["pick"])(options || {}, 'tag', 'attrs', 'type', 'content')); |
365 var attributes = this.attrs; // Ensure we have a correctly formatted `attrs` object. |
355 const attributes = this.attrs; // Ensure we have a correctly formatted `attrs` object. |
366 |
356 |
367 this.attrs = { |
357 this.attrs = { |
368 named: {}, |
358 named: {}, |
369 numeric: [] |
359 numeric: [] |
370 }; |
360 }; |
377 if (Object(lodash__WEBPACK_IMPORTED_MODULE_0__["isString"])(attributes)) { |
367 if (Object(lodash__WEBPACK_IMPORTED_MODULE_0__["isString"])(attributes)) { |
378 this.attrs = attrs(attributes); // Identify a correctly formatted `attrs` object. |
368 this.attrs = attrs(attributes); // Identify a correctly formatted `attrs` object. |
379 } else if (Object(lodash__WEBPACK_IMPORTED_MODULE_0__["isEqual"])(Object.keys(attributes), ['named', 'numeric'])) { |
369 } else if (Object(lodash__WEBPACK_IMPORTED_MODULE_0__["isEqual"])(Object.keys(attributes), ['named', 'numeric'])) { |
380 this.attrs = attributes; // Handle a flat object of attributes. |
370 this.attrs = attributes; // Handle a flat object of attributes. |
381 } else { |
371 } else { |
382 Object(lodash__WEBPACK_IMPORTED_MODULE_0__["forEach"])(attributes, function (value, key) { |
372 Object(lodash__WEBPACK_IMPORTED_MODULE_0__["forEach"])(attributes, (value, key) => { |
383 _this.set(key, value); |
373 this.set(key, value); |
384 }); |
374 }); |
385 } |
375 } |
386 }, { |
376 }, { |
387 next: next, |
377 next, |
388 replace: replace, |
378 replace, |
389 string: string, |
379 string, |
390 regexp: regexp, |
380 regexp, |
391 attrs: attrs, |
381 attrs, |
392 fromMatch: fromMatch |
382 fromMatch |
393 }); |
383 }); |
394 Object(lodash__WEBPACK_IMPORTED_MODULE_0__["extend"])(shortcode.prototype, { |
384 Object(lodash__WEBPACK_IMPORTED_MODULE_0__["extend"])(shortcode.prototype, { |
395 /** |
385 /** |
396 * Get a shortcode attribute. |
386 * Get a shortcode attribute. |
397 * |
387 * |
415 * @param {(number|string)} attr Attribute key. |
405 * @param {(number|string)} attr Attribute key. |
416 * @param {string} value Attribute value. |
406 * @param {string} value Attribute value. |
417 * |
407 * |
418 * @return {WPShortcode} Shortcode instance. |
408 * @return {WPShortcode} Shortcode instance. |
419 */ |
409 */ |
420 set: function set(attr, value) { |
410 set(attr, value) { |
421 this.attrs[Object(lodash__WEBPACK_IMPORTED_MODULE_0__["isNumber"])(attr) ? 'numeric' : 'named'][attr] = value; |
411 this.attrs[Object(lodash__WEBPACK_IMPORTED_MODULE_0__["isNumber"])(attr) ? 'numeric' : 'named'][attr] = value; |
422 return this; |
412 return this; |
423 }, |
413 }, |
424 |
414 |
425 /** |
415 /** |
426 * Transform the shortcode into a string. |
416 * Transform the shortcode into a string. |
427 * |
417 * |
428 * @return {string} String representation of the shortcode. |
418 * @return {string} String representation of the shortcode. |
429 */ |
419 */ |
430 string: function string() { |
420 string() { |
431 var text = '[' + this.tag; |
421 let text = '[' + this.tag; |
432 Object(lodash__WEBPACK_IMPORTED_MODULE_0__["forEach"])(this.attrs.numeric, function (value) { |
422 Object(lodash__WEBPACK_IMPORTED_MODULE_0__["forEach"])(this.attrs.numeric, value => { |
433 if (/\s/.test(value)) { |
423 if (/\s/.test(value)) { |
434 text += ' "' + value + '"'; |
424 text += ' "' + value + '"'; |
435 } else { |
425 } else { |
436 text += ' ' + value; |
426 text += ' ' + value; |
437 } |
427 } |
438 }); |
428 }); |
439 Object(lodash__WEBPACK_IMPORTED_MODULE_0__["forEach"])(this.attrs.named, function (value, name) { |
429 Object(lodash__WEBPACK_IMPORTED_MODULE_0__["forEach"])(this.attrs.named, (value, name) => { |
440 text += ' ' + name + '="' + value + '"'; |
430 text += ' ' + name + '="' + value + '"'; |
441 }); // If the tag is marked as `single` or `self-closing`, close the tag and |
431 }); // If the tag is marked as `single` or `self-closing`, close the tag and |
442 // ignore any additional content. |
432 // ignore any additional content. |
443 |
433 |
444 if ('single' === this.type) { |
434 if ('single' === this.type) { |