@dou-ui/flow 0.1.0-alpha.21 → 0.1.0-alpha.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/comments.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { defineFlowExtension } from "./core/extension.js";
2
2
  import { applyCommentAction } from "dou-ui";
3
- import { computed, shallowRef } from "vue";
3
+ import { computed, nextTick, shallowRef, watch } from "vue";
4
4
  import { MessagePlusIcon } from "@dou-ui/icons";
5
5
  // src/comments.ts
6
6
  var KEY = "mod+alt+m";
@@ -25,6 +25,14 @@ var idsOf = (item) => Array.isArray(item.comments) ? item.comments.filter((id) =
25
25
  function useFlowComments(options) {
26
26
  const { props, emit, doc, selection, messages, transact, carry, shownOn } = options;
27
27
  const threads = computed(() => props.comments ?? []);
28
+ let latestThreads = null;
29
+ watch(() => props.comments, () => {
30
+ latestThreads = null;
31
+ }, { flush: "sync" });
32
+ const currentThreads = () => {
33
+ const value = threads.value;
34
+ return latestThreads ?? value;
35
+ };
28
36
  const enabled = computed(() => props.comments !== void 0);
29
37
  const writable = computed(() => enabled.value && !!props.author && props.commentable !== false);
30
38
  const innerActive = shallowRef(null);
@@ -153,11 +161,12 @@ function useFlowComments(options) {
153
161
  if (patch) carry(anchor, patch);
154
162
  }
155
163
  function anchorOf(id) {
156
- const node = doc.value.nodes.find((n) => idsOf(n).includes(id));
164
+ const current = doc.value;
165
+ const node = current.nodes.find((n) => idsOf(n).includes(id));
157
166
  if (node) {
158
167
  const at = pinOf(node, id);
159
168
  if (!at) return { node: node.id };
160
- const known = new Set(threads.value.map((t) => t.id));
169
+ const known = new Set(currentThreads().map((t) => t.id));
161
170
  const pinned = idsOf(node).filter((other) => known.has(other) && pinOf(node, other));
162
171
  return {
163
172
  node: node.id,
@@ -165,7 +174,7 @@ function useFlowComments(options) {
165
174
  number: pinned.indexOf(id) + 1
166
175
  };
167
176
  }
168
- const edge = doc.value.edges.find((e) => idsOf(e).includes(id));
177
+ const edge = current.edges.find((e) => idsOf(e).includes(id));
169
178
  return edge ? { edge: edge.id } : null;
170
179
  }
171
180
  function apply(action) {
@@ -178,7 +187,10 @@ function useFlowComments(options) {
178
187
  const anchor = anchorOf(action.threadId);
179
188
  if (anchor) mark(anchor, action.threadId, false);
180
189
  }
181
- emit("update:comments", applyCommentAction(threads.value, action));
190
+ const next = applyCommentAction(currentThreads(), action);
191
+ if (!latestThreads) nextTick(() => latestThreads = null);
192
+ latestThreads = next;
193
+ emit("update:comments", next);
182
194
  emit("commentAction", action);
183
195
  if (action.type === "create") {
184
196
  open(action.thread.id);
@@ -186,7 +198,7 @@ function useFlowComments(options) {
186
198
  } else if (action.type === "remove" || action.type === "resolve") open(null);
187
199
  }
188
200
  function anchors() {
189
- return Object.fromEntries(threads.value.map((thread) => [thread.id, anchorOf(thread.id)]));
201
+ return Object.fromEntries(currentThreads().map((thread) => [thread.id, anchorOf(thread.id)]));
190
202
  }
191
203
  /** Whether `anchor` has something to offer: a thread to open, or one to start. */
192
204
  const offered = (anchor) => enabled.value && (writable.value || openThere(anchor).length > 0);
@@ -1 +1 @@
1
- {"version":3,"file":"comments.js","names":[],"sources":["../src/comments.ts"],"sourcesContent":["import { MessagePlusIcon } from '@dou-ui/icons'\nimport {\n applyCommentAction,\n type CommentAction,\n type CommentAuthor,\n type CommentThread,\n type ContextMenuItem,\n} from 'dou-ui'\nimport { computed, shallowRef, type ComputedRef, type Ref, type ShallowRef } from 'vue'\nimport type { FlowCommentAnchor, FlowEditorEmits, FlowEditorProps } from './context'\nimport { defineFlowExtension, type FlowExtension } from './core/extension'\nimport type { FlowToolbarItem } from './core/menu'\nimport type { FlowDocument, FlowNode, FlowSelection, Point } from './core/model'\nimport type { FlowTransaction, FlowTransactionMeta } from './core/transaction'\nimport type { FlowMessages } from './locale'\n\ntype Emit = <K extends keyof FlowEditorEmits>(event: K, ...args: FlowEditorEmits[K]) => void\n\n/** The comments, as the editor's parts see them. */\nexport interface FlowComments {\n enabled: ComputedRef<boolean>\n /** Threads can be started and replied to. */\n writable: ComputedRef<boolean>\n threads: ComputedRef<readonly CommentThread[]>\n author: ComputedRef<CommentAuthor | undefined>\n /** The thread open now. */\n active: ComputedRef<string | null>\n /** What a thread being started is about, until its first comment is sent. */\n pending: ShallowRef<FlowCommentAnchor | null>\n /** Whether the reply box of the thread being started takes the focus. */\n pendingFocus: ShallowRef<boolean>\n /** Goes up when the open thread should take the focus, ready for a reply. */\n focusRequest: ShallowRef<number>\n /**\n * The open threads on each node and edge, oldest first; a node's leave\n * out those pinned to a point on it, which are in `pins`.\n */\n openOn: ComputedRef<{\n nodes: Map<string, string[]>\n edges: Map<string, string[]>\n pins: FlowCommentPin[]\n }>\n start: (anchor?: FlowCommentAnchor | null, focus?: boolean) => boolean\n /** Opens a thread, with the focus in its reply box when `focus`. */\n show: (id: string, focus: boolean) => void\n apply: (action: CommentAction) => void\n open: (id: string | null) => void\n close: () => void\n /** Whether this editor opened the thread `id`, rather than the app. */\n openedHere: (id: string | null) => boolean\n}\n\n/** An open thread pinned to a point on a node. */\nexport interface FlowCommentPin {\n thread: string\n node: string\n at: Point\n /** Its number on the node: its place among the node's pins, from 1, oldest first, resolved ones counted. */\n number: number\n}\n\ntype MarkPatch = { comments: string[] | undefined; commentPins?: Record<string, Point> | undefined }\n\nconst KEY = 'mod+alt+m'\n\nconst fraction = (value: unknown) =>\n typeof value === 'number' && Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : null\n\n/** A point within a node, kept between 0 and 1; `null` when it isn't one. */\nexport function pinPoint(at: unknown): Point | null {\n if (!at || typeof at !== 'object') return null\n const x = fraction((at as Point).x)\n const y = fraction((at as Point).y)\n return x === null || y === null ? null : { x, y }\n}\n\n/** Where the thread `id` is pinned on a node, if it is. */\nconst pinOf = (node: FlowNode, id: string): Point | null => {\n const pins = node.commentPins\n return pins && typeof pins === 'object' && Object.hasOwn(pins, id) ? pinPoint(pins[id]) : null\n}\n\n/** The thread ids on a node or edge; nothing when a hand-written document has something else there. */\nconst idsOf = (item: { comments?: unknown }): string[] =>\n Array.isArray(item.comments) ? item.comments.filter((id) => typeof id === 'string') : []\n\nexport function useFlowComments(options: {\n props: FlowEditorProps\n emit: Emit\n doc: ComputedRef<FlowDocument>\n selection: Ref<FlowSelection>\n messages: ComputedRef<FlowMessages>\n transact: (fn: (tr: FlowTransaction) => void, meta?: FlowTransactionMeta) => FlowTransaction\n /** Keeps a change kept out of undo on a node or edge as undo and redo bring it back. */\n carry: (anchor: FlowCommentAnchor, patch: MarkPatch) => void\n /** The open threads a node's marker counts: a collapsed container's take in those inside it. */\n shownOn: (anchor: FlowCommentAnchor) => string[] | undefined\n}) {\n const { props, emit, doc, selection, messages, transact, carry, shownOn } = options\n\n const threads = computed<readonly CommentThread[]>(() => props.comments ?? [])\n const enabled = computed(() => props.comments !== undefined)\n const writable = computed(() => enabled.value && !!props.author && props.commentable !== false)\n\n const innerActive = shallowRef<string | null>(null)\n const active = computed(() =>\n props.activeComment === undefined ? innerActive.value : props.activeComment,\n )\n /** The last thread this editor opened, so a `v-model:activeComment` echoing it isn't taken for one from outside. */\n let ownOpen: string | null = null\n function open(id: string | null) {\n if (id === active.value) return\n innerActive.value = id\n ownOpen = id\n emit('update:activeComment', id)\n }\n const openedHere = (id: string | null) => id === ownOpen\n\n const pending = shallowRef<FlowCommentAnchor | null>(null)\n const pendingFocus = shallowRef(true)\n const focusRequest = shallowRef(0)\n\n const openOn = computed(() => {\n const live = new Set(threads.value.filter((t) => !t.resolved).map((t) => t.id))\n const known = new Set(threads.value.map((t) => t.id))\n const pins: FlowCommentPin[] = []\n const nodes = new Map<string, string[]>()\n for (const node of doc.value.nodes) {\n const ids: string[] = []\n let number = 0\n for (const id of idsOf(node)) {\n const at = pinOf(node, id)\n // numbered among every pin there, so resolving one renumbers none\n if (at && known.has(id)) number++\n if (!live.has(id)) continue\n if (at) pins.push({ thread: id, node: node.id, at, number })\n else ids.push(id)\n }\n if (ids.length) nodes.set(node.id, ids)\n }\n const edges = new Map<string, string[]>()\n for (const edge of doc.value.edges) {\n const ids = idsOf(edge).filter((id) => live.has(id))\n if (ids.length) edges.set(edge.id, ids)\n }\n return { nodes, edges, pins }\n })\n\n const threadsOf = (anchor: FlowCommentAnchor) =>\n ('node' in anchor\n ? openOn.value.nodes.get(anchor.node)\n : openOn.value.edges.get(anchor.edge)) ?? []\n\n /** The open threads on a node or edge, with those its marker shows for what it hides. */\n const openThere = (anchor: FlowCommentAnchor) => shownOn(anchor) ?? threadsOf(anchor)\n\n /** The one node or edge selected. */\n function selected(): FlowCommentAnchor | null {\n const { nodes, edges } = selection.value\n if (nodes.length === 1 && !edges.length) return { node: nodes[0]! }\n if (edges.length === 1 && !nodes.length) return { edge: edges[0]! }\n return null\n }\n\n function show(id: string, focus: boolean) {\n pending.value = null\n open(id)\n if (focus) focusRequest.value++\n }\n\n /**\n * Opens the threads on a node or edge, the selected one by default, or\n * the box to start one there; with `at`, always the box for a new pin.\n * `focus` puts the focus in the reply box: from the keyboard, not from a\n * tap, which would bring up the keyboard on a phone.\n */\n function start(anchor: FlowCommentAnchor | null = selected(), focus = true): boolean {\n if (!enabled.value || !anchor) return false\n if ('node' in anchor && anchor.at !== undefined) {\n const { node } = anchor\n const at = pinPoint(anchor.at)\n if (!at || !writable.value || !doc.value.nodes.some((n) => n.id === node)) return false\n open(null)\n pending.value = { node, at }\n pendingFocus.value = focus\n if (focus) focusRequest.value++\n return true\n }\n anchor = 'node' in anchor ? { node: anchor.node } : { edge: anchor.edge }\n const there =\n 'node' in anchor\n ? doc.value.nodes.some((n) => n.id === anchor.node)\n : doc.value.edges.some((e) => e.id === anchor.edge)\n if (!there) return false\n // one already there, or shown there: open it\n const [first] = openThere(anchor)\n if (first) {\n show(first, focus)\n return true\n }\n if (!writable.value) return false\n open(null)\n pending.value = anchor\n pendingFocus.value = focus\n if (focus) focusRequest.value++\n return true\n }\n\n function close() {\n pending.value = null\n open(null)\n }\n\n /** Adds or takes away a thread's id on what it is about; not an undo step. */\n function mark(anchor: FlowCommentAnchor, id: string, add: boolean) {\n let patch: MarkPatch | null = null\n transact(\n (tr) => {\n const item = 'node' in anchor ? tr.getNode(anchor.node) : tr.getEdge(anchor.edge)\n if (!item) return\n const had = idsOf(item)\n const next = add ? [...had.filter((x) => x !== id), id] : had.filter((x) => x !== id)\n patch = { comments: next.length ? next : undefined }\n if ('node' in anchor) {\n const node = item as FlowNode\n const at = add && anchor.at ? pinPoint(anchor.at) : null\n const pins = { ...node.commentPins }\n delete pins[id]\n if (at) pins[id] = at\n // only touched when there are pins, so a plain thread keeps the node as it was\n if (at || node.commentPins)\n patch.commentPins = Object.keys(pins).length ? pins : undefined\n tr.updateNode(anchor.node, patch)\n } else tr.updateEdge(anchor.edge, patch)\n },\n { history: false, origin: 'comment' },\n )\n if (patch) carry(anchor, patch)\n }\n\n function anchorOf(id: string): FlowCommentAnchor | null {\n const node = doc.value.nodes.find((n) => idsOf(n).includes(id))\n if (node) {\n const at = pinOf(node, id)\n if (!at) return { node: node.id }\n const known = new Set(threads.value.map((t) => t.id))\n const pinned = idsOf(node).filter((other) => known.has(other) && pinOf(node, other))\n return { node: node.id, at, number: pinned.indexOf(id) + 1 }\n }\n const edge = doc.value.edges.find((e) => idsOf(e).includes(id))\n return edge ? { edge: edge.id } : null\n }\n\n function apply(action: CommentAction) {\n if (action.type === 'create') {\n const anchor = pending.value\n if (!anchor) return\n mark(anchor, action.thread.id, true)\n pending.value = null\n } else if (action.type === 'remove') {\n const anchor = anchorOf(action.threadId)\n if (anchor) mark(anchor, action.threadId, false)\n }\n emit('update:comments', applyCommentAction(threads.value, action))\n emit('commentAction', action)\n if (action.type === 'create') {\n open(action.thread.id)\n focusRequest.value++\n } else if (action.type === 'remove' || action.type === 'resolve') open(null)\n }\n\n function anchors(): Record<string, FlowCommentAnchor | null> {\n return Object.fromEntries(threads.value.map((thread) => [thread.id, anchorOf(thread.id)]))\n }\n\n /** Whether `anchor` has something to offer: a thread to open, or one to start. */\n const offered = (anchor: FlowCommentAnchor) =>\n enabled.value && (writable.value || openThere(anchor).length > 0)\n\n const item = (anchor: FlowCommentAnchor): FlowToolbarItem & ContextMenuItem => ({\n key: 'comment',\n label: messages.value.comment,\n icon: MessagePlusIcon,\n shortcut: KEY,\n showWhenReadonly: true,\n run: () => void start(anchor),\n })\n\n const extension: FlowExtension = defineFlowExtension({\n name: 'comments',\n keymap: () => ({ [KEY]: () => start() }),\n contextMenu(_, target) {\n if (target.kind === 'canvas') return []\n const anchor = target.kind === 'node' ? { node: target.node.id } : { edge: target.edge.id }\n return offered(anchor) ? [item(anchor)] : []\n },\n toolbarItems(_, nodes) {\n if (nodes.length !== 1) return []\n const anchor = { node: nodes[0]!.id }\n return offered(anchor) ? [item(anchor)] : []\n },\n edgeToolbarItems(_, edges) {\n if (edges.length !== 1) return []\n const anchor = { edge: edges[0]!.id }\n return offered(anchor) ? [item(anchor)] : []\n },\n })\n\n const comments: FlowComments = {\n enabled,\n writable,\n threads,\n author: computed(() => props.author),\n active,\n pending,\n pendingFocus,\n focusRequest,\n openOn,\n start,\n show,\n apply,\n open,\n close,\n openedHere,\n }\n\n return { comments, extension, anchors, anchorOf }\n}\n"],"mappings":";;;;;AA+DA,IAAM,MAAM;AAEZ,IAAM,YAAY,UAChB,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC,IAAI;;AAG1F,SAAgB,SAAS,IAA2B;CAClD,IAAI,CAAC,MAAM,OAAO,OAAO,UAAU,OAAO;CAC1C,MAAM,IAAI,SAAU,GAAa,CAAC;CAClC,MAAM,IAAI,SAAU,GAAa,CAAC;CAClC,OAAO,MAAM,QAAQ,MAAM,OAAO,OAAO;EAAE;EAAG;CAAE;AAClD;;AAGA,IAAM,SAAS,MAAgB,OAA6B;CAC1D,MAAM,OAAO,KAAK;CAClB,OAAO,QAAQ,OAAO,SAAS,YAAY,OAAO,OAAO,MAAM,EAAE,IAAI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AG,OAAO,CAAC;GAChC,MAAM,SAAS,EAAE,MAAM,MAAM,EAAE,CAAE,GAAG;GACpC,OAAO,QAAQ,MAAM,IAAI,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC;EAC7C;CACF,CAAC;CAoBD,OAAO;EAAE,UAAA;GAjBP;GACA;GACA;GACA,QAAQ,eAAe,MAAM,MAAM;GACnC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EAGO;EAAU;EAAW;EAAS;CAAS;AAClD"}
1
+ {"version":3,"file":"comments.js","names":[],"sources":["../src/comments.ts"],"sourcesContent":["import { MessagePlusIcon } from '@dou-ui/icons'\nimport {\n applyCommentAction,\n type CommentAction,\n type CommentAuthor,\n type CommentThread,\n type ContextMenuItem,\n} from 'dou-ui'\nimport {\n computed,\n nextTick,\n shallowRef,\n watch,\n type ComputedRef,\n type Ref,\n type ShallowRef,\n} from 'vue'\nimport type { FlowCommentAnchor, FlowEditorEmits, FlowEditorProps } from './context'\nimport { defineFlowExtension, type FlowExtension } from './core/extension'\nimport type { FlowToolbarItem } from './core/menu'\nimport type { FlowDocument, FlowNode, FlowSelection, Point } from './core/model'\nimport type { FlowTransaction, FlowTransactionMeta } from './core/transaction'\nimport type { FlowMessages } from './locale'\n\ntype Emit = <K extends keyof FlowEditorEmits>(event: K, ...args: FlowEditorEmits[K]) => void\n\n/** The comments, as the editor's parts see them. */\nexport interface FlowComments {\n enabled: ComputedRef<boolean>\n /** Threads can be started and replied to. */\n writable: ComputedRef<boolean>\n threads: ComputedRef<readonly CommentThread[]>\n author: ComputedRef<CommentAuthor | undefined>\n /** The thread open now. */\n active: ComputedRef<string | null>\n /** What a thread being started is about, until its first comment is sent. */\n pending: ShallowRef<FlowCommentAnchor | null>\n /** Whether the reply box of the thread being started takes the focus. */\n pendingFocus: ShallowRef<boolean>\n /** Goes up when the open thread should take the focus, ready for a reply. */\n focusRequest: ShallowRef<number>\n /**\n * The open threads on each node and edge, oldest first; a node's leave\n * out those pinned to a point on it, which are in `pins`.\n */\n openOn: ComputedRef<{\n nodes: Map<string, string[]>\n edges: Map<string, string[]>\n pins: FlowCommentPin[]\n }>\n start: (anchor?: FlowCommentAnchor | null, focus?: boolean) => boolean\n /** Opens a thread, with the focus in its reply box when `focus`. */\n show: (id: string, focus: boolean) => void\n apply: (action: CommentAction) => void\n open: (id: string | null) => void\n close: () => void\n /** Whether this editor opened the thread `id`, rather than the app. */\n openedHere: (id: string | null) => boolean\n}\n\n/** An open thread pinned to a point on a node. */\nexport interface FlowCommentPin {\n thread: string\n node: string\n at: Point\n /** Its number on the node: its place among the node's pins, from 1, oldest first, resolved ones counted. */\n number: number\n}\n\ntype MarkPatch = { comments: string[] | undefined; commentPins?: Record<string, Point> | undefined }\n\nconst KEY = 'mod+alt+m'\n\nconst fraction = (value: unknown) =>\n typeof value === 'number' && Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : null\n\n/** A point within a node, kept between 0 and 1; `null` when it isn't one. */\nexport function pinPoint(at: unknown): Point | null {\n if (!at || typeof at !== 'object') return null\n const x = fraction((at as Point).x)\n const y = fraction((at as Point).y)\n return x === null || y === null ? null : { x, y }\n}\n\n/** Where the thread `id` is pinned on a node, if it is. */\nconst pinOf = (node: FlowNode, id: string): Point | null => {\n const pins = node.commentPins\n return pins && typeof pins === 'object' && Object.hasOwn(pins, id) ? pinPoint(pins[id]) : null\n}\n\n/** The thread ids on a node or edge; nothing when a hand-written document has something else there. */\nconst idsOf = (item: { comments?: unknown }): string[] =>\n Array.isArray(item.comments) ? item.comments.filter((id) => typeof id === 'string') : []\n\nexport function useFlowComments(options: {\n props: FlowEditorProps\n emit: Emit\n doc: Ref<FlowDocument>\n selection: Ref<FlowSelection>\n messages: ComputedRef<FlowMessages>\n transact: (fn: (tr: FlowTransaction) => void, meta?: FlowTransactionMeta) => FlowTransaction\n /** Keeps a change kept out of undo on a node or edge as undo and redo bring it back. */\n carry: (anchor: FlowCommentAnchor, patch: MarkPatch) => void\n /** The open threads a node's marker counts: a collapsed container's take in those inside it. */\n shownOn: (anchor: FlowCommentAnchor) => string[] | undefined\n}) {\n const { props, emit, doc, selection, messages, transact, carry, shownOn } = options\n\n const threads = computed<readonly CommentThread[]>(() => props.comments ?? [])\n /*\n * `v-model:comments` catches up after the parent renders, so reads in the\n * same tick (such as `getCommentAnchors()` inside `@comment-action`) see\n * the latest applied list immediately.\n */\n let latestThreads: readonly CommentThread[] | null = null\n watch(\n () => props.comments,\n () => {\n latestThreads = null\n },\n { flush: 'sync' },\n )\n const currentThreads = (): readonly CommentThread[] => {\n const value = threads.value\n return latestThreads ?? value\n }\n const enabled = computed(() => props.comments !== undefined)\n const writable = computed(() => enabled.value && !!props.author && props.commentable !== false)\n\n const innerActive = shallowRef<string | null>(null)\n const active = computed(() =>\n props.activeComment === undefined ? innerActive.value : props.activeComment,\n )\n /** The last thread this editor opened, so a `v-model:activeComment` echoing it isn't taken for one from outside. */\n let ownOpen: string | null = null\n function open(id: string | null) {\n if (id === active.value) return\n innerActive.value = id\n ownOpen = id\n emit('update:activeComment', id)\n }\n const openedHere = (id: string | null) => id === ownOpen\n\n const pending = shallowRef<FlowCommentAnchor | null>(null)\n const pendingFocus = shallowRef(true)\n const focusRequest = shallowRef(0)\n\n const openOn = computed(() => {\n const live = new Set(threads.value.filter((t) => !t.resolved).map((t) => t.id))\n const known = new Set(threads.value.map((t) => t.id))\n const pins: FlowCommentPin[] = []\n const nodes = new Map<string, string[]>()\n for (const node of doc.value.nodes) {\n const ids: string[] = []\n let number = 0\n for (const id of idsOf(node)) {\n const at = pinOf(node, id)\n // numbered among every pin there, so resolving one renumbers none\n if (at && known.has(id)) number++\n if (!live.has(id)) continue\n if (at) pins.push({ thread: id, node: node.id, at, number })\n else ids.push(id)\n }\n if (ids.length) nodes.set(node.id, ids)\n }\n const edges = new Map<string, string[]>()\n for (const edge of doc.value.edges) {\n const ids = idsOf(edge).filter((id) => live.has(id))\n if (ids.length) edges.set(edge.id, ids)\n }\n return { nodes, edges, pins }\n })\n\n const threadsOf = (anchor: FlowCommentAnchor) =>\n ('node' in anchor\n ? openOn.value.nodes.get(anchor.node)\n : openOn.value.edges.get(anchor.edge)) ?? []\n\n /** The open threads on a node or edge, with those its marker shows for what it hides. */\n const openThere = (anchor: FlowCommentAnchor) => shownOn(anchor) ?? threadsOf(anchor)\n\n /** The one node or edge selected. */\n function selected(): FlowCommentAnchor | null {\n const { nodes, edges } = selection.value\n if (nodes.length === 1 && !edges.length) return { node: nodes[0]! }\n if (edges.length === 1 && !nodes.length) return { edge: edges[0]! }\n return null\n }\n\n function show(id: string, focus: boolean) {\n pending.value = null\n open(id)\n if (focus) focusRequest.value++\n }\n\n /**\n * Opens the threads on a node or edge, the selected one by default, or\n * the box to start one there; with `at`, always the box for a new pin.\n * `focus` puts the focus in the reply box: from the keyboard, not from a\n * tap, which would bring up the keyboard on a phone.\n */\n function start(anchor: FlowCommentAnchor | null = selected(), focus = true): boolean {\n if (!enabled.value || !anchor) return false\n if ('node' in anchor && anchor.at !== undefined) {\n const { node } = anchor\n const at = pinPoint(anchor.at)\n if (!at || !writable.value || !doc.value.nodes.some((n) => n.id === node)) return false\n open(null)\n pending.value = { node, at }\n pendingFocus.value = focus\n if (focus) focusRequest.value++\n return true\n }\n anchor = 'node' in anchor ? { node: anchor.node } : { edge: anchor.edge }\n const there =\n 'node' in anchor\n ? doc.value.nodes.some((n) => n.id === anchor.node)\n : doc.value.edges.some((e) => e.id === anchor.edge)\n if (!there) return false\n // one already there, or shown there: open it\n const [first] = openThere(anchor)\n if (first) {\n show(first, focus)\n return true\n }\n if (!writable.value) return false\n open(null)\n pending.value = anchor\n pendingFocus.value = focus\n if (focus) focusRequest.value++\n return true\n }\n\n function close() {\n pending.value = null\n open(null)\n }\n\n /** Adds or takes away a thread's id on what it is about; not an undo step. */\n function mark(anchor: FlowCommentAnchor, id: string, add: boolean) {\n let patch: MarkPatch | null = null\n transact(\n (tr) => {\n const item = 'node' in anchor ? tr.getNode(anchor.node) : tr.getEdge(anchor.edge)\n if (!item) return\n const had = idsOf(item)\n const next = add ? [...had.filter((x) => x !== id), id] : had.filter((x) => x !== id)\n patch = { comments: next.length ? next : undefined }\n if ('node' in anchor) {\n const node = item as FlowNode\n const at = add && anchor.at ? pinPoint(anchor.at) : null\n const pins = { ...node.commentPins }\n delete pins[id]\n if (at) pins[id] = at\n // only touched when there are pins, so a plain thread keeps the node as it was\n if (at || node.commentPins)\n patch.commentPins = Object.keys(pins).length ? pins : undefined\n tr.updateNode(anchor.node, patch)\n } else tr.updateEdge(anchor.edge, patch)\n },\n { history: false, origin: 'comment' },\n )\n if (patch) carry(anchor, patch)\n }\n\n function anchorOf(id: string): FlowCommentAnchor | null {\n const current = doc.value\n const node = current.nodes.find((n) => idsOf(n).includes(id))\n if (node) {\n const at = pinOf(node, id)\n if (!at) return { node: node.id }\n const known = new Set(currentThreads().map((t) => t.id))\n const pinned = idsOf(node).filter((other) => known.has(other) && pinOf(node, other))\n return { node: node.id, at, number: pinned.indexOf(id) + 1 }\n }\n const edge = current.edges.find((e) => idsOf(e).includes(id))\n return edge ? { edge: edge.id } : null\n }\n\n function apply(action: CommentAction) {\n if (action.type === 'create') {\n const anchor = pending.value\n if (!anchor) return\n mark(anchor, action.thread.id, true)\n pending.value = null\n } else if (action.type === 'remove') {\n const anchor = anchorOf(action.threadId)\n if (anchor) mark(anchor, action.threadId, false)\n }\n const next = applyCommentAction(currentThreads(), action)\n if (!latestThreads) void nextTick(() => (latestThreads = null))\n latestThreads = next\n emit('update:comments', next)\n emit('commentAction', action)\n if (action.type === 'create') {\n open(action.thread.id)\n focusRequest.value++\n } else if (action.type === 'remove' || action.type === 'resolve') open(null)\n }\n\n function anchors(): Record<string, FlowCommentAnchor | null> {\n return Object.fromEntries(currentThreads().map((thread) => [thread.id, anchorOf(thread.id)]))\n }\n\n /** Whether `anchor` has something to offer: a thread to open, or one to start. */\n const offered = (anchor: FlowCommentAnchor) =>\n enabled.value && (writable.value || openThere(anchor).length > 0)\n\n const item = (anchor: FlowCommentAnchor): FlowToolbarItem & ContextMenuItem => ({\n key: 'comment',\n label: messages.value.comment,\n icon: MessagePlusIcon,\n shortcut: KEY,\n showWhenReadonly: true,\n run: () => void start(anchor),\n })\n\n const extension: FlowExtension = defineFlowExtension({\n name: 'comments',\n keymap: () => ({ [KEY]: () => start() }),\n contextMenu(_, target) {\n if (target.kind === 'canvas') return []\n const anchor = target.kind === 'node' ? { node: target.node.id } : { edge: target.edge.id }\n return offered(anchor) ? [item(anchor)] : []\n },\n toolbarItems(_, nodes) {\n if (nodes.length !== 1) return []\n const anchor = { node: nodes[0]!.id }\n return offered(anchor) ? [item(anchor)] : []\n },\n edgeToolbarItems(_, edges) {\n if (edges.length !== 1) return []\n const anchor = { edge: edges[0]!.id }\n return offered(anchor) ? [item(anchor)] : []\n },\n })\n\n const comments: FlowComments = {\n enabled,\n writable,\n threads,\n author: computed(() => props.author),\n active,\n pending,\n pendingFocus,\n focusRequest,\n openOn,\n start,\n show,\n apply,\n open,\n close,\n openedHere,\n }\n\n return { comments, extension, anchors, anchorOf }\n}\n"],"mappings":";;;;;AAuEA,IAAM,MAAM;AAEZ,IAAM,YAAY,UAChB,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC,IAAI;;AAG1F,SAAgB,SAAS,IAA2B;CAClD,IAAI,CAAC,MAAM,OAAO,OAAO,UAAU,OAAO;CAC1C,MAAM,IAAI,SAAU,GAAa,CAAC;CAClC,MAAM,IAAI,SAAU,GAAa,CAAC;CAClC,OAAO,MAAM,QAAQ,MAAM,OAAO,OAAO;EAAE;EAAG;CAAE;AAClD;;AAGA,IAAM,SAAS,MAAgB,OAA6B;CAC1D,MAAM,OAAO,KAAK;CAClB,OAAO,QAAQ,OAAO,SAAS,YAAY,OAAO,OAAO,MAAM,EAAE,IAAI,SAAS,KAAK,GAAG,IAAI;AAC5F;;AAGA,IAAM,SAAS,SACb,MA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