@dxos/plugin-sheet 0.7.4 → 0.7.5-labs.071a3e2
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-IMHGS7Z4.mjs +370 -0
- package/dist/lib/browser/SheetContainer-IMHGS7Z4.mjs.map +7 -0
- package/dist/lib/browser/chunk-AT7F2WDW.mjs +808 -0
- package/dist/lib/browser/chunk-AT7F2WDW.mjs.map +7 -0
- package/dist/lib/browser/chunk-FOO6NGBM.mjs +229 -0
- package/dist/lib/browser/chunk-FOO6NGBM.mjs.map +7 -0
- package/dist/lib/browser/chunk-GAFHJBCU.mjs +18 -0
- package/dist/lib/browser/chunk-GAFHJBCU.mjs.map +7 -0
- package/dist/lib/browser/chunk-LXHRT3CC.mjs +15 -0
- package/dist/lib/browser/chunk-LXHRT3CC.mjs.map +7 -0
- package/dist/lib/browser/chunk-OOSRC36N.mjs +900 -0
- package/dist/lib/browser/chunk-OOSRC36N.mjs.map +7 -0
- package/dist/lib/browser/compute-graph-registry-EGPD4HEX.mjs +27 -0
- package/dist/lib/browser/compute-graph-registry-EGPD4HEX.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +80 -324
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-6S2RMLQF.mjs +56 -0
- package/dist/lib/browser/intent-resolver-6S2RMLQF.mjs.map +7 -0
- package/dist/lib/browser/markdown-CFJIWHZX.mjs +26 -0
- package/dist/lib/browser/markdown-CFJIWHZX.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-PHKJZYFB.mjs +52 -0
- package/dist/lib/browser/react-surface-PHKJZYFB.mjs.map +7 -0
- package/dist/lib/browser/thread-7ZWW5EA7.mjs +17 -0
- package/dist/lib/browser/thread-7ZWW5EA7.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +62 -0
- package/dist/lib/node/SheetContainer-NNIZN4AK.cjs +364 -0
- package/dist/lib/node/SheetContainer-NNIZN4AK.cjs.map +7 -0
- package/dist/lib/node/chunk-2KCZUH72.cjs +815 -0
- package/dist/lib/node/chunk-2KCZUH72.cjs.map +7 -0
- package/dist/lib/node/chunk-4LSYTNS4.cjs +935 -0
- package/dist/lib/node/chunk-4LSYTNS4.cjs.map +7 -0
- package/dist/lib/node/{chunk-2ZVZI2KJ.cjs → chunk-MLU6KRQN.cjs} +12 -9
- package/dist/lib/node/chunk-MLU6KRQN.cjs.map +7 -0
- package/dist/lib/node/chunk-P4KSGZSS.cjs +251 -0
- package/dist/lib/node/chunk-P4KSGZSS.cjs.map +7 -0
- package/dist/lib/node/{types.cjs → chunk-ZV2RS3QH.cjs} +12 -16
- package/dist/lib/node/chunk-ZV2RS3QH.cjs.map +7 -0
- package/dist/lib/node/compute-graph-registry-GJK5H264.cjs +53 -0
- package/dist/lib/node/compute-graph-registry-GJK5H264.cjs.map +7 -0
- package/dist/lib/node/index.cjs +81 -318
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-I25V7SBT.cjs +69 -0
- package/dist/lib/node/intent-resolver-I25V7SBT.cjs.map +7 -0
- package/dist/lib/node/markdown-YTCSW66K.cjs +40 -0
- package/dist/lib/node/markdown-YTCSW66K.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-surface-HLE6CRA6.cjs +70 -0
- package/dist/lib/node/react-surface-HLE6CRA6.cjs.map +7 -0
- package/dist/lib/node/{meta.cjs → thread-DRNYTR6M.cjs} +12 -10
- package/dist/lib/node/thread-DRNYTR6M.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +84 -0
- package/dist/lib/node/types/index.cjs.map +7 -0
- package/dist/lib/node-esm/SheetContainer-PGDJKGTZ.mjs +371 -0
- package/dist/lib/node-esm/SheetContainer-PGDJKGTZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HPAMZ6SP.mjs +901 -0
- package/dist/lib/node-esm/chunk-HPAMZ6SP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-PTOI45NK.mjs +231 -0
- package/dist/lib/node-esm/chunk-PTOI45NK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-RTZXXOS2.mjs +20 -0
- package/dist/lib/node-esm/chunk-RTZXXOS2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SX3S7UKU.mjs +16 -0
- package/dist/lib/node-esm/chunk-SX3S7UKU.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZM7XLUGL.mjs +809 -0
- package/dist/lib/node-esm/chunk-ZM7XLUGL.mjs.map +7 -0
- package/dist/lib/node-esm/compute-graph-registry-3F5JCYEN.mjs +28 -0
- package/dist/lib/node-esm/compute-graph-registry-3F5JCYEN.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +80 -324
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-IPRSINII.mjs +57 -0
- package/dist/lib/node-esm/intent-resolver-IPRSINII.mjs.map +7 -0
- package/dist/lib/node-esm/markdown-CGSK44XJ.mjs +27 -0
- package/dist/lib/node-esm/markdown-CGSK44XJ.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-PFRJ7V5N.mjs +53 -0
- package/dist/lib/node-esm/react-surface-PFRJ7V5N.mjs.map +7 -0
- package/dist/lib/node-esm/thread-6T5VXPAF.mjs +18 -0
- package/dist/lib/node-esm/thread-6T5VXPAF.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +63 -0
- package/dist/types/src/SheetPlugin.d.ts +1 -3
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +5 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-graph-registry.d.ts +4 -0
- package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +12 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown.d.ts +6 -0
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/thread.d.ts +6 -0
- package/dist/types/src/capabilities/thread.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -0
- package/dist/types/src/components/FunctionEditor/FunctionEditor.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.map +1 -1
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +1 -2
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +7 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +6 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/align.d.ts +28 -0
- package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/comment.d.ts +23 -0
- package/dist/types/src/components/SheetToolbar/comment.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/index.d.ts +2 -0
- package/dist/types/src/components/SheetToolbar/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/style.d.ts +26 -0
- package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/useToolbarAction.d.ts +8 -0
- package/dist/types/src/components/SheetToolbar/useToolbarAction.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts +6 -0
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +0 -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/editor/extension.d.ts +1 -1
- package/dist/types/src/extensions/editor/extension.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +6 -8
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/model/testing.d.ts +1 -1
- package/dist/types/src/model/testing.d.ts.map +1 -1
- package/dist/types/src/model/useSheetModel.d.ts +1 -1
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +1 -1
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/{defs → types}/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/schema.d.ts +105 -0
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/{defs → types}/sheet-range-types.d.ts +1 -1
- package/dist/types/src/types/sheet-range-types.d.ts.map +1 -0
- package/dist/types/src/types/types.d.ts +71 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/src/{defs → types}/util.d.ts +5 -1
- package/dist/types/src/types/util.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +48 -62
- package/src/SheetPlugin.tsx +57 -176
- package/src/capabilities/capabilities.ts +14 -0
- package/src/capabilities/compute-graph-registry.ts +25 -0
- package/src/capabilities/index.ts +13 -0
- package/src/capabilities/intent-resolver.ts +38 -0
- package/src/capabilities/markdown.ts +22 -0
- package/src/capabilities/react-surface.tsx +37 -0
- package/src/capabilities/thread.ts +14 -0
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -2
- package/src/{compute-graph → components/ComputeGraph}/compute-graph.stories.tsx +6 -7
- package/src/components/FunctionEditor/FunctionEditor.tsx +2 -1
- package/src/components/GridSheet/GridSheet.stories.tsx +2 -0
- package/src/components/GridSheet/GridSheet.tsx +15 -18
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +6 -7
- package/src/components/GridSheet/util.ts +4 -3
- package/src/components/RangeList/RangeList.tsx +2 -1
- package/src/components/SheetContainer/SheetContainer.stories.tsx +28 -23
- package/src/components/SheetContainer/SheetContainer.tsx +3 -8
- package/src/components/SheetContext/SheetContext.tsx +1 -2
- package/src/components/{Toolbar/Toolbar.stories.tsx → SheetToolbar/SheetToolbar.stories.tsx} +4 -8
- package/src/components/SheetToolbar/SheetToolbar.tsx +48 -0
- package/src/components/SheetToolbar/align.ts +68 -0
- package/src/components/SheetToolbar/comment.ts +56 -0
- package/src/components/{Toolbar → SheetToolbar}/index.ts +1 -1
- package/src/components/SheetToolbar/style.ts +72 -0
- package/src/components/SheetToolbar/useToolbarAction.ts +87 -0
- package/src/components/SheetToolbar/useToolbarState.ts +17 -0
- package/src/components/index.ts +0 -1
- package/src/extensions/compute.ts +7 -4
- package/src/extensions/editor/extension.test.ts +2 -1
- package/src/extensions/editor/extension.ts +2 -3
- package/src/index.ts +2 -7
- package/src/integrations/thread-ranges.ts +39 -24
- package/src/meta.ts +4 -2
- package/src/model/sheet-model.test.ts +4 -10
- package/src/model/sheet-model.ts +30 -22
- package/src/model/testing.ts +3 -2
- package/src/model/useSheetModel.ts +2 -1
- package/src/sanity.test.ts +1 -1
- package/src/testing/testing.tsx +2 -3
- package/src/{defs → types}/index.ts +1 -0
- package/src/types/schema.ts +56 -0
- package/src/{defs → types}/sheet-range-types.ts +1 -1
- package/src/types/types.ts +67 -0
- package/src/{defs → types}/util.ts +13 -13
- package/dist/lib/browser/SheetContainer-KCLT6PEO.mjs +0 -296
- package/dist/lib/browser/SheetContainer-KCLT6PEO.mjs.map +0 -7
- package/dist/lib/browser/chunk-E5WQ7U7G.mjs +0 -1675
- package/dist/lib/browser/chunk-E5WQ7U7G.mjs.map +0 -7
- package/dist/lib/browser/chunk-F3HE6D3J.mjs +0 -3269
- package/dist/lib/browser/chunk-F3HE6D3J.mjs.map +0 -7
- package/dist/lib/browser/chunk-JXFPOYNA.mjs +0 -67
- package/dist/lib/browser/chunk-JXFPOYNA.mjs.map +0 -7
- package/dist/lib/browser/chunk-RABELMEQ.mjs +0 -15
- package/dist/lib/browser/chunk-RABELMEQ.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-SNUS7HOH.mjs +0 -35
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/types.mjs +0 -16
- package/dist/lib/browser/types.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-VVVRYTQG.cjs +0 -298
- package/dist/lib/node/SheetContainer-VVVRYTQG.cjs.map +0 -7
- package/dist/lib/node/chunk-2ZVZI2KJ.cjs.map +0 -7
- package/dist/lib/node/chunk-45YW2DX2.cjs +0 -1656
- package/dist/lib/node/chunk-45YW2DX2.cjs.map +0 -7
- package/dist/lib/node/chunk-KSEEI5VC.cjs +0 -3323
- package/dist/lib/node/chunk-KSEEI5VC.cjs.map +0 -7
- package/dist/lib/node/chunk-OWH2EUHZ.cjs +0 -90
- package/dist/lib/node/chunk-OWH2EUHZ.cjs.map +0 -7
- package/dist/lib/node/compute-graph-WILPHO4A.cjs +0 -57
- package/dist/lib/node/compute-graph-WILPHO4A.cjs.map +0 -7
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node/types.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-LSBE6Q4X.mjs +0 -297
- package/dist/lib/node-esm/SheetContainer-LSBE6Q4X.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6JF2AHKO.mjs +0 -3270
- package/dist/lib/node-esm/chunk-6JF2AHKO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BM2Q3FFC.mjs +0 -17
- package/dist/lib/node-esm/chunk-BM2Q3FFC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BVS2IQRO.mjs +0 -68
- package/dist/lib/node-esm/chunk-BVS2IQRO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NYDNXI7L.mjs +0 -1676
- package/dist/lib/node-esm/chunk-NYDNXI7L.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-S6CVN7RS.mjs +0 -36
- package/dist/lib/node-esm/compute-graph-S6CVN7RS.mjs.map +0 -7
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/lib/node-esm/types.mjs +0 -17
- package/dist/lib/node-esm/types.mjs.map +0 -7
- package/dist/types/src/components/SheetObjectSettings.d.ts +0 -7
- package/dist/types/src/components/SheetObjectSettings.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +0 -48
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +0 -7
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/index.d.ts +0 -2
- package/dist/types/src/components/Toolbar/index.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-graph-registry.d.ts +0 -34
- package/dist/types/src/compute-graph/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-graph.d.ts +0 -64
- package/dist/types/src/compute-graph/compute-graph.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-graph.stories.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-graph.test.d.ts +0 -2
- package/dist/types/src/compute-graph/compute-graph.test.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-node.d.ts +0 -26
- package/dist/types/src/compute-graph/compute-node.d.ts.map +0 -1
- package/dist/types/src/compute-graph/functions/async-function.d.ts +0 -66
- package/dist/types/src/compute-graph/functions/async-function.d.ts.map +0 -1
- package/dist/types/src/compute-graph/functions/edge-function.d.ts +0 -21
- package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +0 -1
- package/dist/types/src/compute-graph/functions/function-defs.d.ts +0 -11
- package/dist/types/src/compute-graph/functions/function-defs.d.ts.map +0 -1
- package/dist/types/src/compute-graph/functions/index.d.ts +0 -4
- package/dist/types/src/compute-graph/functions/index.d.ts.map +0 -1
- package/dist/types/src/compute-graph/hyperformula.test.d.ts +0 -2
- package/dist/types/src/compute-graph/hyperformula.test.d.ts.map +0 -1
- package/dist/types/src/compute-graph/index.d.ts +0 -5
- package/dist/types/src/compute-graph/index.d.ts.map +0 -1
- package/dist/types/src/compute-graph/testing/index.d.ts +0 -3
- package/dist/types/src/compute-graph/testing/index.d.ts.map +0 -1
- package/dist/types/src/compute-graph/testing/test-builder.d.ts +0 -15
- package/dist/types/src/compute-graph/testing/test-builder.d.ts.map +0 -1
- package/dist/types/src/compute-graph/testing/test-plugin.d.ts +0 -36
- package/dist/types/src/compute-graph/testing/test-plugin.d.ts.map +0 -1
- package/dist/types/src/compute-graph/util.d.ts +0 -2
- package/dist/types/src/compute-graph/util.d.ts.map +0 -1
- package/dist/types/src/defs/index.d.ts.map +0 -1
- package/dist/types/src/defs/sheet-range-types.d.ts.map +0 -1
- package/dist/types/src/defs/types.d.ts +0 -26
- package/dist/types/src/defs/types.d.ts.map +0 -1
- package/dist/types/src/defs/types.test.d.ts +0 -2
- package/dist/types/src/defs/types.test.d.ts.map +0 -1
- package/dist/types/src/defs/util.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -182
- package/dist/types/src/types.d.ts.map +0 -1
- package/dist/vendor/hyperformula.mjs +0 -37145
- package/src/components/SheetObjectSettings.tsx +0 -38
- package/src/components/Toolbar/Toolbar.tsx +0 -346
- package/src/compute-graph/compute-graph-registry.ts +0 -90
- package/src/compute-graph/compute-graph.test.ts +0 -87
- package/src/compute-graph/compute-graph.ts +0 -260
- package/src/compute-graph/compute-node.ts +0 -62
- package/src/compute-graph/functions/async-function.ts +0 -179
- package/src/compute-graph/functions/edge-function.ts +0 -102
- package/src/compute-graph/functions/function-defs.ts +0 -2427
- package/src/compute-graph/functions/index.ts +0 -7
- package/src/compute-graph/hyperformula.test.ts +0 -14
- package/src/compute-graph/index.ts +0 -8
- package/src/compute-graph/testing/index.ts +0 -6
- package/src/compute-graph/testing/test-builder.ts +0 -54
- package/src/compute-graph/testing/test-plugin.ts +0 -100
- package/src/compute-graph/util.ts +0 -8
- package/src/defs/types.test.ts +0 -91
- package/src/defs/types.ts +0 -88
- package/src/types.ts +0 -125
- /package/dist/lib/browser/{compute-graph-SNUS7HOH.mjs.map → types/index.mjs.map} +0 -0
- /package/dist/lib/{browser/meta.mjs.map → node-esm/types/index.mjs.map} +0 -0
- /package/dist/types/src/{compute-graph → components/ComputeGraph}/compute-graph.stories.d.ts +0 -0
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback } from 'react';
|
|
6
6
|
|
|
7
|
+
import { rangeToA1Notation } from '@dxos/compute';
|
|
7
8
|
import { S } from '@dxos/echo-schema';
|
|
8
9
|
import { useTranslation } from '@dxos/react-ui';
|
|
9
10
|
import { List } from '@dxos/react-ui-list';
|
|
10
11
|
import { ghostHover } from '@dxos/react-ui-theme';
|
|
11
12
|
|
|
12
|
-
import { rangeFromIndex, rangeToA1Notation } from '../../defs';
|
|
13
13
|
import { SHEET_PLUGIN } from '../../meta';
|
|
14
|
+
import { rangeFromIndex } from '../../types';
|
|
14
15
|
import { Range, type SheetType } from '../../types';
|
|
15
16
|
|
|
16
17
|
export type RangeListProps = {
|
|
@@ -7,9 +7,12 @@ import '@dxos-theme';
|
|
|
7
7
|
import { type Meta } from '@storybook/react';
|
|
8
8
|
import React from 'react';
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { Capabilities, contributes, createResolver, IntentPlugin } from '@dxos/app-framework';
|
|
11
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
|
+
import { fullyQualifiedId, useSpace } from '@dxos/react-client/echo';
|
|
12
13
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
14
|
+
import { AttendableContainer } from '@dxos/react-ui-attention';
|
|
15
|
+
import { withAttention } from '@dxos/react-ui-attention/testing';
|
|
13
16
|
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
14
17
|
|
|
15
18
|
import { SheetContainer } from './SheetContainer';
|
|
@@ -19,24 +22,6 @@ import { SheetAction, SheetType } from '../../types';
|
|
|
19
22
|
import { useComputeGraph } from '../ComputeGraph';
|
|
20
23
|
import { RangeList } from '../RangeList';
|
|
21
24
|
|
|
22
|
-
// TODO(thure via wittjosiah): stories/components should be written such that the dependency on intents is external and provided via callback and then the story can implement it differently.
|
|
23
|
-
const storybookIntentValue = create({
|
|
24
|
-
dispatch: async (intents: Intent | Intent[]) => {
|
|
25
|
-
const intent = Array.isArray(intents) ? intents[0] : intents;
|
|
26
|
-
switch (intent.action) {
|
|
27
|
-
case SheetAction.DROP_AXIS: {
|
|
28
|
-
if (!intent.undo) {
|
|
29
|
-
const { model, axis, axisIndex } = intent.data as SheetAction.DropAxis;
|
|
30
|
-
model[axis === 'col' ? 'dropColumn' : 'dropRow'](axisIndex);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
undo: async () => ({}),
|
|
36
|
-
history: [],
|
|
37
|
-
registerResolver: () => () => {},
|
|
38
|
-
});
|
|
39
|
-
|
|
40
25
|
export const Basic = () => {
|
|
41
26
|
const space = useSpace();
|
|
42
27
|
const graph = useComputeGraph(space);
|
|
@@ -45,7 +30,11 @@ export const Basic = () => {
|
|
|
45
30
|
return null;
|
|
46
31
|
}
|
|
47
32
|
|
|
48
|
-
return
|
|
33
|
+
return (
|
|
34
|
+
<AttendableContainer id={fullyQualifiedId(sheet)} classNames='contents'>
|
|
35
|
+
<SheetContainer space={space} sheet={sheet} role='article' ignoreAttention />
|
|
36
|
+
</AttendableContainer>
|
|
37
|
+
);
|
|
49
38
|
};
|
|
50
39
|
|
|
51
40
|
export const Spec = () => {
|
|
@@ -57,14 +46,14 @@ export const Spec = () => {
|
|
|
57
46
|
}
|
|
58
47
|
|
|
59
48
|
return (
|
|
60
|
-
<
|
|
49
|
+
<AttendableContainer id={fullyQualifiedId(sheet)} classNames='contents'>
|
|
61
50
|
<div role='none' className='grid grid-rows-[66%_33%] grid-cols-1'>
|
|
62
51
|
<SheetContainer space={space} sheet={sheet} role='article' ignoreAttention />
|
|
63
52
|
<div role='none' data-testid='grid.range-list'>
|
|
64
53
|
<RangeList sheet={sheet} />
|
|
65
54
|
</div>
|
|
66
55
|
</div>
|
|
67
|
-
</
|
|
56
|
+
</AttendableContainer>
|
|
68
57
|
);
|
|
69
58
|
};
|
|
70
59
|
|
|
@@ -80,6 +69,22 @@ const meta: Meta = {
|
|
|
80
69
|
tooltips: true,
|
|
81
70
|
classNames: 'grid',
|
|
82
71
|
}),
|
|
72
|
+
withAttention,
|
|
73
|
+
// TODO(wittjosiah): Consider whether we should refactor component so story doesn't need to depend on intents.
|
|
74
|
+
withPluginManager({
|
|
75
|
+
plugins: [IntentPlugin()],
|
|
76
|
+
capabilities: [
|
|
77
|
+
contributes(
|
|
78
|
+
Capabilities.IntentResolver,
|
|
79
|
+
createResolver({
|
|
80
|
+
intent: SheetAction.DropAxis,
|
|
81
|
+
resolve: ({ model, axis, axisIndex }) => {
|
|
82
|
+
model[axis === 'col' ? 'dropColumn' : 'dropRow'](axisIndex);
|
|
83
|
+
},
|
|
84
|
+
}),
|
|
85
|
+
),
|
|
86
|
+
],
|
|
87
|
+
}),
|
|
83
88
|
],
|
|
84
89
|
parameters: { translations },
|
|
85
90
|
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
7
|
+
import { fullyQualifiedId, type Space } from '@dxos/react-client/echo';
|
|
8
8
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
9
9
|
|
|
10
10
|
import { type SheetType } from '../../types';
|
|
@@ -12,7 +12,7 @@ import { useComputeGraph } from '../ComputeGraph';
|
|
|
12
12
|
import { FunctionEditor } from '../FunctionEditor';
|
|
13
13
|
import { GridSheet } from '../GridSheet';
|
|
14
14
|
import { SheetProvider } from '../SheetContext';
|
|
15
|
-
import {
|
|
15
|
+
import { SheetToolbar } from '../SheetToolbar';
|
|
16
16
|
|
|
17
17
|
export const SheetContainer = ({
|
|
18
18
|
space,
|
|
@@ -30,12 +30,7 @@ export const SheetContainer = ({
|
|
|
30
30
|
return graph ? (
|
|
31
31
|
<SheetProvider sheet={sheet} graph={graph} ignoreAttention={ignoreAttention}>
|
|
32
32
|
<StackItem.Content toolbar statusbar {...(role === 'section' && { classNames: 'aspect-video' })}>
|
|
33
|
-
<
|
|
34
|
-
<Toolbar.Styles />
|
|
35
|
-
<Toolbar.Alignment />
|
|
36
|
-
<Toolbar.Separator />
|
|
37
|
-
<Toolbar.Actions />
|
|
38
|
-
</Toolbar.Root>
|
|
33
|
+
<SheetToolbar attendableId={fullyQualifiedId(sheet)} />
|
|
39
34
|
<GridSheet />
|
|
40
35
|
<FunctionEditor />
|
|
41
36
|
</StackItem.Content>
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { type PropsWithChildren, createContext, useCallback, useContext, useState } from 'react';
|
|
6
6
|
|
|
7
|
+
import { type ComputeGraph, type CellAddress, type CellRange, type CompleteCellRange } from '@dxos/compute';
|
|
7
8
|
import { invariant } from '@dxos/invariant';
|
|
8
9
|
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
9
10
|
import {
|
|
@@ -14,8 +15,6 @@ import {
|
|
|
14
15
|
useGridContext,
|
|
15
16
|
} from '@dxos/react-ui-grid';
|
|
16
17
|
|
|
17
|
-
import { type ComputeGraph } from '../../compute-graph';
|
|
18
|
-
import { type CellAddress, type CellRange, type CompleteCellRange } from '../../defs';
|
|
19
18
|
import { type SheetModel, useSheetModel } from '../../model';
|
|
20
19
|
import { type SheetType } from '../../types';
|
|
21
20
|
|
package/src/components/{Toolbar/Toolbar.stories.tsx → SheetToolbar/SheetToolbar.stories.tsx}
RENAMED
|
@@ -10,22 +10,18 @@ import React from 'react';
|
|
|
10
10
|
import { textBlockWidth } from '@dxos/react-ui-theme';
|
|
11
11
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { SheetToolbar } from './SheetToolbar';
|
|
14
14
|
import translations from '../../translations';
|
|
15
15
|
|
|
16
16
|
const DefaultStory = () => {
|
|
17
|
-
return
|
|
18
|
-
<Toolbar.Root classNames={textBlockWidth}>
|
|
19
|
-
<Toolbar.Alignment />
|
|
20
|
-
</Toolbar.Root>
|
|
21
|
-
);
|
|
17
|
+
return <SheetToolbar classNames={textBlockWidth} />;
|
|
22
18
|
};
|
|
23
19
|
|
|
24
20
|
export const Default = {};
|
|
25
21
|
|
|
26
|
-
const meta: Meta
|
|
22
|
+
const meta: Meta = {
|
|
27
23
|
title: 'plugins/plugin-sheet/Toolbar',
|
|
28
|
-
component:
|
|
24
|
+
component: SheetToolbar,
|
|
29
25
|
render: DefaultStory,
|
|
30
26
|
decorators: [withTheme, withLayout({ tooltips: true })],
|
|
31
27
|
parameters: { translations, layout: 'fullscreen' },
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type PropsWithChildren, useCallback } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type ThemedClassName } from '@dxos/react-ui';
|
|
8
|
+
import { createGapSeparator, MenuProvider, ToolbarMenu, useMenuActions } from '@dxos/react-ui-menu';
|
|
9
|
+
|
|
10
|
+
import { createAlign, useAlignState } from './align';
|
|
11
|
+
import { createComment, useCommentState } from './comment';
|
|
12
|
+
import { createStyle, useStyleState } from './style';
|
|
13
|
+
import { useToolbarAction } from './useToolbarAction';
|
|
14
|
+
import { type ToolbarState, useToolbarState } from './useToolbarState';
|
|
15
|
+
|
|
16
|
+
//
|
|
17
|
+
// Root
|
|
18
|
+
//
|
|
19
|
+
|
|
20
|
+
export type SheetToolbarProps = ThemedClassName<PropsWithChildren<{ attendableId?: string }>>;
|
|
21
|
+
|
|
22
|
+
const createToolbarActions = (state: ToolbarState) => {
|
|
23
|
+
const align = createAlign(state);
|
|
24
|
+
const style = createStyle(state);
|
|
25
|
+
const gap = createGapSeparator();
|
|
26
|
+
const comment = createComment(state);
|
|
27
|
+
return {
|
|
28
|
+
nodes: [...align.nodes, ...style.nodes, ...gap.nodes, ...comment.nodes],
|
|
29
|
+
edges: [...align.edges, ...style.edges, ...gap.edges, ...comment.edges],
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const SheetToolbar = ({ attendableId, classNames }: SheetToolbarProps) => {
|
|
34
|
+
const state = useToolbarState({});
|
|
35
|
+
useAlignState(state);
|
|
36
|
+
useStyleState(state);
|
|
37
|
+
useCommentState(state);
|
|
38
|
+
|
|
39
|
+
const actionsCreator = useCallback(() => createToolbarActions(state), [state]);
|
|
40
|
+
const menu = useMenuActions(actionsCreator);
|
|
41
|
+
const handleAction = useToolbarAction(state);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<MenuProvider {...menu} attendableId={attendableId} onAction={handleAction}>
|
|
45
|
+
<ToolbarMenu classNames={classNames} />
|
|
46
|
+
</MenuProvider>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useEffect } from 'react';
|
|
6
|
+
|
|
7
|
+
import { inRange } from '@dxos/compute';
|
|
8
|
+
import { createMenuAction, createMenuItemGroup, type ToolbarMenuActionGroupProperties } from '@dxos/react-ui-menu';
|
|
9
|
+
|
|
10
|
+
import { SHEET_PLUGIN } from '../../meta';
|
|
11
|
+
import { type AlignKey, alignKey, type AlignValue, rangeFromIndex } from '../../types';
|
|
12
|
+
import { useSheetContext } from '../SheetContext';
|
|
13
|
+
|
|
14
|
+
export type AlignAction = { key: AlignKey; value: AlignValue };
|
|
15
|
+
|
|
16
|
+
export type AlignState = { [alignKey]: AlignValue | undefined };
|
|
17
|
+
|
|
18
|
+
const aligns: Record<AlignValue, string> = {
|
|
19
|
+
start: 'ph--text-align-left--regular',
|
|
20
|
+
center: 'ph--text-align-center--regular',
|
|
21
|
+
end: 'ph--text-align-right--regular',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const useAlignState = (state: Partial<AlignState>) => {
|
|
25
|
+
const { cursor, model } = useSheetContext();
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
// TODO(thure): Can this O(n) call be memoized?
|
|
28
|
+
state[alignKey] = (
|
|
29
|
+
cursor
|
|
30
|
+
? model.sheet.ranges?.findLast(
|
|
31
|
+
({ range, key }) => key === alignKey && inRange(rangeFromIndex(model.sheet, range), cursor),
|
|
32
|
+
)?.value
|
|
33
|
+
: undefined
|
|
34
|
+
) as AlignValue | undefined;
|
|
35
|
+
}, [cursor, model.sheet]);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const createAlignGroupAction = (value?: AlignValue) =>
|
|
39
|
+
createMenuItemGroup('align', {
|
|
40
|
+
label: ['align label', { ns: SHEET_PLUGIN }],
|
|
41
|
+
variant: 'toggleGroup',
|
|
42
|
+
selectCardinality: 'single',
|
|
43
|
+
value: `${alignKey}--${value}`,
|
|
44
|
+
} as ToolbarMenuActionGroupProperties);
|
|
45
|
+
|
|
46
|
+
const createAlignActions = (value?: AlignValue) =>
|
|
47
|
+
Object.entries(aligns).map(([alignValue, icon]) => {
|
|
48
|
+
return createMenuAction<AlignAction>(`${alignKey}--${alignValue}`, {
|
|
49
|
+
key: alignKey,
|
|
50
|
+
value: alignValue as AlignValue,
|
|
51
|
+
checked: value === alignValue,
|
|
52
|
+
label: [`range value ${alignValue} label`, { ns: SHEET_PLUGIN }],
|
|
53
|
+
icon,
|
|
54
|
+
testId: `grid.toolbar.${alignKey}.${alignValue}`,
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export const createAlign = ({ [alignKey]: alignValue }: Partial<AlignState>) => {
|
|
59
|
+
const alignGroup = createAlignGroupAction(alignValue);
|
|
60
|
+
const alignActions = createAlignActions(alignValue);
|
|
61
|
+
return {
|
|
62
|
+
nodes: [alignGroup, ...alignActions],
|
|
63
|
+
edges: [
|
|
64
|
+
{ source: 'root', target: 'align' },
|
|
65
|
+
...alignActions.map(({ id }) => ({ source: alignGroup.id, target: id })),
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useEffect, useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { RefArray } from '@dxos/live-object';
|
|
8
|
+
import { createMenuAction } from '@dxos/react-ui-menu';
|
|
9
|
+
|
|
10
|
+
import { SHEET_PLUGIN } from '../../meta';
|
|
11
|
+
import { commentKey, type CommentKey, type CommentValue, rangeToIndex } from '../../types';
|
|
12
|
+
import { useSheetContext } from '../SheetContext';
|
|
13
|
+
|
|
14
|
+
export type CommentAction = { key: CommentKey; value: CommentValue; cellContent?: string };
|
|
15
|
+
|
|
16
|
+
export type CommentState = { commentEnabled: 'comment' | 'no cursor' | 'selection overlaps existing comment' };
|
|
17
|
+
|
|
18
|
+
export const useCommentState = (state: Partial<CommentState>) => {
|
|
19
|
+
const { cursorFallbackRange, model } = useSheetContext();
|
|
20
|
+
|
|
21
|
+
// TODO(thure): Can this O(n) call be memoized?
|
|
22
|
+
const overlapsCommentAnchor = useMemo(
|
|
23
|
+
() =>
|
|
24
|
+
RefArray.allResolvedTargets(model.sheet.threads ?? [])
|
|
25
|
+
.filter((thread) => thread.status !== 'resolved')
|
|
26
|
+
.some((thread) => {
|
|
27
|
+
if (!cursorFallbackRange) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return rangeToIndex(model.sheet, cursorFallbackRange) === thread.anchor;
|
|
31
|
+
}),
|
|
32
|
+
[cursorFallbackRange, model.sheet],
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
state.commentEnabled = !cursorFallbackRange
|
|
37
|
+
? 'no cursor'
|
|
38
|
+
: overlapsCommentAnchor
|
|
39
|
+
? 'selection overlaps existing comment'
|
|
40
|
+
: 'comment';
|
|
41
|
+
}, [overlapsCommentAnchor, cursorFallbackRange]);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const createCommentAction = (state: Partial<CommentState>) =>
|
|
45
|
+
createMenuAction<Pick<CommentAction, 'key'>>('comment', {
|
|
46
|
+
key: commentKey,
|
|
47
|
+
testId: 'editor.toolbar.comment',
|
|
48
|
+
icon: 'ph--chat-text--regular',
|
|
49
|
+
label: [`${state.commentEnabled} label`, { ns: SHEET_PLUGIN }],
|
|
50
|
+
disabled: state.commentEnabled !== 'comment',
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export const createComment = (state: Partial<CommentState>) => ({
|
|
54
|
+
nodes: [createCommentAction(state)],
|
|
55
|
+
edges: [{ source: 'root', target: 'comment' }],
|
|
56
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useEffect } from 'react';
|
|
6
|
+
|
|
7
|
+
import { inRange } from '@dxos/compute';
|
|
8
|
+
import { createMenuAction, createMenuItemGroup, type ToolbarMenuActionGroupProperties } from '@dxos/react-ui-menu';
|
|
9
|
+
|
|
10
|
+
import { SHEET_PLUGIN } from '../../meta';
|
|
11
|
+
import { rangeFromIndex, type StyleKey, type StyleValue } from '../../types';
|
|
12
|
+
import { useSheetContext } from '../SheetContext';
|
|
13
|
+
|
|
14
|
+
export type StyleState = Partial<Record<StyleValue, boolean>>;
|
|
15
|
+
|
|
16
|
+
export type StyleAction = { key: StyleKey; value: StyleValue };
|
|
17
|
+
|
|
18
|
+
const styles: Record<StyleValue, string> = {
|
|
19
|
+
highlight: 'ph--highlighter--regular',
|
|
20
|
+
softwrap: 'ph--paragraph--regular',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const useStyleState = (state: StyleState) => {
|
|
24
|
+
const { cursorFallbackRange, model } = useSheetContext();
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
state.highlight = false;
|
|
28
|
+
state.softwrap = false;
|
|
29
|
+
if (cursorFallbackRange && model.sheet.ranges) {
|
|
30
|
+
model.sheet.ranges
|
|
31
|
+
.filter(
|
|
32
|
+
({ range, key }) => key === 'style' && inRange(rangeFromIndex(model.sheet, range), cursorFallbackRange.from),
|
|
33
|
+
)
|
|
34
|
+
.forEach(({ value }) => {
|
|
35
|
+
state[value as StyleValue] = true;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}, [cursorFallbackRange, model.sheet]);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const createStyleGroup = (state: StyleState) => {
|
|
42
|
+
return createMenuItemGroup('style', {
|
|
43
|
+
variant: 'toggleGroup',
|
|
44
|
+
selectCardinality: 'multiple',
|
|
45
|
+
value: Object.keys(styles)
|
|
46
|
+
.filter((key) => !!state[key as StyleValue])
|
|
47
|
+
.map((styleValue) => `style--${styleValue}`),
|
|
48
|
+
} as ToolbarMenuActionGroupProperties);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const createStyleActions = (state: StyleState) =>
|
|
52
|
+
Object.entries(styles).map(([styleValue, icon]) => {
|
|
53
|
+
return createMenuAction<StyleAction>(`style--${styleValue}`, {
|
|
54
|
+
key: 'style',
|
|
55
|
+
value: styleValue as StyleValue,
|
|
56
|
+
icon,
|
|
57
|
+
label: [`range value ${styleValue} label`, { ns: SHEET_PLUGIN }],
|
|
58
|
+
checked: !!state[styleValue as StyleValue],
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export const createStyle = (state: StyleState) => {
|
|
63
|
+
const styleGroupAction = createStyleGroup(state);
|
|
64
|
+
const styleActions = createStyleActions(state);
|
|
65
|
+
return {
|
|
66
|
+
nodes: [styleGroupAction, ...styleActions],
|
|
67
|
+
edges: [
|
|
68
|
+
{ source: 'root', target: 'style' },
|
|
69
|
+
...styleActions.map(({ id }) => ({ source: styleGroupAction.id, target: id })),
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useCallback } from 'react';
|
|
6
|
+
|
|
7
|
+
import { createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
|
+
import { inRange } from '@dxos/compute';
|
|
9
|
+
import { ThreadAction } from '@dxos/plugin-thread/types';
|
|
10
|
+
import type { MenuAction, MenuActionHandler } from '@dxos/react-ui-menu';
|
|
11
|
+
|
|
12
|
+
import { type AlignAction } from './align';
|
|
13
|
+
import { type CommentAction } from './comment';
|
|
14
|
+
import { type StyleAction } from './style';
|
|
15
|
+
import { type ToolbarState } from './useToolbarState';
|
|
16
|
+
import { completeCellRangeToThreadCursor } from '../../integrations';
|
|
17
|
+
import { alignKey, rangeFromIndex, rangeToIndex } from '../../types';
|
|
18
|
+
import { useSheetContext } from '../SheetContext';
|
|
19
|
+
|
|
20
|
+
export type ToolbarAction = StyleAction | AlignAction | CommentAction;
|
|
21
|
+
|
|
22
|
+
export const useToolbarAction = (state: ToolbarState) => {
|
|
23
|
+
const { model, cursorFallbackRange, cursor } = useSheetContext();
|
|
24
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
25
|
+
|
|
26
|
+
// TODO(Zan): Externalize the toolbar action handler. E.g., Toolbar/keys should both fire events.
|
|
27
|
+
return useCallback(
|
|
28
|
+
(action: MenuAction<ToolbarAction>) => {
|
|
29
|
+
const { key, value } = action.properties;
|
|
30
|
+
if (cursorFallbackRange) {
|
|
31
|
+
const index =
|
|
32
|
+
model.sheet.ranges?.findIndex(
|
|
33
|
+
(range) => range.key === key && inRange(rangeFromIndex(model.sheet, range.range), cursorFallbackRange.from),
|
|
34
|
+
) ?? -1;
|
|
35
|
+
const nextRangeEntity = {
|
|
36
|
+
range: rangeToIndex(model.sheet, cursorFallbackRange),
|
|
37
|
+
key,
|
|
38
|
+
value,
|
|
39
|
+
};
|
|
40
|
+
switch (key) {
|
|
41
|
+
case 'alignment':
|
|
42
|
+
if (index < 0) {
|
|
43
|
+
model.sheet.ranges?.push(nextRangeEntity);
|
|
44
|
+
state[alignKey] = value;
|
|
45
|
+
} else if (model.sheet.ranges![index].value === value) {
|
|
46
|
+
model.sheet.ranges?.splice(index, 1);
|
|
47
|
+
state[alignKey] = undefined;
|
|
48
|
+
} else {
|
|
49
|
+
model.sheet.ranges?.splice(index, 1, nextRangeEntity);
|
|
50
|
+
state[alignKey] = value;
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
case 'style':
|
|
54
|
+
if (
|
|
55
|
+
model.sheet.ranges
|
|
56
|
+
.filter(
|
|
57
|
+
({ range, key: rangeKey }) =>
|
|
58
|
+
rangeKey === 'style' && inRange(rangeFromIndex(model.sheet, range), cursorFallbackRange.from),
|
|
59
|
+
)
|
|
60
|
+
.some(({ value: rangeValue }) => rangeValue === value)
|
|
61
|
+
) {
|
|
62
|
+
// this value should be unset
|
|
63
|
+
if (index >= 0) {
|
|
64
|
+
model.sheet.ranges?.splice(index, 1);
|
|
65
|
+
}
|
|
66
|
+
state[value] = false;
|
|
67
|
+
} else {
|
|
68
|
+
model.sheet.ranges?.push(nextRangeEntity);
|
|
69
|
+
state[value] = true;
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
case 'comment': {
|
|
73
|
+
const cellContent = model.getCellText(cursorFallbackRange.from);
|
|
74
|
+
void dispatch(
|
|
75
|
+
createIntent(ThreadAction.Create, {
|
|
76
|
+
cursor: completeCellRangeToThreadCursor(cursorFallbackRange),
|
|
77
|
+
name: cellContent,
|
|
78
|
+
subject: model.sheet,
|
|
79
|
+
}),
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
[model.sheet, cursorFallbackRange, cursor, dispatch],
|
|
86
|
+
) as MenuActionHandler;
|
|
87
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { create } from '@dxos/live-object';
|
|
8
|
+
|
|
9
|
+
import { type AlignState } from './align';
|
|
10
|
+
import { type CommentState } from './comment';
|
|
11
|
+
import { type StyleState } from './style';
|
|
12
|
+
|
|
13
|
+
export type ToolbarState = Partial<StyleState & AlignState & CommentState>;
|
|
14
|
+
|
|
15
|
+
export const useToolbarState = (initialState: ToolbarState = {}) => {
|
|
16
|
+
return useMemo(() => create<ToolbarState>(initialState), []);
|
|
17
|
+
};
|
package/src/components/index.ts
CHANGED
|
@@ -15,13 +15,16 @@ import {
|
|
|
15
15
|
import { Decoration, EditorView, ViewPlugin, WidgetType } from '@codemirror/view';
|
|
16
16
|
|
|
17
17
|
import { type UnsubscribeCallback, debounce } from '@dxos/async';
|
|
18
|
+
import {
|
|
19
|
+
createSheetName,
|
|
20
|
+
type CellAddress,
|
|
21
|
+
type CellScalarValue,
|
|
22
|
+
type ComputeGraph,
|
|
23
|
+
type ComputeNode,
|
|
24
|
+
} from '@dxos/compute';
|
|
18
25
|
import { invariant } from '@dxos/invariant';
|
|
19
26
|
import { documentId, singleValueFacet } from '@dxos/react-ui-editor';
|
|
20
27
|
|
|
21
|
-
import { type ComputeGraph, type ComputeNode, createSheetName } from '../compute-graph';
|
|
22
|
-
import { type CellAddress } from '../defs';
|
|
23
|
-
import { type CellScalarValue } from '../types';
|
|
24
|
-
|
|
25
28
|
const LANGUAGE_TAG = 'dx';
|
|
26
29
|
|
|
27
30
|
// TODO(burdon): Create marker just for our decorator?
|
|
@@ -8,8 +8,9 @@ import { testTree } from '@lezer/generator/test';
|
|
|
8
8
|
import { spreadsheet } from 'codemirror-lang-spreadsheet';
|
|
9
9
|
import { describe, expect, test } from 'vitest';
|
|
10
10
|
|
|
11
|
+
import { defaultFunctions } from '@dxos/compute';
|
|
12
|
+
|
|
11
13
|
import { sheetExtension } from './extension';
|
|
12
|
-
import { defaultFunctions } from '../../compute-graph';
|
|
13
14
|
|
|
14
15
|
describe('formula parser', () => {
|
|
15
16
|
const {
|
|
@@ -18,12 +18,11 @@ import { type SyntaxNode } from '@lezer/common';
|
|
|
18
18
|
import { tags } from '@lezer/highlight';
|
|
19
19
|
import { spreadsheet } from 'codemirror-lang-spreadsheet';
|
|
20
20
|
|
|
21
|
+
import { type FunctionDefinition } from '@dxos/compute';
|
|
22
|
+
import { RANGE_NOTATION } from '@dxos/compute';
|
|
21
23
|
import { singleValueFacet } from '@dxos/react-ui-editor';
|
|
22
24
|
import { mx } from '@dxos/react-ui-theme';
|
|
23
25
|
|
|
24
|
-
import { type FunctionDefinition } from '../../compute-graph';
|
|
25
|
-
import { RANGE_NOTATION } from '../../defs';
|
|
26
|
-
|
|
27
26
|
/**
|
|
28
27
|
* https://codemirror.net/examples/styling
|
|
29
28
|
* https://lezer.codemirror.net/docs/ref/#highlight
|
package/src/index.ts
CHANGED
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export { SheetCapabilities } from './capabilities';
|
|
6
|
+
export * from './meta';
|
|
7
7
|
export * from './SheetPlugin';
|
|
8
|
-
|
|
9
|
-
// TODO(burdon): Move to types entrypoint or create a new one.
|
|
10
|
-
export * from './defs';
|
|
11
|
-
|
|
12
|
-
export default SheetPlugin;
|