@dxos/plugin-sheet 0.8.3 → 0.8.4-main.1068cf700f
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/lib/browser/SheetContainer-6DNFC4TY.mjs +397 -0
- package/dist/lib/browser/SheetContainer-6DNFC4TY.mjs.map +7 -0
- package/dist/lib/browser/anchor-sort-AMMLA66W.mjs +24 -0
- package/dist/lib/browser/anchor-sort-AMMLA66W.mjs.map +7 -0
- package/dist/lib/browser/chunk-EDWHV64N.mjs +1473 -0
- package/dist/lib/browser/chunk-EDWHV64N.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FJRLDX7Z.mjs → chunk-IFLWVS2V.mjs} +7 -7
- package/dist/lib/browser/chunk-IFLWVS2V.mjs.map +7 -0
- package/dist/lib/browser/chunk-KE3AKN5W.mjs +397 -0
- package/dist/lib/browser/chunk-KE3AKN5W.mjs.map +7 -0
- package/dist/lib/browser/compute-graph-registry-RC5L7RE4.mjs +21 -0
- package/dist/lib/browser/compute-graph-registry-RC5L7RE4.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +80 -89
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/markdown-D2T2DOVX.mjs +29 -0
- package/dist/lib/browser/markdown-D2T2DOVX.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-P2RX75DA.mjs +79 -0
- package/dist/lib/browser/operation-resolver-P2RX75DA.mjs.map +7 -0
- package/dist/lib/browser/react-surface-45CRAB5G.mjs +51 -0
- package/dist/lib/browser/react-surface-45CRAB5G.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -12
- package/dist/lib/node-esm/SheetContainer-7H5R7M54.mjs +398 -0
- package/dist/lib/node-esm/SheetContainer-7H5R7M54.mjs.map +7 -0
- package/dist/lib/node-esm/anchor-sort-VHMBRX2E.mjs +25 -0
- package/dist/lib/node-esm/anchor-sort-VHMBRX2E.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-6J5L47IB.mjs +398 -0
- package/dist/lib/node-esm/chunk-6J5L47IB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-AYSEWH7N.mjs +1474 -0
- package/dist/lib/node-esm/chunk-AYSEWH7N.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-NMCVJWDT.mjs → chunk-PPOYR7DK.mjs} +7 -7
- package/dist/lib/node-esm/chunk-PPOYR7DK.mjs.map +7 -0
- package/dist/lib/node-esm/compute-graph-registry-ZGXVLVGD.mjs +22 -0
- package/dist/lib/node-esm/compute-graph-registry-ZGXVLVGD.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +80 -89
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/markdown-PTV72DLO.mjs +30 -0
- package/dist/lib/node-esm/markdown-PTV72DLO.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-WPIWQ5IO.mjs +80 -0
- package/dist/lib/node-esm/operation-resolver-WPIWQ5IO.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-ITV2L6HK.mjs +52 -0
- package/dist/lib/node-esm/react-surface-ITV2L6HK.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +7 -12
- package/dist/types/src/SheetPlugin.d.ts +2 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts +6 -0
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts.map +1 -0
- package/dist/types/src/capabilities/anchor-sort/index.d.ts +3 -0
- package/dist/types/src/capabilities/anchor-sort/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts +5 -0
- package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-graph-registry/index.d.ts +3 -0
- package/dist/types/src/capabilities/compute-graph-registry/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -11
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown/index.d.ts +3 -0
- package/dist/types/src/capabilities/markdown/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown/markdown.d.ts +5 -0
- package/dist/types/src/capabilities/markdown/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts +9 -4
- package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +51 -3
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts +11 -20
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/util.d.ts +1 -1
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
- package/dist/types/src/components/RangeList/RangeList.d.ts +2 -2
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +5 -6
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +54 -5
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +3 -3
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +3 -4
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +88 -4
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/align.d.ts +13 -20
- package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/style.d.ts +12 -18
- package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts +14 -1
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.d.ts +1 -1
- package/dist/types/src/extensions/compute.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.stories.d.ts +10 -13
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/index.d.ts +1 -1
- package/dist/types/src/extensions/editor/index.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/{extension.d.ts → sheet-extension.d.ts} +1 -1
- package/dist/types/src/extensions/editor/sheet-extension.d.ts.map +1 -0
- package/dist/types/src/extensions/editor/sheet-extension.test.d.ts +2 -0
- package/dist/types/src/extensions/editor/sheet-extension.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +6 -6
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/model/testing.d.ts +2 -2
- package/dist/types/src/model/testing.d.ts.map +1 -1
- package/dist/types/src/model/useSheetModel.d.ts +2 -2
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
- package/dist/types/src/playwright/playwright.config.d.ts +3 -0
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
- package/dist/types/src/{testing/playwright → playwright}/sheet-manager.d.ts +1 -1
- package/dist/types/src/playwright/sheet-manager.d.ts.map +1 -0
- package/dist/types/src/playwright/sheet.spec.d.ts.map +1 -0
- package/dist/types/src/serializer.d.ts +2 -2
- package/dist/types/src/serializer.d.ts.map +1 -1
- package/dist/types/src/testing/data.d.ts +2 -2
- package/dist/types/src/testing/data.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +27 -3
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +8 -62
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Sheet.d.ts +76 -0
- package/dist/types/src/types/Sheet.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts +6 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/sheet-range-types.d.ts +2 -2
- package/dist/types/src/types/sheet-range-types.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +92 -75
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/types/util.d.ts +10 -10
- package/dist/types/src/types/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +83 -73
- package/src/SheetPlugin.tsx +53 -65
- package/src/capabilities/anchor-sort/anchor-sort.ts +27 -0
- package/src/capabilities/anchor-sort/index.ts +7 -0
- package/src/capabilities/compute-graph-registry/compute-graph-registry.ts +27 -0
- package/src/capabilities/compute-graph-registry/index.ts +7 -0
- package/src/capabilities/index.ts +5 -9
- package/src/capabilities/markdown/index.ts +7 -0
- package/src/capabilities/markdown/markdown.ts +30 -0
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +77 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +43 -0
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -1
- package/src/components/ComputeGraph/compute-graph.stories.tsx +21 -20
- package/src/components/FunctionEditor/FunctionEditor.tsx +2 -2
- package/src/components/GridSheet/GridSheet.stories.tsx +23 -17
- package/src/components/GridSheet/GridSheet.tsx +63 -52
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +44 -43
- package/src/components/GridSheet/util.ts +17 -11
- package/src/components/RangeList/RangeList.tsx +13 -10
- package/src/components/SheetContainer/SheetContainer.stories.tsx +71 -47
- package/src/components/SheetContainer/SheetContainer.tsx +30 -18
- package/src/components/SheetContext/SheetContext.tsx +9 -9
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +19 -13
- package/src/components/SheetToolbar/SheetToolbar.tsx +52 -42
- package/src/components/SheetToolbar/align.ts +46 -20
- package/src/components/SheetToolbar/style.ts +48 -18
- package/src/components/SheetToolbar/useToolbarState.ts +22 -5
- package/src/extensions/compute.stories.tsx +43 -30
- package/src/extensions/compute.ts +3 -4
- package/src/extensions/editor/index.ts +1 -1
- package/src/extensions/editor/{extension.test.ts → sheet-extension.test.ts} +1 -1
- package/src/extensions/editor/{extension.ts → sheet-extension.ts} +7 -4
- package/src/index.ts +1 -1
- package/src/integrations/thread-ranges.ts +43 -51
- package/src/meta.ts +9 -7
- package/src/model/sheet-model.test.ts +5 -4
- package/src/model/sheet-model.ts +85 -53
- package/src/model/testing.ts +4 -4
- package/src/model/useSheetModel.ts +2 -2
- package/src/playwright/playwright.config.ts +17 -0
- package/src/{testing/playwright → playwright}/sheet-manager.ts +1 -1
- package/src/{testing/playwright → playwright}/sheet.spec.ts +3 -2
- package/src/sanity.test.ts +4 -5
- package/src/serializer.ts +4 -4
- package/src/testing/data.ts +2 -2
- package/src/testing/testing.tsx +11 -5
- package/src/translations.ts +10 -7
- package/src/types/Sheet.ts +97 -0
- package/src/types/capabilities.ts +14 -0
- package/src/types/index.ts +2 -1
- package/src/types/sheet-range-types.ts +2 -2
- package/src/types/types.ts +84 -49
- package/src/types/util.ts +14 -41
- package/dist/lib/browser/SheetContainer-BDZXBB5U.mjs +0 -351
- package/dist/lib/browser/SheetContainer-BDZXBB5U.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-NYYZLRAA.mjs +0 -24
- package/dist/lib/browser/anchor-sort-NYYZLRAA.mjs.map +0 -7
- package/dist/lib/browser/chunk-5TA43LO4.mjs +0 -847
- package/dist/lib/browser/chunk-5TA43LO4.mjs.map +0 -7
- package/dist/lib/browser/chunk-D3G4UGEK.mjs +0 -18
- package/dist/lib/browser/chunk-D3G4UGEK.mjs.map +0 -7
- package/dist/lib/browser/chunk-FJRLDX7Z.mjs.map +0 -7
- package/dist/lib/browser/chunk-I7FZ4TWJ.mjs +0 -892
- package/dist/lib/browser/chunk-I7FZ4TWJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-IR42IS3F.mjs +0 -15
- package/dist/lib/browser/chunk-IR42IS3F.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-registry-IXGGJJBU.mjs +0 -30
- package/dist/lib/browser/compute-graph-registry-IXGGJJBU.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-IBBI6B74.mjs +0 -56
- package/dist/lib/browser/intent-resolver-IBBI6B74.mjs.map +0 -7
- package/dist/lib/browser/markdown-T4TUP4BF.mjs +0 -26
- package/dist/lib/browser/markdown-T4TUP4BF.mjs.map +0 -7
- package/dist/lib/browser/react-surface-UI46P43F.mjs +0 -53
- package/dist/lib/browser/react-surface-UI46P43F.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-VWPM3HYJ.cjs +0 -351
- package/dist/lib/node/SheetContainer-VWPM3HYJ.cjs.map +0 -7
- package/dist/lib/node/anchor-sort-A7NABMJM.cjs +0 -39
- package/dist/lib/node/anchor-sort-A7NABMJM.cjs.map +0 -7
- package/dist/lib/node/chunk-FIM6EZ6M.cjs +0 -256
- package/dist/lib/node/chunk-FIM6EZ6M.cjs.map +0 -7
- package/dist/lib/node/chunk-JSIDCZHB.cjs +0 -41
- package/dist/lib/node/chunk-JSIDCZHB.cjs.map +0 -7
- package/dist/lib/node/chunk-LJWWS53Z.cjs +0 -34
- package/dist/lib/node/chunk-LJWWS53Z.cjs.map +0 -7
- package/dist/lib/node/chunk-N7FSEUIN.cjs +0 -927
- package/dist/lib/node/chunk-N7FSEUIN.cjs.map +0 -7
- package/dist/lib/node/chunk-ST3WA73J.cjs +0 -855
- package/dist/lib/node/chunk-ST3WA73J.cjs.map +0 -7
- package/dist/lib/node/compute-graph-registry-ARLDHPFW.cjs +0 -56
- package/dist/lib/node/compute-graph-registry-ARLDHPFW.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -173
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-2657YDOU.cjs +0 -69
- package/dist/lib/node/intent-resolver-2657YDOU.cjs.map +0 -7
- package/dist/lib/node/markdown-DBPOAYI7.cjs +0 -40
- package/dist/lib/node/markdown-DBPOAYI7.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/react-surface-XQEIRKWU.cjs +0 -71
- package/dist/lib/node/react-surface-XQEIRKWU.cjs.map +0 -7
- package/dist/lib/node/types/index.cjs +0 -84
- package/dist/lib/node/types/index.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-V632Q4HA.mjs +0 -352
- package/dist/lib/node-esm/SheetContainer-V632Q4HA.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-JTNZOE67.mjs +0 -25
- package/dist/lib/node-esm/anchor-sort-JTNZOE67.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-C4IKYVTV.mjs +0 -893
- package/dist/lib/node-esm/chunk-C4IKYVTV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IQ76YE6M.mjs +0 -16
- package/dist/lib/node-esm/chunk-IQ76YE6M.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NMCVJWDT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SOC52B67.mjs +0 -848
- package/dist/lib/node-esm/chunk-SOC52B67.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Y6ND5HWX.mjs +0 -20
- package/dist/lib/node-esm/chunk-Y6ND5HWX.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-registry-7PDWXMHF.mjs +0 -31
- package/dist/lib/node-esm/compute-graph-registry-7PDWXMHF.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-M2HNR7PJ.mjs +0 -57
- package/dist/lib/node-esm/intent-resolver-M2HNR7PJ.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-WWUJ3E5F.mjs +0 -27
- package/dist/lib/node-esm/markdown-WWUJ3E5F.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-OLXO2MVB.mjs +0 -54
- package/dist/lib/node-esm/react-surface-OLXO2MVB.mjs.map +0 -7
- package/dist/types/src/capabilities/anchor-sort.d.ts +0 -6
- package/dist/types/src/capabilities/anchor-sort.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -5
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/compute-graph-registry.d.ts +0 -4
- package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown.d.ts +0 -6
- package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/extensions/editor/extension.d.ts.map +0 -1
- package/dist/types/src/extensions/editor/extension.test.d.ts +0 -2
- package/dist/types/src/extensions/editor/extension.test.d.ts.map +0 -1
- package/dist/types/src/testing/playwright/sheet-manager.d.ts.map +0 -1
- package/dist/types/src/testing/playwright/sheet.spec.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -37
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capabilities/anchor-sort.ts +0 -22
- package/src/capabilities/capabilities.ts +0 -14
- package/src/capabilities/compute-graph-registry.ts +0 -28
- package/src/capabilities/intent-resolver.ts +0 -38
- package/src/capabilities/markdown.ts +0 -22
- package/src/capabilities/react-surface.tsx +0 -39
- package/src/testing/playwright/playwright.config.cts +0 -18
- package/src/types/schema.ts +0 -60
- /package/dist/types/src/{testing/playwright → playwright}/sheet.spec.d.ts +0 -0
|
@@ -2,16 +2,25 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
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 {
|
|
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
|
-
import {
|
|
17
|
+
import { meta } from '../../meta';
|
|
11
18
|
import { type SheetModel } from '../../model';
|
|
12
|
-
import {
|
|
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 = (
|
|
33
|
+
export const useStyleState = (stateAtom: ToolbarStateAtom) => {
|
|
34
|
+
const registry = useContext(RegistryContext);
|
|
25
35
|
const { cursorFallbackRange, model } = useSheetContext();
|
|
26
36
|
|
|
27
37
|
useEffect(() => {
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
46
|
+
if (value === 'highlight') {
|
|
47
|
+
highlight = true;
|
|
48
|
+
}
|
|
49
|
+
if (value === 'softwrap') {
|
|
50
|
+
softwrap = true;
|
|
51
|
+
}
|
|
37
52
|
});
|
|
38
53
|
}
|
|
39
|
-
|
|
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
|
-
|
|
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,27 +103,31 @@ const createStyleActions = (model: SheetModel, state: StyleState, cursorFallback
|
|
|
77
103
|
) {
|
|
78
104
|
// this value should be unset
|
|
79
105
|
if (index >= 0) {
|
|
80
|
-
model.sheet
|
|
106
|
+
Obj.change(model.sheet, (obj) => {
|
|
107
|
+
obj.ranges?.splice(index, 1);
|
|
108
|
+
});
|
|
81
109
|
}
|
|
82
|
-
|
|
110
|
+
registry.set(stateAtom, { ...currentState, [nextRangeEntity.value]: false });
|
|
83
111
|
} else {
|
|
84
|
-
model.sheet
|
|
85
|
-
|
|
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
|
{
|
|
89
119
|
key: 'style',
|
|
90
120
|
value: styleValue as StyleValue,
|
|
91
121
|
icon,
|
|
92
|
-
label: [`range value ${styleValue} label`, { ns:
|
|
122
|
+
label: [`range value ${styleValue} label`, { ns: meta.id }],
|
|
93
123
|
checked: !!state[styleValue as StyleValue],
|
|
94
124
|
},
|
|
95
125
|
);
|
|
96
126
|
});
|
|
97
127
|
|
|
98
|
-
export const createStyle = (
|
|
99
|
-
const styleGroupAction = createStyleGroup(state);
|
|
100
|
-
const styleActions = createStyleActions(
|
|
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 {
|
|
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
|
-
|
|
15
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Hook to get the registry for updating toolbar state.
|
|
30
|
+
*/
|
|
31
|
+
export const useToolbarStateRegistry = (): Registry.Registry => {
|
|
32
|
+
return useContext(RegistryContext);
|
|
16
33
|
};
|
|
@@ -2,31 +2,32 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useEffect, useMemo } from 'react';
|
|
9
7
|
|
|
8
|
+
import { OperationPlugin, RuntimePlugin } from '@dxos/app-framework';
|
|
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
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
15
|
+
import { useTextEditor } from '@dxos/react-ui-editor';
|
|
14
16
|
import {
|
|
15
17
|
createBasicExtensions,
|
|
16
18
|
createMarkdownExtensions,
|
|
17
19
|
createThemeExtensions,
|
|
18
20
|
decorateMarkdown,
|
|
19
21
|
documentId,
|
|
20
|
-
|
|
21
|
-
} from '@dxos/react-ui-editor';
|
|
22
|
-
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
22
|
+
} from '@dxos/ui-editor';
|
|
23
23
|
import { isNonNullable } from '@dxos/util';
|
|
24
24
|
|
|
25
|
-
import { compute, computeGraphFacet } from './compute';
|
|
26
25
|
import { GridSheet, SheetProvider, useComputeGraph } from '../components';
|
|
27
26
|
import { useSheetModel } from '../model';
|
|
28
27
|
import { useTestSheet, withComputeGraphDecorator } from '../testing';
|
|
29
|
-
import {
|
|
28
|
+
import { Sheet } from '../types';
|
|
29
|
+
|
|
30
|
+
import { compute, computeGraphFacet } from './compute';
|
|
30
31
|
|
|
31
32
|
const str = (...lines: string[]) => lines.join('\n');
|
|
32
33
|
|
|
@@ -41,7 +42,7 @@ type EditorProps = {
|
|
|
41
42
|
|
|
42
43
|
const SHEET_NAME = 'Test Sheet';
|
|
43
44
|
|
|
44
|
-
const
|
|
45
|
+
const DefaultStory = ({ text }: EditorProps) => {
|
|
45
46
|
const id = useMemo(() => PublicKey.random(), []);
|
|
46
47
|
const { themeMode } = useThemeContext();
|
|
47
48
|
const space = useSpace();
|
|
@@ -51,7 +52,7 @@ const EditorStory = ({ text }: EditorProps) => {
|
|
|
51
52
|
initialValue: text,
|
|
52
53
|
extensions: [
|
|
53
54
|
createBasicExtensions(),
|
|
54
|
-
createMarkdownExtensions(
|
|
55
|
+
createMarkdownExtensions(),
|
|
55
56
|
createThemeExtensions({ themeMode, syntaxHighlighting: true }),
|
|
56
57
|
documentId.of(id.toHex()),
|
|
57
58
|
computeGraph && computeGraphFacet.of(computeGraph),
|
|
@@ -62,7 +63,7 @@ const EditorStory = ({ text }: EditorProps) => {
|
|
|
62
63
|
[computeGraph, themeMode],
|
|
63
64
|
);
|
|
64
65
|
|
|
65
|
-
return <div className='
|
|
66
|
+
return <div className='is-[40rem] overflow-hidden' ref={parentRef} {...focusAttributes} />;
|
|
66
67
|
};
|
|
67
68
|
|
|
68
69
|
const Grid = () => {
|
|
@@ -72,7 +73,12 @@ const Grid = () => {
|
|
|
72
73
|
const model = useSheetModel(graph, sheet);
|
|
73
74
|
useEffect(() => {
|
|
74
75
|
if (model) {
|
|
75
|
-
model.setValues({
|
|
76
|
+
model.setValues({
|
|
77
|
+
A1: { value: 100 },
|
|
78
|
+
A2: { value: 200 },
|
|
79
|
+
A3: { value: 300 },
|
|
80
|
+
A5: { value: '=SUM(A1:A3)' },
|
|
81
|
+
});
|
|
76
82
|
}
|
|
77
83
|
}, [model]);
|
|
78
84
|
|
|
@@ -81,7 +87,7 @@ const Grid = () => {
|
|
|
81
87
|
}
|
|
82
88
|
|
|
83
89
|
return (
|
|
84
|
-
<div className='flex
|
|
90
|
+
<div className='flex is-[40rem] overflow-hidden'>
|
|
85
91
|
<SheetProvider graph={graph} sheet={sheet}>
|
|
86
92
|
<GridSheet />
|
|
87
93
|
</SheetProvider>
|
|
@@ -92,15 +98,35 @@ const Grid = () => {
|
|
|
92
98
|
const GraphStory = (props: EditorProps) => {
|
|
93
99
|
return (
|
|
94
100
|
<div className='grid grid-rows-2'>
|
|
95
|
-
<
|
|
101
|
+
<DefaultStory {...props} />
|
|
96
102
|
<Grid />
|
|
97
103
|
</div>
|
|
98
104
|
);
|
|
99
105
|
};
|
|
100
106
|
|
|
107
|
+
const meta = {
|
|
108
|
+
title: 'plugins/plugin-sheet/extensions',
|
|
109
|
+
decorators: [
|
|
110
|
+
withTheme(),
|
|
111
|
+
withClientProvider({
|
|
112
|
+
types: [Sheet.Sheet],
|
|
113
|
+
createIdentity: true,
|
|
114
|
+
createSpace: true,
|
|
115
|
+
}),
|
|
116
|
+
// TODO(wittjosiah): Try to write story which does not depend on plugin manager.
|
|
117
|
+
withPluginManager({ plugins: [OperationPlugin(), RuntimePlugin()] }),
|
|
118
|
+
withComputeGraphDecorator(),
|
|
119
|
+
],
|
|
120
|
+
parameters: {
|
|
121
|
+
layout: 'fullscreen',
|
|
122
|
+
},
|
|
123
|
+
} satisfies Meta;
|
|
124
|
+
|
|
125
|
+
export default meta;
|
|
126
|
+
|
|
101
127
|
// TODO(burdon): Inline formulae.
|
|
102
|
-
export const Default = {
|
|
103
|
-
render:
|
|
128
|
+
export const Default: StoryObj<typeof DefaultStory> = {
|
|
129
|
+
render: DefaultStory,
|
|
104
130
|
args: {
|
|
105
131
|
text: str(
|
|
106
132
|
//
|
|
@@ -123,7 +149,7 @@ export const Default = {
|
|
|
123
149
|
},
|
|
124
150
|
};
|
|
125
151
|
|
|
126
|
-
export const Graph = {
|
|
152
|
+
export const Graph: StoryObj<typeof GraphStory> = {
|
|
127
153
|
render: GraphStory,
|
|
128
154
|
args: {
|
|
129
155
|
text: str(
|
|
@@ -140,16 +166,3 @@ export const Graph = {
|
|
|
140
166
|
),
|
|
141
167
|
},
|
|
142
168
|
};
|
|
143
|
-
|
|
144
|
-
const meta: Meta = {
|
|
145
|
-
title: 'plugins/plugin-sheet/extensions',
|
|
146
|
-
decorators: [
|
|
147
|
-
withClientProvider({ types: [SheetType], createIdentity: true, createSpace: true }),
|
|
148
|
-
withComputeGraphDecorator(),
|
|
149
|
-
withTheme,
|
|
150
|
-
withLayout({ fullscreen: true, classNames: 'justify-center' }),
|
|
151
|
-
],
|
|
152
|
-
parameters: { layout: 'fullscreen' },
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export default meta;
|
|
@@ -16,14 +16,14 @@ import { Decoration, EditorView, ViewPlugin, WidgetType } from '@codemirror/view
|
|
|
16
16
|
|
|
17
17
|
import { type CleanupFn, debounce } from '@dxos/async';
|
|
18
18
|
import {
|
|
19
|
-
createSheetName,
|
|
20
19
|
type CellAddress,
|
|
21
20
|
type CellScalarValue,
|
|
22
21
|
type ComputeGraph,
|
|
23
22
|
type ComputeNode,
|
|
23
|
+
createSheetName,
|
|
24
24
|
} from '@dxos/compute';
|
|
25
25
|
import { invariant } from '@dxos/invariant';
|
|
26
|
-
import { documentId, singleValueFacet } from '@dxos/
|
|
26
|
+
import { documentId, singleValueFacet } from '@dxos/ui-editor';
|
|
27
27
|
|
|
28
28
|
const LANGUAGE_TAG = 'dx';
|
|
29
29
|
|
|
@@ -34,7 +34,7 @@ export const computeGraphFacet = singleValueFacet<ComputeGraph>();
|
|
|
34
34
|
|
|
35
35
|
export type ComputeOptions = {};
|
|
36
36
|
|
|
37
|
-
export const compute = (
|
|
37
|
+
export const compute = (_options: ComputeOptions = {}): Extension => {
|
|
38
38
|
let computeNode: ComputeNode | undefined;
|
|
39
39
|
|
|
40
40
|
const update = (state: EditorState, current?: RangeSet<Decoration>) => {
|
|
@@ -53,7 +53,6 @@ export const compute = (options: ComputeOptions = {}): Extension => {
|
|
|
53
53
|
const text = node.node.getChild('CodeText');
|
|
54
54
|
if (type === LANGUAGE_TAG && text) {
|
|
55
55
|
const formula = state.sliceDoc(text.from, text.to);
|
|
56
|
-
|
|
57
56
|
const iter = current?.iter(node.node.from);
|
|
58
57
|
if (iter?.value && iter?.value.spec.formula === formula) {
|
|
59
58
|
// Add existing widget.
|
|
@@ -10,7 +10,7 @@ import { describe, expect, test } from 'vitest';
|
|
|
10
10
|
|
|
11
11
|
import { defaultFunctions } from '@dxos/compute';
|
|
12
12
|
|
|
13
|
-
import { sheetExtension } from './extension';
|
|
13
|
+
import { sheetExtension } from './sheet-extension';
|
|
14
14
|
|
|
15
15
|
describe('formula parser', () => {
|
|
16
16
|
const {
|
|
@@ -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/
|
|
24
|
-
import { mx } from '@dxos/
|
|
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({
|
|
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-
|
|
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,28 +2,23 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
6
|
import { useCallback, useEffect, useMemo } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
createResolver,
|
|
11
|
-
LayoutAction,
|
|
12
|
-
useIntentResolver,
|
|
13
|
-
useIntentDispatcher,
|
|
14
|
-
chain,
|
|
15
|
-
} from '@dxos/app-framework';
|
|
8
|
+
import { useOperationInvoker, useOperationResolver } from '@dxos/app-framework/ui';
|
|
9
|
+
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
16
10
|
import { debounce } from '@dxos/async';
|
|
17
11
|
import { type CellAddress, type CompleteCellRange, inRange } from '@dxos/compute';
|
|
18
12
|
import { Obj, Relation } from '@dxos/echo';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
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';
|
|
17
|
+
import { type DxGridElement, type GridContentProps } from '@dxos/react-ui-grid';
|
|
18
|
+
import { AnchoredTo, Thread } from '@dxos/types';
|
|
24
19
|
|
|
25
20
|
import { useSheetContext } from '../components';
|
|
26
|
-
import {
|
|
21
|
+
import { meta } from '../meta';
|
|
27
22
|
|
|
28
23
|
export const completeCellRangeToThreadCursor = (range: CompleteCellRange): string => {
|
|
29
24
|
return `${range.from.col},${range.from.row},${range.to.col},${range.to.row}`;
|
|
@@ -44,43 +39,37 @@ export const parseThreadAnchorAsCellRange = (cursor: string): CompleteCellRange
|
|
|
44
39
|
|
|
45
40
|
export const useUpdateFocusedCellOnThreadSelection = (grid: DxGridElement | null) => {
|
|
46
41
|
const { model, setActiveRefs } = useSheetContext();
|
|
47
|
-
const
|
|
42
|
+
const sheetId = Obj.getDXN(model.sheet).toString();
|
|
43
|
+
|
|
44
|
+
const scrollIntoViewHandler = useMemo(
|
|
48
45
|
() =>
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
OperationResolver.make({
|
|
47
|
+
operation: LayoutOperation.ScrollIntoView,
|
|
51
48
|
position: 'hoist',
|
|
52
|
-
filter: (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return data.subject === fullyQualifiedId(model.sheet) && !!data.options?.cursor;
|
|
64
|
-
},
|
|
65
|
-
resolve: ({ options: { cursor, ref } }) => {
|
|
66
|
-
setActiveRefs(ref);
|
|
67
|
-
// TODO(Zan): Everywhere we refer to the cursor in a thread context should change to `anchor`.
|
|
68
|
-
const range = parseThreadAnchorAsCellRange(cursor!);
|
|
69
|
-
range && grid?.setFocus({ ...range.to, plane: 'grid' }, true);
|
|
70
|
-
},
|
|
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
|
+
}),
|
|
71
60
|
}),
|
|
72
|
-
[
|
|
61
|
+
[sheetId, setActiveRefs, grid],
|
|
73
62
|
);
|
|
74
63
|
|
|
75
|
-
|
|
64
|
+
useOperationResolver(meta.id, scrollIntoViewHandler);
|
|
76
65
|
};
|
|
77
66
|
|
|
78
67
|
export const useSelectThreadOnCellFocus = () => {
|
|
79
68
|
const { model, cursor } = useSheetContext();
|
|
80
|
-
const {
|
|
69
|
+
const { invokePromise } = useOperationInvoker();
|
|
81
70
|
|
|
82
|
-
const
|
|
83
|
-
const anchors = useQuery(
|
|
71
|
+
const db = Obj.getDatabase(model.sheet);
|
|
72
|
+
const anchors = useQuery(db, Query.select(Filter.id(model.sheet.id)).targetOf(AnchoredTo.AnchoredTo));
|
|
84
73
|
|
|
85
74
|
const selectClosestThread = useCallback(
|
|
86
75
|
(cellAddress: CellAddress) => {
|
|
@@ -90,7 +79,7 @@ export const useSelectThreadOnCellFocus = () => {
|
|
|
90
79
|
|
|
91
80
|
const closestThread = anchors.find((anchor) => {
|
|
92
81
|
const source = Relation.getSource(anchor);
|
|
93
|
-
if (anchor.anchor && Obj.instanceOf(
|
|
82
|
+
if (anchor.anchor && Obj.instanceOf(Thread.Thread, source)) {
|
|
94
83
|
const range = parseThreadAnchorAsCellRange(anchor.anchor);
|
|
95
84
|
return range ? inRange(range, cellAddress) : false;
|
|
96
85
|
} else {
|
|
@@ -99,25 +88,28 @@ export const useSelectThreadOnCellFocus = () => {
|
|
|
99
88
|
});
|
|
100
89
|
|
|
101
90
|
if (closestThread) {
|
|
102
|
-
const primary =
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
+
})();
|
|
108
99
|
}
|
|
109
100
|
},
|
|
110
|
-
[
|
|
101
|
+
[invokePromise, anchors],
|
|
111
102
|
);
|
|
112
103
|
|
|
113
104
|
const debounced = useMemo(() => {
|
|
114
|
-
return debounce((cellCoords:
|
|
105
|
+
return debounce((cellCoords: CellAddress) => requestAnimationFrame(() => selectClosestThread(cellCoords)), 50);
|
|
115
106
|
}, [selectClosestThread]);
|
|
116
107
|
|
|
117
108
|
useEffect(() => {
|
|
118
109
|
if (!cursor) {
|
|
119
110
|
return;
|
|
120
111
|
}
|
|
112
|
+
|
|
121
113
|
debounced(cursor);
|
|
122
114
|
}, [cursor, debounced]);
|
|
123
115
|
};
|
package/src/meta.ts
CHANGED
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
6
7
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
export const meta: PluginMeta = {
|
|
10
|
-
id: SHEET_PLUGIN,
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
|
+
id: 'dxos.org/plugin/sheet',
|
|
11
10
|
name: 'Sheet',
|
|
12
|
-
description:
|
|
13
|
-
|
|
11
|
+
description: trim`
|
|
12
|
+
Full-featured spreadsheet application with over 400 built-in formulas for calculations and data analysis.
|
|
13
|
+
Create custom JavaScript functions and integrate with AI agents for advanced automation.
|
|
14
|
+
`,
|
|
14
15
|
icon: 'ph--grid-nine--regular',
|
|
16
|
+
iconHue: 'indigo',
|
|
15
17
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-sheet',
|
|
16
18
|
screenshots: ['https://dxos.network/plugin-details-sheet-dark.png'],
|
|
17
19
|
};
|
|
@@ -7,17 +7,18 @@ import { afterEach, beforeEach, describe, expect, onTestFinished, test } from 'v
|
|
|
7
7
|
import { Trigger } from '@dxos/async';
|
|
8
8
|
import { type CellScalarValue, addressFromA1Notation, isFormula } from '@dxos/compute';
|
|
9
9
|
import { TestBuilder, testFunctionPlugins } from '@dxos/compute/testing';
|
|
10
|
-
import {
|
|
10
|
+
import { Function } from '@dxos/functions';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
12
|
|
|
13
|
+
import { Sheet, mapFormulaIndicesToRefs, mapFormulaRefsToIndices } from '../types';
|
|
14
|
+
|
|
13
15
|
import { SheetModel } from './sheet-model';
|
|
14
16
|
import { createTestGrid } from './testing';
|
|
15
|
-
import { createSheet, mapFormulaIndicesToRefs, mapFormulaRefsToIndices } from '../types';
|
|
16
17
|
|
|
17
18
|
describe('SheetModel', () => {
|
|
18
19
|
let testBuilder: TestBuilder;
|
|
19
20
|
beforeEach(async () => {
|
|
20
|
-
testBuilder = new TestBuilder({ types: [
|
|
21
|
+
testBuilder = new TestBuilder({ types: [Function.Function], plugins: testFunctionPlugins });
|
|
21
22
|
await testBuilder.open();
|
|
22
23
|
});
|
|
23
24
|
afterEach(async () => {
|
|
@@ -30,7 +31,7 @@ describe('SheetModel', () => {
|
|
|
30
31
|
await graph.open();
|
|
31
32
|
|
|
32
33
|
// TODO(burdon): Create via factory.
|
|
33
|
-
const sheet =
|
|
34
|
+
const sheet = Sheet.make({ rows: 5, columns: 5 });
|
|
34
35
|
const model = new SheetModel(graph, sheet);
|
|
35
36
|
await model.open();
|
|
36
37
|
testBuilder.ctx.onDispose(() => model.close());
|