@dxos/plugin-sheet 0.8.4-main.406dc2a → 0.8.4-main.52d7546f51

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 (239) hide show
  1. package/dist/lib/browser/SheetContainer-6DNFC4TY.mjs +397 -0
  2. package/dist/lib/browser/SheetContainer-6DNFC4TY.mjs.map +7 -0
  3. package/dist/lib/browser/anchor-sort-AMMLA66W.mjs +24 -0
  4. package/dist/lib/browser/anchor-sort-AMMLA66W.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-EDWHV64N.mjs +1473 -0
  6. package/dist/lib/browser/chunk-EDWHV64N.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-SSN4HYJL.mjs → chunk-IFLWVS2V.mjs} +9 -9
  8. package/dist/lib/browser/chunk-IFLWVS2V.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-KE3AKN5W.mjs +397 -0
  10. package/dist/lib/browser/chunk-KE3AKN5W.mjs.map +7 -0
  11. package/dist/lib/browser/compute-graph-registry-RC5L7RE4.mjs +21 -0
  12. package/dist/lib/browser/compute-graph-registry-RC5L7RE4.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +71 -80
  14. package/dist/lib/browser/index.mjs.map +4 -4
  15. package/dist/lib/browser/markdown-D2T2DOVX.mjs +29 -0
  16. package/dist/lib/browser/markdown-D2T2DOVX.mjs.map +7 -0
  17. package/dist/lib/browser/meta.json +1 -1
  18. package/dist/lib/browser/operation-resolver-P2RX75DA.mjs +79 -0
  19. package/dist/lib/browser/operation-resolver-P2RX75DA.mjs.map +7 -0
  20. package/dist/lib/browser/{react-surface-7ZDMQDCT.mjs → react-surface-45CRAB5G.mjs} +19 -21
  21. package/dist/lib/browser/react-surface-45CRAB5G.mjs.map +7 -0
  22. package/dist/lib/browser/types/index.mjs +7 -12
  23. package/dist/lib/node-esm/SheetContainer-7H5R7M54.mjs +398 -0
  24. package/dist/lib/node-esm/SheetContainer-7H5R7M54.mjs.map +7 -0
  25. package/dist/lib/node-esm/anchor-sort-VHMBRX2E.mjs +25 -0
  26. package/dist/lib/node-esm/anchor-sort-VHMBRX2E.mjs.map +7 -0
  27. package/dist/lib/node-esm/chunk-6J5L47IB.mjs +398 -0
  28. package/dist/lib/node-esm/chunk-6J5L47IB.mjs.map +7 -0
  29. package/dist/lib/node-esm/chunk-AYSEWH7N.mjs +1474 -0
  30. package/dist/lib/node-esm/chunk-AYSEWH7N.mjs.map +7 -0
  31. package/dist/lib/node-esm/{chunk-IK4O7FUJ.mjs → chunk-PPOYR7DK.mjs} +9 -9
  32. package/dist/lib/node-esm/chunk-PPOYR7DK.mjs.map +7 -0
  33. package/dist/lib/node-esm/compute-graph-registry-ZGXVLVGD.mjs +22 -0
  34. package/dist/lib/node-esm/compute-graph-registry-ZGXVLVGD.mjs.map +7 -0
  35. package/dist/lib/node-esm/index.mjs +71 -80
  36. package/dist/lib/node-esm/index.mjs.map +4 -4
  37. package/dist/lib/node-esm/markdown-PTV72DLO.mjs +30 -0
  38. package/dist/lib/node-esm/markdown-PTV72DLO.mjs.map +7 -0
  39. package/dist/lib/node-esm/meta.json +1 -1
  40. package/dist/lib/node-esm/operation-resolver-WPIWQ5IO.mjs +80 -0
  41. package/dist/lib/node-esm/operation-resolver-WPIWQ5IO.mjs.map +7 -0
  42. package/dist/lib/node-esm/{react-surface-TUME5MM2.mjs → react-surface-ITV2L6HK.mjs} +19 -21
  43. package/dist/lib/node-esm/react-surface-ITV2L6HK.mjs.map +7 -0
  44. package/dist/lib/node-esm/types/index.mjs +7 -12
  45. package/dist/types/src/SheetPlugin.d.ts +2 -1
  46. package/dist/types/src/SheetPlugin.d.ts.map +1 -1
  47. package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts +6 -0
  48. package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts.map +1 -0
  49. package/dist/types/src/capabilities/anchor-sort/index.d.ts +3 -0
  50. package/dist/types/src/capabilities/anchor-sort/index.d.ts.map +1 -0
  51. package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts +5 -0
  52. package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts.map +1 -0
  53. package/dist/types/src/capabilities/compute-graph-registry/index.d.ts +3 -0
  54. package/dist/types/src/capabilities/compute-graph-registry/index.d.ts.map +1 -0
  55. package/dist/types/src/capabilities/index.d.ts +5 -9
  56. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  57. package/dist/types/src/capabilities/markdown/index.d.ts +3 -0
  58. package/dist/types/src/capabilities/markdown/index.d.ts.map +1 -0
  59. package/dist/types/src/capabilities/markdown/markdown.d.ts +5 -0
  60. package/dist/types/src/capabilities/markdown/markdown.d.ts.map +1 -0
  61. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  62. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  63. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  64. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  65. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  66. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  67. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  68. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  69. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
  70. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +3 -2
  71. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
  72. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts +1 -1
  73. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -1
  74. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
  75. package/dist/types/src/components/RangeList/RangeList.d.ts +2 -2
  76. package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
  77. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +5 -6
  78. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
  79. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +5 -3
  80. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
  81. package/dist/types/src/components/SheetContext/SheetContext.d.ts +2 -2
  82. package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
  83. package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +3 -4
  84. package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
  85. package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +2 -0
  86. package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
  87. package/dist/types/src/components/SheetToolbar/align.d.ts +12 -19
  88. package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -1
  89. package/dist/types/src/components/SheetToolbar/style.d.ts +12 -18
  90. package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -1
  91. package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts +14 -1
  92. package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts.map +1 -1
  93. package/dist/types/src/components/index.d.ts +1 -1
  94. package/dist/types/src/components/index.d.ts.map +1 -1
  95. package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
  96. package/dist/types/src/extensions/editor/sheet-extension.d.ts.map +1 -1
  97. package/dist/types/src/index.d.ts +1 -1
  98. package/dist/types/src/index.d.ts.map +1 -1
  99. package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
  100. package/dist/types/src/meta.d.ts +2 -2
  101. package/dist/types/src/meta.d.ts.map +1 -1
  102. package/dist/types/src/model/sheet-model.d.ts +6 -6
  103. package/dist/types/src/model/sheet-model.d.ts.map +1 -1
  104. package/dist/types/src/model/testing.d.ts +2 -2
  105. package/dist/types/src/model/testing.d.ts.map +1 -1
  106. package/dist/types/src/model/useSheetModel.d.ts +2 -2
  107. package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
  108. package/dist/types/src/serializer.d.ts +2 -2
  109. package/dist/types/src/serializer.d.ts.map +1 -1
  110. package/dist/types/src/testing/data.d.ts +2 -2
  111. package/dist/types/src/testing/data.d.ts.map +1 -1
  112. package/dist/types/src/testing/testing.d.ts +26 -2
  113. package/dist/types/src/testing/testing.d.ts.map +1 -1
  114. package/dist/types/src/translations.d.ts +3 -2
  115. package/dist/types/src/translations.d.ts.map +1 -1
  116. package/dist/types/src/types/Sheet.d.ts +76 -0
  117. package/dist/types/src/types/Sheet.d.ts.map +1 -0
  118. package/dist/types/src/types/capabilities.d.ts +6 -0
  119. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  120. package/dist/types/src/types/index.d.ts +2 -1
  121. package/dist/types/src/types/index.d.ts.map +1 -1
  122. package/dist/types/src/types/sheet-range-types.d.ts +2 -2
  123. package/dist/types/src/types/sheet-range-types.d.ts.map +1 -1
  124. package/dist/types/src/types/types.d.ts +91 -74
  125. package/dist/types/src/types/types.d.ts.map +1 -1
  126. package/dist/types/src/types/util.d.ts +10 -10
  127. package/dist/types/src/types/util.d.ts.map +1 -1
  128. package/dist/types/tsconfig.tsbuildinfo +1 -1
  129. package/package.json +76 -68
  130. package/src/SheetPlugin.tsx +41 -61
  131. package/src/capabilities/anchor-sort/anchor-sort.ts +27 -0
  132. package/src/capabilities/anchor-sort/index.ts +7 -0
  133. package/src/capabilities/compute-graph-registry/compute-graph-registry.ts +27 -0
  134. package/src/capabilities/compute-graph-registry/index.ts +7 -0
  135. package/src/capabilities/index.ts +5 -9
  136. package/src/capabilities/markdown/index.ts +7 -0
  137. package/src/capabilities/markdown/markdown.ts +30 -0
  138. package/src/capabilities/operation-resolver/index.ts +7 -0
  139. package/src/capabilities/operation-resolver/operation-resolver.ts +77 -0
  140. package/src/capabilities/react-surface/index.ts +7 -0
  141. package/src/capabilities/react-surface/react-surface.tsx +43 -0
  142. package/src/components/ComputeGraph/compute-graph.stories.tsx +9 -9
  143. package/src/components/FunctionEditor/FunctionEditor.tsx +2 -2
  144. package/src/components/GridSheet/GridSheet.stories.tsx +5 -5
  145. package/src/components/GridSheet/GridSheet.tsx +40 -30
  146. package/src/components/GridSheet/SheetCellEditor.stories.tsx +12 -9
  147. package/src/components/GridSheet/util.ts +11 -5
  148. package/src/components/RangeList/RangeList.tsx +10 -7
  149. package/src/components/SheetContainer/SheetContainer.stories.tsx +46 -23
  150. package/src/components/SheetContainer/SheetContainer.tsx +30 -22
  151. package/src/components/SheetContext/SheetContext.tsx +8 -8
  152. package/src/components/SheetToolbar/SheetToolbar.stories.tsx +1 -1
  153. package/src/components/SheetToolbar/SheetToolbar.tsx +39 -30
  154. package/src/components/SheetToolbar/align.ts +41 -16
  155. package/src/components/SheetToolbar/style.ts +45 -15
  156. package/src/components/SheetToolbar/useToolbarState.ts +22 -5
  157. package/src/extensions/compute.stories.tsx +19 -10
  158. package/src/extensions/compute.ts +1 -1
  159. package/src/extensions/editor/sheet-extension.ts +7 -4
  160. package/src/index.ts +1 -1
  161. package/src/integrations/thread-ranges.ts +39 -49
  162. package/src/meta.ts +8 -4
  163. package/src/model/sheet-model.test.ts +4 -4
  164. package/src/model/sheet-model.ts +80 -48
  165. package/src/model/testing.ts +4 -4
  166. package/src/model/useSheetModel.ts +2 -2
  167. package/src/playwright/playwright.config.ts +1 -1
  168. package/src/playwright/sheet.spec.ts +1 -0
  169. package/src/sanity.test.ts +3 -4
  170. package/src/serializer.ts +4 -4
  171. package/src/testing/data.ts +2 -2
  172. package/src/testing/testing.tsx +3 -3
  173. package/src/translations.ts +3 -2
  174. package/src/types/Sheet.ts +97 -0
  175. package/src/{capabilities → types}/capabilities.ts +2 -2
  176. package/src/types/index.ts +2 -1
  177. package/src/types/sheet-range-types.ts +2 -2
  178. package/src/types/types.ts +82 -48
  179. package/src/types/util.ts +11 -38
  180. package/dist/lib/browser/SheetContainer-VL34UND4.mjs +0 -351
  181. package/dist/lib/browser/SheetContainer-VL34UND4.mjs.map +0 -7
  182. package/dist/lib/browser/anchor-sort-3N44DS5F.mjs +0 -24
  183. package/dist/lib/browser/anchor-sort-3N44DS5F.mjs.map +0 -7
  184. package/dist/lib/browser/chunk-ADK2HW4A.mjs +0 -906
  185. package/dist/lib/browser/chunk-ADK2HW4A.mjs.map +0 -7
  186. package/dist/lib/browser/chunk-CSBSADPQ.mjs +0 -16
  187. package/dist/lib/browser/chunk-CSBSADPQ.mjs.map +0 -7
  188. package/dist/lib/browser/chunk-SSN4HYJL.mjs.map +0 -7
  189. package/dist/lib/browser/chunk-ZJWJMX4E.mjs +0 -852
  190. package/dist/lib/browser/chunk-ZJWJMX4E.mjs.map +0 -7
  191. package/dist/lib/browser/chunk-ZMPNHFIP.mjs +0 -15
  192. package/dist/lib/browser/chunk-ZMPNHFIP.mjs.map +0 -7
  193. package/dist/lib/browser/compute-graph-registry-MF65HGGM.mjs +0 -21
  194. package/dist/lib/browser/compute-graph-registry-MF65HGGM.mjs.map +0 -7
  195. package/dist/lib/browser/intent-resolver-BQLV6IAA.mjs +0 -56
  196. package/dist/lib/browser/intent-resolver-BQLV6IAA.mjs.map +0 -7
  197. package/dist/lib/browser/markdown-RMTMI237.mjs +0 -26
  198. package/dist/lib/browser/markdown-RMTMI237.mjs.map +0 -7
  199. package/dist/lib/browser/react-surface-7ZDMQDCT.mjs.map +0 -7
  200. package/dist/lib/node-esm/SheetContainer-NWJ7L6FC.mjs +0 -352
  201. package/dist/lib/node-esm/SheetContainer-NWJ7L6FC.mjs.map +0 -7
  202. package/dist/lib/node-esm/anchor-sort-YL2OZHYM.mjs +0 -25
  203. package/dist/lib/node-esm/anchor-sort-YL2OZHYM.mjs.map +0 -7
  204. package/dist/lib/node-esm/chunk-BZAPYBSH.mjs +0 -907
  205. package/dist/lib/node-esm/chunk-BZAPYBSH.mjs.map +0 -7
  206. package/dist/lib/node-esm/chunk-H3GSD33H.mjs +0 -18
  207. package/dist/lib/node-esm/chunk-H3GSD33H.mjs.map +0 -7
  208. package/dist/lib/node-esm/chunk-IK4O7FUJ.mjs.map +0 -7
  209. package/dist/lib/node-esm/chunk-LN6ZSAII.mjs +0 -16
  210. package/dist/lib/node-esm/chunk-LN6ZSAII.mjs.map +0 -7
  211. package/dist/lib/node-esm/chunk-YL7BVJPC.mjs +0 -853
  212. package/dist/lib/node-esm/chunk-YL7BVJPC.mjs.map +0 -7
  213. package/dist/lib/node-esm/compute-graph-registry-P2O5LDFZ.mjs +0 -22
  214. package/dist/lib/node-esm/compute-graph-registry-P2O5LDFZ.mjs.map +0 -7
  215. package/dist/lib/node-esm/intent-resolver-MV5ZFXAQ.mjs +0 -57
  216. package/dist/lib/node-esm/intent-resolver-MV5ZFXAQ.mjs.map +0 -7
  217. package/dist/lib/node-esm/markdown-EDIWHA3P.mjs +0 -27
  218. package/dist/lib/node-esm/markdown-EDIWHA3P.mjs.map +0 -7
  219. package/dist/lib/node-esm/react-surface-TUME5MM2.mjs.map +0 -7
  220. package/dist/types/src/capabilities/anchor-sort.d.ts +0 -6
  221. package/dist/types/src/capabilities/anchor-sort.d.ts.map +0 -1
  222. package/dist/types/src/capabilities/capabilities.d.ts +0 -5
  223. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  224. package/dist/types/src/capabilities/compute-graph-registry.d.ts +0 -4
  225. package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +0 -1
  226. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  227. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  228. package/dist/types/src/capabilities/markdown.d.ts +0 -4
  229. package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
  230. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  231. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  232. package/dist/types/src/types/schema.d.ts +0 -37
  233. package/dist/types/src/types/schema.d.ts.map +0 -1
  234. package/src/capabilities/anchor-sort.ts +0 -22
  235. package/src/capabilities/compute-graph-registry.ts +0 -23
  236. package/src/capabilities/intent-resolver.ts +0 -38
  237. package/src/capabilities/markdown.ts +0 -23
  238. package/src/capabilities/react-surface.tsx +0 -40
  239. package/src/types/schema.ts +0 -61
