@draftably/editor 0.3.0 → 0.5.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.
Files changed (43) hide show
  1. package/README.md +5 -3
  2. package/dist/assets/engine.worker-BDrPGHQt.js +7634 -0
  3. package/dist/element.js +182 -17
  4. package/dist/index.js +8827 -7969
  5. package/dist/types/src/components/canvas/Canvas.d.ts +4 -0
  6. package/dist/types/src/components/scene/NodeView.d.ts +7 -0
  7. package/dist/types/src/components/scene/parts.d.ts +7 -11
  8. package/dist/types/src/components/session-context.d.ts +7 -1
  9. package/dist/types/src/dsl/cells.d.ts +1 -0
  10. package/dist/types/src/dsl/compile.d.ts +2 -1
  11. package/dist/types/src/dsl/legend-notes.d.ts +14 -0
  12. package/dist/types/src/dsl/syntax.d.ts +3 -1
  13. package/dist/types/src/dsl/translate.d.ts +1 -1
  14. package/dist/types/src/editor/css.d.ts +3 -0
  15. package/dist/types/src/editor/element.d.ts +8 -6
  16. package/dist/types/src/editor/internal.d.ts +486 -0
  17. package/dist/types/src/editor/mount.d.ts +77 -5
  18. package/dist/types/src/graph-api/core.d.ts +125 -0
  19. package/dist/types/src/model/appearance.d.ts +27 -1
  20. package/dist/types/src/model/colors.d.ts +10 -2
  21. package/dist/types/src/model/labels.d.ts +22 -6
  22. package/dist/types/src/runtime/anchors.d.ts +46 -0
  23. package/dist/types/src/runtime/camera.d.ts +41 -0
  24. package/dist/types/src/runtime/color-scheme.d.ts +15 -0
  25. package/dist/types/src/runtime/element-base.d.ts +40 -0
  26. package/dist/types/src/runtime/geometry.d.ts +72 -0
  27. package/dist/types/src/runtime/host.d.ts +78 -0
  28. package/dist/types/src/runtime/page-shared.d.ts +24 -0
  29. package/dist/types/src/runtime/policy.d.ts +7 -0
  30. package/dist/types/src/runtime/render.d.ts +10 -0
  31. package/dist/types/src/runtime/schemes.d.ts +2 -0
  32. package/dist/types/src/runtime/svg-renderer.d.ts +12 -0
  33. package/dist/types/src/runtime/types.d.ts +122 -0
  34. package/dist/types/src/runtime/version.d.ts +2 -0
  35. package/dist/types/src/runtime/viewer.d.ts +123 -0
  36. package/dist/types/src/state/active-session.d.ts +10 -1
  37. package/dist/types/src/state/dom-root.d.ts +8 -0
  38. package/dist/types/src/state/session/document.d.ts +3 -1
  39. package/dist/types/src/state/session/editor.d.ts +3 -2
  40. package/dist/types/src/state/session/emphasis.d.ts +3 -0
  41. package/dist/types/src/state/session/index.d.ts +13 -1
  42. package/package.json +1 -1
  43. package/dist/assets/engine.worker-BY9GKt7x.js +0 -7505
@@ -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 { TypeProfile } from '../../model/fonts';
1
+ import type { ResolvedAppearance } from '../../model/appearance';
2
+ import type { NodeLabel } from '../../model/labels';
2
3
  import type { Rect } from '../../model/types';
3
- /** Multi-line, vertically centered text in one of the diagram's type profiles. */
4
- export declare function SceneText(props: {
5
- lines: string[];
6
- x: number;
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
- class?: string;
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;
@@ -273,6 +274,9 @@ export declare const useSessionIfAny: () => ({
273
274
  showState: (id: string | null) => void;
274
275
  stepState: (by: 1 | -1) => boolean;
275
276
  drawnDoc: () => import("../model/types").Diagram;
277
+ dark: import("solid-js").Accessor<boolean>;
278
+ setDark: import("solid-js").Setter<boolean>;
279
+ drawnAppearance: () => import("../model/appearance").DiagramAppearance;
276
280
  } & {
277
281
  tool: import("solid-js").Accessor<import("../state/session/editor").Tool>;
278
282
  setToolSignal: import("solid-js").Setter<import("../state/session/editor").Tool>;
@@ -482,5 +486,7 @@ export declare const useSessionIfAny: () => ({
482
486
  onDoubleClick: (e: MouseEvent) => void;
483
487
  selectForContextMenu: (e: MouseEvent) => void;
484
488
  dragKind: () => string | undefined;
489
+ } & {
490
+ describeLink: (href: string) => string;
485
491
  }) | undefined;
486
492
  export declare function useDiagramSession(): DiagramSession;
@@ -15,6 +15,7 @@ export interface CellInput {
15
15
  size?: {
16
16
  width: number;
17
17
  height?: number;
18
+ minHeight?: number;
18
19
  };
19
20
  }
20
21
  export interface CellBox {
@@ -99,11 +99,12 @@ export declare function layoutFor(m: Model, scope: string): ModelLayout;
99
99
  /**
100
100
  * Size of a node: its requested size, or the default width with a height that fits the title in
101
101
  * the theme's type and padding. A requested size is kept exactly; `overflow` reports a title that
102
- * no longer fits in it.
102
+ * no longer fits in it. With `height=auto`, `min-height` is a floor under the title's height.
103
103
  */
104
104
  export declare function leafSize(o: ModelObject, size: {
105
105
  width: number;
106
106
  height?: number;
107
+ minHeight?: number;
107
108
  } | undefined, look: ResolvedAppearance): {
108
109
  w: number;
109
110
  h: 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" | "diamond" | "circle" | "box" | "pill")[];
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
  /**
@@ -7,7 +7,7 @@
7
7
  * write snaps back when the source is reprojected, so nothing unsaved looks saved. Changes the
8
8
  * file cannot express are rejected outright.
9
9
  */
10
- import type { DiagramAppearance } from '../model/appearance';
10
+ import { type DiagramAppearance } from '../model/appearance';
11
11
  import type { Diagram } from '../model/types';
12
12
  import { type Scene } from './compile';
13
13
  import { type SourceDoc } from './syntax';
@@ -0,0 +1,3 @@
1
+ export declare function registerEditorCss(key: string, css: string): void;
2
+ /** Add the editor's styles to `root`, once. One constructable sheet per page, shared. */
3
+ export declare function adoptEditorCss(root: Document | ShadowRoot): void;
@@ -1,11 +1,13 @@
1
- /**
2
- * `<draft-editor>`: the editor as a custom element, for any framework or plain HTML. Its `source`
3
- * attribute or property sets the text; every kept edit fires `draft-change` with the new text.
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 {