diff --git a/src/components/Tiptap/BubbleMenu.vue b/src/components/Tiptap/BubbleMenu.vue index 7ac042a..0003b77 100644 --- a/src/components/Tiptap/BubbleMenu.vue +++ b/src/components/Tiptap/BubbleMenu.vue @@ -10,33 +10,33 @@ const showUrlInput = ref(false) const inputUrl = ref(null) const openLinkInput = () => { + url.value = editor.getAttributes('link').href || '' showUrlInput.value = true - nextTick(() => - inputUrl.value?.focus(), - ) + nextTick(() => inputUrl.value?.focus()) } const setLink = () => { - const previousUrl = editor.getAttributes('link').href - - if (previousUrl) - inputUrl.value = previousUrl - - // cancelled - if (url.value === null) - return - - if (url.value === '') { - editor.chain().focus().extendMarkRange('link').unsetAllMarks().run() + if (url.value === null) { + showUrlInput.value = false return } + // empty + if (url.value === '') { + editor.chain().focus().extendMarkRange('link').unsetLink().run() + showUrlInput.value = false + return + } + + // unpdate link editor .chain() .focus() .extendMarkRange('link') .setLink({ href: url.value }) .run() + + showUrlInput.value = false } @@ -90,7 +90,9 @@ const setLink = () => { > @@ -106,18 +108,15 @@ const setLink = () => { /> -
+
-