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: 解决用户在插入链接时,如果没有填写链接地址,无法自定义给出错误提示的问题 #5820

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions packages/basic-modules/src/modules/link/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ function genLinkNode(url: string, text?: string): LinkElement {
* @param url url
*/
export async function insertLink(editor: IDomEditor, text: string, url: string) {
// 校验
const checkRes = await check('insertLink', editor, text, url)
if (!checkRes) return // 校验未通过

if (!url) return
if (!text) text = url // 无 text 则用 url 代替

Expand All @@ -96,10 +100,6 @@ export async function insertLink(editor: IDomEditor, text: string, url: string)

if (isMenuDisabled(editor)) return

// 校验
const checkRes = await check('insertLink', editor, text, url)
if (!checkRes) return // 校验未通过

// 转换 url
const parsedUrl = await parse('insertLink', editor, url)

Expand Down Expand Up @@ -142,12 +142,12 @@ export async function insertLink(editor: IDomEditor, text: string, url: string)
* @param url link url
*/
export async function updateLink(editor: IDomEditor, text: string, url: string) {
if (!url) return

// 校验
const checkRes = await check('editLink', editor, text, url)
if (!checkRes) return // 校验未通过

if (!url) return

// 转换 url
const parsedUrl = await parse('editLink', editor, url)

Expand Down