@dou-ui/flow 0.1.0-alpha.0 → 0.1.0-alpha.10

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 (73) hide show
  1. package/dist/collaboration/index.js +76 -5
  2. package/dist/collaboration/index.js.map +1 -1
  3. package/dist/comments.js +245 -0
  4. package/dist/comments.js.map +1 -0
  5. package/dist/components/default-node2.js.map +1 -1
  6. package/dist/components/flow-comments.js +6 -0
  7. package/dist/components/flow-comments.js.map +1 -0
  8. package/dist/components/flow-comments.vue_vue_type_script_setup_true_lang.js +205 -0
  9. package/dist/components/flow-comments.vue_vue_type_script_setup_true_lang.js.map +1 -0
  10. package/dist/components/port.js +7 -0
  11. package/dist/components/port.js.map +1 -0
  12. package/dist/context.js.map +1 -1
  13. package/dist/core/edge-types.js +107 -3
  14. package/dist/core/edge-types.js.map +1 -1
  15. package/dist/core/extension.js.map +1 -1
  16. package/dist/core/history.js +26 -0
  17. package/dist/core/history.js.map +1 -1
  18. package/dist/core/model.js.map +1 -1
  19. package/dist/core/node-types.js +35 -1
  20. package/dist/core/node-types.js.map +1 -1
  21. package/dist/core/transaction.js +112 -15
  22. package/dist/core/transaction.js.map +1 -1
  23. package/dist/document.js +1 -1
  24. package/dist/export/render.js +78 -0
  25. package/dist/export/render.js.map +1 -0
  26. package/dist/flow-editor.js.map +1 -1
  27. package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js +454 -36
  28. package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js.map +1 -1
  29. package/dist/index.js +6 -6
  30. package/dist/index.js.map +1 -1
  31. package/dist/kit.js +1 -1
  32. package/dist/locale.js +24 -9
  33. package/dist/locale.js.map +1 -1
  34. package/dist/style.css +1 -1
  35. package/dist/style.js +2 -1
  36. package/dist/types/collaboration/index.d.ts +32 -4
  37. package/dist/types/comments.d.ts +73 -0
  38. package/dist/types/components/default-node.d.ts +1 -1
  39. package/dist/types/components/flow-comments.vue.d.ts +35 -0
  40. package/dist/types/components/port.d.ts +7 -0
  41. package/dist/types/context.d.ts +54 -1
  42. package/dist/types/core/extension.d.ts +2 -1
  43. package/dist/types/core/history.d.ts +10 -0
  44. package/dist/types/core/menu.d.ts +5 -0
  45. package/dist/types/core/model.d.ts +19 -0
  46. package/dist/types/core/node-types.d.ts +16 -2
  47. package/dist/types/core/transaction.d.ts +23 -1
  48. package/dist/types/export/render.d.ts +27 -0
  49. package/dist/types/flow-editor.vue.d.ts +11 -0
  50. package/dist/types/index.d.ts +36 -9
  51. package/dist/types/locale.d.ts +13 -3
  52. package/dist/types/whiteboard/image.d.ts +8 -0
  53. package/dist/types/whiteboard/index.d.ts +1 -1
  54. package/dist/types/whiteboard/kit.d.ts +7 -1
  55. package/dist/types/whiteboard/model.d.ts +2 -11
  56. package/dist/types/whiteboard/state.d.ts +5 -1
  57. package/dist/whiteboard/board-node.js.map +1 -1
  58. package/dist/whiteboard/board-node.vue_vue_type_script_setup_true_lang.js +3 -3
  59. package/dist/whiteboard/board-node.vue_vue_type_script_setup_true_lang.js.map +1 -1
  60. package/dist/whiteboard/connector.js +5 -10
  61. package/dist/whiteboard/connector.js.map +1 -1
  62. package/dist/whiteboard/image.js +17 -6
  63. package/dist/whiteboard/image.js.map +1 -1
  64. package/dist/whiteboard/kit.js +64 -8
  65. package/dist/whiteboard/kit.js.map +1 -1
  66. package/dist/whiteboard/model.js +4 -31
  67. package/dist/whiteboard/model.js.map +1 -1
  68. package/dist/whiteboard/state.js +6 -1
  69. package/dist/whiteboard/state.js.map +1 -1
  70. package/dist/whiteboard/whiteboard-toolbar.js.map +1 -1
  71. package/dist/whiteboard/whiteboard-toolbar.vue_vue_type_script_setup_true_lang.js +14 -7
  72. package/dist/whiteboard/whiteboard-toolbar.vue_vue_type_script_setup_true_lang.js.map +1 -1
  73. package/package.json +3 -3
