0e9ab84afb
- Add MarkdownToolbar to the workspace note editor (was missing entirely) - Add [[ button to MarkdownToolbar so wikilinks are discoverable in all editors; clicking inserts [[ which immediately triggers the WikilinkSuggestion dropdown - Add link suggestions strip: polls /api/notes/link-suggestions 2.5s after edit, shows unlinked note-title mentions as clickable chips to wrap in [[...]], plus "All" button to apply everything at once — directly addresses the heading→wikilink workflow (note title appearing as heading text gets detected and offered for linking) - Add Ctrl+S keyboard shortcut on title input and editor area to save - Replace ✕ delete icon on note list items with trash can SVG (consistency with task panel) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
125 lines
3.0 KiB
Vue
125 lines
3.0 KiB
Vue
<script setup lang="ts">
|
|
import type { Editor } from "@tiptap/vue-3";
|
|
|
|
const props = defineProps<{
|
|
editor: Editor | null;
|
|
}>();
|
|
|
|
const buttons = [
|
|
{
|
|
label: "B",
|
|
title: "Bold",
|
|
command: () => props.editor?.chain().focus().toggleBold().run(),
|
|
isActive: () => props.editor?.isActive("bold") ?? false,
|
|
},
|
|
{
|
|
label: "I",
|
|
title: "Italic",
|
|
command: () => props.editor?.chain().focus().toggleItalic().run(),
|
|
isActive: () => props.editor?.isActive("italic") ?? false,
|
|
},
|
|
{
|
|
label: "H1",
|
|
title: "Heading 1",
|
|
command: () =>
|
|
props.editor?.chain().focus().toggleHeading({ level: 1 }).run(),
|
|
isActive: () => props.editor?.isActive("heading", { level: 1 }) ?? false,
|
|
},
|
|
{
|
|
label: "H2",
|
|
title: "Heading 2",
|
|
command: () =>
|
|
props.editor?.chain().focus().toggleHeading({ level: 2 }).run(),
|
|
isActive: () => props.editor?.isActive("heading", { level: 2 }) ?? false,
|
|
},
|
|
{
|
|
label: "Link",
|
|
title: "Link",
|
|
command: () => {
|
|
const ed = props.editor;
|
|
if (!ed) return;
|
|
if (ed.isActive("link")) {
|
|
ed.chain().focus().unsetLink().run();
|
|
} else {
|
|
const url = prompt("URL:");
|
|
if (url) {
|
|
ed.chain().focus().setLink({ href: url }).run();
|
|
}
|
|
}
|
|
},
|
|
isActive: () => props.editor?.isActive("link") ?? false,
|
|
},
|
|
{
|
|
label: "UL",
|
|
title: "Bullet List",
|
|
command: () => props.editor?.chain().focus().toggleBulletList().run(),
|
|
isActive: () => props.editor?.isActive("bulletList") ?? false,
|
|
},
|
|
{
|
|
label: "OL",
|
|
title: "Numbered List",
|
|
command: () => props.editor?.chain().focus().toggleOrderedList().run(),
|
|
isActive: () => props.editor?.isActive("orderedList") ?? false,
|
|
},
|
|
{
|
|
label: "`",
|
|
title: "Inline Code",
|
|
command: () => props.editor?.chain().focus().toggleCode().run(),
|
|
isActive: () => props.editor?.isActive("code") ?? false,
|
|
},
|
|
{
|
|
label: "```",
|
|
title: "Code Block",
|
|
command: () => props.editor?.chain().focus().toggleCodeBlock().run(),
|
|
isActive: () => props.editor?.isActive("codeBlock") ?? false,
|
|
},
|
|
{
|
|
label: "[[",
|
|
title: "Insert wikilink (type note title to search)",
|
|
command: () => props.editor?.chain().focus().insertContent("[[").run(),
|
|
isActive: () => false,
|
|
},
|
|
];
|
|
</script>
|
|
|
|
<template>
|
|
<div class="md-toolbar">
|
|
<button
|
|
v-for="btn in buttons"
|
|
:key="btn.label"
|
|
:class="['md-btn', { active: btn.isActive() }]"
|
|
:title="btn.title"
|
|
@click="btn.command()"
|
|
>
|
|
{{ btn.label }}
|
|
</button>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.md-toolbar {
|
|
display: flex;
|
|
gap: 2px;
|
|
flex-wrap: wrap;
|
|
}
|
|
.md-btn {
|
|
padding: 0.25rem 0.5rem;
|
|
border: 1px solid var(--color-input-border);
|
|
border-radius: var(--radius-sm);
|
|
background: var(--color-bg-card);
|
|
color: var(--color-text);
|
|
cursor: pointer;
|
|
font-size: 0.8rem;
|
|
font-family: inherit;
|
|
line-height: 1;
|
|
}
|
|
.md-btn:hover {
|
|
background: var(--color-bg-secondary);
|
|
}
|
|
.md-btn.active {
|
|
background: var(--color-primary);
|
|
color: #fff;
|
|
border-color: var(--color-primary);
|
|
}
|
|
</style>
|