@humanonlyweb/writer 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,236 @@
1
+ # Editor
2
+
3
+ > Markdown in, a live preview while you write.
4
+
5
+ `<WriterEditor>` edits Markdown, held in its `v-model`. In plain Vue, import `WriterEditor`.
6
+
7
+ ## Examples
8
+
9
+ ### Basic
10
+
11
+ ```vue
12
+ <script setup lang="ts">
13
+ const body = ref(`## A heading
14
+
15
+ Some **bold**, some _italic_, a [link](https://example.com) and \`code\`.
16
+
17
+ - A list
18
+ - [x] A done task
19
+
20
+ > A quote.`);
21
+ const editor = useTemplateRef("editor");
22
+ </script>
23
+
24
+ <template>
25
+ <div class="writer-demo">
26
+ <WriterToolbar
27
+ :editor="editor"
28
+ :items="['heading2', 'bold', 'italic', 'link', 'quote', 'bulletList', 'image']"
29
+ />
30
+ <WriterEditor ref="editor" v-model="body" label="Body" placeholder="Start writing…" />
31
+ </div>
32
+ </template>
33
+ ```
34
+
35
+ ### Source mode
36
+
37
+ Plain Markdown throughout, with the source highlighted.
38
+
39
+ ```vue
40
+ <script setup lang="ts">
41
+ const body = ref(`## Plain Markdown
42
+
43
+ Every **mark** stays where you can see it.
44
+
45
+ ::callout
46
+ Blocks too.
47
+ ::`);
48
+ </script>
49
+
50
+ <template>
51
+ <div class="writer-demo">
52
+ <WriterEditor v-model="body" mode="source" label="Body" />
53
+ </div>
54
+ </template>
55
+ ```
56
+
57
+ ### Uploads
58
+
59
+ Pass `upload` and files can be pasted, dropped or picked. It gets the `File` and resolves to its URL.
60
+
61
+ ```vue
62
+ <script setup lang="ts">
63
+ const body = ref("Drop, paste or choose an image:\n\n![]()\n");
64
+ const editor = useTemplateRef("editor");
65
+ const error = ref("");
66
+
67
+ // Your endpoint stores the file and answers with its URL. Here: the image inlined,
68
+ // after a moment, so you can see it upload.
69
+ async function upload(file: File) {
70
+ await new Promise((resolve) => setTimeout(resolve, 1500));
71
+ return new Promise<string>((resolve) => {
72
+ const reader = new FileReader();
73
+ reader.addEventListener("load", () => resolve(String(reader.result)));
74
+ reader.readAsDataURL(file);
75
+ });
76
+ }
77
+ </script>
78
+
79
+ <template>
80
+ <div class="writer-demo">
81
+ <WriterToolbar :editor="editor" :items="['bold', 'italic', 'image']" />
82
+ <WriterEditor
83
+ ref="editor"
84
+ v-model="body"
85
+ label="Body"
86
+ :upload="upload"
87
+ @upload-error="(_, file) => (error = `Couldn't upload ${file.name}.`)"
88
+ />
89
+ <p class="writer-demo-stats">
90
+ {{ error || (editor?.uploading ? "Uploading…" : "Ready to save") }}
91
+ </p>
92
+ </div>
93
+ </template>
94
+ ```
95
+
96
+ ### Read-only
97
+
98
+ `readonly` locks everything: the text, task checkboxes and image cards.
99
+
100
+ ```vue
101
+ <script setup lang="ts">
102
+ const body = ref(`## Read-only
103
+
104
+ Nothing here can change: not the text, not the task,
105
+ and not the image card below.
106
+
107
+ - [x] A done task
108
+
109
+ ![A snowy street](https://picsum.photos/id/1036/900/360 "Look, don't touch."){width="900" height="360"}`);
110
+ const readonly = ref(true);
111
+ </script>
112
+
113
+ <template>
114
+ <div class="writer-demo">
115
+ <div class="writer-demo-bar">
116
+ <span class="writer-demo-stats">{{ readonly ? "Read-only" : "Editable" }}</span>
117
+ <button
118
+ type="button"
119
+ class="writer-demo-toggle"
120
+ :aria-pressed="readonly"
121
+ @click="readonly = !readonly"
122
+ >
123
+ Read-only
124
+ </button>
125
+ </div>
126
+ <WriterEditor v-model="body" :readonly="readonly" label="Body" />
127
+ </div>
128
+ </template>
129
+ ```
130
+
131
+ ### Link suggestions
132
+
133
+ `links` suggests targets as the author types `](`, e.g. your site's pages.
134
+
135
+ ```vue
136
+ <script setup lang="ts">
137
+ const body = ref("Type `](` after some text in brackets: [the council](");
138
+
139
+ const pages = [
140
+ { label: "City council", url: "/topics/council" },
141
+ { label: "Winter", url: "/topics/winter" },
142
+ { label: "Dale", url: "/people/dale" },
143
+ ];
144
+ const links = (query: string) => pages.filter((page) => page.url.includes(query));
145
+ </script>
146
+
147
+ <template>
148
+ <div class="writer-demo">
149
+ <WriterEditor v-model="body" label="Body" :links="links" />
150
+ </div>
151
+ </template>
152
+ ```
153
+
154
+ ## Live preview
155
+
156
+ The document is always Markdown, but it reads like the page:
157
+
158
+ - **Formatting:** marks hide except in the element being edited. `**bold**` shows its asterisks only while the cursor is in it. Heading, quote and list marks show on the cursor's line.
159
+ - **Blocks** render with your components. Click or arrow into one and its source opens, framed, in the same spot. Set `--writer-block-inset` and `--writer-block-background` to your blocks' padding and background, and the text doesn't jump.
160
+ - **Images** on their own line are cards: the published figure, with caption and alt text typed in place. Drop, paste or pick a file to fill or replace one.
161
+ - **Leaving the editor** shows everything as published. The cursor stays put for when you come back.
162
+
163
+ `mode="source"` turns it off.
164
+
165
+ ## Props
166
+
167
+ | Prop | Type | Description |
168
+ | --------------- | -------------------------------------------- | ----------------------------------------------------------------------------------- |
169
+ | `v-model` | `string` | The Markdown. |
170
+ | `label` | `string` | Accessible name. Default: "Markdown editor". |
171
+ | `labelledby` | `string` | Id of the element naming it, instead of `label`. |
172
+ | `describedby` | `string` | Id of a hint or error. |
173
+ | `name` | `string` | Submits the Markdown with its form. |
174
+ | `placeholder` | `string` | |
175
+ | `readonly` | `boolean` | |
176
+ | `mode` | `"live" \| "source"` | Live preview (default) or plain Markdown. |
177
+ | `upload` | `(file: File) => Promise<string>` | Enables pasting, dropping and picking files. Resolve to the URL. |
178
+ | `links` | `(query) => { label, url }[]` (or a promise) | Suggests link targets after `](`. |
179
+ | `codeLanguages` | `LanguageDescription[]` | Highlighting inside fenced code, e.g. `languages` from `@codemirror/language-data`. |
180
+ | `extensions` | `Extension` | Extra CodeMirror extensions. Read once, on mount. |
181
+
182
+ ## Events
183
+
184
+ | Event | Payload | When |
185
+ | -------------- | ------------------------------ | ------------------------------------------------------------------------------- |
186
+ | `focus` | | The editor gets focus. |
187
+ | `blur` | | It loses it. |
188
+ | `upload-error` | `(error: unknown, file: File)` | An `upload` rejected. Its placeholder is gone, or the card's old image is back. |
189
+
190
+ ## Exposed
191
+
192
+ Through a template ref:
193
+
194
+ | Member | Description |
195
+ | -------------------- | --------------------------------------------------------------------------------------------------------------------------- |
196
+ | `ready` | CodeMirror has loaded. |
197
+ | `active` | Formatting at the cursor, a `Set` of command names. |
198
+ | `canUpload` | `upload` is set. |
199
+ | `canUndo`, `canRedo` | |
200
+ | `uploading` | Uploads in progress. Save when it's `0`. |
201
+ | `run(command)` | Applies a [command](/components/toolbar#commands). `image` opens the file picker with `upload`, else inserts an empty card. |
202
+ | `insert(text)` | Replaces the selection. |
203
+ | `insertFiles(files)` | Uploads and inserts files at the cursor. |
204
+ | `focus()` | |
205
+ | `view()` | The CodeMirror `EditorView`, for anything else. |
206
+
207
+ ## Keyboard
208
+
209
+ `Mod` is Ctrl, or ⌘ on a Mac.
210
+
211
+ | Keys | Description |
212
+ | ------------------------------- | ------------------------------------------------------------ |
213
+ | `Mod+B` `Mod+I` `Mod+E` `Mod+K` | Bold, italic, code, link |
214
+ | `Mod+Shift+X` | Strikethrough |
215
+ | `Mod+Alt+1` … `3` | Heading 1–3 |
216
+ | `Mod+Shift+7` `8` `9` | Numbered, bulleted, task list |
217
+ | `Mod+Alt+F` | Footnote |
218
+ | `Mod+Z` `Mod+Shift+Z` | Undo, redo |
219
+ | `Enter` | New paragraph (in a quote, inside it); in a list, a new item |
220
+ | `Shift+Enter` | Line break inside the paragraph (`\` at the line end) |
221
+ | `/` on an empty line | Block menu |
222
+ | `Mod+]` `Mod+[` | Indent, outdent |
223
+
224
+ `Tab` leaves the editor, so keyboard users aren't trapped. Pasting a URL over a selection links it.
225
+
226
+ ## Uploads
227
+
228
+ While a file uploads, the Markdown holds an `#upload-…` placeholder where its URL will go, and `uploading` counts what's in flight. Wait for `0` before saving: the URL landing changes the Markdown, so a save-on-change runs again by itself. A placeholder saved anyway renders nothing, and in the editor it's an empty card to fill again.
229
+
230
+ ## Loading another document
231
+
232
+ Change the editor's `key`. An outside `v-model` change is applied as an edit, keeping undo history; a new document should start fresh.
233
+
234
+ ## Server rendering
235
+
236
+ The server renders the content as it will read (a `<textarea>` in source mode). CodeMirror loads in the browser and takes over, keeping anything typed before it did. Pages without an editor never load CodeMirror.
@@ -0,0 +1,146 @@
1
+ # Toolbar
2
+
3
+ > Formatting buttons for an editor.
4
+
5
+ `<WriterToolbar>` formats an editor: pass it the editor's template ref. In plain Vue, import `WriterToolbar`.
6
+
7
+ ## Examples
8
+
9
+ ### Basic
10
+
11
+ ```vue
12
+ <script setup lang="ts">
13
+ const body = ref("Select some text, then format it.");
14
+ const editor = useTemplateRef("editor");
15
+ </script>
16
+
17
+ <template>
18
+ <div class="writer-demo">
19
+ <WriterToolbar
20
+ :editor="editor"
21
+ :items="[
22
+ 'heading2',
23
+ 'bold',
24
+ 'italic',
25
+ 'strikethrough',
26
+ 'link',
27
+ 'bulletList',
28
+ 'taskList',
29
+ 'undo',
30
+ 'redo',
31
+ ]"
32
+ />
33
+ <WriterEditor ref="editor" v-model="body" label="Body" />
34
+ </div>
35
+ </template>
36
+ ```
37
+
38
+ ### Every command
39
+
40
+ Try each one on an empty line, in the middle of a line and on a selection. Blocks (tables, dividers, images, code) get blank lines around them, so they never join the text next to them.
41
+
42
+ ```vue
43
+ <script setup lang="ts">
44
+ import type { CommandName } from "@humanonlyweb/writer";
45
+
46
+ // Every command. Try each one on an empty line, in the middle of a line, and on a
47
+ // selection: the cursor should always land where the next word goes.
48
+ const items: CommandName[] = [
49
+ "heading1",
50
+ "heading2",
51
+ "heading3",
52
+ "bold",
53
+ "italic",
54
+ "strikethrough",
55
+ "code",
56
+ "link",
57
+ "quote",
58
+ "bulletList",
59
+ "orderedList",
60
+ "taskList",
61
+ "codeBlock",
62
+ "table",
63
+ "divider",
64
+ "image",
65
+ "footnote",
66
+ "undo",
67
+ "redo",
68
+ ];
69
+
70
+ const body = ref("A line to format.\n\n");
71
+ const editor = useTemplateRef("editor");
72
+ const mode = ref<"live" | "source">("live");
73
+ </script>
74
+
75
+ <template>
76
+ <div class="writer-demo">
77
+ <div class="writer-demo-bar">
78
+ <WriterToolbar :editor="editor" :items="items" />
79
+ <button
80
+ type="button"
81
+ class="writer-demo-toggle"
82
+ :aria-pressed="mode === 'source'"
83
+ @click="mode = mode === 'source' ? 'live' : 'source'"
84
+ >
85
+ Markdown
86
+ </button>
87
+ </div>
88
+ <WriterEditor ref="editor" v-model="body" :mode="mode" label="Body" />
89
+ </div>
90
+ </template>
91
+ ```
92
+
93
+ ### Icons
94
+
95
+ The `item` slot replaces a button's content. Its label stays the accessible name.
96
+
97
+ ```vue
98
+ <script setup lang="ts">
99
+ const body = ref("Icons instead of words; the names stay for screen readers.");
100
+ const editor = useTemplateRef("editor");
101
+ const icons = {
102
+ bold: "bold",
103
+ italic: "italic",
104
+ link: "link",
105
+ quote: "quote",
106
+ image: "image",
107
+ } as const;
108
+ </script>
109
+
110
+ <template>
111
+ <div class="writer-demo">
112
+ <WriterToolbar :editor="editor" :items="Object.keys(icons) as (keyof typeof icons)[]">
113
+ <template #item="{ command }">
114
+ <Icon :name="icons[command as keyof typeof icons]" />
115
+ </template>
116
+ </WriterToolbar>
117
+ <WriterEditor ref="editor" v-model="body" label="Body" />
118
+ </div>
119
+ </template>
120
+ ```
121
+
122
+ ## Props
123
+
124
+ | Prop | Type | Description |
125
+ | -------- | --------------- | ----------------------------------------------------------------------------------------------------- |
126
+ | `editor` | editor ref | The `<WriterEditor>` to format: pass its template ref. |
127
+ | `items` | `CommandName[]` | Commands, in order. Default: headings 2–3, bold, italic, link, code, quote, lists, code block, image. |
128
+ | `label` | `string` | Accessible name. Default: "Formatting". |
129
+
130
+ ## Slots
131
+
132
+ | Slot | Props | Description |
133
+ | ------ | ---------------------------- | --------------------------------- |
134
+ | `item` | `{ command, label, active }` | A button's content, e.g. an icon. |
135
+
136
+ ## Commands
137
+
138
+ `bold`, `italic`, `strikethrough`, `code`, `link`, `heading1`, `heading2`, `heading3`, `quote`, `bulletList`, `orderedList`, `taskList`, `codeBlock`, `table`, `divider`, `image`, `footnote`, `undo`, `redo`.
139
+
140
+ Headings, quotes and lists replace each other on a line, and the cursor ends after their marks. Italic writes `*`, which works inside a word; spaces at a selection's edges stay outside the marks. `image` opens the file picker when the editor has `upload`, and otherwise inserts an empty image card.
141
+
142
+ For a different toolbar entirely, call the editor's `run(command)` yourself. `ToolbarEditor` is the type of what the toolbar needs from an editor.
143
+
144
+ ## Accessibility
145
+
146
+ `role="toolbar"`, with one tab stop: arrow keys, Home and End move between buttons. Formatting buttons show `aria-pressed`; `undo` and `redo` are `aria-disabled` when there's nothing to undo or redo. Buttons don't take focus from the editor.
@@ -0,0 +1,80 @@
1
+ # Images
2
+
3
+ > Images, figures and uploads.
4
+
5
+ ## In Markdown
6
+
7
+ Plain Markdown, no block needed: `![Alt text](/cat.png)`. Alone in its paragraph with a title, it becomes a figure:
8
+
9
+ ```md
10
+ ![A cat on a sofa](/cat.png "Our cat, 2026")
11
+ ```
12
+
13
+ ```html
14
+ <figure>
15
+ <img src="/cat.png" alt="A cat on a sofa" loading="lazy" decoding="async" />
16
+ <figcaption>Our cat, 2026</figcaption>
17
+ </figure>
18
+ ```
19
+
20
+ Size it with attributes so the page doesn't shift: `![Alt](/cat.png){width="800" height="600"}`. Uploads add them for you.
21
+
22
+ - `data:image/…` URLs work, for images only.
23
+ - An image without a URL (`![]()`) doesn't render. In the editor it's an empty card to fill.
24
+ - For responsive images or a CDN, replace `img` through `components`, e.g. `{ img: "NuxtImg" }`.
25
+
26
+ ## In the editor
27
+
28
+ Images on their own line are cards: the picture, its caption and its alt text, edited in place. Arrowing onto a card selects it; Backspace or Delete removes it, Enter adds a paragraph after it. A card never turns back into Markdown; switch to source mode for that.
29
+
30
+ ## Uploads
31
+
32
+ Give the editor an `upload` function: it gets the `File` and resolves to its URL.
33
+
34
+ ```ts
35
+ async function upload(file: File) {
36
+ const body = new FormData();
37
+ body.append("file", file);
38
+ const { url } = await $fetch<{ url: string }>("/api/uploads", { method: "POST", body });
39
+ return url;
40
+ }
41
+ ```
42
+
43
+ While it uploads, the card shows the local file at its real size, so nothing moves when the URL arrives. Several files upload side by side, in order. A failed upload fires `upload-error` and removes its placeholder, or puts a replaced card back the way it was.
44
+
45
+ On the server, check what you're given: the file type by its first bytes, not its name, and a size limit. Don't accept SVG on your own origin: it can run script.
46
+
47
+ ```vue
48
+ <script setup lang="ts">
49
+ const body = ref("Drop, paste or choose an image:\n\n![]()\n");
50
+ const editor = useTemplateRef("editor");
51
+ const error = ref("");
52
+
53
+ // Your endpoint stores the file and answers with its URL. Here: the image inlined,
54
+ // after a moment, so you can see it upload.
55
+ async function upload(file: File) {
56
+ await new Promise((resolve) => setTimeout(resolve, 1500));
57
+ return new Promise<string>((resolve) => {
58
+ const reader = new FileReader();
59
+ reader.addEventListener("load", () => resolve(String(reader.result)));
60
+ reader.readAsDataURL(file);
61
+ });
62
+ }
63
+ </script>
64
+
65
+ <template>
66
+ <div class="writer-demo">
67
+ <WriterToolbar :editor="editor" :items="['bold', 'italic', 'image']" />
68
+ <WriterEditor
69
+ ref="editor"
70
+ v-model="body"
71
+ label="Body"
72
+ :upload="upload"
73
+ @upload-error="(_, file) => (error = `Couldn't upload ${file.name}.`)"
74
+ />
75
+ <p class="writer-demo-stats">
76
+ {{ error || (editor?.uploading ? "Uploading…" : "Ready to save") }}
77
+ </p>
78
+ </div>
79
+ </template>
80
+ ```
@@ -0,0 +1,86 @@
1
+ # Introduction
2
+
3
+ > A Markdown editor and renderer for Vue 3 and Nuxt.
4
+
5
+ Authors write Markdown, but it reads like the published page: formatting marks tuck away, blocks render as your own components, and images are cards with their caption and alt text. Readers get the same Markdown rendered by the same components, server-side.
6
+
7
+ ```vue
8
+ <script setup lang="ts">
9
+ import { countWords, readingMinutes } from "@humanonlyweb/writer";
10
+
11
+ const body =
12
+ ref(`City council voted 7–2 on Tuesday to approve this winter's snow-clearing budget, which officials describe as "ambitious, in a spiritual sense."
13
+
14
+ ::callout{type="note"}
15
+ The **full budget** is available at city hall, between 2:00 and 2:05 p.m.
16
+ ::
17
+
18
+ ## What residents can do
19
+
20
+ - Shovel early, shovel often
21
+ - [x] Buy salt
22
+ - [ ] Lower expectations
23
+
24
+ > "It's not a plan, it's a vibe," said one resident.
25
+
26
+ ![A snowy street](https://picsum.photos/id/1036/900/360 "Cul-de-sac, February. Artist's impression."){width="900" height="360"}
27
+
28
+ Drop a photo of your street below, or choose one:
29
+
30
+ ![]()
31
+ `);
32
+
33
+ const editor = useTemplateRef("editor");
34
+ const mode = ref<"live" | "source">("live");
35
+ const icons = {
36
+ heading2: "heading",
37
+ bold: "bold",
38
+ italic: "italic",
39
+ link: "link",
40
+ quote: "quote",
41
+ bulletList: "list",
42
+ image: "image",
43
+ } as const;
44
+ const words = computed(() => countWords(body.value));
45
+
46
+ // A stand-in for your upload endpoint: the image, inlined, after a moment.
47
+ async function upload(file: File) {
48
+ await new Promise((resolve) => setTimeout(resolve, 1500));
49
+ return new Promise<string>((resolve) => {
50
+ const reader = new FileReader();
51
+ reader.addEventListener("load", () => resolve(String(reader.result)));
52
+ reader.readAsDataURL(file);
53
+ });
54
+ }
55
+ </script>
56
+
57
+ <template>
58
+ <div class="writer-demo">
59
+ <div class="writer-demo-bar">
60
+ <WriterToolbar :editor="editor" :items="Object.keys(icons) as (keyof typeof icons)[]">
61
+ <template #item="{ command }">
62
+ <Icon :name="icons[command as keyof typeof icons]" />
63
+ </template>
64
+ </WriterToolbar>
65
+ <button
66
+ type="button"
67
+ class="writer-demo-toggle"
68
+ :aria-pressed="mode === 'source'"
69
+ @click="mode = mode === 'source' ? 'live' : 'source'"
70
+ >
71
+ Markdown
72
+ </button>
73
+ </div>
74
+ <WriterEditor ref="editor" v-model="body" :mode="mode" label="Article" :upload="upload" />
75
+ <p class="writer-demo-stats">{{ words }} words · {{ readingMinutes(words) }} min read</p>
76
+ </div>
77
+ </template>
78
+ ```
79
+
80
+ - **Markdown is the source of truth.** Store it, diff it, edit it anywhere.
81
+ - **Blocks are your Vue components.** `::callout` renders `Callout.vue`, in the editor and on the page.
82
+ - **Fast pages.** Parse on save and render the stored document: visitors download neither the parser nor the editor.
83
+ - **Safe by default.** Raw HTML is text, and only Markdown's own elements and your blocks render.
84
+ - **SSR, accessible, unstyled.** Works with server rendering, follows the ARIA patterns, and takes your site's CSS.
85
+
86
+ Built on [CodeMirror 6](https://codemirror.net) and [Comark](https://comark.dev).
@@ -0,0 +1,74 @@
1
+ # Installation
2
+
3
+ > Nuxt module or Vue plugin.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ bun add @humanonlyweb/writer
9
+ ```
10
+
11
+ ## Nuxt
12
+
13
+ The components are auto-imported, `core.css` is added, and every component in `components/blocks/` becomes a block.
14
+
15
+ ```ts
16
+ // nuxt.config.ts
17
+ export default defineNuxtConfig({
18
+ modules: ["@humanonlyweb/writer/nuxt"],
19
+ writer: {
20
+ blocks: "blocks", // folder in components/; false for none
21
+ components: { a: "NuxtLink" }, // render native elements with your components
22
+ css: true, // inject core.css
23
+ parser: { highlight: true }, // see Parsing
24
+ },
25
+ });
26
+ ```
27
+
28
+ On the server, `parseWriterDocument`, `writerParserVersion` and `countWords` are auto-imported.
29
+
30
+ ## Vue
31
+
32
+ ```ts
33
+ import { createWriter } from "@humanonlyweb/writer";
34
+ import "@humanonlyweb/writer/core.css";
35
+
36
+ createApp(App)
37
+ .use(createWriter({ blocks: { callout: Callout }, components: { a: RouterLink } }))
38
+ .mount("#app");
39
+ ```
40
+
41
+ | Option | What it does |
42
+ | -------------- | -------------------------------------------------------------------------------------------------- |
43
+ | `blocks` | Components authors can use, by Markdown name: `{ callout }` is `::callout`. See [Blocks](/blocks). |
44
+ | `components` | Native elements to render with your components, e.g. `{ a: RouterLink, img: AppImage }`. |
45
+ | `parser` | [Parser options](/parsing) for Markdown parsed in the browser. |
46
+ | `translations` | The built-in text. See [Localisation](/localisation). |
47
+
48
+ `useWriterConfig()` reads the config in your own components, and `WRITER_CONFIG_KEY` provides one yourself.
49
+
50
+ ## Use it
51
+
52
+ ```vue
53
+ <script setup lang="ts">
54
+ const body = ref("");
55
+ const editor = useTemplateRef("editor");
56
+ </script>
57
+
58
+ <template>
59
+ <WriterToolbar :editor="editor" />
60
+ <WriterEditor ref="editor" v-model="body" label="Post body" />
61
+ <WriterContent :value="body" />
62
+ </template>
63
+ ```
64
+
65
+ In plain Vue, import `WriterEditor`, `WriterToolbar` and `WriterContent` from `@humanonlyweb/writer`.
66
+
67
+ ## AI agents
68
+
69
+ The package ships these docs as Markdown, matching the installed version. Point your agent at them in `AGENTS.md` or `CLAUDE.md`:
70
+
71
+ ```md
72
+ For @humanonlyweb/writer, read node_modules/@humanonlyweb/writer/dist/docs/README.md
73
+ before using it. It indexes a page per topic: components, parsing, storing documents.
74
+ ```
@@ -0,0 +1,11 @@
1
+ # Limitations
2
+
3
+ > What it doesn't do yet.
4
+
5
+ - **Live preview** renders blocks and images on their own line. Tables, footnote references and inline images stay Markdown. A block still being typed (no closing `::`) stays Markdown until it's closed.
6
+ - **Indented content** (four spaces in, outside a block) stays Markdown: it's code, or deeply nested list content.
7
+ - **Blocks in the editor** render through the app, not the page: they get app-level plugins and `provide`s, but nothing a parent of `<WriterEditor>` provides.
8
+ - **Footnotes inside a block** are numbered within that block in the editor; the page numbers them across the document.
9
+ - **An empty image card** is 16:9 until a file is chosen.
10
+ - **Chinese, Japanese and Korean input** (IME composition) hasn't been tested by hand yet.
11
+ - **Tested** in Chromium, Firefox and WebKit, automatically. Touch devices and screen readers haven't been tested by hand yet.
@@ -0,0 +1,35 @@
1
+ # Localisation
2
+
3
+ > Every string the components show or announce.
4
+
5
+ Pass only what you change. In Nuxt, use `app.config.ts`:
6
+
7
+ ```ts
8
+ export default defineAppConfig({
9
+ writer: {
10
+ translations: { editor: "Éditeur", commands: { bold: "Gras" } },
11
+ },
12
+ });
13
+ ```
14
+
15
+ In Vue, `createWriter({ translations })`. A ref keeps it live, e.g. when the reader switches language.
16
+
17
+ | Key | Default |
18
+ | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
19
+ | `editor` | Markdown editor |
20
+ | `toolbar` | Formatting |
21
+ | `commands` | A label per command: Bold, Italic, Strikethrough, Code, Link, Heading 1–3, Quote, Bulleted list, Numbered list, Task list, Code block, Table, Divider, Image, Footnote, Undo, Redo |
22
+ | `task` | Task (a task checkbox's name before it has text) |
23
+ | `imageAlt` | Alt text |
24
+ | `imageAltHint` | Describe the image for people who can't see it |
25
+ | `imageCaption` | Add a caption |
26
+ | `imageDrop` | Drop an image here, or |
27
+ | `imageChoose` | Choose an image |
28
+ | `imageUrl` | Image URL |
29
+ | `imageReplace` | Replace |
30
+ | `imageRemove` | Remove |
31
+ | `imageUploading` | Uploading… |
32
+
33
+ `defaultTranslations` has them all; `useTranslations()` gives the resolved set.
34
+
35
+ Each line takes its own text direction, so right-to-left and mixed text work.