@@ -0,0 +1,35 @@
1
+ import type { FlowComments } from '../comments';
2
+ import type { FlowCommentAnchor } from '../context';
3
+ import { type FlowMessages } from '../locale';
4
+ export interface FlowCommentMarker {
5
+ key: string;
6
+ anchor: FlowCommentAnchor;
7
+ /** The open threads there, oldest first, counted on the marker; empty for a thread being started. */
8
+ threads: string[];
9
+ /** The threads its card shows: the open ones, and a resolved one opened from outside. */
10
+ shown: string[];
11
+ /** A thread is being started here. */
12
+ pending: boolean;
13
+ /** Where it goes, in px within the editor. */
14
+ x: number;
15
+ y: number;
16
+ /** Above an edge's label: a finger's target keeps clear of the label. */
17
+ lifted: boolean;
18
+ /**
19
+ * A pin on a point of a node: its place among the open pins there, from
20
+ * 1; `0` for one being started or a resolved one opened from outside.
21
+ */
22
+ number?: number;
23
+ /** The name of the node it is on, for screen readers. */
24
+ node?: string;
25
+ }
26
+ type __VLS_Props = {
27
+ comments: FlowComments;
28
+ markers: FlowCommentMarker[];
29
+ messages: FlowMessages;
30
+ /** Gives the focus back to what a thread is about, after the card closes. */
31
+ restore: (anchor: FlowCommentAnchor | null) => void;
32
+ };
33
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
+ declare const _default: typeof __VLS_export;
35
+ export default _default;
@@ -0,0 +1,7 @@
1
+ export declare const DouFlowPort: import("dou-ui").WithInstall<import("vue").DefineComponent<{
2
+ id: string;
3
+ auto?: boolean;
4
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
5
+ id: string;
6
+ auto?: boolean;
7
+ }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, import("vue").HTMLAttributes>;
@@ -1,4 +1,4 @@
1
- import type { ContextMenuItem } from 'dou-ui';
1
+ import type { CommentAction, CommentAuthor, CommentThread, ContextMenuItem } from 'dou-ui';
2
2
  import type { FlowExportOptions, FlowImageOptions } from './export/draw';
3
3
  import type { FlowTree } from './core/groups';
4
4
  import { type ComputedRef, type InjectionKey, type Ref, type ShallowRef } from 'vue';
@@ -82,11 +82,43 @@ export interface FlowEditorProps {
82
82
  * sentence saying why. Called for every port while an edge is dragged.
83
83
  */
84
84
  canConnect?: (connection: FlowConnection, doc: FlowDocument) => boolean | string;
85
+ /**
86
+ * The hairline frame and rounded corners. Off, the canvas takes no
87
+ * border at all, for a panel or page region that already has an edge.
88
+ * On by default.
89
+ */
90
+ bordered?: boolean;
85
91
  /** Accessible name of the canvas. */
86
92
  ariaLabel?: string;
87
93
  /** Texts to change; only the ones given are replaced. */
88
94
  messages?: FlowMessagesOverride;
95
+ /**
96
+ * The comment threads, bound with `v-model:comments`. The node or edge a
97
+ * thread is about keeps the thread's id in its `comments`. Left out,
98
+ * there are no comments.
99
+ */
100
+ comments?: CommentThread[];
101
+ /** Who is commenting. Without it comments can be read but not written. */
102
+ author?: CommentAuthor;
103
+ /** The thread open now, bound with `v-model:activeComment`. */
104
+ activeComment?: string | null;
105
+ /** Threads can be started and replied to; also while `readonly`. On by default. */
106
+ commentable?: boolean;
89
107
  }
