forked from farhoodlabs/paperclip
Allow custom markdown mention links in editor
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -68,6 +68,12 @@ function escapeRegExp(value: string): string {
|
|||||||
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isSafeMarkdownLinkUrl(url: string): boolean {
|
||||||
|
const trimmed = url.trim();
|
||||||
|
if (!trimmed) return true;
|
||||||
|
return !/^(javascript|data|vbscript):/i.test(trimmed);
|
||||||
|
}
|
||||||
|
|
||||||
/* ---- Mention detection helpers ---- */
|
/* ---- Mention detection helpers ---- */
|
||||||
|
|
||||||
interface MentionState {
|
interface MentionState {
|
||||||
@@ -269,7 +275,7 @@ export const MarkdownEditor = forwardRef<MarkdownEditorRef, MarkdownEditorProps>
|
|||||||
listsPlugin(),
|
listsPlugin(),
|
||||||
quotePlugin(),
|
quotePlugin(),
|
||||||
tablePlugin(),
|
tablePlugin(),
|
||||||
linkPlugin(),
|
linkPlugin({ validateUrl: isSafeMarkdownLinkUrl }),
|
||||||
linkDialogPlugin(),
|
linkDialogPlugin(),
|
||||||
thematicBreakPlugin(),
|
thematicBreakPlugin(),
|
||||||
codeBlockPlugin({
|
codeBlockPlugin({
|
||||||
|
|||||||
Reference in New Issue
Block a user