@dou-ui/flow 0.1.0-alpha.3 → 0.1.0-alpha.5

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 (42) hide show
  1. package/dist/comments.js +177 -0
  2. package/dist/comments.js.map +1 -0
  3. package/dist/components/flow-comments.js +6 -0
  4. package/dist/components/flow-comments.js.map +1 -0
  5. package/dist/components/flow-comments.vue_vue_type_script_setup_true_lang.js +184 -0
  6. package/dist/components/flow-comments.vue_vue_type_script_setup_true_lang.js.map +1 -0
  7. package/dist/context.js.map +1 -1
  8. package/dist/core/history.js +26 -0
  9. package/dist/core/history.js.map +1 -1
  10. package/dist/core/model.js.map +1 -1
  11. package/dist/core/node-types.js +8 -1
  12. package/dist/core/node-types.js.map +1 -1
  13. package/dist/core/transaction.js +5 -4
  14. package/dist/core/transaction.js.map +1 -1
  15. package/dist/document.js +1 -1
  16. package/dist/export/render.js +78 -0
  17. package/dist/export/render.js.map +1 -0
  18. package/dist/flow-editor.js.map +1 -1
  19. package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js +220 -15
  20. package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js.map +1 -1
  21. package/dist/index.js +4 -3
  22. package/dist/index.js.map +1 -1
  23. package/dist/kit.js +1 -1
  24. package/dist/locale.js +6 -0
  25. package/dist/locale.js.map +1 -1
  26. package/dist/style.css +1 -1
  27. package/dist/style.js +1 -1
  28. package/dist/types/comments.d.ts +55 -0
  29. package/dist/types/components/flow-comments.vue.d.ts +28 -0
  30. package/dist/types/context.d.ts +31 -1
  31. package/dist/types/core/history.d.ts +10 -0
  32. package/dist/types/core/menu.d.ts +5 -0
  33. package/dist/types/core/model.d.ts +7 -0
  34. package/dist/types/core/node-types.d.ts +2 -0
  35. package/dist/types/core/transaction.d.ts +2 -1
  36. package/dist/types/export/render.d.ts +27 -0
  37. package/dist/types/flow-editor.vue.d.ts +10 -0
  38. package/dist/types/index.d.ts +30 -1
  39. package/dist/types/locale.d.ts +4 -0
  40. package/dist/whiteboard/connector.js +1 -1
  41. package/dist/whiteboard/kit.js +1 -1
  42. package/package.json +3 -3
@@ -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;
@@ -53,6 +61,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, FlowE
53
61
  searchable: boolean;
54
62
  panOnScroll: boolean;
55
63
  bordered: boolean;
64
+ activeComment: string | null;
65
+ commentable: boolean;
56
66
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
57
67
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
58
68
  declare const _default: typeof __VLS_export;
