@humanonlyweb/writer 0.2.1 → 0.2.2

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.
@@ -1,3 +1,5 @@
1
+ import { ParserOptions } from "../parser-options.js";
2
+ import "../parse.js";
1
3
  import { Component, PropType } from "vue";
2
4
  import { MarkdownDocument } from "comark";
3
5
  /**
@@ -10,11 +12,26 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
10
12
  type: PropType<string | MarkdownDocument>;
11
13
  default: string;
12
14
  };
15
+ /** Merged over the app's `blocks` for this render. */
16
+ blocks: {
17
+ type: PropType<Record<string, Component>>;
18
+ default: undefined;
19
+ };
13
20
  /** Merged over the app's `components` for this render. */
14
21
  components: {
15
22
  type: PropType<Record<string, Component>>;
16
23
  default: undefined;
17
24
  };
25
+ /** Parser options for this render. Defaults to the app's `parser`. */
26
+ parser: {
27
+ type: PropType<ParserOptions>;
28
+ default: undefined;
29
+ };
30
+ /** Extra data exposed as `data` for `:prop="data.key"` bindings. */
31
+ data: {
32
+ type: PropType<Record<string, unknown>>;
33
+ default: undefined;
34
+ };
18
35
  /** Milliseconds to wait after the Markdown changes before parsing again. Use ~100 for live previews of long documents. */
19
36
  debounce: {
20
37
  type: NumberConstructor;
@@ -33,11 +50,26 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
33
50
  type: PropType<string | MarkdownDocument>;
34
51
  default: string;
35
52
  };
53
+ /** Merged over the app's `blocks` for this render. */
54
+ blocks: {
55
+ type: PropType<Record<string, Component>>;
56
+ default: undefined;
57
+ };
36
58
  /** Merged over the app's `components` for this render. */
37
59
  components: {
38
60
  type: PropType<Record<string, Component>>;
39
61
  default: undefined;
40
62
  };
63
+ /** Parser options for this render. Defaults to the app's `parser`. */
64
+ parser: {
65
+ type: PropType<ParserOptions>;
66
+ default: undefined;
67
+ };
68
+ /** Extra data exposed as `data` for `:prop="data.key"` bindings. */
69
+ data: {
70
+ type: PropType<Record<string, unknown>>;
71
+ default: undefined;
72
+ };
41
73
  /** Milliseconds to wait after the Markdown changes before parsing again. Use ~100 for live previews of long documents. */
42
74
  debounce: {
43
75
  type: NumberConstructor;
@@ -49,8 +81,11 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
49
81
  default: string;
50
82
  };
