Skip to content

Commit

Permalink
add ShortcodeType to ease maintaining
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeybinns committed Apr 6, 2024
1 parent 3315605 commit 677861b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/shortcode/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type WPShortcodeAttrs = {
numeric: string[];
};

type ShortcodeType = 'single' | 'self-closing' | 'closed';

/**
* Shortcode object.
*
Expand Down Expand Up @@ -49,7 +51,7 @@ type WPShortcodeOptions = {
/**
* Shortcode type.
*/
type: 'single' | 'self-closing' | 'closed';
type: ShortcodeType;
};

/**
Expand Down Expand Up @@ -279,7 +281,7 @@ export const attrs = memize( ( text: string ): WPShortcodeAttrs => {
* @return {WPShortcode} Shortcode instance.
*/
export function fromMatch( match: RegExpExecArray ): WPShortcode {
let type: 'single' | 'self-closing' | 'closed';
let type: ShortcodeType;

if ( match[ 4 ] ) {
type = 'self-closing';
Expand Down Expand Up @@ -325,7 +327,7 @@ function isWPShortcodeAttrsObject(
class shortcode {
tag?: string;
attrs: WPShortcodeAttrs;
type?: 'single' | 'self-closing' | 'closed';
type?: ShortcodeType;
content?: string;

constructor( options: WPShortcodeOptions ) {
Expand Down

0 comments on commit 677861b

Please sign in to comment.