29 "default": () => (/* binding */ build_module) |
29 "default": () => (/* binding */ build_module) |
30 }); |
30 }); |
31 |
31 |
32 // UNUSED EXPORTS: attrs, fromMatch, next, regexp, replace, string |
32 // UNUSED EXPORTS: attrs, fromMatch, next, regexp, replace, string |
33 |
33 |
34 ;// CONCATENATED MODULE: ./node_modules/memize/dist/index.js |
34 ;// ./node_modules/memize/dist/index.js |
35 /** |
35 /** |
36 * Memize options object. |
36 * Memize options object. |
37 * |
37 * |
38 * @typedef MemizeOptions |
38 * @typedef MemizeOptions |
39 * |
39 * |
191 return memoized; |
191 return memoized; |
192 } |
192 } |
193 |
193 |
194 |
194 |
195 |
195 |
196 ;// CONCATENATED MODULE: ./node_modules/@wordpress/shortcode/build-module/index.js |
196 ;// ./node_modules/@wordpress/shortcode/build-module/index.js |
197 /** |
197 /** |
198 * External dependencies |
198 * External dependencies |
199 */ |
199 */ |
200 |
200 |
201 |
201 |
202 /** |
|
203 * Shortcode attributes object. |
|
204 * |
|
205 * @typedef {Object} WPShortcodeAttrs |
|
206 * |
|
207 * @property {Object} named Object with named attributes. |
|
208 * @property {Array} numeric Array with numeric attributes. |
|
209 */ |
|
210 |
|
211 /** |
|
212 * Shortcode object. |
|
213 * |
|
214 * @typedef {Object} WPShortcode |
|
215 * |
|
216 * @property {string} tag Shortcode tag. |
|
217 * @property {WPShortcodeAttrs} attrs Shortcode attributes. |
|
218 * @property {string} content Shortcode content. |
|
219 * @property {string} type Shortcode type: `self-closing`, |
|
220 * `closed`, or `single`. |
|
221 */ |
|
222 |
|
223 /** |
|
224 * @typedef {Object} WPShortcodeMatch |
|
225 * |
|
226 * @property {number} index Index the shortcode is found at. |
|
227 * @property {string} content Matched content. |
|
228 * @property {WPShortcode} shortcode Shortcode instance of the match. |
|
229 */ |
|
230 |
202 |
231 /** |
203 /** |
232 * Find the next matching shortcode. |
204 * Find the next matching shortcode. |
233 * |
205 * |
234 * @param {string} tag Shortcode tag. |
206 * @param {string} tag Shortcode tag. |
235 * @param {string} text Text to search. |
207 * @param {string} text Text to search. |
236 * @param {number} index Index to start search from. |
208 * @param {number} index Index to start search from. |
237 * |
209 * |
238 * @return {WPShortcodeMatch | undefined} Matched information. |
210 * @return {import('./types').ShortcodeMatch | undefined} Matched information. |
239 */ |
211 */ |
240 function next(tag, text, index = 0) { |
212 function next(tag, text, index = 0) { |
241 const re = regexp(tag); |
213 const re = regexp(tag); |
242 re.lastIndex = index; |
214 re.lastIndex = index; |
243 const match = re.exec(text); |
215 const match = re.exec(text); |
270 } |
242 } |
271 |
243 |
272 /** |
244 /** |
273 * Replace matching shortcodes in a block of text. |
245 * Replace matching shortcodes in a block of text. |
274 * |
246 * |
275 * @param {string} tag Shortcode tag. |
247 * @param {string} tag Shortcode tag. |
276 * @param {string} text Text to search. |
248 * @param {string} text Text to search. |
277 * @param {Function} callback Function to process the match and return |
249 * @param {import('./types').ReplaceCallback} callback Function to process the match and return |
278 * replacement string. |
250 * replacement string. |
279 * |
251 * |
280 * @return {string} Text with shortcodes replaced. |
252 * @return {string} Text with shortcodes replaced. |
281 */ |
253 */ |
282 function replace(tag, text, callback) { |
254 function replace(tag, text, callback) { |
283 return text.replace(regexp(tag), function (match, left, $3, attrs, slash, content, closing, right) { |
255 return text.replace(regexp(tag), function (match, left, $3, attrs, slash, content, closing, right) { |
405 * |
377 * |
406 * Accepts a `match` object from calling `regexp.exec()` on a `RegExp` generated |
378 * Accepts a `match` object from calling `regexp.exec()` on a `RegExp` generated |
407 * by `regexp()`. `match` can also be set to the `arguments` from a callback |
379 * by `regexp()`. `match` can also be set to the `arguments` from a callback |
408 * passed to `regexp.replace()`. |
380 * passed to `regexp.replace()`. |
409 * |
381 * |
410 * @param {Array} match Match array. |
382 * @param {import('./types').Match} match Match array. |
411 * |
383 * |
412 * @return {WPShortcode} Shortcode instance. |
384 * @return {InstanceType<import('./types').shortcode>} Shortcode instance. |
413 */ |
385 */ |
414 function fromMatch(match) { |
386 function fromMatch(match) { |
415 let type; |
387 let type; |
416 if (match[4]) { |
388 if (match[4]) { |
417 type = 'self-closing'; |
389 type = 'self-closing'; |
434 * To access a raw representation of a shortcode, pass an `options` object, |
406 * To access a raw representation of a shortcode, pass an `options` object, |
435 * containing a `tag` string, a string or object of `attrs`, a string indicating |
407 * containing a `tag` string, a string or object of `attrs`, a string indicating |
436 * the `type` of the shortcode ('single', 'self-closing', or 'closed'), and a |
408 * the `type` of the shortcode ('single', 'self-closing', or 'closed'), and a |
437 * `content` string. |
409 * `content` string. |
438 * |
410 * |
439 * @param {Object} options Options as described. |
411 * @type {import('./types').shortcode} Shortcode instance. |
440 * |
|
441 * @return {WPShortcode} Shortcode instance. |
|
442 */ |
412 */ |
443 const shortcode = Object.assign(function (options) { |
413 const shortcode = Object.assign(function (options) { |
444 const { |
414 const { |
445 tag, |
415 tag, |
446 attrs: attributes, |
416 attrs: attributes, |