@dou-ui/flow 0.1.0-alpha.29 → 0.1.0-alpha.30

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 (44) hide show
  1. package/dist/components/flow-toolbar.js.map +1 -1
  2. package/dist/components/flow-toolbar.vue_vue_type_script_setup_true_lang.js +300 -9
  3. package/dist/components/flow-toolbar.vue_vue_type_script_setup_true_lang.js.map +1 -1
  4. package/dist/export/color.js +49 -6
  5. package/dist/export/color.js.map +1 -1
  6. package/dist/export/context.js +16 -9
  7. package/dist/export/context.js.map +1 -1
  8. package/dist/export/draw.js +6 -5
  9. package/dist/export/draw.js.map +1 -1
  10. package/dist/flow-editor.js.map +1 -1
  11. package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js +318 -87
  12. package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js.map +1 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/locale.js +90 -3
  15. package/dist/locale.js.map +1 -1
  16. package/dist/style.css +1 -1
  17. package/dist/style.js +1 -0
  18. package/dist/types/core/menu.d.ts +55 -0
  19. package/dist/types/export/color.d.ts +6 -1
  20. package/dist/types/flow-editor.vue.d.ts +1 -1
  21. package/dist/types/index.d.ts +4 -4
  22. package/dist/types/locale.d.ts +19 -1
  23. package/dist/types/whiteboard/board-node.vue.d.ts +5 -0
  24. package/dist/types/whiteboard/colors.d.ts +36 -0
  25. package/dist/types/whiteboard/index.d.ts +2 -2
  26. package/dist/types/whiteboard/model.d.ts +22 -3
  27. package/dist/types/whiteboard/toolbar.d.ts +46 -0
  28. package/dist/whiteboard/board-node.js.map +1 -1
  29. package/dist/whiteboard/board-node.vue_vue_type_script_setup_true_lang.js +50 -10
  30. package/dist/whiteboard/board-node.vue_vue_type_script_setup_true_lang.js.map +1 -1
  31. package/dist/whiteboard/colors.js +84 -0
  32. package/dist/whiteboard/colors.js.map +1 -0
  33. package/dist/whiteboard/connector.js +42 -3
  34. package/dist/whiteboard/connector.js.map +1 -1
  35. package/dist/whiteboard/draw.js +26 -9
  36. package/dist/whiteboard/draw.js.map +1 -1
  37. package/dist/whiteboard/index.js +2 -1
  38. package/dist/whiteboard/kit.js +2 -0
  39. package/dist/whiteboard/kit.js.map +1 -1
  40. package/dist/whiteboard/model.js +2 -1
  41. package/dist/whiteboard/model.js.map +1 -1
  42. package/dist/whiteboard/toolbar.js +296 -0
  43. package/dist/whiteboard/toolbar.js.map +1 -0
  44. package/package.json +3 -3
@@ -47,6 +47,7 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
47
47
  edgeType: string;
48
48
  readonly: boolean;
49
49
  author: import("dou-ui").CommentAuthor;
50
+ bordered: boolean;
50
51
  simpleZoom: number;
51
52
  guides: boolean;
52
53
  minZoom: number;
@@ -55,7 +56,6 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
55
56
  fitMinZoom: number;
56
57
  searchable: boolean;
57
58
  panOnScroll: boolean;
58
- bordered: boolean;
59
59
  activeComment: string | null;
60
60
  commentable: boolean;
61
61
  }, false, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
@@ -94,6 +94,7 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
94
94
  edgeType: string;
95
95
  readonly: boolean;
96
96
  author: import("dou-ui").CommentAuthor;
97
+ bordered: boolean;
97
98
  simpleZoom: number;
98
99
  guides: boolean;
99
100
  minZoom: number;
@@ -102,7 +103,6 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
102
103
  fitMinZoom: number;
103
104
  searchable: boolean;
104
105
  panOnScroll: boolean;
105
- bordered: boolean;
106
106
  activeComment: string | null;
107
107
  commentable: boolean;
108
108
  }>;
@@ -156,6 +156,7 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
156
156
  edgeType: string;
157
157
  readonly: boolean;
158
158
  author: import("dou-ui").CommentAuthor;
159
+ bordered: boolean;
159
160
  simpleZoom: number;
160
161
  guides: boolean;
161
162
  minZoom: number;
@@ -164,7 +165,6 @@ export declare const DouFlowEditor: import("dou-ui").WithInstall<{
164
165
  fitMinZoom: number;
165
166
  searchable: boolean;
166
167
  panOnScroll: boolean;
167
- bordered: boolean;
168
168
  activeComment: string | null;
169
169
  commentable: boolean;
170
170
  }, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
@@ -193,7 +193,7 @@ export type { GroupNodeData } from './components/group-node';
193
193
  export { containerAt, FlowTree } from './core/groups';
194
194
  export { defineNodeType, labelOf, portSide, portsOf, resizeOf, sidePorts } from './core/node-types';
195
195
  export type { NodePaletteSpec, NodeResize, NodeTypeSpec, NodeViewProps } from './core/node-types';
196
- export type { FlowMenuTarget, FlowToolbarItem } from './core/menu';
196
+ export type { FlowMenuTarget, FlowToolbarColor, FlowToolbarColorPreset, FlowToolbarItem, } from './core/menu';
197
197
  export { createId, emptyDocument, emptySelection } from './core/model';
198
198
  export type { FlowData, FlowDocument, FlowEdge, FlowEndpoint, FlowNode, FlowPortSpec, FlowPortVisible, FlowSelection, FlowViewport, Point, PortSide, Rect, } from './core/model';
199
199
  export { checkDocument, migrateDocument } from './document';
@@ -1,4 +1,5 @@
1
- import type { WhiteboardArrow, WhiteboardDash, WhiteboardRoute } from './whiteboard/model';
1
+ import type { WhiteboardArrow, WhiteboardDash, WhiteboardPaletteColor, WhiteboardRoute } from './whiteboard/model';
2
+ import { type Tone } from 'dou-ui';
2
3
  import { type MaybeRefOrGetter } from 'vue';
3
4
  export interface FlowMessages {
4
5
  /** The canvas's accessible description. */
@@ -166,6 +167,23 @@ export interface FlowMessages {
166
167
  routeSet: string;
167
168
  dashSet: string;
168
169
  arrowSet: string;
170
+ /** Color buttons' names; `{value}` is the current color, default, none or mixed. */
171
+ fillOf: string;
172
+ strokeOf: string;
173
+ textColorOf: string;
174
+ lineColorOf: string;
175
+ /** Announced after changing a color; `{value}` is the new label. */
176
+ fillSet: string;
177
+ strokeSet: string;
178
+ textColorSet: string;
179
+ lineColorSet: string;
180
+ /** Swatch labels inside the color popover. */
181
+ colorDefault: string;
182
+ colorCustom: string;
183
+ fillNone: string;
184
+ borderNone: string;
185
+ colors: Record<WhiteboardPaletteColor, string>;
186
+ tones: Record<Tone, string>;
169
187
  };
170
188
  }
171
189
  export declare const flowLocales: Record<string, FlowMessages>;
@@ -1,11 +1,16 @@
1
1
  import type { NodeViewProps } from '../core/node-types';
2
2
  import type { Tone } from 'dou-ui';
3
+ import { type WhiteboardColor, type WhiteboardFill, type WhiteboardStroke } from './colors';
3
4
  import { type WhiteboardShape } from './model';
