@zuilib/text-editor 0.4.0 → 0.6.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/CHANGELOG.md +100 -0
- package/DRAWING_FORMAT.md +246 -66
- package/README.md +181 -57
- package/dist/index.d.ts +593 -60
- package/dist/index.js +3289 -1363
- package/dist/styles.css +383 -93
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,33 @@ import { LexicalEditor, TextFormatType, ElementNode, NodeKey, EditorConfig, Seri
|
|
|
4
4
|
import { TableNode } from '@lexical/table';
|
|
5
5
|
import { MultilineElementTransformer, ElementTransformer } from '@lexical/markdown';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Horizontal sizing of a block that would otherwise span the editor:
|
|
9
|
+
*
|
|
10
|
+
* - `full` — the container width (the content pane, minus its gutters).
|
|
11
|
+
* The default; omitted when serialised.
|
|
12
|
+
* - `text` — the text column: the block's edges align with the paragraphs
|
|
13
|
+
* around it. Only differs from `full` when a measure is set
|
|
14
|
+
* (`--zui-text-editor-measure` / the `measure` prop); otherwise the two
|
|
15
|
+
* are visually identical.
|
|
16
|
+
* - `content` — shrinks to fit what is inside (table columns, drawing
|
|
17
|
+
* shapes), left-aligned with the text and never wider than the column.
|
|
18
|
+
*/
|
|
19
|
+
type BlockWidth = 'full' | 'text' | 'content';
|
|
20
|
+
declare const BLOCK_WIDTHS: readonly BlockWidth[];
|
|
21
|
+
declare function isBlockWidth(value: unknown): value is BlockWidth;
|
|
22
|
+
/**
|
|
23
|
+
* Width written into the markdown when a new table / drawing is inserted
|
|
24
|
+
* (`MarkdownEditor.Root`'s `defaultBlockWidth`). Only affects insertion:
|
|
25
|
+
* existing markdown without a width marker always means `full`.
|
|
26
|
+
*/
|
|
27
|
+
type BlockWidthDefaults = Readonly<{
|
|
28
|
+
table?: BlockWidth;
|
|
29
|
+
drawing?: BlockWidth;
|
|
30
|
+
}>;
|
|
31
|
+
|
|
7
32
|
type EditorMode = 'edit-raw' | 'edit-md' | 'view';
|
|
33
|
+
|
|
8
34
|
type EditorRootProps = Readonly<{
|
|
9
35
|
value?: string;
|
|
10
36
|
onChange?: (value: string) => void;
|
|
@@ -12,6 +38,22 @@ type EditorRootProps = Readonly<{
|
|
|
12
38
|
className?: string;
|
|
13
39
|
mode?: EditorMode;
|
|
14
40
|
autoFocus?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Text measure: the maximum width of the text column, as a CSS length
|
|
43
|
+
* (`'48rem'` recommended). Text blocks are capped at this width and
|
|
44
|
+
* centred; tables and drawings choose per block whether to align with
|
|
45
|
+
* the column (`text`), span the pane (`full`) or hug their content.
|
|
46
|
+
* Sugar for setting `--zui-text-editor-measure` on the root; the
|
|
47
|
+
* variable can equally be set from a stylesheet. Unset: no measure, every
|
|
48
|
+
* block spans the pane.
|
|
49
|
+
*/
|
|
50
|
+
measure?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Width written into the markdown when the toolbar or
|
|
53
|
+
* `useMarkdownEditor()` inserts a new table / drawing. Only affects
|
|
54
|
+
* insertion — markdown without a width marker always means `full`.
|
|
55
|
+
*/
|
|
56
|
+
defaultBlockWidth?: BlockWidthDefaults;
|
|
15
57
|
children: ReactNode;
|
|
16
58
|
}>;
|
|
17
59
|
/**
|
|
@@ -19,7 +61,7 @@ type EditorRootProps = Readonly<{
|
|
|
19
61
|
* beneath it (`Content`, `Toolbar`, `Outline`, or your own components using
|
|
20
62
|
* `useMarkdownEditor`) shares the same editor instance.
|
|
21
63
|
*/
|
|
22
|
-
declare function EditorRoot({ value, onChange, readOnly, className, mode, autoFocus, children, }: EditorRootProps): ReactElement;
|
|
64
|
+
declare function EditorRoot({ value, onChange, readOnly, className, mode, autoFocus, measure, defaultBlockWidth, children, }: EditorRootProps): ReactElement;
|
|
23
65
|
|
|
24
66
|
type EditorContentProps = Readonly<{
|
|
25
67
|
placeholder?: string;
|
|
@@ -41,13 +83,6 @@ declare function EditorContent({ placeholder, foldable, children, }: EditorConte
|
|
|
41
83
|
*/
|
|
42
84
|
declare function OutlinePlugin(): ReactElement;
|
|
43
85
|
|
|
44
|
-
/**
|
|
45
|
-
* Horizontal sizing of a block that would otherwise span the editor:
|
|
46
|
-
* `full` stretches to the content column, `content` shrinks to fit what is
|
|
47
|
-
* inside (table columns, drawing shapes) and left-aligns with the text.
|
|
48
|
-
*/
|
|
49
|
-
type BlockWidth = 'full' | 'content';
|
|
50
|
-
|
|
51
86
|
/** Cell padding / font size preset */
|
|
52
87
|
type TableDensity = 'compact' | 'comfortable' | 'spacious';
|
|
53
88
|
type TableSettings = Readonly<{
|
|
@@ -55,8 +90,14 @@ type TableSettings = Readonly<{
|
|
|
55
90
|
density: TableDensity;
|
|
56
91
|
}>;
|
|
57
92
|
declare const DEFAULT_TABLE_SETTINGS: TableSettings;
|
|
93
|
+
type TableSettingsOptions = Readonly<{
|
|
94
|
+
/** Persist the width even when it is `full` */
|
|
95
|
+
explicitWidth?: boolean;
|
|
96
|
+
}>;
|
|
58
97
|
declare function $getTableSettings(table: TableNode): TableSettings;
|
|
59
|
-
declare function $setTableSettings(table: TableNode, settings: Partial<TableSettings
|
|
98
|
+
declare function $setTableSettings(table: TableNode, settings: Partial<TableSettings>, options?: TableSettingsOptions): void;
|
|
99
|
+
/** Whether the table's width should be persisted even when it is `full` */
|
|
100
|
+
declare function $isTableWidthExplicit(table: TableNode): boolean;
|
|
60
101
|
declare function $getTableWidth(table: TableNode): BlockWidth;
|
|
61
102
|
declare function $setTableWidth(table: TableNode, width: BlockWidth): void;
|
|
62
103
|
declare function $getTableDensity(table: TableNode): TableDensity;
|
|
@@ -65,10 +106,17 @@ declare function $setTableDensity(table: TableNode, density: TableDensity): void
|
|
|
65
106
|
declare function $getSelectedTable(): TableNode | null;
|
|
66
107
|
/** @deprecated Use `formatTableSettingsMarker({ ...DEFAULT_TABLE_SETTINGS, width: 'content' })` */
|
|
67
108
|
declare const TABLE_WIDTH_MARKER = "<!-- width: content -->";
|
|
68
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Settings encoded in a marker line, or null if the text is not a marker.
|
|
111
|
+
* A marker naming a known setting with an unknown value yields that setting
|
|
112
|
+
* omitted (possibly an empty object): the line is still a settings marker.
|
|
113
|
+
*/
|
|
69
114
|
declare function parseTableSettingsMarker(text: string): Partial<TableSettings> | null;
|
|
70
|
-
/**
|
|
71
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Marker line for the given settings, or null when everything is default.
|
|
117
|
+
* With `explicitWidth` the width is listed even when it is `full`.
|
|
118
|
+
*/
|
|
119
|
+
declare function formatTableSettingsMarker(settings: TableSettings, options?: TableSettingsOptions): string | null;
|
|
72
120
|
|
|
73
121
|
type MarkdownEditorApi = Readonly<{
|
|
74
122
|
/** The underlying Lexical editor, for dispatching your own commands */
|
|
@@ -76,14 +124,40 @@ type MarkdownEditorApi = Readonly<{
|
|
|
76
124
|
/** Text formats active at the current selection */
|
|
77
125
|
activeFormats: ReadonlySet<TextFormatType>;
|
|
78
126
|
toggleFormat: (format: TextFormatType) => void;
|
|
127
|
+
/**
|
|
128
|
+
* Insert a table at the selection. `width` defaults to
|
|
129
|
+
* `defaultBlockWidth.table` (Root prop); when given it is written to the
|
|
130
|
+
* markdown explicitly, even when `full`.
|
|
131
|
+
*/
|
|
79
132
|
insertTable: (options?: {
|
|
80
133
|
rows?: number;
|
|
81
134
|
columns?: number;
|
|
135
|
+
width?: BlockWidth;
|
|
82
136
|
}) => void;
|
|
83
|
-
|
|
84
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Insert an empty drawing at the selection. `width` defaults to
|
|
139
|
+
* `defaultBlockWidth.drawing` (Root prop); when given it is written to
|
|
140
|
+
* the markdown explicitly, even when `full`.
|
|
141
|
+
*/
|
|
142
|
+
insertDrawing: (options?: {
|
|
143
|
+
width?: BlockWidth;
|
|
144
|
+
}) => void;
|
|
145
|
+
/**
|
|
146
|
+
* Width of the block containing the selection — the focused drawing, or
|
|
147
|
+
* else the table the caret is in; `null` outside both.
|
|
148
|
+
*/
|
|
149
|
+
blockWidth: BlockWidth | null;
|
|
150
|
+
/** Resize that block; no-op when `blockWidth` is `null` */
|
|
151
|
+
setBlockWidth: (width: BlockWidth) => void;
|
|
152
|
+
/**
|
|
153
|
+
* Width of the table containing the selection; `null` outside tables.
|
|
154
|
+
* @deprecated Use `blockWidth`, which also covers drawings.
|
|
155
|
+
*/
|
|
85
156
|
tableWidth: BlockWidth | null;
|
|
86
|
-
/**
|
|
157
|
+
/**
|
|
158
|
+
* Resize the table containing the selection; no-op outside tables.
|
|
159
|
+
* @deprecated Use `setBlockWidth`, which also covers drawings.
|
|
160
|
+
*/
|
|
87
161
|
setTableWidth: (width: BlockWidth) => void;
|
|
88
162
|
/** Density of the table containing the selection; `null` outside tables */
|
|
89
163
|
tableDensity: TableDensity | null;
|
|
@@ -210,14 +284,39 @@ declare function $isFrontmatterNode(node: LexicalNode | null | undefined): node
|
|
|
210
284
|
*/
|
|
211
285
|
declare const FRONTMATTER: MultilineElementTransformer;
|
|
212
286
|
|
|
213
|
-
|
|
287
|
+
/** Card-like shapes: fillable, bindable, carrying the three text slots */
|
|
288
|
+
type BoxType = 'rect' | 'ellipse' | 'diamond' | 'note' | 'cylinder' | 'cloud' | 'queue' | 'actor';
|
|
289
|
+
type ConnectorType = 'arrow' | 'line';
|
|
290
|
+
type DrawingShapeType = BoxType | ConnectorType | 'text';
|
|
291
|
+
declare const BOX_TYPES: readonly BoxType[];
|
|
292
|
+
declare const CONNECTOR_TYPES: readonly ConnectorType[];
|
|
293
|
+
declare const SHAPE_TYPES: readonly DrawingShapeType[];
|
|
294
|
+
type Point = Readonly<{
|
|
295
|
+
x: number;
|
|
296
|
+
y: number;
|
|
297
|
+
}>;
|
|
298
|
+
type BindingSide = 'top' | 'right' | 'bottom' | 'left';
|
|
299
|
+
/**
|
|
300
|
+
* Where a connector endpoint attaches to a box.
|
|
301
|
+
*
|
|
302
|
+
* `fixedPoint` is a ratio inside the box's bounding box (`[0,0]` top-left,
|
|
303
|
+
* `[1,1]` bottom-right). Omitted = the box center, which makes the endpoint
|
|
304
|
+
* auto-aim at the other end. `mode: 'inside'` pins the endpoint exactly on
|
|
305
|
+
* the fixed point; the default (`'orbit'`) projects it onto the outline with
|
|
306
|
+
* a small gap.
|
|
307
|
+
*/
|
|
308
|
+
type Binding = Readonly<{
|
|
309
|
+
id: string;
|
|
310
|
+
fixedPoint?: readonly [number, number];
|
|
311
|
+
mode?: 'orbit' | 'inside';
|
|
312
|
+
}>;
|
|
214
313
|
type DrawingShape = Readonly<{
|
|
215
314
|
id: string;
|
|
216
315
|
type: DrawingShapeType;
|
|
217
|
-
/** Top-left corner (
|
|
316
|
+
/** Top-left corner (boxes/text) or start point (connectors) */
|
|
218
317
|
x: number;
|
|
219
318
|
y: number;
|
|
220
|
-
/** Size (
|
|
319
|
+
/** Size (boxes/text) or delta to the end point (connectors) */
|
|
221
320
|
w: number;
|
|
222
321
|
h: number;
|
|
223
322
|
stroke: string;
|
|
@@ -229,44 +328,64 @@ type DrawingShape = Readonly<{
|
|
|
229
328
|
label?: string;
|
|
230
329
|
/** Small line rendered at the bottom of a box */
|
|
231
330
|
footer?: string;
|
|
232
|
-
/**
|
|
233
|
-
startBinding?:
|
|
234
|
-
/**
|
|
235
|
-
endBinding?:
|
|
236
|
-
/** Arrow:
|
|
331
|
+
/** Connector: box the start point is attached to */
|
|
332
|
+
startBinding?: Binding;
|
|
333
|
+
/** Connector: box the end point is attached to */
|
|
334
|
+
endBinding?: Binding;
|
|
335
|
+
/** Arrow: arrowheads on both ends */
|
|
237
336
|
bidirectional?: boolean;
|
|
238
|
-
/** Connector routing: right-angled
|
|
337
|
+
/** Connector routing: right-angled auto-routed path instead of a straight line */
|
|
239
338
|
routing?: 'elbow';
|
|
240
|
-
/**
|
|
339
|
+
/**
|
|
340
|
+
* Elbow override: position of the middle segment as a fraction of the
|
|
341
|
+
* span, applied only when the routed path is a simple three-segment Z.
|
|
342
|
+
*/
|
|
241
343
|
elbow?: number;
|
|
242
344
|
/**
|
|
243
345
|
* Connector: intermediate path points between start and end (absolute
|
|
244
346
|
* canvas coordinates). Takes precedence over `routing`.
|
|
245
347
|
*/
|
|
246
|
-
waypoints?:
|
|
247
|
-
x: number;
|
|
248
|
-
y: number;
|
|
249
|
-
}>;
|
|
348
|
+
waypoints?: readonly Point[];
|
|
250
349
|
}>;
|
|
251
350
|
type DrawingData = Readonly<{
|
|
252
|
-
version:
|
|
253
|
-
|
|
351
|
+
version: 2;
|
|
352
|
+
/**
|
|
353
|
+
* Logical canvas width. When set the drawing is scaled to fit narrower
|
|
354
|
+
* layouts (SVG viewBox); when omitted the canvas is fluid and shapes are
|
|
355
|
+
* in CSS pixels.
|
|
356
|
+
*/
|
|
357
|
+
canvasWidth?: number;
|
|
358
|
+
canvasHeight: number;
|
|
254
359
|
/**
|
|
255
|
-
*
|
|
256
|
-
* `content` fits the shapes' horizontal extent.
|
|
360
|
+
* Block width: `full` (default) spans the editor; `text` aligns with the
|
|
361
|
+
* text column; `content` fits the shapes' horizontal extent. The editor
|
|
362
|
+
* omits `full` unless it was written explicitly (an insertion default or
|
|
363
|
+
* the source payload); unknown values are dropped.
|
|
257
364
|
*/
|
|
258
365
|
width?: BlockWidth;
|
|
259
366
|
shapes: readonly DrawingShape[];
|
|
260
367
|
}>;
|
|
368
|
+
declare const EMPTY_DRAWING: DrawingData;
|
|
369
|
+
declare const STROKE_COLORS: readonly ["#1e1e1e", "#e03131", "#2f9e44", "#1971c2", "#f08c00", "#7048e8"];
|
|
370
|
+
declare const FILL_COLORS: readonly ["transparent", "#ffc9c9", "#b2f2bb", "#a5d8ff", "#ffec99", "#d0bfff"];
|
|
371
|
+
/** Edge midpoints, used by the ```diagram skeleton's `side` option */
|
|
372
|
+
declare const SIDE_FIXED_POINTS: Record<BindingSide, readonly [number, number]>;
|
|
261
373
|
declare function serializeDrawingData(data: DrawingData): string;
|
|
374
|
+
/**
|
|
375
|
+
* Parse a ```drawing payload. Exactly one format is accepted: version 2 as
|
|
376
|
+
* written by the editor (the ```diagram skeleton is a separate block type,
|
|
377
|
+
* see skeleton.ts). Shapes that fail validation are dropped and a malformed
|
|
378
|
+
* document yields an empty canvas. Never throws.
|
|
379
|
+
*/
|
|
262
380
|
declare function parseDrawingData(json: string): DrawingData;
|
|
381
|
+
declare function normalizeDrawingData(parsed: unknown): DrawingData;
|
|
263
382
|
|
|
264
383
|
type SerializedDrawingNode = Spread<{
|
|
265
384
|
data: string;
|
|
266
385
|
}, SerializedLexicalNode>;
|
|
267
386
|
/**
|
|
268
|
-
* A block-level decorator node embedding a vector
|
|
269
|
-
*
|
|
387
|
+
* A block-level decorator node embedding a vector diagram (cards, connectors,
|
|
388
|
+
* text) edited on a canvas.
|
|
270
389
|
*
|
|
271
390
|
* The drawing is stored as a JSON string and round-trips through markdown as
|
|
272
391
|
* a ```drawing fenced code block, so documents remain plain markdown.
|
|
@@ -295,44 +414,62 @@ declare function $isDrawingNode(node: LexicalNode | null | undefined): node is D
|
|
|
295
414
|
* claims the fence first on import.
|
|
296
415
|
*/
|
|
297
416
|
declare const DRAWING: MultilineElementTransformer;
|
|
417
|
+
/**
|
|
418
|
+
* Import-only transformer for ```diagram blocks: a compact skeleton
|
|
419
|
+
* (boxes, connectors by id, auto layout) that expands into a full drawing.
|
|
420
|
+
* Once in the editor the node is a regular drawing and exports as
|
|
421
|
+
* ```drawing, so the expansion is one-way.
|
|
422
|
+
*/
|
|
423
|
+
declare const DIAGRAM: MultilineElementTransformer;
|
|
298
424
|
|
|
299
425
|
/**
|
|
300
426
|
* Markdown transformer for GFM tables. Adapted from the Lexical playground.
|
|
301
427
|
* Rows are matched line-by-line on import and stitched into a single
|
|
302
428
|
* TableNode; the divider row promotes the row above it to a header row.
|
|
303
|
-
* A `<!-- width:
|
|
429
|
+
* A `<!-- width: text; density: compact -->` settings line directly
|
|
304
430
|
* above the table (see tableSettings.ts) is consumed on import and
|
|
305
431
|
* re-emitted on export.
|
|
306
432
|
*/
|
|
307
433
|
declare const TABLE: ElementTransformer;
|
|
308
434
|
|
|
309
435
|
/**
|
|
310
|
-
* JSON Schema (draft-07) for the payload of a ```drawing fenced block
|
|
436
|
+
* JSON Schema (draft-07) for the payload of a ```drawing fenced block
|
|
437
|
+
* (format version 2).
|
|
311
438
|
*
|
|
312
439
|
* Use it to validate LLM- or tool-generated drawings before embedding them,
|
|
313
440
|
* or pass it as a structured-output / tool schema so a model is forced to
|
|
314
|
-
* emit valid payloads. Kept in sync with `parseDrawingData` /
|
|
315
|
-
* in
|
|
441
|
+
* emit valid payloads. Kept in sync with `parseDrawingData` /
|
|
442
|
+
* `normalizeShape` in types.ts; update both together.
|
|
443
|
+
*
|
|
444
|
+
* For generation prefer the ```diagram skeleton
|
|
445
|
+
* (`DRAWING_SKELETON_JSON_SCHEMA`): it needs no coordinates and expands into
|
|
446
|
+
* this format on import.
|
|
316
447
|
*/
|
|
317
448
|
declare const DRAWING_DATA_JSON_SCHEMA: {
|
|
318
449
|
readonly $schema: "http://json-schema.org/draft-07/schema#";
|
|
319
450
|
readonly title: "DrawingData";
|
|
320
|
-
readonly description: "Vector drawing embedded in markdown as a ```drawing fenced code block";
|
|
451
|
+
readonly description: "Vector drawing embedded in markdown as a ```drawing fenced code block (format version 2)";
|
|
321
452
|
readonly type: "object";
|
|
322
|
-
readonly required: readonly ["version", "
|
|
453
|
+
readonly required: readonly ["version", "canvasHeight", "shapes"];
|
|
323
454
|
readonly additionalProperties: false;
|
|
324
455
|
readonly properties: {
|
|
325
456
|
readonly version: {
|
|
326
|
-
readonly const:
|
|
457
|
+
readonly const: 2;
|
|
458
|
+
readonly description: "Format version; always 2";
|
|
327
459
|
};
|
|
328
|
-
readonly
|
|
460
|
+
readonly canvasHeight: {
|
|
329
461
|
readonly type: "number";
|
|
330
462
|
readonly minimum: 80;
|
|
331
|
-
readonly description: "Canvas height in pixels";
|
|
463
|
+
readonly description: "Canvas height in pixels. Make it large enough to contain every shape plus ~20px margin.";
|
|
464
|
+
};
|
|
465
|
+
readonly canvasWidth: {
|
|
466
|
+
readonly type: "number";
|
|
467
|
+
readonly minimum: 120;
|
|
468
|
+
readonly description: "Optional logical canvas width in pixels. When set, the drawing is scaled down to fit narrower layouts (SVG viewBox) so coordinates can assume this width. When omitted the canvas is fluid and coordinates are CSS pixels.";
|
|
332
469
|
};
|
|
333
470
|
readonly width: {
|
|
334
|
-
readonly enum: readonly ["full", "content"];
|
|
335
|
-
readonly description: "
|
|
471
|
+
readonly enum: readonly ["full", "text", "content"];
|
|
472
|
+
readonly description: "Block width: \"full\" (default, omit it) spans the editor; \"text\" aligns the block with the text column (same as \"full\" unless the app sets a text measure); \"content\" fits the shapes' horizontal extent and left-aligns with the text";
|
|
336
473
|
};
|
|
337
474
|
readonly shapes: {
|
|
338
475
|
readonly type: "array";
|
|
@@ -350,9 +487,38 @@ declare const DRAWING_DATA_JSON_SCHEMA: {
|
|
|
350
487
|
readonly properties: {
|
|
351
488
|
readonly x: {
|
|
352
489
|
readonly type: "number";
|
|
490
|
+
readonly description: "Absolute canvas x";
|
|
353
491
|
};
|
|
354
492
|
readonly y: {
|
|
355
493
|
readonly type: "number";
|
|
494
|
+
readonly description: "Absolute canvas y";
|
|
495
|
+
};
|
|
496
|
+
};
|
|
497
|
+
};
|
|
498
|
+
readonly binding: {
|
|
499
|
+
readonly type: "object";
|
|
500
|
+
readonly description: "Where a connector endpoint attaches to a box. Omit fixedPoint to let the endpoint auto-aim from the box center at the other end.";
|
|
501
|
+
readonly required: readonly ["id"];
|
|
502
|
+
readonly additionalProperties: false;
|
|
503
|
+
readonly properties: {
|
|
504
|
+
readonly id: {
|
|
505
|
+
readonly type: "string";
|
|
506
|
+
readonly description: "Id of the box this endpoint is attached to";
|
|
507
|
+
};
|
|
508
|
+
readonly fixedPoint: {
|
|
509
|
+
readonly type: "array";
|
|
510
|
+
readonly items: {
|
|
511
|
+
readonly type: "number";
|
|
512
|
+
readonly minimum: 0;
|
|
513
|
+
readonly maximum: 1;
|
|
514
|
+
};
|
|
515
|
+
readonly minItems: 2;
|
|
516
|
+
readonly maxItems: 2;
|
|
517
|
+
readonly description: "Attach point as a ratio of the box's bounding box: [0,0] top-left, [1,1] bottom-right, [0.5,0] top edge midpoint, [1,0.5] right edge midpoint. Omitted: the endpoint auto-aims from the box center at the other end.";
|
|
518
|
+
};
|
|
519
|
+
readonly mode: {
|
|
520
|
+
readonly enum: readonly ["orbit", "inside"];
|
|
521
|
+
readonly description: "\"orbit\" (default): the endpoint is projected onto the box outline with a 6px gap. \"inside\": the endpoint sits exactly on the fixed point.";
|
|
356
522
|
};
|
|
357
523
|
};
|
|
358
524
|
};
|
|
@@ -366,7 +532,8 @@ declare const DRAWING_DATA_JSON_SCHEMA: {
|
|
|
366
532
|
readonly description: "Unique within the drawing; connector bindings reference it";
|
|
367
533
|
};
|
|
368
534
|
readonly type: {
|
|
369
|
-
readonly enum: readonly ["rect", "ellipse", "
|
|
535
|
+
readonly enum: readonly ["rect", "ellipse", "diamond", "note", "cylinder", "cloud", "queue", "actor", "arrow", "line", "text"];
|
|
536
|
+
readonly description: "Boxes (cards with label/text/footer slots): rect, ellipse, diamond, note (sticky note with a folded corner), cylinder (database), cloud, queue (horizontal cylinder), actor (stick figure; only the text slot, rendered as a name under the figure). Connectors: arrow (head at the end), line. Free-floating annotation: text.";
|
|
370
537
|
};
|
|
371
538
|
readonly x: {
|
|
372
539
|
readonly type: "number";
|
|
@@ -386,11 +553,11 @@ declare const DRAWING_DATA_JSON_SCHEMA: {
|
|
|
386
553
|
};
|
|
387
554
|
readonly stroke: {
|
|
388
555
|
readonly type: "string";
|
|
389
|
-
readonly description: "CSS color of the outline (and of any text)";
|
|
556
|
+
readonly description: "CSS color of the outline (and of any text). Palette: #1e1e1e (default), #e03131 red, #2f9e44 green, #1971c2 blue, #f08c00 orange, #7048e8 purple.";
|
|
390
557
|
};
|
|
391
558
|
readonly fill: {
|
|
392
559
|
readonly type: "string";
|
|
393
|
-
readonly description: "CSS color of the interior; \"transparent\" for none";
|
|
560
|
+
readonly description: "CSS color of the interior; \"transparent\" for none. Palette: #ffc9c9 red, #b2f2bb green, #a5d8ff blue, #ffec99 yellow, #d0bfff purple.";
|
|
394
561
|
};
|
|
395
562
|
readonly strokeWidth: {
|
|
396
563
|
readonly type: "number";
|
|
@@ -398,23 +565,23 @@ declare const DRAWING_DATA_JSON_SCHEMA: {
|
|
|
398
565
|
};
|
|
399
566
|
readonly text: {
|
|
400
567
|
readonly type: "string";
|
|
401
|
-
readonly description: "Standalone text content; center content of a box; midpoint label of a connector";
|
|
568
|
+
readonly description: "Standalone text content; center content of a box (the name under an actor); midpoint label of a connector";
|
|
402
569
|
};
|
|
403
570
|
readonly label: {
|
|
404
571
|
readonly type: "string";
|
|
405
|
-
readonly description: "Boxes only: small bold heading at the top";
|
|
572
|
+
readonly description: "Boxes only (not actor): small bold heading at the top";
|
|
406
573
|
};
|
|
407
574
|
readonly footer: {
|
|
408
575
|
readonly type: "string";
|
|
409
|
-
readonly description: "Boxes only: small dim line at the bottom";
|
|
576
|
+
readonly description: "Boxes only (not actor): small dim line at the bottom";
|
|
410
577
|
};
|
|
411
578
|
readonly startBinding: {
|
|
412
|
-
readonly
|
|
413
|
-
readonly description: "Connectors only:
|
|
579
|
+
readonly $ref: "#/definitions/binding";
|
|
580
|
+
readonly description: "Connectors only: box the start point attaches to. The editor re-anchors the endpoint onto that box and keeps it attached as the box moves.";
|
|
414
581
|
};
|
|
415
582
|
readonly endBinding: {
|
|
416
|
-
readonly
|
|
417
|
-
readonly description: "Connectors only:
|
|
583
|
+
readonly $ref: "#/definitions/binding";
|
|
584
|
+
readonly description: "Connectors only: box the end point attaches to";
|
|
418
585
|
};
|
|
419
586
|
readonly bidirectional: {
|
|
420
587
|
readonly type: "boolean";
|
|
@@ -422,24 +589,390 @@ declare const DRAWING_DATA_JSON_SCHEMA: {
|
|
|
422
589
|
};
|
|
423
590
|
readonly routing: {
|
|
424
591
|
readonly const: "elbow";
|
|
425
|
-
readonly description: "Connectors only:
|
|
592
|
+
readonly description: "Connectors only: right-angled auto-routed path. It leaves the box perpendicular to the attach side, avoids every box on the canvas and minimises bends. Ignored when waypoints are present.";
|
|
426
593
|
};
|
|
427
594
|
readonly elbow: {
|
|
428
595
|
readonly type: "number";
|
|
429
596
|
readonly minimum: 0;
|
|
430
597
|
readonly maximum: 1;
|
|
431
|
-
readonly description: "Elbow middle
|
|
598
|
+
readonly description: "Elbow override: position of the middle segment as a fraction of the span. Applied only when the routed path is a simple three-segment Z.";
|
|
432
599
|
};
|
|
433
600
|
readonly waypoints: {
|
|
434
601
|
readonly type: "array";
|
|
435
602
|
readonly items: {
|
|
436
603
|
readonly $ref: "#/definitions/point";
|
|
437
604
|
};
|
|
438
|
-
readonly description: "Connectors only: intermediate path points in canvas coordinates, ordered start
|
|
605
|
+
readonly description: "Connectors only: intermediate path points in canvas coordinates, ordered start to end. Takes precedence over routing.";
|
|
606
|
+
};
|
|
607
|
+
};
|
|
608
|
+
};
|
|
609
|
+
};
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
type Rect = Readonly<{
|
|
613
|
+
x: number;
|
|
614
|
+
y: number;
|
|
615
|
+
w: number;
|
|
616
|
+
h: number;
|
|
617
|
+
}>;
|
|
618
|
+
|
|
619
|
+
declare function boxOutline(box: DrawingShape): Point[];
|
|
620
|
+
/** Topmost box under a point, if any; smaller boxes win over enclosing ones */
|
|
621
|
+
declare function findBoxAt(shapes: readonly DrawingShape[], point: Point, excludeId?: string, tolerance?: number): DrawingShape | null;
|
|
622
|
+
/** The point a binding refers to: its fixed point, or the box center */
|
|
623
|
+
declare function anchorPoint(box: DrawingShape, binding?: Binding): Point;
|
|
624
|
+
/**
|
|
625
|
+
* Fixed point for a drop at `point`: undefined (auto-aim) for drops near
|
|
626
|
+
* the center, otherwise a ratio snapped onto the nearest bounding-box edge.
|
|
627
|
+
*/
|
|
628
|
+
declare function fixedPointFor(box: DrawingShape, point: Point): [number, number] | undefined;
|
|
629
|
+
/**
|
|
630
|
+
* Recompute the endpoints of every bound connector from the current
|
|
631
|
+
* positions of the boxes they're attached to, and drop bindings whose box
|
|
632
|
+
* no longer exists. Idempotent, so it can run after every shape update.
|
|
633
|
+
*/
|
|
634
|
+
declare function resolveBindings(shapes: readonly DrawingShape[]): readonly DrawingShape[];
|
|
635
|
+
/** Attach a freshly drawn connector to the boxes under its endpoints */
|
|
636
|
+
declare function bindEndpoints(shape: DrawingShape, shapes: readonly DrawingShape[]): DrawingShape;
|
|
637
|
+
declare function makeBinding(box: DrawingShape, point: Point): Binding;
|
|
638
|
+
|
|
639
|
+
/** Vertices of a connector's path, start to end */
|
|
640
|
+
declare function connectorPoints(shape: DrawingShape, shapes?: readonly DrawingShape[]): Point[];
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Orthogonal route for an elbow connector: leaves each bound box
|
|
644
|
+
* perpendicular to its attach side, avoids every box on the canvas, and
|
|
645
|
+
* takes the path with the fewest bends (then the shortest). Falls back to
|
|
646
|
+
* a plain L when the grid search fails.
|
|
647
|
+
*/
|
|
648
|
+
declare function routeElbow(shape: DrawingShape, shapes: readonly DrawingShape[]): Point[];
|
|
649
|
+
|
|
650
|
+
type TextField = 'text' | 'label' | 'footer';
|
|
651
|
+
/**
|
|
652
|
+
* Geometry of a box type, kept free of React so the router, bindings,
|
|
653
|
+
* skeleton expansion and exporters can use it without a DOM.
|
|
654
|
+
*/
|
|
655
|
+
type BoxDefinition = Readonly<{
|
|
656
|
+
type: BoxType;
|
|
657
|
+
label: string;
|
|
658
|
+
/** Size used when a shape is created without explicit dimensions */
|
|
659
|
+
defaultSize: Readonly<{
|
|
660
|
+
w: number;
|
|
661
|
+
h: number;
|
|
662
|
+
}>;
|
|
663
|
+
/** Text slots the shape renders (and offers for editing) */
|
|
664
|
+
textSlots: readonly TextField[];
|
|
665
|
+
/** Fill applied when the tool is picked with the default (transparent) fill */
|
|
666
|
+
defaultFill?: string;
|
|
667
|
+
/** Closed outline used for hit-testing and binding endpoints */
|
|
668
|
+
outline: (shape: DrawingShape) => Point[];
|
|
669
|
+
/** Area the text slots lay out in */
|
|
670
|
+
textArea: (shape: DrawingShape) => Rect;
|
|
671
|
+
}>;
|
|
672
|
+
declare const BOX_DEFINITIONS: Record<BoxType, BoxDefinition>;
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Skeleton (intent) layer: a compact, LLM-friendly description of a diagram
|
|
676
|
+
* — boxes, connectors between them and loose texts — that expands into a
|
|
677
|
+
* full `DrawingData` document. Sizes, positions and connector geometry are
|
|
678
|
+
* derived, so a generator only needs to say *what* is on the canvas.
|
|
679
|
+
*/
|
|
680
|
+
|
|
681
|
+
type ColorName = 'gray' | 'red' | 'green' | 'blue' | 'orange' | 'purple';
|
|
682
|
+
declare const COLOR_PRESETS: Record<ColorName, {
|
|
683
|
+
stroke: string;
|
|
684
|
+
fill: string;
|
|
685
|
+
}>;
|
|
686
|
+
type SkeletonBox = Readonly<{
|
|
687
|
+
id: string;
|
|
688
|
+
/** Default `'rect'` */
|
|
689
|
+
type?: BoxType;
|
|
690
|
+
label?: string;
|
|
691
|
+
text?: string;
|
|
692
|
+
footer?: string;
|
|
693
|
+
/** Omitted → auto layout */
|
|
694
|
+
x?: number;
|
|
695
|
+
y?: number;
|
|
696
|
+
/** Omitted → measured from the text, never smaller than the type's default size */
|
|
697
|
+
w?: number;
|
|
698
|
+
h?: number;
|
|
699
|
+
/** Preset → stroke + fill (fill only when `fill` isn't given) */
|
|
700
|
+
color?: ColorName;
|
|
701
|
+
stroke?: string;
|
|
702
|
+
fill?: string;
|
|
703
|
+
}>;
|
|
704
|
+
type SkeletonEnd = string | Readonly<{
|
|
705
|
+
id: string;
|
|
706
|
+
side?: BindingSide;
|
|
707
|
+
}>;
|
|
708
|
+
type SkeletonConnector = Readonly<{
|
|
709
|
+
id?: string;
|
|
710
|
+
/** Default `'arrow'` */
|
|
711
|
+
type?: ConnectorType;
|
|
712
|
+
from: SkeletonEnd;
|
|
713
|
+
to: SkeletonEnd;
|
|
714
|
+
text?: string;
|
|
715
|
+
bidirectional?: boolean;
|
|
716
|
+
/** Default `'straight'` */
|
|
717
|
+
routing?: 'elbow' | 'straight';
|
|
718
|
+
color?: ColorName;
|
|
719
|
+
stroke?: string;
|
|
720
|
+
}>;
|
|
721
|
+
type SkeletonText = Readonly<{
|
|
722
|
+
id?: string;
|
|
723
|
+
x: number;
|
|
724
|
+
y: number;
|
|
725
|
+
text: string;
|
|
726
|
+
color?: ColorName;
|
|
727
|
+
stroke?: string;
|
|
728
|
+
}>;
|
|
729
|
+
type DrawingSkeleton = Readonly<{
|
|
730
|
+
/** Auto-layout flow direction, default `'right'` */
|
|
731
|
+
direction?: 'right' | 'down';
|
|
732
|
+
canvasWidth?: number;
|
|
733
|
+
canvasHeight?: number;
|
|
734
|
+
/** Block width of the expanded drawing; omit for `full` */
|
|
735
|
+
width?: BlockWidth;
|
|
736
|
+
boxes: readonly SkeletonBox[];
|
|
737
|
+
connectors?: readonly SkeletonConnector[];
|
|
738
|
+
texts?: readonly SkeletonText[];
|
|
739
|
+
}>;
|
|
740
|
+
/** Structural check: an object with a `boxes` array */
|
|
741
|
+
declare function isDrawingSkeleton(value: unknown): value is DrawingSkeleton;
|
|
742
|
+
/**
|
|
743
|
+
* Parse a skeleton JSON payload into drawing data. Lenient: invalid boxes,
|
|
744
|
+
* connectors and texts are dropped individually, and a malformed document
|
|
745
|
+
* yields an empty canvas. Never throws.
|
|
746
|
+
*/
|
|
747
|
+
declare function parseDrawingSkeleton(json: string): DrawingData;
|
|
748
|
+
declare function expandSkeleton(skeleton: DrawingSkeleton): DrawingData;
|
|
749
|
+
declare const DRAWING_SKELETON_JSON_SCHEMA: {
|
|
750
|
+
readonly $schema: "http://json-schema.org/draft-07/schema#";
|
|
751
|
+
readonly title: "DrawingSkeleton";
|
|
752
|
+
readonly description: "Compact intent description of a diagram. Boxes are sized from their text and laid out automatically along the connector flow; connectors are drawn between box outlines. Only say what is on the canvas — geometry is derived";
|
|
753
|
+
readonly type: "object";
|
|
754
|
+
readonly required: readonly ["boxes"];
|
|
755
|
+
readonly additionalProperties: false;
|
|
756
|
+
readonly properties: {
|
|
757
|
+
readonly direction: {
|
|
758
|
+
readonly enum: readonly ["right", "down"];
|
|
759
|
+
readonly description: "Auto-layout flow direction. Boxes connected a→b are placed in successive ranks along this axis (\"right\" = columns left to right, \"down\" = rows top to bottom). Default \"right\"";
|
|
760
|
+
};
|
|
761
|
+
readonly canvasWidth: {
|
|
762
|
+
readonly type: "number";
|
|
763
|
+
readonly minimum: 120;
|
|
764
|
+
readonly description: "Logical canvas width in px. Omit for a fluid canvas in CSS pixels";
|
|
765
|
+
};
|
|
766
|
+
readonly canvasHeight: {
|
|
767
|
+
readonly type: "number";
|
|
768
|
+
readonly minimum: 80;
|
|
769
|
+
readonly description: "Canvas height in px. Omit to fit the content";
|
|
770
|
+
};
|
|
771
|
+
readonly width: {
|
|
772
|
+
readonly enum: readonly ["full", "text", "content"];
|
|
773
|
+
readonly description: "Block width: \"text\" aligns the drawing with the text column (same as \"full\" unless the app sets a text measure); \"content\" fits the drawing to its shapes and left-aligns it with the text; omit to span the editor";
|
|
774
|
+
};
|
|
775
|
+
readonly boxes: {
|
|
776
|
+
readonly type: "array";
|
|
777
|
+
readonly items: {
|
|
778
|
+
readonly $ref: "#/definitions/box";
|
|
779
|
+
};
|
|
780
|
+
readonly description: "Card-like shapes carrying up to three text slots. Order is the render order and the stacking order within a layout rank";
|
|
781
|
+
};
|
|
782
|
+
readonly connectors: {
|
|
783
|
+
readonly type: "array";
|
|
784
|
+
readonly items: {
|
|
785
|
+
readonly $ref: "#/definitions/connector";
|
|
786
|
+
};
|
|
787
|
+
readonly description: "Arrows and lines between boxes. Connectors whose from/to id does not match a box are dropped";
|
|
788
|
+
};
|
|
789
|
+
readonly texts: {
|
|
790
|
+
readonly type: "array";
|
|
791
|
+
readonly items: {
|
|
792
|
+
readonly $ref: "#/definitions/text";
|
|
793
|
+
};
|
|
794
|
+
readonly description: "Free-floating annotations not attached to any box. Prefer box slots (label/text/footer) when the text belongs to a box";
|
|
795
|
+
};
|
|
796
|
+
};
|
|
797
|
+
readonly definitions: {
|
|
798
|
+
readonly box: {
|
|
799
|
+
readonly type: "object";
|
|
800
|
+
readonly required: readonly ["id"];
|
|
801
|
+
readonly additionalProperties: false;
|
|
802
|
+
readonly properties: {
|
|
803
|
+
readonly id: {
|
|
804
|
+
readonly type: "string";
|
|
805
|
+
readonly description: "Unique within the drawing; connectors reference it";
|
|
806
|
+
};
|
|
807
|
+
readonly type: {
|
|
808
|
+
readonly enum: readonly BoxType[];
|
|
809
|
+
readonly description: "Shape: rect (default), ellipse, diamond (decision), note (sticky note, yellow by default), cylinder (database), cloud (external system), queue (message queue), actor (stick figure; only the \"text\" slot renders, below the figure)";
|
|
810
|
+
};
|
|
811
|
+
readonly label: {
|
|
812
|
+
readonly type: "string";
|
|
813
|
+
readonly description: "Small bold heading at the top of the box";
|
|
814
|
+
};
|
|
815
|
+
readonly text: {
|
|
816
|
+
readonly type: "string";
|
|
817
|
+
readonly description: "Main content, centered. Wraps automatically; \"\\n\" forces a line break";
|
|
818
|
+
};
|
|
819
|
+
readonly footer: {
|
|
820
|
+
readonly type: "string";
|
|
821
|
+
readonly description: "Small dim line at the bottom of the box";
|
|
822
|
+
};
|
|
823
|
+
readonly x: {
|
|
824
|
+
readonly type: "number";
|
|
825
|
+
readonly description: "Top-left x in px. Omit (with y) to let the layout place the box";
|
|
826
|
+
};
|
|
827
|
+
readonly y: {
|
|
828
|
+
readonly type: "number";
|
|
829
|
+
readonly description: "Top-left y in px. Omit (with x) to let the layout place the box";
|
|
830
|
+
};
|
|
831
|
+
readonly w: {
|
|
832
|
+
readonly type: "number";
|
|
833
|
+
readonly exclusiveMinimum: 0;
|
|
834
|
+
readonly description: "Width in px. Omit to size from the text (never smaller than the type default)";
|
|
835
|
+
};
|
|
836
|
+
readonly h: {
|
|
837
|
+
readonly type: "number";
|
|
838
|
+
readonly exclusiveMinimum: 0;
|
|
839
|
+
readonly description: "Height in px. Omit to size from the text (never smaller than the type default)";
|
|
840
|
+
};
|
|
841
|
+
readonly color: {
|
|
842
|
+
readonly enum: readonly ColorName[];
|
|
843
|
+
readonly description: "Named color preset. Sets the stroke (outline + text) and, for boxes, a matching pastel fill. Omit for the default gray on transparent";
|
|
844
|
+
};
|
|
845
|
+
readonly stroke: {
|
|
846
|
+
readonly type: "string";
|
|
847
|
+
readonly description: "CSS color of the outline and text; overrides the preset";
|
|
848
|
+
};
|
|
849
|
+
readonly fill: {
|
|
850
|
+
readonly type: "string";
|
|
851
|
+
readonly description: "CSS color of the interior (\"transparent\" for none); overrides the preset";
|
|
852
|
+
};
|
|
853
|
+
};
|
|
854
|
+
};
|
|
855
|
+
readonly connector: {
|
|
856
|
+
readonly type: "object";
|
|
857
|
+
readonly required: readonly ["from", "to"];
|
|
858
|
+
readonly additionalProperties: false;
|
|
859
|
+
readonly properties: {
|
|
860
|
+
readonly id: {
|
|
861
|
+
readonly type: "string";
|
|
862
|
+
readonly description: "Optional; generated when omitted";
|
|
863
|
+
};
|
|
864
|
+
readonly type: {
|
|
865
|
+
readonly enum: readonly ConnectorType[];
|
|
866
|
+
readonly description: "arrow (default; arrowhead at \"to\") or line (no arrowheads)";
|
|
867
|
+
};
|
|
868
|
+
readonly from: {
|
|
869
|
+
readonly oneOf: readonly [{
|
|
870
|
+
readonly type: "string";
|
|
871
|
+
readonly description: "Id of a box. The connector attaches to its outline, aimed at the other end";
|
|
872
|
+
}, {
|
|
873
|
+
readonly type: "object";
|
|
874
|
+
readonly required: readonly ["id"];
|
|
875
|
+
readonly additionalProperties: false;
|
|
876
|
+
readonly properties: {
|
|
877
|
+
readonly id: {
|
|
878
|
+
readonly type: "string";
|
|
879
|
+
readonly description: "Id of a box";
|
|
880
|
+
};
|
|
881
|
+
readonly side: {
|
|
882
|
+
readonly enum: readonly ["top", "right", "bottom", "left"];
|
|
883
|
+
readonly description: "Pin the endpoint to the middle of this side of the box instead of auto-aiming";
|
|
884
|
+
};
|
|
885
|
+
};
|
|
886
|
+
}];
|
|
887
|
+
readonly description: "Box a connector end attaches to: a bare box id, or {id, side} to pick the attach edge";
|
|
888
|
+
};
|
|
889
|
+
readonly to: {
|
|
890
|
+
readonly oneOf: readonly [{
|
|
891
|
+
readonly type: "string";
|
|
892
|
+
readonly description: "Id of a box. The connector attaches to its outline, aimed at the other end";
|
|
893
|
+
}, {
|
|
894
|
+
readonly type: "object";
|
|
895
|
+
readonly required: readonly ["id"];
|
|
896
|
+
readonly additionalProperties: false;
|
|
897
|
+
readonly properties: {
|
|
898
|
+
readonly id: {
|
|
899
|
+
readonly type: "string";
|
|
900
|
+
readonly description: "Id of a box";
|
|
901
|
+
};
|
|
902
|
+
readonly side: {
|
|
903
|
+
readonly enum: readonly ["top", "right", "bottom", "left"];
|
|
904
|
+
readonly description: "Pin the endpoint to the middle of this side of the box instead of auto-aiming";
|
|
905
|
+
};
|
|
906
|
+
};
|
|
907
|
+
}];
|
|
908
|
+
readonly description: "Box a connector end attaches to: a bare box id, or {id, side} to pick the attach edge";
|
|
909
|
+
};
|
|
910
|
+
readonly text: {
|
|
911
|
+
readonly type: "string";
|
|
912
|
+
readonly description: "Label rendered at the middle of the connector";
|
|
913
|
+
};
|
|
914
|
+
readonly bidirectional: {
|
|
915
|
+
readonly type: "boolean";
|
|
916
|
+
readonly description: "Arrow only: arrowheads on both ends";
|
|
917
|
+
};
|
|
918
|
+
readonly routing: {
|
|
919
|
+
readonly enum: readonly ["straight", "elbow"];
|
|
920
|
+
readonly description: "straight (default) draws a direct line; elbow draws a right-angled path routed around the boxes";
|
|
921
|
+
};
|
|
922
|
+
readonly color: {
|
|
923
|
+
readonly enum: readonly ColorName[];
|
|
924
|
+
readonly description: "Named color preset. Sets the stroke (outline + text) and, for boxes, a matching pastel fill. Omit for the default gray on transparent";
|
|
925
|
+
};
|
|
926
|
+
readonly stroke: {
|
|
927
|
+
readonly type: "string";
|
|
928
|
+
readonly description: "CSS color of the line and label; overrides the preset";
|
|
929
|
+
};
|
|
930
|
+
};
|
|
931
|
+
};
|
|
932
|
+
readonly text: {
|
|
933
|
+
readonly type: "object";
|
|
934
|
+
readonly required: readonly ["x", "y", "text"];
|
|
935
|
+
readonly additionalProperties: false;
|
|
936
|
+
readonly properties: {
|
|
937
|
+
readonly id: {
|
|
938
|
+
readonly type: "string";
|
|
939
|
+
readonly description: "Optional; generated when omitted";
|
|
940
|
+
};
|
|
941
|
+
readonly x: {
|
|
942
|
+
readonly type: "number";
|
|
943
|
+
readonly description: "Top-left x of the first line, in px";
|
|
944
|
+
};
|
|
945
|
+
readonly y: {
|
|
946
|
+
readonly type: "number";
|
|
947
|
+
readonly description: "Top-left y of the first line, in px";
|
|
948
|
+
};
|
|
949
|
+
readonly text: {
|
|
950
|
+
readonly type: "string";
|
|
951
|
+
readonly description: "Content; \"\\n\" forces a line break";
|
|
952
|
+
};
|
|
953
|
+
readonly color: {
|
|
954
|
+
readonly enum: readonly ColorName[];
|
|
955
|
+
readonly description: "Named color preset. Sets the stroke (outline + text) and, for boxes, a matching pastel fill. Omit for the default gray on transparent";
|
|
956
|
+
};
|
|
957
|
+
readonly stroke: {
|
|
958
|
+
readonly type: "string";
|
|
959
|
+
readonly description: "CSS color of the text; overrides the preset";
|
|
439
960
|
};
|
|
440
961
|
};
|
|
441
962
|
};
|
|
442
963
|
};
|
|
443
964
|
};
|
|
444
965
|
|
|
445
|
-
|
|
966
|
+
type MermaidDirection = 'LR' | 'TD';
|
|
967
|
+
type MermaidOptions = Readonly<{
|
|
968
|
+
direction?: MermaidDirection;
|
|
969
|
+
}>;
|
|
970
|
+
/**
|
|
971
|
+
* Export a drawing as a Mermaid `flowchart`. Boxes become nodes (in shape
|
|
972
|
+
* order), connectors bound at both ends become edges; unbound connectors
|
|
973
|
+
* are dropped and free text shapes are kept as `%% note:` comments so
|
|
974
|
+
* nothing is silently lost.
|
|
975
|
+
*/
|
|
976
|
+
declare function drawingToMermaid(data: DrawingData, options?: MermaidOptions): string;
|
|
977
|
+
|
|
978
|
+
export { $createDrawingNode, $createFrontmatterNode, $getSelectedTable, $getTableDensity, $getTableSettings, $getTableWidth, $isDrawingNode, $isFrontmatterNode, $isTableWidthExplicit, $setTableDensity, $setTableSettings, $setTableWidth, BLOCK_WIDTHS, BOX_DEFINITIONS, BOX_TYPES, type Binding, type BindingSide, type BlockWidth, type BlockWidthDefaults, type BoxDefinition, type BoxType, COLOR_PRESETS, CONNECTOR_TYPES, type ColorName, type ConnectorType, DEFAULT_TABLE_SETTINGS, DIAGRAM, DRAWING, DRAWING_DATA_JSON_SCHEMA, DRAWING_SKELETON_JSON_SCHEMA, type DrawingData, DrawingNode, type DrawingShape, type DrawingShapeType, type DrawingSkeleton, EMPTY_DRAWING, type EditorContentProps, type EditorMode, type EditorRootProps, FILL_COLORS, FRONTMATTER, FormatButtons, FrontmatterNode, HistoryButtons, InsertButtons, MarkdownEditor, type MarkdownEditorApi, type Props as MarkdownEditorProps, type MermaidDirection, type MermaidOptions, type Point, SHAPE_TYPES, SIDE_FIXED_POINTS, STROKE_COLORS, type SerializedDrawingNode, type SerializedFrontmatterNode, type SkeletonBox, type SkeletonConnector, type SkeletonEnd, type SkeletonText, TABLE, TABLE_WIDTH_MARKER, type TableDensity, type TableSettings, type TableSettingsOptions, type TextField, Toolbar, ToolbarButton, ToolbarDivider, type ToolbarItems, anchorPoint, bindEndpoints, boxOutline, connectorPoints, drawingToMermaid, expandSkeleton, findBoxAt, fixedPointFor, formatTableSettingsMarker, isBlockWidth, isDrawingSkeleton, makeBinding, normalizeDrawingData, parseDrawingData, parseDrawingSkeleton, parseTableSettingsMarker, resolveBindings, routeElbow, serializeDrawingData, useMarkdownEditor };
|