@@ -2,18 +2,16 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Rx } from '@effect-rx/rx-react';
6
- import React, { type PropsWithChildren, useMemo } from 'react';
5
+ import { Atom, type Registry, RegistryContext } from '@effect-atom/atom-react';
6
+ import React, { type PropsWithChildren, useContext, useMemo } from 'react';
7
7
 
8
- import { useAppGraph } from '@dxos/app-framework';
8
+ import { useAppGraph } from '@dxos/app-toolkit/ui';
9
9
  import { type CompleteCellRange } from '@dxos/compute';
10
- import { type ThemedClassName } from '@dxos/react-ui';
11
10
  import {
12
11
  type ActionGraphProps,
13
12
  MenuProvider,
14
13
  ToolbarMenu,
15
14
  createGapSeparator,
16
- rxFromSignal,
17
15
  useMenuActions,
18
16
  } from '@dxos/react-ui-menu';
19
17
 
@@ -22,23 +20,28 @@ import { useSheetContext } from '../SheetContext';
22
20
 
23
21
  import { createAlign, useAlignState } from './align';
24
22
  import { createStyle, useStyleState } from './style';
25
- import { type ToolbarState, useToolbarState } from './useToolbarState';
23
+ import { type ToolbarStateAtom, useToolbarState } from './useToolbarState';
26
24
 
