@dxos/plugin-sheet 0.6.11 → 0.6.12-main.568932b
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-T2QWJOFD.mjs +262 -0
- package/dist/lib/browser/SheetContainer-T2QWJOFD.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FUAGSXA4.mjs → chunk-5ZMVZYGB.mjs} +24 -19
- package/dist/lib/browser/chunk-5ZMVZYGB.mjs.map +7 -0
- package/dist/lib/browser/chunk-GSV5QNLD.mjs +2966 -0
- package/dist/lib/browser/chunk-GSV5QNLD.mjs.map +7 -0
- package/dist/lib/browser/{chunk-JRL5LGCE.mjs → chunk-QILRZNE5.mjs} +2 -5
- package/dist/lib/browser/chunk-QILRZNE5.mjs.map +7 -0
- package/dist/lib/browser/{SheetContainer-U4H5D34A.mjs → chunk-ZL2V5UJR.mjs} +1182 -249
- package/dist/lib/browser/chunk-ZL2V5UJR.mjs.map +7 -0
- package/dist/lib/browser/graph-M4IQ76QX.mjs +33 -0
- package/dist/lib/browser/graph-M4IQ76QX.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +96 -60
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/types.mjs +4 -6
- package/dist/lib/node/SheetContainer-PV5ET4UJ.cjs +280 -0
- package/dist/lib/node/SheetContainer-PV5ET4UJ.cjs.map +7 -0
- package/dist/lib/node/{SheetContainer-AXQV3ZT5.cjs → chunk-2K53Z2TU.cjs} +1212 -287
- package/dist/lib/node/chunk-2K53Z2TU.cjs.map +7 -0
- package/dist/lib/node/{chunk-5KKJ4NPP.cjs → chunk-5XPK2V4A.cjs} +418 -678
- package/dist/lib/node/chunk-5XPK2V4A.cjs.map +7 -0
- package/dist/lib/node/{chunk-BJ6ZD7MN.cjs → chunk-BNARJ5GM.cjs} +5 -18
- package/dist/lib/node/chunk-BNARJ5GM.cjs.map +7 -0
- package/dist/lib/node/{chunk-DSYKOI4E.cjs → chunk-STAVQ2JE.cjs} +28 -24
- package/dist/lib/node/chunk-STAVQ2JE.cjs.map +7 -0
- package/dist/lib/node/graph-Q3N2X26H.cjs +55 -0
- package/dist/lib/node/graph-Q3N2X26H.cjs.map +7 -0
- package/dist/lib/node/index.cjs +106 -66
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.cjs +3 -3
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +10 -12
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/lib/node-esm/SheetContainer-FOZD2WLT.mjs +263 -0
- package/dist/lib/node-esm/SheetContainer-FOZD2WLT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-2HAM45RC.mjs +88 -0
- package/dist/lib/node-esm/chunk-2HAM45RC.mjs.map +7 -0
- package/dist/lib/{browser/chunk-D5AGLXJP.mjs → node-esm/chunk-5WPZCXNS.mjs} +411 -678
- package/dist/lib/node-esm/chunk-5WPZCXNS.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-IU2L277A.mjs +17 -0
- package/dist/lib/node-esm/chunk-IU2L277A.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QEUCIHIN.mjs +2706 -0
- package/dist/lib/node-esm/chunk-QEUCIHIN.mjs.map +7 -0
- package/dist/lib/node-esm/graph-SMPUMOV2.mjs +34 -0
- package/dist/lib/node-esm/graph-SMPUMOV2.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +285 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/meta.mjs +10 -0
- package/dist/lib/node-esm/meta.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +21 -0
- package/dist/lib/node-esm/types.mjs.map +7 -0
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +23 -3
- package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts +2 -2
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +11 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +1 -3
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +10 -0
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +9 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/util.d.ts +16 -0
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/Sheet.d.ts +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts +5 -6
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/decorations.d.ts +24 -0
- package/dist/types/src/components/Sheet/decorations.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/grid.d.ts +2 -2
- package/dist/types/src/components/Sheet/grid.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/nav.d.ts +3 -3
- package/dist/types/src/components/Sheet/nav.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/sheet-context.d.ts +8 -7
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/threads.d.ts +2 -0
- package/dist/types/src/components/Sheet/threads.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer.d.ts +2 -3
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +19 -3
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +18 -13
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/defs/index.d.ts +3 -0
- package/dist/types/src/defs/index.d.ts.map +1 -0
- package/dist/types/src/{model → defs}/types.d.ts +8 -3
- package/dist/types/src/defs/types.d.ts.map +1 -0
- package/dist/types/src/defs/types.test.d.ts.map +1 -0
- package/dist/types/src/defs/util.d.ts +43 -0
- package/dist/types/src/defs/util.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.d.ts +6 -0
- package/dist/types/src/extensions/compute.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.stories.d.ts +26 -0
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +2 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph-registry.d.ts +34 -0
- package/dist/types/src/graph/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.d.ts +64 -0
- package/dist/types/src/graph/compute-graph.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.stories.d.ts +10 -0
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.test.d.ts +2 -0
- package/dist/types/src/graph/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/graph/compute-node.d.ts +26 -0
- package/dist/types/src/graph/compute-node.d.ts.map +1 -0
- package/dist/types/src/{components/ComputeGraph → graph/functions}/async-function.d.ts +14 -5
- package/dist/types/src/graph/functions/async-function.d.ts.map +1 -0
- package/dist/types/src/graph/functions/edge-function.d.ts +21 -0
- package/dist/types/src/graph/functions/edge-function.d.ts.map +1 -0
- package/dist/types/src/{model/functions.d.ts → graph/functions/function-defs.d.ts} +1 -1
- package/dist/types/src/graph/functions/function-defs.d.ts.map +1 -0
- package/dist/types/src/graph/functions/index.d.ts +4 -0
- package/dist/types/src/graph/functions/index.d.ts.map +1 -0
- package/dist/types/src/graph/hyperformula.test.d.ts +2 -0
- package/dist/types/src/graph/hyperformula.test.d.ts.map +1 -0
- package/dist/types/src/graph/index.d.ts +5 -0
- package/dist/types/src/graph/index.d.ts.map +1 -0
- package/dist/types/src/graph/testing/index.d.ts +3 -0
- package/dist/types/src/graph/testing/index.d.ts.map +1 -0
- package/dist/types/src/graph/testing/test-builder.d.ts +15 -0
- package/dist/types/src/graph/testing/test-builder.d.ts.map +1 -0
- package/dist/types/src/graph/testing/test-plugin.d.ts +36 -0
- package/dist/types/src/graph/testing/test-plugin.d.ts.map +1 -0
- package/dist/types/src/graph/util.d.ts +2 -0
- package/dist/types/src/graph/util.d.ts.map +1 -0
- package/dist/types/src/hooks/hooks.stories.d.ts +11 -0
- package/dist/types/src/hooks/hooks.stories.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +4 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts +7 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +1 -0
- package/dist/types/src/hooks/useFormattingModel.d.ts +3 -0
- package/dist/types/src/hooks/useFormattingModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useSheetModel.d.ts +8 -0
- package/dist/types/src/hooks/useSheetModel.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +1 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/formatting-model.d.ts +16 -0
- package/dist/types/src/model/formatting-model.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +2 -3
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/{model.d.ts → sheet-model.d.ts} +10 -65
- package/dist/types/src/model/sheet-model.d.ts.map +1 -0
- package/dist/types/src/model/sheet-model.test.d.ts +2 -0
- package/dist/types/src/model/sheet-model.test.d.ts.map +1 -0
- package/dist/types/src/sanity.test.d.ts +2 -0
- package/dist/types/src/sanity.test.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +8 -0
- package/dist/types/src/testing/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +17 -12
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +86 -5
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/vendor/hyperformula.mjs +37145 -0
- package/package.json +55 -47
- package/src/SheetPlugin.tsx +50 -73
- package/src/components/CellEditor/CellEditor.stories.tsx +6 -6
- package/src/components/CellEditor/CellEditor.tsx +59 -9
- package/src/components/CellEditor/extension.test.ts +4 -6
- package/src/components/CellEditor/extension.ts +5 -6
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +20 -0
- package/src/components/ComputeGraph/index.ts +1 -3
- package/src/components/GridSheet/GridSheet.stories.tsx +36 -0
- package/src/components/GridSheet/GridSheet.tsx +171 -0
- package/src/components/GridSheet/util.ts +148 -0
- package/src/components/Sheet/Sheet.stories.tsx +52 -88
- package/src/components/Sheet/Sheet.tsx +87 -32
- package/src/components/Sheet/decorations.ts +62 -0
- package/src/components/Sheet/grid.ts +3 -3
- package/src/components/Sheet/nav.ts +19 -19
- package/src/components/Sheet/sheet-context.tsx +18 -80
- package/src/components/Sheet/threads.tsx +205 -0
- package/src/components/SheetContainer.tsx +68 -16
- package/src/components/Toolbar/Toolbar.tsx +53 -12
- package/src/components/index.ts +1 -0
- package/src/defs/index.ts +6 -0
- package/src/{model → defs}/types.test.ts +8 -9
- package/src/{model → defs}/types.ts +24 -14
- package/src/defs/util.ts +151 -0
- package/src/extensions/compute.stories.tsx +151 -0
- package/src/extensions/compute.ts +147 -0
- package/src/extensions/index.ts +5 -0
- package/src/graph/compute-graph-registry.ts +90 -0
- package/src/graph/compute-graph.stories.tsx +93 -0
- package/src/graph/compute-graph.test.ts +87 -0
- package/src/graph/compute-graph.ts +242 -0
- package/src/graph/compute-node.ts +63 -0
- package/src/{components/ComputeGraph → graph/functions}/async-function.ts +25 -15
- package/src/{components/ComputeGraph → graph/functions}/edge-function.ts +16 -14
- package/src/graph/functions/index.ts +7 -0
- package/src/graph/hyperformula.test.ts +14 -0
- package/src/graph/index.ts +8 -0
- package/src/graph/testing/index.ts +6 -0
- package/src/graph/testing/test-builder.ts +54 -0
- package/src/{components/ComputeGraph/custom.ts → graph/testing/test-plugin.ts} +44 -14
- package/src/graph/util.ts +8 -0
- package/src/hooks/hooks.stories.tsx +50 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useComputeGraph.ts +28 -0
- package/src/hooks/useFormattingModel.ts +11 -0
- package/src/hooks/useSheetModel.ts +40 -0
- package/src/meta.tsx +1 -5
- package/src/{components/Sheet/formatting.ts → model/formatting-model.ts} +20 -13
- package/src/model/index.ts +2 -3
- package/src/model/sheet-model.test.ts +57 -0
- package/src/model/sheet-model.ts +416 -0
- package/src/sanity.test.ts +40 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/testing.tsx +68 -0
- package/src/translations.ts +6 -1
- package/src/types.ts +35 -10
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +0 -7
- package/dist/lib/browser/chunk-APHOLYUB.mjs +0 -175
- package/dist/lib/browser/chunk-APHOLYUB.mjs.map +0 -7
- package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +0 -7
- package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +0 -7
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/browser/chunk-NU4PBN33.mjs +0 -8
- package/dist/lib/browser/chunk-NU4PBN33.mjs.map +0 -7
- package/dist/lib/browser/testing.mjs +0 -92
- package/dist/lib/browser/testing.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +0 -7
- package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +0 -7
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
- package/dist/lib/node/chunk-CN3RPESU.cjs +0 -202
- package/dist/lib/node/chunk-CN3RPESU.cjs.map +0 -7
- package/dist/lib/node/chunk-DSYKOI4E.cjs.map +0 -7
- package/dist/lib/node/chunk-PYXHNAAK.cjs +0 -40
- package/dist/lib/node/chunk-PYXHNAAK.cjs.map +0 -7
- package/dist/lib/node/testing.cjs +0 -111
- package/dist/lib/node/testing.cjs.map +0 -7
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/custom.d.ts +0 -21
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts +0 -20
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts +0 -12
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +0 -2
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.d.ts +0 -26
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/formatting.d.ts +0 -14
- package/dist/types/src/components/Sheet/formatting.d.ts.map +0 -1
- package/dist/types/src/model/functions.d.ts.map +0 -1
- package/dist/types/src/model/model.browser.test.d.ts +0 -2
- package/dist/types/src/model/model.browser.test.d.ts.map +0 -1
- package/dist/types/src/model/model.d.ts.map +0 -1
- package/dist/types/src/model/types.d.ts.map +0 -1
- package/dist/types/src/model/types.test.d.ts.map +0 -1
- package/dist/types/src/model/util.d.ts +0 -15
- package/dist/types/src/model/util.d.ts.map +0 -1
- package/dist/types/src/testing.d.ts +0 -9
- package/dist/types/src/testing.d.ts.map +0 -1
- package/src/components/ComputeGraph/graph-context.tsx +0 -50
- package/src/components/ComputeGraph/graph.browser.test.ts +0 -50
- package/src/components/ComputeGraph/graph.ts +0 -62
- package/src/model/model.browser.test.ts +0 -100
- package/src/model/model.ts +0 -550
- package/src/model/util.ts +0 -36
- package/src/testing.ts +0 -50
- /package/dist/types/src/{model → defs}/types.test.d.ts +0 -0
- /package/src/{model/functions.ts → graph/functions/function-defs.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-sheet",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.12-main.568932b",
|
|
4
4
|
"description": "Braneframe sketch plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "DXOS.org",
|
|
9
|
+
"imports": {
|
|
10
|
+
"#hyperformula": {
|
|
11
|
+
"types": "hyperformula",
|
|
12
|
+
"default": "./dist/vendor/hyperformula.mjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
9
15
|
"exports": {
|
|
10
16
|
".": {
|
|
11
17
|
"browser": "./dist/lib/browser/index.mjs",
|
|
12
18
|
"node": {
|
|
13
|
-
"
|
|
19
|
+
"require": "./dist/lib/node/index.cjs",
|
|
20
|
+
"default": "./dist/lib/node-esm/index.mjs"
|
|
14
21
|
},
|
|
15
22
|
"types": "./dist/types/src/index.d.ts"
|
|
16
23
|
},
|
|
17
24
|
"./meta": {
|
|
18
25
|
"browser": "./dist/lib/browser/meta.mjs",
|
|
19
26
|
"node": {
|
|
20
|
-
"
|
|
27
|
+
"require": "./dist/lib/node/meta.cjs",
|
|
28
|
+
"default": "./dist/lib/node-esm/meta.mjs"
|
|
21
29
|
},
|
|
22
30
|
"types": "./dist/types/src/meta.d.ts"
|
|
23
31
|
},
|
|
24
|
-
"./testing": {
|
|
25
|
-
"browser": "./dist/lib/browser/testing.mjs",
|
|
26
|
-
"node": {
|
|
27
|
-
"default": "./dist/lib/node/testing.cjs"
|
|
28
|
-
},
|
|
29
|
-
"types": "./dist/types/src/testing.d.ts"
|
|
30
|
-
},
|
|
31
32
|
"./types": {
|
|
32
33
|
"browser": "./dist/lib/browser/types.mjs",
|
|
33
34
|
"node": {
|
|
34
|
-
"
|
|
35
|
+
"require": "./dist/lib/node/types.cjs",
|
|
36
|
+
"default": "./dist/lib/node-esm/types.mjs"
|
|
35
37
|
},
|
|
36
38
|
"types": "./dist/types/src/types.d.ts"
|
|
37
39
|
}
|
|
@@ -55,16 +57,17 @@
|
|
|
55
57
|
"src"
|
|
56
58
|
],
|
|
57
59
|
"dependencies": {
|
|
58
|
-
"@codemirror/autocomplete": "^6.18.
|
|
59
|
-
"@codemirror/language": "^6.10.
|
|
60
|
+
"@codemirror/autocomplete": "^6.18.1",
|
|
61
|
+
"@codemirror/language": "^6.10.3",
|
|
60
62
|
"@codemirror/state": "^6.4.1",
|
|
61
|
-
"@codemirror/view": "^6.
|
|
63
|
+
"@codemirror/view": "^6.34.1",
|
|
62
64
|
"@dnd-kit/core": "^6.0.5",
|
|
63
65
|
"@dnd-kit/modifiers": "^6.0.0",
|
|
64
66
|
"@dnd-kit/sortable": "^7.0.1",
|
|
65
67
|
"@dnd-kit/utilities": "^3.2.0",
|
|
66
|
-
"@
|
|
67
|
-
"@lezer/
|
|
68
|
+
"@effect/schema": "^0.75.1",
|
|
69
|
+
"@lezer/common": "^1.2.2",
|
|
70
|
+
"@lezer/highlight": "^1.2.1",
|
|
68
71
|
"@lezer/lezer": "^1.1.2",
|
|
69
72
|
"@lezer/lr": "^1.4.2",
|
|
70
73
|
"@preact/signals-core": "^1.6.0",
|
|
@@ -76,25 +79,29 @@
|
|
|
76
79
|
"re-resizable": "^6.9.17",
|
|
77
80
|
"react-markdown": "^8.0.5",
|
|
78
81
|
"react-resize-detector": "^11.0.1",
|
|
79
|
-
"@dxos/app-framework": "0.6.
|
|
80
|
-
"@dxos/async": "0.6.
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/
|
|
83
|
-
"@dxos/
|
|
84
|
-
"@dxos/debug": "0.6.
|
|
85
|
-
"@dxos/echo-schema": "0.6.
|
|
86
|
-
"@dxos/invariant": "0.6.
|
|
87
|
-
"@dxos/
|
|
88
|
-
"@dxos/
|
|
89
|
-
"@dxos/log": "0.6.
|
|
90
|
-
"@dxos/plugin-
|
|
91
|
-
"@dxos/plugin-
|
|
92
|
-
"@dxos/plugin-
|
|
93
|
-
"@dxos/plugin-
|
|
94
|
-
"@dxos/react-
|
|
95
|
-
"@dxos/
|
|
96
|
-
"@dxos/react-
|
|
97
|
-
"@dxos/
|
|
82
|
+
"@dxos/app-framework": "0.6.12-main.568932b",
|
|
83
|
+
"@dxos/async": "0.6.12-main.568932b",
|
|
84
|
+
"@dxos/client": "0.6.12-main.568932b",
|
|
85
|
+
"@dxos/crypto": "0.6.12-main.568932b",
|
|
86
|
+
"@dxos/context": "0.6.12-main.568932b",
|
|
87
|
+
"@dxos/debug": "0.6.12-main.568932b",
|
|
88
|
+
"@dxos/echo-schema": "0.6.12-main.568932b",
|
|
89
|
+
"@dxos/invariant": "0.6.12-main.568932b",
|
|
90
|
+
"@dxos/plugin-attention": "0.6.12-main.568932b",
|
|
91
|
+
"@dxos/keys": "0.6.12-main.568932b",
|
|
92
|
+
"@dxos/log": "0.6.12-main.568932b",
|
|
93
|
+
"@dxos/plugin-client": "0.6.12-main.568932b",
|
|
94
|
+
"@dxos/plugin-graph": "0.6.12-main.568932b",
|
|
95
|
+
"@dxos/plugin-markdown": "0.6.12-main.568932b",
|
|
96
|
+
"@dxos/plugin-space": "0.6.12-main.568932b",
|
|
97
|
+
"@dxos/react-client": "0.6.12-main.568932b",
|
|
98
|
+
"@dxos/plugin-stack": "0.6.12-main.568932b",
|
|
99
|
+
"@dxos/react-hooks": "0.6.12-main.568932b",
|
|
100
|
+
"@dxos/react-ui-editor": "0.6.12-main.568932b",
|
|
101
|
+
"@dxos/react-ui-attention": "0.6.12-main.568932b",
|
|
102
|
+
"@dxos/plugin-script": "0.6.12-main.568932b",
|
|
103
|
+
"@dxos/react-ui-grid": "0.6.12-main.568932b",
|
|
104
|
+
"@dxos/util": "0.6.12-main.568932b"
|
|
98
105
|
},
|
|
99
106
|
"devDependencies": {
|
|
100
107
|
"@lezer/generator": "^1.7.1",
|
|
@@ -106,20 +113,21 @@
|
|
|
106
113
|
"@types/react-window": "^1.8.8",
|
|
107
114
|
"react": "~18.2.0",
|
|
108
115
|
"react-dom": "~18.2.0",
|
|
109
|
-
"vite": "
|
|
110
|
-
"@dxos/echo-generator": "0.6.
|
|
111
|
-
"@dxos/random": "0.6.
|
|
112
|
-
"@dxos/react-ui": "0.6.
|
|
113
|
-
"@dxos/react-ui-
|
|
114
|
-
"@dxos/
|
|
115
|
-
"@dxos/react-ui-
|
|
116
|
+
"vite": "5.4.7",
|
|
117
|
+
"@dxos/echo-generator": "0.6.12-main.568932b",
|
|
118
|
+
"@dxos/random": "0.6.12-main.568932b",
|
|
119
|
+
"@dxos/react-ui": "0.6.12-main.568932b",
|
|
120
|
+
"@dxos/react-ui-syntax-highlighter": "0.6.12-main.568932b",
|
|
121
|
+
"@dxos/react-ui-theme": "0.6.12-main.568932b",
|
|
122
|
+
"@dxos/react-ui-types": "0.6.12-main.568932b",
|
|
123
|
+
"@dxos/storybook-utils": "0.6.12-main.568932b"
|
|
116
124
|
},
|
|
117
|
-
"
|
|
125
|
+
"peerDependencies": {
|
|
118
126
|
"@phosphor-icons/react": "^2.1.5",
|
|
119
|
-
"react": "
|
|
120
|
-
"react-dom": "
|
|
121
|
-
"@dxos/react-ui
|
|
122
|
-
"@dxos/react-ui": "0.6.
|
|
127
|
+
"react": "~18.2.0",
|
|
128
|
+
"react-dom": "~18.2.0",
|
|
129
|
+
"@dxos/react-ui": "0.6.12-main.568932b",
|
|
130
|
+
"@dxos/react-ui-theme": "0.6.12-main.568932b"
|
|
123
131
|
},
|
|
124
132
|
"publishConfig": {
|
|
125
133
|
"access": "public"
|
package/src/SheetPlugin.tsx
CHANGED
|
@@ -2,84 +2,71 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { GridNine } from '@phosphor-icons/react';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
parseIntentPlugin,
|
|
11
|
-
resolvePlugin,
|
|
12
|
-
type PluginDefinition,
|
|
13
|
-
type LayoutCoordinate,
|
|
14
|
-
} from '@dxos/app-framework';
|
|
15
|
-
import { create } from '@dxos/echo-schema';
|
|
8
|
+
import { NavigationAction, parseIntentPlugin, resolvePlugin, type PluginDefinition } from '@dxos/app-framework';
|
|
9
|
+
import { invariant } from '@dxos/invariant';
|
|
16
10
|
import { parseClientPlugin } from '@dxos/plugin-client';
|
|
17
|
-
import {
|
|
11
|
+
import { createExtension, isActionGroup, type ActionGroup } from '@dxos/plugin-graph';
|
|
18
12
|
import { FunctionType } from '@dxos/plugin-script/types';
|
|
19
13
|
import { SpaceAction } from '@dxos/plugin-space';
|
|
20
14
|
import { getSpace, isEchoObject } from '@dxos/react-client/echo';
|
|
21
15
|
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
type ComputeGraph,
|
|
28
|
-
} from './components';
|
|
29
|
-
// TODO(wittjosiah): Refactor. These are not exported from ./components due to depending on ECHO.
|
|
30
|
-
import { EdgeFunctionPlugin, EdgeFunctionPluginTranslations } from './components/ComputeGraph/edge-function';
|
|
31
|
-
import { ComputeGraphContextProvider } from './components/ComputeGraph/graph-context';
|
|
16
|
+
import { ComputeGraphContextProvider, SheetContainer } from './components';
|
|
17
|
+
import { compareIndexPositions, createSheet } from './defs';
|
|
18
|
+
import { computeGraphFacet } from './extensions';
|
|
19
|
+
import { type ComputeGraphRegistry } from './graph';
|
|
20
|
+
import { useComputeGraph } from './hooks';
|
|
32
21
|
import meta, { SHEET_PLUGIN } from './meta';
|
|
33
|
-
import { SheetModel } from './model';
|
|
34
22
|
import translations from './translations';
|
|
35
|
-
import {
|
|
23
|
+
import { SheetAction, SheetType, type SheetPluginProvides } from './types';
|
|
36
24
|
|
|
37
25
|
export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
const graphs = create<Record<string, ComputeGraph>>({});
|
|
41
|
-
const setGraph = (key: string, graph: ComputeGraph) => {
|
|
42
|
-
graphs[key] = graph;
|
|
43
|
-
};
|
|
26
|
+
let computeGraphRegistry: ComputeGraphRegistry | undefined;
|
|
44
27
|
|
|
45
28
|
return {
|
|
46
29
|
meta,
|
|
47
30
|
ready: async (plugins) => {
|
|
48
31
|
const client = resolvePlugin(plugins, parseClientPlugin)?.provides.client;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
32
|
+
invariant(client);
|
|
33
|
+
let remoteFunctionUrl: string | undefined;
|
|
53
34
|
if (client.config.values.runtime?.services?.edge?.url) {
|
|
54
35
|
const url = new URL('/functions', client.config.values.runtime?.services?.edge?.url);
|
|
55
36
|
url.protocol = 'https';
|
|
56
37
|
remoteFunctionUrl = url.toString();
|
|
57
38
|
}
|
|
39
|
+
|
|
40
|
+
// Async import removes direct dependency on hyperformula.
|
|
41
|
+
const { ComputeGraphRegistry } = await import('./graph');
|
|
42
|
+
computeGraphRegistry = new ComputeGraphRegistry({ remoteFunctionUrl });
|
|
58
43
|
},
|
|
59
44
|
provides: {
|
|
60
45
|
context: ({ children }) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
{children}
|
|
64
|
-
</ComputeGraphContextProvider>
|
|
65
|
-
);
|
|
46
|
+
invariant(computeGraphRegistry);
|
|
47
|
+
return <ComputeGraphContextProvider registry={computeGraphRegistry}>{children}</ComputeGraphContextProvider>;
|
|
66
48
|
},
|
|
67
49
|
metadata: {
|
|
68
50
|
records: {
|
|
69
51
|
[SheetType.typename]: {
|
|
70
|
-
label: (object: any) => (object instanceof SheetType ? object.
|
|
52
|
+
label: (object: any) => (object instanceof SheetType ? object.name : undefined),
|
|
71
53
|
placeholder: ['sheet title placeholder', { ns: SHEET_PLUGIN }],
|
|
72
|
-
icon:
|
|
73
|
-
iconSymbol: 'ph--grid-nine--regular',
|
|
54
|
+
icon: 'ph--grid-nine--regular',
|
|
74
55
|
},
|
|
75
56
|
},
|
|
76
57
|
},
|
|
77
58
|
translations,
|
|
78
59
|
echo: {
|
|
79
60
|
// TODO(wittjosiah): Factor out to common package/plugin.
|
|
80
|
-
//
|
|
61
|
+
// FunctionType is currently registered here in case script plugin isn't enabled.
|
|
81
62
|
schema: [SheetType, FunctionType],
|
|
82
63
|
},
|
|
64
|
+
space: {
|
|
65
|
+
onSpaceCreate: {
|
|
66
|
+
label: ['create sheet label', { ns: SHEET_PLUGIN }],
|
|
67
|
+
action: SheetAction.CREATE,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
83
70
|
graph: {
|
|
84
71
|
builder: (plugins) => {
|
|
85
72
|
const client = resolvePlugin(plugins, parseClientPlugin)?.provides.client;
|
|
@@ -113,8 +100,7 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
|
113
100
|
},
|
|
114
101
|
properties: {
|
|
115
102
|
label: ['create sheet label', { ns: SHEET_PLUGIN }],
|
|
116
|
-
icon:
|
|
117
|
-
iconSymbol: 'ph--grid-nine--regular',
|
|
103
|
+
icon: 'ph--grid-nine--regular',
|
|
118
104
|
testId: 'sheetPlugin.createObject',
|
|
119
105
|
},
|
|
120
106
|
},
|
|
@@ -123,6 +109,16 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
|
123
109
|
});
|
|
124
110
|
},
|
|
125
111
|
},
|
|
112
|
+
markdown: {
|
|
113
|
+
extensions: ({ document: doc }) => {
|
|
114
|
+
invariant(computeGraphRegistry);
|
|
115
|
+
const space = getSpace(doc);
|
|
116
|
+
if (space) {
|
|
117
|
+
const computeGraph = computeGraphRegistry.getOrCreateGraph(space);
|
|
118
|
+
return computeGraphFacet.of(computeGraph);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
},
|
|
126
122
|
stack: {
|
|
127
123
|
creators: [
|
|
128
124
|
{
|
|
@@ -138,23 +134,20 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
|
138
134
|
},
|
|
139
135
|
],
|
|
140
136
|
},
|
|
137
|
+
thread: {
|
|
138
|
+
predicate: (data) => data instanceof SheetType,
|
|
139
|
+
createSort: (sheet) => (indexA, indexB) =>
|
|
140
|
+
!indexA || !indexB ? 0 : compareIndexPositions(sheet, indexA, indexB),
|
|
141
|
+
},
|
|
141
142
|
surface: {
|
|
142
|
-
component: ({ data, role
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
if (
|
|
143
|
+
component: ({ data, role }) => {
|
|
144
|
+
const space = isEchoObject(data.object) ? getSpace(data.object) : undefined;
|
|
145
|
+
const graph = useComputeGraph(space);
|
|
146
|
+
if (graph && data.object instanceof SheetType) {
|
|
146
147
|
switch (role) {
|
|
147
148
|
case 'article':
|
|
148
149
|
case 'section': {
|
|
149
|
-
return
|
|
150
|
-
<SheetContainer
|
|
151
|
-
sheet={data.object}
|
|
152
|
-
space={space}
|
|
153
|
-
role={role}
|
|
154
|
-
coordinate={data.coordinate as LayoutCoordinate}
|
|
155
|
-
remoteFunctionUrl={remoteFunctionUrl}
|
|
156
|
-
/>
|
|
157
|
-
);
|
|
150
|
+
return <SheetContainer graph={graph} sheet={data.object} role={role} />;
|
|
158
151
|
}
|
|
159
152
|
}
|
|
160
153
|
}
|
|
@@ -166,23 +159,7 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
|
166
159
|
resolver: async (intent) => {
|
|
167
160
|
switch (intent.action) {
|
|
168
161
|
case SheetAction.CREATE: {
|
|
169
|
-
|
|
170
|
-
const sheet = createSheet();
|
|
171
|
-
const graph =
|
|
172
|
-
graphs[space.id] ??
|
|
173
|
-
createComputeGraph(
|
|
174
|
-
[
|
|
175
|
-
{ plugin: EdgeFunctionPlugin, translations: EdgeFunctionPluginTranslations },
|
|
176
|
-
// TODO(wittjosiah): Remove. Needed for current test sheet generated data.
|
|
177
|
-
{ plugin: CustomPlugin, translations: CustomPluginTranslations },
|
|
178
|
-
],
|
|
179
|
-
space,
|
|
180
|
-
{ remoteFunctionUrl },
|
|
181
|
-
);
|
|
182
|
-
const model = new SheetModel(graph, sheet);
|
|
183
|
-
await model.initialize();
|
|
184
|
-
await model.destroy();
|
|
185
|
-
return { data: sheet };
|
|
162
|
+
return { data: createSheet() };
|
|
186
163
|
}
|
|
187
164
|
}
|
|
188
165
|
},
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { HyperFormula } from 'hyperformula';
|
|
8
7
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
9
8
|
|
|
10
9
|
import { Client } from '@dxos/client';
|
|
@@ -12,10 +11,12 @@ import { createDocAccessor, type EchoReactiveObject } from '@dxos/client/echo';
|
|
|
12
11
|
import { automerge } from '@dxos/react-ui-editor';
|
|
13
12
|
import { withTheme } from '@dxos/storybook-utils';
|
|
14
13
|
|
|
14
|
+
import { HyperFormula } from '#hyperformula';
|
|
15
15
|
import { CellEditor, type CellEditorProps } from './CellEditor';
|
|
16
16
|
import { sheetExtension } from './extension';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
17
|
+
import { createSheet } from '../../defs';
|
|
18
|
+
import { defaultFunctions } from '../../graph';
|
|
19
|
+
import { SheetType } from '../../types';
|
|
19
20
|
|
|
20
21
|
export default {
|
|
21
22
|
title: 'plugin-sheet/CellEditor',
|
|
@@ -41,14 +42,13 @@ const AutomergeStory = ({ value, ...props }: StoryProps) => {
|
|
|
41
42
|
const [object, setObject] = useState<EchoReactiveObject<SheetType>>();
|
|
42
43
|
useEffect(() => {
|
|
43
44
|
setTimeout(async () => {
|
|
44
|
-
const client = new Client();
|
|
45
|
+
const client = new Client({ types: [SheetType] });
|
|
45
46
|
await client.initialize();
|
|
46
47
|
await client.halo.createIdentity();
|
|
47
48
|
const space = await client.spaces.create();
|
|
48
|
-
client.addTypes([SheetType]);
|
|
49
49
|
|
|
50
50
|
const sheet = createSheet();
|
|
51
|
-
sheet.
|
|
51
|
+
sheet.name = 'Test';
|
|
52
52
|
sheet.cells[cell] = { value };
|
|
53
53
|
space.db.add(sheet);
|
|
54
54
|
setObject(sheet);
|
|
@@ -14,10 +14,13 @@ import {
|
|
|
14
14
|
preventNewline,
|
|
15
15
|
useTextEditor,
|
|
16
16
|
} from '@dxos/react-ui-editor';
|
|
17
|
+
import { type GridEditBox } from '@dxos/react-ui-grid';
|
|
18
|
+
|
|
19
|
+
type EditorKeyEvent = Pick<KeyboardEvent<HTMLInputElement>, 'key'> & { shift?: boolean };
|
|
17
20
|
|
|
18
21
|
export type EditorKeysProps = {
|
|
19
|
-
onClose: (value: string | undefined) => void;
|
|
20
|
-
onNav?: (value: string | undefined,
|
|
22
|
+
onClose: (value: string | undefined, event: EditorKeyEvent) => void;
|
|
23
|
+
onNav?: (value: string | undefined, event: EditorKeyEvent) => void;
|
|
21
24
|
};
|
|
22
25
|
|
|
23
26
|
export const editorKeys = ({ onNav, onClose }: EditorKeysProps): Extension => {
|
|
@@ -57,14 +60,29 @@ export const editorKeys = ({ onNav, onClose }: EditorKeysProps): Extension => {
|
|
|
57
60
|
{
|
|
58
61
|
key: 'Enter',
|
|
59
62
|
run: (editor) => {
|
|
60
|
-
onClose(editor.state.doc.toString());
|
|
63
|
+
onClose(editor.state.doc.toString(), { key: 'Enter' });
|
|
64
|
+
return true;
|
|
65
|
+
},
|
|
66
|
+
shift: (editor) => {
|
|
67
|
+
onClose(editor.state.doc.toString(), { key: 'Enter', shift: true });
|
|
68
|
+
return true;
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
key: 'Tab',
|
|
73
|
+
run: (editor) => {
|
|
74
|
+
onClose(editor.state.doc.toString(), { key: 'Tab' });
|
|
75
|
+
return true;
|
|
76
|
+
},
|
|
77
|
+
shift: (editor) => {
|
|
78
|
+
onClose(editor.state.doc.toString(), { key: 'Tab', shift: true });
|
|
61
79
|
return true;
|
|
62
80
|
},
|
|
63
81
|
},
|
|
64
82
|
{
|
|
65
83
|
key: 'Escape',
|
|
66
84
|
run: () => {
|
|
67
|
-
onClose(undefined);
|
|
85
|
+
onClose(undefined, { key: 'Escape' });
|
|
68
86
|
return true;
|
|
69
87
|
},
|
|
70
88
|
},
|
|
@@ -74,10 +92,35 @@ export const editorKeys = ({ onNav, onClose }: EditorKeysProps): Extension => {
|
|
|
74
92
|
export type CellEditorProps = {
|
|
75
93
|
value?: string;
|
|
76
94
|
extension?: Extension;
|
|
95
|
+
variant?: keyof typeof editorVariants;
|
|
96
|
+
box?: GridEditBox;
|
|
97
|
+
gridId?: string;
|
|
77
98
|
} & Pick<UseTextEditorProps, 'autoFocus'> &
|
|
78
99
|
Pick<DOMAttributes<HTMLInputElement>, 'onBlur' | 'onKeyDown'>;
|
|
79
100
|
|
|
80
|
-
|
|
101
|
+
const editorVariants = {
|
|
102
|
+
// TODO(thure): remove when legacy is no longer used.
|
|
103
|
+
legacy: {
|
|
104
|
+
root: 'flex w-full',
|
|
105
|
+
editor: 'flex w-full [&>.cm-scroller]:scrollbar-none',
|
|
106
|
+
content: '!px-2 !py-1',
|
|
107
|
+
},
|
|
108
|
+
grid: {
|
|
109
|
+
root: 'absolute z-[1]',
|
|
110
|
+
editor: '[&>.cm-scroller]:scrollbar-none tabular-nums',
|
|
111
|
+
content: '!border !border-transparent !p-0.5',
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const CellEditor = ({
|
|
116
|
+
value,
|
|
117
|
+
extension,
|
|
118
|
+
autoFocus,
|
|
119
|
+
onBlur,
|
|
120
|
+
variant = 'legacy',
|
|
121
|
+
box,
|
|
122
|
+
gridId,
|
|
123
|
+
}: CellEditorProps) => {
|
|
81
124
|
const { themeMode } = useThemeContext();
|
|
82
125
|
const { parentRef } = useTextEditor(() => {
|
|
83
126
|
return {
|
|
@@ -98,16 +141,23 @@ export const CellEditor = ({ value, extension, autoFocus, onBlur }: CellEditorPr
|
|
|
98
141
|
themeMode,
|
|
99
142
|
slots: {
|
|
100
143
|
editor: {
|
|
101
|
-
className:
|
|
144
|
+
className: editorVariants[variant].editor,
|
|
102
145
|
},
|
|
103
146
|
content: {
|
|
104
|
-
className:
|
|
147
|
+
className: editorVariants[variant].content,
|
|
105
148
|
},
|
|
106
149
|
},
|
|
107
150
|
}),
|
|
108
151
|
],
|
|
109
152
|
};
|
|
110
|
-
}, [extension]);
|
|
153
|
+
}, [extension, autoFocus, value, variant, onBlur]);
|
|
111
154
|
|
|
112
|
-
return
|
|
155
|
+
return (
|
|
156
|
+
<div
|
|
157
|
+
ref={parentRef}
|
|
158
|
+
className={editorVariants[variant].root}
|
|
159
|
+
style={box}
|
|
160
|
+
{...(gridId && { 'data-grid': gridId })}
|
|
161
|
+
/>
|
|
162
|
+
);
|
|
113
163
|
};
|
|
@@ -4,14 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import { CompletionContext, type CompletionSource } from '@codemirror/autocomplete';
|
|
6
6
|
import { EditorState } from '@codemirror/state';
|
|
7
|
-
// @ts-ignore
|
|
8
7
|
import { testTree } from '@lezer/generator/test';
|
|
9
|
-
import { expect } from 'chai';
|
|
10
8
|
import { spreadsheet } from 'codemirror-lang-spreadsheet';
|
|
11
|
-
import { describe, test } from 'vitest';
|
|
9
|
+
import { describe, expect, test } from 'vitest';
|
|
12
10
|
|
|
13
11
|
import { sheetExtension } from './extension';
|
|
14
|
-
import { defaultFunctions } from '../../
|
|
12
|
+
import { defaultFunctions } from '../../graph';
|
|
15
13
|
|
|
16
14
|
describe('formula parser', () => {
|
|
17
15
|
const {
|
|
@@ -37,8 +35,8 @@ describe('formula parser', () => {
|
|
|
37
35
|
extensions: sheetExtension({ functions }),
|
|
38
36
|
});
|
|
39
37
|
|
|
40
|
-
const [
|
|
41
|
-
const result = await
|
|
38
|
+
const [fn] = state.languageDataAt<CompletionSource>('autocomplete', text.length);
|
|
39
|
+
const result = await fn(new CompletionContext(state, text.length, true));
|
|
42
40
|
expect(result?.options).to.have.length(1);
|
|
43
41
|
});
|
|
44
42
|
});
|
|
@@ -12,15 +12,16 @@ import {
|
|
|
12
12
|
startCompletion,
|
|
13
13
|
} from '@codemirror/autocomplete';
|
|
14
14
|
import { HighlightStyle, type Language, syntaxHighlighting } from '@codemirror/language';
|
|
15
|
-
import { type Extension
|
|
15
|
+
import { type Extension } from '@codemirror/state';
|
|
16
16
|
import { type EditorView, ViewPlugin, type ViewUpdate, keymap } from '@codemirror/view';
|
|
17
17
|
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 { singleValueFacet } from '@dxos/react-ui-editor/state';
|
|
21
22
|
import { mx } from '@dxos/react-ui-theme';
|
|
22
23
|
|
|
23
|
-
import { type FunctionDefinition } from '../../
|
|
24
|
+
import { type FunctionDefinition } from '../../graph';
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* https://codemirror.net/examples/styling
|
|
@@ -59,7 +60,7 @@ const highlightStyles = HighlightStyle.define([
|
|
|
59
60
|
},
|
|
60
61
|
]);
|
|
61
62
|
|
|
62
|
-
const languageFacet =
|
|
63
|
+
const languageFacet = singleValueFacet<Language>();
|
|
63
64
|
|
|
64
65
|
export type SheetExtensionOptions = {
|
|
65
66
|
functions?: FunctionDefinition[];
|
|
@@ -165,8 +166,6 @@ export const sheetExtension = ({ functions = [] }: SheetExtensionOptions): Exten
|
|
|
165
166
|
icons: false,
|
|
166
167
|
tooltipClass: () =>
|
|
167
168
|
mx(
|
|
168
|
-
// TODO(burdon): Factor out fragments.
|
|
169
|
-
// TODO(burdon): Size to make width same as column.
|
|
170
169
|
'!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]',
|
|
171
170
|
'[&>ul>li[aria-selected]]:!bg-accentSurface',
|
|
172
171
|
'border-separator',
|
|
@@ -231,7 +230,7 @@ export const rangeExtension = (onInit: (notifier: CellRangeNotifier) => void): E
|
|
|
231
230
|
|
|
232
231
|
// Find first Range or cell at cursor.
|
|
233
232
|
activeRange = undefined;
|
|
234
|
-
const
|
|
233
|
+
const language = view.state.facet(languageFacet);
|
|
235
234
|
const { topNode } = language.parser.parse(view.state.doc.toString());
|
|
236
235
|
visitTree(topNode, ({ type, from, to }) => {
|
|
237
236
|
if (from <= anchor && to >= anchor) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { createContext, type PropsWithChildren } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type ComputeGraphRegistry } from '../../graph';
|
|
8
|
+
|
|
9
|
+
export type ComputeGraphContextType = {
|
|
10
|
+
registry: ComputeGraphRegistry;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The compute graph context manages a ComputeGraph for each space.
|
|
15
|
+
*/
|
|
16
|
+
export const ComputeGraphContext = createContext<ComputeGraphContextType | undefined>(undefined);
|
|
17
|
+
|
|
18
|
+
export const ComputeGraphContextProvider = ({ registry, children }: PropsWithChildren<ComputeGraphContextType>) => {
|
|
19
|
+
return <ComputeGraphContext.Provider value={{ registry }}>{children}</ComputeGraphContext.Provider>;
|
|
20
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { useSpace } from '@dxos/react-client/echo';
|
|
8
|
+
import { withClientProvider } from '@dxos/react-client/testing';
|
|
9
|
+
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
10
|
+
|
|
11
|
+
import { GridSheet } from './GridSheet';
|
|
12
|
+
import { useComputeGraph } from '../../hooks';
|
|
13
|
+
import { useTestSheet, withComputeGraphDecorator } from '../../testing';
|
|
14
|
+
import { SheetType } from '../../types';
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
title: 'plugin-sheet/GridSheet',
|
|
18
|
+
component: GridSheet,
|
|
19
|
+
decorators: [
|
|
20
|
+
withClientProvider({ types: [SheetType], createSpace: true }),
|
|
21
|
+
withComputeGraphDecorator(),
|
|
22
|
+
withTheme,
|
|
23
|
+
withLayout({ fullscreen: true, tooltips: true }),
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const Basic = () => {
|
|
28
|
+
const space = useSpace();
|
|
29
|
+
const graph = useComputeGraph(space);
|
|
30
|
+
const sheet = useTestSheet(space, graph);
|
|
31
|
+
if (!sheet || !space) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return <GridSheet graph={graph} sheet={sheet} />;
|
|
36
|
+
};
|