@wordpress/shortcode
Version:
Shortcode module for WordPress.
8 lines (7 loc) • 2.69 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../src/types.ts"],
"sourcesContent": ["/**\n * Shortcode attributes object.\n */\nexport type ShortcodeAttrs = {\n\t/**\n\t * Object with named attributes.\n\t */\n\tnamed: Record< string, string | undefined >;\n\n\t/**\n\t * Array with numeric attributes.\n\t */\n\tnumeric: string[];\n};\n\n/**\n * Shortcode object.\n */\nexport interface Shortcode {\n\t/**\n\t * Shortcode tag.\n\t */\n\ttag: string;\n\n\t/**\n\t * Shortcode attributes.\n\t */\n\tattrs: ShortcodeAttrs;\n\n\t/**\n\t * Shortcode content.\n\t */\n\tcontent?: string;\n\n\t/**\n\t * Shortcode type: `self-closing`, `closed`, or `single`.\n\t */\n\ttype?: 'self-closing' | 'closed' | 'single';\n}\n\n/**\n * Shortcode match result.\n */\nexport type ShortcodeMatch = {\n\t/**\n\t * Index the shortcode is found at.\n\t */\n\tindex: number;\n\n\t/**\n\t * Matched content.\n\t */\n\tcontent: string;\n\n\t/**\n\t * Shortcode instance of the match.\n\t */\n\tshortcode: Shortcode;\n};\n\n/**\n * Shortcode options for creating a new shortcode.\n */\nexport interface ShortcodeOptions {\n\t/**\n\t * Shortcode tag.\n\t */\n\ttag: string;\n\n\t/**\n\t * Shortcode attributes.\n\t */\n\tattrs?: Partial< ShortcodeAttrs > | string;\n\n\t/**\n\t * Shortcode content.\n\t */\n\tcontent?: string;\n\n\t/**\n\t * Shortcode type: `self-closing`, `closed`, or `single`.\n\t */\n\ttype?: 'self-closing' | 'closed' | 'single';\n}\n\n/**\n * Match array from regexp.exec() or arguments from replace callback.\n */\nexport type Match =\n\t| NonNullable< ReturnType< RegExp[ 'exec' ] > >\n\t| IArguments\n\t| ArrayLike< string >;\n\n/**\n * Callback function for replace operations.\n */\nexport type ReplaceCallback = ( shortcode: Shortcode ) => string;\n\n/**\n * Shortcode instance returned by the constructor.\n */\nexport interface ShortcodeInstance extends Shortcode {\n\t/**\n\t * Transform the shortcode into a string.\n\t *\n\t * @return String representation of the shortcode.\n\t */\n\tstring: () => string;\n\n\t/**\n\t * Get a shortcode attribute.\n\t *\n\t * Automatically detects whether `attr` is named or numeric and routes it\n\t * accordingly.\n\t *\n\t * @param attr Attribute key.\n\t *\n\t * @return Attribute value.\n\t */\n\tget: ( attr: string | number ) => string | undefined;\n\n\t/**\n\t * Set a shortcode attribute.\n\t *\n\t * Automatically detects whether `attr` is named or numeric and routes it\n\t * accordingly.\n\t *\n\t * @param attr Attribute key.\n\t * @param value Attribute value.\n\t *\n\t * @return Shortcode instance.\n\t */\n\tset: ( attr: string | number, value: string ) => ShortcodeInstance;\n}\n"],
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
"names": []
}