@astryx-vue/richtext 0.0.0-stage → 0.5.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,2 @@
1
+ import { a as RichTextMarkdownExtension, i as RichTextExtensionError, n as editorStateJSONToMarkdown, o as createRichTextExtension, r as markdownToEditorStateJSON, t as MarkdownSerializerOptions } from "./markdownSerializers-BLgqlNe3.js";
2
+ export { type MarkdownSerializerOptions, RichTextExtensionError, type RichTextMarkdownExtension, createRichTextExtension, editorStateJSONToMarkdown, markdownToEditorStateJSON };
@@ -0,0 +1,2 @@
1
+ import { a as createRichTextExtension, i as RichTextExtensionError, n as markdownToEditorStateJSON, t as editorStateJSONToMarkdown } from "./markdownSerializers-ByYsTuIA.js";
2
+ export { RichTextExtensionError, createRichTextExtension, editorStateJSONToMarkdown, markdownToEditorStateJSON };
@@ -0,0 +1,88 @@
1
+ import { Transformer } from "@lexical/markdown";
2
+ import { DecoratorNode, Klass, LexicalEditor, LexicalNode, TextNode } from "lexical";
3
+ import { MarkdownPluginEntry } from "@astryx-vue/core/Markdown/plugins";
4
+ //#region src/markdownExtensions.d.ts
5
+ declare const extensionPlugin: unique symbol;
6
+ /**
7
+ * One Markdown plugin adopted by RichText. Opaque: create it with
8
+ * `createRichTextExtension`, and pass it to the surfaces and serializers that
9
+ * should recognize the plugin's syntax.
10
+ */
11
+ interface RichTextMarkdownExtension {
12
+ /** The adopted plugin's name. */
13
+ readonly name: string;
14
+ readonly [extensionPlugin]: MarkdownPluginEntry;
15
+ }
16
+ /** Why RichText refused a plugin or a configuration (spec:AST-064 FR4, FR6). */
17
+ declare class RichTextExtensionError extends Error {
18
+ /** The plugin RichText refused, or that a configuration claims twice. */
19
+ readonly plugin: string;
20
+ /** What RichText cannot honor: `transform`, or what was claimed twice. */
21
+ readonly capability: string;
22
+ /** The transformer or second extension that claims the same thing. */
23
+ readonly claimant: string | null;
24
+ constructor(plugin: string, capability: string, claimant: string | null);
25
+ }
26
+ /**
27
+ * Adopts a Markdown plugin for RichText (spec:AST-064 FR1, FR4). RichText
28
+ * recognizes the plugin's syntax with core's parser and keeps each node's
29
+ * source; it never runs the plugin's immutable transform, so a plugin that
30
+ * declares one is refused with a `RichTextExtensionError` here, before any
31
+ * surface uses it.
32
+ *
33
+ * @example
34
+ * ```
35
+ * const mentions = createRichTextExtension(mentionsPlugin);
36
+ * markdownToEditorStateJSON(markdown, {extensions: [mentions]});
37
+ * ```
38
+ */
39
+ declare function createRichTextExtension(plugin: MarkdownPluginEntry): RichTextMarkdownExtension;
40
+ //#endregion
41
+ //#region src/markdownSerializers.d.ts
42
+ /** Options shared by the Markdown serializer helpers. */
43
+ interface MarkdownSerializerOptions {
44
+ /**
45
+ * Markdown transformers to use. Defaults to the editor's default set: the
46
+ * standard `@lexical/markdown` `TRANSFORMERS` plus GFM tables. Pass the same
47
+ * array you give `RichTextEditor`'s `transformers` prop so content
48
+ * round-trips consistently.
49
+ */
50
+ transformers?: ReadonlyArray<Transformer>;
51
+ /**
52
+ * Extra Lexical nodes to register beyond the default OSS set, mirroring the
53
+ * editor's `nodes` prop. Required for custom node types to serialize.
54
+ */
55
+ nodes?: ReadonlyArray<Klass<LexicalNode>>;
56
+ /**
57
+ * Markdown plugins to recognize, each adopted with `createRichTextExtension`
58
+ * (spec:AST-064). Their syntax becomes extension nodes holding its exact
59
+ * source; without them, plugin syntax stays text. Pass the same extensions
60
+ * the surfaces that show the document use.
61
+ */
62
+ extensions?: ReadonlyArray<RichTextMarkdownExtension>;
63
+ }
64
+ /**
65
+ * Convert a Markdown string to a serialized Lexical `EditorState` JSON string
66
+ * — the same shape `RichTextEditor`'s `defaultValue` expects. Runs headless
67
+ * (no DOM), so it is safe in Node / SSR.
68
+ *
69
+ * @example
70
+ * ```
71
+ * const value = markdownToEditorStateJSON('# Title\n\nHello');
72
+ * <RichTextEditor label="Notes" defaultValue={value} />
73
+ * ```
74
+ */
75
+ declare function markdownToEditorStateJSON(markdown: string, options?: MarkdownSerializerOptions): string;
76
+ /**
77
+ * Convert a serialized Lexical `EditorState` JSON string (e.g. the value
78
+ * produced by `RichTextEditor`'s `onChange` or `defaultValue`) to a Markdown
79
+ * string. Runs headless (no DOM), so it is safe in Node / SSR.
80
+ *
81
+ * @example
82
+ * ```
83
+ * const md = editorStateJSONToMarkdown(savedJson);
84
+ * ```
85
+ */
86
+ declare function editorStateJSONToMarkdown(editorStateJSON: string, options?: MarkdownSerializerOptions): string;
87
+ //#endregion
88
+ export { RichTextMarkdownExtension as a, RichTextExtensionError as i, editorStateJSONToMarkdown as n, createRichTextExtension as o, markdownToEditorStateJSON as r, MarkdownSerializerOptions as t };