108
+ /**
109
+ * What a comment thread is about: a node, a point on a node, or an edge.
110
+ * `at` pins the thread to that point, as fractions of the node's width and
111
+ * height from its top left, 0 to 1 (not canvas px, unlike other `at`s).
112
+ * `number` is the pin's number on the node, as drawn: read from
113
+ * `getCommentAnchors`, left out when starting one.
114
+ */
115
+ export type FlowCommentAnchor = {
116
+ node: string;
117
+ at?: Point;
118
+ number?: number;
119
+ } | {
120
+ edge: string;
121
+ };
90
122
  export interface FlowEditorEmits {
91
123
  /** Every change to the document, with its steps; `update:modelValue` follows. */
92
124
  transaction: [tr: FlowTransaction];
@@ -95,6 +127,10 @@ export interface FlowEditorEmits {
95
127
  * says why, and the editor shows it and reads it out.
96
128
  */
97
129
  transactionCancel: [tr: FlowTransaction];
130
+ 'update:comments': [threads: CommentThread[]];
131
+ 'update:activeComment': [id: string | null];
132
+ /** A change to the comments made here: to send to a server, notify people, keep a log. */
133
+ commentAction: [action: CommentAction];
98
134
  nodeClick: [node: FlowNode, event: MouseEvent];
99
135
  nodeDblclick: [node: FlowNode, event: MouseEvent];
100
136
  nodeContextmenu: [node: FlowNode, event: MouseEvent];
@@ -165,6 +201,19 @@ export interface FlowEditorExpose {
165
201
  readonly staleEdges: string[];
166
202
  /** Removes the stale edges as one undo step; returns how many. */
167
203
  removeStaleEdges: () => number;
204
+ /**
205
+ * Opens the open thread on a node or edge (the selected one when left
206
+ * out), ready to reply, or starts one there; `false` when there is no such
207
+ * node or edge, or nothing to open and comments can't be written. With
208
+ * `at`, it always starts a new thread pinned to that point of the node.
209
+ * `focus: false` leaves the focus where it is instead of putting it in the
210
+ * reply box, for a tap that shouldn't bring up a phone's keyboard.
211
+ */
212
+ comment: (anchor?: FlowCommentAnchor, options?: {
213
+ focus?: boolean;
214
+ }) => boolean;
215
+ /** What each thread is about; `null` when its node or edge is gone. Not reactive. */
216
+ getCommentAnchors: () => Record<string, FlowCommentAnchor | null>;
168
217
  /**
169
218
  * Adds a node of a type with its defaults and selects it, as one undo
170
219
  * step; returns its id. See `FlowInsertOptions` for where it goes.
@@ -271,6 +320,10 @@ export interface FlowEditorContext {
271
320
  /** A port type's color as CSS. */
272
321
  colorOf: (spec: PortTypeSpec | undefined) => string | undefined;
273
322
  getNodeRect: FlowEditorExpose['getNodeRect'];
323
+ /** See `FlowEditorExpose.comment`. */
324
+ comment: FlowEditorExpose['comment'];
325
+ /** Comment threads can be started: the editor has `comments`, an `author` and is `commentable`. */
326
+ canComment: ComputedRef<boolean>;
274
327
  exportSVG: FlowEditorExpose['exportSVG'];
275
328
  exportPNG: FlowEditorExpose['exportPNG'];
276
329
  tidy: FlowEditorExpose['tidy'];
@@ -98,7 +98,8 @@ export interface FlowExtension {
98
98
  /**
99
99
  * Asked first when the canvas or a node is pressed with the main button or
100
100
  * one finger, in priority order. Return handlers to take the press over;
101
- * the editor then doesn't select, drag or pan for it.
101
+ * the editor then doesn't select, drag or pan for it. Asked while
102
+ * read-only too: check `context.readonly` before changing the document.
102
103
  */
103
104
  press?: (context: FlowExtensionContext, press: FlowPress) => FlowPressHandler | void;
104
105
  /** Runs once the editor is mounted. Return a function to run when it unmounts. */
@@ -20,5 +20,15 @@ export declare class FlowHistory {
20
20
  tr: FlowTransaction;
21
21
  selection: FlowSelection;
22
22
  } | null;
23
+ /**
24
+ * Gives a change kept out of undo to a node or edge as undo and redo
25
+ * bring it back, too: comments started on a new node stay on it when its
26
+ * adding is undone and redone.
27
+ */
28
+ carry(target: {
29
+ node: string;
30
+ } | {
31
+ edge: string;
32
+ }, patch: Record<string, unknown>): void;
23
33
  clear(): void;
24
34
  }
@@ -37,4 +37,9 @@ export interface FlowToolbarItem {
37
37
  * click. Give the items `checked` to mark the one in use.
38
38
  */
39
39
  children?: ContextMenuItem[];
40
+ /**
41
+ * Shown while the editor is `readonly` too, for what doesn't change the
42
+ * flow, such as commenting; the other buttons are left out then.
43
+ */
44
+ showWhenReadonly?: boolean;
40
45
  }
@@ -21,6 +21,17 @@ export interface FlowNode<Data extends FlowData = FlowData> {
21
21
  * top. Nodes without it count as `0`; equal ones keep the document order.
22
22
  */
23
23
  z?: number;
24
+ /**
25
+ * The ids of the comment threads about this node, see the editor's
26
+ * `comments`. Kept when the node is deleted and brought back by undo.
27
+ */
28
+ comments?: string[];
29
+ /**
30
+ * Where on the node each pinned thread is, by thread id: `x` and `y` are
31
+ * fractions of the node's width and height from its top left, 0 to 1, so
32
+ * a pin moves and scales with the node. The ids are in `comments` too.
33
+ */
34
+ commentPins?: Record<string, Point>;
24
35
  }
25
36
  export interface FlowEndpoint {
26
37
  node: string;
@@ -37,7 +48,15 @@ export interface FlowEdge<Data extends FlowData = FlowData> {
37
48
  label?: string;
38
49
  /** Dashes run along the edge in its direction, e.g. while data flows through it. */
39
50
  animated?: boolean;
51
+ /**
52
+ * Points on the canvas the edge runs through on its way, in order. Tidying
53
+ * sets them on an edge that spans several ranks, so it passes between
54
+ * the nodes in its way; moving either end clears them.
55
+ */
56
+ points?: Point[];
40
57
  data?: Data;
58
+ /** The ids of the comment threads about this edge, see the editor's `comments`. */
59
+ comments?: string[];
41
60
  }
42
61
  export interface FlowDocument {
43
62
  /** The version of the format; see `migrateDocument`. */
@@ -20,8 +20,13 @@ export interface NodeTypeSpec<Data extends FlowData = FlowData> {
20
20
  * component does not place are spread along their sides.
21
21
  */
22
22
  component?: Component;
23
- /** The node's ports, fixed or worked out from its data. */
24
- ports?: FlowPortSpec[] | ((node: FlowNode<Data>) => FlowPortSpec[]);
23
+ /**
24
+ * The node's ports, fixed or worked out from its data. `'sides'`: an
25
+ * output and an input in the middle of each side, all alike (see
26
+ * `sidePorts`); tidying lays such nodes out the way their edges are
27
+ * drawn and moves the edges' ends onto the sides that face each other.
28
+ */
29
+ ports?: FlowPortSpec[] | 'sides' | ((node: FlowNode<Data>) => FlowPortSpec[]);
25
30
  /** Data for a new node of this type. */
26
31
  defaults?: () => Data;
27
32
  /**
@@ -88,6 +93,13 @@ export interface NodePaletteSpec {
88
93
  /** Declares a node type, with the data type checked against its component. */
89
94
  export declare function defineNodeType<Data extends FlowData = FlowData>(spec: NodeTypeSpec<Data>): NodeTypeSpec<Data>;
90
95
  export declare const portSide: (port: FlowPortSpec) => PortSide;
96
+ /**
97
+ * The ports of `ports: 'sides'`: an output and an input in the middle of
98
+ * each side. Edges go from an output (`right`) to an input (`left-in`).
99
+ * `right` and `left-in` come first, so a node added after another joins it
100
+ * left to right.
101
+ */
102
+ export declare const sidePorts: readonly FlowPortSpec[];
91
103
  export declare function portsOf(spec: NodeTypeSpec | undefined, node: FlowNode): FlowPortSpec[];
92
104
  export type NodeResize = boolean | {
93
105
  minWidth?: number;
@@ -101,3 +113,5 @@ export declare function resizeOf(spec: NodeTypeSpec | undefined, node: FlowNode)
101
113
  export declare function labelOf(spec: NodeTypeSpec | undefined, node: FlowNode, messages: FlowMessages): string;
102
114
  /** The box `node` covers on screen, drawn at `rect`. */
103
115
  export declare function nodeBounds(spec: NodeTypeSpec, node: FlowNode, rect: Rect): Rect;
116
+ /** Warns once per page about a node type no one registered. Call only while developing. */
117
+ export declare function warnUnknownNodeType(type: string): void;
@@ -59,24 +59,46 @@ export declare class FlowTransaction {
59
59
  * editor fires `transactionCancel` and says why. For an extension's `transaction`
60
60
  * hook, e.g. to keep people from changing what they may not; hooks after
61
61
  * it don't run. A change kept out of the history (`meta.history: false`),
62
- * such as undo, redo or another person's, can't be cancelled and goes ahead.
62
+ * such as undo, redo, another person's or a comment's (`meta.origin`
63
+ * tells which), can't be cancelled and goes ahead.
63
64
  */
64
65
  cancel(reason?: string): this;
65
66
  /** Whether `cancel` stopped it. */
66
67
  get cancelled(): boolean;
67
68
  /** What `cancel` was given, to tell people why. */
68
69
  get cancelReason(): string | undefined;
70
+ private index;
71
+ private incident?;
72
+ private was?;
73
+ private nodeIndex;
74
+ private edgeIndex;
75
+ /** The document as it was before this transaction. */
76
+ private get original();
69
77
  getNode(id: string): FlowNode<import("./model").FlowData> | undefined;
70
78
  getEdge(id: string): FlowEdge<import("./model").FlowData> | undefined;
71
79
  /** Edges that start or end at a node. */
72
80
  edgesOf(id: string): FlowEdge<import("./model").FlowData>[];
81
+ private attach;
82
+ private detach;
83
+ /** Renumbers an index from `from` on, after an insert or removal there. */
84
+ private reindex;
73
85
  setMeta(meta: FlowTransactionMeta): this;
74
86
  step(step: FlowStep): this;
75
87
  addNode(node: FlowNode, index?: number): this;
76
88
  /** Removes a node and every edge attached to it. */
77
89
  removeNode(id: string): this;
90
+ /**
91
+ * Changes a node. Moving it moves the points of an edge at it along when
92
+ * the edge's other end has moved just as far in this transaction, and
93
+ * drops them otherwise, as they no longer fit; so does resizing it, as
94
+ * its ports move.
95
+ */
78
96
  updateNode(id: string, patch: Patch<FlowNode>): this;
79
97
  moveNode(id: string, x: number, y: number): this;
98
+ /** Moves the points of the edges at a moved node along, or drops them. */
99
+ private carryPoints;
100
+ /** How far a node has moved in this transaction so far. */
101
+ private shiftOf;
80
102
  /** Merges `patch` into the node's `data`. */
81
103
  updateData(id: string, patch: Record<string, unknown>): this;
82
104
  addEdge(edge: FlowEdge, index?: number): this;
@@ -0,0 +1,27 @@
1
+ import { type ResolvedColorMode } from 'dou-ui';
2
+ import { type AppContext } from 'vue';
3
+ import type { FlowEditorProps } from '../context';
4
+ import type { FlowDocument } from '../core/model';
5
+ import type { FlowExportOptions } from './draw';
6
+ export interface RenderFlowOptions extends Pick<FlowEditorProps, 'extensions' | 'nodeTypes' | 'edgeTypes' | 'edgeType' | 'portTypes' | 'direction' | 'messages'>, Omit<FlowExportOptions, 'range'> {
7
+ /** Light or dark colors; the page's own color mode by default. */
8
+ colorMode?: ResolvedColorMode;
9
+ /**
10
+ * The app context node components render in, for its locale, plugins and
11
+ * provides, e.g. `getCurrentInstance()!.appContext`. Defaults to the app
12
+ * `app.use(DouUI)` was called on.
13
+ */
14
+ appContext?: AppContext | null;
15
+ }
16
+ export interface RenderFlowImageOptions extends RenderFlowOptions {
17
+ /** Pixels per CSS pixel. Defaults to `2`. */
18
+ pixelRatio?: number;
19
+ }
20
+ /**
21
+ * The document as an SVG document, drawn as `exportSVG` draws it, without an
22
+ * editor on the page: for thumbnails and previews. Give it the same node,
23
+ * edge and port types as the editor that shows the document.
24
+ */
25
+ export declare function renderFlowSVG(document: FlowDocument, options?: RenderFlowOptions): Promise<string>;
26
+ /** The document as a PNG image, as `exportPNG` draws it, without an editor on the page. */
27
+ export declare function renderFlowPNG(document: FlowDocument, options?: RenderFlowImageOptions): Promise<Blob>;
@@ -12,6 +12,9 @@ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
12
12
  declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, FlowEditorExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
13
  transaction: (tr: FlowTransaction) => any;
14
14
  transactionCancel: (tr: FlowTransaction) => any;
15
+ "update:comments": (threads: import("dou-ui").CommentThread[]) => any;
16
+ "update:activeComment": (id: string | null) => any;
17
+ commentAction: (action: import("dou-ui").CommentAction) => any;
15
18
  nodeClick: (node: FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any;
16
19
  nodeDblclick: (node: FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any;
17
20
  nodeContextmenu: (node: FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any;
@@ -27,6 +30,9 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, FlowE
27
30
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
28
31
  onTransaction?: ((tr: FlowTransaction) => any) | undefined;
29
32
  onTransactionCancel?: ((tr: FlowTransaction) => any) | undefined;
33
+ "onUpdate:comments"?: ((threads: import("dou-ui").CommentThread[]) => any) | undefined;
34
+ "onUpdate:activeComment"?: ((id: string | null) => any) | undefined;
35
+ onCommentAction?: ((action: import("dou-ui").CommentAction) => any) | undefined;
30
36
  onNodeClick?: ((node: FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
31
37
  onNodeDblclick?: ((node: FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
32
38
  onNodeContextmenu?: ((node: FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
@@ -40,10 +46,12 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, FlowE
40
46
  "onUpdate:selection"?: ((value: FlowSelection) => any) | undefined;
41
47
  "onUpdate:viewport"?: ((value: FlowViewport) => any) | undefined;
42
48
  }>, {
49
+ comments: import("dou-ui").CommentThread[];
43
50
  direction: "horizontal" | "vertical";
44
51
  grid: number;
45
52
  edgeType: string;
46
53
  readonly: boolean;
54
+ author: import("dou-ui").CommentAuthor;
47
55
  simpleZoom: number;
48
56
  guides: boolean;
49
57
  minZoom: number;
@@ -52,6 +60,9 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, FlowE
52
60
  fitMinZoom: number;
53
61
  searchable: boolean;
54
62
  panOnScroll: boolean;
63
+ bordered: boolean;
64
+ activeComment: string | null;
65
+ commentable: boolean;
55
66
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
56
67
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
57
68
  declare const _default: typeof __VLS_export;
@@ -1,3 +1,4 @@
1
+ import { DouFlowPort } from './components/port';
1
2
  export declare const DouFlowEditor: import("dou-ui").WithInstall<{
2
3
  new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("./context").FlowEditorProps & {
3
4
  modelValue?: import("./index.js").FlowDocument;
@@ -6,6 +7,9 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
6
7
  }> & Readonly<{
7
8
  onTransaction?: ((tr: import("./index.js").FlowTransaction) => any) | undefined;
8
9
  onTransactionCancel?: ((tr: import("./index.js").FlowTransaction) => any) | undefined;
10
+ "onUpdate:comments"?: ((threads: import("dou-ui").CommentThread[]) => any) | undefined;
11
+ "onUpdate:activeComment"?: ((id: string | null) => any) | undefined;
12
+ onCommentAction?: ((action: import("dou-ui").CommentAction) => any) | undefined;
9
13
  onNodeClick?: ((node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
10
14
  onNodeDblclick?: ((node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
11
15
  onNodeContextmenu?: ((node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
@@ -21,6 +25,9 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
21
25
  }>, import("./context").FlowEditorExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
22
26
  transaction: (tr: import("./index.js").FlowTransaction) => any;
23
27
  transactionCancel: (tr: import("./index.js").FlowTransaction) => any;
28
+ "update:comments": (threads: import("dou-ui").CommentThread[]) => any;
29
+ "update:activeComment": (id: string | null) => any;
30
+ commentAction: (action: import("dou-ui").CommentAction) => any;
24
31
  nodeClick: (node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any;
25
32
  nodeDblclick: (node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any;
26
33
  nodeContextmenu: (node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any;
@@ -34,10 +41,12 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
34
41
  "update:selection": (value: import("./index.js").FlowSelection) => any;
35
42
  "update:viewport": (value: import("./index.js").FlowViewport) => any;
36
43
  }, import("vue").PublicProps, {
44
+ comments: import("dou-ui").CommentThread[];
37
45
  direction: "horizontal" | "vertical";
38
46
  grid: number;
39
47
  edgeType: string;
40
48
  readonly: boolean;
49
+ author: import("dou-ui").CommentAuthor;
41
50
  simpleZoom: number;
42
51
  guides: boolean;
43
52
  minZoom: number;
@@ -46,6 +55,9 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
46
55
  fitMinZoom: number;
47
56
  searchable: boolean;
48
57
  panOnScroll: boolean;
58
+ bordered: boolean;
59
+ activeComment: string | null;
60
+ commentable: boolean;
49
61
  }, false, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
50
62
  P: {};
51
63
  B: {};
@@ -60,6 +72,9 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
60
72
  }> & Readonly<{
61
73
  onTransaction?: ((tr: import("./index.js").FlowTransaction) => any) | undefined;
62
74
  onTransactionCancel?: ((tr: import("./index.js").FlowTransaction) => any) | undefined;
75
+ "onUpdate:comments"?: ((threads: import("dou-ui").CommentThread[]) => any) | undefined;
76
+ "onUpdate:activeComment"?: ((id: string | null) => any) | undefined;
77
+ onCommentAction?: ((action: import("dou-ui").CommentAction) => any) | undefined;
63
78
  onNodeClick?: ((node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
64
79
  onNodeDblclick?: ((node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
65
80
  onNodeContextmenu?: ((node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
@@ -73,10 +88,12 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
73
88
  "onUpdate:selection"?: ((value: import("./index.js").FlowSelection) => any) | undefined;
74
89
  "onUpdate:viewport"?: ((value: import("./index.js").FlowViewport) => any) | undefined;
75
90
  }>, import("./context").FlowEditorExpose, {}, {}, {}, {
91
+ comments: import("dou-ui").CommentThread[];
76
92
  direction: "horizontal" | "vertical";
77
93
  grid: number;
78
94
  edgeType: string;
79
95
  readonly: boolean;
96
+ author: import("dou-ui").CommentAuthor;
80
97
  simpleZoom: number;
81
98
  guides: boolean;
82
99
  minZoom: number;
@@ -85,6 +102,9 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
85
102
  fitMinZoom: number;
86
103
  searchable: boolean;
87
104
  panOnScroll: boolean;
105
+ bordered: boolean;
106
+ activeComment: string | null;
107
+ commentable: boolean;
88
108
  }>;
89
109
  __isFragment?: never;
90
110
  __isTeleport?: never;
@@ -96,6 +116,9 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
96
116
  }> & Readonly<{
97
117
  onTransaction?: ((tr: import("./index.js").FlowTransaction) => any) | undefined;
98
118
  onTransactionCancel?: ((tr: import("./index.js").FlowTransaction) => any) | undefined;
119
+ "onUpdate:comments"?: ((threads: import("dou-ui").CommentThread[]) => any) | undefined;
120
+ "onUpdate:activeComment"?: ((id: string | null) => any) | undefined;
121
+ onCommentAction?: ((action: import("dou-ui").CommentAction) => any) | undefined;
99
122
  onNodeClick?: ((node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
100
123
  onNodeDblclick?: ((node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
101
124
  onNodeContextmenu?: ((node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
@@ -111,6 +134,9 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
111
134
  }>, import("./context").FlowEditorExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
112
135
  transaction: (tr: import("./index.js").FlowTransaction) => any;
113
136
  transactionCancel: (tr: import("./index.js").FlowTransaction) => any;
137
+ "update:comments": (threads: import("dou-ui").CommentThread[]) => any;
138
+ "update:activeComment": (id: string | null) => any;
139
+ commentAction: (action: import("dou-ui").CommentAction) => any;
114
140
  nodeClick: (node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any;
115
141
  nodeDblclick: (node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any;
116
142
  nodeContextmenu: (node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any;
@@ -124,10 +150,12 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
124
150
  "update:selection": (value: import("./index.js").FlowSelection) => any;
125
151
  "update:viewport": (value: import("./index.js").FlowViewport) => any;
126
152
  }, string, {
153
+ comments: import("dou-ui").CommentThread[];
127
154
  direction: "horizontal" | "vertical";
128
155
  grid: number;
129
156
  edgeType: string;
130
157
  readonly: boolean;
158
+ author: import("dou-ui").CommentAuthor;
131
159
  simpleZoom: number;
132
160
  guides: boolean;
133
161
  minZoom: number;
@@ -136,6 +164,9 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
136
164
  fitMinZoom: number;
137
165
  searchable: boolean;
138
166
  panOnScroll: boolean;
167
+ bordered: boolean;
168
+ activeComment: string | null;
169
+ commentable: boolean;
139
170
  }, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
140
171
  $slots: import("./context").FlowEditorSlots;
141
172
  }), import("vue").HTMLAttributes>;
@@ -149,16 +180,10 @@ export declare const DouFlowMinimap: import("dou-ui").WithInstall<import("vue").
149
180
  height: number;
150
181
  placement: import("./context").FlowPanelPlacement;
151
182
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, import("vue").HTMLAttributes>;
152
- export declare const DouFlowPort: import("dou-ui").WithInstall<import("vue").DefineComponent<{
153
- id: string;
154
- auto?: boolean;
155
- }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
156
- id: string;
157
- auto?: boolean;
158
- }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, import("vue").HTMLAttributes>;
183
+ export { DouFlowPort };
159
184
  export default DouFlowEditor;
160
185
  export { useFlowEditor } from './context';
161
- export type { FlowControlsProps, FlowEditorContext, FlowEditorEmits, FlowEditorExpose, FlowEditorProps, FlowInsertOptions, FlowMinimapProps, FlowNodePreview, FlowEditorSlots, FlowPanelPlacement, FlowSearchQuery, NodeMetrics, PortAnchor, PortState, } from './context';
186
+ export type { FlowCommentAnchor, FlowControlsProps, FlowEditorContext, FlowEditorEmits, FlowEditorExpose, FlowEditorProps, FlowInsertOptions, FlowMinimapProps, FlowNodePreview, FlowEditorSlots, FlowPanelPlacement, FlowSearchQuery, NodeMetrics, PortAnchor, PortState, } from './context';
162
187
  export { flowLocales, useFlowMessages } from './locale';
163
188
  export type { FlowMessages, FlowMessagesOverride } from './locale';
164
189
  export { defaultNode } from './components/default-node';
@@ -166,7 +191,7 @@ export type { DefaultNodeData } from './components/default-node';
166
191
  export { groupNode } from './components/group-node';
167
192
  export type { GroupNodeData } from './components/group-node';
168
193
  export { containerAt, FlowTree } from './core/groups';
169
- export { defineNodeType, labelOf, portSide, portsOf, resizeOf } from './core/node-types';
194
+ export { defineNodeType, labelOf, portSide, portsOf, resizeOf, sidePorts } from './core/node-types';
170
195
  export type { NodePaletteSpec, NodeResize, NodeTypeSpec, NodeViewProps } from './core/node-types';
171
196
  export type { FlowMenuTarget, FlowToolbarItem } from './core/menu';
172
197
  export { createId, emptyDocument, emptySelection } from './core/model';
@@ -182,6 +207,8 @@ export { flowKit } from './kit';
182
207
  export type { FlowKitOptions } from './kit';
183
208
  export { moveLayer } from './layers';
184
209
  export { drawCard } from './export/draw';
210
+ export { renderFlowPNG, renderFlowSVG } from './export/render';
211
+ export type { RenderFlowImageOptions, RenderFlowOptions } from './export/render';
185
212
  export type { FlowExportOptions, FlowImageOptions } from './export/draw';
186
213
  export type { FlowDrawContext, FlowDrawTextOptions } from './export/context';
187
214
  export type { LayerMove } from './layers';
@@ -98,6 +98,12 @@ export interface FlowMessages {
98
98
  noTarget: string;
99
99
  /** `{count}` edges no longer fit their ports. */
100
100
  stale: string;
101
+ /** Starts a discussion about a node or an edge. */
102
+ comment: string;
103
+ /** The marker of the discussions on a node or an edge; `{count}` of them are open. */
104
+ comments: string;
105
+ /** A thread pinned to a point on a node; `{number}` is its number there, `{node}` the node's name. */
106
+ commentPin: string;
101
107
  /** Why an edge was refused, announced when it is dropped. */
102
108
  refused: {
103
109
  direction: string;
@@ -108,9 +114,9 @@ export interface FlowMessages {
108
114
  custom: string;
109
115
  };
110
116
  status: {
111
- wait: string;
112
- process: string;
113
- finish: string;
117
+ pending: string;
118
+ running: string;
119
+ done: string;
114
120
  error: string;
115
121
  };
116
122
  /** The whiteboard's toolbar and nodes. */
@@ -131,12 +137,16 @@ export interface FlowMessages {
131
137
  named: string;
132
138
  pen: string;
133
139
  eraser: string;
140
+ /** The tool that pins a comment where a node is clicked. */
141
+ comment: string;
134
142
  /** The toolbar button that inserts an image. */
135
143
  image: string;
136
144
  /** A pen stroke. */
137
145
  ink: string;
138
146
  /** `{name}` is the file's name. */
139
147
  imageFailed: string;
148
+ /** `{count}` images in one drop or pick could not be added. */
149
+ imagesFailed: string;
140
150
  /** `{count}` strokes were erased. */
141
151
  erased: string;
142
152
  rotate: string;
@@ -11,11 +11,19 @@ export type WhiteboardUploaded = string | {
11
11
  src: string;
12
12
  alt?: string;
13
13
  };
14
+ /**
15
+ * Called for each image whose upload threw or rejected, with the file and
16
+ * what it threw. Giving it replaces the built-in error toast, and the app
17
+ * then tells the user, screen readers included, in its own way.
18
+ */
19
+ export type WhiteboardUploadErrorHandler = (file: File, error: unknown) => void;
14
20
  export interface WhiteboardImageOptions {
15
21
  /** Where the images go, in canvas units; the middle of the view by default. */
16
22
  at?: Point;
17
23
  /** Overrides the kit's `upload` option for these images. */
18
24
  upload?: WhiteboardUpload;
25
+ /** Overrides the kit's `onUploadError` option for these images. */
26
+ onUploadError?: WhiteboardUploadErrorHandler;
19
27
  }
20
28
  export declare const imageFiles: (files: Iterable<File> | null | undefined) => File[];
21
29
  /**
@@ -2,5 +2,5 @@ export { connectorEdge, imageNode, inkNode, shapeNode, stickyNode, textNode, whi
2
2
  export { imageKey, whiteboardKeys } from './model';
3
3
  export { insertImages, pickImages } from './image';
4
4
  export type { WhiteboardKitOptions } from './kit';
5
- export type { WhiteboardImageOptions, WhiteboardUpload, WhiteboardUploaded } from './image';
5
+ export type { WhiteboardImageOptions, WhiteboardUpload, WhiteboardUploaded, WhiteboardUploadErrorHandler, } from './image';
6
6
  export type { WhiteboardImageData, WhiteboardInkData, WhiteboardNodeData, WhiteboardShape, WhiteboardShapeData, WhiteboardShapeTool, WhiteboardStickyData, WhiteboardTextData, WhiteboardTool, WhiteboardArrow, WhiteboardConnectorData, WhiteboardDash, WhiteboardRoute, } from './model';
@@ -1,7 +1,7 @@
1
1
  import { type Ref } from 'vue';
2
2
  import { type FlowExtension } from '../core/extension';
3
3
  import { type WhiteboardImageData, type WhiteboardInkData, type WhiteboardShapeData, type WhiteboardStickyData, type WhiteboardTextData, type WhiteboardTool } from './model';
4
- import { type WhiteboardUpload } from './image';
4
+ import { type WhiteboardUpload, type WhiteboardUploadErrorHandler } from './image';
5
5
  import { connectorEdge } from './connector';
6
6
  /** A rectangle, ellipse or diamond with centred text; `data.shape` says which. */
7
7
  export declare const shapeNode: import("..").NodeTypeSpec<WhiteboardShapeData>;
@@ -27,6 +27,12 @@ export interface WhiteboardKitOptions {
27
27
  * images are kept in the document as data URLs.
28
28
  */
29
29
  upload?: WhiteboardUpload;
30
+ /**
31
+ * Called for each image whose `upload` failed, with the file and the
32
+ * error; the app then tells the user, screen readers included. Without
33
+ * it, a danger toast at the bottom says which images were not added.
34
+ */
35
+ onUploadError?: WhiteboardUploadErrorHandler;
30
36
  }
31
37
  /**
32
38
  * The whiteboard: shape, sticky note and text nodes, the `connector` edge,
@@ -1,9 +1,8 @@
1
1
  import type { Tone } from 'dou-ui';
2
- import type { FlowPortSpec } from '../core/model';
3
2
  /** What a press on the board does. */
4
- export type WhiteboardTool = 'select' | 'hand' | 'rect' | 'ellipse' | 'diamond' | 'sticky' | 'text' | 'pen' | 'eraser';
3
+ export type WhiteboardTool = 'select' | 'hand' | 'rect' | 'ellipse' | 'diamond' | 'sticky' | 'text' | 'pen' | 'eraser' | 'comment';
5
4
  /** The tools that put down a node with a box. */
6
- export type WhiteboardShapeTool = Exclude<WhiteboardTool, 'select' | 'hand' | 'pen' | 'eraser'>;
5
+ export type WhiteboardShapeTool = Exclude<WhiteboardTool, 'select' | 'hand' | 'pen' | 'eraser' | 'comment'>;
7
6
  export type WhiteboardShape = 'rect' | 'ellipse' | 'diamond';
8
7
  /** What every board node can carry. */
9
8
  export interface WhiteboardNodeData {
@@ -68,12 +67,4 @@ export interface WhiteboardImageData extends WhiteboardNodeData {
68
67
  export declare const whiteboardKeys: Record<WhiteboardTool, string>;
69
68
  /** The key that inserts an image. */
70
69
  export declare const imageKey = "i";
71
- /**
72
- * Four anchors, one on each side. Each is an output and an input at the
73
- * same spot, so a connector can start and end on any of them. Edges in
74
- * data go from an output (`right`) to an input (`left-in`). The order puts
75
- * `right` and `left-in` first, so a node added after another joins it left
76
- * to right.
77
- */
78
- export declare const anchorPorts: FlowPortSpec[];
79
70
  export declare const anchorSides: readonly ["top", "right", "bottom", "left"];