@blue-patterns/richtext 0.0.0-stage → 0.7.18
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.
- package/CHANGELOG.md +275 -0
- package/LICENSE +22 -0
- package/README.md +88 -2
- package/astryx.integration.mjs +11 -0
- package/blocks/RichTextEditorShowcase.template.mjs +13 -0
- package/blocks/RichTextEditorShowcase.tsx +19 -0
- package/dist/RichTextEditor.d.ts +282 -0
- package/dist/RichTextEditor.d.ts.map +1 -0
- package/dist/RichTextEditor.js +657 -0
- package/dist/RichTextEditorAutoLinkPlugin.d.ts +83 -0
- package/dist/RichTextEditorAutoLinkPlugin.d.ts.map +1 -0
- package/dist/RichTextEditorAutoLinkPlugin.js +99 -0
- package/dist/RichTextEditorToolbar.d.ts +186 -0
- package/dist/RichTextEditorToolbar.d.ts.map +1 -0
- package/dist/RichTextEditorToolbar.js +688 -0
- package/dist/RichTextView.d.ts +92 -0
- package/dist/RichTextView.d.ts.map +1 -0
- package/dist/RichTextView.js +267 -0
- package/dist/codeLanguages.d.ts +14 -0
- package/dist/codeLanguages.d.ts.map +1 -0
- package/dist/codeLanguages.js +34 -0
- package/dist/codeLineTokens.d.ts +53 -0
- package/dist/codeLineTokens.d.ts.map +1 -0
- package/dist/codeLineTokens.js +188 -0
- package/dist/editorNodes.d.ts +8 -0
- package/dist/editorNodes.d.ts.map +1 -0
- package/dist/editorNodes.js +30 -0
- package/dist/editorTheme.d.ts +7 -0
- package/dist/editorTheme.d.ts.map +1 -0
- package/dist/editorTheme.js +328 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/internal/CodeBackspacePlugin.d.ts +2 -0
- package/dist/internal/CodeBackspacePlugin.d.ts.map +1 -0
- package/dist/internal/CodeBackspacePlugin.js +70 -0
- package/dist/internal/CodeBlockHeaderPlugin.d.ts +11 -0
- package/dist/internal/CodeBlockHeaderPlugin.d.ts.map +1 -0
- package/dist/internal/CodeBlockHeaderPlugin.js +204 -0
- package/dist/internal/CodePastePlugin.d.ts +5 -0
- package/dist/internal/CodePastePlugin.d.ts.map +1 -0
- package/dist/internal/CodePastePlugin.js +104 -0
- package/dist/internal/CodeSyntaxPlugin.d.ts +8 -0
- package/dist/internal/CodeSyntaxPlugin.d.ts.map +1 -0
- package/dist/internal/CodeSyntaxPlugin.js +397 -0
- package/dist/internal/CodeTabPlugin.d.ts +2 -0
- package/dist/internal/CodeTabPlugin.d.ts.map +1 -0
- package/dist/internal/CodeTabPlugin.js +256 -0
- package/dist/internal/DisabledLinkGuardPlugin.d.ts +4 -0
- package/dist/internal/DisabledLinkGuardPlugin.d.ts.map +1 -0
- package/dist/internal/DisabledLinkGuardPlugin.js +93 -0
- package/dist/internal/ImageSourceCaretPlugin.d.ts +3 -0
- package/dist/internal/ImageSourceCaretPlugin.d.ts.map +1 -0
- package/dist/internal/ImageSourceCaretPlugin.js +105 -0
- package/dist/internal/ListItemShortcutsPlugin.d.ts +6 -0
- package/dist/internal/ListItemShortcutsPlugin.d.ts.map +1 -0
- package/dist/internal/ListItemShortcutsPlugin.js +314 -0
- package/dist/internal/MarkdownExtensionsPlugin.d.ts +17 -0
- package/dist/internal/MarkdownExtensionsPlugin.d.ts.map +1 -0
- package/dist/internal/MarkdownExtensionsPlugin.js +185 -0
- package/dist/internal/SelectAllScopePlugin.d.ts +2 -0
- package/dist/internal/SelectAllScopePlugin.d.ts.map +1 -0
- package/dist/internal/SelectAllScopePlugin.js +67 -0
- package/dist/internal/TableColumnFloorPlugin.d.ts +12 -0
- package/dist/internal/TableColumnFloorPlugin.d.ts.map +1 -0
- package/dist/internal/TableColumnFloorPlugin.js +84 -0
- package/dist/internal/TablePastePlugin.d.ts +9 -0
- package/dist/internal/TablePastePlugin.d.ts.map +1 -0
- package/dist/internal/TablePastePlugin.js +183 -0
- package/dist/internal/TableScrollRegionPlugin.d.ts +9 -0
- package/dist/internal/TableScrollRegionPlugin.d.ts.map +1 -0
- package/dist/internal/TableScrollRegionPlugin.js +95 -0
- package/dist/internal/TaskCheckboxPlugin.d.ts +7 -0
- package/dist/internal/TaskCheckboxPlugin.d.ts.map +1 -0
- package/dist/internal/TaskCheckboxPlugin.js +193 -0
- package/dist/internal/ToolbarLinkPopover.d.ts +74 -0
- package/dist/internal/ToolbarLinkPopover.d.ts.map +1 -0
- package/dist/internal/ToolbarLinkPopover.js +292 -0
- package/dist/linkEditing.d.ts +6 -0
- package/dist/linkEditing.d.ts.map +1 -0
- package/dist/linkEditing.js +20 -0
- package/dist/linkForm.d.ts +28 -0
- package/dist/linkForm.d.ts.map +1 -0
- package/dist/linkForm.js +137 -0
- package/dist/linkUtils.d.ts +27 -0
- package/dist/linkUtils.d.ts.map +1 -0
- package/dist/linkUtils.js +101 -0
- package/dist/markdown.d.ts +17 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +17 -0
- package/dist/markdownCharacterReferences.d.ts +135 -0
- package/dist/markdownCharacterReferences.d.ts.map +1 -0
- package/dist/markdownCharacterReferences.js +1127 -0
- package/dist/markdownCodeFence.d.ts +4 -0
- package/dist/markdownCodeFence.d.ts.map +1 -0
- package/dist/markdownCodeFence.js +167 -0
- package/dist/markdownExtensionNode.d.ts +88 -0
- package/dist/markdownExtensionNode.d.ts.map +1 -0
- package/dist/markdownExtensionNode.js +248 -0
- package/dist/markdownExtensions.d.ts +115 -0
- package/dist/markdownExtensions.d.ts.map +1 -0
- package/dist/markdownExtensions.js +392 -0
- package/dist/markdownHardLineBreak.d.ts +25 -0
- package/dist/markdownHardLineBreak.d.ts.map +1 -0
- package/dist/markdownHardLineBreak.js +59 -0
- package/dist/markdownHeading.d.ts +20 -0
- package/dist/markdownHeading.d.ts.map +1 -0
- package/dist/markdownHeading.js +30 -0
- package/dist/markdownLink.d.ts +5 -0
- package/dist/markdownLink.d.ts.map +1 -0
- package/dist/markdownLink.js +80 -0
- package/dist/markdownListExport.d.ts +3 -0
- package/dist/markdownListExport.d.ts.map +1 -0
- package/dist/markdownListExport.js +68 -0
- package/dist/markdownListIndentation.d.ts +8 -0
- package/dist/markdownListIndentation.d.ts.map +1 -0
- package/dist/markdownListIndentation.js +101 -0
- package/dist/markdownOrderedList.d.ts +3 -0
- package/dist/markdownOrderedList.d.ts.map +1 -0
- package/dist/markdownOrderedList.js +51 -0
- package/dist/markdownQuote.d.ts +22 -0
- package/dist/markdownQuote.d.ts.map +1 -0
- package/dist/markdownQuote.js +32 -0
- package/dist/markdownSerializers.d.ts +49 -0
- package/dist/markdownSerializers.d.ts.map +1 -0
- package/dist/markdownSerializers.js +83 -0
- package/dist/markdownSource.d.ts +71 -0
- package/dist/markdownSource.d.ts.map +1 -0
- package/dist/markdownSource.js +804 -0
- package/dist/markdownSpaceRuns.d.ts +24 -0
- package/dist/markdownSpaceRuns.d.ts.map +1 -0
- package/dist/markdownSpaceRuns.js +147 -0
- package/dist/markdownTable.d.ts +35 -0
- package/dist/markdownTable.d.ts.map +1 -0
- package/dist/markdownTable.js +227 -0
- package/dist/markdownTaskList.d.ts +48 -0
- package/dist/markdownTaskList.d.ts.map +1 -0
- package/dist/markdownTaskList.js +166 -0
- package/dist/markdownThematicBreak.d.ts +3 -0
- package/dist/markdownThematicBreak.d.ts.map +1 -0
- package/dist/markdownThematicBreak.js +55 -0
- package/dist/privateAttributes/layerPortalBoundary.stylex.d.ts +12 -0
- package/dist/privateAttributes/layerPortalBoundary.stylex.d.ts.map +1 -0
- package/dist/privateAttributes/layerPortalBoundary.stylex.js +16 -0
- package/dist/richtext.css +213 -0
- package/dist/textSemantics.d.ts +3 -0
- package/dist/textSemantics.d.ts.map +1 -0
- package/dist/textSemantics.js +87 -0
- package/package.json +158 -3
- package/src/RichTextEditor.doc.mjs +308 -0
- package/src/RichTextEditor.tsx +1109 -0
- package/src/RichTextEditorAutoLinkPlugin.doc.mjs +43 -0
- package/src/RichTextEditorAutoLinkPlugin.tsx +126 -0
- package/src/RichTextEditorToolbar.doc.mjs +92 -0
- package/src/RichTextEditorToolbar.tsx +871 -0
- package/src/RichTextView.doc.mjs +101 -0
- package/src/RichTextView.tsx +351 -0
- package/src/codeLanguages.ts +42 -0
- package/src/codeLineTokens.ts +241 -0
- package/src/doc-mjs.d.ts +23 -0
- package/src/editorNodes.ts +44 -0
- package/src/editorTheme.ts +550 -0
- package/src/index.ts +59 -0
- package/src/internal/CodeBackspacePlugin.tsx +96 -0
- package/src/internal/CodeBlockHeaderPlugin.tsx +282 -0
- package/src/internal/CodePastePlugin.tsx +144 -0
- package/src/internal/CodeSyntaxPlugin.tsx +493 -0
- package/src/internal/CodeTabPlugin.tsx +298 -0
- package/src/internal/DisabledLinkGuardPlugin.tsx +93 -0
- package/src/internal/ImageSourceCaretPlugin.tsx +159 -0
- package/src/internal/ListItemShortcutsPlugin.tsx +404 -0
- package/src/internal/MarkdownExtensionsPlugin.tsx +289 -0
- package/src/internal/SelectAllScopePlugin.tsx +86 -0
- package/src/internal/TableColumnFloorPlugin.tsx +99 -0
- package/src/internal/TablePastePlugin.tsx +223 -0
- package/src/internal/TableScrollRegionPlugin.tsx +107 -0
- package/src/internal/TaskCheckboxPlugin.tsx +246 -0
- package/src/internal/ToolbarLinkPopover.tsx +392 -0
- package/src/linkEditing.ts +20 -0
- package/src/linkForm.tsx +156 -0
- package/src/linkUtils.ts +106 -0
- package/src/markdown.ts +25 -0
- package/src/markdownCharacterReferences.ts +1137 -0
- package/src/markdownCodeFence.ts +216 -0
- package/src/markdownExtensionNode.ts +339 -0
- package/src/markdownExtensions.ts +496 -0
- package/src/markdownHardLineBreak.ts +73 -0
- package/src/markdownHeading.ts +33 -0
- package/src/markdownLink.ts +86 -0
- package/src/markdownListExport.ts +85 -0
- package/src/markdownListIndentation.ts +105 -0
- package/src/markdownOrderedList.ts +60 -0
- package/src/markdownQuote.ts +35 -0
- package/src/markdownSerializers.ts +108 -0
- package/src/markdownSource.ts +1045 -0
- package/src/markdownSpaceRuns.ts +164 -0
- package/src/markdownTable.ts +309 -0
- package/src/markdownTaskList.ts +222 -0
- package/src/markdownThematicBreak.ts +66 -0
- package/src/privateAttributes/layerPortalBoundary.stylex.ts +18 -0
- package/src/textSemantics.ts +104 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file RichTextEditor.tsx
|
|
3
|
+
* @input Uses React, useId, a declared DOM boundary, Lexical (lexical + @lexical/react, composed through
|
|
4
|
+
* LexicalExtensionComposer), Field, VisuallyHidden, useInputStatusIcon,
|
|
5
|
+
* mergeProps, design tokens
|
|
6
|
+
* @output Exports an accessibly labelled RichTextEditor component with a flush
|
|
7
|
+
* top toolbar slot, configurable editable-surface minimum height, and distinct
|
|
8
|
+
* read-only and disabled states that follow prop changes, RichTextEditorProps,
|
|
9
|
+
* RichTextEditorStatus, RichTextEditorStatusType, RichTextEditorSize
|
|
10
|
+
* @position @blue-patterns/richtext implementation; consumed by the package index.ts and
|
|
11
|
+
* re-exported from @blue-patterns/richtext. Tested by RichTextEditor.test.tsx.
|
|
12
|
+
*
|
|
13
|
+
* SYNC: When modified, update these files to stay in sync:
|
|
14
|
+
* - /packages/richtext/src/RichTextEditor.doc.mjs (props table, features, implementation notes)
|
|
15
|
+
* - /packages/richtext/src/RichTextEditor.test.tsx (tests for new/changed behavior)
|
|
16
|
+
* - /packages/richtext/src/index.ts (exports if types change)
|
|
17
|
+
* - /apps/storybook/stories/RichTextEditor.stories.tsx (storybook stories)
|
|
18
|
+
*
|
|
19
|
+
* NOTE: `lexical` and `@lexical/*` are OPTIONAL peer dependencies — install them to
|
|
20
|
+
* use this component.
|
|
21
|
+
*/
|
|
22
|
+
import { type ReactNode, type Ref } from 'react';
|
|
23
|
+
import { type FieldStatusVariant } from '@blue-patterns/core/Field';
|
|
24
|
+
import type { BaseProps } from '@blue-patterns/core';
|
|
25
|
+
import { type SizeValue } from '@blue-patterns/core/utils';
|
|
26
|
+
import type { RichTextMarkdownExtension } from './markdownExtensions.js';
|
|
27
|
+
import type { CodeLanguage } from '@blue-patterns/core/CodeBlock';
|
|
28
|
+
import { type Transformer } from '@lexical/markdown';
|
|
29
|
+
import { type EditorState, type Klass, type LexicalEditor, type LexicalNode } from 'lexical';
|
|
30
|
+
export type RichTextEditorStatusType = 'warning' | 'error' | 'success';
|
|
31
|
+
export type RichTextEditorSize = 'sm' | 'md' | 'lg';
|
|
32
|
+
export interface RichTextEditorStatus {
|
|
33
|
+
/** The type of status to display. */
|
|
34
|
+
type: RichTextEditorStatusType;
|
|
35
|
+
/** Optional message to display below the editor. */
|
|
36
|
+
message?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Imperative handle exposed via `ref`. Lets callers focus, clear, and read the
|
|
40
|
+
* editor without wiring a custom plugin. Available after mount.
|
|
41
|
+
*/
|
|
42
|
+
export interface RichTextEditorRef {
|
|
43
|
+
/**
|
|
44
|
+
* Move focus into the editor's editable surface. No-op when the editor is
|
|
45
|
+
* read-only or disabled.
|
|
46
|
+
*/
|
|
47
|
+
focus: () => void;
|
|
48
|
+
/**
|
|
49
|
+
* Remove all content, resetting the editor to a single empty paragraph.
|
|
50
|
+
* No-op when the editor is read-only or disabled.
|
|
51
|
+
*/
|
|
52
|
+
clear: () => void;
|
|
53
|
+
/** Read the current `EditorState`. Serialize with `.toJSON()` to persist. */
|
|
54
|
+
getEditorState: () => EditorState;
|
|
55
|
+
/**
|
|
56
|
+
* Serialize the current content to a Markdown string, using the same
|
|
57
|
+
* `transformers` the editor is configured with (so custom transformers
|
|
58
|
+
* layered in via the `transformers` prop are honored). Content imported
|
|
59
|
+
* with `markdownToEditorStateJSON` comes back as written: blocks nobody
|
|
60
|
+
* changed byte for byte, and only edited or added blocks in canonical
|
|
61
|
+
* Markdown.
|
|
62
|
+
*/
|
|
63
|
+
getMarkdown: () => string;
|
|
64
|
+
/**
|
|
65
|
+
* Serialize the current content to an HTML string via
|
|
66
|
+
* `$generateHtmlFromNodes`. Requires a DOM (available in the browser and in
|
|
67
|
+
* jsdom-based tests). Useful for copy/paste, email, or non-Lexical consumers.
|
|
68
|
+
*/
|
|
69
|
+
getHTML: () => string;
|
|
70
|
+
/**
|
|
71
|
+
* Access the underlying `LexicalEditor` instance for advanced use cases
|
|
72
|
+
* (custom commands, listeners, node transforms).
|
|
73
|
+
*/
|
|
74
|
+
getEditor: () => LexicalEditor;
|
|
75
|
+
}
|
|
76
|
+
export interface RichTextEditorProps extends Omit<BaseProps, 'onChange' | 'defaultValue'> {
|
|
77
|
+
/**
|
|
78
|
+
* Imperative handle for callers that manage the editor from outside. In
|
|
79
|
+
* React 19 `ref` is an ordinary prop, so it is declared here rather than
|
|
80
|
+
* supplied by a `forwardRef` wrapper.
|
|
81
|
+
*/
|
|
82
|
+
ref?: Ref<RichTextEditorRef>;
|
|
83
|
+
/** Label text for the editor (always rendered for accessibility). */
|
|
84
|
+
label: string;
|
|
85
|
+
/**
|
|
86
|
+
* Whether to visually hide the label (still accessible to screen readers).
|
|
87
|
+
* @default false
|
|
88
|
+
*/
|
|
89
|
+
isLabelHidden?: boolean;
|
|
90
|
+
/** Description text displayed between the label and editor. */
|
|
91
|
+
description?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Whether the field is optional. Mutually exclusive with isRequired.
|
|
94
|
+
* @default false
|
|
95
|
+
*/
|
|
96
|
+
isOptional?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Whether the field is required. Mutually exclusive with isOptional.
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
isRequired?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Initial serialized editor state (a JSON string produced by
|
|
104
|
+
* `JSON.stringify(editorState.toJSON())`), used to seed the editor on mount.
|
|
105
|
+
* The editor is uncontrolled: this is read once.
|
|
106
|
+
*/
|
|
107
|
+
defaultValue?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Callback fired when the editor content changes. Receives the current
|
|
110
|
+
* `EditorState` and the `LexicalEditor` instance. Serialize with
|
|
111
|
+
* `editorState.toJSON()` for persistence.
|
|
112
|
+
*/
|
|
113
|
+
onChange?: (editorState: EditorState, editor: LexicalEditor) => void;
|
|
114
|
+
/** Placeholder text shown when the editor is empty. */
|
|
115
|
+
placeholder?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Whether the editor is read-only (non-editable). The content stays at full
|
|
118
|
+
* opacity, in the tab order, and announced as read-only, so people can still
|
|
119
|
+
* reach, read, and copy it. Takes effect when changed after mount.
|
|
120
|
+
* @default false
|
|
121
|
+
*/
|
|
122
|
+
isReadOnly?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Whether the editor is disabled: non-editable, dimmed, out of the tab
|
|
125
|
+
* order, and announced as disabled. Its links do not navigate and are not
|
|
126
|
+
* tab stops. Wins when `isReadOnly` is also set.
|
|
127
|
+
* Takes effect when changed after mount.
|
|
128
|
+
* @default false
|
|
129
|
+
*/
|
|
130
|
+
isDisabled?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Status indicator. When set, displays a colored border. If message is
|
|
133
|
+
* provided, displays a message box below the editor.
|
|
134
|
+
*/
|
|
135
|
+
status?: RichTextEditorStatus;
|
|
136
|
+
/**
|
|
137
|
+
* How the status message is placed relative to the editor.
|
|
138
|
+
* - 'attached': message overlaps directly below the editor and the status
|
|
139
|
+
* icon remains inside the editing surface
|
|
140
|
+
* - 'detached': message floats below with its own leading status icon
|
|
141
|
+
* - 'tooltip': no message box; the in-editor status icon becomes a focusable
|
|
142
|
+
* info-tip button that reveals the message
|
|
143
|
+
* @default 'attached'
|
|
144
|
+
*/
|
|
145
|
+
statusVariant?: FieldStatusVariant | 'tooltip';
|
|
146
|
+
/**
|
|
147
|
+
* Width of the field. Numbers are treated as pixels, strings are used as-is
|
|
148
|
+
* (e.g. `'100%'`).
|
|
149
|
+
*/
|
|
150
|
+
width?: SizeValue;
|
|
151
|
+
/**
|
|
152
|
+
* Minimum height of the editable content surface. Numbers are treated as
|
|
153
|
+
* pixels, strings are used as CSS lengths.
|
|
154
|
+
* @default '4.5rem'
|
|
155
|
+
*/
|
|
156
|
+
minHeight?: SizeValue;
|
|
157
|
+
/** Tooltip text to display in an info icon at the end of the label. */
|
|
158
|
+
labelTooltip?: string;
|
|
159
|
+
/**
|
|
160
|
+
* The size of the editor, affecting internal padding.
|
|
161
|
+
* @default 'md'
|
|
162
|
+
*/
|
|
163
|
+
size?: RichTextEditorSize;
|
|
164
|
+
/**
|
|
165
|
+
* Additional Lexical nodes to register beyond the default OSS set
|
|
166
|
+
* (Heading, Quote, List, Link, Code). Use this extension point to plug in
|
|
167
|
+
* custom nodes (e.g. mentions, images) without forking the editor.
|
|
168
|
+
*/
|
|
169
|
+
nodes?: ReadonlyArray<Klass<LexicalNode>>;
|
|
170
|
+
/**
|
|
171
|
+
* Toolbar content rendered edge-to-edge at the top of the field, before the
|
|
172
|
+
* padded editing surface. Pass `<RichTextEditorToolbar />` here so the
|
|
173
|
+
* toolbar stays inside the Lexical composer while retaining correct visual
|
|
174
|
+
* and keyboard order.
|
|
175
|
+
*/
|
|
176
|
+
toolbar?: ReactNode;
|
|
177
|
+
/**
|
|
178
|
+
* Additional Lexical plugins to render inside the composer. Use this to
|
|
179
|
+
* compose extra behaviour (mentions, autolink, etc.) on top of the base
|
|
180
|
+
* editor. Plugins receive the editor via `useLexicalComposerContext()`.
|
|
181
|
+
*/
|
|
182
|
+
plugins?: ReactNode;
|
|
183
|
+
/**
|
|
184
|
+
* Whether to enable Markdown shortcut typing (e.g. `# ` for a heading,
|
|
185
|
+
* `- ` for a list). Uses the `transformers` prop (defaults to the standard
|
|
186
|
+
* `@lexical/markdown` transformers plus GFM tables). At the start of a list
|
|
187
|
+
* item, `- `, `1. `, or `[ ] ` switches its list between bullets, numbers,
|
|
188
|
+
* and tasks, and `# ` or `> ` takes a top-level item out of its list as a
|
|
189
|
+
* heading or a quote.
|
|
190
|
+
* @default true
|
|
191
|
+
*/
|
|
192
|
+
hasMarkdownShortcuts?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Markdown transformers — the single source of truth for markdown behaviour.
|
|
195
|
+
* Defaults to the standard `@lexical/markdown` `TRANSFORMERS` plus GFM
|
|
196
|
+
* tables. A custom array replaces the default, tables included.
|
|
197
|
+
*
|
|
198
|
+
* The same array drives all three markdown operations in Lexical (see the
|
|
199
|
+
* lexical-playground reference, where one `PLAYGROUND_TRANSFORMERS` array
|
|
200
|
+
* feeds each):
|
|
201
|
+
* - shortcut typing — `registerMarkdownShortcuts` (wired here today)
|
|
202
|
+
* - markdown -> state — `$convertFromMarkdownString` (future import API)
|
|
203
|
+
* - state -> markdown — `$convertToMarkdownString` (future `getMarkdown`)
|
|
204
|
+
*
|
|
205
|
+
* Pass a custom array to support additional node types (e.g. custom
|
|
206
|
+
* transformers layered in via the `nodes` extension point) consistently
|
|
207
|
+
* across all three. Shortcut typing is only applied when
|
|
208
|
+
* `hasMarkdownShortcuts` is true; the array is still the intended input for
|
|
209
|
+
* the serialization APIs added in later phases.
|
|
210
|
+
*/
|
|
211
|
+
transformers?: ReadonlyArray<Transformer>;
|
|
212
|
+
/**
|
|
213
|
+
* Markdown plugins whose nodes this surface draws, each adopted with
|
|
214
|
+
* `createRichTextExtension` (spec:AST-064). A plugin node renders exactly as
|
|
215
|
+
* core `Markdown` renders it, and one whose plugin is not given here shows
|
|
216
|
+
* its source. Pass the extensions the content was converted with. Create
|
|
217
|
+
* them in a client module: they hold the plugins' functions, so they are not
|
|
218
|
+
* serializable props.
|
|
219
|
+
*/
|
|
220
|
+
markdownExtensions?: ReadonlyArray<RichTextMarkdownExtension>;
|
|
221
|
+
/**
|
|
222
|
+
* CodeBlock language values a fence may name, each imported on its own,
|
|
223
|
+
* such as `graphql` from `@blue-patterns/core/CodeBlock/languages/graphql`,
|
|
224
|
+
* or made with `createCodeLanguage`. Pass the same list as `Markdown`'s
|
|
225
|
+
* `codeLanguages`, so reading and editing paint and label the same
|
|
226
|
+
* languages (spec:AST-061).
|
|
227
|
+
*/
|
|
228
|
+
codeLanguages?: ReadonlyArray<CodeLanguage>;
|
|
229
|
+
/** Whether to automatically focus the editor on mount. @default false */
|
|
230
|
+
hasAutoFocus?: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Screen-reader hint describing how to move focus out of the editor, since
|
|
233
|
+
* Tab is bound to indentation (press Escape, then Tab). Rendered visually
|
|
234
|
+
* hidden and referenced from the editor's `aria-describedby`. Override it
|
|
235
|
+
* to change the text, or pass an empty string to omit the hint entirely
|
|
236
|
+
* (e.g. when the host app provides its own instructions).
|
|
237
|
+
* @default 'Press Escape then Tab to move focus out of the editor.', translated for the active locale
|
|
238
|
+
*/
|
|
239
|
+
tabEscapeHint?: string;
|
|
240
|
+
/**
|
|
241
|
+
* Maximum number of characters. When set, a character counter
|
|
242
|
+
* (current/max) is displayed below the editor. Like TextArea, this does
|
|
243
|
+
* NOT enforce the limit natively — the counter shows error styling when the
|
|
244
|
+
* plain-text length exceeds the limit. Count is the editor's plain-text
|
|
245
|
+
* content length.
|
|
246
|
+
*/
|
|
247
|
+
maxLength?: number;
|
|
248
|
+
/**
|
|
249
|
+
* The Lexical composer namespace, used for editor identity.
|
|
250
|
+
* @default 'astryx-editor'
|
|
251
|
+
*/
|
|
252
|
+
namespace?: string;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* A WYSIWYG rich-text editor built on Lexical, styled with Astryx design
|
|
256
|
+
* tokens. Ships from `@blue-patterns/richtext`. `lexical` and `@lexical/*` are
|
|
257
|
+
* optional peer dependencies — install them to use this component.
|
|
258
|
+
*
|
|
259
|
+
* The editor is intentionally minimal and extensible: pass `toolbar`, `nodes`,
|
|
260
|
+
* and `plugins` to layer richer behaviour (formatting, mentions, hover cards)
|
|
261
|
+
* on top without forking.
|
|
262
|
+
*
|
|
263
|
+
* The forwarded `RichTextEditorRef` exposes imperative `focus()` and `clear()`
|
|
264
|
+
* methods for callers that manage the editor from outside.
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```
|
|
268
|
+
* import {RichTextEditor, type RichTextEditorRef} from '@blue-patterns/richtext';
|
|
269
|
+
* const ref = useRef<RichTextEditorRef>(null);
|
|
270
|
+
* <RichTextEditor
|
|
271
|
+
* ref={ref}
|
|
272
|
+
* label="Notes"
|
|
273
|
+
* placeholder="Write something..."
|
|
274
|
+
* onChange={state => save(JSON.stringify(state.toJSON()))}
|
|
275
|
+
* />
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
export declare const RichTextEditor: {
|
|
279
|
+
({ label, isLabelHidden, description, isOptional, isRequired, defaultValue, onChange, placeholder, isReadOnly, isDisabled, status, statusVariant, width, minHeight, labelTooltip, size: sizeProp, nodes, toolbar, plugins, hasMarkdownShortcuts, transformers, markdownExtensions, codeLanguages, hasAutoFocus, tabEscapeHint: tabEscapeHintFromProps, maxLength, namespace, xstyle, className, style, ref, ...rest }: RichTextEditorProps): import("react").JSX.Element;
|
|
280
|
+
displayName: string;
|
|
281
|
+
};
|
|
282
|
+
//# sourceMappingURL=RichTextEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RichTextEditor.d.ts","sourceRoot":"","sources":["../src/RichTextEditor.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAOL,KAAK,SAAS,EACd,KAAK,GAAG,EACT,MAAM,OAAO,CAAC;AASf,OAAO,EAML,KAAK,kBAAkB,EACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAInD,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,2BAA2B,CAAC;AAyBnC,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAMhE,OAAO,EAAC,KAAK,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAKnD,OAAO,EASL,KAAK,WAAW,EAChB,KAAK,KAAK,EACV,KAA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