51
83
  }>> & Readonly<{}>, {
84
+ blocks: Record<string, Component>;
52
85
  components: Record<string, Component>;
86
+ parser: ParserOptions;
53
87
  value: string | MarkdownDocument<Record<string, any>, Record<string, any>>;
88
+ data: Record<string, unknown>;
54
89
  debounce: number;
55
90
  tag: string;
56
91
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -1,7 +1,11 @@
1
1
  import { useWriterConfig } from "../config.js";
2
- import { loadParser } from "../load-parser.js";
2
+ import { loadParserEffect } from "../load-parser.js";
3
3
  import { renderDocument } from "../render.js";
4
- import { isMarkdownDocument } from "comark/utils";
4
+ import { isMarkdownDocument, kebabCase } from "comark/utils";
5
+ import * as Effect from "effect/Effect";
6
+ import * as Exit from "effect/Exit";
7
+ import * as Fiber from "effect/Fiber";
8
+ import * as Scope from "effect/Scope";
5
9
  import { Suspense, computed, defineComponent, h, onScopeDispose, shallowRef, watch } from "vue";
6
10
  // src/components/WriterContent.ts
7
11
  const EMPTY = {
@@ -10,8 +14,8 @@ const EMPTY = {
10
14
  meta: {}
11
15
  };
12
16
  /**
13
- * Parses `source`, then again whenever it changes: one parse at a time, always ending on
14
- * the latest. Its default slot renders the document.
17
+ * Parses `source`, then again whenever it changes: Effect fiber interruption cancels
18
+ * superseded debounces and stale parses, always settling on the latest source.
15
19
  */
16
20
  const ParsedContent = defineComponent({
17
21
  name: "WriterParsedContent",
@@ -31,34 +35,34 @@ const ParsedContent = defineComponent({
31
35
  },
32
36
  async setup(props, { slots }) {
33
37
  const document = shallowRef(EMPTY);
34
- let running;
35
- let queued = false;
36
- async function parseLatest() {
37
- queued = false;
38
- try {
39
- const parse = await loadParser(props.parser);
40
- document.value = await parse(props.source);
41
- } catch (error) {
42
- console.error("[writer] couldn't parse Markdown:", error);
43
- }
44
- if (queued) return parseLatest();
45
- }
46
- function update() {
47
- if (running) {
48
- queued = true;
49
- return running;
50
- }
51
- running = parseLatest().finally(() => running = void 0);
52
- return running;
38
+ const scope = Scope.makeUnsafe("parallel");
39
+ let activeFiber;
40
+ const parseSource = Effect.fnUntraced(function* (source, parserOptions, delay) {
41
+ if (delay > 0) yield* Effect.sleep(delay);
42
+ const parse = yield* loadParserEffect(parserOptions);
43
+ const parsed = yield* Effect.tryPromise({
44
+ try: () => parse(source),
45
+ catch: (error) => error
46
+ });
47
+ document.value = parsed;
48
+ }, Effect.catch((error) => Effect.sync(() => {
49
+ console.error("[writer] couldn't parse Markdown:", error);
50
+ })));
51
+ function schedule(delay) {
52
+ const previous = activeFiber;
53
+ const next = Effect.gen(function* () {
54
+ if (previous) yield* Fiber.interrupt(previous);
55
+ yield* parseSource(props.source, props.parser, delay);
56
+ });
57
+ activeFiber = Effect.runSync(Effect.forkIn(next, scope));
53
58
  }
54
- let timer;
55
- watch(() => props.source, () => {
56
- clearTimeout(timer);
57
- if (props.debounce > 0) timer = setTimeout(update, props.debounce);
58
- else update();
59
+ watch([() => props.source, () => props.parser], () => {
60
+ schedule(props.debounce);
59
61
  });
60
- onScopeDispose(() => clearTimeout(timer));
61
- await update();
62
+ onScopeDispose(() => {
63
+ Effect.runFork(Scope.close(scope, Exit.void));
64
+ });
65
+ await Effect.runPromise(parseSource(props.source, props.parser, 0));
62
66
  return () => slots.default?.(document.value);
63
67
  }
64
68
  });
@@ -74,11 +78,26 @@ var WriterContent_default = defineComponent({
74
78
  type: [String, Object],
75
79
  default: ""
76
80
  },
81
+ /** Merged over the app's `blocks` for this render. */
82
+ blocks: {
83
+ type: Object,
84
+ default: void 0
85
+ },
77
86
  /** Merged over the app's `components` for this render. */
78
87
  components: {
79
88
  type: Object,
80
89
  default: void 0
81
90
  },
91
+ /** Parser options for this render. Defaults to the app's `parser`. */
92
+ parser: {
93
+ type: Object,
94
+ default: void 0
95
+ },
96
+ /** Extra data exposed as `data` for `:prop="data.key"` bindings. */
97
+ data: {
98
+ type: Object,
99
+ default: void 0
100
+ },
82
101
  /** Milliseconds to wait after the Markdown changes before parsing again. Use ~100 for live previews of long documents. */
83
102
  debounce: {
84
103
  type: Number,
@@ -90,24 +109,50 @@ var WriterContent_default = defineComponent({
90
109
  default: "div"
91
110
  }
92
111
  },
93
- setup(props) {
112
+ setup(props, { slots }) {
94
113
  const config = useWriterConfig();
95
- const options = computed(() => ({
96
- blocks: Object.fromEntries(Object.entries(config.blocks).map(([name, block]) => [name, block.component])),
97
- components: {
98
- ...config.components,
99
- ...props.components
114
+ const baseBlocks = computed(() => {
115
+ const blocks = {};
116
+ const nodeBlocks = /* @__PURE__ */ new Set();
117
+ for (const [name, block] of Object.entries(config.blocks)) {
118
+ blocks[name] = block.component;
119
+ if (block.node) nodeBlocks.add(name);
120
+ }
121
+ return {
122
+ blocks,
123
+ nodeBlocks
124
+ };
125
+ });
126
+ const resolvedParser = computed(() => props.parser ?? config.parser);
127
+ const options = computed(() => {
128
+ let blocks = baseBlocks.value.blocks;
129
+ if (props.blocks) {
130
+ const merged = { ...blocks };
131
+ for (const [key, component] of Object.entries(props.blocks)) merged[kebabCase(key)] = component;
132
+ blocks = merged;
100
133
  }
101
- }));
134
+ return {
135
+ blocks,
136
+ components: props.components ? {
137
+ ...config.components,
138
+ ...props.components
139
+ } : config.components,
140
+ nodeBlocks: baseBlocks.value.nodeBlocks.size ? baseBlocks.value.nodeBlocks : void 0,
141
+ security: resolvedParser.value.security,
142
+ data: props.data
143
+ };
144
+ });
102
145
  const render = (document) => h(props.tag, { "data-part": "writer-content" }, renderDocument(document, options.value));
103
146
  return () => {
104
147
  const { value } = props;
105
148
  if (isMarkdownDocument(value)) return render(value);
106
- return h(Suspense, null, { default: () => h(ParsedContent, {
149
+ const suspenseSlots = { default: () => h(ParsedContent, {
107
150
  source: value,
108
- parser: config.parser,
151
+ parser: resolvedParser.value,
109
152
  debounce: props.debounce
110
- }, { default: render }) });
153
+ }, { default: render }) };
154
+ if (slots.fallback) suspenseSlots.fallback = () => slots.fallback?.();
155
+ return h(Suspense, null, suspenseSlots);
111
156
  };
112
157
  }
113
158
  });
@@ -1,7 +1,11 @@
1
1
  import { useTranslations, useWriterConfig } from "../config.js";
2
- import { loadParser } from "../load-parser.js";
2
+ import { loadParserEffect } from "../load-parser.js";
3
3
  import WriterContent_default from "./WriterContent.js";
4
+ import * as Effect from "effect/Effect";
5
+ import * as Exit from "effect/Exit";
6
+ import * as Scope from "effect/Scope";
4
7
  import { computed, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, getCurrentInstance, h, mergeModels, nextTick, onBeforeUnmount, onMounted, openBlock, render, renderSlot, shallowRef, unref, useModel, useSlots, useTemplateRef, watch } from "vue";
8
+ import * as Cache from "effect/Cache";
5
9
  // src/components/WriterEditor.vue
6
10
  const _hoisted_1 = [
7
11
  "data-mode",
@@ -26,6 +30,7 @@ const _hoisted_4 = ["hidden"];
26
30
  const _hoisted_5 = { "data-slot": "replace" };
27
31
  const _hoisted_6 = { "data-slot": "remove" };
28
32
  const _hoisted_7 = ["name", "value"];
33
+ const _hoisted_8 = ["accept"];
29
34
  const _sfc_main = /*@__PURE__*/ defineComponent({
30
35
  __name: "WriterEditor",
31
36
  props: /*@__PURE__*/ mergeModels({
@@ -37,6 +42,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
37
42
  readonly: { type: Boolean },
38
43
  mode: {},
39
44
  upload: { type: Function },
45
+ accept: {},
40
46
  links: { type: Function },
41
47
  codeLanguages: {},
42
48
  extensions: {}
@@ -57,14 +63,22 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
57
63
  const t = useTranslations();
58
64
  const config = useWriterConfig();
59
65
  const appContext = getCurrentInstance()?.appContext ?? null;
60
- const previews = /* @__PURE__ */ new Map();
66
+ const componentScope = Scope.makeUnsafe("parallel");
67
+ const previewCache = Effect.runSync(Cache.make({
68
+ capacity: 200,
69
+ lookup: (source) => Effect.gen(function* () {
70
+ const parse = yield* loadParserEffect(config.parser);
71
+ return yield* Effect.tryPromise({
72
+ try: () => parse(source),
73
+ catch: (error) => error
74
+ });
75
+ })
76
+ }));
77
+ const parseBlockPreview = Effect.fnUntraced(function* (source) {
78
+ return yield* Cache.get(previewCache, source).pipe(Effect.tapError(() => Cache.invalidate(previewCache, source)));
79
+ });
61
80
  const renderPreview = async (source, host) => {
62
- let document = previews.get(source);
63
- if (!document) {
64
- document = await (await loadParser(config.parser))(source);
65
- previews.set(source, document);
66
- if (previews.size > 200) previews.delete(previews.keys().next().value);
67
- }
81
+ const document = await Effect.runPromise(parseBlockPreview(source));
68
82
  const vnode = h(WriterContent_default, { value: document });
69
83
  vnode.appContext = appContext;
70
84
  render(vnode, host);
@@ -87,7 +101,6 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
87
101
  const uploading = shallowRef(0);
88
102
  const canRedo = shallowRef(false);
89
103
  let editor;
90
- let unmounted = false;
91
104
  const attributes = computed(() => {
92
105
  const result = {
93
106
  spellcheck: "true",
@@ -100,60 +113,76 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
100
113
  if (props.readonly) result["aria-readonly"] = "true";
101
114
  return result;
102
115
  });
103
- onMounted(async () => {
104
- const { createEditor } = await (editorCode ?? import("../editor/setup.js"));
105
- if (unmounted || !host.value) return;
106
- const textarea = fallback.value;
107
- const focused = !!textarea && document.activeElement === textarea;
108
- editor = createEditor({
109
- parent: host.value,
110
- doc: textarea?.value ?? model.value,
111
- selection: textarea && focused ? {
112
- anchor: textarea.selectionStart,
113
- head: textarea.selectionEnd
114
- } : void 0,
115
- attributes: attributes.value,
116
- placeholder: props.placeholder,
117
- readonly: props.readonly,
118
- preview: preview(),
119
- blocks: Object.entries(config.blocks).map(([name, block]) => ({
120
- name,
121
- label: block.label,
122
- snippet: block.snippet
123
- })),
124
- translations: t.value,
125
- codeLanguages: props.codeLanguages,
126
- extensions: props.extensions,
127
- upload: props.upload,
128
- imageIcons: {
129
- replace: slotIcon("replace"),
130
- remove: slotIcon("remove")
131
- },
132
- links: props.links,
133
- onChange: (doc) => model.value = doc,
134
- onState: (state) => {
135
- active.value = state.active;
136
- canUndo.value = state.undo;
137
- canRedo.value = state.redo;
138
- },
139
- onFocus: (value) => value ? emit("focus") : emit("blur"),
140
- onUploadError: (error, file) => emit("uploadError", error, file),
141
- onUploading: (count) => uploading.value = count
142
- });
143
- if (editor.getDoc() !== model.value) model.value = editor.getDoc();
144
- ready.value = true;
145
- await nextTick();
146
- editor.view.requestMeasure();
147
- if (focused) editor.view.focus();
116
+ onMounted(() => {
117
+ const mountEditor = Effect.gen(function* () {
118
+ const { createEditor } = yield* Effect.tryPromise({
119
+ try: () => editorCode ?? import("../editor/setup.js"),
120
+ catch: (error) => error
121
+ });
122
+ if (!host.value) return;
123
+ const textarea = fallback.value;
124
+ const focused = !!textarea && document.activeElement === textarea;
125
+ editor = createEditor({
126
+ parent: host.value,
127
+ doc: textarea?.value ?? model.value,
128
+ selection: textarea && focused ? {
129
+ anchor: textarea.selectionStart,
130
+ head: textarea.selectionEnd
131
+ } : void 0,
132
+ attributes: attributes.value,
133
+ placeholder: props.placeholder,
134
+ readonly: props.readonly,
135
+ preview: preview(),
136
+ blocks: Object.entries(config.blocks).map(([name, block]) => ({
137
+ name,
138
+ label: block.label,
139
+ snippet: block.snippet,
140
+ description: block.description,
141
+ keywords: block.keywords
142
+ })),
143
+ translations: t.value,
144
+ codeLanguages: props.codeLanguages,
145
+ extensions: props.extensions,
146
+ upload: props.upload,
147
+ accept: props.accept,
148
+ imageIcons: {
149
+ replace: slotIcon("replace"),
150
+ remove: slotIcon("remove")
151
+ },
152
+ links: props.links,
153
+ onChange: (doc) => model.value = doc,
154
+ onState: (state) => {
155
+ active.value = state.active;
156
+ canUndo.value = state.undo;
157
+ canRedo.value = state.redo;
158
+ },
159
+ onFocus: (value) => value ? emit("focus") : emit("blur"),
160
+ onUploadError: (error, file) => emit("uploadError", error, file),
161
+ onUploading: (count) => uploading.value = count
162
+ });
163
+ if (editor.getDoc() !== model.value) model.value = editor.getDoc();
164
+ ready.value = true;
165
+ yield* Effect.promise(() => nextTick());
166
+ editor.view.requestMeasure();
167
+ if (focused) editor.view.focus();
168
+ }).pipe(Effect.catch((error) => Effect.sync(() => {
169
+ console.error("[writer] couldn't load editor:", error);
170
+ })));
171
+ Effect.runSync(Effect.forkIn(mountEditor, componentScope));
148
172
  });
149
173
  onBeforeUnmount(() => {
150
- unmounted = true;
174
+ Effect.runFork(Scope.close(componentScope, Exit.void));
151
175
  editor?.destroy();
152
176
  });
153
177
  watch(model, (value) => editor?.setDoc(value ?? ""));
154
178
  watch(() => props.readonly, (value) => editor?.setReadonly(value));
155
179
  watch(attributes, (value) => editor?.setAttributes(value));
156
180
  watch(() => props.mode, () => editor?.setPreview(preview()));
181
+ watch(() => props.placeholder, (value) => editor?.setPlaceholder(value));
182
+ watch(t, (value) => editor?.setTranslations(value));
183
+ watch(() => props.upload, (value) => editor?.setUpload(value));
184
+ watch(() => props.accept, (value) => editor?.setAccept(value));
185
+ watch(() => props.links, (value) => editor?.setLinks(value));
157
186
  function onFallbackInput(event) {
158
187
  model.value = event.target.value;
159
188
  }
@@ -238,12 +267,12 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
238
267
  ref_key: "picker",
239
268
  ref: picker,
240
269
  type: "file",
241
- accept: "image/*",
270
+ accept: __props.accept ?? "image/*",
242
271
  multiple: "",
243
272
  hidden: "",
244
273
  tabindex: "-1",
245
274
  onChange: onPick
246
- }, null, 544)) : createCommentVNode("v-if", true)
275
+ }, null, 40, _hoisted_8)) : createCommentVNode("v-if", true)
247
276
  ], 8, _hoisted_1);
248
277
  };
249
278
  }
@@ -20,7 +20,9 @@ type __VLS_Props = {
20
20
  */
21
21
  mode?: "live" | "source";
22
22
  /** Uploads a pasted, dropped or picked file and resolves to its URL. Enables file insertion. */
23
- upload?: (file: File) => Promise<string>;
23
+ upload?: (file: File, signal?: AbortSignal) => Promise<string>;
24
+ /** Accepted file types for the file picker (e.g. `"image/*,.pdf"`). Defaults to `"image/*"`. */
25
+ accept?: string;
24
26
  /** Suggests link targets as the author types `](`, e.g. the site's pages matching `query`. */
25
27
  links?: (query: string) => LinkSuggestion[] | Promise<LinkSuggestion[]>;
26
28
  /** Languages for highlighting fenced code, e.g. `languages` from `@codemirror/language-data`. */
package/dist/config.d.ts CHANGED
@@ -1,17 +1,34 @@
1
- import { WriterTranslations, WriterTranslationsInput } from "./translations.js";
2
1
  import { ParserOptions } from "./parser-options.js";
3
2
  import "./parse.js";
4
- import { App, Component, ComputedRef, InjectionKey, Ref } from "vue";
3
+ import { WriterTranslations, WriterTranslationsInput } from "./translations.js";
4
+ import { Component, ComputedRef, InjectionKey, Plugin, Ref } from "vue";
5
5
  export interface WriterBlock {
6
6
  /** Rendered for `::name` in content. Receives the attributes as props and the body as slots. */
7
7
  component: Component;
8
8
  /** Slash menu entry. Defaults to the block name. */
9
9
  label?: string;
10
+ /** Optional secondary text in the slash menu. Defaults to `::name`. */
11
+ description?: string;
12
+ /** Extra words that match this block in the slash menu. */
13
+ keywords?: readonly string[];
10
14
  /**
11
15
  * Inserted from the slash menu, in CodeMirror snippet syntax: `${}` marks where the
12
16
  * cursor goes, `${name}` a field Tab moves to. Defaults to an empty block.
13
17
  */
14
18
  snippet?: string;
19
+ /**
20
+ * Pass the raw Comark AST node as `__node`. Required for async components (such as
21
+ * Nuxt-discovered blocks) whose `props` aren't visible before they load.
22
+ */
23
+ node?: boolean;
24
+ }
25
+ export interface ResolvedWriterBlock {
26
+ component: Component;
27
+ label: string;
28
+ snippet: string;
29
+ description?: string;
30
+ keywords?: readonly string[];
31
+ node?: boolean;
15
32
  }
16
33
  export interface WriterOptions {
17
34
  /** Components authors can use, keyed by their Markdown name: `{ callout }` for `::callout`. */
@@ -24,16 +41,14 @@ export interface WriterOptions {
24
41
  translations?: WriterTranslationsInput | Ref<WriterTranslationsInput>;
25
42
  }
26
43
  export interface WriterConfig {
27
- blocks: Readonly<Record<string, Required<WriterBlock>>>;
44
+ blocks: Readonly<Record<string, ResolvedWriterBlock>>;
28
45
  components: Readonly<Record<string, Component>>;
29
46
  parser: ParserOptions;
30
47
  translations: Ref<WriterTranslationsInput>;
31
48
  }
32
49
  export declare const WRITER_CONFIG_KEY: InjectionKey<WriterConfig>;
33
50
  /** `app.use(createWriter({ blocks }))`. Scoped to the app, so nothing leaks between SSR requests. */
34
- export declare function createWriter(options?: WriterOptions): {
35
- install(app: App): void;
36
- };
51
+ export declare function createWriter(options?: WriterOptions): Plugin;
37
52
  export declare function useWriterConfig(): WriterConfig;
38
53
  /** The built-in text: English, with the app's `translations` on top. */
39
54
  export declare function useTranslations(): ComputedRef<WriterTranslations>;
package/dist/config.js CHANGED
@@ -12,7 +12,10 @@ function resolveConfig(options = {}) {
12
12
  blocks[name] = {
13
13
  component: block.component,
14
14
  label: block.label ?? name,
15
- snippet: block.snippet ?? `::${name}\n\${}\n::`
15
+ snippet: block.snippet ?? `::${name}\n\${}\n::`,
16
+ description: block.description,
17
+ keywords: block.keywords,
18
+ node: block.node
16
19
  };
17
20
  }
18
21
  const { translations = {} } = options;
@@ -39,13 +39,18 @@ In Nuxt, every component in `components/blocks/` is a block: `Callout.vue` is `:
39
39
 
40
40
  In Vue, pass them to `createWriter({ blocks: { callout: Callout } })`.
41
41
 
42
- The slash menu's labels and snippets go in `app.config.ts` (or `{ component, label, snippet }` in Vue):
42
+ The slash menu's labels, descriptions, keywords and snippets go in `app.config.ts` (or `{ component, label, description, keywords, snippet, node }` in Vue):
43
43
 
44
44
  ```ts
45
45
  export default defineAppConfig({
46
46
  writer: {
47
47
  blocks: {
48
- callout: { label: "Callout", snippet: '::callout{type="${note}"}\n${}\n::' },
48
+ callout: {
49
+ label: "Callout",
50
+ description: "Highlighted note",
51
+ keywords: ["note", "tip"],
52
+ snippet: '::callout{type="${note}"}\n${}\n::',
53
+ },
49
54
  },
50
55
  },
51
56
  });
@@ -61,4 +66,4 @@ GitHub alerts (`> [!NOTE]`) render as a blockquote, or as your `note` block if y
61
66
 
62
67
  ## In the editor
63
68
 
64
- Blocks render inside the editor through the app, not the page around it: they get app-level plugins and `provide`s, but nothing provided by a parent of `<WriterEditor>`. Declare a `__node` prop to receive the block's raw node.
69
+ Blocks render inside the editor through the app, not the page around it: they get app-level plugins and `provide`s, but nothing provided by a parent of `<WriterEditor>`. Declare a `__node` prop to receive the block's raw node (for async Nuxt blocks, set `node: true` in `app.config.ts` so it is passed before the component resolves).
@@ -2,6 +2,11 @@
2
2
 
3
3
  > Changes in each release.
4
4
 
5
+ ## 0.2.2 (2026-12-01)
6
+
7
+ - fix: harden sanitization, optimize parsing/rendering, move async orchestration to Effect v4 (0.2.2)
8
+ - chore: update deps
9
+
5
10
  ## 0.2.1 (2026-11-23)
6
11
 
7
12
  - fix: bare domains (example.com, www.example.com) become links again, as before comark 0.9: linkify is registered as a plugin with fuzzyLink, replacing the deprecated linkify option (0.2.1)
@@ -31,14 +31,17 @@ A callout block.
31
31
 
32
32
  ## Props
33
33
 
34
- | Prop | Type | Description |
35
- | ------------ | ---------------------------- | -------------------------------------------------------------------- |
36
- | `value` | `string \| MarkdownDocument` | Markdown, or a document parsed ahead of time (no parser download). |
37
- | `components` | `Record<string, Component>` | Native element overrides for this render, e.g. `{ a: NuxtLink }`. |
38
- | `debounce` | `number` | Ms to wait before parsing changed Markdown again. ~100 for previews. |
39
- | `tag` | `string` | Wrapper element. Default `div`. |
40
-
41
- Give it a parsed document on public pages: they render without loading the parser. A string works anywhere, server rendering included, and loads the parser on demand.
34
+ | Prop | Type | Description |
35
+ | ------------ | ---------------------------- | --------------------------------------------------------------------------- |
36
+ | `value` | `string \| MarkdownDocument` | Markdown, or a document parsed ahead of time (no parser download). |
37
+ | `blocks` | `Record<string, Component>` | Extra or overridden blocks for this render, merged over the app's `blocks`. |
38
+ | `components` | `Record<string, Component>` | Native element overrides for this render, e.g. `{ a: NuxtLink }`. |
39
+ | `parser` | `ParserOptions` | Parser options for this render. Defaults to the app's `parser`. |
40
+ | `data` | `Record<string, unknown>` | Extra data exposed as `data` for `:prop="data.key"` bindings (sanitized). |
41
+ | `debounce` | `number` | Ms to wait before parsing changed Markdown again. ~100 for previews. |
42
+ | `tag` | `string` | Wrapper element. Default `div`. |
43
+
44
+ A `#fallback` slot renders while a Markdown string is being parsed on the client. Give it a parsed document on public pages: they render without loading the parser. A string works anywhere, server rendering included, and loads the parser on demand.
42
45
 
43
46
  ## What renders
44
47
 
@@ -164,20 +164,21 @@ The document is always Markdown, but it reads like the page:
164
164
 
165
165
  ## Props
166
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. |
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, signal?: AbortSignal) => Promise<string>` | Enables pasting, dropping and picking files. Resolve to the URL; `signal` aborts on unmount. |
178
+ | `accept` | `string` | Accepted file types for the file picker (e.g. `"image/*,.pdf"`). Default `"image/*"`. |
179
+ | `links` | `(query) => { label, url }[]` (or a promise) | Suggests link targets after `](`. |
180
+ | `codeLanguages` | `LanguageDescription[]` | Highlighting inside fenced code, e.g. `languages` from `@codemirror/language-data`. |
181
+ | `extensions` | `Extension` | Extra CodeMirror extensions. Read once, on mount. |
181
182
 
182
183
  ## Events
183
184