27
- //
28
- // Root
29
- //
30
-
31
- export type SheetToolbarProps = ThemedClassName<PropsWithChildren<{ id: string }>>;
25
+ type ToolbarActionsContext = {
26
+ model: SheetModel;
27
+ stateAtom: ToolbarStateAtom;
28
+ registry: Registry.Registry;
29
+ cursorFallbackRange?: CompleteCellRange;
30
+ customActions?: Atom.Atom<ActionGraphProps>;
31
+ };
32
32
 
33
- const createToolbarActions = (
34
- model: SheetModel,
35
- state: ToolbarState,
36
- cursorFallbackRange?: CompleteCellRange,
37
- customActions?: Rx.Rx<ActionGraphProps>,
38
- ): Rx.Rx<ActionGraphProps> => {
39
- return Rx.make((get) => {
40
- const align = get(rxFromSignal(() => createAlign(model, state, cursorFallbackRange)));
41
- const style = get(rxFromSignal(() => createStyle(model, state, cursorFallbackRange)));
33
+ const createToolbarActions = ({
34
+ model,
35
+ stateAtom,
36
+ registry,
37
+ cursorFallbackRange,
38
+ customActions,
39
+ }: ToolbarActionsContext): Atom.Atom<ActionGraphProps> => {
40
+ return Atom.make((get) => {
41
+ const state = get(stateAtom);
42
+ const context = { model, state, stateAtom, registry, cursorFallbackRange };
43
+ const align = createAlign(context);
44
+ const style = createStyle(context);
42
45
  const gap = createGapSeparator();
43
46
 
44
47
  const graph: ActionGraphProps = {
@@ -56,30 +59,36 @@ const createToolbarActions = (
56
59
  });
57
60
  };
58
61
 
59
- export const SheetToolbar = ({ id, classNames }: SheetToolbarProps) => {
62
+ export type SheetToolbarProps = PropsWithChildren<{ id: string }>;
63
+
64
+ export const SheetToolbar = ({ id }: SheetToolbarProps) => {
60
65
  const { model, cursorFallbackRange } = useSheetContext();
61
- const state = useToolbarState({});
62
- useAlignState(state);
63
- useStyleState(state);
66
+ const stateAtom = useToolbarState({});
67
+ const registry = useContext(RegistryContext);
68
+ useAlignState(stateAtom);
69
+ useStyleState(stateAtom);
64
70
 
65
71
  const { graph } = useAppGraph();
66
72
  const customActions = useMemo(() => {
67
- return Rx.make((get) => {
73
+ return Atom.make((get) => {
68
74
  const actions = get(graph.actions(id));
69
75
  const nodes = actions.filter((action) => action.properties.disposition === 'toolbar');
70
- return { nodes, edges: nodes.map((node) => ({ source: 'root', target: node.id })) };
76
+ return {
77
+ nodes,
78
+ edges: nodes.map((node) => ({ source: 'root', target: node.id })),
79
+ };
71
80
  });
72
- }, [graph]);
81
+ }, [graph, id]);
73
82
 
74
83
  const actionsCreator = useMemo(
75
- () => createToolbarActions(model, state, cursorFallbackRange, customActions),
76
- [model, state, cursorFallbackRange, customActions],
84
+ () => createToolbarActions({ model, stateAtom, registry, cursorFallbackRange, customActions }),
85
+ [model, stateAtom, registry, cursorFallbackRange, customActions],
77
86
  );
78
87
  const menu = useMenuActions(actionsCreator);
79
88
 
80
89
  return (
81
90
  <MenuProvider {...menu} attendableId={id}>
82
- <ToolbarMenu classNames={classNames} />
91
+ <ToolbarMenu />
83
92
  </MenuProvider>
84
93
  );
85
94
  };
@@ -2,17 +2,24 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { useEffect } from 'react';
5
+ import { type Registry, RegistryContext } from '@effect-atom/atom-react';
6
+ import { useContext, useEffect } from 'react';
6
7
 
7
8
  import { type CompleteCellRange, inRange } from '@dxos/compute';
8
- import { type ToolbarMenuActionGroupProperties, createMenuAction, createMenuItemGroup } from '@dxos/react-ui-menu';
9
+ import { Obj } from '@dxos/echo';
10
+ import {
11
+ type ActionGraphProps,
12
+ type ToolbarMenuActionGroupProperties,
13
+ createMenuAction,
14
+ createMenuItemGroup,
15
+ } from '@dxos/react-ui-menu';
9
16
 
10
17
  import { meta } from '../../meta';
11
18
  import { type SheetModel } from '../../model';
12
19
  import { type AlignKey, type AlignValue, alignKey, rangeFromIndex, rangeToIndex } from '../../types';
13
20
  import { useSheetContext } from '../SheetContext';
14
21
 
15
- import { type ToolbarState } from './useToolbarState';
22
+ import { type ToolbarState, type ToolbarStateAtom } from './useToolbarState';
16
23
 
17
24
  export type AlignAction = { key: AlignKey; value: AlignValue };
18
25
 
@@ -24,18 +31,21 @@ const aligns: Record<AlignValue, string> = {
24
31
  end: 'ph--text-align-right--regular',
25
32
  };
26
33
 
27
- export const useAlignState = (state: Partial<AlignState>) => {
34
+ export const useAlignState = (stateAtom: ToolbarStateAtom) => {
35
+ const registry = useContext(RegistryContext);
28
36
  const { cursor, model } = useSheetContext();
29
37
  useEffect(() => {
30
38
  // TODO(thure): Can this O(n) call be memoized?
31
- state[alignKey] = (
39
+ const alignValue = (
32
40
  cursor
33
41
  ? model.sheet.ranges?.findLast(
34
42
  ({ range, key }) => key === alignKey && inRange(rangeFromIndex(model.sheet, range), cursor),
35
43
  )?.value
36
44
  : undefined
37
45
  ) as AlignValue | undefined;
38
- }, [cursor, model.sheet]);
46
+ const prev = registry.get(stateAtom);
47
+ registry.set(stateAtom, { ...prev, [alignKey]: alignValue });
48
+ }, [cursor, model.sheet, registry, stateAtom]);
39
49
  };
40
50
 
41
51
  const createAlignGroupAction = (value?: AlignValue) =>
@@ -46,7 +56,15 @@ const createAlignGroupAction = (value?: AlignValue) =>
46
56
  value: `${alignKey}--${value}`,
47
57
  } as ToolbarMenuActionGroupProperties);
48
58
 
49
- const createAlignActions = (model: SheetModel, state: ToolbarState, cursorFallbackRange?: CompleteCellRange) =>
59
+ type AlignActionsContext = {
60
+ model: SheetModel;
61
+ state: ToolbarState;
62
+ stateAtom: ToolbarStateAtom;
63
+ registry: Registry.Registry;
64
+ cursorFallbackRange?: CompleteCellRange;
65
+ };
66
+
67
+ const createAlignActions = ({ model, state, stateAtom, registry, cursorFallbackRange }: AlignActionsContext) =>
50
68
  Object.entries(aligns).map(([alignValue, icon]) => {
51
69
  return createMenuAction<AlignAction>(
52
70
  `${alignKey}--${alignValue}`,
@@ -64,15 +82,22 @@ const createAlignActions = (model: SheetModel, state: ToolbarState, cursorFallba
64
82
  key: alignKey,
65
83
  value: alignValue as AlignValue,
66
84
  };
85
+ const currentState = registry.get(stateAtom);
67
86
  if (index < 0) {
68
- model.sheet.ranges?.push(nextRangeEntity);
69
- state[alignKey] = nextRangeEntity.value;
87
+ Obj.change(model.sheet, (obj) => {
88
+ obj.ranges?.push(nextRangeEntity);
89
+ });
90
+ registry.set(stateAtom, { ...currentState, [alignKey]: nextRangeEntity.value });
70
91
  } else if (model.sheet.ranges![index].value === nextRangeEntity.value) {
71
- model.sheet.ranges?.splice(index, 1);
72
- state[alignKey] = undefined;
92
+ Obj.change(model.sheet, (obj) => {
93
+ obj.ranges?.splice(index, 1);
94
+ });
95
+ registry.set(stateAtom, { ...currentState, [alignKey]: undefined });
73
96
  } else {
74
- model.sheet.ranges?.splice(index, 1, nextRangeEntity);
75
- state[alignKey] = nextRangeEntity.value;
97
+ Obj.change(model.sheet, (obj) => {
98
+ obj.ranges?.splice(index, 1, nextRangeEntity);
99
+ });
100
+ registry.set(stateAtom, { ...currentState, [alignKey]: nextRangeEntity.value });
76
101
  }
77
102
  },
78
103
  {
@@ -86,9 +111,9 @@ const createAlignActions = (model: SheetModel, state: ToolbarState, cursorFallba
86
111
  );
87
112
  });
88
113
 
89
- export const createAlign = (model: SheetModel, state: ToolbarState, cursorFallbackRange?: CompleteCellRange) => {
90
- const alignGroup = createAlignGroupAction(state[alignKey]);
91
- const alignActions = createAlignActions(model, state, cursorFallbackRange);
114
+ export const createAlign = (context: AlignActionsContext): ActionGraphProps => {
115
+ const alignGroup = createAlignGroupAction(context.state[alignKey]);
116
+ const alignActions = createAlignActions(context);
92
117
  return {
93
118
  nodes: [alignGroup, ...alignActions],
94
119
  edges: [
@@ -2,16 +2,25 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { useEffect } from 'react';
5
+ import { type Registry, RegistryContext } from '@effect-atom/atom-react';
6
+ import { useContext, useEffect } from 'react';
6
7
 
7
8
  import { type CompleteCellRange, inRange } from '@dxos/compute';
8
- import { type ToolbarMenuActionGroupProperties, createMenuAction, createMenuItemGroup } from '@dxos/react-ui-menu';
9
+ import { Obj } from '@dxos/echo';
10
+ import {
11
+ type ActionGraphProps,
12
+ type ToolbarMenuActionGroupProperties,
13
+ createMenuAction,
14
+ createMenuItemGroup,
15
+ } from '@dxos/react-ui-menu';
9
16
 
10
17
  import { meta } from '../../meta';
11
18
  import { type SheetModel } from '../../model';
12
19
  import { type StyleKey, type StyleValue, rangeFromIndex, rangeToIndex } from '../../types';
13
20
  import { useSheetContext } from '../SheetContext';
14
21
 
22
+ import { type ToolbarState, type ToolbarStateAtom } from './useToolbarState';
23
+
15
24
  export type StyleState = Partial<Record<StyleValue, boolean>>;
16
25
 
17
26
  export type StyleAction = { key: StyleKey; value: StyleValue };
@@ -21,22 +30,30 @@ const styles: Record<StyleValue, string> = {
21
30
  softwrap: 'ph--paragraph--regular',
22
31
  };
23
32
 
24
- export const useStyleState = (state: StyleState) => {
33
+ export const useStyleState = (stateAtom: ToolbarStateAtom) => {
34
+ const registry = useContext(RegistryContext);
25
35
  const { cursorFallbackRange, model } = useSheetContext();
26
36
 
27
37
  useEffect(() => {
28
- state.highlight = false;
29
- state.softwrap = false;
38
+ let highlight = false;
39
+ let softwrap = false;
30
40
  if (cursorFallbackRange && model.sheet.ranges) {
31
41
  model.sheet.ranges
32
42
  .filter(
33
43
  ({ range, key }) => key === 'style' && inRange(rangeFromIndex(model.sheet, range), cursorFallbackRange.from),
34
44
  )
35
45
  .forEach(({ value }) => {
36
- state[value as StyleValue] = true;
46
+ if (value === 'highlight') {
47
+ highlight = true;
48
+ }
49
+ if (value === 'softwrap') {
50
+ softwrap = true;
51
+ }
37
52
  });
38
53
  }
39
- }, [cursorFallbackRange, model.sheet]);
54
+ const prev = registry.get(stateAtom);
55
+ registry.set(stateAtom, { ...prev, highlight, softwrap });
56
+ }, [cursorFallbackRange, model.sheet, registry, stateAtom]);
40
57
  };
41
58
 
42
59
  const createStyleGroup = (state: StyleState) => {
@@ -49,7 +66,15 @@ const createStyleGroup = (state: StyleState) => {
49
66
  } as ToolbarMenuActionGroupProperties);
50
67
  };
51
68
 
52
- const createStyleActions = (model: SheetModel, state: StyleState, cursorFallbackRange?: CompleteCellRange) =>
69
+ type StyleActionsContext = {
70
+ model: SheetModel;
71
+ state: ToolbarState;
72
+ stateAtom: ToolbarStateAtom;
73
+ registry: Registry.Registry;
74
+ cursorFallbackRange?: CompleteCellRange;
75
+ };
76
+
77
+ const createStyleActions = ({ model, state, stateAtom, registry, cursorFallbackRange }: StyleActionsContext) =>
53
78
  Object.entries(styles).map(([styleValue, icon]) => {
54
79
  return createMenuAction<StyleAction>(
55
80
  `style--${styleValue}`,
@@ -67,6 +92,7 @@ const createStyleActions = (model: SheetModel, state: StyleState, cursorFallback
67
92
  key: 'style',
68
93
  value: styleValue as StyleValue,
69
94
  };
95
+ const currentState = registry.get(stateAtom);
70
96
  if (
71
97
  model.sheet.ranges
72
98
  .filter(
@@ -77,12 +103,16 @@ const createStyleActions = (model: SheetModel, state: StyleState, cursorFallback
77
103
  ) {
78
104
  // this value should be unset
79
105
  if (index >= 0) {
80
- model.sheet.ranges?.splice(index, 1);
106
+ Obj.change(model.sheet, (obj) => {
107
+ obj.ranges?.splice(index, 1);
108
+ });
81
109
  }
82
- state[nextRangeEntity.value] = false;
110
+ registry.set(stateAtom, { ...currentState, [nextRangeEntity.value]: false });
83
111
  } else {
84
- model.sheet.ranges?.push(nextRangeEntity);
85
- state[nextRangeEntity.value] = true;
112
+ Obj.change(model.sheet, (obj) => {
113
+ obj.ranges?.push(nextRangeEntity);
114
+ });
115
+ registry.set(stateAtom, { ...currentState, [nextRangeEntity.value]: true });
86
116
  }
87
117
  },
88
118
  {
@@ -95,9 +125,9 @@ const createStyleActions = (model: SheetModel, state: StyleState, cursorFallback
95
125
  );
96
126
  });
97
127
 
98
- export const createStyle = (model: SheetModel, state: StyleState, cursorFallbackRange?: CompleteCellRange) => {
99
- const styleGroupAction = createStyleGroup(state);
100
- const styleActions = createStyleActions(model, state, cursorFallbackRange);
128
+ export const createStyle = (context: StyleActionsContext): ActionGraphProps => {
129
+ const styleGroupAction = createStyleGroup(context.state);
130
+ const styleActions = createStyleActions(context);
101
131
  return {
102
132
  nodes: [styleGroupAction, ...styleActions],
103
133
  edges: [
@@ -2,15 +2,32 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { useMemo } from 'react';
6
-
7
- import { live } from '@dxos/live-object';
5
+ import { Atom, type Registry, RegistryContext, useAtomValue } from '@effect-atom/atom-react';
6
+ import { useContext, useMemo } from 'react';
8
7
 
9
8
  import { type AlignState } from './align';
10
9
  import { type StyleState } from './style';
11
10
 
12
11
  export type ToolbarState = Partial<StyleState & AlignState>;
12
+ export type ToolbarStateAtom = Atom.Writable<ToolbarState>;
13
+
14
+ /**
15
+ * Creates a reactive toolbar state Atom.
16
+ */
17
+ export const useToolbarState = (initialState: ToolbarState = {}): ToolbarStateAtom => {
18
+ return useMemo(() => Atom.make<ToolbarState>(initialState).pipe(Atom.keepAlive), []);
19
+ };
20
+
21
+ /**
22
+ * Hook to read the current toolbar state value.
23
+ */
24
+ export const useToolbarStateValue = (stateAtom: ToolbarStateAtom): ToolbarState => {
25
+ return useAtomValue(stateAtom);
26
+ };
13
27
 
14
- export const useToolbarState = (initialState: ToolbarState = {}) => {
15
- return useMemo(() => live<ToolbarState>(initialState), []);
28
+ /**
29
+ * Hook to get the registry for updating toolbar state.
30
+ */
31
+ export const useToolbarStateRegistry = (): Registry.Registry => {
32
+ return useContext(RegistryContext);
16
33
  };
@@ -5,27 +5,27 @@
5
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
  import React, { useEffect, useMemo } from 'react';
7
7
 
8
- import { IntentPlugin } from '@dxos/app-framework';
8
+ import { OperationPlugin, RuntimePlugin } from '@dxos/app-framework';
9
9
  import { withPluginManager } from '@dxos/app-framework/testing';
10
10
  import { PublicKey } from '@dxos/keys';
11
11
  import { useSpace } from '@dxos/react-client/echo';
12
12
  import { withClientProvider } from '@dxos/react-client/testing';
13
13
  import { useThemeContext } from '@dxos/react-ui';
14
14
  import { withTheme } from '@dxos/react-ui/testing';
15
+ import { useTextEditor } from '@dxos/react-ui-editor';
15
16
  import {
16
17
  createBasicExtensions,
17
18
  createMarkdownExtensions,
18
19
  createThemeExtensions,
19
20
  decorateMarkdown,
20
21
  documentId,
21
- useTextEditor,
22
- } from '@dxos/react-ui-editor';
22
+ } from '@dxos/ui-editor';
23
23
  import { isNonNullable } from '@dxos/util';
24
24
 
25
25
  import { GridSheet, SheetProvider, useComputeGraph } from '../components';
26
26
  import { useSheetModel } from '../model';
27
27
  import { useTestSheet, withComputeGraphDecorator } from '../testing';
28
- import { SheetType } from '../types';
28
+ import { Sheet } from '../types';
29
29
 
30
30
  import { compute, computeGraphFacet } from './compute';
31
31
 
@@ -63,7 +63,7 @@ const DefaultStory = ({ text }: EditorProps) => {
63
63
  [computeGraph, themeMode],
64
64
  );
65
65
 
66
- return <div className='w-[40rem] overflow-hidden' ref={parentRef} {...focusAttributes} />;
66
+ return <div className='is-[40rem] overflow-hidden' ref={parentRef} {...focusAttributes} />;
67
67
  };
68
68
 
69
69
  const Grid = () => {
@@ -73,7 +73,12 @@ const Grid = () => {
73
73
  const model = useSheetModel(graph, sheet);
74
74
  useEffect(() => {
75
75
  if (model) {
76
- model.setValues({ A1: { value: 100 }, A2: { value: 200 }, A3: { value: 300 }, A5: { value: '=SUM(A1:A3)' } });
76
+ model.setValues({
77
+ A1: { value: 100 },
78
+ A2: { value: 200 },
79
+ A3: { value: 300 },
80
+ A5: { value: '=SUM(A1:A3)' },
81
+ });
77
82
  }
78
83
  }, [model]);
79
84
 
@@ -82,7 +87,7 @@ const Grid = () => {
82
87
  }
83
88
 
84
89
  return (
85
- <div className='flex w-[40rem] overflow-hidden'>
90
+ <div className='flex is-[40rem] overflow-hidden'>
86
91
  <SheetProvider graph={graph} sheet={sheet}>
87
92
  <GridSheet />
88
93
  </SheetProvider>
@@ -102,10 +107,14 @@ const GraphStory = (props: EditorProps) => {
102
107
  const meta = {
103
108
  title: 'plugins/plugin-sheet/extensions',
104
109
  decorators: [
105
- withTheme,
106
- withClientProvider({ types: [SheetType], createIdentity: true, createSpace: true }),
110
+ withTheme(),
111
+ withClientProvider({
112
+ types: [Sheet.Sheet],
113
+ createIdentity: true,
114
+ createSpace: true,
115
+ }),
107
116
  // TODO(wittjosiah): Try to write story which does not depend on plugin manager.
108
- withPluginManager({ plugins: [IntentPlugin()] }),
117
+ withPluginManager({ plugins: [OperationPlugin(), RuntimePlugin()] }),
109
118
  withComputeGraphDecorator(),
110
119
  ],
111
120
  parameters: {
@@ -23,7 +23,7 @@ import {
23
23
  createSheetName,
24
24
  } from '@dxos/compute';
25
25
  import { invariant } from '@dxos/invariant';
26
- import { documentId, singleValueFacet } from '@dxos/react-ui-editor';
26
+ import { documentId, singleValueFacet } from '@dxos/ui-editor';
27
27
 
28
28
  const LANGUAGE_TAG = 'dx';
29
29
 
@@ -20,8 +20,8 @@ import { spreadsheet } from 'codemirror-lang-spreadsheet';
20
20
 
21
21
  import { type FunctionDefinition } from '@dxos/compute';
22
22
  import { RANGE_NOTATION } from '@dxos/compute';
23
- import { singleValueFacet } from '@dxos/react-ui-editor';
24
- import { mx } from '@dxos/react-ui-theme';
23
+ import { singleValueFacet } from '@dxos/ui-editor';
24
+ import { mx } from '@dxos/ui-theme';
25
25
 
26
26
  /**
27
27
  * https://codemirror.net/examples/styling
@@ -75,7 +75,10 @@ export type SheetExtensionOptions = {
75
75
  * https://hyperformula.handsontable.com/guide/key-concepts.html#grammar
76
76
  */
77
77
  export const sheetExtension = ({ debug, functions = [] }: SheetExtensionOptions): Extension => {
78
- const { extension, language } = spreadsheet({ idiom: 'en-US', decimalSeparator: '.' });
78
+ const { extension, language } = spreadsheet({
79
+ idiom: 'en-US',
80
+ decimalSeparator: '.',
81
+ });
79
82
 
80
83
  const createCompletion = (name: string) => {
81
84
  const { section = 'Custom', description, syntax } = functions.find((value) => value.name === name) ?? {};
@@ -166,7 +169,7 @@ export const sheetExtension = ({ debug, functions = [] }: SheetExtensionOptions)
166
169
  icons: false,
167
170
  tooltipClass: () =>
168
171
  mx(
169
- '!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]',
172
+ '!-left-[1px] !top-[33px] !-m-0 border !border-bs-0 [&>ul]:!min-w-[198px]',
170
173
  '[&>ul>li[aria-selected]]:!bg-accentSurface',
171
174
  'border-separator',
172
175
  ),
package/src/index.ts CHANGED
@@ -2,6 +2,6 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- export { SheetCapabilities } from './capabilities';
5
+ export { SheetCapabilities } from './types';
6
6
  export * from './meta';
7
7
  export * from './SheetPlugin';
@@ -2,26 +2,20 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import * as Function from 'effect/Function';
6
- import * as Schema from 'effect/Schema';
5
+ import * as Effect from 'effect/Effect';
7
6
  import { useCallback, useEffect, useMemo } from 'react';
8
7
 
9
- import {
10
- LayoutAction,
11
- chain,
12
- createIntent,
13
- createResolver,
14
- useIntentDispatcher,
15
- useIntentResolver,
16
- } from '@dxos/app-framework';
8
+ import { useOperationInvoker, useOperationResolver } from '@dxos/app-framework/ui';
9
+ import { LayoutOperation } from '@dxos/app-toolkit';
17
10
  import { debounce } from '@dxos/async';
18
11
  import { type CellAddress, type CompleteCellRange, inRange } from '@dxos/compute';
19
12
  import { Obj, Relation } from '@dxos/echo';
20
- import { ATTENDABLE_PATH_SEPARATOR, DeckAction } from '@dxos/plugin-deck/types';
21
- import { ThreadAction, ThreadType } from '@dxos/plugin-thread/types';
22
- import { Filter, Query, fullyQualifiedId, getSpace, useQuery } from '@dxos/react-client/echo';
13
+ import { OperationResolver } from '@dxos/operation';
14
+ import { ATTENDABLE_PATH_SEPARATOR, DeckOperation } from '@dxos/plugin-deck/types';
15
+ import { ThreadOperation } from '@dxos/plugin-thread/types';
16
+ import { Filter, Query, useQuery } from '@dxos/react-client/echo';
23
17
  import { type DxGridElement, type GridContentProps } from '@dxos/react-ui-grid';
24
- import { AnchoredTo } from '@dxos/schema';
18
+ import { AnchoredTo, Thread } from '@dxos/types';
25
19
 
26
20
  import { useSheetContext } from '../components';
27
21
  import { meta } from '../meta';
@@ -45,43 +39,37 @@ export const parseThreadAnchorAsCellRange = (cursor: string): CompleteCellRange
45
39
 
46
40
  export const useUpdateFocusedCellOnThreadSelection = (grid: DxGridElement | null) => {
47
41
  const { model, setActiveRefs } = useSheetContext();
48
- const scrollIntoViewResolver = useMemo(
42
+ const sheetId = Obj.getDXN(model.sheet).toString();
43
+
44
+ const scrollIntoViewHandler = useMemo(
49
45
  () =>
50
- createResolver({
51
- intent: LayoutAction.ScrollIntoView,
46
+ OperationResolver.make({
47
+ operation: LayoutOperation.ScrollIntoView,
52
48
  position: 'hoist',
53
- filter: (
54
- data,
55
- ): data is {
56
- part: 'current';
57
- subject: string;
58
- options: { cursor: string; ref: GridContentProps['activeRefs'] };
59
- } => {
60
- if (!Schema.is(LayoutAction.ScrollIntoView.fields.input)(data)) {
61
- return false;
62
- }
63
-
64
- return data.subject === fullyQualifiedId(model.sheet) && !!data.options?.cursor;
65
- },
66
- resolve: ({ options: { cursor, ref } }) => {
67
- setActiveRefs(ref);
68
- // TODO(Zan): Everywhere we refer to the cursor in a thread context should change to `anchor`.
69
- const range = parseThreadAnchorAsCellRange(cursor!);
70
- range && grid?.setFocus({ ...range.to, plane: 'grid' }, true);
71
- },
49
+ filter: (input) => input.subject === sheetId && !!input.cursor,
50
+ handler: (input) =>
51
+ Effect.sync(() => {
52
+ const { cursor, ref } = input;
53
+ if (cursor) {
54
+ setActiveRefs(ref as GridContentProps['activeRefs']);
55
+ // TODO(Zan): Everywhere we refer to the cursor in a thread context should change to `anchor`.
56
+ const range = parseThreadAnchorAsCellRange(cursor);
57
+ range && grid?.setFocus({ ...range.to, plane: 'grid' }, true);
58
+ }
59
+ }),
72
60
  }),
73
- [model.sheet, setActiveRefs],
61
+ [sheetId, setActiveRefs, grid],
74
62
  );
75
63
 
76
- useIntentResolver(meta.id, scrollIntoViewResolver);
64
+ useOperationResolver(meta.id, scrollIntoViewHandler);
77
65
  };
78
66
 
79
67
  export const useSelectThreadOnCellFocus = () => {
80
68
  const { model, cursor } = useSheetContext();
81
- const { dispatchPromise: dispatch } = useIntentDispatcher();
69
+ const { invokePromise } = useOperationInvoker();
82
70
 
83
- const space = getSpace(model.sheet);
84
- const anchors = useQuery(space, Query.select(Filter.ids(model.sheet.id)).targetOf(AnchoredTo));
71
+ const db = Obj.getDatabase(model.sheet);
72
+ const anchors = useQuery(db, Query.select(Filter.id(model.sheet.id)).targetOf(AnchoredTo.AnchoredTo));
85
73
 
86
74
  const selectClosestThread = useCallback(
87
75
  (cellAddress: CellAddress) => {
@@ -91,7 +79,7 @@ export const useSelectThreadOnCellFocus = () => {
91
79
 
92
80
  const closestThread = anchors.find((anchor) => {
93
81
  const source = Relation.getSource(anchor);
94
- if (anchor.anchor && Obj.instanceOf(ThreadType, source)) {
82
+ if (anchor.anchor && Obj.instanceOf(Thread.Thread, source)) {
95
83
  const range = parseThreadAnchorAsCellRange(anchor.anchor);
96
84
  return range ? inRange(range, cellAddress) : false;
97
85
  } else {
@@ -100,15 +88,17 @@ export const useSelectThreadOnCellFocus = () => {
100
88
  });
101
89
 
102
90
  if (closestThread) {
103
- const primary = fullyQualifiedId(model.sheet);
104
- const intent = Function.pipe(
105
- createIntent(ThreadAction.Select, { current: fullyQualifiedId(closestThread) }),
106
- chain(DeckAction.ChangeCompanion, { primary, companion: `${primary}${ATTENDABLE_PATH_SEPARATOR}comments` }),
107
- );
108
- void dispatch(intent);
91
+ const primary = Obj.getDXN(model.sheet).toString();
92
+ void (async () => {
93
+ await invokePromise(ThreadOperation.Select, { current: Relation.getDXN(closestThread).toString() });
94
+ await invokePromise(DeckOperation.ChangeCompanion, {
95
+ primary,
96
+ companion: `${primary}${ATTENDABLE_PATH_SEPARATOR}comments`,
97
+ });
98
+ })();
109
99
  }
110
100
  },
111
- [dispatch, anchors],
101
+ [invokePromise, anchors],
112
102
  );
113
103
 
114
104
  const debounced = useMemo(() => {