Skip to content

Commit

Permalink
fix: Show the set link on the text instead of clearing it
Browse files Browse the repository at this point in the history
  • Loading branch information
surajshetty3416 committed Jun 15, 2024
1 parent 29c78d0 commit 727570e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions frontend/src/components/TextBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@
<Button @click="() => setLink(linkInput?.getInputValue())" class="ml-1">
<FeatherIcon class="h-3 w-3" name="check" />
</Button>
<Button
@click="
() => {
textLink = '';
setLink(null);
}
"
class="ml-1">
<FeatherIcon class="h-3 w-3" name="x" />
</Button>
</div>
<div v-show="!settingLink" class="flex gap-1">
<button
Expand Down Expand Up @@ -89,11 +99,7 @@
@click="
() => {
if (!editor) return;
if (editor.isActive('link')) {
editor.chain().focus().unsetLink().run();
} else {
enableLinkInput();
}
enableLinkInput();
}
"
class="rounded px-2 py-1 hover:bg-gray-100"
Expand Down Expand Up @@ -302,6 +308,9 @@ const handleKeydown = (e: KeyboardEvent) => {
const enableLinkInput = () => {
settingLink.value = true;
// check if link is already set on selection
const link = editor.value?.isActive("link") ? editor.value?.getAttributes("link").href : null;
textLink.value = link || "";
nextTick(() => {
if (linkInput.value) {
const input = document.querySelector(".link-input") as HTMLInputElement;
Expand Down

0 comments on commit 727570e

Please sign in to comment.