4
5
  type BoardData = {
5
6
  [key: string]: unknown;
6
7
  text?: string;
7
8
  shape?: WhiteboardShape;
8
9
  tone?: Tone;
10
+ fill?: WhiteboardFill;
11
+ stroke?: WhiteboardStroke;
12
+ textColor?: WhiteboardColor;
13
+ color?: WhiteboardColor;
9
14
  rotation?: number;
10
15
  points?: number[];
11
16
  box?: [number, number];
@@ -0,0 +1,36 @@
1
+ import type { Tone } from 'dou-ui';
2
+ import type { FlowMessages } from '../locale';
3
+ /**
4
+ * The built-in whiteboard palette names; their values follow the light or dark
5
+ * color mode for readable contrast on the board.
6
+ */
7
+ export declare const whiteboardColors: readonly ["gray", "red", "orange", "yellow", "green", "blue", "purple", "pink"];
8
+ export type WhiteboardPaletteColor = (typeof whiteboardColors)[number];
9
+ /**
10
+ * A color on the whiteboard: a palette name (adapts to light and dark mode),
11
+ * a DouUI `Tone`, or any CSS color string (such as `#3b6ea8` or `rgba(...)`).
12
+ */
13
+ export type WhiteboardColor = WhiteboardPaletteColor | Tone | (string & {});
14
+ /** A background fill color, or `'none'` / `'transparent'` for a transparent fill. */
15
+ export type WhiteboardFill = WhiteboardColor | 'none' | 'transparent';
16
+ /** A border color, or `'none'` (or `'transparent'`) for a borderless shape. */
17
+ export type WhiteboardStroke = WhiteboardColor | 'none';
18
+ export declare const isWhiteboardColor: (value: unknown) => value is WhiteboardPaletteColor;
19
+ export declare const isToneColor: (value: unknown) => value is Tone;
20
+ /** Whether a color value explicitly disables painting (`'none'` or `'transparent'`). */
21
+ export declare const isNoneColor: (value: unknown) => boolean;
22
+ /** Trims a color value; maps `'none'` / `'transparent'` to `'none'`, empty strings to `undefined`. */
23
+ export declare function normalizeColorValue(value: unknown): string | undefined;
24
+ /** Like `normalizeColorValue`, dropping `'none'`/`'transparent'` for channels that stay painted. */
25
+ export declare function normalizeOpaqueColor(value: unknown): string | undefined;
26
+ /**
27
+ * Turns a fill color into a CSS / SVG paint value.
28
+ * Returns `'none'` for transparent fills (use `'transparent'` for CSS `background-color`).
29
+ */
30
+ export declare function resolveFillColor(value: WhiteboardFill | undefined, kind?: 'shape' | 'sticky'): string | undefined;
31
+ /** Turns a border, connector or ink color into a CSS / SVG stroke/fill paint value. */
32
+ export declare function resolveStrokeColor(value: WhiteboardStroke | undefined): string | undefined;
33
+ /** Turns a text color into a CSS / SVG color value. */
34
+ export declare function resolveTextColor(value: WhiteboardColor | undefined): string | undefined;
35
+ /** Human-readable name for a color value in tooltips and screen-reader announcements. */
36
+ export declare function colorDisplayName(value: string | null | undefined, t: FlowMessages['board'], noneLabel?: string): string;
@@ -1,6 +1,6 @@
1
1
  export { connectorEdge, imageNode, inkNode, shapeNode, stickyNode, textNode, whiteboardKit, } from './kit';
2
- export { imageKey, whiteboardKeys } from './model';
2
+ export { imageKey, isWhiteboardColor, whiteboardColors, whiteboardKeys } from './model';
3
3
  export { insertImages, pickImages } from './image';
4
4
  export type { WhiteboardKitOptions } from './kit';
5
5
  export type { WhiteboardImageOptions, WhiteboardUpload, WhiteboardUploaded, WhiteboardUploadErrorHandler, } from './image';
6
- export type { WhiteboardImageData, WhiteboardInkData, WhiteboardNodeData, WhiteboardShape, WhiteboardShapeData, WhiteboardShapeTool, WhiteboardStickyData, WhiteboardTextData, WhiteboardTool, WhiteboardArrow, WhiteboardConnectorData, WhiteboardDash, WhiteboardRoute, } from './model';
6
+ export type { WhiteboardColor, WhiteboardFill, WhiteboardImageData, WhiteboardInkData, WhiteboardNodeData, WhiteboardPaletteColor, WhiteboardShape, WhiteboardShapeData, WhiteboardShapeTool, WhiteboardStickyData, WhiteboardStroke, WhiteboardTextData, WhiteboardTool, WhiteboardArrow, WhiteboardConnectorData, WhiteboardDash, WhiteboardRoute, } from './model';
@@ -1,4 +1,7 @@
1
1
  import type { Tone } from 'dou-ui';
2
+ import type { WhiteboardColor, WhiteboardFill, WhiteboardStroke } from './colors';
3
+ export { whiteboardColors, isWhiteboardColor } from './colors';
4
+ export type { WhiteboardColor, WhiteboardFill, WhiteboardPaletteColor, WhiteboardStroke, } from './colors';
2
5
  /** What a press on the board does. */
3
6
  export type WhiteboardTool = 'select' | 'hand' | 'rect' | 'ellipse' | 'diamond' | 'sticky' | 'text' | 'pen' | 'eraser' | 'comment';
4
7
  /** The tools that put down a node with a box. */
@@ -13,16 +16,28 @@ export interface WhiteboardNodeData {
13
16
  export interface WhiteboardShapeData extends WhiteboardNodeData {
14
17
  shape: WhiteboardShape;
15
18
  text?: string;
16
- /** `neutral` by default. */
19
+ /** `neutral` by default; kept for compatibility when `fill` / `stroke` are omitted. */
17
20
  tone?: Tone;
21
+ /** Background fill color, or `'none'` / `'transparent'` for no fill. */
22
+ fill?: WhiteboardFill;
23
+ /** Border color, or `'none'` for a borderless shape. */
24
+ stroke?: WhiteboardStroke;
25
+ /** Text color inside the shape. */
26
+ textColor?: WhiteboardColor;
18
27
  }
19
28
  export interface WhiteboardStickyData extends WhiteboardNodeData {
20
29
  text?: string;
21
- /** `warning` (yellow) by default. */
30
+ /** `warning` (yellow) by default; kept for compatibility when `fill` is omitted. */
22
31
  tone?: Tone;
32
+ /** Background color of the sticky note. */
33
+ fill?: WhiteboardFill;
34
+ /** Text color inside the sticky note. */
35
+ textColor?: WhiteboardColor;
23
36
  }
24
37
  export interface WhiteboardTextData extends WhiteboardNodeData {
25
38
  text?: string;
39
+ /** Text color. */
40
+ color?: WhiteboardColor;
26
41
  }
27
42
  /** A pen stroke. */
28
43
  export interface WhiteboardInkData extends WhiteboardNodeData {
@@ -38,8 +53,10 @@ export interface WhiteboardInkData extends WhiteboardNodeData {
38
53
  * makes it 0.4 to 1.6 times as wide as it presses lighter or harder.
39
54
  */
40
55
  size?: number;
41
- /** The text color when left out. */
56
+ /** The text color when left out; kept for compatibility when `color` is omitted. */
42
57
  tone?: Tone;
58
+ /** Stroke color. */
59
+ color?: WhiteboardColor;
43
60
  }
44
61
  /** How a connector runs: one straight line, right-angled turns, or a smooth curve. */
45
62
  export type WhiteboardRoute = 'straight' | 'elbow' | 'curve';
@@ -55,6 +72,8 @@ export interface WhiteboardConnectorData {
55
72
  dash?: WhiteboardDash;
56
73
  /** `end` by default. */
57
74
  arrow?: WhiteboardArrow;
75
+ /** Line and arrowhead color. */
76
+ color?: WhiteboardColor;
58
77
  /** Where an `elbow` connector's middle run sits, from 0 to 1; set by dragging it. */
59
78
  bend?: number;
60
79
  }
@@ -0,0 +1,46 @@
1
+ import type { Component } from 'vue';
2
+ import type { FlowEditorContext } from '../context';
3
+ import type { FlowToolbarColorPreset, FlowToolbarItem } from '../core/menu';
4
+ import type { FlowData, FlowNode } from '../core/model';
5
+ import { type FlowMessages } from '../locale';
6
+ /** Merges `patch` into `base`, omitting keys set to `undefined` for clean JSON data. */
7
+ export declare function cleanData(base: FlowData | undefined, patch: Record<string, unknown>): Record<string, unknown>;
8
+ /** Shallow-compares two optional data objects so no-op color picks skip empty history steps. */
9
+ export declare function sameData(a: FlowData | undefined, b: FlowData | undefined): boolean;
10
+ /** Shared value across a selection, or `null` when items disagree (mixed). */
11
+ export declare function sharedValue(values: (string | undefined)[]): string | null | undefined;
12
+ /** Allocates or closes a transaction group so live drags in `DouColorPanel` undo as one step. */
13
+ export declare function colorTransactionMeta(ctx: FlowEditorContext, scope: string, live: boolean): {
14
+ group?: string;
15
+ } | undefined;
16
+ /** Drops any unclosed live-drag group when the popover closes or selection changes. */
17
+ export declare function resetColorGroup(ctx: FlowEditorContext, scope?: string): void;
18
+ export declare function palettePresets(kind: 'fill' | 'stroke' | 'text', t: FlowMessages['board']): FlowToolbarColorPreset[];
19
+ export interface ColorToolbarOptions {
20
+ ctx: FlowEditorContext;
21
+ key: string;
22
+ /** Scope including the selected targets so live drags on different items never merge. */
23
+ scope?: string;
24
+ kind: 'fill' | 'stroke' | 'text';
25
+ icon: Component;
26
+ value: string | null | undefined;
27
+ swatch: string | undefined;
28
+ disabled?: boolean;
29
+ labelOf: string;
30
+ announceSet: string;
31
+ noneOption?: {
32
+ value: string;
33
+ label: string;
34
+ icon?: Component;
35
+ };
36
+ apply: (value: string | undefined, meta?: {
37
+ group?: string;
38
+ }) => void;
39
+ }
40
+ /** Builds one color-picker toolbar item shared by board nodes and connectors. */
41
+ export declare function colorToolbarItem(options: ColorToolbarOptions): FlowToolbarItem;
42
+ /**
43
+ * Fill, border (with borderless toggle), text color and ink color controls
44
+ * over the selected whiteboard nodes.
45
+ */
46
+ export declare function boardNodeToolbar(ctx: FlowEditorContext, nodes: FlowNode[]): FlowToolbarItem[];
@@ -1 +1 @@
1
- {"version":3,"file":"board-node.js","names":["_sfc_main"],"sources":["../../src/whiteboard/board-node.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ImageOffIcon } from '@dou-ui/icons'\nimport { computed, nextTick, ref, toRef, useTemplateRef, watch } from 'vue'\nimport { DouFlowPort } from '../components/port'\nimport { useFlowEditor } from '../context'\nimport type { NodeViewProps } from '../core/node-types'\nimport type { Tone } from 'dou-ui'\nimport { fitInk, inkOutline, INK_SIZE, unpack } from './ink'\nimport { anchorSides, type WhiteboardShape } from './model'\nimport { boardState } from './state'\nimport { RESIZE_HANDLES, useTransformHandles, type ResizeHandle } from './transform'\n\ntype BoardData = {\n [key: string]: unknown\n text?: string\n shape?: WhiteboardShape\n tone?: Tone\n rotation?: number\n points?: number[]\n box?: [number, number]\n size?: number\n src?: string\n alt?: string\n}\n\ntype Kind = 'shape' | 'sticky' | 'text' | 'ink' | 'image'\n\nconst props = defineProps<NodeViewProps<BoardData>>()\nconst ctx = useFlowEditor()\nconst state = boardState(ctx)\n\nconst KINDS: readonly Kind[] = ['sticky', 'text', 'ink', 'image']\n/** What the node is: one of the shapes, a note, text, a pen stroke or an image. */\nconst kind = computed<Kind>(() => KINDS.find((k) => k === props.node.type) ?? 'shape')\nconst shape = computed<WhiteboardShape>(() => props.data.shape ?? 'rect')\nconst tone = computed<Tone>(\n () => props.data.tone ?? (kind.value === 'sticky' ? 'warning' : 'neutral'),\n)\nconst writable = computed(() => ['shape', 'sticky', 'text'].includes(kind.value))\n\nconst MIN: Record<Kind, number> = { shape: 24, sticky: 64, text: 40, ink: 8, image: 24 }\nconst rotation = computed(() => props.data.rotation ?? 0)\nconst { turning, startTurn, startResize } = useTransformHandles(\n ctx,\n toRef(props, 'node'),\n rotation,\n { width: MIN[kind.value], height: MIN[kind.value] },\n)\n/*\n * A handle being dragged shows the node changed through the editor, so\n * `node` and `data` already are what it is dragged to: the node's own frame,\n * its ports and its edges follow along with it.\n */\nconst transform = computed(() => (rotation.value ? { rotate: `${rotation.value}deg` } : undefined))\n/**\n * The resize handles: an image keeps its proportions, from its corners; text\n * only widens, so it has no top or bottom side; the rest has every corner\n * and side.\n */\nconst resizeHandles = computed(() =>\n kind.value === 'image'\n ? RESIZE_HANDLES.filter((h) => h.x && h.y)\n : kind.value === 'text'\n ? RESIZE_HANDLES.filter((h) => h.x)\n : RESIZE_HANDLES,\n)\nconst sideHandles = computed(() => resizeHandles.value.filter((h) => !h.x || !h.y))\nconst cornerHandles = computed(() => resizeHandles.value.filter((h) => h.x && h.y))\nconst rect = computed(\n () => ctx.getNodeRect(props.node.id) ?? { ...props.node, width: 0, height: 0 },\n)\n/**\n * The node's size, for the anchors and the corner handles to share the\n * corners of a small node: each keeps short of the other.\n */\nconst sizeStyle = computed(() => ({\n '--dou-whiteboard-frame-width': `${rect.value.width}px`,\n '--dou-whiteboard-frame-height': `${rect.value.height}px`,\n}))\n/** The node's box, turned with it, for the handles drawn above every node. */\nconst frameStyle = computed(() => {\n const box = rect.value\n return {\n // `translate`, not `transform`: it applies before `rotate`, so the box\n // turns about its own centre and its offset is not turned with it\n translate: `${box.x}px ${box.y}px`,\n width: `${box.width}px`,\n height: `${box.height}px`,\n ...sizeStyle.value,\n rotate: rotation.value ? `${rotation.value}deg` : undefined,\n }\n})\nconst CURSORS = ['ew-resize', 'nwse-resize', 'ns-resize', 'nesw-resize'] as const\n/** The resize cursor along a handle's way out, turned with the node. */\nfunction cursorOf(handle: ResizeHandle) {\n // text only widens, from a corner too\n if (kind.value === 'text') handle = { x: handle.x, y: 0 }\n const degrees = (Math.atan2(handle.y, handle.x) * 180) / Math.PI + rotation.value\n return CURSORS[((Math.round(degrees / 45) % 4) + 4) % 4]\n}\nfunction onResize(event: PointerEvent, handle: ResizeHandle) {\n startResize(event, handle, {\n keepRatio: kind.value === 'image',\n widthOnly: kind.value === 'text',\n })\n}\n/** Where a handle sits on the box: `-1` is the start, `1` the end. */\nconst place = (v: -1 | 0 | 1) => `${(v + 1) * 50}%`\n\n/** Handles show on the one selected node, while the select tool is in hand. */\nconst handles = computed(\n () =>\n props.selected &&\n !props.readonly &&\n !editing.value &&\n state.tool.value === 'select' &&\n ctx.selection.value.nodes.length === 1,\n)\n\n/** The stroke fitted to the box shown, so stretching it keeps its thickness. */\nconst ink = computed(() => {\n const { points, box: inkBox } = props.data\n if (kind.value !== 'ink' || !points || !inkBox) return ''\n const size = props.data.size ?? INK_SIZE\n return inkOutline(fitInk(unpack(points), inkBox, shown.value.w, shown.value.h, size), size)\n})\nconst erasing = computed(() => state.erasing.value.has(props.node.id))\n\n// drawn in the node's own units, half the 1.5px stroke in from the edge\nconst shown = computed(() => ({ w: props.node.width ?? 160, h: props.node.height ?? 100 }))\nconst diamond = computed(() => {\n const { w, h } = shown.value\n const i = 1\n return `${w / 2},${i} ${w - i},${h / 2} ${w / 2},${h - i} ${i},${h / 2}`\n})\n\n// Whole lines that fit, the last one ending in an ellipsis, as an export draws them.\nconst textEl = useTemplateRef<HTMLElement>('textEl')\nconst textMetrics = ref<{ line: number; padding: number } | null>(null)\nwatch(\n textEl,\n (el) => {\n if (!el) return\n const s = getComputedStyle(el)\n const line = Number.parseFloat(s.lineHeight)\n if (!line) return\n const padding = Number.parseFloat(s.paddingTop) + Number.parseFloat(s.paddingBottom)\n textMetrics.value = { line, padding: padding || 0 }\n },\n { flush: 'post' },\n)\nconst textStyle = computed(() => {\n const m = textMetrics.value\n if (!m || kind.value === 'text') return undefined\n const height = shown.value.h\n return { '-webkit-line-clamp': Math.max(1, Math.floor((height - m.padding + 0.5) / m.line)) }\n})\n\n// An image that can't be loaded: a plain box with a sign, as an export draws it.\nconst broken = ref(false)\nwatch(\n () => props.data.src,\n () => (broken.value = false),\n)\n\nconst editing = computed(() => state.editing.value === props.node.id)\nconst draft = ref('')\nconst field = useTemplateRef<HTMLTextAreaElement>('field')\n\nwatch(\n editing,\n (on) => {\n if (!on) return\n draft.value = props.data.text ?? ''\n void nextTick(() => {\n fit()\n field.value?.focus()\n field.value?.select()\n })\n },\n { immediate: true },\n)\n\n// browsers without `field-sizing` grow the field by hand\nfunction fit() {\n const el = field.value\n if (!el || CSS.supports?.('field-sizing', 'content')) return\n el.style.height = 'auto'\n el.style.height = `${el.scrollHeight}px`\n}\nwatch(draft, () => void nextTick(fit))\n\nfunction edit() {\n if (props.readonly || !writable.value) return\n state.editing.value = props.node.id\n}\n\nfunction finish() {\n if (!editing.value) return\n state.editing.value = null\n const text = draft.value.replace(/\\s+$/, '')\n // text with nothing written in it is nothing at all\n if (!text && kind.value === 'text') ctx.transact((tr) => tr.removeNode(props.node.id))\n else if (text !== (props.data.text ?? '')) props.updateData({ text: text || undefined })\n // back to the canvas, so the keys go on working\n ctx.root.value?.focus({ preventScroll: true })\n}\n\nfunction onKeydown(event: KeyboardEvent) {\n if (event.isComposing) return\n // Escape, or mod+Enter, puts the text down; Enter is a new line\n if (event.key === 'Escape' || (event.key === 'Enter' && (event.metaKey || event.ctrlKey))) {\n event.preventDefault()\n event.stopPropagation()\n finish()\n }\n}\n</script>\n\n<template>\n <div\n class=\"dou-whiteboard-node\"\n :class=\"[\n `is-${kind}`,\n kind === 'shape' && `is-${shape}`,\n `is-${tone}`,\n {\n 'is-editing': editing,\n 'is-turned': !!rotation,\n 'is-turning': turning !== null,\n 'is-selected': selected,\n 'is-erasing': erasing,\n },\n ]\"\n :style=\"[transform, sizeStyle]\"\n @dblclick.stop=\"edit\"\n >\n <svg\n v-if=\"kind === 'shape'\"\n class=\"dou-whiteboard-node__shape\"\n :viewBox=\"`0 0 ${shown.w} ${shown.h}`\"\n aria-hidden=\"true\"\n >\n <rect\n v-if=\"shape === 'rect'\"\n x=\"0.75\"\n y=\"0.75\"\n :width=\"Math.max(0, shown.w - 1.5)\"\n :height=\"Math.max(0, shown.h - 1.5)\"\n rx=\"8\"\n />\n <ellipse\n v-else-if=\"shape === 'ellipse'\"\n :cx=\"shown.w / 2\"\n :cy=\"shown.h / 2\"\n :rx=\"Math.max(0, shown.w / 2 - 0.75)\"\n :ry=\"Math.max(0, shown.h / 2 - 0.75)\"\n />\n <polygon v-else :points=\"diamond\" />\n </svg>\n <svg\n v-else-if=\"kind === 'ink' && data.box\"\n class=\"dou-whiteboard-node__ink\"\n :viewBox=\"`0 0 ${shown.w} ${shown.h}`\"\n aria-hidden=\"true\"\n >\n <path class=\"dou-whiteboard-node__ink-hit\" :d=\"ink\" />\n <path :d=\"ink\" />\n </svg>\n <div\n v-else-if=\"kind === 'image' && broken\"\n class=\"dou-whiteboard-node__image is-broken\"\n role=\"img\"\n :aria-label=\"data.alt || undefined\"\n >\n <ImageOffIcon />\n </div>\n <img\n v-else-if=\"kind === 'image'\"\n class=\"dou-whiteboard-node__image\"\n :src=\"data.src\"\n :alt=\"data.alt ?? ''\"\n draggable=\"false\"\n @error=\"broken = true\"\n />\n <textarea\n v-if=\"editing\"\n ref=\"field\"\n v-model=\"draft\"\n class=\"dou-whiteboard-node__text dou-whiteboard-node__field\"\n :aria-label=\"ctx.messages.value.board.editText\"\n @keydown=\"onKeydown\"\n @blur=\"finish\"\n @pointerdown.stop\n />\n <div\n v-else-if=\"writable\"\n ref=\"textEl\"\n class=\"dou-whiteboard-node__text\"\n :style=\"textStyle\"\n v-text=\"data.text\"\n />\n <div v-if=\"kind !== 'ink'\" class=\"dou-whiteboard-node__anchors\">\n <template v-for=\"side in anchorSides\" :key=\"side\">\n <DouFlowPort :id=\"`${side}-in`\" class=\"dou-whiteboard-node__anchor\" />\n <DouFlowPort :id=\"side\" class=\"dou-whiteboard-node__anchor\" />\n </template>\n </div>\n <template v-if=\"handles\">\n <!-- the sides stay on the node, under its anchors; the turn and the\n corners go above every node, so a neighbour never covers them -->\n <span\n v-for=\"handle in sideHandles\"\n :key=\"`${handle.x},${handle.y}`\"\n :class=\"['dou-whiteboard-node__side', handle.x ? 'is-x' : 'is-y']\"\n :style=\"{ left: place(handle.x), top: place(handle.y), cursor: cursorOf(handle) }\"\n :data-handle=\"`${handle.x},${handle.y}`\"\n data-dou-nodrag\n aria-hidden=\"true\"\n @pointerdown=\"onResize($event, handle)\"\n />\n <Teleport :to=\"state.handles.value\" :disabled=\"!state.handles.value\">\n <div class=\"dou-whiteboard-node__frame\" :style=\"frameStyle\" aria-hidden=\"true\">\n <!-- data-flow-overlay on its target: the selection's toolbar keeps\n clear of where a finger can take it, when it floats below the\n node or the node is turned upside down -->\n <span\n class=\"dou-whiteboard-node__turn\"\n data-flow-handle\n data-dou-nodrag\n @pointerdown=\"startTurn\"\n >\n <span class=\"dou-whiteboard-node__target\" data-flow-overlay />\n </span>\n <span\n v-for=\"handle in cornerHandles\"\n :key=\"`${handle.x},${handle.y}`\"\n :class=\"[\n 'dou-whiteboard-node__corner',\n handle.x < 0 ? 'is-left' : 'is-right',\n handle.y < 0 ? 'is-top' : 'is-bottom',\n ]\"\n :style=\"{ left: place(handle.x), top: place(handle.y), cursor: cursorOf(handle) }\"\n :data-handle=\"`${handle.x},${handle.y}`\"\n data-flow-handle\n data-dou-nodrag\n @pointerdown=\"onResize($event, handle)\"\n />\n </div>\n </Teleport>\n </template>\n </div>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"board-node.js","names":["_sfc_main"],"sources":["../../src/whiteboard/board-node.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ImageOffIcon } from '@dou-ui/icons'\nimport { computed, nextTick, ref, toRef, useTemplateRef, watch } from 'vue'\nimport { DouFlowPort } from '../components/port'\nimport { useFlowEditor } from '../context'\nimport type { NodeViewProps } from '../core/node-types'\nimport type { Tone } from 'dou-ui'\nimport {\n isNoneColor,\n resolveFillColor,\n resolveStrokeColor,\n resolveTextColor,\n type WhiteboardColor,\n type WhiteboardFill,\n type WhiteboardStroke,\n} from './colors'\nimport { fitInk, inkOutline, INK_SIZE, unpack } from './ink'\nimport { anchorSides, type WhiteboardShape } from './model'\nimport { boardState } from './state'\nimport { RESIZE_HANDLES, useTransformHandles, type ResizeHandle } from './transform'\n\ntype BoardData = {\n [key: string]: unknown\n text?: string\n shape?: WhiteboardShape\n tone?: Tone\n fill?: WhiteboardFill\n stroke?: WhiteboardStroke\n textColor?: WhiteboardColor\n color?: WhiteboardColor\n rotation?: number\n points?: number[]\n box?: [number, number]\n size?: number\n src?: string\n alt?: string\n}\n\ntype Kind = 'shape' | 'sticky' | 'text' | 'ink' | 'image'\n\nconst props = defineProps<NodeViewProps<BoardData>>()\nconst ctx = useFlowEditor()\nconst state = boardState(ctx)\n\nconst KINDS: readonly Kind[] = ['sticky', 'text', 'ink', 'image']\n/** What the node is: one of the shapes, a note, text, a pen stroke or an image. */\nconst kind = computed<Kind>(() => KINDS.find((k) => k === props.node.type) ?? 'shape')\nconst shape = computed<WhiteboardShape>(() => props.data.shape ?? 'rect')\nconst tone = computed<Tone>(\n () => props.data.tone ?? (kind.value === 'sticky' ? 'warning' : 'neutral'),\n)\nconst borderless = computed(() => kind.value === 'shape' && isNoneColor(props.data.stroke))\nconst transparentSticky = computed(() => kind.value === 'sticky' && isNoneColor(props.data.fill))\nconst colorStyle = computed(() => {\n const vars: Record<string, string> = {}\n if (kind.value === 'shape') {\n const fill = resolveFillColor(props.data.fill, 'shape')\n if (fill) vars['--dou-whiteboard-shape-fill'] = fill\n if (!borderless.value) {\n const stroke = resolveStrokeColor(props.data.stroke)\n if (stroke && stroke !== 'none') vars['--dou-whiteboard-shape-stroke'] = stroke\n }\n const textColor = resolveTextColor(props.data.textColor)\n if (textColor) vars['--dou-whiteboard-text-color'] = textColor\n } else if (kind.value === 'sticky') {\n const fill = resolveFillColor(props.data.fill, 'sticky')\n if (fill) vars['--dou-whiteboard-sticky-fill'] = fill === 'none' ? 'transparent' : fill\n const textColor = resolveTextColor(props.data.textColor)\n if (textColor) vars['--dou-whiteboard-text-color'] = textColor\n } else if (kind.value === 'text') {\n const textColor = resolveTextColor(props.data.color)\n if (textColor) vars['--dou-whiteboard-text-color'] = textColor\n } else if (kind.value === 'ink') {\n const stroke = resolveStrokeColor(props.data.color)\n if (stroke && stroke !== 'none') vars['--dou-whiteboard-ink-color'] = stroke\n }\n return vars\n})\nconst writable = computed(() => ['shape', 'sticky', 'text'].includes(kind.value))\n\nconst MIN: Record<Kind, number> = { shape: 24, sticky: 64, text: 40, ink: 8, image: 24 }\nconst rotation = computed(() => props.data.rotation ?? 0)\nconst { turning, startTurn, startResize } = useTransformHandles(\n ctx,\n toRef(props, 'node'),\n rotation,\n { width: MIN[kind.value], height: MIN[kind.value] },\n)\n/*\n * A handle being dragged shows the node changed through the editor, so\n * `node` and `data` already are what it is dragged to: the node's own frame,\n * its ports and its edges follow along with it.\n */\nconst transform = computed(() => (rotation.value ? { rotate: `${rotation.value}deg` } : undefined))\n/**\n * The resize handles: an image keeps its proportions, from its corners; text\n * only widens, so it has no top or bottom side; the rest has every corner\n * and side.\n */\nconst resizeHandles = computed(() =>\n kind.value === 'image'\n ? RESIZE_HANDLES.filter((h) => h.x && h.y)\n : kind.value === 'text'\n ? RESIZE_HANDLES.filter((h) => h.x)\n : RESIZE_HANDLES,\n)\nconst sideHandles = computed(() => resizeHandles.value.filter((h) => !h.x || !h.y))\nconst cornerHandles = computed(() => resizeHandles.value.filter((h) => h.x && h.y))\nconst rect = computed(\n () => ctx.getNodeRect(props.node.id) ?? { ...props.node, width: 0, height: 0 },\n)\n/**\n * The node's size, for the anchors and the corner handles to share the\n * corners of a small node: each keeps short of the other.\n */\nconst sizeStyle = computed(() => ({\n '--dou-whiteboard-frame-width': `${rect.value.width}px`,\n '--dou-whiteboard-frame-height': `${rect.value.height}px`,\n}))\n/** The node's box, turned with it, for the handles drawn above every node. */\nconst frameStyle = computed(() => {\n const box = rect.value\n return {\n // `translate`, not `transform`: it applies before `rotate`, so the box\n // turns about its own centre and its offset is not turned with it\n translate: `${box.x}px ${box.y}px`,\n width: `${box.width}px`,\n height: `${box.height}px`,\n ...sizeStyle.value,\n rotate: rotation.value ? `${rotation.value}deg` : undefined,\n }\n})\nconst CURSORS = ['ew-resize', 'nwse-resize', 'ns-resize', 'nesw-resize'] as const\n/** The resize cursor along a handle's way out, turned with the node. */\nfunction cursorOf(handle: ResizeHandle) {\n // text only widens, from a corner too\n if (kind.value === 'text') handle = { x: handle.x, y: 0 }\n const degrees = (Math.atan2(handle.y, handle.x) * 180) / Math.PI + rotation.value\n return CURSORS[((Math.round(degrees / 45) % 4) + 4) % 4]\n}\nfunction onResize(event: PointerEvent, handle: ResizeHandle) {\n startResize(event, handle, {\n keepRatio: kind.value === 'image',\n widthOnly: kind.value === 'text',\n })\n}\n/** Where a handle sits on the box: `-1` is the start, `1` the end. */\nconst place = (v: -1 | 0 | 1) => `${(v + 1) * 50}%`\n\n/** Handles show on the one selected node, while the select tool is in hand. */\nconst handles = computed(\n () =>\n props.selected &&\n !props.readonly &&\n !editing.value &&\n state.tool.value === 'select' &&\n ctx.selection.value.nodes.length === 1,\n)\n\n/** The stroke fitted to the box shown, so stretching it keeps its thickness. */\nconst ink = computed(() => {\n const { points, box: inkBox } = props.data\n if (kind.value !== 'ink' || !points || !inkBox) return ''\n const size = props.data.size ?? INK_SIZE\n return inkOutline(fitInk(unpack(points), inkBox, shown.value.w, shown.value.h, size), size)\n})\nconst erasing = computed(() => state.erasing.value.has(props.node.id))\n\n// drawn in the node's own units, half the 1.5px stroke in from the edge (0 when borderless)\nconst shown = computed(() => ({ w: props.node.width ?? 160, h: props.node.height ?? 100 }))\nconst shapeInset = computed(() => (borderless.value ? 0 : 0.75))\nconst diamond = computed(() => {\n const { w, h } = shown.value\n const i = borderless.value ? 0 : 1\n return `${w / 2},${i} ${w - i},${h / 2} ${w / 2},${h - i} ${i},${h / 2}`\n})\n\n// Whole lines that fit, the last one ending in an ellipsis, as an export draws them.\nconst textEl = useTemplateRef<HTMLElement>('textEl')\nconst textMetrics = ref<{ line: number; padding: number } | null>(null)\nwatch(\n textEl,\n (el) => {\n if (!el) return\n const s = getComputedStyle(el)\n const line = Number.parseFloat(s.lineHeight)\n if (!line) return\n const padding = Number.parseFloat(s.paddingTop) + Number.parseFloat(s.paddingBottom)\n textMetrics.value = { line, padding: padding || 0 }\n },\n { flush: 'post' },\n)\nconst textStyle = computed(() => {\n const m = textMetrics.value\n if (!m || kind.value === 'text') return undefined\n const height = shown.value.h\n return { '-webkit-line-clamp': Math.max(1, Math.floor((height - m.padding + 0.5) / m.line)) }\n})\n\n// An image that can't be loaded: a plain box with a sign, as an export draws it.\nconst broken = ref(false)\nwatch(\n () => props.data.src,\n () => (broken.value = false),\n)\n\nconst editing = computed(() => state.editing.value === props.node.id)\nconst draft = ref('')\nconst field = useTemplateRef<HTMLTextAreaElement>('field')\n\nwatch(\n editing,\n (on) => {\n if (!on) return\n draft.value = props.data.text ?? ''\n void nextTick(() => {\n fit()\n field.value?.focus()\n field.value?.select()\n })\n },\n { immediate: true },\n)\n\n// browsers without `field-sizing` grow the field by hand\nfunction fit() {\n const el = field.value\n if (!el || CSS.supports?.('field-sizing', 'content')) return\n el.style.height = 'auto'\n el.style.height = `${el.scrollHeight}px`\n}\nwatch(draft, () => void nextTick(fit))\n\nfunction edit() {\n if (props.readonly || !writable.value) return\n state.editing.value = props.node.id\n}\n\nfunction finish() {\n if (!editing.value) return\n state.editing.value = null\n const text = draft.value.replace(/\\s+$/, '')\n // text with nothing written in it is nothing at all\n if (!text && kind.value === 'text') ctx.transact((tr) => tr.removeNode(props.node.id))\n else if (text !== (props.data.text ?? '')) props.updateData({ text: text || undefined })\n // back to the canvas, so the keys go on working\n ctx.root.value?.focus({ preventScroll: true })\n}\n\nfunction onKeydown(event: KeyboardEvent) {\n if (event.isComposing) return\n // Escape, or mod+Enter, puts the text down; Enter is a new line\n if (event.key === 'Escape' || (event.key === 'Enter' && (event.metaKey || event.ctrlKey))) {\n event.preventDefault()\n event.stopPropagation()\n finish()\n }\n}\n</script>\n\n<template>\n <div\n class=\"dou-whiteboard-node\"\n :class=\"[\n `is-${kind}`,\n kind === 'shape' && `is-${shape}`,\n `is-${tone}`,\n {\n 'is-editing': editing,\n 'is-turned': !!rotation,\n 'is-turning': turning !== null,\n 'is-selected': selected,\n 'is-erasing': erasing,\n 'is-borderless': borderless,\n 'is-transparent': transparentSticky,\n },\n ]\"\n :style=\"[transform, sizeStyle, colorStyle]\"\n @dblclick.stop=\"edit\"\n >\n <svg\n v-if=\"kind === 'shape'\"\n class=\"dou-whiteboard-node__shape\"\n :viewBox=\"`0 0 ${shown.w} ${shown.h}`\"\n aria-hidden=\"true\"\n >\n <rect\n v-if=\"shape === 'rect'\"\n :x=\"shapeInset\"\n :y=\"shapeInset\"\n :width=\"Math.max(0, shown.w - shapeInset * 2)\"\n :height=\"Math.max(0, shown.h - shapeInset * 2)\"\n rx=\"8\"\n />\n <ellipse\n v-else-if=\"shape === 'ellipse'\"\n :cx=\"shown.w / 2\"\n :cy=\"shown.h / 2\"\n :rx=\"Math.max(0, shown.w / 2 - shapeInset)\"\n :ry=\"Math.max(0, shown.h / 2 - shapeInset)\"\n />\n <polygon v-else :points=\"diamond\" />\n </svg>\n <svg\n v-else-if=\"kind === 'ink' && data.box\"\n class=\"dou-whiteboard-node__ink\"\n :viewBox=\"`0 0 ${shown.w} ${shown.h}`\"\n aria-hidden=\"true\"\n >\n <path class=\"dou-whiteboard-node__ink-hit\" :d=\"ink\" />\n <path :d=\"ink\" />\n </svg>\n <div\n v-else-if=\"kind === 'image' && broken\"\n class=\"dou-whiteboard-node__image is-broken\"\n role=\"img\"\n :aria-label=\"data.alt || undefined\"\n >\n <ImageOffIcon />\n </div>\n <img\n v-else-if=\"kind === 'image'\"\n class=\"dou-whiteboard-node__image\"\n :src=\"data.src\"\n :alt=\"data.alt ?? ''\"\n draggable=\"false\"\n @error=\"broken = true\"\n />\n <textarea\n v-if=\"editing\"\n ref=\"field\"\n v-model=\"draft\"\n class=\"dou-whiteboard-node__text dou-whiteboard-node__field\"\n :aria-label=\"ctx.messages.value.board.editText\"\n @keydown=\"onKeydown\"\n @blur=\"finish\"\n @pointerdown.stop\n />\n <div\n v-else-if=\"writable\"\n ref=\"textEl\"\n class=\"dou-whiteboard-node__text\"\n :style=\"textStyle\"\n v-text=\"data.text\"\n />\n <div v-if=\"kind !== 'ink'\" class=\"dou-whiteboard-node__anchors\">\n <template v-for=\"side in anchorSides\" :key=\"side\">\n <DouFlowPort :id=\"`${side}-in`\" class=\"dou-whiteboard-node__anchor\" />\n <DouFlowPort :id=\"side\" class=\"dou-whiteboard-node__anchor\" />\n </template>\n </div>\n <template v-if=\"handles\">\n <!-- the sides stay on the node, under its anchors; the turn and the\n corners go above every node, so a neighbour never covers them -->\n <span\n v-for=\"handle in sideHandles\"\n :key=\"`${handle.x},${handle.y}`\"\n :class=\"['dou-whiteboard-node__side', handle.x ? 'is-x' : 'is-y']\"\n :style=\"{ left: place(handle.x), top: place(handle.y), cursor: cursorOf(handle) }\"\n :data-handle=\"`${handle.x},${handle.y}`\"\n data-dou-nodrag\n aria-hidden=\"true\"\n @pointerdown=\"onResize($event, handle)\"\n />\n <Teleport :to=\"state.handles.value\" :disabled=\"!state.handles.value\">\n <div class=\"dou-whiteboard-node__frame\" :style=\"frameStyle\" aria-hidden=\"true\">\n <!-- data-flow-overlay on its target: the selection's toolbar keeps\n clear of where a finger can take it, when it floats below the\n node or the node is turned upside down -->\n <span\n class=\"dou-whiteboard-node__turn\"\n data-flow-handle\n data-dou-nodrag\n @pointerdown=\"startTurn\"\n >\n <span class=\"dou-whiteboard-node__target\" data-flow-overlay />\n </span>\n <span\n v-for=\"handle in cornerHandles\"\n :key=\"`${handle.x},${handle.y}`\"\n :class=\"[\n 'dou-whiteboard-node__corner',\n handle.x < 0 ? 'is-left' : 'is-right',\n handle.y < 0 ? 'is-top' : 'is-bottom',\n ]\"\n :style=\"{ left: place(handle.x), top: place(handle.y), cursor: cursorOf(handle) }\"\n :data-handle=\"`${handle.x},${handle.y}`\"\n data-flow-handle\n data-dou-nodrag\n @pointerdown=\"onResize($event, handle)\"\n />\n </div>\n </Teleport>\n </template>\n </div>\n</template>\n"],"mappings":""}
@@ -1,5 +1,6 @@
1
1
  import { useFlowEditor } from "../context.js";
2
2
  import { DouFlowPort } from "../components/port.js";
3
+ import { isNoneColor, resolveFillColor, resolveStrokeColor, resolveTextColor } from "./colors.js";
3
4
  import { fitInk, inkOutline, unpack } from "./ink.js";
4
5
  import { anchorSides } from "./model.js";
5
6
  import { boardState } from "./state.js";
@@ -8,7 +9,12 @@ import { Fragment, Teleport, computed, createBlock, createCommentVNode, createEl
8
9
  import { ImageOffIcon } from "@dou-ui/icons";
9
10
  // src/whiteboard/board-node.vue?vue&type=script&setup=true&lang.ts
10
11
  var _hoisted_1 = ["viewBox"];
11
- var _hoisted_2 = ["width", "height"];
12
+ var _hoisted_2 = [
13
+ "x",
14
+ "y",
15
+ "width",
16
+ "height"
17
+ ];
12
18
  var _hoisted_3 = [
13
19
  "cx",
14
20
  "cy",
@@ -53,6 +59,33 @@ var board_node_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
53
59
  const kind = computed(() => KINDS.find((k) => k === props.node.type) ?? "shape");
54
60
  const shape = computed(() => props.data.shape ?? "rect");
55
61
  const tone = computed(() => props.data.tone ?? (kind.value === "sticky" ? "warning" : "neutral"));
62
+ const borderless = computed(() => kind.value === "shape" && isNoneColor(props.data.stroke));
63
+ const transparentSticky = computed(() => kind.value === "sticky" && isNoneColor(props.data.fill));
64
+ const colorStyle = computed(() => {
65
+ const vars = {};
66
+ if (kind.value === "shape") {
67
+ const fill = resolveFillColor(props.data.fill, "shape");
68
+ if (fill) vars["--dou-whiteboard-shape-fill"] = fill;
69
+ if (!borderless.value) {
70
+ const stroke = resolveStrokeColor(props.data.stroke);
71
+ if (stroke && stroke !== "none") vars["--dou-whiteboard-shape-stroke"] = stroke;
72
+ }
73
+ const textColor = resolveTextColor(props.data.textColor);
74
+ if (textColor) vars["--dou-whiteboard-text-color"] = textColor;
75
+ } else if (kind.value === "sticky") {
76
+ const fill = resolveFillColor(props.data.fill, "sticky");
77
+ if (fill) vars["--dou-whiteboard-sticky-fill"] = fill === "none" ? "transparent" : fill;
78
+ const textColor = resolveTextColor(props.data.textColor);
79
+ if (textColor) vars["--dou-whiteboard-text-color"] = textColor;
80
+ } else if (kind.value === "text") {
81
+ const textColor = resolveTextColor(props.data.color);
82
+ if (textColor) vars["--dou-whiteboard-text-color"] = textColor;
83
+ } else if (kind.value === "ink") {
84
+ const stroke = resolveStrokeColor(props.data.color);
85
+ if (stroke && stroke !== "none") vars["--dou-whiteboard-ink-color"] = stroke;
86
+ }
87
+ return vars;
88
+ });
56
89
  const writable = computed(() => [
57
90
  "shape",
58
91
  "sticky",
@@ -140,9 +173,10 @@ var board_node_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
140
173
  w: props.node.width ?? 160,
141
174
  h: props.node.height ?? 100
142
175
  }));
176
+ const shapeInset = computed(() => borderless.value ? 0 : .75);
143
177
  const diamond = computed(() => {
144
178
  const { w, h } = shown.value;
145
- const i = 1;
179
+ const i = borderless.value ? 0 : 1;
146
180
  return `${w / 2},${i} ${w - i},${h / 2} ${w / 2},${h - i} ${i},${h / 2}`;
147
181
  });
148
182
  const textEl = useTemplateRef("textEl");
@@ -216,10 +250,16 @@ var board_node_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
216
250
  "is-turned": !!rotation.value,
217
251
  "is-turning": unref(turning) !== null,
218
252
  "is-selected": __props.selected,
219
- "is-erasing": erasing.value
253
+ "is-erasing": erasing.value,
254
+ "is-borderless": borderless.value,
255
+ "is-transparent": transparentSticky.value
220
256
  }
221
257
  ]]),
222
- style: normalizeStyle([transform.value, sizeStyle.value]),
258
+ style: normalizeStyle([
259
+ transform.value,
260
+ sizeStyle.value,
261
+ colorStyle.value
262
+ ]),
223
263
  onDblclick: withModifiers(edit, ["stop"])
224
264
  }, [
225
265
  kind.value === "shape" ? (openBlock(), createElementBlock("svg", {
@@ -229,17 +269,17 @@ var board_node_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
229
269
  "aria-hidden": "true"
230
270
  }, [shape.value === "rect" ? (openBlock(), createElementBlock("rect", {
231
271
  key: 0,
232
- x: "0.75",
233
- y: "0.75",
234
- width: Math.max(0, shown.value.w - 1.5),
235
- height: Math.max(0, shown.value.h - 1.5),
272
+ x: shapeInset.value,
273
+ y: shapeInset.value,
274
+ width: Math.max(0, shown.value.w - shapeInset.value * 2),
275
+ height: Math.max(0, shown.value.h - shapeInset.value * 2),
236
276
  rx: "8"
237
277
  }, null, 8, _hoisted_2)) : shape.value === "ellipse" ? (openBlock(), createElementBlock("ellipse", {
238
278
  key: 1,
239
279
  cx: shown.value.w / 2,
240
280
  cy: shown.value.h / 2,
241
- rx: Math.max(0, shown.value.w / 2 - .75),
242
- ry: Math.max(0, shown.value.h / 2 - .75)
281
+ rx: Math.max(0, shown.value.w / 2 - shapeInset.value),
282
+ ry: Math.max(0, shown.value.h / 2 - shapeInset.value)
243
283
  }, null, 8, _hoisted_3)) : (openBlock(), createElementBlock("polygon", {
244
284
  key: 2,
245
285
  points: diamond.value
@@ -1 +1 @@
1
- {"version":3,"file":"board-node.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_normalizeClass","_unref","_normalizeStyle","_withModifiers","_createElementVNode","_createVNode","_createCommentVNode","_withDirectives","_vModelText","_toDisplayString","_Fragment","_renderList","_createBlock","_Teleport"],"sources":["../../src/whiteboard/board-node.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ImageOffIcon } from '@dou-ui/icons'\nimport { computed, nextTick, ref, toRef, useTemplateRef, watch } from 'vue'\nimport { DouFlowPort } from '../components/port'\nimport { useFlowEditor } from '../context'\nimport type { NodeViewProps } from '../core/node-types'\nimport type { Tone } from 'dou-ui'\nimport { fitInk, inkOutline, INK_SIZE, unpack } from './ink'\nimport { anchorSides, type WhiteboardShape } from './model'\nimport { boardState } from './state'\nimport { RESIZE_HANDLES, useTransformHandles, type ResizeHandle } from './transform'\n\ntype BoardData = {\n [key: string]: unknown\n text?: string\n shape?: WhiteboardShape\n tone?: Tone\n rotation?: number\n points?: number[]\n box?: [number, number]\n size?: number\n src?: string\n alt?: string\n}\n\ntype Kind = 'shape' | 'sticky' | 'text' | 'ink' | 'image'\n\nconst props = defineProps<NodeViewProps<BoardData>>()\nconst ctx = useFlowEditor()\nconst state = boardState(ctx)\n\nconst KINDS: readonly Kind[] = ['sticky', 'text', 'ink', 'image']\n/** What the node is: one of the shapes, a note, text, a pen stroke or an image. */\nconst kind = computed<Kind>(() => KINDS.find((k) => k === props.node.type) ?? 'shape')\nconst shape = computed<WhiteboardShape>(() => props.data.shape ?? 'rect')\nconst tone = computed<Tone>(\n () => props.data.tone ?? (kind.value === 'sticky' ? 'warning' : 'neutral'),\n)\nconst writable = computed(() => ['shape', 'sticky', 'text'].includes(kind.value))\n\nconst MIN: Record<Kind, number> = { shape: 24, sticky: 64, text: 40, ink: 8, image: 24 }\nconst rotation = computed(() => props.data.rotation ?? 0)\nconst { turning, startTurn, startResize } = useTransformHandles(\n ctx,\n toRef(props, 'node'),\n rotation,\n { width: MIN[kind.value], height: MIN[kind.value] },\n)\n/*\n * A handle being dragged shows the node changed through the editor, so\n * `node` and `data` already are what it is dragged to: the node's own frame,\n * its ports and its edges follow along with it.\n */\nconst transform = computed(() => (rotation.value ? { rotate: `${rotation.value}deg` } : undefined))\n/**\n * The resize handles: an image keeps its proportions, from its corners; text\n * only widens, so it has no top or bottom side; the rest has every corner\n * and side.\n */\nconst resizeHandles = computed(() =>\n kind.value === 'image'\n ? RESIZE_HANDLES.filter((h) => h.x && h.y)\n : kind.value === 'text'\n ? RESIZE_HANDLES.filter((h) => h.x)\n : RESIZE_HANDLES,\n)\nconst sideHandles = computed(() => resizeHandles.value.filter((h) => !h.x || !h.y))\nconst cornerHandles = computed(() => resizeHandles.value.filter((h) => h.x && h.y))\nconst rect = computed(\n () => ctx.getNodeRect(props.node.id) ?? { ...props.node, width: 0, height: 0 },\n)\n/**\n * The node's size, for the anchors and the corner handles to share the\n * corners of a small node: each keeps short of the other.\n */\nconst sizeStyle = computed(() => ({\n '--dou-whiteboard-frame-width': `${rect.value.width}px`,\n '--dou-whiteboard-frame-height': `${rect.value.height}px`,\n}))\n/** The node's box, turned with it, for the handles drawn above every node. */\nconst frameStyle = computed(() => {\n const box = rect.value\n return {\n // `translate`, not `transform`: it applies before `rotate`, so the box\n // turns about its own centre and its offset is not turned with it\n translate: `${box.x}px ${box.y}px`,\n width: `${box.width}px`,\n height: `${box.height}px`,\n ...sizeStyle.value,\n rotate: rotation.value ? `${rotation.value}deg` : undefined,\n }\n})\nconst CURSORS = ['ew-resize', 'nwse-resize', 'ns-resize', 'nesw-resize'] as const\n/** The resize cursor along a handle's way out, turned with the node. */\nfunction cursorOf(handle: ResizeHandle) {\n // text only widens, from a corner too\n if (kind.value === 'text') handle = { x: handle.x, y: 0 }\n const degrees = (Math.atan2(handle.y, handle.x) * 180) / Math.PI + rotation.value\n return CURSORS[((Math.round(degrees / 45) % 4) + 4) % 4]\n}\nfunction onResize(event: PointerEvent, handle: ResizeHandle) {\n startResize(event, handle, {\n keepRatio: kind.value === 'image',\n widthOnly: kind.value === 'text',\n })\n}\n/** Where a handle sits on the box: `-1` is the start, `1` the end. */\nconst place = (v: -1 | 0 | 1) => `${(v + 1) * 50}%`\n\n/** Handles show on the one selected node, while the select tool is in hand. */\nconst handles = computed(\n () =>\n props.selected &&\n !props.readonly &&\n !editing.value &&\n state.tool.value === 'select' &&\n ctx.selection.value.nodes.length === 1,\n)\n\n/** The stroke fitted to the box shown, so stretching it keeps its thickness. */\nconst ink = computed(() => {\n const { points, box: inkBox } = props.data\n if (kind.value !== 'ink' || !points || !inkBox) return ''\n const size = props.data.size ?? INK_SIZE\n return inkOutline(fitInk(unpack(points), inkBox, shown.value.w, shown.value.h, size), size)\n})\nconst erasing = computed(() => state.erasing.value.has(props.node.id))\n\n// drawn in the node's own units, half the 1.5px stroke in from the edge\nconst shown = computed(() => ({ w: props.node.width ?? 160, h: props.node.height ?? 100 }))\nconst diamond = computed(() => {\n const { w, h } = shown.value\n const i = 1\n return `${w / 2},${i} ${w - i},${h / 2} ${w / 2},${h - i} ${i},${h / 2}`\n})\n\n// Whole lines that fit, the last one ending in an ellipsis, as an export draws them.\nconst textEl = useTemplateRef<HTMLElement>('textEl')\nconst textMetrics = ref<{ line: number; padding: number } | null>(null)\nwatch(\n textEl,\n (el) => {\n if (!el) return\n const s = getComputedStyle(el)\n const line = Number.parseFloat(s.lineHeight)\n if (!line) return\n const padding = Number.parseFloat(s.paddingTop) + Number.parseFloat(s.paddingBottom)\n textMetrics.value = { line, padding: padding || 0 }\n },\n { flush: 'post' },\n)\nconst textStyle = computed(() => {\n const m = textMetrics.value\n if (!m || kind.value === 'text') return undefined\n const height = shown.value.h\n return { '-webkit-line-clamp': Math.max(1, Math.floor((height - m.padding + 0.5) / m.line)) }\n})\n\n// An image that can't be loaded: a plain box with a sign, as an export draws it.\nconst broken = ref(false)\nwatch(\n () => props.data.src,\n () => (broken.value = false),\n)\n\nconst editing = computed(() => state.editing.value === props.node.id)\nconst draft = ref('')\nconst field = useTemplateRef<HTMLTextAreaElement>('field')\n\nwatch(\n editing,\n (on) => {\n if (!on) return\n draft.value = props.data.text ?? ''\n void nextTick(() => {\n fit()\n field.value?.focus()\n field.value?.select()\n })\n },\n { immediate: true },\n)\n\n// browsers without `field-sizing` grow the field by hand\nfunction fit() {\n const el = field.value\n if (!el || CSS.supports?.('field-sizing', 'content')) return\n el.style.height = 'auto'\n el.style.height = `${el.scrollHeight}px`\n}\nwatch(draft, () => void nextTick(fit))\n\nfunction edit() {\n if (props.readonly || !writable.value) return\n state.editing.value = props.node.id\n}\n\nfunction finish() {\n if (!editing.value) return\n state.editing.value = null\n const text = draft.value.replace(/\\s+$/, '')\n // text with nothing written in it is nothing at all\n if (!text && kind.value === 'text') ctx.transact((tr) => tr.removeNode(props.node.id))\n else if (text !== (props.data.text ?? '')) props.updateData({ text: text || undefined })\n // back to the canvas, so the keys go on working\n ctx.root.value?.focus({ preventScroll: true })\n}\n\nfunction onKeydown(event: KeyboardEvent) {\n if (event.isComposing) return\n // Escape, or mod+Enter, puts the text down; Enter is a new line\n if (event.key === 'Escape' || (event.key === 'Enter' && (event.metaKey || event.ctrlKey))) {\n event.preventDefault()\n event.stopPropagation()\n finish()\n }\n}\n</script>\n\n<template>\n <div\n class=\"dou-whiteboard-node\"\n :class=\"[\n `is-${kind}`,\n kind === 'shape' && `is-${shape}`,\n `is-${tone}`,\n {\n 'is-editing': editing,\n 'is-turned': !!rotation,\n 'is-turning': turning !== null,\n 'is-selected': selected,\n 'is-erasing': erasing,\n },\n ]\"\n :style=\"[transform, sizeStyle]\"\n @dblclick.stop=\"edit\"\n >\n <svg\n v-if=\"kind === 'shape'\"\n class=\"dou-whiteboard-node__shape\"\n :viewBox=\"`0 0 ${shown.w} ${shown.h}`\"\n aria-hidden=\"true\"\n >\n <rect\n v-if=\"shape === 'rect'\"\n x=\"0.75\"\n y=\"0.75\"\n :width=\"Math.max(0, shown.w - 1.5)\"\n :height=\"Math.max(0, shown.h - 1.5)\"\n rx=\"8\"\n />\n <ellipse\n v-else-if=\"shape === 'ellipse'\"\n :cx=\"shown.w / 2\"\n :cy=\"shown.h / 2\"\n :rx=\"Math.max(0, shown.w / 2 - 0.75)\"\n :ry=\"Math.max(0, shown.h / 2 - 0.75)\"\n />\n <polygon v-else :points=\"diamond\" />\n </svg>\n <svg\n v-else-if=\"kind === 'ink' && data.box\"\n class=\"dou-whiteboard-node__ink\"\n :viewBox=\"`0 0 ${shown.w} ${shown.h}`\"\n aria-hidden=\"true\"\n >\n <path class=\"dou-whiteboard-node__ink-hit\" :d=\"ink\" />\n <path :d=\"ink\" />\n </svg>\n <div\n v-else-if=\"kind === 'image' && broken\"\n class=\"dou-whiteboard-node__image is-broken\"\n role=\"img\"\n :aria-label=\"data.alt || undefined\"\n >\n <ImageOffIcon />\n </div>\n <img\n v-else-if=\"kind === 'image'\"\n class=\"dou-whiteboard-node__image\"\n :src=\"data.src\"\n :alt=\"data.alt ?? ''\"\n draggable=\"false\"\n @error=\"broken = true\"\n />\n <textarea\n v-if=\"editing\"\n ref=\"field\"\n v-model=\"draft\"\n class=\"dou-whiteboard-node__text dou-whiteboard-node__field\"\n :aria-label=\"ctx.messages.value.board.editText\"\n @keydown=\"onKeydown\"\n @blur=\"finish\"\n @pointerdown.stop\n />\n <div\n v-else-if=\"writable\"\n ref=\"textEl\"\n class=\"dou-whiteboard-node__text\"\n :style=\"textStyle\"\n v-text=\"data.text\"\n />\n <div v-if=\"kind !== 'ink'\" class=\"dou-whiteboard-node__anchors\">\n <template v-for=\"side in anchorSides\" :key=\"side\">\n <DouFlowPort :id=\"`${side}-in`\" class=\"dou-whiteboard-node__anchor\" />\n <DouFlowPort :id=\"side\" class=\"dou-whiteboard-node__anchor\" />\n </template>\n </div>\n <template v-if=\"handles\">\n <!-- the sides stay on the node, under its anchors; the turn and the\n corners go above every node, so a neighbour never covers them -->\n <span\n v-for=\"handle in sideHandles\"\n :key=\"`${handle.x},${handle.y}`\"\n :class=\"['dou-whiteboard-node__side', handle.x ? 'is-x' : 'is-y']\"\n :style=\"{ left: place(handle.x), top: place(handle.y), cursor: cursorOf(handle) }\"\n :data-handle=\"`${handle.x},${handle.y}`\"\n data-dou-nodrag\n aria-hidden=\"true\"\n @pointerdown=\"onResize($event, handle)\"\n />\n <Teleport :to=\"state.handles.value\" :disabled=\"!state.handles.value\">\n <div class=\"dou-whiteboard-node__frame\" :style=\"frameStyle\" aria-hidden=\"true\">\n <!-- data-flow-overlay on its target: the selection's toolbar keeps\n clear of where a finger can take it, when it floats below the\n node or the node is turned upside down -->\n <span\n class=\"dou-whiteboard-node__turn\"\n data-flow-handle\n data-dou-nodrag\n @pointerdown=\"startTurn\"\n >\n <span class=\"dou-whiteboard-node__target\" data-flow-overlay />\n </span>\n <span\n v-for=\"handle in cornerHandles\"\n :key=\"`${handle.x},${handle.y}`\"\n :class=\"[\n 'dou-whiteboard-node__corner',\n handle.x < 0 ? 'is-left' : 'is-right',\n handle.y < 0 ? 'is-top' : 'is-bottom',\n ]\"\n :style=\"{ left: place(handle.x), top: place(handle.y), cursor: cursorOf(handle) }\"\n :data-handle=\"`${handle.x},${handle.y}`\"\n data-flow-handle\n data-dou-nodrag\n @pointerdown=\"onResize($event, handle)\"\n />\n </div>\n </Teleport>\n </template>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BA,MAAM,QAAQ;EACd,MAAM,MAAM,cAAc;EAC1B,MAAM,QAAQ,WAAW,GAAG;EAE5B,MAAM,QAAyB;GAAC;GAAU;GAAQ;GAAO;EAAO;;EAEhE,MAAM,OAAO,eAAqB,MAAM,MAAM,MAAM,MAAM,MAAM,KAAK,IAAI,KAAK,OAAO;EACrF,MAAM,QAAQ,eAAgC,MAAM,KAAK,SAAS,MAAM;EACxE,MAAM,OAAO,eACL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M;MAAA,CAAA;MAC7E,eAAW,GAAK,OAAO,EAAC,GAAI,OAAO;MACpC,mBAAA;MACA,eAAY;MACX,gBAAW,WAAE,SAAS,QAAQ,MAAM;;I,YAEvCJ,UAAA,GAAAc,YA4BWC,UAAA;KA5BA,IAAIZ,MAAA,KAAA,CAAK,CAAC,QAAQ;KAAQ,UAAQ,CAAGA,MAAA,KAAA,CAAK,CAAC,QAAQ;I,IAC5DG,mBA0BM,OAAA;KA1BD,OAAM;KAA8B,OAAKF,eAAE,WAAA,KAAU;KAAE,eAAY;I,IAItEE,mBAOO,QAAA;KANL,OAAM;KACN,oBAAA;KACA,mBAAA;KACC,eAAW,OAAA,OAAA,OAAA,MAAE,GAAA,SAAAH,MAAA,SAAA,KAAAA,MAAA,SAAA,CAAA,CAAA,GAAA,IAAA;I,kCAEdG,mBAA8D,QAAA;KAAxD,OAAM;KAA8B,qBAAA;I,uBAE5CN,UAAA,IAAA,GAAAC,mBAaEW,UAAA,MAAAC,WAZiB,cAAA,QAAV,WAAM;KADf,OAAAb,UAAA,GAAAC,mBAaE,QAAA;MAXC,KAAG,GAAK,OAAO,EAAC,GAAI,OAAO;MAC3B,OAAKC,eAAA;;OAA+D,OAAO,IAAC,IAAA,YAAA;OAA6C,OAAO,IAAC,IAAA,WAAA;;MAKjI,OAAKE,eAAA;OAAA,MAAU,MAAM,OAAO,CAAC;OAAA,KAAQ,MAAM,OAAO,CAAC;OAAA,QAAW,SAAS,MAAM;MAAA,CAAA;MAC7E,eAAW,GAAK,OAAO,EAAC,GAAI,OAAO;MACpC,oBAAA;MACA,mBAAA;MACC,gBAAW,WAAE,SAAS,QAAQ,MAAM"}
1
+ {"version":3,"file":"board-node.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_normalizeClass","_unref","_normalizeStyle","_withModifiers","_createElementVNode","_createVNode","_createCommentVNode","_withDirectives","_vModelText","_toDisplayString","_Fragment","_renderList","_createBlock","_Teleport"],"sources":["../../src/whiteboard/board-node.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ImageOffIcon } from '@dou-ui/icons'\nimport { computed, nextTick, ref, toRef, useTemplateRef, watch } from 'vue'\nimport { DouFlowPort } from '../components/port'\nimport { useFlowEditor } from '../context'\nimport type { NodeViewProps } from '../core/node-types'\nimport type { Tone } from 'dou-ui'\nimport {\n isNoneColor,\n resolveFillColor,\n resolveStrokeColor,\n resolveTextColor,\n type WhiteboardColor,\n type WhiteboardFill,\n type WhiteboardStroke,\n} from './colors'\nimport { fitInk, inkOutline, INK_SIZE, unpack } from './ink'\nimport { anchorSides, type WhiteboardShape } from './model'\nimport { boardState } from './state'\nimport { RESIZE_HANDLES, useTransformHandles, type ResizeHandle } from './transform'\n\ntype BoardData = {\n [key: string]: unknown\n text?: string\n shape?: WhiteboardShape\n tone?: Tone\n fill?: WhiteboardFill\n stroke?: WhiteboardStroke\n textColor?: WhiteboardColor\n color?: WhiteboardColor\n rotation?: number\n points?: number[]\n box?: [number, number]\n size?: number\n src?: string\n alt?: string\n}\n\ntype Kind = 'shape' | 'sticky' | 'text' | 'ink' | 'image'\n\nconst props = defineProps<NodeViewProps<BoardData>>()\nconst ctx = useFlowEditor()\nconst state = boardState(ctx)\n\nconst KINDS: readonly Kind[] = ['sticky', 'text', 'ink', 'image']\n/** What the node is: one of the shapes, a note, text, a pen stroke or an image. */\nconst kind = computed<Kind>(() => KINDS.find((k) => k === props.node.type) ?? 'shape')\nconst shape = computed<WhiteboardShape>(() => props.data.shape ?? 'rect')\nconst tone = computed<Tone>(\n () => props.data.tone ?? (kind.value === 'sticky' ? 'warning' : 'neutral'),\n)\nconst borderless = computed(() => kind.value === 'shape' && isNoneColor(props.data.stroke))\nconst transparentSticky = computed(() => kind.value === 'sticky' && isNoneColor(props.data.fill))\nconst colorStyle = computed(() => {\n const vars: Record<string, string> = {}\n if (kind.value === 'shape') {\n const fill = resolveFillColor(props.data.fill, 'shape')\n if (fill) vars['--dou-whiteboard-shape-fill'] = fill\n if (!borderless.value) {\n const stroke = resolveStrokeColor(props.data.stroke)\n if (stroke && stroke !== 'none') vars['--dou-whiteboard-shape-stroke'] = stroke\n }\n const textColor = resolveTextColor(props.data.textColor)\n if (textColor) vars['--dou-whiteboard-text-color'] = textColor\n } else if (kind.value === 'sticky') {\n const fill = resolveFillColor(props.data.fill, 'sticky')\n if (fill) vars['--dou-whiteboard-sticky-fill'] = fill === 'none' ? 'transparent' : fill\n const textColor = resolveTextColor(props.data.textColor)\n if (textColor) vars['--dou-whiteboard-text-color'] = textColor\n } else if (kind.value === 'text') {\n const textColor = resolveTextColor(props.data.color)\n if (textColor) vars['--dou-whiteboard-text-color'] = textColor\n } else if (kind.value === 'ink') {\n const stroke = resolveStrokeColor(props.data.color)\n if (stroke && stroke !== 'none') vars['--dou-whiteboard-ink-color'] = stroke\n }\n return vars\n})\nconst writable = computed(() => ['shape', 'sticky', 'text'].includes(kind.value))\n\nconst MIN: Record<Kind, number> = { shape: 24, sticky: 64, text: 40, ink: 8, image: 24 }\nconst rotation = computed(() => props.data.rotation ?? 0)\nconst { turning, startTurn, startResize } = useTransformHandles(\n ctx,\n toRef(props, 'node'),\n rotation,\n { width: MIN[kind.value], height: MIN[kind.value] },\n)\n/*\n * A handle being dragged shows the node changed through the editor, so\n * `node` and `data` already are what it is dragged to: the node's own frame,\n * its ports and its edges follow along with it.\n */\nconst transform = computed(() => (rotation.value ? { rotate: `${rotation.value}deg` } : undefined))\n/**\n * The resize handles: an image keeps its proportions, from its corners; text\n * only widens, so it has no top or bottom side; the rest has every corner\n * and side.\n */\nconst resizeHandles = computed(() =>\n kind.value === 'image'\n ? RESIZE_HANDLES.filter((h) => h.x && h.y)\n : kind.value === 'text'\n ? RESIZE_HANDLES.filter((h) => h.x)\n : RESIZE_HANDLES,\n)\nconst sideHandles = computed(() => resizeHandles.value.filter((h) => !h.x || !h.y))\nconst cornerHandles = computed(() => resizeHandles.value.filter((h) => h.x && h.y))\nconst rect = computed(\n () => ctx.getNodeRect(props.node.id) ?? { ...props.node, width: 0, height: 0 },\n)\n/**\n * The node's size, for the anchors and the corner handles to share the\n * corners of a small node: each keeps short of the other.\n */\nconst sizeStyle = computed(() => ({\n '--dou-whiteboard-frame-width': `${rect.value.width}px`,\n '--dou-whiteboard-frame-height': `${rect.value.height}px`,\n}))\n/** The node's box, turned with it, for the handles drawn above every node. */\nconst frameStyle = computed(() => {\n const box = rect.value\n return {\n // `translate`, not `transform`: it applies before `rotate`, so the box\n // turns about its own centre and its offset is not turned with it\n translate: `${box.x}px ${box.y}px`,\n width: `${box.width}px`,\n height: `${box.height}px`,\n ...sizeStyle.value,\n rotate: rotation.value ? `${rotation.value}deg` : undefined,\n }\n})\nconst CURSORS = ['ew-resize', 'nwse-resize', 'ns-resize', 'nesw-resize'] as const\n/** The resize cursor along a handle's way out, turned with the node. */\nfunction cursorOf(handle: ResizeHandle) {\n // text only widens, from a corner too\n if (kind.value === 'text') handle = { x: handle.x, y: 0 }\n const degrees = (Math.atan2(handle.y, handle.x) * 180) / Math.PI + rotation.value\n return CURSORS[((Math.round(degrees / 45) % 4) + 4) % 4]\n}\nfunction onResize(event: PointerEvent, handle: ResizeHandle) {\n startResize(event, handle, {\n keepRatio: kind.value === 'image',\n widthOnly: kind.value === 'text',\n })\n}\n/** Where a handle sits on the box: `-1` is the start, `1` the end. */\nconst place = (v: -1 | 0 | 1) => `${(v + 1) * 50}%`\n\n/** Handles show on the one selected node, while the select tool is in hand. */\nconst handles = computed(\n () =>\n props.selected &&\n !props.readonly &&\n !editing.value &&\n state.tool.value === 'select' &&\n ctx.selection.value.nodes.length === 1,\n)\n\n/** The stroke fitted to the box shown, so stretching it keeps its thickness. */\nconst ink = computed(() => {\n const { points, box: inkBox } = props.data\n if (kind.value !== 'ink' || !points || !inkBox) return ''\n const size = props.data.size ?? INK_SIZE\n return inkOutline(fitInk(unpack(points), inkBox, shown.value.w, shown.value.h, size), size)\n})\nconst erasing = computed(() => state.erasing.value.has(props.node.id))\n\n// drawn in the node's own units, half the 1.5px stroke in from the edge (0 when borderless)\nconst shown = computed(() => ({ w: props.node.width ?? 160, h: props.node.height ?? 100 }))\nconst shapeInset = computed(() => (borderless.value ? 0 : 0.75))\nconst diamond = computed(() => {\n const { w, h } = shown.value\n const i = borderless.value ? 0 : 1\n return `${w / 2},${i} ${w - i},${h / 2} ${w / 2},${h - i} ${i},${h / 2}`\n})\n\n// Whole lines that fit, the last one ending in an ellipsis, as an export draws them.\nconst textEl = useTemplateRef<HTMLElement>('textEl')\nconst textMetrics = ref<{ line: number; padding: number } | null>(null)\nwatch(\n textEl,\n (el) => {\n if (!el) return\n const s = getComputedStyle(el)\n const line = Number.parseFloat(s.lineHeight)\n if (!line) return\n const padding = Number.parseFloat(s.paddingTop) + Number.parseFloat(s.paddingBottom)\n textMetrics.value = { line, padding: padding || 0 }\n },\n { flush: 'post' },\n)\nconst textStyle = computed(() => {\n const m = textMetrics.value\n if (!m || kind.value === 'text') return undefined\n const height = shown.value.h\n return { '-webkit-line-clamp': Math.max(1, Math.floor((height - m.padding + 0.5) / m.line)) }\n})\n\n// An image that can't be loaded: a plain box with a sign, as an export draws it.\nconst broken = ref(false)\nwatch(\n () => props.data.src,\n () => (broken.value = false),\n)\n\nconst editing = computed(() => state.editing.value === props.node.id)\nconst draft = ref('')\nconst field = useTemplateRef<HTMLTextAreaElement>('field')\n\nwatch(\n editing,\n (on) => {\n if (!on) return\n draft.value = props.data.text ?? ''\n void nextTick(() => {\n fit()\n field.value?.focus()\n field.value?.select()\n })\n },\n { immediate: true },\n)\n\n// browsers without `field-sizing` grow the field by hand\nfunction fit() {\n const el = field.value\n if (!el || CSS.supports?.('field-sizing', 'content')) return\n el.style.height = 'auto'\n el.style.height = `${el.scrollHeight}px`\n}\nwatch(draft, () => void nextTick(fit))\n\nfunction edit() {\n if (props.readonly || !writable.value) return\n state.editing.value = props.node.id\n}\n\nfunction finish() {\n if (!editing.value) return\n state.editing.value = null\n const text = draft.value.replace(/\\s+$/, '')\n // text with nothing written in it is nothing at all\n if (!text && kind.value === 'text') ctx.transact((tr) => tr.removeNode(props.node.id))\n else if (text !== (props.data.text ?? '')) props.updateData({ text: text || undefined })\n // back to the canvas, so the keys go on working\n ctx.root.value?.focus({ preventScroll: true })\n}\n\nfunction onKeydown(event: KeyboardEvent) {\n if (event.isComposing) return\n // Escape, or mod+Enter, puts the text down; Enter is a new line\n if (event.key === 'Escape' || (event.key === 'Enter' && (event.metaKey || event.ctrlKey))) {\n event.preventDefault()\n event.stopPropagation()\n finish()\n }\n}\n</script>\n\n<template>\n <div\n class=\"dou-whiteboard-node\"\n :class=\"[\n `is-${kind}`,\n kind === 'shape' && `is-${shape}`,\n `is-${tone}`,\n {\n 'is-editing': editing,\n 'is-turned': !!rotation,\n 'is-turning': turning !== null,\n 'is-selected': selected,\n 'is-erasing': erasing,\n 'is-borderless': borderless,\n 'is-transparent': transparentSticky,\n },\n ]\"\n :style=\"[transform, sizeStyle, colorStyle]\"\n @dblclick.stop=\"edit\"\n >\n <svg\n v-if=\"kind === 'shape'\"\n class=\"dou-whiteboard-node__shape\"\n :viewBox=\"`0 0 ${shown.w} ${shown.h}`\"\n aria-hidden=\"true\"\n >\n <rect\n v-if=\"shape === 'rect'\"\n :x=\"shapeInset\"\n :y=\"shapeInset\"\n :width=\"Math.max(0, shown.w - shapeInset * 2)\"\n :height=\"Math.max(0, shown.h - shapeInset * 2)\"\n rx=\"8\"\n />\n <ellipse\n v-else-if=\"shape === 'ellipse'\"\n :cx=\"shown.w / 2\"\n :cy=\"shown.h / 2\"\n :rx=\"Math.max(0, shown.w / 2 - shapeInset)\"\n :ry=\"Math.max(0, shown.h / 2 - shapeInset)\"\n />\n <polygon v-else :points=\"diamond\" />\n </svg>\n <svg\n v-else-if=\"kind === 'ink' && data.box\"\n class=\"dou-whiteboard-node__ink\"\n :viewBox=\"`0 0 ${shown.w} ${shown.h}`\"\n aria-hidden=\"true\"\n >\n <path class=\"dou-whiteboard-node__ink-hit\" :d=\"ink\" />\n <path :d=\"ink\" />\n </svg>\n <div\n v-else-if=\"kind === 'image' && broken\"\n class=\"dou-whiteboard-node__image is-broken\"\n role=\"img\"\n :aria-label=\"data.alt || undefined\"\n >\n <ImageOffIcon />\n </div>\n <img\n v-else-if=\"kind === 'image'\"\n class=\"dou-whiteboard-node__image\"\n :src=\"data.src\"\n :alt=\"data.alt ?? ''\"\n draggable=\"false\"\n @error=\"broken = true\"\n />\n <textarea\n v-if=\"editing\"\n ref=\"field\"\n v-model=\"draft\"\n class=\"dou-whiteboard-node__text dou-whiteboard-node__field\"\n :aria-label=\"ctx.messages.value.board.editText\"\n @keydown=\"onKeydown\"\n @blur=\"finish\"\n @pointerdown.stop\n />\n <div\n v-else-if=\"writable\"\n ref=\"textEl\"\n class=\"dou-whiteboard-node__text\"\n :style=\"textStyle\"\n v-text=\"data.text\"\n />\n <div v-if=\"kind !== 'ink'\" class=\"dou-whiteboard-node__anchors\">\n <template v-for=\"side in anchorSides\" :key=\"side\">\n <DouFlowPort :id=\"`${side}-in`\" class=\"dou-whiteboard-node__anchor\" />\n <DouFlowPort :id=\"side\" class=\"dou-whiteboard-node__anchor\" />\n </template>\n </div>\n <template v-if=\"handles\">\n <!-- the sides stay on the node, under its anchors; the turn and the\n corners go above every node, so a neighbour never covers them -->\n <span\n v-for=\"handle in sideHandles\"\n :key=\"`${handle.x},${handle.y}`\"\n :class=\"['dou-whiteboard-node__side', handle.x ? 'is-x' : 'is-y']\"\n :style=\"{ left: place(handle.x), top: place(handle.y), cursor: cursorOf(handle) }\"\n :data-handle=\"`${handle.x},${handle.y}`\"\n data-dou-nodrag\n aria-hidden=\"true\"\n @pointerdown=\"onResize($event, handle)\"\n />\n <Teleport :to=\"state.handles.value\" :disabled=\"!state.handles.value\">\n <div class=\"dou-whiteboard-node__frame\" :style=\"frameStyle\" aria-hidden=\"true\">\n <!-- data-flow-overlay on its target: the selection's toolbar keeps\n clear of where a finger can take it, when it floats below the\n node or the node is turned upside down -->\n <span\n class=\"dou-whiteboard-node__turn\"\n data-flow-handle\n data-dou-nodrag\n @pointerdown=\"startTurn\"\n >\n <span class=\"dou-whiteboard-node__target\" data-flow-overlay />\n </span>\n <span\n v-for=\"handle in cornerHandles\"\n :key=\"`${handle.x},${handle.y}`\"\n :class=\"[\n 'dou-whiteboard-node__corner',\n handle.x < 0 ? 'is-left' : 'is-right',\n handle.y < 0 ? 'is-top' : 'is-bottom',\n ]\"\n :style=\"{ left: place(handle.x), top: place(handle.y), cursor: cursorOf(handle) }\"\n :data-handle=\"`${handle.x},${handle.y}`\"\n data-flow-handle\n data-dou-nodrag\n @pointerdown=\"onResize($event, handle)\"\n />\n </div>\n </Teleport>\n </template>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwCA,MAAM,QAAQ;EACd,MAAM,MAAM,cAAc;EAC1B,MAAM,QAAQ,WAAW,GAAG;EAE5B,MAAM,QAAyB;GAAC;GAAU;GAAQ;GAAO;EAAO;;EAEhE,MAAM,OAAO,eAAqB,MAAM,MAAM,MAAM,MAAM,MAAM,KAAK,IAAI,KAAK,OAAO;EACrF,MAAM,QAAQ,eAAgC,MAAM,KAAK,SAAS,MAAM;EACxE,MAAM,OAAO,eACL,MAAM,KAAK,SAAS,KAAK,UAAU,WAAW,YAAY,UAClE;EACA,MAAM,aAAa,eAAe,KAAK,UAAU,WAAW,YAAY,MAAM,KAAK,MAAM,CAAC;EAC1F,MAAM,oBAAoB,eAAe,KAAK,UAAU,YAAY,YAAY,MAAM,KAAK,IAAI,CAAC;EAChG,MAAM,aAAa,eAAe;GAChC,MAAM,OAA+B,CAAC;GACtC,IAAI,KAAK,UAAU,SAAS;IAC1B,MAAM,OAAO,iBAAiB,MAAM,KAAK,MAAM,OAAO;IACtD,IAAI,MAAM,KAAK,iCAAiC;IAChD,IAAI,CAAC,WAAW,OAAO;KACrB,MAAM,SAAS,mBAAmB,MAAM,KAAK,MAAM;KACnD,IAAI,UAAU,WAAW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