@@ -7,6 +7,9 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
7
7
  }> & Readonly<{
8
8
  onTransaction?: ((tr: import("./index.js").FlowTransaction) => any) | undefined;
9
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;
10
13
  onNodeClick?: ((node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
11
14
  onNodeDblclick?: ((node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
12
15
  onNodeContextmenu?: ((node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
@@ -22,6 +25,9 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
22
25
  }>, import("./context").FlowEditorExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
23
26
  transaction: (tr: import("./index.js").FlowTransaction) => any;
24
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;
25
31
  nodeClick: (node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any;
26
32
  nodeDblclick: (node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any;
27
33
  nodeContextmenu: (node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any;
@@ -35,10 +41,12 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
35
41
  "update:selection": (value: import("./index.js").FlowSelection) => any;
36
42
  "update:viewport": (value: import("./index.js").FlowViewport) => any;
37
43
  }, import("vue").PublicProps, {
44
+ comments: import("dou-ui").CommentThread[];
38
45
  direction: "horizontal" | "vertical";
39
46
  grid: number;
40
47
  edgeType: string;
41
48
  readonly: boolean;
49
+ author: import("dou-ui").CommentAuthor;
42
50
  simpleZoom: number;
43
51
  guides: boolean;
44
52
  minZoom: number;
@@ -48,6 +56,8 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
48
56
  searchable: boolean;
49
57
  panOnScroll: boolean;
50
58
  bordered: boolean;
59
+ activeComment: string | null;
60
+ commentable: boolean;
51
61
  }, false, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
52
62
  P: {};
53
63
  B: {};
@@ -62,6 +72,9 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
62
72
  }> & Readonly<{
63
73
  onTransaction?: ((tr: import("./index.js").FlowTransaction) => any) | undefined;
64
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;
65
78
  onNodeClick?: ((node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
66
79
  onNodeDblclick?: ((node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
67
80
  onNodeContextmenu?: ((node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
@@ -75,10 +88,12 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
75
88
  "onUpdate:selection"?: ((value: import("./index.js").FlowSelection) => any) | undefined;
76
89
  "onUpdate:viewport"?: ((value: import("./index.js").FlowViewport) => any) | undefined;
77
90
  }>, import("./context").FlowEditorExpose, {}, {}, {}, {
91
+ comments: import("dou-ui").CommentThread[];
78
92
  direction: "horizontal" | "vertical";
79
93
  grid: number;
80
94
  edgeType: string;
81
95
  readonly: boolean;
96
+ author: import("dou-ui").CommentAuthor;
82
97
  simpleZoom: number;
83
98
  guides: boolean;
84
99
  minZoom: number;
@@ -88,6 +103,8 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
88
103
  searchable: boolean;
89
104
  panOnScroll: boolean;
90
105
  bordered: boolean;
106
+ activeComment: string | null;
107
+ commentable: boolean;
91
108
  }>;
92
109
  __isFragment?: never;
93
110
  __isTeleport?: never;
@@ -99,6 +116,9 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
99
116
  }> & Readonly<{
100
117
  onTransaction?: ((tr: import("./index.js").FlowTransaction) => any) | undefined;
101
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;
102
122
  onNodeClick?: ((node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
103
123
  onNodeDblclick?: ((node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
104
124
  onNodeContextmenu?: ((node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any) | undefined;
@@ -114,6 +134,9 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
114
134
  }>, import("./context").FlowEditorExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
115
135
  transaction: (tr: import("./index.js").FlowTransaction) => any;
116
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;
117
140
  nodeClick: (node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any;
118
141
  nodeDblclick: (node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any;
119
142
  nodeContextmenu: (node: import("./index.js").FlowNode<import("./index.js").FlowData>, event: MouseEvent) => any;
@@ -127,10 +150,12 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
127
150
  "update:selection": (value: import("./index.js").FlowSelection) => any;
128
151
  "update:viewport": (value: import("./index.js").FlowViewport) => any;
129
152
  }, string, {
153
+ comments: import("dou-ui").CommentThread[];
130
154
  direction: "horizontal" | "vertical";
131
155
  grid: number;
132
156
  edgeType: string;
133
157
  readonly: boolean;
158
+ author: import("dou-ui").CommentAuthor;
134
159
  simpleZoom: number;
135
160
  guides: boolean;
136
161
  minZoom: number;
@@ -140,6 +165,8 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
140
165
  searchable: boolean;
141
166
  panOnScroll: boolean;
142
167
  bordered: boolean;
168
+ activeComment: string | null;
169
+ commentable: boolean;
143
170
  }, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
144
171
  $slots: import("./context").FlowEditorSlots;
145
172
  }), import("vue").HTMLAttributes>;
@@ -156,7 +183,7 @@ export declare const DouFlowMinimap: import("dou-ui").WithInstall<import("vue").
156
183
  export { DouFlowPort };
157
184
  export default DouFlowEditor;
158
185
  export { useFlowEditor } from './context';
159
- 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';
160
187
  export { flowLocales, useFlowMessages } from './locale';
161
188
  export type { FlowMessages, FlowMessagesOverride } from './locale';
162
189
  export { defaultNode } from './components/default-node';
@@ -180,6 +207,8 @@ export { flowKit } from './kit';
180
207
  export type { FlowKitOptions } from './kit';
181
208
  export { moveLayer } from './layers';
182
209
  export { drawCard } from './export/draw';
210
+ export { renderFlowPNG, renderFlowSVG } from './export/render';
211
+ export type { RenderFlowImageOptions, RenderFlowOptions } from './export/render';
183
212
  export type { FlowExportOptions, FlowImageOptions } from './export/draw';
184
213
  export type { FlowDrawContext, FlowDrawTextOptions } from './export/context';
185
214
  export type { LayerMove } from './layers';
@@ -98,6 +98,10 @@ 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;
101
105
  /** Why an edge was refused, announced when it is dropped. */
102
106
  refused: {
103
107
  direction: string;
@@ -1,5 +1,5 @@
1
- import { bezierEdge, defineEdgeType, stepEdge } from "../core/edge-types.js";
2
1
  import { format } from "../locale.js";
2
+ import { bezierEdge, defineEdgeType, stepEdge } from "../core/edge-types.js";
3
3
  import { ArrowEndsIcon, ArrowLeftRightIcon, ArrowRightIcon, ConnectorCurveIcon, ConnectorElbowIcon, ConnectorStraightIcon, LineDashDotIcon, LineDashedIcon, LineDottedIcon, LineSolidIcon, LineStyleIcon, MinusIcon, RouteIcon } from "@dou-ui/icons";
4
4
  // src/whiteboard/connector.ts
5
5
  var ARROW = {
@@ -1,6 +1,6 @@
1
1
  import { defineNodeType } from "../core/node-types.js";
2
- import { defineFlowExtension } from "../core/extension.js";
3
2
  import { format } from "../locale.js";
3
+ import { defineFlowExtension } from "../core/extension.js";
4
4
  import { createId } from "../core/model.js";
5
5
  import { anchorPorts, whiteboardKeys } from "./model.js";
6
6
  import { boardState } from "./state.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dou-ui/flow",
3
- "version": "0.1.0-alpha.3",
3
+ "version": "0.1.0-alpha.5",
4
4
  "description": "DouUI 的流程编辑器:在无限画布上拖动节点、连接端口",
5
5
  "keywords": [
6
6
  "vue",
@@ -54,7 +54,7 @@
54
54
  "build": "vite build && vue-tsc -p tsconfig.build.json && bun scripts/build-style.ts"
55
55
  },
56
56
  "peerDependencies": {
57
- "dou-ui": "0.1.0-alpha.3",
57
+ "dou-ui": "0.1.0-alpha.5",
58
58
  "vue": "^3.5.0",
59
59
  "yjs": "^13.6.0"
60
60
  },
@@ -64,7 +64,7 @@
64
64
  }
65
65
  },
66
66
  "dependencies": {
67
- "@dou-ui/icons": "0.1.0-alpha.3"
67
+ "@dou-ui/icons": "0.1.0-alpha.5"
68
68
  },
69
69
  "devDependencies": {
70
70
  "y-protocols": "^1.0.7",