A toolbar button is clicked outside of the text you're editing. In the live demo, select word, click Bold, and check the change with Undo and Redo.
GoTipe is a block editor library. EditorContent in this Vue example displays the document while the application defines the buttons and the layout.
Recorded Markdown for this sentence; other blocks are omitted.
| Action | Markdown fragment |
|---|---|
| Before | Select this word and press Bold. |
| Bold | Select this **word** and press Bold. |
| Undo | Select this word and press Bold. |
Keep the selection when a button runs
The complete example pins core 0.1.6, Vue adapter 0.1.2 and Vue 3.5.45. Its Vite configuration aliases the exact core import to @gotipe/core/js; the editor uses engine: "js".
These are exact excerpts from src/NotesEditor.vue at commit 8af552d, not a standalone component. The full file includes imports, editor creation and the state subscription; the button sits inside the editor-ready branch.
<button
type="button"
:aria-pressed="toolbar?.activeMarks.includes('bold') ?? false"
@mousedown.prevent
@click="toggleBold"
>
Bold
</button>
The click handler is:
function toggleBold() {
editor.value?.chain().focus().toggleBold().run();
}
@mousedown.prevent blocks the default change of focus. The click handler focuses the editor and toggles Bold on the selection.
useEditorState supplies toolbar state for host bindings. The host uses activeMarks to derive aria-pressed and uses canUndo and canRedo to disable the history buttons. The same editor instance is passed to EditorContent under the buttons.
Keep one owner for cleanup
App.vue controls mounting NotesEditor. useEditorStatus creates and destroys the editor. EditorContent mounts and unmounts its surface. useEditorState cleans up its own scoped subscription.
After requesting unmount, App.vue awaits nextTick() and reads the retired editor's isDestroyed. App.vue doesn't call destroy().
Remounting starts with a fresh document and an empty undo history. The initial content is HTML. getMarkdown() returns the current document in Markdown. Nothing is saved, and no Markdown source snapshot is retained.
For integration instructions, see the Vue guide. To modify the example, click on the StackBlitz launcher. This launches a temporary session.
Disclosure: We maintain GoTipe. AI helped draft this article; the example's source and recorded browser checks were independently reviewed. The core and Vue adapter in this example are MIT-licensed, with application-owned CSS. GoTipe's ready-made editor UI and themes use commercial licenses.
About the author
- GoTipe is a block editor for apps that store Markdown. Our TypeScript and Rust/WASM engines, Markdown codec and headless adapters for React, Vue, Svelte and Solid are MIT-licensed. The ready-made UI and themes use a commercial license. We share runnable examples of Markdown preservation, editor integration, collaboration and AI review. Try the editor and read the docs: https://gotipe.com Source and examples: https://github.com/veniameen/gotipe
Comments
Join the discussionNo comments yet. Be the first to comment.
