Skip to content

Commit

Permalink
fix: Disallow only whitespace between markdown shortcuts delimiters (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rfgamaral authored Mar 27, 2024
1 parent 45e70c8 commit aa029fe
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions packages/extension-bold/src/bold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ declare module '@tiptap/core' {
}
}

export const starInputRegex = /(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))$/
export const starPasteRegex = /(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))/g
export const underscoreInputRegex = /(?:^|\s)((?:__)((?:[^__]+))(?:__))$/
export const underscorePasteRegex = /(?:^|\s)((?:__)((?:[^__]+))(?:__))/g
export const starInputRegex = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/
export const starPasteRegex = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g
export const underscoreInputRegex = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/
export const underscorePasteRegex = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g

export const Bold = Mark.create<BoldOptions>({
name: 'bold',
Expand Down
4 changes: 2 additions & 2 deletions packages/extension-code/src/code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ declare module '@tiptap/core' {
}
}

export const inputRegex = /(?:^|\s)((?:`)((?:[^`]+))(?:`))$/
export const pasteRegex = /(?:^|\s)((?:`)((?:[^`]+))(?:`))/g
export const inputRegex = /(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/
export const pasteRegex = /(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g

export const Code = Mark.create<CodeOptions>({
name: 'code',
Expand Down
4 changes: 2 additions & 2 deletions packages/extension-highlight/src/highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ declare module '@tiptap/core' {
}
}

export const inputRegex = /(?:^|\s)((?:==)((?:[^~=]+))(?:==))$/
export const pasteRegex = /(?:^|\s)((?:==)((?:[^~=]+))(?:==))/g
export const inputRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/
export const pasteRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g

export const Highlight = Mark.create<HighlightOptions>({
name: 'highlight',
Expand Down
8 changes: 4 additions & 4 deletions packages/extension-italic/src/italic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ declare module '@tiptap/core' {
}
}

export const starInputRegex = /(?:^|\s)((?:\*)((?:[^*]+))(?:\*))$/
export const starPasteRegex = /(?:^|\s)((?:\*)((?:[^*]+))(?:\*))/g
export const underscoreInputRegex = /(?:^|\s)((?:_)((?:[^_]+))(?:_))$/
export const underscorePasteRegex = /(?:^|\s)((?:_)((?:[^_]+))(?:_))/g
export const starInputRegex = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/
export const starPasteRegex = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g
export const underscoreInputRegex = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/
export const underscorePasteRegex = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g

export const Italic = Mark.create<ItalicOptions>({
name: 'italic',
Expand Down
4 changes: 2 additions & 2 deletions packages/extension-strike/src/strike.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ declare module '@tiptap/core' {
}
}

export const inputRegex = /(?:^|\s)((?:~~)((?:[^~]+))(?:~~))$/
export const pasteRegex = /(?:^|\s)((?:~~)((?:[^~]+))(?:~~))/g
export const inputRegex = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/
export const pasteRegex = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g

export const Strike = Mark.create<StrikeOptions>({
name: 'strike',
Expand Down

0 comments on commit aa029fe

Please sign in to comment.