# A GoTipe editor in Vue: the renderer and the toolbar are separate

A toolbar button is clicked outside of the text you're editing. In the [live demo](https://veniameen.github.io/gotipe-vue-headless-example/?utm_source=hashnode&utm_medium=referral&utm_campaign=vue_headless_renderer&utm_content=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](https://github.com/veniameen/gotipe-vue-headless-example?utm_source=hashnode&utm_medium=referral&utm_campaign=vue_headless_renderer&utm_content=source) 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.

```vue
        <button
          type="button"
          :aria-pressed="toolbar?.activeMarks.includes('bold') ?? false"
          @mousedown.prevent
          @click="toggleBold"
        >
          Bold
        </button>
```

The click handler is:

```ts
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](https://gotipe.com/docs/frameworks/vue/?utm_source=hashnode&utm_medium=referral&utm_campaign=vue_headless_renderer&utm_content=guide). To modify the example, click on the [StackBlitz launcher](https://veniameen.github.io/gotipe-vue-headless-example/stackblitz/?utm_source=hashnode&utm_medium=referral&utm_campaign=vue_headless_renderer&utm_content=editable). 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](https://gotipe.com/docs/resources/licensing/?utm_source=hashnode&utm_medium=referral&utm_campaign=vue_headless_renderer&utm_content=licensing).

