# MarkdownEditor

> A plain-text Markdown editor with a formatting toolbar, Ctrl/⌘ shortcuts and a Write / Preview / Split view rendered in Nasaq typography, controlled or uncontrolled, with a hidden input for form posts.

Source: https://docs.nasaqui.com/components/markdown-editor

## Install

```bash
npx shadcn@latest add https://docs.nasaqui.com/r/markdown-editor.json
```

A `textarea` with a toolbar and a live preview. The value is Markdown text, so you store and diff it as is.

## When to use

- Descriptions, comments, release notes and docs where people know or tolerate Markdown.
- When you need the source text, not HTML.

## When not to use

- Writers who expect a word processor: use [`RichTextEditor`](https://docs.nasaqui.com/components/rich-text-editor).
- Showing Markdown only: use [`Markdown`](https://docs.nasaqui.com/components/markdown).
- A short single-line field: use `Input`.

## Import

```tsx
import { MarkdownEditor } from "@fadymondy/nasaq/web";
// inside this monorepo: "@nasaq/web"
```

## Quick start

```tsx
import { MarkdownEditor } from "@fadymondy/nasaq/web";
import { useState } from "react";

export function Description() {
  const [value, setValue] = useState("## Notes\n\nWrite **here**.");
  return <MarkdownEditor value={value} onValueChange={setValue} defaultView="split" aria-label="Description" />;
}
```

## Anatomy

```
MarkdownEditor                  data-slot="markdown-editor", data-view="write|preview|split"
├─ toolbar (role="toolbar")     bold, italic, headings, lists, task list, quote, link, code, code block
├─ ToggleGroup                  Write · Preview · Split (Split from md up)
├─ textarea                     monospace, dir="auto"
├─ preview                      data-slot="markdown-editor-preview", <Markdown>
└─ input type="hidden"          when `name` is set
```

## API

**MarkdownEditor**: every `div` prop except `onChange` and `defaultValue`, plus:

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` / `defaultValue` | `string` | `""` | Controlled or initial Markdown. |
| `onValueChange` | `(value) => void` | | Every edit, including toolbar actions. |
| `view` / `defaultView` | `"write" \| "preview" \| "split"` | `"write"` | Controlled or initial view. |
| `onViewChange` | `(view) => void` | | |
| `placeholder` | `string` | localised | |
| `rows` | `number` | `10` | Height of the text area. |
| `disabled` | `boolean` | `false` | |
| `name` | `string` | | Adds a hidden input with the value for form posts. |
| `aria-label` | `string` | "Write" | Name of the text area when there is no visible label. |
| `labels` | `Partial<MarkdownEditorLabels>` | | Override any string. |

Shortcuts: Ctrl/⌘+B bold, Ctrl/⌘+I italic, Ctrl/⌘+K link. Toolbar actions wrap the selection, or insert a
placeholder, and keep it selected.

## Accessibility

- The toolbar is labelled and `aria-controls` the text area; every icon button has a name and a tooltip.
- Toolbar buttons keep focus and the selection in the text area.
- The preview is `aria-live="polite"`.

## RTL & i18n

- English and Arabic strings follow the Nasaq locale. The text area uses `dir="auto"`, so Arabic and English
  lines each read the right way; Split puts Write at the inline start.

## Styling & tokens

- `Card` surface, `rounded-card`, mono text area, preview in `Markdown` typography. Target `[data-slot="markdown-editor"]`.

## Do / Don't

- Do sanitise Markdown on the server before rendering it elsewhere.
- Do start in Split on wide screens for people new to Markdown.
- Don't use it for chat input; Enter makes a new line here.

## Related

- [`Markdown`](https://docs.nasaqui.com/components/markdown)
- [`RichTextEditor`](https://docs.nasaqui.com/components/rich-text-editor)
- [`Notes`](https://docs.nasaqui.com/components/notes)

## Lab

https://docs.nasaqui.com/?path=/docs/components-editors-markdown-editor--docs

## Code

### React

```tsx
import { MarkdownEditor } from "@fadymondy/nasaq/web";
import { useState } from "react";

export function Description() {
  const [value, setValue] = useState("## Notes\n\nWrite **here**.");
  return <MarkdownEditor value={value} onValueChange={setValue} defaultView="split" aria-label="Description" />;
}
```

### shadcn

```tsx
import { MarkdownEditor } from "@/components/ui/markdown-editor";
import { useState } from "react";

export function Description() {
  const [value, setValue] = useState("## Notes\n\nWrite **here**.");
  return <MarkdownEditor value={value} onValueChange={setValue} defaultView="split" aria-label="Description" />;
}
```

### Vue

```vue
<script setup lang="ts">
import { NqMarkdownEditor } from "@fadymondy/nasaq/vue";
import { ref } from "vue";

const value = ref("## Notes\n\nWrite **here**.");
</script>

<template>
  <NqMarkdownEditor v-model="value" default-view="split" aria-label="Description" />
</template>
```

### Blade

```blade
<x-nq::markdown-editor :value="'## Notes'.chr(10).chr(10).'Write **here**.'" view="split" aria-label="Description" />
```

### HTML + Alpine

```html
<div data-slot="markdown-editor" x-data="nqMarkdownEditor(JSON.parse('{\u0022value\u0022:\u0022## Notes\\n\\nWrite **here**.\u0022,\u0022view\u0022:\u0022split\u0022,\u0022disabled\u0022:false,\u0022empty\u0022:\u0022Nothing to preview yet.\u0022}'))" x-modelable="body" x-bind:data-view="mode"
    class="flex min-w-0 flex-col overflow-hidden rounded-card border border-border bg-card">
    <div class="flex flex-wrap items-center gap-1 border-b border-border px-1.5 py-1">
        <div role="toolbar" aria-label="Formatting" aria-controls="nq-md-000001" class="flex flex-wrap items-center gap-0.5">
                                            <div data-slot="tooltip" x-data="nqTooltip(600, false)" x-modelable="open" x-id="['nq-tooltip']" class="contents">
    <span data-slot="tooltip-trigger" class="contents"><button data-slot="button"
     type="button"                         aria-label="Bold" x-on:mousedown.prevent="x-on:mousedown.prevent" x-bind:disabled="locked()" x-on:click="apply(&#039;bold&#039;)" class="inline-flex shrink-0 select-none items-center justify-center gap-2 whitespace-nowrap rounded-control border border-transparent font-sans text-label transition-colors duration-150 ease-nq min-h-[var(--nq-touch-min,0px)] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-nq-focus disabled:pointer-events-none disabled:opacity-50 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 text-foreground hover:bg-nq-hover size-control-sm p-0">
        <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <path d="M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"/>
</svg></button></span>
    <template x-teleport="body">
        <div data-slot="tooltip-content" x-bind="popup" x-nq-presence="open" x-anchor.top.offset.6="triggerEl"
            class="z-50 max-w-64 rounded-control bg-foreground px-2 py-1 text-caption text-background transition-opacity duration-150 ease-nq data-starting-style:opacity-0 data-ending-style:opacity-0">Bold (⌘B)</div>
    </template>
</div>
                                            <div data-slot="tooltip" x-data="nqTooltip(600, false)" x-modelable="open" x-id="['nq-tooltip']" class="contents">
    <span data-slot="tooltip-trigger" class="contents"><button data-slot="button"
     type="button"                         aria-label="Italic" x-on:mousedown.prevent="x-on:mousedown.prevent" x-bind:disabled="locked()" x-on:click="apply(&#039;italic&#039;)" class="inline-flex shrink-0 select-none items-center justify-center gap-2 whitespace-nowrap rounded-control border border-transparent font-sans text-label transition-colors duration-150 ease-nq min-h-[var(--nq-touch-min,0px)] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-nq-focus disabled:pointer-events-none disabled:opacity-50 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 text-foreground hover:bg-nq-hover size-control-sm p-0">
        <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <line x1="19" x2="10" y1="4" y2="4"/>
  <line x1="14" x2="5" y1="20" y2="20"/>
  <line x1="15" x2="9" y1="4" y2="20"/>
</svg></button></span>
    <template x-teleport="body">
        <div data-slot="tooltip-content" x-bind="popup" x-nq-presence="open" x-anchor.top.offset.6="triggerEl"
            class="z-50 max-w-64 rounded-control bg-foreground px-2 py-1 text-caption text-background transition-opacity duration-150 ease-nq data-starting-style:opacity-0 data-ending-style:opacity-0">Italic (⌘I)</div>
    </template>
</div>
                                            <div data-slot="tooltip" x-data="nqTooltip(600, false)" x-modelable="open" x-id="['nq-tooltip']" class="contents">
    <span data-slot="tooltip-trigger" class="contents"><button data-slot="button"
     type="button"                         aria-label="Heading" x-on:mousedown.prevent="x-on:mousedown.prevent" x-bind:disabled="locked()" x-on:click="apply(&#039;h2&#039;)" class="inline-flex shrink-0 select-none items-center justify-center gap-2 whitespace-nowrap rounded-control border border-transparent font-sans text-label transition-colors duration-150 ease-nq min-h-[var(--nq-touch-min,0px)] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-nq-focus disabled:pointer-events-none disabled:opacity-50 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 text-foreground hover:bg-nq-hover size-control-sm p-0">
        <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <path d="M4 12h8"/>
  <path d="M4 18V6"/>
  <path d="M12 18V6"/>
  <path d="M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"/>
</svg></button></span>
    <template x-teleport="body">
        <div data-slot="tooltip-content" x-bind="popup" x-nq-presence="open" x-anchor.top.offset.6="triggerEl"
            class="z-50 max-w-64 rounded-control bg-foreground px-2 py-1 text-caption text-background transition-opacity duration-150 ease-nq data-starting-style:opacity-0 data-ending-style:opacity-0">Heading</div>
    </template>
</div>
                                            <div data-slot="tooltip" x-data="nqTooltip(600, false)" x-modelable="open" x-id="['nq-tooltip']" class="contents">
    <span data-slot="tooltip-trigger" class="contents"><button data-slot="button"
     type="button"                         aria-label="Subheading" x-on:mousedown.prevent="x-on:mousedown.prevent" x-bind:disabled="locked()" x-on:click="apply(&#039;h3&#039;)" class="inline-flex shrink-0 select-none items-center justify-center gap-2 whitespace-nowrap rounded-control border border-transparent font-sans text-label transition-colors duration-150 ease-nq min-h-[var(--nq-touch-min,0px)] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-nq-focus disabled:pointer-events-none disabled:opacity-50 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 text-foreground hover:bg-nq-hover size-control-sm p-0">
        <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <path d="M4 12h8"/>
  <path d="M4 18V6"/>
  <path d="M12 18V6"/>
  <path d="M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"/>
  <path d="M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"/>
</svg></button></span>
    <template x-teleport="body">
        <div data-slot="tooltip-content" x-bind="popup" x-nq-presence="open" x-anchor.top.offset.6="triggerEl"
            class="z-50 max-w-64 rounded-control bg-foreground px-2 py-1 text-caption text-background transition-opacity duration-150 ease-nq data-starting-style:opacity-0 data-ending-style:opacity-0">Subheading</div>
    </template>
</div>
                                            <div data-slot="tooltip" x-data="nqTooltip(600, false)" x-modelable="open" x-id="['nq-tooltip']" class="contents">
    <span data-slot="tooltip-trigger" class="contents"><button data-slot="button"
     type="button"                         aria-label="Bulleted list" x-on:mousedown.prevent="x-on:mousedown.prevent" x-bind:disabled="locked()" x-on:click="apply(&#039;bullet&#039;)" class="inline-flex shrink-0 select-none items-center justify-center gap-2 whitespace-nowrap rounded-control border border-transparent font-sans text-label transition-colors duration-150 ease-nq min-h-[var(--nq-touch-min,0px)] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-nq-focus disabled:pointer-events-none disabled:opacity-50 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 text-foreground hover:bg-nq-hover size-control-sm p-0">
        <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <path d="M3 5h.01"/>
  <path d="M3 12h.01"/>
  <path d="M3 19h.01"/>
  <path d="M8 5h13"/>
  <path d="M8 12h13"/>
  <path d="M8 19h13"/>
</svg></button></span>
    <template x-teleport="body">
        <div data-slot="tooltip-content" x-bind="popup" x-nq-presence="open" x-anchor.top.offset.6="triggerEl"
            class="z-50 max-w-64 rounded-control bg-foreground px-2 py-1 text-caption text-background transition-opacity duration-150 ease-nq data-starting-style:opacity-0 data-ending-style:opacity-0">Bulleted list</div>
    </template>
</div>
                                            <div data-slot="tooltip" x-data="nqTooltip(600, false)" x-modelable="open" x-id="['nq-tooltip']" class="contents">
    <span data-slot="tooltip-trigger" class="contents"><button data-slot="button"
     type="button"                         aria-label="Numbered list" x-on:mousedown.prevent="x-on:mousedown.prevent" x-bind:disabled="locked()" x-on:click="apply(&#039;ordered&#039;)" class="inline-flex shrink-0 select-none items-center justify-center gap-2 whitespace-nowrap rounded-control border border-transparent font-sans text-label transition-colors duration-150 ease-nq min-h-[var(--nq-touch-min,0px)] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-nq-focus disabled:pointer-events-none disabled:opacity-50 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 text-foreground hover:bg-nq-hover size-control-sm p-0">
        <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <path d="M11 5h10"/>
  <path d="M11 12h10"/>
  <path d="M11 19h10"/>
  <path d="M4 4h1v5"/>
  <path d="M4 9h2"/>
  <path d="M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02"/>
</svg></button></span>
    <template x-teleport="body">
        <div data-slot="tooltip-content" x-bind="popup" x-nq-presence="open" x-anchor.top.offset.6="triggerEl"
            class="z-50 max-w-64 rounded-control bg-foreground px-2 py-1 text-caption text-background transition-opacity duration-150 ease-nq data-starting-style:opacity-0 data-ending-style:opacity-0">Numbered list</div>
    </template>
</div>
                                            <div data-slot="tooltip" x-data="nqTooltip(600, false)" x-modelable="open" x-id="['nq-tooltip']" class="contents">
    <span data-slot="tooltip-trigger" class="contents"><button data-slot="button"
     type="button"                         aria-label="Task list" x-on:mousedown.prevent="x-on:mousedown.prevent" x-bind:disabled="locked()" x-on:click="apply(&#039;task&#039;)" class="inline-flex shrink-0 select-none items-center justify-center gap-2 whitespace-nowrap rounded-control border border-transparent font-sans text-label transition-colors duration-150 ease-nq min-h-[var(--nq-touch-min,0px)] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-nq-focus disabled:pointer-events-none disabled:opacity-50 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 text-foreground hover:bg-nq-hover size-control-sm p-0">
        <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <path d="M13 5h8"/>
  <path d="M13 12h8"/>
  <path d="M13 19h8"/>
  <path d="m3 17 2 2 4-4"/>
  <path d="m3 7 2 2 4-4"/>
</svg></button></span>
    <template x-teleport="body">
        <div data-slot="tooltip-content" x-bind="popup" x-nq-presence="open" x-anchor.top.offset.6="triggerEl"
            class="z-50 max-w-64 rounded-control bg-foreground px-2 py-1 text-caption text-background transition-opacity duration-150 ease-nq data-starting-style:opacity-0 data-ending-style:opacity-0">Task list</div>
    </template>
</div>
                                            <div data-slot="tooltip" x-data="nqTooltip(600, false)" x-modelable="open" x-id="['nq-tooltip']" class="contents">
    <span data-slot="tooltip-trigger" class="contents"><button data-slot="button"
     type="button"                         aria-label="Quote" x-on:mousedown.prevent="x-on:mousedown.prevent" x-bind:disabled="locked()" x-on:click="apply(&#039;quote&#039;)" class="inline-flex shrink-0 select-none items-center justify-center gap-2 whitespace-nowrap rounded-control border border-transparent font-sans text-label transition-colors duration-150 ease-nq min-h-[var(--nq-touch-min,0px)] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-nq-focus disabled:pointer-events-none disabled:opacity-50 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 text-foreground hover:bg-nq-hover size-control-sm p-0">
        <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <path d="M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"/>
  <path d="M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"/>
</svg></button></span>
    <template x-teleport="body">
        <div data-slot="tooltip-content" x-bind="popup" x-nq-presence="open" x-anchor.top.offset.6="triggerEl"
            class="z-50 max-w-64 rounded-control bg-foreground px-2 py-1 text-caption text-background transition-opacity duration-150 ease-nq data-starting-style:opacity-0 data-ending-style:opacity-0">Quote</div>
    </template>
</div>
                                            <div data-slot="tooltip" x-data="nqTooltip(600, false)" x-modelable="open" x-id="['nq-tooltip']" class="contents">
    <span data-slot="tooltip-trigger" class="contents"><button data-slot="button"
     type="button"                         aria-label="Link" x-on:mousedown.prevent="x-on:mousedown.prevent" x-bind:disabled="locked()" x-on:click="apply(&#039;link&#039;)" class="inline-flex shrink-0 select-none items-center justify-center gap-2 whitespace-nowrap rounded-control border border-transparent font-sans text-label transition-colors duration-150 ease-nq min-h-[var(--nq-touch-min,0px)] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-nq-focus disabled:pointer-events-none disabled:opacity-50 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 text-foreground hover:bg-nq-hover size-control-sm p-0">
        <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <path d="M9 17H7A5 5 0 0 1 7 7h2"/>
  <path d="M15 7h2a5 5 0 1 1 0 10h-2"/>
  <line x1="8" x2="16" y1="12" y2="12"/>
</svg></button></span>
    <template x-teleport="body">
        <div data-slot="tooltip-content" x-bind="popup" x-nq-presence="open" x-anchor.top.offset.6="triggerEl"
            class="z-50 max-w-64 rounded-control bg-foreground px-2 py-1 text-caption text-background transition-opacity duration-150 ease-nq data-starting-style:opacity-0 data-ending-style:opacity-0">Link (⌘K)</div>
    </template>
</div>
                                            <div data-slot="tooltip" x-data="nqTooltip(600, false)" x-modelable="open" x-id="['nq-tooltip']" class="contents">
    <span data-slot="tooltip-trigger" class="contents"><button data-slot="button"
     type="button"                         aria-label="Inline code" x-on:mousedown.prevent="x-on:mousedown.prevent" x-bind:disabled="locked()" x-on:click="apply(&#039;code&#039;)" class="inline-flex shrink-0 select-none items-center justify-center gap-2 whitespace-nowrap rounded-control border border-transparent font-sans text-label transition-colors duration-150 ease-nq min-h-[var(--nq-touch-min,0px)] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-nq-focus disabled:pointer-events-none disabled:opacity-50 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 text-foreground hover:bg-nq-hover size-control-sm p-0">
        <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <path d="m16 18 6-6-6-6"/>
  <path d="m8 6-6 6 6 6"/>
</svg></button></span>
    <template x-teleport="body">
        <div data-slot="tooltip-content" x-bind="popup" x-nq-presence="open" x-anchor.top.offset.6="triggerEl"
            class="z-50 max-w-64 rounded-control bg-foreground px-2 py-1 text-caption text-background transition-opacity duration-150 ease-nq data-starting-style:opacity-0 data-ending-style:opacity-0">Inline code</div>
    </template>
</div>
                                            <div data-slot="tooltip" x-data="nqTooltip(600, false)" x-modelable="open" x-id="['nq-tooltip']" class="contents">
    <span data-slot="tooltip-trigger" class="contents"><button data-slot="button"
     type="button"                         aria-label="Code block" x-on:mousedown.prevent="x-on:mousedown.prevent" x-bind:disabled="locked()" x-on:click="apply(&#039;codeBlock&#039;)" class="inline-flex shrink-0 select-none items-center justify-center gap-2 whitespace-nowrap rounded-control border border-transparent font-sans text-label transition-colors duration-150 ease-nq min-h-[var(--nq-touch-min,0px)] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-nq-focus disabled:pointer-events-none disabled:opacity-50 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 text-foreground hover:bg-nq-hover size-control-sm p-0">
        <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <path d="m10 9-3 3 3 3"/>
  <path d="m14 15 3-3-3-3"/>
  <rect x="3" y="3" width="18" height="18" rx="2"/>
</svg></button></span>
    <template x-teleport="body">
        <div data-slot="tooltip-content" x-bind="popup" x-nq-presence="open" x-anchor.top.offset.6="triggerEl"
            class="z-50 max-w-64 rounded-control bg-foreground px-2 py-1 text-caption text-background transition-opacity duration-150 ease-nq data-starting-style:opacity-0 data-ending-style:opacity-0">Code block</div>
    </template>
</div>
                    </div>
        <div role="group" data-slot="toggle-group" data-variant="segmented" data-orientation="horizontal"
    x-data="nqToggleGroup(JSON.parse('[\u0022split\u0022]'), false)" x-modelable="value" x-bind="root"
            aria-label="View" x-model="modes" class="flex w-fit max-w-full gap-0.5 rounded-control bg-secondary p-0.5 ms-auto">
    <button type="button" data-slot="toggle" aria-pressed="false"
     x-bind="toggle('write')"             aria-label="Write" class="inline-flex h-7 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-3 text-label text-muted-foreground outline-none transition-colors duration-150 ease-nq hover:text-foreground [&_svg]:size-4 [&_svg]:shrink-0 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-nq-focus data-disabled:pointer-events-none data-disabled:opacity-50 rounded-[calc(var(--radius-control)-2px)] data-pressed:bg-card data-pressed:text-foreground data-pressed:shadow-xs"><svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/>
  <path d="m15 5 4 4"/>
</svg>                <span class="max-sm:hidden">Write</span></button>
            <button type="button" data-slot="toggle" aria-pressed="false"
     x-bind="toggle('preview')"             aria-label="Preview" class="inline-flex h-7 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-3 text-label text-muted-foreground outline-none transition-colors duration-150 ease-nq hover:text-foreground [&_svg]:size-4 [&_svg]:shrink-0 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-nq-focus data-disabled:pointer-events-none data-disabled:opacity-50 rounded-[calc(var(--radius-control)-2px)] data-pressed:bg-card data-pressed:text-foreground data-pressed:shadow-xs"><svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"/>
  <circle cx="12" cy="12" r="3"/>
</svg>                <span class="max-sm:hidden">Preview</span></button>
            <button type="button" data-slot="toggle" aria-pressed="true"
     x-bind="toggle('split')"      data-pressed         aria-label="Split" class="inline-flex h-7 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-3 text-label text-muted-foreground outline-none transition-colors duration-150 ease-nq hover:text-foreground [&_svg]:size-4 [&_svg]:shrink-0 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-nq-focus data-disabled:pointer-events-none data-disabled:opacity-50 rounded-[calc(var(--radius-control)-2px)] data-pressed:bg-card data-pressed:text-foreground data-pressed:shadow-xs max-md:hidden"><svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  <rect width="18" height="18" x="3" y="3" rx="2"/>
  <path d="M12 3v18"/>
</svg>                <span class="max-sm:hidden">Split</span></button>
</div>
    </div>
    <div class="grid min-h-0 flex-1" x-bind:class="isSplit() ? 'md:grid-cols-2 md:divide-x md:divide-border rtl:md:divide-x-reverse' : ''">
        <textarea id="nq-md-000001" x-ref="field" x-model="body" x-show="showsEditor()" x-on:keydown="onKey($event)" dir="auto" rows="10"
                        aria-label="Description" placeholder="Write in Markdown…"
            class="min-h-48 w-full resize-y bg-transparent p-3 font-mono text-body-sm text-foreground outline-none placeholder:text-muted-foreground focus-visible:bg-nq-hover/40">## Notes
Write **here**.</textarea>
        <div data-slot="markdown-editor-preview" aria-live="polite" x-show="showsPreview()" x-html="previewHtml()"
            x-bind:class="isSplit() ? 'max-md:border-t max-md:border-border' : ''"
                        class="min-h-48 overflow-auto p-4">
                            <div data-slot="markdown" class="flex min-w-0 flex-col gap-3 text-body text-nq-fg-body"><h2 data-slot="text" dir="auto" class="text-h2 text-foreground mt-2 text-start first:mt-0">Notes</h2>
<p data-slot="text" dir="auto" class="text-body text-nq-fg-body text-start">Write <strong class="font-semibold text-foreground">here</strong>.</p>
</div>
                    </div>
    </div>
    </div>
```
