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

pref: add the option to open a new window to the picture jump link #6170

Merged
merged 1 commit into from
Jun 27, 2024
Merged
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
35 changes: 27 additions & 8 deletions ui/packages/editor/src/extensions/image/BubbleItemImageHref.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { i18n } from "@/locales";
import type { Editor } from "@/tiptap/vue-3";
import { computed, type Component } from "vue";
import Image from "./index";
import { ExtensionLink, ExtensionImage } from "@/extensions";

const props = defineProps<{
editor: Editor;
Expand All @@ -15,15 +15,24 @@ const props = defineProps<{

const href = computed({
get: () => {
return props.editor.getAttributes(Image.name).href;
const attrs = props.editor.getAttributes(ExtensionLink.name);
return attrs?.href || props.editor.getAttributes(ExtensionImage.name).href;
},
set: (href: string) => {
props.editor
.chain()
.updateAttributes(Image.name, { href: href })
.setNodeSelection(props.editor.state.selection.from)
.focus()
.run();
props.editor.commands.setLink({ href: href, target: "_blank" });
},
});

const target = computed({
get() {
const attrs = props.editor.getAttributes(ExtensionLink.name);
return attrs?.target === "_blank";
},
set(value) {
props.editor.commands.setLink({
href: href.value,
target: value ? "_blank" : "_self",
});
},
});
</script>
Expand All @@ -34,4 +43,14 @@ const href = computed({
:placeholder="i18n.global.t('editor.common.placeholder.alt_href')"
class="bg-gray-50 rounded-md hover:bg-gray-100 block px-2 w-full py-1.5 text-sm text-gray-900 border border-gray-300 focus:ring-blue-500 focus:border-blue-500"
/>
<label class="inline-flex items-center mt-2">
<input
v-model="target"
type="checkbox"
class="form-checkbox text-blue-600 focus:ring-blue-500 border-gray-300 rounded"
/>
<span class="ml-2 text-sm text-gray-500">
{{ i18n.global.t("editor.extensions.link.open_in_new_window") }}
</span>
</label>
</template>