Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Disallow only whitespace between markdown shortcuts delimiters #4866

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading