Skip to content
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