@zuilib/text-editor 0.11.0 → 0.12.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 +180 -17
- package/DRAWING_FORMAT.md +23 -21
- package/README.md +486 -68
- package/dist/chunk-32RX4GZF.js +2 -0
- package/dist/chunk-3TZVOXWX.js +16 -0
- package/dist/chunk-5VRVC56Y.js +2 -0
- package/dist/chunk-7Z3CW6Q3.js +2 -0
- package/dist/chunk-A7MCBSAZ.js +2 -0
- package/dist/chunk-AGTPMKLK.js +2 -0
- package/dist/chunk-C7VEINKX.js +2 -0
- package/dist/chunk-LDVPFZCN.js +2 -0
- package/dist/chunk-N5JWZ2VW.js +9 -0
- package/dist/chunk-QKHMJQO3.js +2 -0
- package/dist/chunk-R5PL4Q7X.js +5 -0
- package/dist/chunk-SDICQI2B.js +2 -0
- package/dist/chunk-TGVEPLDM.js +1 -0
- package/dist/chunk-XP3MZRCW.js +2 -0
- package/dist/chunk-XRJNLGI4.js +2 -0
- package/dist/chunk-YFFSTMIR.js +2 -0
- package/dist/chunk-ZXZMYJ7F.js +2 -0
- package/dist/comment-markers-BrrrAdSL.d.ts +27 -0
- package/dist/comments.d.ts +68 -0
- package/dist/comments.js +2 -0
- package/dist/drawing-data-EWzEQ1_i.d.ts +111 -0
- package/dist/drawing-preset-Ag7a7F9h.d.ts +69 -0
- package/dist/drawing.d.ts +7 -0
- package/dist/drawing.js +2 -0
- package/dist/image-node-kR1Zf5kz.d.ts +70 -0
- package/dist/images.d.ts +66 -0
- package/dist/images.js +2 -0
- package/dist/index-A4S7bRwQ.d.ts +425 -0
- package/dist/index.d.ts +36 -1394
- package/dist/index.js +2 -7447
- package/dist/lexical.d.ts +117 -0
- package/dist/lexical.js +2 -0
- package/dist/markdown.d.ts +29 -0
- package/dist/markdown.js +2 -0
- package/dist/mention-node-eSsjUpaE.d.ts +44 -0
- package/dist/mentions-plugin-gio3_XKd.d.ts +74 -0
- package/dist/mentions.d.ts +5 -0
- package/dist/mentions.js +2 -0
- package/dist/mermaid-BwGHjwpk.d.ts +553 -0
- package/dist/paste.d.ts +45 -0
- package/dist/paste.js +2 -0
- package/dist/presets-BtNPH0pa.d.ts +78 -0
- package/dist/styles.css +406 -99
- package/dist/table-grid-D70tNhp2.d.ts +459 -0
- package/package.json +57 -12
- package/dist/index.css +0 -79
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
import { LexicalCommand, NodeKey } from 'lexical';
|
|
2
|
+
import { a as BlockWidth } from './presets-BtNPH0pa.js';
|
|
3
|
+
import { c as DrawingShape, P as Point, B as Binding, e as NodeShapeType, b as ConnectorType, a as BindingSide, D as DrawingData } from './drawing-data-EWzEQ1_i.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Handles `INSERT_DRAWING_COMMAND`. The `DrawingNode` itself must be in the
|
|
7
|
+
* editor's `nodes` (it is in the default entry; add it yourself on top of
|
|
8
|
+
* `./core`).
|
|
9
|
+
*/
|
|
10
|
+
declare function DrawingPlugin(): null;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Dispatched by a drawing canvas when it gains focus (its node key) or
|
|
14
|
+
* loses it (`null`). A drawing is a decorator, so Lexical's selection does
|
|
15
|
+
* not follow the caret into it; `useMarkdownEditor()` listens to this to
|
|
16
|
+
* know which block `blockWidth` refers to.
|
|
17
|
+
*/
|
|
18
|
+
declare const DRAWING_FOCUS_COMMAND: LexicalCommand<NodeKey | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Insert an empty drawing at the selection. Handled by `DrawingPlugin`
|
|
21
|
+
* (mounted by the default `MarkdownEditor`; absent from the `./core`
|
|
22
|
+
* entry, where the command is a no-op).
|
|
23
|
+
*/
|
|
24
|
+
declare const INSERT_DRAWING_COMMAND: LexicalCommand<{
|
|
25
|
+
width?: BlockWidth;
|
|
26
|
+
} | undefined>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* JSON Schema (draft-07) for the payload of a ```drawing fenced block
|
|
30
|
+
* (format version 3).
|
|
31
|
+
*
|
|
32
|
+
* Use it to validate LLM- or tool-generated drawings before embedding them,
|
|
33
|
+
* or pass it as a structured-output / tool schema so a model is forced to
|
|
34
|
+
* emit valid payloads. Kept in sync with `deserializeDrawingData` /
|
|
35
|
+
* `normalizeShape` in types.ts; update both together.
|
|
36
|
+
*
|
|
37
|
+
* For generation prefer the ```diagram skeleton
|
|
38
|
+
* (`DRAWING_SKELETON_JSON_SCHEMA`): it needs no coordinates and expands into
|
|
39
|
+
* this format on import.
|
|
40
|
+
*/
|
|
41
|
+
declare const DRAWING_DATA_JSON_SCHEMA: {
|
|
42
|
+
readonly $schema: "http://json-schema.org/draft-07/schema#";
|
|
43
|
+
readonly title: "DrawingData";
|
|
44
|
+
readonly description: "Vector drawing embedded in markdown as a ```drawing fenced code block (format version 3)";
|
|
45
|
+
readonly type: "object";
|
|
46
|
+
readonly required: readonly ["version", "canvasHeight", "shapes"];
|
|
47
|
+
readonly additionalProperties: false;
|
|
48
|
+
readonly properties: {
|
|
49
|
+
readonly version: {
|
|
50
|
+
readonly const: 3;
|
|
51
|
+
readonly description: "Format version; always 3";
|
|
52
|
+
};
|
|
53
|
+
readonly canvasHeight: {
|
|
54
|
+
readonly type: "number";
|
|
55
|
+
readonly minimum: 80;
|
|
56
|
+
readonly description: "Canvas height in pixels. Make it large enough to contain every shape plus ~20px margin.";
|
|
57
|
+
};
|
|
58
|
+
readonly canvasWidth: {
|
|
59
|
+
readonly type: "number";
|
|
60
|
+
readonly minimum: 120;
|
|
61
|
+
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.";
|
|
62
|
+
};
|
|
63
|
+
readonly width: {
|
|
64
|
+
readonly enum: readonly ["full", "text", "content"];
|
|
65
|
+
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";
|
|
66
|
+
};
|
|
67
|
+
readonly title: {
|
|
68
|
+
readonly type: "string";
|
|
69
|
+
readonly description: "Optional accessible name of the drawing, read by screen readers in place of the shapes";
|
|
70
|
+
};
|
|
71
|
+
readonly description: {
|
|
72
|
+
readonly type: "string";
|
|
73
|
+
readonly description: "Optional longer accessible description of what the drawing shows";
|
|
74
|
+
};
|
|
75
|
+
readonly shapes: {
|
|
76
|
+
readonly type: "array";
|
|
77
|
+
readonly items: {
|
|
78
|
+
readonly $ref: "#/definitions/shape";
|
|
79
|
+
};
|
|
80
|
+
readonly maxItems: 5000;
|
|
81
|
+
readonly description: "Render order: later shapes draw on top";
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
readonly definitions: {
|
|
85
|
+
readonly point: {
|
|
86
|
+
readonly type: "object";
|
|
87
|
+
readonly required: readonly ["x", "y"];
|
|
88
|
+
readonly additionalProperties: false;
|
|
89
|
+
readonly properties: {
|
|
90
|
+
readonly x: {
|
|
91
|
+
readonly type: "number";
|
|
92
|
+
readonly description: "Absolute canvas x";
|
|
93
|
+
};
|
|
94
|
+
readonly y: {
|
|
95
|
+
readonly type: "number";
|
|
96
|
+
readonly description: "Absolute canvas y";
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
readonly binding: {
|
|
101
|
+
readonly type: "object";
|
|
102
|
+
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.";
|
|
103
|
+
readonly required: readonly ["id"];
|
|
104
|
+
readonly additionalProperties: false;
|
|
105
|
+
readonly properties: {
|
|
106
|
+
readonly id: {
|
|
107
|
+
readonly type: "string";
|
|
108
|
+
readonly description: "Id of the box this endpoint is attached to";
|
|
109
|
+
};
|
|
110
|
+
readonly fixedPoint: {
|
|
111
|
+
readonly type: "array";
|
|
112
|
+
readonly items: {
|
|
113
|
+
readonly type: "number";
|
|
114
|
+
readonly minimum: 0;
|
|
115
|
+
readonly maximum: 1;
|
|
116
|
+
};
|
|
117
|
+
readonly minItems: 2;
|
|
118
|
+
readonly maxItems: 2;
|
|
119
|
+
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.";
|
|
120
|
+
};
|
|
121
|
+
readonly mode: {
|
|
122
|
+
readonly enum: readonly ["orbit", "inside"];
|
|
123
|
+
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.";
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
readonly shape: {
|
|
128
|
+
readonly type: "object";
|
|
129
|
+
readonly required: readonly ["id", "type", "x", "y", "width", "height", "stroke", "fill", "strokeWidth"];
|
|
130
|
+
readonly additionalProperties: false;
|
|
131
|
+
readonly properties: {
|
|
132
|
+
readonly id: {
|
|
133
|
+
readonly type: "string";
|
|
134
|
+
readonly description: "Unique within the drawing; connector bindings reference it";
|
|
135
|
+
};
|
|
136
|
+
readonly type: {
|
|
137
|
+
readonly enum: readonly ["rect", "ellipse", "diamond", "note", "cylinder", "cloud", "queue", "actor", "arrow", "line", "text"];
|
|
138
|
+
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.";
|
|
139
|
+
};
|
|
140
|
+
readonly x: {
|
|
141
|
+
readonly type: "number";
|
|
142
|
+
readonly description: "Boxes/text: left edge of the bounding box. Connectors: start point x.";
|
|
143
|
+
};
|
|
144
|
+
readonly y: {
|
|
145
|
+
readonly type: "number";
|
|
146
|
+
readonly description: "Boxes/text: top edge of the bounding box. Connectors: start point y.";
|
|
147
|
+
};
|
|
148
|
+
readonly width: {
|
|
149
|
+
readonly type: "number";
|
|
150
|
+
readonly description: "Boxes/text: width (non-negative). Connectors: delta x to the end point (may be negative).";
|
|
151
|
+
};
|
|
152
|
+
readonly height: {
|
|
153
|
+
readonly type: "number";
|
|
154
|
+
readonly description: "Boxes/text: height (non-negative). Connectors: delta y to the end point (may be negative).";
|
|
155
|
+
};
|
|
156
|
+
readonly stroke: {
|
|
157
|
+
readonly type: "string";
|
|
158
|
+
readonly description: "CSS color of the outline (and of any text). Palette: #1e1e1e (default), #e03131 red, #2f9e44 green, #1971c2 blue, #f08c00 orange, #7048e8 purple.";
|
|
159
|
+
};
|
|
160
|
+
readonly fill: {
|
|
161
|
+
readonly type: "string";
|
|
162
|
+
readonly description: "CSS color of the interior; \"transparent\" for none. Palette: #ffc9c9 red, #b2f2bb green, #a5d8ff blue, #ffec99 yellow, #d0bfff purple.";
|
|
163
|
+
};
|
|
164
|
+
readonly strokeWidth: {
|
|
165
|
+
readonly type: "number";
|
|
166
|
+
readonly description: "Outline width; use 2";
|
|
167
|
+
};
|
|
168
|
+
readonly text: {
|
|
169
|
+
readonly type: "string";
|
|
170
|
+
readonly description: "Standalone text content; center content of a box (the name under an actor); midpoint label of a connector";
|
|
171
|
+
};
|
|
172
|
+
readonly label: {
|
|
173
|
+
readonly type: "string";
|
|
174
|
+
readonly description: "Boxes only (not actor): small bold heading at the top";
|
|
175
|
+
};
|
|
176
|
+
readonly footer: {
|
|
177
|
+
readonly type: "string";
|
|
178
|
+
readonly description: "Boxes only (not actor): small dim line at the bottom";
|
|
179
|
+
};
|
|
180
|
+
readonly startBinding: {
|
|
181
|
+
readonly $ref: "#/definitions/binding";
|
|
182
|
+
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.";
|
|
183
|
+
};
|
|
184
|
+
readonly endBinding: {
|
|
185
|
+
readonly $ref: "#/definitions/binding";
|
|
186
|
+
readonly description: "Connectors only: box the end point attaches to";
|
|
187
|
+
};
|
|
188
|
+
readonly bidirectional: {
|
|
189
|
+
readonly type: "boolean";
|
|
190
|
+
readonly description: "Arrows only: arrowheads on both ends";
|
|
191
|
+
};
|
|
192
|
+
readonly routing: {
|
|
193
|
+
readonly const: "elbow";
|
|
194
|
+
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.";
|
|
195
|
+
};
|
|
196
|
+
readonly elbow: {
|
|
197
|
+
readonly type: "number";
|
|
198
|
+
readonly minimum: 0;
|
|
199
|
+
readonly maximum: 1;
|
|
200
|
+
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.";
|
|
201
|
+
};
|
|
202
|
+
readonly waypoints: {
|
|
203
|
+
readonly type: "array";
|
|
204
|
+
readonly items: {
|
|
205
|
+
readonly $ref: "#/definitions/point";
|
|
206
|
+
};
|
|
207
|
+
readonly description: "Connectors only: intermediate path points in canvas coordinates, ordered start to end. Takes precedence over routing.";
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
type Rect = Readonly<{
|
|
215
|
+
x: number;
|
|
216
|
+
y: number;
|
|
217
|
+
w: number;
|
|
218
|
+
h: number;
|
|
219
|
+
}>;
|
|
220
|
+
|
|
221
|
+
/** Topmost box under a point, if any; smaller boxes win over enclosing ones */
|
|
222
|
+
declare function findNodeShapeAt(shapes: readonly DrawingShape[], point: Point, excludeId?: string, tolerance?: number): DrawingShape | null;
|
|
223
|
+
declare function createBinding(box: DrawingShape, point: Point): Binding;
|
|
224
|
+
|
|
225
|
+
type TextField = 'text' | 'label' | 'footer';
|
|
226
|
+
/**
|
|
227
|
+
* Geometry of a box type, kept free of React so the router, bindings,
|
|
228
|
+
* skeleton expansion and exporters can use it without a DOM.
|
|
229
|
+
*/
|
|
230
|
+
type NodeShapeDefinition = Readonly<{
|
|
231
|
+
type: NodeShapeType;
|
|
232
|
+
label: string;
|
|
233
|
+
/** Size used when a shape is created without explicit dimensions */
|
|
234
|
+
defaultSize: Readonly<{
|
|
235
|
+
w: number;
|
|
236
|
+
h: number;
|
|
237
|
+
}>;
|
|
238
|
+
/** Text slots the shape renders (and offers for editing) */
|
|
239
|
+
textSlots: readonly TextField[];
|
|
240
|
+
/** Fill applied when the tool is picked with the default (transparent) fill */
|
|
241
|
+
defaultFill?: string;
|
|
242
|
+
/** Closed outline used for hit-testing and binding endpoints */
|
|
243
|
+
outline: (shape: DrawingShape) => Point[];
|
|
244
|
+
/** Area the text slots lay out in */
|
|
245
|
+
textArea: (shape: DrawingShape) => Rect;
|
|
246
|
+
}>;
|
|
247
|
+
declare const NODE_SHAPE_DEFINITIONS: Record<NodeShapeType, NodeShapeDefinition>;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Skeleton (intent) layer: a compact, LLM-friendly description of a diagram
|
|
251
|
+
* — boxes, connectors between them and loose texts — that expands into a
|
|
252
|
+
* full `DrawingData` document. Sizes, positions and connector geometry are
|
|
253
|
+
* derived, so a generator only needs to say *what* is on the canvas.
|
|
254
|
+
*/
|
|
255
|
+
|
|
256
|
+
type ColorName = 'plain' | 'black' | 'gray' | 'red' | 'green' | 'blue' | 'orange' | 'purple';
|
|
257
|
+
declare const COLOR_PRESETS: Record<ColorName, {
|
|
258
|
+
stroke: string;
|
|
259
|
+
fill: string;
|
|
260
|
+
}>;
|
|
261
|
+
type SkeletonBox = Readonly<{
|
|
262
|
+
id: string;
|
|
263
|
+
/** Default `'rect'` */
|
|
264
|
+
type?: NodeShapeType;
|
|
265
|
+
label?: string;
|
|
266
|
+
text?: string;
|
|
267
|
+
footer?: string;
|
|
268
|
+
/** Omitted → auto layout */
|
|
269
|
+
x?: number;
|
|
270
|
+
y?: number;
|
|
271
|
+
/** Omitted → measured from the text, never smaller than the type's default size */
|
|
272
|
+
w?: number;
|
|
273
|
+
h?: number;
|
|
274
|
+
/** Preset → stroke + fill (fill only when `fill` isn't given) */
|
|
275
|
+
color?: ColorName;
|
|
276
|
+
stroke?: string;
|
|
277
|
+
fill?: string;
|
|
278
|
+
}>;
|
|
279
|
+
type SkeletonEnd = string | Readonly<{
|
|
280
|
+
id: string;
|
|
281
|
+
side?: BindingSide;
|
|
282
|
+
}>;
|
|
283
|
+
type SkeletonConnector = Readonly<{
|
|
284
|
+
id?: string;
|
|
285
|
+
/** Default `'arrow'` */
|
|
286
|
+
type?: ConnectorType;
|
|
287
|
+
from: SkeletonEnd;
|
|
288
|
+
to: SkeletonEnd;
|
|
289
|
+
text?: string;
|
|
290
|
+
bidirectional?: boolean;
|
|
291
|
+
/** Default `'straight'` */
|
|
292
|
+
routing?: 'elbow' | 'straight';
|
|
293
|
+
color?: ColorName;
|
|
294
|
+
stroke?: string;
|
|
295
|
+
}>;
|
|
296
|
+
type SkeletonText = Readonly<{
|
|
297
|
+
id?: string;
|
|
298
|
+
x: number;
|
|
299
|
+
y: number;
|
|
300
|
+
text: string;
|
|
301
|
+
color?: ColorName;
|
|
302
|
+
stroke?: string;
|
|
303
|
+
}>;
|
|
304
|
+
type DrawingSkeleton = Readonly<{
|
|
305
|
+
/** Auto-layout flow direction, default `'right'` */
|
|
306
|
+
direction?: 'right' | 'down';
|
|
307
|
+
canvasWidth?: number;
|
|
308
|
+
canvasHeight?: number;
|
|
309
|
+
/** Block width of the expanded drawing; omit for `full` */
|
|
310
|
+
width?: BlockWidth;
|
|
311
|
+
boxes: readonly SkeletonBox[];
|
|
312
|
+
connectors?: readonly SkeletonConnector[];
|
|
313
|
+
texts?: readonly SkeletonText[];
|
|
314
|
+
}>;
|
|
315
|
+
/** Structural check: an object with a `boxes` array */
|
|
316
|
+
declare function isDrawingSkeleton(value: unknown): value is DrawingSkeleton;
|
|
317
|
+
/**
|
|
318
|
+
* Parse a skeleton JSON payload into drawing data. Lenient: invalid boxes,
|
|
319
|
+
* connectors and texts are dropped individually, and a malformed document
|
|
320
|
+
* yields an empty canvas. Never throws.
|
|
321
|
+
*/
|
|
322
|
+
declare function parseDrawingSkeleton(json: string): DrawingData;
|
|
323
|
+
declare function expandDrawingSkeleton(skeleton: DrawingSkeleton): DrawingData;
|
|
324
|
+
declare const DRAWING_SKELETON_JSON_SCHEMA: {
|
|
325
|
+
readonly $schema: "http://json-schema.org/draft-07/schema#";
|
|
326
|
+
readonly title: "DrawingSkeleton";
|
|
327
|
+
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";
|
|
328
|
+
readonly type: "object";
|
|
329
|
+
readonly required: readonly ["boxes"];
|
|
330
|
+
readonly additionalProperties: false;
|
|
331
|
+
readonly properties: {
|
|
332
|
+
readonly direction: {
|
|
333
|
+
readonly enum: readonly ["right", "down"];
|
|
334
|
+
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\"";
|
|
335
|
+
};
|
|
336
|
+
readonly canvasWidth: {
|
|
337
|
+
readonly type: "number";
|
|
338
|
+
readonly minimum: 120;
|
|
339
|
+
readonly description: "Logical canvas width in px. Omit for a fluid canvas in CSS pixels";
|
|
340
|
+
};
|
|
341
|
+
readonly canvasHeight: {
|
|
342
|
+
readonly type: "number";
|
|
343
|
+
readonly minimum: 80;
|
|
344
|
+
readonly description: "Canvas height in px. Omit to fit the content";
|
|
345
|
+
};
|
|
346
|
+
readonly width: {
|
|
347
|
+
readonly enum: readonly ["full", "text", "content"];
|
|
348
|
+
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";
|
|
349
|
+
};
|
|
350
|
+
readonly boxes: {
|
|
351
|
+
readonly type: "array";
|
|
352
|
+
readonly items: {
|
|
353
|
+
readonly $ref: "#/definitions/box";
|
|
354
|
+
};
|
|
355
|
+
readonly description: "Card-like shapes carrying up to three text slots. Order is the render order and the stacking order within a layout rank";
|
|
356
|
+
};
|
|
357
|
+
readonly connectors: {
|
|
358
|
+
readonly type: "array";
|
|
359
|
+
readonly items: {
|
|
360
|
+
readonly $ref: "#/definitions/connector";
|
|
361
|
+
};
|
|
362
|
+
readonly description: "Arrows and lines between boxes. Connectors whose from/to id does not match a box are dropped";
|
|
363
|
+
};
|
|
364
|
+
readonly texts: {
|
|
365
|
+
readonly type: "array";
|
|
366
|
+
readonly items: {
|
|
367
|
+
readonly $ref: "#/definitions/text";
|
|
368
|
+
};
|
|
369
|
+
readonly description: "Free-floating annotations not attached to any box. Prefer box slots (label/text/footer) when the text belongs to a box";
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
readonly definitions: {
|
|
373
|
+
readonly box: {
|
|
374
|
+
readonly type: "object";
|
|
375
|
+
readonly required: readonly ["id"];
|
|
376
|
+
readonly additionalProperties: false;
|
|
377
|
+
readonly properties: {
|
|
378
|
+
readonly id: {
|
|
379
|
+
readonly type: "string";
|
|
380
|
+
readonly description: "Unique within the drawing; connectors reference it";
|
|
381
|
+
};
|
|
382
|
+
readonly type: {
|
|
383
|
+
readonly enum: readonly NodeShapeType[];
|
|
384
|
+
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)";
|
|
385
|
+
};
|
|
386
|
+
readonly label: {
|
|
387
|
+
readonly type: "string";
|
|
388
|
+
readonly description: "Small bold heading at the top of the box";
|
|
389
|
+
};
|
|
390
|
+
readonly text: {
|
|
391
|
+
readonly type: "string";
|
|
392
|
+
readonly description: "Main content, centered. Wraps automatically; \"\\n\" forces a line break";
|
|
393
|
+
};
|
|
394
|
+
readonly footer: {
|
|
395
|
+
readonly type: "string";
|
|
396
|
+
readonly description: "Small dim line at the bottom of the box";
|
|
397
|
+
};
|
|
398
|
+
readonly x: {
|
|
399
|
+
readonly type: "number";
|
|
400
|
+
readonly description: "Top-left x in px. Omit (with y) to let the layout place the box";
|
|
401
|
+
};
|
|
402
|
+
readonly y: {
|
|
403
|
+
readonly type: "number";
|
|
404
|
+
readonly description: "Top-left y in px. Omit (with x) to let the layout place the box";
|
|
405
|
+
};
|
|
406
|
+
readonly w: {
|
|
407
|
+
readonly type: "number";
|
|
408
|
+
readonly exclusiveMinimum: 0;
|
|
409
|
+
readonly description: "Width in px. Omit to size from the text (never smaller than the type default)";
|
|
410
|
+
};
|
|
411
|
+
readonly h: {
|
|
412
|
+
readonly type: "number";
|
|
413
|
+
readonly exclusiveMinimum: 0;
|
|
414
|
+
readonly description: "Height in px. Omit to size from the text (never smaller than the type default)";
|
|
415
|
+
};
|
|
416
|
+
readonly color: {
|
|
417
|
+
readonly enum: readonly ColorName[];
|
|
418
|
+
readonly description: "Named color preset: outline plus, for boxes, a matching fill. `plain` has no outline and a light fill, `black` is a dark card with light text, `gray` is a dark outline on transparent (the default); the rest pair a colored outline with its pastel fill.";
|
|
419
|
+
};
|
|
420
|
+
readonly stroke: {
|
|
421
|
+
readonly type: "string";
|
|
422
|
+
readonly description: "CSS color of the outline and text; overrides the preset";
|
|
423
|
+
};
|
|
424
|
+
readonly fill: {
|
|
425
|
+
readonly type: "string";
|
|
426
|
+
readonly description: "CSS color of the interior (\"transparent\" for none); overrides the preset";
|
|
427
|
+
};
|
|
428
|
+
};
|
|
429
|
+
};
|
|
430
|
+
readonly connector: {
|
|
431
|
+
readonly type: "object";
|
|
432
|
+
readonly required: readonly ["from", "to"];
|
|
433
|
+
readonly additionalProperties: false;
|
|
434
|
+
readonly properties: {
|
|
435
|
+
readonly id: {
|
|
436
|
+
readonly type: "string";
|
|
437
|
+
readonly description: "Optional; generated when omitted";
|
|
438
|
+
};
|
|
439
|
+
readonly type: {
|
|
440
|
+
readonly enum: readonly ConnectorType[];
|
|
441
|
+
readonly description: "arrow (default; arrowhead at \"to\") or line (no arrowheads)";
|
|
442
|
+
};
|
|
443
|
+
readonly from: {
|
|
444
|
+
readonly oneOf: readonly [{
|
|
445
|
+
readonly type: "string";
|
|
446
|
+
readonly description: "Id of a box. The connector attaches to its outline, aimed at the other end";
|
|
447
|
+
}, {
|
|
448
|
+
readonly type: "object";
|
|
449
|
+
readonly required: readonly ["id"];
|
|
450
|
+
readonly additionalProperties: false;
|
|
451
|
+
readonly properties: {
|
|
452
|
+
readonly id: {
|
|
453
|
+
readonly type: "string";
|
|
454
|
+
readonly description: "Id of a box";
|
|
455
|
+
};
|
|
456
|
+
readonly side: {
|
|
457
|
+
readonly enum: readonly ["top", "right", "bottom", "left"];
|
|
458
|
+
readonly description: "Pin the endpoint to the middle of this side of the box instead of auto-aiming";
|
|
459
|
+
};
|
|
460
|
+
};
|
|
461
|
+
}];
|
|
462
|
+
readonly description: "Box a connector end attaches to: a bare box id, or {id, side} to pick the attach edge";
|
|
463
|
+
};
|
|
464
|
+
readonly to: {
|
|
465
|
+
readonly oneOf: readonly [{
|
|
466
|
+
readonly type: "string";
|
|
467
|
+
readonly description: "Id of a box. The connector attaches to its outline, aimed at the other end";
|
|
468
|
+
}, {
|
|
469
|
+
readonly type: "object";
|
|
470
|
+
readonly required: readonly ["id"];
|
|
471
|
+
readonly additionalProperties: false;
|
|
472
|
+
readonly properties: {
|
|
473
|
+
readonly id: {
|
|
474
|
+
readonly type: "string";
|
|
475
|
+
readonly description: "Id of a box";
|
|
476
|
+
};
|
|
477
|
+
readonly side: {
|
|
478
|
+
readonly enum: readonly ["top", "right", "bottom", "left"];
|
|
479
|
+
readonly description: "Pin the endpoint to the middle of this side of the box instead of auto-aiming";
|
|
480
|
+
};
|
|
481
|
+
};
|
|
482
|
+
}];
|
|
483
|
+
readonly description: "Box a connector end attaches to: a bare box id, or {id, side} to pick the attach edge";
|
|
484
|
+
};
|
|
485
|
+
readonly text: {
|
|
486
|
+
readonly type: "string";
|
|
487
|
+
readonly description: "Label rendered at the middle of the connector";
|
|
488
|
+
};
|
|
489
|
+
readonly bidirectional: {
|
|
490
|
+
readonly type: "boolean";
|
|
491
|
+
readonly description: "Arrow only: arrowheads on both ends";
|
|
492
|
+
};
|
|
493
|
+
readonly routing: {
|
|
494
|
+
readonly enum: readonly ["straight", "elbow"];
|
|
495
|
+
readonly description: "straight (default) draws a direct line; elbow draws a right-angled path routed around the boxes";
|
|
496
|
+
};
|
|
497
|
+
readonly color: {
|
|
498
|
+
readonly enum: readonly ColorName[];
|
|
499
|
+
readonly description: "Named color preset: outline plus, for boxes, a matching fill. `plain` has no outline and a light fill, `black` is a dark card with light text, `gray` is a dark outline on transparent (the default); the rest pair a colored outline with its pastel fill.";
|
|
500
|
+
};
|
|
501
|
+
readonly stroke: {
|
|
502
|
+
readonly type: "string";
|
|
503
|
+
readonly description: "CSS color of the line and label; overrides the preset";
|
|
504
|
+
};
|
|
505
|
+
};
|
|
506
|
+
};
|
|
507
|
+
readonly text: {
|
|
508
|
+
readonly type: "object";
|
|
509
|
+
readonly required: readonly ["x", "y", "text"];
|
|
510
|
+
readonly additionalProperties: false;
|
|
511
|
+
readonly properties: {
|
|
512
|
+
readonly id: {
|
|
513
|
+
readonly type: "string";
|
|
514
|
+
readonly description: "Optional; generated when omitted";
|
|
515
|
+
};
|
|
516
|
+
readonly x: {
|
|
517
|
+
readonly type: "number";
|
|
518
|
+
readonly description: "Top-left x of the first line, in px";
|
|
519
|
+
};
|
|
520
|
+
readonly y: {
|
|
521
|
+
readonly type: "number";
|
|
522
|
+
readonly description: "Top-left y of the first line, in px";
|
|
523
|
+
};
|
|
524
|
+
readonly text: {
|
|
525
|
+
readonly type: "string";
|
|
526
|
+
readonly description: "Content; \"\\n\" forces a line break";
|
|
527
|
+
};
|
|
528
|
+
readonly color: {
|
|
529
|
+
readonly enum: readonly ColorName[];
|
|
530
|
+
readonly description: "Named color preset: outline plus, for boxes, a matching fill. `plain` has no outline and a light fill, `black` is a dark card with light text, `gray` is a dark outline on transparent (the default); the rest pair a colored outline with its pastel fill.";
|
|
531
|
+
};
|
|
532
|
+
readonly stroke: {
|
|
533
|
+
readonly type: "string";
|
|
534
|
+
readonly description: "CSS color of the text; overrides the preset";
|
|
535
|
+
};
|
|
536
|
+
};
|
|
537
|
+
};
|
|
538
|
+
};
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
type MermaidDirection = 'LR' | 'TD';
|
|
542
|
+
type MermaidOptions = Readonly<{
|
|
543
|
+
direction?: MermaidDirection;
|
|
544
|
+
}>;
|
|
545
|
+
/**
|
|
546
|
+
* Export a drawing as a Mermaid `flowchart`. Boxes become nodes (in shape
|
|
547
|
+
* order), connectors bound at both ends become edges; unbound connectors
|
|
548
|
+
* are dropped and free text shapes are kept as `%% note:` comments so
|
|
549
|
+
* nothing is silently lost.
|
|
550
|
+
*/
|
|
551
|
+
declare function drawingToMermaid(data: DrawingData, options?: MermaidOptions): string;
|
|
552
|
+
|
|
553
|
+
export { COLOR_PRESETS as C, DRAWING_DATA_JSON_SCHEMA as D, INSERT_DRAWING_COMMAND as I, type MermaidDirection as M, NODE_SHAPE_DEFINITIONS as N, type SkeletonBox as S, type TextField as T, type ColorName as a, DRAWING_FOCUS_COMMAND as b, DRAWING_SKELETON_JSON_SCHEMA as c, DrawingPlugin as d, type DrawingSkeleton as e, type MermaidOptions as f, type NodeShapeDefinition as g, type SkeletonConnector as h, type SkeletonEnd as i, type SkeletonText as j, createBinding as k, drawingToMermaid as l, expandDrawingSkeleton as m, findNodeShapeAt as n, isDrawingSkeleton as o, parseDrawingSkeleton as p };
|
package/dist/paste.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalisation of pasted HTML from Word, Google Docs, Confluence and
|
|
3
|
+
* browsers: structure is kept (headings, paragraphs, lists, tables, links,
|
|
4
|
+
* code, quotes, emphasis, images), presentation is dropped (styles,
|
|
5
|
+
* classes, ids, fonts, spans, Office namespaces, comments, scripts).
|
|
6
|
+
* Links whose `href` fails `isSafeUrl` (`javascript:`, `data:`, ...) keep
|
|
7
|
+
* their text only.
|
|
8
|
+
*/
|
|
9
|
+
type PasteNormalizeOptions = Readonly<{
|
|
10
|
+
/** Keep `<table>` structure (default `true`); `false` flattens cells to paragraphs */
|
|
11
|
+
tables?: boolean;
|
|
12
|
+
/** Keep `<a href>` (default `true`); `false` keeps the text only */
|
|
13
|
+
links?: boolean;
|
|
14
|
+
/** Keep `<img>` (default `true`) */
|
|
15
|
+
images?: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* The cleaned body HTML of a pasted fragment. `<pre>` content is left as
|
|
19
|
+
* is apart from attribute stripping.
|
|
20
|
+
*/
|
|
21
|
+
declare function normalizePastedHtml(html: string, options?: PasteNormalizeOptions): string;
|
|
22
|
+
/** Whether the HTML looks like it came from Word, Google Docs, Confluence or Outlook */
|
|
23
|
+
declare function isRichSourceHtml(html: string): boolean;
|
|
24
|
+
|
|
25
|
+
type PastePluginProps = PasteNormalizeOptions & Readonly<{
|
|
26
|
+
/**
|
|
27
|
+
* `'rich-sources'` (default) normalises only HTML that carries Word,
|
|
28
|
+
* Google Docs, Confluence or Outlook fingerprints; `'always'` normalises
|
|
29
|
+
* every HTML paste.
|
|
30
|
+
*/
|
|
31
|
+
when?: 'rich-sources' | 'always';
|
|
32
|
+
/** Transform the cleaned HTML further before it is converted to nodes */
|
|
33
|
+
transform?: (html: string) => string;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* HTML paste normalisation. Word, Google Docs and Confluence put inline
|
|
37
|
+
* styles, spans, fonts, Office namespaces and conditional comments on the
|
|
38
|
+
* clipboard; this plugin strips them and keeps headings, paragraphs,
|
|
39
|
+
* lists, tables, links, code, quotes, emphasis and images before the
|
|
40
|
+
* built-in rich-text paste converts the HTML to nodes. Plain-text pastes
|
|
41
|
+
* and pastes inside a decorator's input are untouched.
|
|
42
|
+
*/
|
|
43
|
+
declare function PastePlugin({ when, transform, tables, links, images }?: PastePluginProps): null;
|
|
44
|
+
|
|
45
|
+
export { type PasteNormalizeOptions, PastePlugin, type PastePluginProps, isRichSourceHtml, normalizePastedHtml };
|
package/dist/paste.js
ADDED