quoin-editor 0.1.0 → 0.2.0
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/README.md +245 -29
- package/dist/index.cjs +155 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +120 -5
- package/dist/index.d.ts +120 -5
- package/dist/index.js +137 -49
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +40 -11
package/dist/index.d.cts
CHANGED
|
@@ -87,9 +87,12 @@ declare function paletteBlocks(definitions: AnyBlockDefinition[]): AnyBlockDefin
|
|
|
87
87
|
/** Props for `BlockCanvas`; `blocks` and `onChange` are the whole document contract. */
|
|
88
88
|
type BlockCanvasProps = {
|
|
89
89
|
/**
|
|
90
|
-
* The document. Update it synchronously from `onChange`, as with a controlled `<input value onChange
|
|
91
|
-
*
|
|
92
|
-
*
|
|
90
|
+
* The document. Update it synchronously from `onChange`, as with a controlled `<input value onChange>`.
|
|
91
|
+
* Applying the edit late is tolerated as long as what comes back is one of the arrays the canvas emitted:
|
|
92
|
+
* it recognises its own output even several keystrokes behind, so a transition or a debounced setter is safe.
|
|
93
|
+
* A store that rebuilds the document on the way through hands back a structural copy instead, which arrives
|
|
94
|
+
* behind the canvas's own state and reads as a foreign document. That does not revert the edit cleanly: the
|
|
95
|
+
* characters the copy predates are dropped and the ones typed after them are kept.
|
|
93
96
|
* A new array that differs from the last one you supplied replaces what the canvas shows, which is how a host
|
|
94
97
|
* loads, undoes or merges. An array structurally equal to the last one you supplied is ignored, so a "discard
|
|
95
98
|
* changes" button that hands back the original document does nothing; remount the canvas with a React `key` to
|
|
@@ -99,6 +102,17 @@ type BlockCanvasProps = {
|
|
|
99
102
|
*/
|
|
100
103
|
blocks: QuoinBlock[];
|
|
101
104
|
onChange: (blocks: QuoinBlock[]) => void;
|
|
105
|
+
/**
|
|
106
|
+
* Called when a block is removed through its actions menu, with the block and the index it held.
|
|
107
|
+
* It runs just after the `onChange` that reports the document without it, so a host acting on the
|
|
108
|
+
* deletion is already looking at the new array. Restore the block by supplying a `blocks` array
|
|
109
|
+
* with it spliced back at that index, the same way any other document arrives.
|
|
110
|
+
*
|
|
111
|
+
* Restore it on a later tick or a later interaction, such as the click of an Undo toast. A
|
|
112
|
+
* restore applied synchronously inside this callback batches with the echo of the deletion, so
|
|
113
|
+
* what arrives is structurally equal to the document last supplied and is ignored.
|
|
114
|
+
*/
|
|
115
|
+
onDelete?: (block: QuoinBlock, index: number) => void;
|
|
102
116
|
/** Defaults to the five core block types. Pass `[...coreBlocks, yours]` to extend them. */
|
|
103
117
|
blockTypes?: AnyBlockDefinition[];
|
|
104
118
|
upload?: UploadFn;
|
|
@@ -113,11 +127,39 @@ type BlockCanvasProps = {
|
|
|
113
127
|
'aria-label'?: string;
|
|
114
128
|
};
|
|
115
129
|
/** The editor: renders `blocks`, reports every edit through `onChange`, and accepts a new `blocks` array from outside at any time. */
|
|
116
|
-
declare function BlockCanvas({ blocks, onChange, blockTypes, upload, resolveAssetUrl, onError, readOnly, className, id, 'aria-label': ariaLabel, }: BlockCanvasProps): React.JSX.Element;
|
|
130
|
+
declare function BlockCanvas({ blocks, onChange, onDelete, blockTypes, upload, resolveAssetUrl, onError, readOnly, className, id, 'aria-label': ariaLabel, }: BlockCanvasProps): React.JSX.Element;
|
|
117
131
|
|
|
118
132
|
/** The block types Quoin ships with. Spread them alongside your own definitions. */
|
|
119
133
|
declare const coreBlocks: AnyBlockDefinition[];
|
|
120
134
|
|
|
135
|
+
/** Props for `UploadField`; the upload function itself comes from the canvas, not from here. */
|
|
136
|
+
type UploadFieldProps = {
|
|
137
|
+
/** Names what the file is for, and is passed to the host's `upload` as its second argument. */
|
|
138
|
+
category: string;
|
|
139
|
+
/** Labels the control for both the pointer and assistive technology. */
|
|
140
|
+
label: string;
|
|
141
|
+
/** An `accept` attribute for the file input, such as `'image/*'` or `'.pdf'`. */
|
|
142
|
+
accept?: string;
|
|
143
|
+
/** Called once the upload resolves. Throwing from it is reported through the canvas `onError`. */
|
|
144
|
+
onUploaded: (result: UploadResult) => void;
|
|
145
|
+
};
|
|
146
|
+
/** A file picker wired to the canvas `upload` function, with its own busy state and inline error. */
|
|
147
|
+
declare function UploadField({ category, label, accept, onUploaded }: UploadFieldProps): React.JSX.Element;
|
|
148
|
+
|
|
149
|
+
/** Props for `FilePickerButton`. */
|
|
150
|
+
type FilePickerButtonProps = {
|
|
151
|
+
/** Labels the button and the file input behind it. */
|
|
152
|
+
label: string;
|
|
153
|
+
/** An `accept` attribute for the file input, such as `'image/*'` or `'.pdf'`. */
|
|
154
|
+
accept?: string;
|
|
155
|
+
/** Greys the button out and disables the input behind it. */
|
|
156
|
+
disabled?: boolean;
|
|
157
|
+
/** Called with the chosen file, and again if the same file is picked after a failure. */
|
|
158
|
+
onPick: (file: File) => void;
|
|
159
|
+
};
|
|
160
|
+
/** A button that opens the file picker and hands back the chosen file, performing no upload of its own. */
|
|
161
|
+
declare function FilePickerButton({ label, accept, disabled, onPick }: FilePickerButtonProps): React.JSX.Element;
|
|
162
|
+
|
|
121
163
|
/** The resolved canvas configuration every block editor reads through `useQuoin`. */
|
|
122
164
|
type QuoinConfig = {
|
|
123
165
|
blockTypes: AnyBlockDefinition[];
|
|
@@ -145,6 +187,7 @@ type BlockList = {
|
|
|
145
187
|
blocks: QuoinBlock[];
|
|
146
188
|
insertAt: (index: number, type: string, data?: Record<string, unknown>) => string;
|
|
147
189
|
update: (id: string, data: Record<string, unknown>) => void;
|
|
190
|
+
/** Returns a token `undo` restores that block with; only the last 20 removals stay restorable. */
|
|
148
191
|
remove: (id: string) => UndoToken;
|
|
149
192
|
undo: (token: UndoToken) => void;
|
|
150
193
|
move: (index: number, dir: -1 | 1) => void;
|
|
@@ -203,4 +246,76 @@ type TextCommand = {
|
|
|
203
246
|
/** The built-in slash-palette commands, in display order. */
|
|
204
247
|
declare const TEXT_COMMANDS: TextCommand[];
|
|
205
248
|
|
|
206
|
-
|
|
249
|
+
/** A text transform result: the next value and where the selection should land. */
|
|
250
|
+
type Edit = {
|
|
251
|
+
value: string;
|
|
252
|
+
selectionStart: number;
|
|
253
|
+
selectionEnd: number;
|
|
254
|
+
};
|
|
255
|
+
/** Applies an edit to a textarea through the native undo stack when the browser allows it, so Ctrl+Z still works. */
|
|
256
|
+
declare function applyEdit(el: HTMLTextAreaElement, edit: Edit, commit: (value: string) => void): void;
|
|
257
|
+
|
|
258
|
+
type Line = {
|
|
259
|
+
start: number;
|
|
260
|
+
end: number;
|
|
261
|
+
text: string;
|
|
262
|
+
};
|
|
263
|
+
/** The line containing the offset, with its start and end offsets and its text (no trailing newline). */
|
|
264
|
+
declare function lineAt(value: string, offset: number): Line;
|
|
265
|
+
|
|
266
|
+
/** A line-level markdown prefix: a heading level, a bullet or a numbered item. */
|
|
267
|
+
type LinePrefix = 'h1' | 'h2' | 'h3' | 'bullet' | 'ordered';
|
|
268
|
+
/** Adds the prefix to every line in the selection, or removes it when every line already carries it; fenced code is left alone. */
|
|
269
|
+
declare function toggleLinePrefix(kind: LinePrefix, value: string, selectionStart: number, selectionEnd: number): Edit;
|
|
270
|
+
|
|
271
|
+
/** Continues a list item on Enter, or climbs out of the list on an empty item or Backspace at the marker; returns null when the caret is not in a list item or is inside a code fence, so the default key behaviour runs. */
|
|
272
|
+
declare function continueList(value: string, caret: number, key: 'Enter' | 'Backspace'): Edit | null;
|
|
273
|
+
|
|
274
|
+
/** Indents or outdents the selected list items; returns null when the selection is not entirely list items, is inside a code fence, or cannot move further, so Tab keeps its default behaviour. */
|
|
275
|
+
declare function indentList(value: string, selectionStart: number, selectionEnd: number, direction: 1 | -1): Edit | null;
|
|
276
|
+
|
|
277
|
+
/** An inline markdown wrapper: bold, italic, code or a link. */
|
|
278
|
+
type WrapKind = 'bold' | 'italic' | 'code' | 'link';
|
|
279
|
+
/** Wraps the selection in the markers for the kind, or removes them when it is already wrapped. */
|
|
280
|
+
declare function wrapSelection(kind: WrapKind, value: string, selectionStart: number, selectionEnd: number): Edit;
|
|
281
|
+
/** Turns a pasted URL over a selection into a markdown link; returns null when nothing is selected or the paste is not a bare URL, so the paste goes through unchanged. */
|
|
282
|
+
declare function linkPaste(value: string, selectionStart: number, selectionEnd: number, pasted: string): Edit | null;
|
|
283
|
+
|
|
284
|
+
/** The fields `insertCommand` needs. `TextCommand` satisfies this structurally. */
|
|
285
|
+
type InsertableCommand = {
|
|
286
|
+
insert: string;
|
|
287
|
+
caretOffset: number;
|
|
288
|
+
selectLength?: number;
|
|
289
|
+
separate: boolean;
|
|
290
|
+
};
|
|
291
|
+
/** Inserts a command's markdown at the caret, starting a new line (or a blank line if it asks) when the caret is mid-line. */
|
|
292
|
+
declare function insertCommand(command: InsertableCommand, value: string, caret: number): Edit;
|
|
293
|
+
|
|
294
|
+
/** Whether typing "/" here should open the command palette: only at a word start, with no selection and outside a code fence. */
|
|
295
|
+
declare function shouldOpenPalette(value: string, selectionStart: number, selectionEnd: number): boolean;
|
|
296
|
+
|
|
297
|
+
/** Renders a "mod+shift+b" style hint as the platform's own label, such as ⌘⇧B on a Mac and Ctrl+Shift+B elsewhere. */
|
|
298
|
+
declare function formatShortcut(hint: string): string;
|
|
299
|
+
|
|
300
|
+
/** The caret's position and line height, in pixels relative to the textarea's top left corner. */
|
|
301
|
+
type CaretRect = {
|
|
302
|
+
top: number;
|
|
303
|
+
left: number;
|
|
304
|
+
height: number;
|
|
305
|
+
};
|
|
306
|
+
/** A textarea exposes no caret geometry, so the text before the caret is laid
|
|
307
|
+
* out again in a hidden div that copies the box's own metrics, and a marker at
|
|
308
|
+
* the end of it is measured. Returns null when the textarea is not laid out
|
|
309
|
+
* (hidden or detached), because there is nothing to measure. */
|
|
310
|
+
declare function caretRect(el: HTMLTextAreaElement): CaretRect | null;
|
|
311
|
+
|
|
312
|
+
/** Keyboard and paste handlers that give a plain textarea markdown shortcuts, list continuation, Tab indent and the slash palette trigger. */
|
|
313
|
+
declare function useMarkdownKeymap({ commit, onOpenPalette, }: {
|
|
314
|
+
commit: (markdown: string) => void;
|
|
315
|
+
onOpenPalette: () => void;
|
|
316
|
+
}): {
|
|
317
|
+
onKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
318
|
+
onPaste: (event: React.ClipboardEvent<HTMLTextAreaElement>) => void;
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
export { type AnyBlockDefinition, type AutosaveStatus, BlockCanvas, type BlockCanvasProps, type BlockDefinition, type BlockEditorProps, type BlockList, type BlockPreviewProps, type CaretRect, type Edit, FilePickerButton, type FilePickerButtonProps, type InsertableCommand, type LinePrefix, type QuoinBlock, type QuoinConfig, type QuoinConfigInput, QuoinProvider, TEXT_COMMANDS, type TextCommand, type UndoToken, UploadField, type UploadFieldProps, type UploadFn, type UploadResult, type UseAutosaveInput, type UseAutosaveResult, type WrapKind, applyEdit, blockByType, caretRect, continueList, coreBlocks, defineBlock, formatShortcut, indentList, insertCommand, lineAt, linkPaste, paletteBlocks, shouldOpenPalette, toggleLinePrefix, useAutoGrow, useAutosave, useBlockList, useMarkdownKeymap, useQuoin, wrapSelection };
|
package/dist/index.d.ts
CHANGED
|
@@ -87,9 +87,12 @@ declare function paletteBlocks(definitions: AnyBlockDefinition[]): AnyBlockDefin
|
|
|
87
87
|
/** Props for `BlockCanvas`; `blocks` and `onChange` are the whole document contract. */
|
|
88
88
|
type BlockCanvasProps = {
|
|
89
89
|
/**
|
|
90
|
-
* The document. Update it synchronously from `onChange`, as with a controlled `<input value onChange
|
|
91
|
-
*
|
|
92
|
-
*
|
|
90
|
+
* The document. Update it synchronously from `onChange`, as with a controlled `<input value onChange>`.
|
|
91
|
+
* Applying the edit late is tolerated as long as what comes back is one of the arrays the canvas emitted:
|
|
92
|
+
* it recognises its own output even several keystrokes behind, so a transition or a debounced setter is safe.
|
|
93
|
+
* A store that rebuilds the document on the way through hands back a structural copy instead, which arrives
|
|
94
|
+
* behind the canvas's own state and reads as a foreign document. That does not revert the edit cleanly: the
|
|
95
|
+
* characters the copy predates are dropped and the ones typed after them are kept.
|
|
93
96
|
* A new array that differs from the last one you supplied replaces what the canvas shows, which is how a host
|
|
94
97
|
* loads, undoes or merges. An array structurally equal to the last one you supplied is ignored, so a "discard
|
|
95
98
|
* changes" button that hands back the original document does nothing; remount the canvas with a React `key` to
|
|
@@ -99,6 +102,17 @@ type BlockCanvasProps = {
|
|
|
99
102
|
*/
|
|
100
103
|
blocks: QuoinBlock[];
|
|
101
104
|
onChange: (blocks: QuoinBlock[]) => void;
|
|
105
|
+
/**
|
|
106
|
+
* Called when a block is removed through its actions menu, with the block and the index it held.
|
|
107
|
+
* It runs just after the `onChange` that reports the document without it, so a host acting on the
|
|
108
|
+
* deletion is already looking at the new array. Restore the block by supplying a `blocks` array
|
|
109
|
+
* with it spliced back at that index, the same way any other document arrives.
|
|
110
|
+
*
|
|
111
|
+
* Restore it on a later tick or a later interaction, such as the click of an Undo toast. A
|
|
112
|
+
* restore applied synchronously inside this callback batches with the echo of the deletion, so
|
|
113
|
+
* what arrives is structurally equal to the document last supplied and is ignored.
|
|
114
|
+
*/
|
|
115
|
+
onDelete?: (block: QuoinBlock, index: number) => void;
|
|
102
116
|
/** Defaults to the five core block types. Pass `[...coreBlocks, yours]` to extend them. */
|
|
103
117
|
blockTypes?: AnyBlockDefinition[];
|
|
104
118
|
upload?: UploadFn;
|
|
@@ -113,11 +127,39 @@ type BlockCanvasProps = {
|
|
|
113
127
|
'aria-label'?: string;
|
|
114
128
|
};
|
|
115
129
|
/** The editor: renders `blocks`, reports every edit through `onChange`, and accepts a new `blocks` array from outside at any time. */
|
|
116
|
-
declare function BlockCanvas({ blocks, onChange, blockTypes, upload, resolveAssetUrl, onError, readOnly, className, id, 'aria-label': ariaLabel, }: BlockCanvasProps): React.JSX.Element;
|
|
130
|
+
declare function BlockCanvas({ blocks, onChange, onDelete, blockTypes, upload, resolveAssetUrl, onError, readOnly, className, id, 'aria-label': ariaLabel, }: BlockCanvasProps): React.JSX.Element;
|
|
117
131
|
|
|
118
132
|
/** The block types Quoin ships with. Spread them alongside your own definitions. */
|
|
119
133
|
declare const coreBlocks: AnyBlockDefinition[];
|
|
120
134
|
|
|
135
|
+
/** Props for `UploadField`; the upload function itself comes from the canvas, not from here. */
|
|
136
|
+
type UploadFieldProps = {
|
|
137
|
+
/** Names what the file is for, and is passed to the host's `upload` as its second argument. */
|
|
138
|
+
category: string;
|
|
139
|
+
/** Labels the control for both the pointer and assistive technology. */
|
|
140
|
+
label: string;
|
|
141
|
+
/** An `accept` attribute for the file input, such as `'image/*'` or `'.pdf'`. */
|
|
142
|
+
accept?: string;
|
|
143
|
+
/** Called once the upload resolves. Throwing from it is reported through the canvas `onError`. */
|
|
144
|
+
onUploaded: (result: UploadResult) => void;
|
|
145
|
+
};
|
|
146
|
+
/** A file picker wired to the canvas `upload` function, with its own busy state and inline error. */
|
|
147
|
+
declare function UploadField({ category, label, accept, onUploaded }: UploadFieldProps): React.JSX.Element;
|
|
148
|
+
|
|
149
|
+
/** Props for `FilePickerButton`. */
|
|
150
|
+
type FilePickerButtonProps = {
|
|
151
|
+
/** Labels the button and the file input behind it. */
|
|
152
|
+
label: string;
|
|
153
|
+
/** An `accept` attribute for the file input, such as `'image/*'` or `'.pdf'`. */
|
|
154
|
+
accept?: string;
|
|
155
|
+
/** Greys the button out and disables the input behind it. */
|
|
156
|
+
disabled?: boolean;
|
|
157
|
+
/** Called with the chosen file, and again if the same file is picked after a failure. */
|
|
158
|
+
onPick: (file: File) => void;
|
|
159
|
+
};
|
|
160
|
+
/** A button that opens the file picker and hands back the chosen file, performing no upload of its own. */
|
|
161
|
+
declare function FilePickerButton({ label, accept, disabled, onPick }: FilePickerButtonProps): React.JSX.Element;
|
|
162
|
+
|
|
121
163
|
/** The resolved canvas configuration every block editor reads through `useQuoin`. */
|
|
122
164
|
type QuoinConfig = {
|
|
123
165
|
blockTypes: AnyBlockDefinition[];
|
|
@@ -145,6 +187,7 @@ type BlockList = {
|
|
|
145
187
|
blocks: QuoinBlock[];
|
|
146
188
|
insertAt: (index: number, type: string, data?: Record<string, unknown>) => string;
|
|
147
189
|
update: (id: string, data: Record<string, unknown>) => void;
|
|
190
|
+
/** Returns a token `undo` restores that block with; only the last 20 removals stay restorable. */
|
|
148
191
|
remove: (id: string) => UndoToken;
|
|
149
192
|
undo: (token: UndoToken) => void;
|
|
150
193
|
move: (index: number, dir: -1 | 1) => void;
|
|
@@ -203,4 +246,76 @@ type TextCommand = {
|
|
|
203
246
|
/** The built-in slash-palette commands, in display order. */
|
|
204
247
|
declare const TEXT_COMMANDS: TextCommand[];
|
|
205
248
|
|
|
206
|
-
|
|
249
|
+
/** A text transform result: the next value and where the selection should land. */
|
|
250
|
+
type Edit = {
|
|
251
|
+
value: string;
|
|
252
|
+
selectionStart: number;
|
|
253
|
+
selectionEnd: number;
|
|
254
|
+
};
|
|
255
|
+
/** Applies an edit to a textarea through the native undo stack when the browser allows it, so Ctrl+Z still works. */
|
|
256
|
+
declare function applyEdit(el: HTMLTextAreaElement, edit: Edit, commit: (value: string) => void): void;
|
|
257
|
+
|
|
258
|
+
type Line = {
|
|
259
|
+
start: number;
|
|
260
|
+
end: number;
|
|
261
|
+
text: string;
|
|
262
|
+
};
|
|
263
|
+
/** The line containing the offset, with its start and end offsets and its text (no trailing newline). */
|
|
264
|
+
declare function lineAt(value: string, offset: number): Line;
|
|
265
|
+
|
|
266
|
+
/** A line-level markdown prefix: a heading level, a bullet or a numbered item. */
|
|
267
|
+
type LinePrefix = 'h1' | 'h2' | 'h3' | 'bullet' | 'ordered';
|
|
268
|
+
/** Adds the prefix to every line in the selection, or removes it when every line already carries it; fenced code is left alone. */
|
|
269
|
+
declare function toggleLinePrefix(kind: LinePrefix, value: string, selectionStart: number, selectionEnd: number): Edit;
|
|
270
|
+
|
|
271
|
+
/** Continues a list item on Enter, or climbs out of the list on an empty item or Backspace at the marker; returns null when the caret is not in a list item or is inside a code fence, so the default key behaviour runs. */
|
|
272
|
+
declare function continueList(value: string, caret: number, key: 'Enter' | 'Backspace'): Edit | null;
|
|
273
|
+
|
|
274
|
+
/** Indents or outdents the selected list items; returns null when the selection is not entirely list items, is inside a code fence, or cannot move further, so Tab keeps its default behaviour. */
|
|
275
|
+
declare function indentList(value: string, selectionStart: number, selectionEnd: number, direction: 1 | -1): Edit | null;
|
|
276
|
+
|
|
277
|
+
/** An inline markdown wrapper: bold, italic, code or a link. */
|
|
278
|
+
type WrapKind = 'bold' | 'italic' | 'code' | 'link';
|
|
279
|
+
/** Wraps the selection in the markers for the kind, or removes them when it is already wrapped. */
|
|
280
|
+
declare function wrapSelection(kind: WrapKind, value: string, selectionStart: number, selectionEnd: number): Edit;
|
|
281
|
+
/** Turns a pasted URL over a selection into a markdown link; returns null when nothing is selected or the paste is not a bare URL, so the paste goes through unchanged. */
|
|
282
|
+
declare function linkPaste(value: string, selectionStart: number, selectionEnd: number, pasted: string): Edit | null;
|
|
283
|
+
|
|
284
|
+
/** The fields `insertCommand` needs. `TextCommand` satisfies this structurally. */
|
|
285
|
+
type InsertableCommand = {
|
|
286
|
+
insert: string;
|
|
287
|
+
caretOffset: number;
|
|
288
|
+
selectLength?: number;
|
|
289
|
+
separate: boolean;
|
|
290
|
+
};
|
|
291
|
+
/** Inserts a command's markdown at the caret, starting a new line (or a blank line if it asks) when the caret is mid-line. */
|
|
292
|
+
declare function insertCommand(command: InsertableCommand, value: string, caret: number): Edit;
|
|
293
|
+
|
|
294
|
+
/** Whether typing "/" here should open the command palette: only at a word start, with no selection and outside a code fence. */
|
|
295
|
+
declare function shouldOpenPalette(value: string, selectionStart: number, selectionEnd: number): boolean;
|
|
296
|
+
|
|
297
|
+
/** Renders a "mod+shift+b" style hint as the platform's own label, such as ⌘⇧B on a Mac and Ctrl+Shift+B elsewhere. */
|
|
298
|
+
declare function formatShortcut(hint: string): string;
|
|
299
|
+
|
|
300
|
+
/** The caret's position and line height, in pixels relative to the textarea's top left corner. */
|
|
301
|
+
type CaretRect = {
|
|
302
|
+
top: number;
|
|
303
|
+
left: number;
|
|
304
|
+
height: number;
|
|
305
|
+
};
|
|
306
|
+
/** A textarea exposes no caret geometry, so the text before the caret is laid
|
|
307
|
+
* out again in a hidden div that copies the box's own metrics, and a marker at
|
|
308
|
+
* the end of it is measured. Returns null when the textarea is not laid out
|
|
309
|
+
* (hidden or detached), because there is nothing to measure. */
|
|
310
|
+
declare function caretRect(el: HTMLTextAreaElement): CaretRect | null;
|
|
311
|
+
|
|
312
|
+
/** Keyboard and paste handlers that give a plain textarea markdown shortcuts, list continuation, Tab indent and the slash palette trigger. */
|
|
313
|
+
declare function useMarkdownKeymap({ commit, onOpenPalette, }: {
|
|
314
|
+
commit: (markdown: string) => void;
|
|
315
|
+
onOpenPalette: () => void;
|
|
316
|
+
}): {
|
|
317
|
+
onKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
318
|
+
onPaste: (event: React.ClipboardEvent<HTMLTextAreaElement>) => void;
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
export { type AnyBlockDefinition, type AutosaveStatus, BlockCanvas, type BlockCanvasProps, type BlockDefinition, type BlockEditorProps, type BlockList, type BlockPreviewProps, type CaretRect, type Edit, FilePickerButton, type FilePickerButtonProps, type InsertableCommand, type LinePrefix, type QuoinBlock, type QuoinConfig, type QuoinConfigInput, QuoinProvider, TEXT_COMMANDS, type TextCommand, type UndoToken, UploadField, type UploadFieldProps, type UploadFn, type UploadResult, type UseAutosaveInput, type UseAutosaveResult, type WrapKind, applyEdit, blockByType, caretRect, continueList, coreBlocks, defineBlock, formatShortcut, indentList, insertCommand, lineAt, linkPaste, paletteBlocks, shouldOpenPalette, toggleLinePrefix, useAutoGrow, useAutosave, useBlockList, useMarkdownKeymap, useQuoin, wrapSelection };
|