feat: 增强编辑器链接对话框并统一图片插入选择器
链接支持网址/文字与站内搜索,新标签由全站设置控制;文章与评论共用已上传图片选择器。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -122,9 +122,12 @@ export function insertMarkdownLink(
|
||||
value: string,
|
||||
url: string,
|
||||
onChange: ChangeHandler,
|
||||
opts?: { text?: string },
|
||||
) {
|
||||
const { selectionStart, selectionEnd } = textarea;
|
||||
const selected = value.slice(selectionStart, selectionEnd) || '链接文字';
|
||||
const selected = opts?.text?.trim()
|
||||
|| value.slice(selectionStart, selectionEnd)
|
||||
|| '链接文字';
|
||||
const insert = `[${selected}](${url})`;
|
||||
const next = value.slice(0, selectionStart) + insert + value.slice(selectionEnd);
|
||||
applyTextareaChange(
|
||||
|
||||
Reference in New Issue
Block a user