fix: prevent named capturing groups, fix #2128
This commit is contained in:
@@ -38,8 +38,8 @@ declare module '@tiptap/core' {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const backtickInputRegex = /^```(?<language>[a-z]*)?[\s\n]$/
|
export const backtickInputRegex = /^```([a-z]+)?[\s\n]$/
|
||||||
export const tildeInputRegex = /^~~~(?<language>[a-z]*)?[\s\n]$/
|
export const tildeInputRegex = /^~~~([a-z]+)?[\s\n]$/
|
||||||
|
|
||||||
export const CodeBlock = Node.create<CodeBlockOptions>({
|
export const CodeBlock = Node.create<CodeBlockOptions>({
|
||||||
name: 'codeBlock',
|
name: 'codeBlock',
|
||||||
@@ -212,12 +212,16 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
|
|||||||
textblockTypeInputRule({
|
textblockTypeInputRule({
|
||||||
find: backtickInputRegex,
|
find: backtickInputRegex,
|
||||||
type: this.type,
|
type: this.type,
|
||||||
getAttributes: ({ groups }) => groups,
|
getAttributes: match => ({
|
||||||
|
language: match[1],
|
||||||
|
}),
|
||||||
}),
|
}),
|
||||||
textblockTypeInputRule({
|
textblockTypeInputRule({
|
||||||
find: tildeInputRegex,
|
find: tildeInputRegex,
|
||||||
type: this.type,
|
type: this.type,
|
||||||
getAttributes: ({ groups }) => groups,
|
getAttributes: match => ({
|
||||||
|
language: match[1],
|
||||||
|
}),
|
||||||
}),
|
}),
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user