@draftably/editor 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/assets/engine.worker-C6o2x40z.js +7609 -0
- package/dist/element.js +171 -17
- package/dist/index.js +9837 -8468
- package/dist/types/src/cli/raster-fonts.d.ts +3 -0
- package/dist/types/src/components/canvas/Canvas.d.ts +4 -0
- package/dist/types/src/components/scene/NodeView.d.ts +7 -0
- package/dist/types/src/components/scene/parts.d.ts +7 -11
- package/dist/types/src/components/session-context.d.ts +4 -1
- package/dist/types/src/dsl/cells.d.ts +1 -0
- package/dist/types/src/dsl/compile.d.ts +15 -1
- package/dist/types/src/dsl/corridors.d.ts +38 -0
- package/dist/types/src/dsl/legend-notes.d.ts +14 -0
- package/dist/types/src/dsl/syntax.d.ts +3 -1
- package/dist/types/src/editor/css.d.ts +3 -0
- package/dist/types/src/editor/element.d.ts +8 -6
- package/dist/types/src/editor/internal.d.ts +483 -0
- package/dist/types/src/editor/mount.d.ts +70 -5
- package/dist/types/src/graph-api/core.d.ts +125 -0
- package/dist/types/src/model/appearance.d.ts +19 -0
- package/dist/types/src/model/colors.d.ts +10 -2
- package/dist/types/src/model/labels.d.ts +22 -6
- package/dist/types/src/model/types.d.ts +9 -0
- package/dist/types/src/runtime/anchors.d.ts +46 -0
- package/dist/types/src/runtime/camera.d.ts +41 -0
- package/dist/types/src/runtime/element-base.d.ts +40 -0
- package/dist/types/src/runtime/geometry.d.ts +72 -0
- package/dist/types/src/runtime/host.d.ts +46 -0
- package/dist/types/src/runtime/page-shared.d.ts +24 -0
- package/dist/types/src/runtime/policy.d.ts +7 -0
- package/dist/types/src/runtime/render.d.ts +10 -0
- package/dist/types/src/runtime/svg-renderer.d.ts +8 -0
- package/dist/types/src/runtime/types.d.ts +115 -0
- package/dist/types/src/runtime/version.d.ts +2 -0
- package/dist/types/src/runtime/viewer.d.ts +123 -0
- package/dist/types/src/state/active-session.d.ts +7 -1
- package/dist/types/src/state/dom-root.d.ts +8 -0
- package/dist/types/src/state/session/document.d.ts +3 -1
- package/dist/types/src/state/session/editor.d.ts +3 -2
- package/dist/types/src/state/session/index.d.ts +5 -1
- package/package.json +1 -1
- package/dist/assets/engine.worker-DwN9io_m.js +0 -6856
- package/dist/types/src/cli/png.d.ts +0 -23
- package/dist/types/src/model/embed.d.ts +0 -17
|
@@ -7,6 +7,10 @@ export interface CanvasProps {
|
|
|
7
7
|
onDropFiles?: (files: File[]) => Promise<void> | void;
|
|
8
8
|
/** Shown under the hint on an empty canvas, such as a button that builds from a list. */
|
|
9
9
|
emptyAction?: JSX.Element;
|
|
10
|
+
/** The host's slot targets, above the drawing and below the chrome layer. */
|
|
11
|
+
anchorLayer?: HTMLElement;
|
|
12
|
+
/** Nodes a host body covers: their titles hide, and their ports and handles draw on top. */
|
|
13
|
+
bodies?: () => ReadonlySet<string>;
|
|
10
14
|
}
|
|
11
15
|
/**
|
|
12
16
|
* The canvas for the session in context: drawing, selection, dragging, inline editing, layout
|
|
@@ -14,5 +14,12 @@ export interface NodeViewProps {
|
|
|
14
14
|
/** Comparison candidates: focusable so a keyboard user can choose the anchor. */
|
|
15
15
|
focusable?: boolean;
|
|
16
16
|
idPrefix?: string;
|
|
17
|
+
/** A host body covers this node: its ports and handles draw in the chrome layer above it. */
|
|
18
|
+
body?: boolean;
|
|
17
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* The ports and resize handles of a node with a host body, drawn in the editor's top layer so the
|
|
22
|
+
* body never hides them. Pointer input on them reaches the canvas's own handlers.
|
|
23
|
+
*/
|
|
24
|
+
export declare function NodeChrome(props: NodeViewProps): import("solid-js").JSX.Element;
|
|
18
25
|
export declare function NodeView(props: NodeViewProps): import("solid-js").JSX.Element;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ResolvedAppearance } from '../../model/appearance';
|
|
2
|
+
import type { NodeLabel } from '../../model/labels';
|
|
2
3
|
import type { Rect } from '../../model/types';
|
|
3
|
-
/**
|
|
4
|
-
export declare function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
y: number;
|
|
8
|
-
lineHeight: number;
|
|
9
|
-
type: TypeProfile;
|
|
4
|
+
/** A shape's title: its name lines, then its detail lines a step smaller in `detailFill`. */
|
|
5
|
+
export declare function NodeTitle(props: {
|
|
6
|
+
label: NodeLabel;
|
|
7
|
+
look: ResolvedAppearance;
|
|
10
8
|
fill: string;
|
|
11
|
-
|
|
12
|
-
/** Strike the text through, as for a removed object. */
|
|
9
|
+
detailFill: string;
|
|
13
10
|
strike?: boolean;
|
|
14
|
-
/** Fade of the text alone, as for a removed object. */
|
|
15
11
|
fade?: number;
|
|
16
12
|
}): import("solid-js").JSX.Element;
|
|
17
13
|
/** The removed marker, a minus in a disc, centred at (x, y). */
|
|
@@ -52,7 +52,8 @@ export declare const useSessionIfAny: () => ({
|
|
|
52
52
|
redo: () => void;
|
|
53
53
|
canUndo: () => boolean;
|
|
54
54
|
canRedo: () => boolean;
|
|
55
|
-
setCamera: (camera: import("../model/types").Camera) => void;
|
|
55
|
+
setCamera: (camera: import("../model/types").Camera, reason?: import("../runtime/camera").CameraReason) => void;
|
|
56
|
+
onCamera: (listener: (reason: import("../runtime/camera").CameraReason) => void) => () => boolean;
|
|
56
57
|
disableBrowserStorage: () => boolean;
|
|
57
58
|
setPersistenceBlocked: (blocked: boolean) => void;
|
|
58
59
|
persist: () => void;
|
|
@@ -482,5 +483,7 @@ export declare const useSessionIfAny: () => ({
|
|
|
482
483
|
onDoubleClick: (e: MouseEvent) => void;
|
|
483
484
|
selectForContextMenu: (e: MouseEvent) => void;
|
|
484
485
|
dragKind: () => string | undefined;
|
|
486
|
+
} & {
|
|
487
|
+
describeLink: (href: string) => string;
|
|
485
488
|
}) | undefined;
|
|
486
489
|
export declare function useDiagramSession(): DiagramSession;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ResolvedAppearance } from '../model/appearance';
|
|
2
2
|
import type { CellsChrome, Lane, SequenceLayout } from '../model/types';
|
|
3
|
+
import { type Planned } from './corridors';
|
|
3
4
|
import { GROUP_HEADER, GROUP_INSET, contentOrigin } from './frame';
|
|
4
5
|
import { type Model, type ModelEdge, type ModelLayout, type ModelObject } from './syntax';
|
|
5
6
|
/** The single render context. Browser window size changes the camera, never the layout. */
|
|
@@ -44,6 +45,8 @@ export interface Diagnostic {
|
|
|
44
45
|
/** A connection as the file declares it, plus the lane a fold's wrap edge returns along. */
|
|
45
46
|
export interface SceneEdge extends ModelEdge {
|
|
46
47
|
lane?: Lane;
|
|
48
|
+
/** A forward line's route, planned from its scope's ranks and corridors (`planRoutes`). */
|
|
49
|
+
plan?: Planned;
|
|
47
50
|
/** A sequence message: the height of its row; it is drawn straight between lifelines there. */
|
|
48
51
|
row?: number;
|
|
49
52
|
}
|
|
@@ -96,11 +99,12 @@ export declare function layoutFor(m: Model, scope: string): ModelLayout;
|
|
|
96
99
|
/**
|
|
97
100
|
* Size of a node: its requested size, or the default width with a height that fits the title in
|
|
98
101
|
* the theme's type and padding. A requested size is kept exactly; `overflow` reports a title that
|
|
99
|
-
* no longer fits in it.
|
|
102
|
+
* no longer fits in it. With `height=auto`, `min-height` is a floor under the title's height.
|
|
100
103
|
*/
|
|
101
104
|
export declare function leafSize(o: ModelObject, size: {
|
|
102
105
|
width: number;
|
|
103
106
|
height?: number;
|
|
107
|
+
minHeight?: number;
|
|
104
108
|
} | undefined, look: ResolvedAppearance): {
|
|
105
109
|
w: number;
|
|
106
110
|
h: number;
|
|
@@ -149,6 +153,16 @@ export declare function crossings(paths: Array<Array<{
|
|
|
149
153
|
}>>): number;
|
|
150
154
|
/** The order of up to six items that scores fewest crossings; the first such, from `items`. */
|
|
151
155
|
export declare function fewestCrossings<T>(items: T[], score: (order: T[]) => number): T[];
|
|
156
|
+
/**
|
|
157
|
+
* The corridors a `flow` scope keeps for lines that skip ranks: the ranks with their stand-ins,
|
|
158
|
+
* each line's stand-ins by its index in the scope's pairs, and each stand-in's place across the
|
|
159
|
+
* run, in the scope's coordinates.
|
|
160
|
+
*/
|
|
161
|
+
export interface Corridors {
|
|
162
|
+
order: string[][];
|
|
163
|
+
chains: Map<number, string[]>;
|
|
164
|
+
across: Map<string, number>;
|
|
165
|
+
}
|
|
152
166
|
/**
|
|
153
167
|
* Lay out a model. `arranged` holds world positions from layout engines; scopes that an engine
|
|
154
168
|
* governs take their children's relative placement from it instead of their built-in recipe.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Routes for a `flow` scope's forward lines, planned from its ranks as a layered layout routes its
|
|
3
|
+
* edges: out of the source's trailing side, along a track in each gap the line turns in, down a
|
|
4
|
+
* corridor through each rank it skips, and into the target's leading side. The ranks' order already
|
|
5
|
+
* keeps crossings few, so the plan only has to place ports and order each gap's tracks. The router
|
|
6
|
+
* takes a planned route as it is when it clears every box.
|
|
7
|
+
*/
|
|
8
|
+
import type { Point, Rect } from '../model/types';
|
|
9
|
+
export interface PlanLine {
|
|
10
|
+
id: string;
|
|
11
|
+
/** Source, the stand-ins of the ranks it skips, target. */
|
|
12
|
+
chain: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface Planned {
|
|
15
|
+
points: Point[];
|
|
16
|
+
fromOffset: number;
|
|
17
|
+
toOffset: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Space between ports on one side and between neighbouring tracks in a gap, as the router keeps
|
|
21
|
+
* them: ports `max(portGap, edgeGap)` apart and tracks `edgeGap` apart.
|
|
22
|
+
*/
|
|
23
|
+
export interface Spacing {
|
|
24
|
+
port: number;
|
|
25
|
+
track: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Plans each line of `lines`. `order` is the ranks with stand-ins, `box` each real member's drawn
|
|
29
|
+
* box and `across` each stand-in's place across the run, all in drawing coordinates. Lines that
|
|
30
|
+
* cannot be planned (a member without a box) are left out.
|
|
31
|
+
*/
|
|
32
|
+
export declare function planRoutes(axis: 'down' | 'right', order: string[][], lines: PlanLine[], box: (id: string) => Rect | undefined, across: (id: string) => number | undefined, spacing?: Spacing): Map<string, Planned>;
|
|
33
|
+
/**
|
|
34
|
+
* The room each gap between ranks needs for the tracks `planRoutes` lays in it: a standoff from
|
|
35
|
+
* the boxes either side and a pitch between tracks, by gap index; a gap with no track is absent.
|
|
36
|
+
* `box` may be a member's slot: only its place across the run counts.
|
|
37
|
+
*/
|
|
38
|
+
export declare function trackRoom(axis: 'down' | 'right', order: string[][], lines: PlanLine[], box: (id: string) => Rect | undefined, across: (id: string) => number | undefined, spacing?: Spacing): number[];
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `check` advice on the key and the prose round a drawing: a key that leaves a color or a line
|
|
3
|
+
* style unexplained, a `legend` swatch drawn in a shade that no node of its family uses, and
|
|
4
|
+
* heading prose that the drawing should say instead.
|
|
5
|
+
*/
|
|
6
|
+
import { type Shade } from '../model/appearance';
|
|
1
7
|
import type { Diagnostic } from './compile';
|
|
2
8
|
import type { Model } from './syntax';
|
|
3
9
|
export declare function legendNotes(m: Model): Diagnostic[];
|
|
10
|
+
/**
|
|
11
|
+
* The shade a `legend family` swatch draws when its line sets none: what the family's nodes draw.
|
|
12
|
+
* When no node names the family and its nodes are all member cards (they inherit it from a group
|
|
13
|
+
* on a quiet surface shade), that is the member card's shade; otherwise it is a colored node's.
|
|
14
|
+
*/
|
|
15
|
+
export declare function legendShade(m: Model, family: string): Shade;
|
|
16
|
+
/** Give each `legend family` line with no `shade=` the shade its family's nodes draw. */
|
|
17
|
+
export declare function settleLegendShades(m: Model): void;
|
|
@@ -210,11 +210,13 @@ export type Hint = {
|
|
|
210
210
|
line: number;
|
|
211
211
|
}
|
|
212
212
|
/** `height` is unset for `height=auto`: the title's height at that width, as without a size. */
|
|
213
|
+
/** `minHeight` is a floor under `height=auto`, for a host that draws more than the title. */
|
|
213
214
|
| {
|
|
214
215
|
type: 'size';
|
|
215
216
|
id: string;
|
|
216
217
|
width: number;
|
|
217
218
|
height?: number;
|
|
219
|
+
minHeight?: number;
|
|
218
220
|
line: number;
|
|
219
221
|
};
|
|
220
222
|
export type Strength = 'prefer' | 'required';
|
|
@@ -306,7 +308,7 @@ export declare const isIdentifier: (s: string) => boolean;
|
|
|
306
308
|
export declare const COLORS: DslColor[];
|
|
307
309
|
export declare const DSL_SHAPES: DslShape[];
|
|
308
310
|
/** Shapes a node's box can draw as it was: a marker's box is a thin cut, so it has no other shape. */
|
|
309
|
-
export declare const PAST_SHAPES: ("text" | "
|
|
311
|
+
export declare const PAST_SHAPES: ("text" | "box" | "pill" | "circle" | "diamond")[];
|
|
310
312
|
/** Parse and validate source. Throws `DslError` with a line number for the first problem. */
|
|
311
313
|
export declare function parseModel(source: string | SourceDoc): Model;
|
|
312
314
|
/**
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* It mounts when added to the page and stops its session when removed.
|
|
5
|
-
*/
|
|
6
|
-
import { type MountedEditor } from './mount';
|
|
1
|
+
import { type EditorOptions, type MountedEditor } from './mount';
|
|
2
|
+
export type { DraftEventMap, HostEventName, HostEvents } from '../runtime/host';
|
|
3
|
+
export type { EditorOptions };
|
|
7
4
|
export interface DraftEditorElement extends HTMLElement {
|
|
8
5
|
source: string;
|
|
6
|
+
/**
|
|
7
|
+
* Every `mountEditor` option except `source` and `onChange`. Callbacks apply live; a new
|
|
8
|
+
* `storageKey` mounts a new editor. A new object with the same values does nothing.
|
|
9
|
+
*/
|
|
10
|
+
options: EditorOptions;
|
|
9
11
|
readonly editor?: MountedEditor;
|
|
10
12
|
}
|
|
11
13
|
declare global {
|