@inkbrick/react 0.0.0-stage → 0.1.0-alpha.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/dist/FormulaPalette-WFRPRHS5.js +320 -0
- package/dist/FormulaPalette-WFRPRHS5.js.map +1 -0
- package/dist/chunk-TPUX4C45.js +2309 -0
- package/dist/chunk-TPUX4C45.js.map +1 -0
- package/dist/index.d.ts +1431 -0
- package/dist/index.js +4880 -0
- package/dist/index.js.map +1 -0
- package/dist/mathCss-FLPE6QBM.js +361 -0
- package/dist/mathCss-FLPE6QBM.js.map +1 -0
- package/package.json +46 -3
- package/src/block-handle/BlockHandleController.ts +93 -0
- package/src/block-handle/BlockHandleHost.tsx +108 -0
- package/src/block-handle/DefaultBlockHandle.tsx +71 -0
- package/src/block-handle/DefaultBlockMenu.tsx +114 -0
- package/src/block-handle/DropIndicatorHost.tsx +58 -0
- package/src/block-handle/actions.tsx +146 -0
- package/src/block-handle/blockDrag.ts +215 -0
- package/src/block-handle/geometry.ts +64 -0
- package/src/block-handle/gripGesture.ts +108 -0
- package/src/block-handle/types.ts +65 -0
- package/src/block-handle/useBlockDrag.ts +21 -0
- package/src/block-handle/useBlockHandles.ts +125 -0
- package/src/blocks/BlockChildren.tsx +17 -0
- package/src/blocks/BlockProps.ts +5 -0
- package/src/blocks/CalloutBlock.tsx +61 -0
- package/src/blocks/CodeBlock.tsx +96 -0
- package/src/blocks/DividerBlock.tsx +15 -0
- package/src/blocks/Editable.tsx +84 -0
- package/src/blocks/FormulaBlock.tsx +173 -0
- package/src/blocks/HeadingBlock.tsx +22 -0
- package/src/blocks/ImageBlock.tsx +362 -0
- package/src/blocks/ListBlock.tsx +86 -0
- package/src/blocks/NoteBlock.tsx +10 -0
- package/src/blocks/PageBlock.tsx +10 -0
- package/src/blocks/ParagraphBlock.tsx +20 -0
- package/src/blocks/QuoteBlock.tsx +18 -0
- package/src/blocks/UnknownBlockView.tsx +27 -0
- package/src/blocks/defineBlock.ts +49 -0
- package/src/clipboard/html/blocks.ts +379 -0
- package/src/clipboard/html/inline.ts +92 -0
- package/src/clipboard/html/style.ts +92 -0
- package/src/clipboard/html/tags.ts +77 -0
- package/src/clipboard/htmlToFragment.ts +41 -0
- package/src/clipboard/useClipboard.ts +296 -0
- package/src/code/highlight.ts +56 -0
- package/src/code/languages.ts +236 -0
- package/src/code/scan/css.ts +164 -0
- package/src/code/scan/generic.ts +328 -0
- package/src/code/scan/html.ts +129 -0
- package/src/code/scan/markdown.ts +58 -0
- package/src/code/scan/shared.ts +81 -0
- package/src/code/scan/yaml.ts +34 -0
- package/src/code/types.ts +34 -0
- package/src/context/EditorContext.ts +9 -0
- package/src/context/EditorProvider.tsx +172 -0
- package/src/controllers/adapters.tsx +63 -0
- package/src/editing/BlockSelectionController.ts +27 -0
- package/src/editing/CaretController.ts +27 -0
- package/src/editing/EditorView.ts +108 -0
- package/src/editing/ViewportController.ts +63 -0
- package/src/editing/beforeInput.ts +276 -0
- package/src/editing/deleteAtBoundary.ts +16 -0
- package/src/editing/inputActions.ts +109 -0
- package/src/editing/renderCode.ts +69 -0
- package/src/editing/renderInline.ts +144 -0
- package/src/editing/selection.ts +262 -0
- package/src/editing/useEditorInput.ts +223 -0
- package/src/editing/useSelectionState.ts +46 -0
- package/src/formula/FormulaController.ts +51 -0
- package/src/formula/FormulaPalette.tsx +79 -0
- package/src/formula/FormulaPopover.tsx +181 -0
- package/src/formula/LazyFormulaPalette.tsx +42 -0
- package/src/formula/actions.ts +138 -0
- package/src/formula/snippet.ts +70 -0
- package/src/formula/symbols.ts +264 -0
- package/src/hooks/useBlock.ts +21 -0
- package/src/hooks/useBlockController.ts +30 -0
- package/src/hooks/useChildren.ts +16 -0
- package/src/hooks/useDocument.ts +16 -0
- package/src/hooks/useEditor.ts +13 -0
- package/src/hooks/useEditorView.ts +13 -0
- package/src/hooks/useHistory.ts +46 -0
- package/src/hooks/useReadOnly.ts +21 -0
- package/src/hooks/useT.ts +10 -0
- package/src/i18n/en.ts +182 -0
- package/src/i18n/ru.ts +174 -0
- package/src/i18n/translate.ts +77 -0
- package/src/icons/ICONS_LICENSE.md +50 -0
- package/src/icons/Icon.tsx +41 -0
- package/src/icons/lucide.ts +234 -0
- package/src/images/ImageError.ts +39 -0
- package/src/images/UploadTracker.ts +49 -0
- package/src/images/insertImages.ts +142 -0
- package/src/images/types.ts +22 -0
- package/src/images/upload.ts +62 -0
- package/src/index.ts +102 -0
- package/src/keymap/defaultKeymap.ts +189 -0
- package/src/keymap/keymap.ts +42 -0
- package/src/keymap/shortcut.ts +105 -0
- package/src/keymap/types.ts +40 -0
- package/src/math/FormulaView.tsx +62 -0
- package/src/math/mathCss.ts +4 -0
- package/src/math/renderer.ts +198 -0
- package/src/registry/defaultBlockComponents.ts +26 -0
- package/src/registry/resolveBlockComponent.ts +14 -0
- package/src/renderer/BlockRenderer.tsx +63 -0
- package/src/renderer/DocumentRenderer.tsx +33 -0
- package/src/renderer/DocumentView.tsx +94 -0
- package/src/renderer/virtual/VirtualChildList.tsx +355 -0
- package/src/renderer/virtual/estimate.ts +62 -0
- package/src/renderer/virtual/virtualRenderer.tsx +35 -0
- package/src/slash/DefaultSlashMenu.tsx +119 -0
- package/src/slash/SlashMenuController.ts +66 -0
- package/src/slash/SlashMenuHost.tsx +48 -0
- package/src/slash/applySlashItem.ts +57 -0
- package/src/slash/defaultSlashItems.tsx +186 -0
- package/src/slash/filter.ts +29 -0
- package/src/slash/items.ts +30 -0
- package/src/slash/syncSlashMenu.ts +67 -0
- package/src/slash/types.ts +21 -0
- package/src/toolbar/DefaultToolbar.tsx +281 -0
- package/src/toolbar/ToolbarController.ts +100 -0
- package/src/toolbar/ToolbarHost.tsx +81 -0
- package/src/toolbar/formatting.ts +75 -0
- package/src/toolbar/rich.ts +58 -0
- package/src/toolbar/syncToolbar.ts +39 -0
- package/src/toolbar/types.ts +21 -0
- package/src/ui/EditorUIContext.ts +26 -0
- package/src/ui/presentation.ts +24 -0
- package/src/ui/types.ts +70 -0
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1431 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, PointerEvent, MouseEvent, CSSProperties, ComponentType, SVGProps } from 'react';
|
|
3
|
+
import * as _inkbrick_engine from '@inkbrick/engine';
|
|
4
|
+
import { RangeFormats, Editor, EditorIntent, CaretResult, BlockController, TypedBlock, BlockDefinition, BlockContext, Fragment } from '@inkbrick/engine';
|
|
5
|
+
import * as _inkbrick_document from '@inkbrick/document';
|
|
6
|
+
import { Alignment, BlockId, BaseBlock, BlockProps as BlockProps$1 } from '@inkbrick/document';
|
|
7
|
+
|
|
8
|
+
type DropPosition = 'before' | 'after';
|
|
9
|
+
interface BlockAnchor {
|
|
10
|
+
readonly blockId: string;
|
|
11
|
+
readonly x: number;
|
|
12
|
+
readonly y: number;
|
|
13
|
+
}
|
|
14
|
+
interface DropIndicatorRect {
|
|
15
|
+
readonly left: number;
|
|
16
|
+
readonly top: number;
|
|
17
|
+
readonly width: number;
|
|
18
|
+
}
|
|
19
|
+
interface DragState {
|
|
20
|
+
readonly blockId: string;
|
|
21
|
+
readonly targetId: string | null;
|
|
22
|
+
readonly position: DropPosition | null;
|
|
23
|
+
readonly indicator: DropIndicatorRect | null;
|
|
24
|
+
}
|
|
25
|
+
interface BlockHandleState {
|
|
26
|
+
readonly hover: BlockAnchor | null;
|
|
27
|
+
readonly menu: BlockAnchor | null;
|
|
28
|
+
readonly drag: DragState | null;
|
|
29
|
+
}
|
|
30
|
+
declare class BlockHandleController {
|
|
31
|
+
private state;
|
|
32
|
+
private readonly listeners;
|
|
33
|
+
getState: () => BlockHandleState;
|
|
34
|
+
subscribe: (listener: () => void) => (() => void);
|
|
35
|
+
setHover(hover: BlockAnchor | null): void;
|
|
36
|
+
openMenu(menu: BlockAnchor): void;
|
|
37
|
+
closeMenu(): void;
|
|
38
|
+
startDrag(blockId: string): void;
|
|
39
|
+
updateDrag(patch: Partial<Omit<DragState, 'blockId'>>): void;
|
|
40
|
+
endDrag(): void;
|
|
41
|
+
private set;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Английский словарь — эталон: набор его ключей определяет `MessageKey`, а недостающие ключи любого другого
|
|
46
|
+
* словаря берутся отсюда. В строках можно использовать подстановки `{name}`.
|
|
47
|
+
*/
|
|
48
|
+
declare const en: {
|
|
49
|
+
readonly 'editor.hint': "Press / to open the menu";
|
|
50
|
+
readonly 'editor.label': "Document";
|
|
51
|
+
readonly 'block.list.done': "Done";
|
|
52
|
+
readonly 'block.code.language': "Code language";
|
|
53
|
+
readonly 'block.code.copy': "Copy code";
|
|
54
|
+
readonly 'block.code.copied': "Copied";
|
|
55
|
+
readonly 'block.callout.label': "Callout style: {tone}. Click to change";
|
|
56
|
+
readonly 'block.callout.change': "Change style";
|
|
57
|
+
readonly 'block.callout.tone.info': "info";
|
|
58
|
+
readonly 'block.callout.tone.warning': "warning";
|
|
59
|
+
readonly 'block.callout.tone.success': "success";
|
|
60
|
+
readonly 'block.callout.tone.danger': "danger";
|
|
61
|
+
readonly 'block.unknown.title': "Unknown block type:";
|
|
62
|
+
readonly 'block.unknown.hint': "Register a component for it via";
|
|
63
|
+
readonly 'image.options': "Image options";
|
|
64
|
+
readonly 'image.align.left': "Align left";
|
|
65
|
+
readonly 'image.align.center': "Align center";
|
|
66
|
+
readonly 'image.align.right': "Align right";
|
|
67
|
+
readonly 'image.width': "Image width";
|
|
68
|
+
readonly 'image.alt': "Alt text";
|
|
69
|
+
readonly 'image.caption.label': "Caption";
|
|
70
|
+
readonly 'image.caption.placeholder': "Write a caption…";
|
|
71
|
+
readonly 'image.replace': "Replace image";
|
|
72
|
+
readonly 'image.url.label': "Image URL";
|
|
73
|
+
readonly 'image.url.placeholder': "Paste an image link…";
|
|
74
|
+
readonly 'image.embed': "Embed";
|
|
75
|
+
readonly 'image.upload': "Upload";
|
|
76
|
+
readonly 'image.status.uploading': "Uploading…";
|
|
77
|
+
readonly 'image.status.none': "No image";
|
|
78
|
+
readonly 'image.status.unsupported': "This image address is not supported";
|
|
79
|
+
readonly 'image.status.failed': "The image could not be loaded";
|
|
80
|
+
readonly 'image.status.retry': "Replace";
|
|
81
|
+
readonly 'image.error.invalidLink': "Enter a valid http(s) image link";
|
|
82
|
+
readonly 'image.error.unsupportedAddress': "This image address is not supported";
|
|
83
|
+
readonly 'image.error.type': "Unsupported image type \"{type}\"";
|
|
84
|
+
readonly 'image.error.size': "The image is larger than {size} KB. Provide \"images.upload\" to store larger images.";
|
|
85
|
+
readonly 'image.error.uploadAddress': "The upload returned an unsupported image address";
|
|
86
|
+
readonly 'image.error.read': "Could not read the file";
|
|
87
|
+
readonly 'image.error.generic': "Could not add the image";
|
|
88
|
+
readonly 'formula.source': "LaTeX formula";
|
|
89
|
+
readonly 'formula.placeholder': "Type LaTeX, e.g. \\frac{a}{b}";
|
|
90
|
+
readonly 'formula.hint': "Ctrl+Enter to apply, Esc to cancel";
|
|
91
|
+
readonly 'formula.empty': "Add a formula";
|
|
92
|
+
readonly 'formula.edit': "Edit formula";
|
|
93
|
+
readonly 'formula.inline.title': "Inline formula";
|
|
94
|
+
readonly 'formula.apply': "Apply";
|
|
95
|
+
readonly 'formula.remove': "Remove formula";
|
|
96
|
+
readonly 'formula.cancel': "Cancel";
|
|
97
|
+
readonly 'formula.palette.label': "Math symbols";
|
|
98
|
+
readonly 'formula.palette.functions': "Functions";
|
|
99
|
+
readonly 'formula.palette.structures': "Structures";
|
|
100
|
+
readonly 'formula.palette.greek': "Greek letters";
|
|
101
|
+
readonly 'formula.palette.operators': "Operators";
|
|
102
|
+
readonly 'formula.palette.relations': "Relations";
|
|
103
|
+
readonly 'formula.palette.arrows': "Arrows";
|
|
104
|
+
readonly 'formula.palette.sets': "Sets and logic";
|
|
105
|
+
readonly 'color.black': "Black";
|
|
106
|
+
readonly 'color.white': "White";
|
|
107
|
+
readonly 'color.gray': "Gray";
|
|
108
|
+
readonly 'color.brown': "Brown";
|
|
109
|
+
readonly 'color.orange': "Orange";
|
|
110
|
+
readonly 'color.yellow': "Yellow";
|
|
111
|
+
readonly 'color.green': "Green";
|
|
112
|
+
readonly 'color.blue': "Blue";
|
|
113
|
+
readonly 'color.purple': "Purple";
|
|
114
|
+
readonly 'color.pink': "Pink";
|
|
115
|
+
readonly 'color.red': "Red";
|
|
116
|
+
readonly 'toolbar.label': "Text formatting";
|
|
117
|
+
readonly 'toolbar.bold.label': "Bold";
|
|
118
|
+
readonly 'toolbar.bold.title': "Bold (Ctrl+B)";
|
|
119
|
+
readonly 'toolbar.italic.label': "Italic";
|
|
120
|
+
readonly 'toolbar.italic.title': "Italic (Ctrl+I)";
|
|
121
|
+
readonly 'toolbar.underline.label': "Underline";
|
|
122
|
+
readonly 'toolbar.underline.title': "Underline (Ctrl+U)";
|
|
123
|
+
readonly 'toolbar.strike.label': "Strikethrough";
|
|
124
|
+
readonly 'toolbar.strike.title': "Strikethrough (Ctrl+Shift+X)";
|
|
125
|
+
readonly 'toolbar.code.label': "Code";
|
|
126
|
+
readonly 'toolbar.code.title': "Code (Ctrl+E)";
|
|
127
|
+
readonly 'toolbar.formula.label': "Formula";
|
|
128
|
+
readonly 'toolbar.formula.title': "Formula (Ctrl+Shift+M)";
|
|
129
|
+
readonly 'toolbar.color.label': "Text color";
|
|
130
|
+
readonly 'toolbar.color.title': "Text color";
|
|
131
|
+
readonly 'toolbar.color.default': "Default color";
|
|
132
|
+
readonly 'toolbar.highlight.label': "Highlight color";
|
|
133
|
+
readonly 'toolbar.highlight.title': "Highlight";
|
|
134
|
+
readonly 'toolbar.highlight.none': "No highlight";
|
|
135
|
+
readonly 'toolbar.align.left.label': "Align left";
|
|
136
|
+
readonly 'toolbar.align.left.title': "Align left (Ctrl+Shift+L)";
|
|
137
|
+
readonly 'toolbar.align.center.label': "Align center";
|
|
138
|
+
readonly 'toolbar.align.center.title': "Align center (Ctrl+Shift+E)";
|
|
139
|
+
readonly 'toolbar.align.right.label': "Align right";
|
|
140
|
+
readonly 'toolbar.align.right.title': "Align right (Ctrl+Shift+R)";
|
|
141
|
+
readonly 'toolbar.align.justify.label': "Justify";
|
|
142
|
+
readonly 'toolbar.align.justify.title': "Justify (Ctrl+Shift+J)";
|
|
143
|
+
readonly 'toolbar.link.label': "Link";
|
|
144
|
+
readonly 'toolbar.link.title': "Link (Ctrl+K)";
|
|
145
|
+
readonly 'toolbar.link.url': "Link URL";
|
|
146
|
+
readonly 'toolbar.link.placeholder': "Paste a link…";
|
|
147
|
+
readonly 'toolbar.link.apply': "Apply link";
|
|
148
|
+
readonly 'toolbar.link.remove': "Remove link";
|
|
149
|
+
readonly 'handle.add': "Add block below";
|
|
150
|
+
readonly 'handle.grip': "Drag to move, click for options";
|
|
151
|
+
readonly 'menu.label': "Block options";
|
|
152
|
+
readonly 'menu.duplicate': "Duplicate";
|
|
153
|
+
readonly 'menu.moveUp': "Move up";
|
|
154
|
+
readonly 'menu.moveDown': "Move down";
|
|
155
|
+
readonly 'menu.delete': "Delete";
|
|
156
|
+
readonly 'menu.turnInto': "Turn into";
|
|
157
|
+
readonly 'menu.empty': "No actions";
|
|
158
|
+
readonly 'history.undo': "Undo";
|
|
159
|
+
readonly 'history.redo': "Redo";
|
|
160
|
+
readonly 'slash.label': "Insert block";
|
|
161
|
+
readonly 'slash.empty': "No results";
|
|
162
|
+
readonly 'slash.item.text.title': "Text";
|
|
163
|
+
readonly 'slash.item.text.description': "Plain paragraph";
|
|
164
|
+
readonly 'slash.item.text.keywords': "paragraph, p";
|
|
165
|
+
readonly 'slash.item.heading-1.title': "Heading 1";
|
|
166
|
+
readonly 'slash.item.heading-1.description': "Large section heading";
|
|
167
|
+
readonly 'slash.item.heading-1.keywords': "h1, title";
|
|
168
|
+
readonly 'slash.item.heading-2.title': "Heading 2";
|
|
169
|
+
readonly 'slash.item.heading-2.description': "Medium section heading";
|
|
170
|
+
readonly 'slash.item.heading-2.keywords': "h2, subtitle";
|
|
171
|
+
readonly 'slash.item.heading-3.title': "Heading 3";
|
|
172
|
+
readonly 'slash.item.heading-3.description': "Small section heading";
|
|
173
|
+
readonly 'slash.item.heading-3.keywords': "h3";
|
|
174
|
+
readonly 'slash.item.heading-4.title': "Heading 4";
|
|
175
|
+
readonly 'slash.item.heading-4.description': "Subsection heading";
|
|
176
|
+
readonly 'slash.item.heading-4.keywords': "h4";
|
|
177
|
+
readonly 'slash.item.heading-5.title': "Heading 5";
|
|
178
|
+
readonly 'slash.item.heading-5.description': "Minor subsection heading";
|
|
179
|
+
readonly 'slash.item.heading-5.keywords': "h5";
|
|
180
|
+
readonly 'slash.item.heading-6.title': "Heading 6";
|
|
181
|
+
readonly 'slash.item.heading-6.description': "Smallest heading";
|
|
182
|
+
readonly 'slash.item.heading-6.keywords': "h6";
|
|
183
|
+
readonly 'slash.item.bullet-list.title': "Bulleted list";
|
|
184
|
+
readonly 'slash.item.bullet-list.description': "Simple bulleted list";
|
|
185
|
+
readonly 'slash.item.bullet-list.keywords': "ul, unordered, list";
|
|
186
|
+
readonly 'slash.item.numbered-list.title': "Numbered list";
|
|
187
|
+
readonly 'slash.item.numbered-list.description': "List with numbering";
|
|
188
|
+
readonly 'slash.item.numbered-list.keywords': "ol, ordered, list";
|
|
189
|
+
readonly 'slash.item.todo-list.title': "To-do list";
|
|
190
|
+
readonly 'slash.item.todo-list.description': "Track tasks with checkboxes";
|
|
191
|
+
readonly 'slash.item.todo-list.keywords': "todo, task, checkbox, check";
|
|
192
|
+
readonly 'slash.item.quote.title': "Quote";
|
|
193
|
+
readonly 'slash.item.quote.description': "Capture a quote";
|
|
194
|
+
readonly 'slash.item.quote.keywords': "blockquote, citation";
|
|
195
|
+
readonly 'slash.item.code.title': "Code";
|
|
196
|
+
readonly 'slash.item.code.description': "Code snippet with monospace font";
|
|
197
|
+
readonly 'slash.item.code.keywords': "snippet, pre, program";
|
|
198
|
+
readonly 'slash.item.callout.title': "Callout";
|
|
199
|
+
readonly 'slash.item.callout.description': "Highlight important information";
|
|
200
|
+
readonly 'slash.item.callout.keywords': "info, note, warning, tip, alert";
|
|
201
|
+
readonly 'slash.item.image.title': "Image";
|
|
202
|
+
readonly 'slash.item.image.description': "Upload or embed an image";
|
|
203
|
+
readonly 'slash.item.image.keywords': "picture, photo, img, upload";
|
|
204
|
+
readonly 'slash.item.formula.title': "Formula";
|
|
205
|
+
readonly 'slash.item.formula.description': "Display a LaTeX formula";
|
|
206
|
+
readonly 'slash.item.formula.keywords': "math, equation, latex, tex";
|
|
207
|
+
readonly 'slash.item.divider.title': "Divider";
|
|
208
|
+
readonly 'slash.item.divider.description': "Visually separate sections";
|
|
209
|
+
readonly 'slash.item.divider.keywords': "hr, line, separator, rule";
|
|
210
|
+
};
|
|
211
|
+
type MessageKey = keyof typeof en;
|
|
212
|
+
type Messages = Readonly<Record<MessageKey, string>>;
|
|
213
|
+
type PartialMessages = Readonly<Partial<Record<MessageKey, string>>>;
|
|
214
|
+
|
|
215
|
+
type MessageParams = Readonly<Record<string, string | number>>;
|
|
216
|
+
type TFunction = (key: MessageKey, params?: MessageParams) => string;
|
|
217
|
+
/**
|
|
218
|
+
* Подключает словарь под кодом языка (`'de'`, `'uk'`, `'pt-BR'`). Словарь может быть неполным: недостающие
|
|
219
|
+
* ключи берутся из английского. Повторная регистрация того же кода заменяет словарь (в том числе встроенный).
|
|
220
|
+
*/
|
|
221
|
+
declare function registerLocale(code: string, messages: PartialMessages): void;
|
|
222
|
+
declare function getLocales(): string[];
|
|
223
|
+
interface ResolveMessagesOptions {
|
|
224
|
+
readonly locale?: string;
|
|
225
|
+
readonly locales?: Readonly<Record<string, PartialMessages>>;
|
|
226
|
+
readonly messages?: PartialMessages;
|
|
227
|
+
}
|
|
228
|
+
declare function resolveMessages(options?: ResolveMessagesOptions): Messages;
|
|
229
|
+
declare function createTranslator(messages: Messages): TFunction;
|
|
230
|
+
|
|
231
|
+
type ImageErrorCode = 'type' | 'size' | 'uploadAddress' | 'read';
|
|
232
|
+
interface ImageErrorInfo {
|
|
233
|
+
readonly message: string;
|
|
234
|
+
readonly code?: ImageErrorCode;
|
|
235
|
+
readonly params?: MessageParams;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Какие блоки-картинки сейчас загружаются и какие ошибки загрузки показать. Состояние живёт здесь, а не в
|
|
240
|
+
* компоненте: пока файл обрабатывается, выбор файла заменяется индикатором и локальное состояние пропало бы.
|
|
241
|
+
*/
|
|
242
|
+
declare class UploadTracker {
|
|
243
|
+
private readonly active;
|
|
244
|
+
private readonly errors;
|
|
245
|
+
private readonly listeners;
|
|
246
|
+
has: (blockId: string) => boolean;
|
|
247
|
+
errorOf: (blockId: string) => string | undefined;
|
|
248
|
+
errorDetailsOf: (blockId: string) => ImageErrorInfo | undefined;
|
|
249
|
+
subscribe: (listener: () => void) => (() => void);
|
|
250
|
+
start(blockId: string): void;
|
|
251
|
+
finish(blockId: string, error?: string | ImageErrorInfo): void;
|
|
252
|
+
clearError(blockId: string): void;
|
|
253
|
+
private notify;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Какие блоки сейчас затронуты непустым выделением. Подписка идёт на уровне отдельного блока:
|
|
258
|
+
* при смене выделения перерисовываются только те блоки, у которых флаг `selected` изменился.
|
|
259
|
+
*/
|
|
260
|
+
declare class BlockSelectionController {
|
|
261
|
+
private selected;
|
|
262
|
+
private readonly listeners;
|
|
263
|
+
isSelected: (blockId: string) => boolean;
|
|
264
|
+
subscribe: (listener: () => void) => (() => void);
|
|
265
|
+
set(ids: readonly string[]): void;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
type FormulaEditorMode = 'insert' | 'edit';
|
|
269
|
+
interface FormulaEditorState {
|
|
270
|
+
readonly open: boolean;
|
|
271
|
+
readonly mode: FormulaEditorMode;
|
|
272
|
+
readonly blockId: string;
|
|
273
|
+
readonly from: number;
|
|
274
|
+
readonly to: number;
|
|
275
|
+
readonly latex: string;
|
|
276
|
+
readonly position: {
|
|
277
|
+
readonly x: number;
|
|
278
|
+
readonly y: number;
|
|
279
|
+
readonly top: number;
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
declare class FormulaController {
|
|
283
|
+
private state;
|
|
284
|
+
private readonly listeners;
|
|
285
|
+
getState: () => FormulaEditorState;
|
|
286
|
+
subscribe: (listener: () => void) => (() => void);
|
|
287
|
+
open(state: Omit<FormulaEditorState, 'open'>): void;
|
|
288
|
+
close(): void;
|
|
289
|
+
private set;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* В каком блоке сейчас стоит каретка (выделение свёрнуто). Подписка идёт на уровне блока: при переносе каретки
|
|
294
|
+
* перерисовываются только два блока — тот, который она покинула, и тот, куда попала.
|
|
295
|
+
*/
|
|
296
|
+
declare class CaretController {
|
|
297
|
+
private blockId;
|
|
298
|
+
private readonly listeners;
|
|
299
|
+
has: (blockId: string) => boolean;
|
|
300
|
+
subscribe: (listener: () => void) => (() => void);
|
|
301
|
+
set(blockId: string | null): void;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
interface SlashMenuState {
|
|
305
|
+
readonly open: boolean;
|
|
306
|
+
readonly blockId: string | null;
|
|
307
|
+
readonly slashOffset: number;
|
|
308
|
+
readonly query: string;
|
|
309
|
+
readonly activeIndex: number;
|
|
310
|
+
readonly position: {
|
|
311
|
+
readonly x: number;
|
|
312
|
+
readonly y: number;
|
|
313
|
+
} | null;
|
|
314
|
+
}
|
|
315
|
+
declare class SlashMenuController {
|
|
316
|
+
private state;
|
|
317
|
+
private readonly listeners;
|
|
318
|
+
getState: () => SlashMenuState;
|
|
319
|
+
subscribe: (listener: () => void) => (() => void);
|
|
320
|
+
open(blockId: string, slashOffset: number): void;
|
|
321
|
+
close(): void;
|
|
322
|
+
update(patch: Partial<Pick<SlashMenuState, 'query' | 'activeIndex' | 'position'>>): void;
|
|
323
|
+
move(delta: number, count: number): void;
|
|
324
|
+
private set;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
interface DocPoint {
|
|
328
|
+
blockId: string;
|
|
329
|
+
offset: number;
|
|
330
|
+
}
|
|
331
|
+
interface DocSelection {
|
|
332
|
+
from: DocPoint;
|
|
333
|
+
to: DocPoint;
|
|
334
|
+
collapsed: boolean;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
type InlineFormat = 'bold' | 'italic' | 'underline' | 'strike' | 'code';
|
|
338
|
+
type ToolbarPanel = 'color' | 'highlight';
|
|
339
|
+
interface ToolbarProps {
|
|
340
|
+
readonly formats: RangeFormats;
|
|
341
|
+
readonly position: {
|
|
342
|
+
readonly x: number;
|
|
343
|
+
readonly y: number;
|
|
344
|
+
};
|
|
345
|
+
readonly linkOpen: boolean;
|
|
346
|
+
readonly onToggle: (format: InlineFormat) => void;
|
|
347
|
+
readonly onOpenLink: () => void;
|
|
348
|
+
readonly onApplyLink: (url: string | null) => boolean;
|
|
349
|
+
readonly onCancelLink: () => void;
|
|
350
|
+
readonly panel: ToolbarPanel | null;
|
|
351
|
+
readonly onTogglePanel: (panel: ToolbarPanel) => void;
|
|
352
|
+
readonly onApplyColor: (kind: 'color' | 'backgroundColor', value: string | null) => void;
|
|
353
|
+
readonly onAlign: (align: Alignment) => void;
|
|
354
|
+
readonly onInsertFormula: () => void;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
interface ToolbarState {
|
|
358
|
+
readonly visible: boolean;
|
|
359
|
+
readonly position: {
|
|
360
|
+
readonly x: number;
|
|
361
|
+
readonly y: number;
|
|
362
|
+
} | null;
|
|
363
|
+
readonly formats: RangeFormats | null;
|
|
364
|
+
readonly range: DocSelection | null;
|
|
365
|
+
readonly linkOpen: boolean;
|
|
366
|
+
readonly panel: ToolbarPanel | null;
|
|
367
|
+
}
|
|
368
|
+
declare class ToolbarController {
|
|
369
|
+
private state;
|
|
370
|
+
private readonly listeners;
|
|
371
|
+
getState: () => ToolbarState;
|
|
372
|
+
subscribe: (listener: () => void) => (() => void);
|
|
373
|
+
show(range: DocSelection, formats: RangeFormats, position: {
|
|
374
|
+
x: number;
|
|
375
|
+
y: number;
|
|
376
|
+
}): void;
|
|
377
|
+
hide(): void;
|
|
378
|
+
openLink(): void;
|
|
379
|
+
togglePanel(panel: ToolbarPanel): void;
|
|
380
|
+
closePanel(): void;
|
|
381
|
+
closeLink(): void;
|
|
382
|
+
private set;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Какие блоки обязаны оставаться в DOM при виртуальной отрисовке: края выделения (там стоит каретка или
|
|
387
|
+
* начинается/кончается выделение) и блоки, которые редактор попросил показать (`reveal`), например перед
|
|
388
|
+
* установкой каретки в блок за пределами окна. Обычный рендерер это состояние не читает.
|
|
389
|
+
*/
|
|
390
|
+
declare class ViewportController {
|
|
391
|
+
private edges;
|
|
392
|
+
private revealed;
|
|
393
|
+
private lists;
|
|
394
|
+
private version;
|
|
395
|
+
private readonly listeners;
|
|
396
|
+
getVersion: () => number;
|
|
397
|
+
subscribe: (listener: () => void) => (() => void);
|
|
398
|
+
getPinned(): readonly string[];
|
|
399
|
+
get virtual(): boolean;
|
|
400
|
+
attach(): () => void;
|
|
401
|
+
setEdges(ids: readonly string[]): void;
|
|
402
|
+
reveal(ids: readonly string[]): boolean;
|
|
403
|
+
private notify;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Связь модели с DOM: корневой редактируемый элемент и элементы текстовых блоков.
|
|
408
|
+
* Нужна, чтобы после изменения модели вернуть курсор/выделение на место.
|
|
409
|
+
*/
|
|
410
|
+
declare class EditorView {
|
|
411
|
+
private readonly elements;
|
|
412
|
+
private root;
|
|
413
|
+
readonly slash: SlashMenuController;
|
|
414
|
+
readonly uploads: UploadTracker;
|
|
415
|
+
readonly selection: BlockSelectionController;
|
|
416
|
+
readonly caret: CaretController;
|
|
417
|
+
readonly blocks: BlockHandleController;
|
|
418
|
+
readonly formula: FormulaController;
|
|
419
|
+
readonly toolbar: ToolbarController;
|
|
420
|
+
readonly viewport: ViewportController;
|
|
421
|
+
pointerDown: boolean;
|
|
422
|
+
private pending;
|
|
423
|
+
setRoot(element: HTMLElement | null): () => void;
|
|
424
|
+
getRoot(): HTMLElement | null;
|
|
425
|
+
register(id: BlockId, element: HTMLElement): () => void;
|
|
426
|
+
getElement(id: BlockId): HTMLElement | undefined;
|
|
427
|
+
placeCaret(id: BlockId, offset: number): void;
|
|
428
|
+
placeSelection(from: DocPoint, to: DocPoint): void;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
declare const EditorContext: react.Context<Editor | null>;
|
|
432
|
+
declare const EditorViewContext: react.Context<EditorView | null>;
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Тип токена подсветки. Стандартные типы получают цвета из `@inkbrick/styles` (`--inkbrick-syntax-*`); свой подсветчик может
|
|
436
|
+
* вернуть и любой другой тип — он попадёт в `data-inkbrick-token` как есть, и вы раскрасите его своим CSS.
|
|
437
|
+
*/
|
|
438
|
+
type HighlightTokenType = 'keyword' | 'string' | 'comment' | 'number' | 'function' | 'type' | 'constant' | 'builtin' | 'variable' | 'property' | 'tag' | 'attribute' | 'meta' | 'regex' | (string & {});
|
|
439
|
+
interface HighlightToken {
|
|
440
|
+
readonly from: number;
|
|
441
|
+
readonly to: number;
|
|
442
|
+
readonly type: HighlightTokenType;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Подсветчик кода: по тексту и языку (`props.language` блока) возвращает токены. Результат не обязан быть
|
|
446
|
+
* упорядоченным и не должен быть идеальным: пересечения, выход за границы и неверные типы отбрасываются, а текст
|
|
447
|
+
* блока подсветка изменить не может. Встроенный подсветчик — `highlightCode`; подключить Shiki, Prism или
|
|
448
|
+
* highlight.js можно, обернув их в такую функцию (`<EditorProvider highlighter={…}>`).
|
|
449
|
+
*/
|
|
450
|
+
type CodeHighlighter = (code: string, language: string) => readonly HighlightToken[];
|
|
451
|
+
|
|
452
|
+
interface FormulaRenderOptions {
|
|
453
|
+
readonly display: boolean;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Рисует формулу в `target`: по коду LaTeX строит DOM (MathML, HTML, SVG…). Может быть асинхронной — например, для
|
|
457
|
+
* подгрузки библиотеки. Если код ошибочен, функция должна бросить исключение: редактор покажет исходный текст и
|
|
458
|
+
* сообщение об ошибке. Встроенный `temmlRenderer` строит MathML; KaTeX подключается так:
|
|
459
|
+
* `(latex, target, { display }) => katex.render(latex, target, { displayMode: display, throwOnError: true })`.
|
|
460
|
+
*
|
|
461
|
+
* Результат вставляется в страницу как есть, поэтому используйте только безопасные режимы библиотек
|
|
462
|
+
* (например, `trust: false`): LaTeX приходит из документа и может быть недоверенным.
|
|
463
|
+
*/
|
|
464
|
+
type FormulaRenderer = (latex: string, target: HTMLElement, options: FormulaRenderOptions) => void | Promise<void>;
|
|
465
|
+
declare const temmlRenderer: FormulaRenderer;
|
|
466
|
+
/**
|
|
467
|
+
* Подключает стили MathML (Temml) к документу или теневому корню встроенной формулы. В документе стили кладутся
|
|
468
|
+
* в слой `inkbrick.math`, поэтому любое ваше правило без слоя сильнее. Стили подгружаются при первом вызове
|
|
469
|
+
* и применяются, как только загрузятся (одновременно с самой формулой).
|
|
470
|
+
*/
|
|
471
|
+
declare function ensureMathStyles(scope: Document | ShadowRoot): void;
|
|
472
|
+
type FormulaState = 'empty' | 'source' | 'loading' | 'ready' | 'error';
|
|
473
|
+
interface MountFormulaOptions {
|
|
474
|
+
readonly display: boolean;
|
|
475
|
+
readonly renderer: FormulaRenderer | null;
|
|
476
|
+
readonly onSettled?: (state: 'ready' | 'error', message?: string) => void;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Рисует формулу в `target`. Пока идёт расчёт, виден исходный код (`data-state="loading"`); готовый результат кладётся
|
|
480
|
+
* в кэш, поэтому одинаковые формулы (и перерисовка блока на каждое нажатие клавиши) появляются сразу, без мигания.
|
|
481
|
+
* Возвращает функцию отмены: после неё устаревший результат в `target` не попадёт.
|
|
482
|
+
*/
|
|
483
|
+
declare function mountFormula(target: HTMLElement, latex: string, { display, renderer, onSettled }: MountFormulaOptions): () => void;
|
|
484
|
+
|
|
485
|
+
interface SlashMenuItem {
|
|
486
|
+
readonly id: string;
|
|
487
|
+
readonly title: string;
|
|
488
|
+
readonly description?: string;
|
|
489
|
+
readonly keywords?: readonly string[];
|
|
490
|
+
readonly icon?: ReactNode;
|
|
491
|
+
readonly flavour: string;
|
|
492
|
+
readonly props?: Readonly<Record<string, unknown>>;
|
|
493
|
+
}
|
|
494
|
+
interface SlashMenuProps {
|
|
495
|
+
readonly items: readonly SlashMenuItem[];
|
|
496
|
+
readonly query: string;
|
|
497
|
+
readonly activeIndex: number;
|
|
498
|
+
readonly position: {
|
|
499
|
+
readonly x: number;
|
|
500
|
+
readonly y: number;
|
|
501
|
+
};
|
|
502
|
+
readonly onSelect: (item: SlashMenuItem) => void;
|
|
503
|
+
readonly onHover: (index: number) => void;
|
|
504
|
+
readonly onClose: () => void;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
interface KeymapContext {
|
|
508
|
+
readonly editor: Editor;
|
|
509
|
+
readonly view: EditorView;
|
|
510
|
+
readonly root: HTMLElement;
|
|
511
|
+
readonly event: KeyboardEvent;
|
|
512
|
+
readonly slashItems: readonly SlashMenuItem[];
|
|
513
|
+
selection(): DocSelection | null;
|
|
514
|
+
exec<T = unknown>(intent: EditorIntent): T | undefined;
|
|
515
|
+
run(action: () => CaretResult | undefined): void;
|
|
516
|
+
replaceSelection(selection: DocSelection, text: string): CaretResult | undefined;
|
|
517
|
+
undo(): void;
|
|
518
|
+
redo(): void;
|
|
519
|
+
toggleFormat(format: string): void;
|
|
520
|
+
}
|
|
521
|
+
interface KeyBinding {
|
|
522
|
+
/**
|
|
523
|
+
* Уникальное имя. Привязка с тем же `id`, что у стандартной, заменяет её (на её месте в порядке проверки);
|
|
524
|
+
* остальные проверяются раньше стандартных.
|
|
525
|
+
*/
|
|
526
|
+
readonly id: string;
|
|
527
|
+
/**
|
|
528
|
+
* Комбинации: `'Mod-b'`, `'Mod-Shift-z'`, `'Tab'`, `'Shift-Tab'`, `'ArrowDown'`. `Mod` — Ctrl или Cmd.
|
|
529
|
+
* Shift и Alt учитываются точно (`'Tab'` не срабатывает на Shift+Tab). Пустой массив отключает привязку.
|
|
530
|
+
*/
|
|
531
|
+
readonly keys: string | readonly string[];
|
|
532
|
+
readonly when?: (context: KeymapContext) => boolean;
|
|
533
|
+
/**
|
|
534
|
+
* Обработчик. `false` — «не моё»: событие идёт дальше по списку привязок и в браузер.
|
|
535
|
+
* Любой другой результат считается обработкой: `preventDefault` вызывается автоматически.
|
|
536
|
+
*/
|
|
537
|
+
readonly run: (context: KeymapContext) => boolean | void;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
interface ImageOptions {
|
|
541
|
+
/**
|
|
542
|
+
* Загружает файл и возвращает адрес картинки (http(s) или относительный). Без него картинки
|
|
543
|
+
* встраиваются в документ как data:-адреса (до `maxInlineBytes`).
|
|
544
|
+
*/
|
|
545
|
+
readonly upload?: (file: File) => Promise<string>;
|
|
546
|
+
/** Предел размера для встраивания data:-картинки, байт (по умолчанию 1,5 МБ). */
|
|
547
|
+
readonly maxInlineBytes?: number;
|
|
548
|
+
/** Допустимые MIME-типы (по умолчанию PNG, JPEG, GIF, WebP, AVIF). SVG не поддерживается. */
|
|
549
|
+
readonly acceptedTypes?: readonly string[];
|
|
550
|
+
readonly onError?: (error: unknown, file: File) => void;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Props встроенного жеста для элемента-«хваталки»: клик открывает меню, протягивание мышью
|
|
555
|
+
* или долгое нажатие пальцем переносит блок. Свой DnD может их не вешать (см. `useBlockDrag`).
|
|
556
|
+
*/
|
|
557
|
+
interface GripProps {
|
|
558
|
+
readonly onPointerDown: (event: PointerEvent<HTMLElement>) => void;
|
|
559
|
+
/** Долгое нажатие пальцем не должно открывать системное контекстное меню. */
|
|
560
|
+
readonly onContextMenu: (event: MouseEvent<HTMLElement>) => void;
|
|
561
|
+
/** `touch-action: none`: палец на хваталке не прокручивает страницу. */
|
|
562
|
+
readonly style: CSSProperties;
|
|
563
|
+
readonly 'data-inkbrick-grip': '';
|
|
564
|
+
}
|
|
565
|
+
interface BlockHandleProps {
|
|
566
|
+
readonly blockId: string;
|
|
567
|
+
/** Левый верхний угол блока в координатах окна (для position: fixed). */
|
|
568
|
+
readonly position: {
|
|
569
|
+
readonly x: number;
|
|
570
|
+
readonly y: number;
|
|
571
|
+
};
|
|
572
|
+
readonly canAdd: boolean;
|
|
573
|
+
readonly dragging: boolean;
|
|
574
|
+
readonly menuOpen: boolean;
|
|
575
|
+
readonly onAdd: () => void;
|
|
576
|
+
/** Открывает меню действий (например, по клавиатуре). Обычный клик по «хваталке» открывает его сам. */
|
|
577
|
+
readonly onOpenMenu: () => void;
|
|
578
|
+
/**
|
|
579
|
+
* Повесьте на элемент-«хваталку»: клик открывает меню, протягивание мышью или долгое нажатие пальцем
|
|
580
|
+
* переносит блок. Для своего DnD не вешайте их, а вызовите `onOpenMenu` по клику и `useBlockDrag()` для переноса.
|
|
581
|
+
*/
|
|
582
|
+
readonly gripProps: GripProps;
|
|
583
|
+
}
|
|
584
|
+
interface DropIndicatorProps {
|
|
585
|
+
readonly blockId: string;
|
|
586
|
+
readonly targetId: string;
|
|
587
|
+
readonly position: DropPosition;
|
|
588
|
+
/** Где рисовать линию, в координатах окна (для position: fixed). */
|
|
589
|
+
readonly indicator: DropIndicatorRect;
|
|
590
|
+
}
|
|
591
|
+
interface BlockMenuAction {
|
|
592
|
+
readonly id: string;
|
|
593
|
+
readonly title: string;
|
|
594
|
+
readonly icon?: ReactNode;
|
|
595
|
+
readonly disabled?: boolean;
|
|
596
|
+
readonly danger?: boolean;
|
|
597
|
+
readonly run: () => void;
|
|
598
|
+
}
|
|
599
|
+
interface BlockMenuProps {
|
|
600
|
+
readonly block: BaseBlock;
|
|
601
|
+
readonly position: {
|
|
602
|
+
readonly x: number;
|
|
603
|
+
readonly y: number;
|
|
604
|
+
};
|
|
605
|
+
readonly actions: readonly BlockMenuAction[];
|
|
606
|
+
readonly turnInto: readonly BlockMenuAction[];
|
|
607
|
+
readonly onClose: () => void;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Props, которые получает React-представление блока.
|
|
612
|
+
*
|
|
613
|
+
* Блок нельзя изменять напрямую: все изменения документа идут через
|
|
614
|
+
* `editor.dispatch(...)`. Для редактируемого текста используйте компонент
|
|
615
|
+
* `<Editable block={block} placeholder="…" />` — он подключает ввод, выделение и
|
|
616
|
+
* клавиатурные действия редактора. Дочерние блоки выводит `<BlockChildren id={block.id} />`.
|
|
617
|
+
*/
|
|
618
|
+
interface BlockViewProps<TBlock extends BaseBlock = BaseBlock> {
|
|
619
|
+
readonly block: TBlock;
|
|
620
|
+
readonly editor: Editor;
|
|
621
|
+
readonly selected: boolean;
|
|
622
|
+
readonly readOnly: boolean;
|
|
623
|
+
/**
|
|
624
|
+
* Контроллер типа блока (`defineBlock({ controller })`), если есть. Удобнее хук `useBlockController(block)`:
|
|
625
|
+
* его `execute`/`can` сами подставляют `blockId`.
|
|
626
|
+
*/
|
|
627
|
+
readonly controller?: BlockController<any>;
|
|
628
|
+
}
|
|
629
|
+
type BlockComponent<TBlock extends BaseBlock = BaseBlock> = ComponentType<BlockViewProps<TBlock>>;
|
|
630
|
+
type BlockComponentRegistry = Readonly<Partial<Record<string, BlockComponent>>>;
|
|
631
|
+
interface UnknownBlockViewProps extends BlockViewProps {
|
|
632
|
+
/** Уже выведенные дочерние блоки (данные не теряются, даже если тип блока неизвестен). */
|
|
633
|
+
readonly children?: ReactNode;
|
|
634
|
+
}
|
|
635
|
+
interface EditorSlots {
|
|
636
|
+
readonly UnknownBlock?: ComponentType<UnknownBlockViewProps>;
|
|
637
|
+
readonly SlashMenu?: ComponentType<SlashMenuProps>;
|
|
638
|
+
readonly Toolbar?: ComponentType<ToolbarProps> | null;
|
|
639
|
+
/**
|
|
640
|
+
* Ручка слева от блока («+» и хваталка для переноса); `null` отключает ручки, меню и встроенное перетаскивание.
|
|
641
|
+
* Свой DnD подключается через `useBlockDrag()` — в своей ручке или в любом компоненте внутри `<EditorProvider>`.
|
|
642
|
+
*/
|
|
643
|
+
readonly BlockHandle?: ComponentType<BlockHandleProps> | null;
|
|
644
|
+
readonly BlockMenu?: ComponentType<BlockMenuProps>;
|
|
645
|
+
readonly DropIndicator?: ComponentType<DropIndicatorProps> | null;
|
|
646
|
+
}
|
|
647
|
+
interface EditorUIConfig {
|
|
648
|
+
readonly components: BlockComponentRegistry;
|
|
649
|
+
readonly slots: EditorSlots;
|
|
650
|
+
readonly slashItems: readonly SlashMenuItem[];
|
|
651
|
+
readonly highlighter: CodeHighlighter | null;
|
|
652
|
+
readonly formulaRenderer: FormulaRenderer | null;
|
|
653
|
+
readonly locale: string;
|
|
654
|
+
readonly t: TFunction;
|
|
655
|
+
readonly keymap: readonly KeyBinding[];
|
|
656
|
+
readonly images: ImageOptions;
|
|
657
|
+
readonly readOnly?: boolean;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Визуальный слой редактора одним объектом: представления блоков, элементы оболочки (меню, toolbar, ручки),
|
|
662
|
+
* пункты slash-меню, подсветка кода и отрисовка формул. Модель документа и команды от него не зависят, поэтому
|
|
663
|
+
* дизайн-систему можно подключить к любому редактору: `<EditorProvider presentation={myDesignSystem}>`.
|
|
664
|
+
*
|
|
665
|
+
* Отдельные props провайдера (`components`, `slots`, …) уточняют presentation: `components` и `slots`
|
|
666
|
+
* сливаются с ним (одинаковый ключ — из prop), остальное заменяется целиком.
|
|
667
|
+
*/
|
|
668
|
+
interface EditorPresentation {
|
|
669
|
+
readonly components?: BlockComponentRegistry;
|
|
670
|
+
readonly slots?: EditorSlots;
|
|
671
|
+
readonly slashItems?: readonly SlashMenuItem[] | false;
|
|
672
|
+
readonly highlighter?: CodeHighlighter | false;
|
|
673
|
+
readonly formulaRenderer?: FormulaRenderer | false;
|
|
674
|
+
}
|
|
675
|
+
declare function definePresentation<T extends EditorPresentation>(presentation: T): T;
|
|
676
|
+
|
|
677
|
+
type CustomBlockViewProps<TProps extends BlockProps$1 = BlockProps$1> = BlockViewProps<TypedBlock<TProps> & {
|
|
678
|
+
props: TProps;
|
|
679
|
+
}>;
|
|
680
|
+
/**
|
|
681
|
+
* Пользовательский блок целиком: схема документа, React-компонент и (необязательно) контроллер поведения.
|
|
682
|
+
* Схема и контроллер нужны движку (`new Editor({ blocks: [...] })`), компонент — UI (`<EditorProvider blocks>`).
|
|
683
|
+
*/
|
|
684
|
+
interface ReactBlockDefinition<TProps extends BlockProps$1 = BlockProps$1> extends BlockDefinition<TProps> {
|
|
685
|
+
readonly component: ComponentType<CustomBlockViewProps<TProps>>;
|
|
686
|
+
readonly controller?: BlockController<TProps>;
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Объявляет пользовательский блок одним объектом:
|
|
690
|
+
*
|
|
691
|
+
* ```ts
|
|
692
|
+
* export const counterBlock = defineBlock<CounterProps>({ schema, component: CounterView, controller });
|
|
693
|
+
* const editor = new Editor({ blocks: [counterBlock] });
|
|
694
|
+
* <EditorProvider editor={editor} blocks={[counterBlock]}>…
|
|
695
|
+
* ```
|
|
696
|
+
*
|
|
697
|
+
* Объект создавайте один раз (вне компонента).
|
|
698
|
+
*/
|
|
699
|
+
declare function defineBlock<TProps extends BlockProps$1 = BlockProps$1>(definition: ReactBlockDefinition<TProps>): ReactBlockDefinition<TProps>;
|
|
700
|
+
|
|
701
|
+
interface EditorProviderProps {
|
|
702
|
+
readonly editor: Editor;
|
|
703
|
+
readonly children: ReactNode;
|
|
704
|
+
/**
|
|
705
|
+
* Визуальный слой одним объектом (дизайн-система): представления блоков, оболочка, slash-меню, подсветка кода
|
|
706
|
+
* и формулы — см. `definePresentation`. Отдельные props ниже уточняют его. Держите объект стабильным.
|
|
707
|
+
*/
|
|
708
|
+
readonly presentation?: EditorPresentation;
|
|
709
|
+
/**
|
|
710
|
+
* Пользовательские блоки из `defineBlock`: их компоненты добавляются к `components` (prop `components`
|
|
711
|
+
* с тем же flavour важнее). Схемы и контроллеры этих блоков передайте и в `new Editor({ blocks })`:
|
|
712
|
+
* пункты slash-меню, меню блока и клавиши берутся из контроллеров редактора. Держите массив стабильным.
|
|
713
|
+
*/
|
|
714
|
+
readonly blocks?: readonly ReactBlockDefinition<any>[];
|
|
715
|
+
/**
|
|
716
|
+
* Свои React-представления блоков: `{ 'block:paragraph': MyParagraph }`.
|
|
717
|
+
* Не указанные flavour используют стандартные компоненты Inkbrick.
|
|
718
|
+
* Чтобы не перерисовывать документ без необходимости, держите объект стабильным
|
|
719
|
+
* (вынесите из компонента или оберните в useMemo).
|
|
720
|
+
*/
|
|
721
|
+
readonly components?: BlockComponentRegistry;
|
|
722
|
+
readonly slots?: EditorSlots;
|
|
723
|
+
/**
|
|
724
|
+
* Пункты slash-меню. Дополняют стандартные (одинаковый `id` заменяет стандартный пункт);
|
|
725
|
+
* `false` выключает меню. Держите массив стабильным (вынесите из компонента или useMemo).
|
|
726
|
+
*/
|
|
727
|
+
readonly slashItems?: readonly SlashMenuItem[] | false;
|
|
728
|
+
/**
|
|
729
|
+
* Подсветка синтаксиса в блоках кода. По умолчанию — встроенный `highlightCode` (без зависимостей);
|
|
730
|
+
* свой подсветчик (Shiki, Prism, highlight.js) — функция `(code, language) => токены`; `false` выключает подсветку.
|
|
731
|
+
* Держите функцию стабильной: смена функции перерисовывает все блоки кода.
|
|
732
|
+
*/
|
|
733
|
+
readonly highlighter?: CodeHighlighter | false;
|
|
734
|
+
/**
|
|
735
|
+
* Отрисовка формул (блоки и встроенные): по умолчанию Temml → MathML, подгружается при первой формуле.
|
|
736
|
+
* Свой подсчётчик (KaTeX, MathJax) — функция `(latex, target, { display }) => void | Promise<void>`;
|
|
737
|
+
* `false` — показывать только исходный код. Держите функцию стабильной: её смена перерисовывает все формулы.
|
|
738
|
+
*/
|
|
739
|
+
readonly formulaRenderer?: FormulaRenderer | false;
|
|
740
|
+
/**
|
|
741
|
+
* Язык интерфейса: код подключённого словаря (`'en'`, `'ru'` или свой, см. `registerLocale` и `locales`).
|
|
742
|
+
* `'pt-BR'` без своего словаря возьмёт `'pt'`; неизвестный код — английский. По умолчанию `'en'`.
|
|
743
|
+
*/
|
|
744
|
+
readonly locale?: string;
|
|
745
|
+
/**
|
|
746
|
+
* Словари, подключаемые только к этому редактору: `{ de: { 'menu.delete': 'Löschen', … } }`.
|
|
747
|
+
* Словарь может быть неполным — недостающее берётся из английского. Держите объект стабильным.
|
|
748
|
+
*/
|
|
749
|
+
readonly locales?: Readonly<Record<string, PartialMessages>>;
|
|
750
|
+
/** Точечные замены строк поверх выбранного языка: `{ 'menu.delete': 'Убрать' }`. Держите объект стабильным. */
|
|
751
|
+
readonly messages?: PartialMessages;
|
|
752
|
+
/**
|
|
753
|
+
* Свои привязки клавиш. Привязка с `id` стандартной (`'undo'`, `'format.bold'`, `'indent'`, …) заменяет её,
|
|
754
|
+
* новая проверяется раньше стандартных; `unbind('id')` отключает стандартную. Держите массив стабильным.
|
|
755
|
+
*/
|
|
756
|
+
readonly keymap?: readonly KeyBinding[];
|
|
757
|
+
/**
|
|
758
|
+
* Режим только чтения: ввод, команды, undo, toolbar, ручки блоков и slash-меню отключены,
|
|
759
|
+
* выделение и копирование работают. Применяется к редактору (`editor.setReadOnly`), поэтому
|
|
760
|
+
* защищает документ и от вызовов из кода.
|
|
761
|
+
*/
|
|
762
|
+
readonly readOnly?: boolean;
|
|
763
|
+
/**
|
|
764
|
+
* Изображения: `upload` — куда сохранять файлы (иначе картинки встраиваются в документ как data:-адреса
|
|
765
|
+
* до `maxInlineBytes`), `acceptedTypes`, `onError`. Держите объект стабильным.
|
|
766
|
+
*/
|
|
767
|
+
readonly images?: ImageOptions;
|
|
768
|
+
}
|
|
769
|
+
declare function EditorProvider({ editor, children, presentation, blocks, components, slots, slashItems, keymap, highlighter, formulaRenderer, locale, locales, messages, readOnly, images, }: EditorProviderProps): react.JSX.Element;
|
|
770
|
+
|
|
771
|
+
declare function useEditor(): _inkbrick_engine.Editor;
|
|
772
|
+
|
|
773
|
+
declare function useEditorView(): EditorView;
|
|
774
|
+
|
|
775
|
+
declare function useDocument(): _inkbrick_document.Document;
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Подписывается на один блок. Блоки в документе иммутабельны (каждое изменение
|
|
779
|
+
* создаёт новый объект), поэтому ссылка — корректный snapshot для React.
|
|
780
|
+
*/
|
|
781
|
+
declare function useBlock(id: BlockId): _inkbrick_document.BaseBlock | undefined;
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Идентификаторы дочерних блоков. Возвращает стабильную ссылку, пока children
|
|
785
|
+
* не изменились (создавать новый массив в getSnapshot нельзя — это приводит
|
|
786
|
+
* к бесконечному циклу рендера в useSyncExternalStore).
|
|
787
|
+
*/
|
|
788
|
+
declare function useChildren(parentId: BlockId): readonly BlockId[];
|
|
789
|
+
|
|
790
|
+
interface HistoryControls {
|
|
791
|
+
readonly canUndo: boolean;
|
|
792
|
+
readonly canRedo: boolean;
|
|
793
|
+
undo(): boolean;
|
|
794
|
+
redo(): boolean;
|
|
795
|
+
}
|
|
796
|
+
declare function useHistory(): HistoryControls;
|
|
797
|
+
|
|
798
|
+
declare function useReadOnly(): boolean;
|
|
799
|
+
|
|
800
|
+
interface BlockControllerHandle<TProps extends BlockProps$1 = BlockProps$1> extends BlockContext<TProps> {
|
|
801
|
+
readonly controller: BlockController<TProps> | undefined;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Контроллер блока для его React-компонента: `execute('counter.increment')` и `can(...)` уже знают `blockId`.
|
|
805
|
+
* Команды уважают режим только чтения (возвращают undefined); для разметки используйте prop `readOnly`.
|
|
806
|
+
*/
|
|
807
|
+
declare function useBlockController<TProps extends BlockProps$1 = BlockProps$1>(block: BaseBlock): BlockControllerHandle<TProps>;
|
|
808
|
+
|
|
809
|
+
declare function embeddedFragment(html: string): Fragment | null;
|
|
810
|
+
declare function htmlToFragment(html: string): Fragment | null;
|
|
811
|
+
|
|
812
|
+
declare function uploadImage(file: File, options: ImageOptions): Promise<string>;
|
|
813
|
+
declare function normalizeImageUrl(input: string): string | null;
|
|
814
|
+
|
|
815
|
+
/** Props встроенных компонентов; пользовательским компонентам доступны также `editor`, `selected` и `readOnly`. */
|
|
816
|
+
type BlockProps = Pick<BlockViewProps, 'block'> & Partial<Pick<BlockViewProps, 'selected' | 'readOnly'>>;
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Выводит дочерние блоки `id` — для пользовательских компонентов-контейнеров. Как именно (все сразу или только
|
|
820
|
+
* видимые), решает рендерер документа (`<DocumentView renderer>`).
|
|
821
|
+
*/
|
|
822
|
+
declare function BlockChildren({ id }: {
|
|
823
|
+
readonly id: BlockId;
|
|
824
|
+
}): react.JSX.Element;
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* Стандартная заглушка для блока с незарегистрированным flavour.
|
|
828
|
+
* Не редактируется; данные блока остаются в документе нетронутыми.
|
|
829
|
+
*/
|
|
830
|
+
declare function UnknownBlockView({ block, children }: UnknownBlockViewProps): react.JSX.Element;
|
|
831
|
+
|
|
832
|
+
interface EditableProps {
|
|
833
|
+
readonly block: BaseBlock;
|
|
834
|
+
/**
|
|
835
|
+
* Собственная подсказка пустого блока (показывается всегда, пока блок пуст). Не нужна: по умолчанию редактор
|
|
836
|
+
* сам показывает одну общую подсказку («Нажмите / …») в пустом блоке, где стоит каретка.
|
|
837
|
+
*/
|
|
838
|
+
readonly placeholder?: string;
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Текст блока. Сам по себе не является contenteditable: редактируемым элементом
|
|
842
|
+
* служит корень `<DocumentView>`, благодаря чему выделение может охватывать несколько блоков.
|
|
843
|
+
* Содержимое рисуется из `block.content`, а ввод обрабатывается корнем через движок.
|
|
844
|
+
*
|
|
845
|
+
* Атрибуты для стилизации: `data-empty`, `data-focused` (каретка в этом блоке), `data-hint` (текст общей
|
|
846
|
+
* подсказки; есть только там, где работает slash-меню), `data-placeholder` (своя подсказка, если задана).
|
|
847
|
+
*/
|
|
848
|
+
declare function Editable({ block, placeholder }: EditableProps): react.JSX.Element;
|
|
849
|
+
|
|
850
|
+
declare function PageBlock({ block }: BlockProps): react.JSX.Element;
|
|
851
|
+
|
|
852
|
+
declare function NoteBlock({ block }: BlockProps): react.JSX.Element;
|
|
853
|
+
|
|
854
|
+
declare function ParagraphBlock({ block, selected }: BlockProps): react.JSX.Element;
|
|
855
|
+
|
|
856
|
+
declare function HeadingBlock({ block, selected }: BlockProps): react.JSX.Element;
|
|
857
|
+
|
|
858
|
+
declare function ListBlock({ block, selected, readOnly }: BlockProps): react.JSX.Element;
|
|
859
|
+
|
|
860
|
+
declare function QuoteBlock({ block, selected }: BlockProps): react.JSX.Element;
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Языки в выпадающем списке. Редактор хранит только `language`; подсветку делает `highlighter` провайдера
|
|
864
|
+
* (по умолчанию встроенный — он знает эти языки и их псевдонимы).
|
|
865
|
+
*/
|
|
866
|
+
declare const CODE_LANGUAGES: readonly ["plain", "typescript", "javascript", "json", "html", "css", "python", "bash", "sql", "go", "rust", "java", "c", "cpp", "markdown", "yaml"];
|
|
867
|
+
declare function CodeBlock({ block, editor, selected, readOnly }: BlockViewProps): react.JSX.Element;
|
|
868
|
+
|
|
869
|
+
declare function DividerBlock({ block, selected }: BlockProps): react.JSX.Element;
|
|
870
|
+
|
|
871
|
+
declare function CalloutBlock({ block, editor, selected, readOnly }: BlockViewProps): react.JSX.Element;
|
|
872
|
+
|
|
873
|
+
declare function ImageBlock({ block, editor, selected, readOnly }: BlockViewProps): react.JSX.Element;
|
|
874
|
+
|
|
875
|
+
interface BlockRendererProps {
|
|
876
|
+
readonly id: BlockId;
|
|
877
|
+
}
|
|
878
|
+
declare const BlockRenderer: react.NamedExoticComponent<BlockRendererProps>;
|
|
879
|
+
|
|
880
|
+
interface ChildListProps {
|
|
881
|
+
readonly parentId: BlockId;
|
|
882
|
+
readonly ids: readonly BlockId[];
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Способ отрисовки документа: как выводить детей каждого контейнера (страницы, заметки, вложенного списка).
|
|
886
|
+
* Модель и команды от него не зависят. Встроенные варианты — `fullRenderer` (всё дерево, по умолчанию)
|
|
887
|
+
* и `virtualRenderer()` (только блоки около видимой области).
|
|
888
|
+
*/
|
|
889
|
+
interface DocumentRenderer {
|
|
890
|
+
readonly ChildList: ComponentType<ChildListProps>;
|
|
891
|
+
}
|
|
892
|
+
declare const fullRenderer: DocumentRenderer;
|
|
893
|
+
|
|
894
|
+
interface DocumentViewProps {
|
|
895
|
+
readonly label?: string;
|
|
896
|
+
/**
|
|
897
|
+
* Как рисовать блоки: `'full'` (по умолчанию) — всё дерево; `'virtual'` или `virtualRenderer({...})` — только
|
|
898
|
+
* блоки около видимой области (для документов на тысячи блоков); либо свой `DocumentRenderer`.
|
|
899
|
+
*/
|
|
900
|
+
readonly renderer?: 'full' | 'virtual' | DocumentRenderer;
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Единственный редактируемый элемент документа. Все блоки лежат внутри него, поэтому
|
|
904
|
+
* выделение работает через границы блоков; ввод перехватывается и превращается в команды движка.
|
|
905
|
+
*/
|
|
906
|
+
declare function DocumentView({ label, renderer }?: DocumentViewProps): react.JSX.Element;
|
|
907
|
+
|
|
908
|
+
type BlockHeightEstimate = (block: BaseBlock) => number;
|
|
909
|
+
/**
|
|
910
|
+
* Оценка по умолчанию под стандартные стили: строки текста × высота строки + отступы блока.
|
|
911
|
+
* Ошибка оценки сказывается только на длине полосы прокрутки: отрисованный блок измеряется точно.
|
|
912
|
+
*/
|
|
913
|
+
declare const estimateBlockHeight: BlockHeightEstimate;
|
|
914
|
+
|
|
915
|
+
interface VirtualRendererOptions {
|
|
916
|
+
/** Контейнер с меньшим числом детей рисуется целиком. По умолчанию 100. */
|
|
917
|
+
readonly threshold?: number;
|
|
918
|
+
/** Запас над и под видимой областью, в котором блоки уже отрисованы, px. По умолчанию 1200. */
|
|
919
|
+
readonly overscan?: number;
|
|
920
|
+
/** Не больше стольких блоков подряд в окне (защита от нулевых высот). По умолчанию 400. */
|
|
921
|
+
readonly maxRendered?: number;
|
|
922
|
+
readonly estimateHeight?: BlockHeightEstimate;
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Виртуальный рендерер: в DOM только блоки около видимой области, остальные заменены распорками известной
|
|
926
|
+
* (измеренной) или оценённой высоты. Подключение: `<DocumentView renderer={virtualRenderer()} />` (или
|
|
927
|
+
* `renderer="virtual"` с настройками по умолчанию). Создавайте рендерер один раз, вне компонента.
|
|
928
|
+
*/
|
|
929
|
+
declare function virtualRenderer(options?: VirtualRendererOptions): DocumentRenderer;
|
|
930
|
+
|
|
931
|
+
declare function useEditorUI(): EditorUIConfig;
|
|
932
|
+
|
|
933
|
+
declare const defaultBlockComponents: BlockComponentRegistry;
|
|
934
|
+
|
|
935
|
+
declare function resolveBlockComponent(flavour: string, custom: BlockComponentRegistry): BlockComponent | undefined;
|
|
936
|
+
|
|
937
|
+
/** Длиннее этого текста блок не подсвечивается: подсветка пересчитывается на каждое нажатие клавиши. */
|
|
938
|
+
declare const HIGHLIGHT_LIMIT = 100000;
|
|
939
|
+
declare function normalizeLanguage(language: string): string;
|
|
940
|
+
/**
|
|
941
|
+
* Встроенный подсветчик: без зависимостей, по правилам для распространённых языков (JavaScript/TypeScript, Python,
|
|
942
|
+
* Go, Rust, Java, C/C++, Bash, SQL, JSON, YAML, HTML/XML, CSS, Markdown). Это не полноценный разбор, а быстрая
|
|
943
|
+
* лексическая раскраска; для точности подключите свой `CodeHighlighter` (Shiki, Prism, highlight.js).
|
|
944
|
+
* Неизвестный язык, `plain` и слишком длинный текст дают пустой список токенов.
|
|
945
|
+
*/
|
|
946
|
+
declare const highlightCode: CodeHighlighter;
|
|
947
|
+
|
|
948
|
+
interface FormulaViewProps {
|
|
949
|
+
readonly latex: string;
|
|
950
|
+
readonly display?: boolean;
|
|
951
|
+
readonly showError?: boolean;
|
|
952
|
+
readonly onSettled?: (state: 'ready' | 'error', message?: string) => void;
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Формула, нарисованная выбранным в `EditorProvider` подсчётчиком (по умолчанию Temml → MathML). Пока считается и при
|
|
956
|
+
* ошибке виден исходный код. Атрибуты: `data-inkbrick-part="formula-render"`, `data-state="empty|source|loading|ready|error"`.
|
|
957
|
+
*/
|
|
958
|
+
declare function FormulaView({ latex, display, showError, onSettled, }: FormulaViewProps): react.JSX.Element;
|
|
959
|
+
|
|
960
|
+
declare function useT(): TFunction;
|
|
961
|
+
declare function useLocale(): string;
|
|
962
|
+
|
|
963
|
+
declare const ru: Messages;
|
|
964
|
+
|
|
965
|
+
declare const ICON_SHAPES: {
|
|
966
|
+
readonly bold: readonly [readonly ["path", {
|
|
967
|
+
readonly d: "M6 12h9a4 4 0 010 8H7a1 1 0 01-1-1V5a1 1 0 011-1h7a4 4 0 010 8";
|
|
968
|
+
}]];
|
|
969
|
+
readonly italic: readonly [readonly ["line", {
|
|
970
|
+
readonly x1: "19";
|
|
971
|
+
readonly x2: "10";
|
|
972
|
+
readonly y1: "4";
|
|
973
|
+
readonly y2: "4";
|
|
974
|
+
}], readonly ["line", {
|
|
975
|
+
readonly x1: "14";
|
|
976
|
+
readonly x2: "5";
|
|
977
|
+
readonly y1: "20";
|
|
978
|
+
readonly y2: "20";
|
|
979
|
+
}], readonly ["line", {
|
|
980
|
+
readonly x1: "15";
|
|
981
|
+
readonly x2: "9";
|
|
982
|
+
readonly y1: "4";
|
|
983
|
+
readonly y2: "20";
|
|
984
|
+
}]];
|
|
985
|
+
readonly underline: readonly [readonly ["path", {
|
|
986
|
+
readonly d: "M6 4v6a6 6 0 0 0 12 0V4";
|
|
987
|
+
}], readonly ["line", {
|
|
988
|
+
readonly x1: "4";
|
|
989
|
+
readonly x2: "20";
|
|
990
|
+
readonly y1: "20";
|
|
991
|
+
readonly y2: "20";
|
|
992
|
+
}]];
|
|
993
|
+
readonly strike: readonly [readonly ["path", {
|
|
994
|
+
readonly d: "M16 4H9a3 3 0 0 0-2.83 4";
|
|
995
|
+
}], readonly ["path", {
|
|
996
|
+
readonly d: "M14 12a4 4 0 0 1 0 8H6";
|
|
997
|
+
}], readonly ["line", {
|
|
998
|
+
readonly x1: "4";
|
|
999
|
+
readonly x2: "20";
|
|
1000
|
+
readonly y1: "12";
|
|
1001
|
+
readonly y2: "12";
|
|
1002
|
+
}]];
|
|
1003
|
+
readonly code: readonly [readonly ["path", {
|
|
1004
|
+
readonly d: "m18 16 4-4-4-4";
|
|
1005
|
+
}], readonly ["path", {
|
|
1006
|
+
readonly d: "m6 8-4 4 4 4";
|
|
1007
|
+
}], readonly ["path", {
|
|
1008
|
+
readonly d: "m14.5 4-5 16";
|
|
1009
|
+
}]];
|
|
1010
|
+
readonly link: readonly [readonly ["path", {
|
|
1011
|
+
readonly d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71";
|
|
1012
|
+
}], readonly ["path", {
|
|
1013
|
+
readonly d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71";
|
|
1014
|
+
}]];
|
|
1015
|
+
readonly unlink: readonly [readonly ["path", {
|
|
1016
|
+
readonly d: "m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71";
|
|
1017
|
+
}], readonly ["path", {
|
|
1018
|
+
readonly d: "m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71";
|
|
1019
|
+
}], readonly ["line", {
|
|
1020
|
+
readonly x1: "8";
|
|
1021
|
+
readonly x2: "8";
|
|
1022
|
+
readonly y1: "2";
|
|
1023
|
+
readonly y2: "5";
|
|
1024
|
+
}], readonly ["line", {
|
|
1025
|
+
readonly x1: "2";
|
|
1026
|
+
readonly x2: "5";
|
|
1027
|
+
readonly y1: "8";
|
|
1028
|
+
readonly y2: "8";
|
|
1029
|
+
}], readonly ["line", {
|
|
1030
|
+
readonly x1: "16";
|
|
1031
|
+
readonly x2: "16";
|
|
1032
|
+
readonly y1: "19";
|
|
1033
|
+
readonly y2: "22";
|
|
1034
|
+
}], readonly ["line", {
|
|
1035
|
+
readonly x1: "19";
|
|
1036
|
+
readonly x2: "22";
|
|
1037
|
+
readonly y1: "16";
|
|
1038
|
+
readonly y2: "16";
|
|
1039
|
+
}]];
|
|
1040
|
+
readonly check: readonly [readonly ["path", {
|
|
1041
|
+
readonly d: "M20 6 9 17l-5-5";
|
|
1042
|
+
}]];
|
|
1043
|
+
readonly x: readonly [readonly ["path", {
|
|
1044
|
+
readonly d: "M18 6 6 18";
|
|
1045
|
+
}], readonly ["path", {
|
|
1046
|
+
readonly d: "m6 6 12 12";
|
|
1047
|
+
}]];
|
|
1048
|
+
readonly plus: readonly [readonly ["path", {
|
|
1049
|
+
readonly d: "M5 12h14";
|
|
1050
|
+
}], readonly ["path", {
|
|
1051
|
+
readonly d: "M12 5v14";
|
|
1052
|
+
}]];
|
|
1053
|
+
readonly grip: readonly [readonly ["circle", {
|
|
1054
|
+
readonly cx: "9";
|
|
1055
|
+
readonly cy: "12";
|
|
1056
|
+
readonly r: "1";
|
|
1057
|
+
}], readonly ["circle", {
|
|
1058
|
+
readonly cx: "9";
|
|
1059
|
+
readonly cy: "5";
|
|
1060
|
+
readonly r: "1";
|
|
1061
|
+
}], readonly ["circle", {
|
|
1062
|
+
readonly cx: "9";
|
|
1063
|
+
readonly cy: "19";
|
|
1064
|
+
readonly r: "1";
|
|
1065
|
+
}], readonly ["circle", {
|
|
1066
|
+
readonly cx: "15";
|
|
1067
|
+
readonly cy: "12";
|
|
1068
|
+
readonly r: "1";
|
|
1069
|
+
}], readonly ["circle", {
|
|
1070
|
+
readonly cx: "15";
|
|
1071
|
+
readonly cy: "5";
|
|
1072
|
+
readonly r: "1";
|
|
1073
|
+
}], readonly ["circle", {
|
|
1074
|
+
readonly cx: "15";
|
|
1075
|
+
readonly cy: "19";
|
|
1076
|
+
readonly r: "1";
|
|
1077
|
+
}]];
|
|
1078
|
+
readonly trash: readonly [readonly ["path", {
|
|
1079
|
+
readonly d: "M10 11v6";
|
|
1080
|
+
}], readonly ["path", {
|
|
1081
|
+
readonly d: "M14 11v6";
|
|
1082
|
+
}], readonly ["path", {
|
|
1083
|
+
readonly d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6";
|
|
1084
|
+
}], readonly ["path", {
|
|
1085
|
+
readonly d: "M3 6h18";
|
|
1086
|
+
}], readonly ["path", {
|
|
1087
|
+
readonly d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2";
|
|
1088
|
+
}]];
|
|
1089
|
+
readonly copy: readonly [readonly ["rect", {
|
|
1090
|
+
readonly width: "14";
|
|
1091
|
+
readonly height: "14";
|
|
1092
|
+
readonly x: "8";
|
|
1093
|
+
readonly y: "8";
|
|
1094
|
+
readonly rx: "2";
|
|
1095
|
+
readonly ry: "2";
|
|
1096
|
+
}], readonly ["path", {
|
|
1097
|
+
readonly d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2";
|
|
1098
|
+
}]];
|
|
1099
|
+
readonly 'arrow-up': readonly [readonly ["path", {
|
|
1100
|
+
readonly d: "m5 12 7-7 7 7";
|
|
1101
|
+
}], readonly ["path", {
|
|
1102
|
+
readonly d: "M12 19V5";
|
|
1103
|
+
}]];
|
|
1104
|
+
readonly 'arrow-down': readonly [readonly ["path", {
|
|
1105
|
+
readonly d: "M12 5v14";
|
|
1106
|
+
}], readonly ["path", {
|
|
1107
|
+
readonly d: "m19 12-7 7-7-7";
|
|
1108
|
+
}]];
|
|
1109
|
+
readonly 'chevron-down': readonly [readonly ["path", {
|
|
1110
|
+
readonly d: "m6 9 6 6 6-6";
|
|
1111
|
+
}]];
|
|
1112
|
+
readonly text: readonly [readonly ["path", {
|
|
1113
|
+
readonly d: "M13 4v16";
|
|
1114
|
+
}], readonly ["path", {
|
|
1115
|
+
readonly d: "M17 4v16";
|
|
1116
|
+
}], readonly ["path", {
|
|
1117
|
+
readonly d: "M19 4H9.5a4.5 4.5 0 0 0 0 9H13";
|
|
1118
|
+
}]];
|
|
1119
|
+
readonly 'heading-1': readonly [readonly ["path", {
|
|
1120
|
+
readonly d: "M4 12h8";
|
|
1121
|
+
}], readonly ["path", {
|
|
1122
|
+
readonly d: "M4 18V6";
|
|
1123
|
+
}], readonly ["path", {
|
|
1124
|
+
readonly d: "M12 18V6";
|
|
1125
|
+
}], readonly ["path", {
|
|
1126
|
+
readonly d: "m17 12 3-2v8";
|
|
1127
|
+
}]];
|
|
1128
|
+
readonly 'heading-2': readonly [readonly ["path", {
|
|
1129
|
+
readonly d: "M4 12h8";
|
|
1130
|
+
}], readonly ["path", {
|
|
1131
|
+
readonly d: "M4 18V6";
|
|
1132
|
+
}], readonly ["path", {
|
|
1133
|
+
readonly d: "M12 18V6";
|
|
1134
|
+
}], readonly ["path", {
|
|
1135
|
+
readonly d: "M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1";
|
|
1136
|
+
}]];
|
|
1137
|
+
readonly 'heading-3': readonly [readonly ["path", {
|
|
1138
|
+
readonly d: "M4 12h8";
|
|
1139
|
+
}], readonly ["path", {
|
|
1140
|
+
readonly d: "M4 18V6";
|
|
1141
|
+
}], readonly ["path", {
|
|
1142
|
+
readonly d: "M12 18V6";
|
|
1143
|
+
}], readonly ["path", {
|
|
1144
|
+
readonly d: "M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2";
|
|
1145
|
+
}], readonly ["path", {
|
|
1146
|
+
readonly d: "M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2";
|
|
1147
|
+
}]];
|
|
1148
|
+
readonly 'heading-4': readonly [readonly ["path", {
|
|
1149
|
+
readonly d: "M12 18V6";
|
|
1150
|
+
}], readonly ["path", {
|
|
1151
|
+
readonly d: "M17 10v3a1 1 0 0 0 1 1h3";
|
|
1152
|
+
}], readonly ["path", {
|
|
1153
|
+
readonly d: "M21 10v8";
|
|
1154
|
+
}], readonly ["path", {
|
|
1155
|
+
readonly d: "M4 12h8";
|
|
1156
|
+
}], readonly ["path", {
|
|
1157
|
+
readonly d: "M4 18V6";
|
|
1158
|
+
}]];
|
|
1159
|
+
readonly 'heading-5': readonly [readonly ["path", {
|
|
1160
|
+
readonly d: "M4 12h8";
|
|
1161
|
+
}], readonly ["path", {
|
|
1162
|
+
readonly d: "M4 18V6";
|
|
1163
|
+
}], readonly ["path", {
|
|
1164
|
+
readonly d: "M12 18V6";
|
|
1165
|
+
}], readonly ["path", {
|
|
1166
|
+
readonly d: "M17 13v-3h4";
|
|
1167
|
+
}], readonly ["path", {
|
|
1168
|
+
readonly d: "M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17";
|
|
1169
|
+
}]];
|
|
1170
|
+
readonly 'heading-6': readonly [readonly ["path", {
|
|
1171
|
+
readonly d: "M4 12h8";
|
|
1172
|
+
}], readonly ["path", {
|
|
1173
|
+
readonly d: "M4 18V6";
|
|
1174
|
+
}], readonly ["path", {
|
|
1175
|
+
readonly d: "M12 18V6";
|
|
1176
|
+
}], readonly ["circle", {
|
|
1177
|
+
readonly cx: "19";
|
|
1178
|
+
readonly cy: "16";
|
|
1179
|
+
readonly r: "2";
|
|
1180
|
+
}], readonly ["path", {
|
|
1181
|
+
readonly d: "M20 10c-2 2-3 3.5-3 6";
|
|
1182
|
+
}]];
|
|
1183
|
+
readonly list: readonly [readonly ["path", {
|
|
1184
|
+
readonly d: "M3 5h.01";
|
|
1185
|
+
}], readonly ["path", {
|
|
1186
|
+
readonly d: "M3 12h.01";
|
|
1187
|
+
}], readonly ["path", {
|
|
1188
|
+
readonly d: "M3 19h.01";
|
|
1189
|
+
}], readonly ["path", {
|
|
1190
|
+
readonly d: "M8 5h13";
|
|
1191
|
+
}], readonly ["path", {
|
|
1192
|
+
readonly d: "M8 12h13";
|
|
1193
|
+
}], readonly ["path", {
|
|
1194
|
+
readonly d: "M8 19h13";
|
|
1195
|
+
}]];
|
|
1196
|
+
readonly 'list-ordered': readonly [readonly ["path", {
|
|
1197
|
+
readonly d: "M11 5h10";
|
|
1198
|
+
}], readonly ["path", {
|
|
1199
|
+
readonly d: "M11 12h10";
|
|
1200
|
+
}], readonly ["path", {
|
|
1201
|
+
readonly d: "M11 19h10";
|
|
1202
|
+
}], readonly ["path", {
|
|
1203
|
+
readonly d: "M4 4h1v5";
|
|
1204
|
+
}], readonly ["path", {
|
|
1205
|
+
readonly d: "M4 9h2";
|
|
1206
|
+
}], readonly ["path", {
|
|
1207
|
+
readonly d: "M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02";
|
|
1208
|
+
}]];
|
|
1209
|
+
readonly 'list-todo': readonly [readonly ["path", {
|
|
1210
|
+
readonly d: "M13 5h8";
|
|
1211
|
+
}], readonly ["path", {
|
|
1212
|
+
readonly d: "M13 12h8";
|
|
1213
|
+
}], readonly ["path", {
|
|
1214
|
+
readonly d: "M13 19h8";
|
|
1215
|
+
}], readonly ["path", {
|
|
1216
|
+
readonly d: "m3 17 2 2 4-4";
|
|
1217
|
+
}], readonly ["path", {
|
|
1218
|
+
readonly d: "m3 7 2 2 4-4";
|
|
1219
|
+
}]];
|
|
1220
|
+
readonly quote: readonly [readonly ["path", {
|
|
1221
|
+
readonly d: "M17 5H3";
|
|
1222
|
+
}], readonly ["path", {
|
|
1223
|
+
readonly d: "M21 12H8";
|
|
1224
|
+
}], readonly ["path", {
|
|
1225
|
+
readonly d: "M21 19H8";
|
|
1226
|
+
}], readonly ["path", {
|
|
1227
|
+
readonly d: "M3 12v7";
|
|
1228
|
+
}]];
|
|
1229
|
+
readonly divider: readonly [readonly ["path", {
|
|
1230
|
+
readonly d: "M5 12h14";
|
|
1231
|
+
}]];
|
|
1232
|
+
readonly info: readonly [readonly ["circle", {
|
|
1233
|
+
readonly cx: "12";
|
|
1234
|
+
readonly cy: "12";
|
|
1235
|
+
readonly r: "10";
|
|
1236
|
+
}], readonly ["path", {
|
|
1237
|
+
readonly d: "M12 16v-4";
|
|
1238
|
+
}], readonly ["path", {
|
|
1239
|
+
readonly d: "M12 8h.01";
|
|
1240
|
+
}]];
|
|
1241
|
+
readonly warning: readonly [readonly ["path", {
|
|
1242
|
+
readonly d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3";
|
|
1243
|
+
}], readonly ["path", {
|
|
1244
|
+
readonly d: "M12 9v4";
|
|
1245
|
+
}], readonly ["path", {
|
|
1246
|
+
readonly d: "M12 17h.01";
|
|
1247
|
+
}]];
|
|
1248
|
+
readonly success: readonly [readonly ["circle", {
|
|
1249
|
+
readonly cx: "12";
|
|
1250
|
+
readonly cy: "12";
|
|
1251
|
+
readonly r: "10";
|
|
1252
|
+
}], readonly ["path", {
|
|
1253
|
+
readonly d: "m16 9-5.5 5.5L8 12";
|
|
1254
|
+
}]];
|
|
1255
|
+
readonly danger: readonly [readonly ["path", {
|
|
1256
|
+
readonly d: "m15 9-6 6";
|
|
1257
|
+
}], readonly ["path", {
|
|
1258
|
+
readonly d: "M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z";
|
|
1259
|
+
}], readonly ["path", {
|
|
1260
|
+
readonly d: "m9 9 6 6";
|
|
1261
|
+
}]];
|
|
1262
|
+
readonly image: readonly [readonly ["rect", {
|
|
1263
|
+
readonly width: "18";
|
|
1264
|
+
readonly height: "18";
|
|
1265
|
+
readonly x: "3";
|
|
1266
|
+
readonly y: "3";
|
|
1267
|
+
readonly rx: "2";
|
|
1268
|
+
readonly ry: "2";
|
|
1269
|
+
}], readonly ["circle", {
|
|
1270
|
+
readonly cx: "9";
|
|
1271
|
+
readonly cy: "9";
|
|
1272
|
+
readonly r: "2";
|
|
1273
|
+
}], readonly ["path", {
|
|
1274
|
+
readonly d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21";
|
|
1275
|
+
}]];
|
|
1276
|
+
readonly replace: readonly [readonly ["path", {
|
|
1277
|
+
readonly d: "M14 4a1 1 0 0 1 1-1";
|
|
1278
|
+
}], readonly ["path", {
|
|
1279
|
+
readonly d: "M15 10a1 1 0 0 1-1-1";
|
|
1280
|
+
}], readonly ["path", {
|
|
1281
|
+
readonly d: "M21 4a1 1 0 0 0-1-1";
|
|
1282
|
+
}], readonly ["path", {
|
|
1283
|
+
readonly d: "M21 9a1 1 0 0 1-1 1";
|
|
1284
|
+
}], readonly ["path", {
|
|
1285
|
+
readonly d: "m3 7 3 3 3-3";
|
|
1286
|
+
}], readonly ["path", {
|
|
1287
|
+
readonly d: "M6 10V5a2 2 0 0 1 2-2h2";
|
|
1288
|
+
}], readonly ["rect", {
|
|
1289
|
+
readonly x: "3";
|
|
1290
|
+
readonly y: "14";
|
|
1291
|
+
readonly width: "7";
|
|
1292
|
+
readonly height: "7";
|
|
1293
|
+
readonly rx: "1";
|
|
1294
|
+
}]];
|
|
1295
|
+
readonly 'align-left': readonly [readonly ["path", {
|
|
1296
|
+
readonly d: "M21 5H3";
|
|
1297
|
+
}], readonly ["path", {
|
|
1298
|
+
readonly d: "M15 12H3";
|
|
1299
|
+
}], readonly ["path", {
|
|
1300
|
+
readonly d: "M17 19H3";
|
|
1301
|
+
}]];
|
|
1302
|
+
readonly 'align-center': readonly [readonly ["path", {
|
|
1303
|
+
readonly d: "M21 5H3";
|
|
1304
|
+
}], readonly ["path", {
|
|
1305
|
+
readonly d: "M17 12H7";
|
|
1306
|
+
}], readonly ["path", {
|
|
1307
|
+
readonly d: "M19 19H5";
|
|
1308
|
+
}]];
|
|
1309
|
+
readonly 'align-right': readonly [readonly ["path", {
|
|
1310
|
+
readonly d: "M21 5H3";
|
|
1311
|
+
}], readonly ["path", {
|
|
1312
|
+
readonly d: "M21 12H9";
|
|
1313
|
+
}], readonly ["path", {
|
|
1314
|
+
readonly d: "M21 19H7";
|
|
1315
|
+
}]];
|
|
1316
|
+
readonly 'align-justify': readonly [readonly ["path", {
|
|
1317
|
+
readonly d: "M3 5h18";
|
|
1318
|
+
}], readonly ["path", {
|
|
1319
|
+
readonly d: "M3 12h18";
|
|
1320
|
+
}], readonly ["path", {
|
|
1321
|
+
readonly d: "M3 19h18";
|
|
1322
|
+
}]];
|
|
1323
|
+
readonly baseline: readonly [readonly ["path", {
|
|
1324
|
+
readonly d: "M4 20h16";
|
|
1325
|
+
}], readonly ["path", {
|
|
1326
|
+
readonly d: "m6 16 6-12 6 12";
|
|
1327
|
+
}], readonly ["path", {
|
|
1328
|
+
readonly d: "M8 12h8";
|
|
1329
|
+
}]];
|
|
1330
|
+
readonly highlighter: readonly [readonly ["path", {
|
|
1331
|
+
readonly d: "m9 11-6 6v3h9l3-3";
|
|
1332
|
+
}], readonly ["path", {
|
|
1333
|
+
readonly d: "m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4";
|
|
1334
|
+
}]];
|
|
1335
|
+
readonly sigma: readonly [readonly ["path", {
|
|
1336
|
+
readonly d: "M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2";
|
|
1337
|
+
}]];
|
|
1338
|
+
};
|
|
1339
|
+
type IconName = keyof typeof ICON_SHAPES;
|
|
1340
|
+
|
|
1341
|
+
interface IconProps extends Omit<SVGProps<SVGSVGElement>, 'name' | 'children'> {
|
|
1342
|
+
readonly name: IconName;
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* Иконка из набора Lucide (ISC). Рисуется текущим цветом текста; размер задаётся CSS (`--inkbrick-icon-size`
|
|
1346
|
+
* или `width`/`height` у `[data-inkbrick-icon]`). Годится и для пользовательских пунктов slash-меню и меню блока.
|
|
1347
|
+
*/
|
|
1348
|
+
declare function Icon({ name, ...props }: IconProps): react.JSX.Element;
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* Стандартные привязки редактора, в порядке проверки. Свои привязки передаются в `<EditorProvider keymap>`:
|
|
1352
|
+
* тот же `id` заменяет стандартную, новый `id` проверяется раньше стандартных.
|
|
1353
|
+
*/
|
|
1354
|
+
declare const defaultKeymap: readonly KeyBinding[];
|
|
1355
|
+
|
|
1356
|
+
/**
|
|
1357
|
+
* Собирает итоговый список привязок: свои привязки с `id` стандартной занимают её место, остальные идут
|
|
1358
|
+
* перед стандартными (проверяются первыми).
|
|
1359
|
+
*/
|
|
1360
|
+
declare function resolveKeymap(custom?: readonly KeyBinding[]): readonly KeyBinding[];
|
|
1361
|
+
declare function unbind(id: string): KeyBinding;
|
|
1362
|
+
|
|
1363
|
+
/**
|
|
1364
|
+
* Нажата ли ровно эта комбинация: Shift и Alt должны совпадать точно; Ctrl/Meta, если не упомянуты,
|
|
1365
|
+
* не должны быть нажаты (`Mod` принимает любую из двух).
|
|
1366
|
+
*/
|
|
1367
|
+
declare function matchesShortcut(event: KeyboardEvent, spec: string): boolean;
|
|
1368
|
+
|
|
1369
|
+
declare const defaultSlashItems: readonly SlashMenuItem[];
|
|
1370
|
+
|
|
1371
|
+
declare function filterSlashItems(items: readonly SlashMenuItem[], query: string): SlashMenuItem[];
|
|
1372
|
+
|
|
1373
|
+
declare function DefaultSlashMenu({ items, activeIndex, position, onSelect, onHover, }: SlashMenuProps): react.JSX.Element;
|
|
1374
|
+
|
|
1375
|
+
declare function DefaultToolbar({ formats, position, linkOpen, panel, onToggle, onOpenLink, onApplyLink, onCancelLink, onTogglePanel, onApplyColor, onAlign, onInsertFormula, }: ToolbarProps): react.JSX.Element;
|
|
1376
|
+
|
|
1377
|
+
declare function DefaultBlockHandle({ blockId, position, canAdd, dragging, menuOpen, onAdd, onOpenMenu, gripProps, }: BlockHandleProps): react.JSX.Element;
|
|
1378
|
+
|
|
1379
|
+
declare function DefaultDropIndicator({ indicator, position }: DropIndicatorProps): react.JSX.Element;
|
|
1380
|
+
|
|
1381
|
+
interface BlockDropTarget {
|
|
1382
|
+
readonly targetId: string;
|
|
1383
|
+
readonly position: DropPosition;
|
|
1384
|
+
readonly indicator: DropIndicatorRect;
|
|
1385
|
+
}
|
|
1386
|
+
interface BlockRects {
|
|
1387
|
+
/** Строка самого блока (его текст), без вложенных блоков. */
|
|
1388
|
+
readonly row: DOMRect;
|
|
1389
|
+
/** Весь блок вместе с вложенными блоками. */
|
|
1390
|
+
readonly box: DOMRect;
|
|
1391
|
+
}
|
|
1392
|
+
/**
|
|
1393
|
+
* Всё, что нужно своей системе перетаскивания блоков (dnd-kit, pragmatic-drag-and-drop, своя на pointer events):
|
|
1394
|
+
* геометрия, проверка цели, линия вставки и сам перенос. Встроенное перетаскивание построено на этом же API.
|
|
1395
|
+
*
|
|
1396
|
+
* Обычный порядок: `start(blockId)` → на каждое движение `update(x, y)` → `drop()` или `cancel()`.
|
|
1397
|
+
*/
|
|
1398
|
+
interface BlockDragApi {
|
|
1399
|
+
/** Блок с ручкой под точкой окна; точку в полосе слева от текста прижимает к тексту. */
|
|
1400
|
+
blockAtPoint(x: number, y: number): string | null;
|
|
1401
|
+
blockRects(blockId: string): BlockRects | null;
|
|
1402
|
+
/** Можно ли перенести блок `blockId` перед/после `targetId` (схема, вложенность, глубина). */
|
|
1403
|
+
canMove(blockId: string, targetId: string, position: DropPosition): boolean;
|
|
1404
|
+
/** Допустимое место вставки под точкой окна для блока `blockId`; верхняя половина строки — «перед». */
|
|
1405
|
+
dropTargetAt(blockId: string, x: number, y: number): BlockDropTarget | null;
|
|
1406
|
+
start(blockId: string): void;
|
|
1407
|
+
/** Задаёт текущее место вставки (или убирает его) и рисует линию. Цель, которую движок не примет, отбрасывается. */
|
|
1408
|
+
setTarget(target: BlockDropTarget | null): void;
|
|
1409
|
+
/** Удобная связка `dropTargetAt` + `setTarget` с автопрокруткой у края окна. Возвращает найденную цель. */
|
|
1410
|
+
update(x: number, y: number): BlockDropTarget | null;
|
|
1411
|
+
/** Завершает перенос: применяет его к текущей цели одним шагом undo. `true`, если блок перенесён. */
|
|
1412
|
+
drop(): boolean;
|
|
1413
|
+
cancel(): void;
|
|
1414
|
+
/** Переносит блок сразу, без жеста (например, из своего DnD без линии вставки). Один шаг undo. */
|
|
1415
|
+
move(blockId: string, targetId: string, position: DropPosition): boolean;
|
|
1416
|
+
autoScroll(clientY: number): void;
|
|
1417
|
+
getState(): DragState | null;
|
|
1418
|
+
subscribe(listener: () => void): () => void;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
/**
|
|
1422
|
+
* API перетаскивания блоков текущего редактора: на нём строится своя система DnD
|
|
1423
|
+
* (dnd-kit, pragmatic-drag-and-drop и т. п.). Объект стабилен между рендерами.
|
|
1424
|
+
* Работает внутри `<EditorProvider>`, в том числе в компоненте `slots.BlockHandle`.
|
|
1425
|
+
*/
|
|
1426
|
+
declare function useBlockDrag(): BlockDragApi;
|
|
1427
|
+
declare function useBlockDragState(): DragState | null;
|
|
1428
|
+
|
|
1429
|
+
declare function DefaultBlockMenu({ position, actions, turnInto, onClose }: BlockMenuProps): react.JSX.Element;
|
|
1430
|
+
|
|
1431
|
+
export { BlockChildren, type BlockComponent, type BlockComponentRegistry, type BlockControllerHandle, type BlockDragApi, type DragState as BlockDragState, type BlockDropTarget, type BlockHandleProps, type BlockHeightEstimate, type BlockMenuAction, type BlockMenuProps, type BlockProps, type BlockRects, BlockRenderer, type BlockRendererProps, type BlockViewProps, CODE_LANGUAGES, CalloutBlock, type ChildListProps, CodeBlock, type CodeHighlighter, type CustomBlockViewProps, DefaultBlockHandle, DefaultBlockMenu, DefaultDropIndicator, DefaultSlashMenu, DefaultToolbar, DividerBlock, type DocumentRenderer, DocumentView, type DocumentViewProps, type DropIndicatorProps, type DropIndicatorRect, type DropPosition, Editable, type EditableProps, EditorContext, type EditorPresentation, EditorProvider, type EditorProviderProps, type EditorSlots, type EditorUIConfig, EditorView, EditorViewContext, type FormulaRenderOptions, type FormulaRenderer, type FormulaState, FormulaView, type GripProps, HIGHLIGHT_LIMIT, HeadingBlock, type HighlightToken, type HighlightTokenType, type HistoryControls, Icon, type IconName, type IconProps, ImageBlock, type ImageOptions, type InlineFormat, type KeyBinding, type KeymapContext, ListBlock, type MessageKey, type MessageParams, type Messages, NoteBlock, PageBlock, ParagraphBlock, type PartialMessages, QuoteBlock, type ReactBlockDefinition, type SlashMenuItem, type SlashMenuProps, type TFunction, type ToolbarProps, UnknownBlockView, type UnknownBlockViewProps, type VirtualRendererOptions, createTranslator, defaultBlockComponents, defaultKeymap, defaultSlashItems, defineBlock, definePresentation, embeddedFragment, en, ensureMathStyles, estimateBlockHeight, filterSlashItems, fullRenderer, getLocales, highlightCode, htmlToFragment, matchesShortcut, mountFormula, normalizeImageUrl, normalizeLanguage, registerLocale, resolveBlockComponent, resolveKeymap, resolveMessages, ru, temmlRenderer, unbind, uploadImage, useBlock, useBlockController, useBlockDrag, useBlockDragState, useChildren, useDocument, useEditor, useEditorUI, useEditorView, useHistory, useLocale, useReadOnly, useT, virtualRenderer };
|