@dxos/plugin-markdown 0.8.4-main.406dc2a → 0.8.4-main.422d1c7879
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/MarkdownSettings-62YSRY7L.mjs +32 -0
- package/dist/lib/browser/MarkdownSettings-62YSRY7L.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +51 -0
- package/dist/lib/browser/blueprints/index.mjs.map +7 -0
- package/dist/lib/browser/chunk-4KOZEH2H.mjs +121 -0
- package/dist/lib/browser/chunk-4KOZEH2H.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-QFPZONKP.mjs +158 -0
- package/dist/lib/browser/chunk-QFPZONKP.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +39 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/create-YL5ELZWP.mjs +30 -0
- package/dist/lib/browser/create-YL5ELZWP.mjs.map +7 -0
- package/dist/lib/browser/create-markdown-LU5IDKMH.mjs +22 -0
- package/dist/lib/browser/create-markdown-LU5IDKMH.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +611 -152
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/open-AFSOZZ6G.mjs +21 -0
- package/dist/lib/browser/open-AFSOZZ6G.mjs.map +7 -0
- package/dist/lib/browser/operations/index.mjs +14 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/scroll-to-anchor-IPXV32A6.mjs +49 -0
- package/dist/lib/browser/scroll-to-anchor-IPXV32A6.mjs.map +7 -0
- package/dist/lib/browser/set-view-mode-2QWB24RR.mjs +26 -0
- package/dist/lib/browser/set-view-mode-2QWB24RR.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +11 -5
- package/dist/lib/browser/update-HZNVYBMO.mjs +45 -0
- package/dist/lib/browser/update-HZNVYBMO.mjs.map +7 -0
- package/dist/lib/node-esm/MarkdownSettings-QMPISOEU.mjs +33 -0
- package/dist/lib/node-esm/MarkdownSettings-QMPISOEU.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +52 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-3OPDJJJH.mjs +122 -0
- package/dist/lib/node-esm/chunk-3OPDJJJH.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-JUGS6RKO.mjs +159 -0
- package/dist/lib/node-esm/chunk-JUGS6RKO.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +40 -0
- package/dist/lib/node-esm/cli/index.mjs.map +7 -0
- package/dist/lib/node-esm/create-SMQAIM3V.mjs +31 -0
- package/dist/lib/node-esm/create-SMQAIM3V.mjs.map +7 -0
- package/dist/lib/node-esm/create-markdown-X2OASYKG.mjs +23 -0
- package/dist/lib/node-esm/create-markdown-X2OASYKG.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +611 -152
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/open-SRWLLOKE.mjs +22 -0
- package/dist/lib/node-esm/open-SRWLLOKE.mjs.map +7 -0
- package/dist/lib/node-esm/operations/index.mjs +15 -0
- package/dist/lib/node-esm/operations/index.mjs.map +7 -0
- package/dist/lib/node-esm/scroll-to-anchor-M76GXKYQ.mjs +50 -0
- package/dist/lib/node-esm/scroll-to-anchor-M76GXKYQ.mjs.map +7 -0
- package/dist/lib/node-esm/set-view-mode-6BB6KIDS.mjs +27 -0
- package/dist/lib/node-esm/set-view-mode-6BB6KIDS.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +11 -5
- package/dist/lib/node-esm/update-4CELTLXK.mjs +46 -0
- package/dist/lib/node-esm/update-4CELTLXK.mjs.map +7 -0
- package/dist/types/src/MarkdownPlugin.d.ts +2 -1
- package/dist/types/src/MarkdownPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/markdown-blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/markdown-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/anchor-sort.d.ts +4 -4
- package/dist/types/src/capabilities/anchor-sort.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-serializer.d.ts +3 -2
- package/dist/types/src/capabilities/app-graph-serializer.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts +3 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -4
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +9 -18
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/node.d.ts +4 -0
- package/dist/types/src/capabilities/node.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +4 -2
- package/dist/types/src/capabilities/settings.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts +4 -9
- package/dist/types/src/capabilities/state.d.ts.map +1 -1
- package/dist/types/src/cli/index.d.ts +2 -0
- package/dist/types/src/cli/index.d.ts.map +1 -0
- package/dist/types/src/cli/plugin.d.ts +3 -0
- package/dist/types/src/cli/plugin.d.ts.map +1 -0
- package/dist/types/src/components/MarkdownEditor/FileUpload.d.ts +11 -0
- package/dist/types/src/components/MarkdownEditor/FileUpload.d.ts.map +1 -0
- package/dist/types/src/components/MarkdownEditor/MarkdownEditor.d.ts +44 -21
- package/dist/types/src/components/MarkdownEditor/MarkdownEditor.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownEditor/MarkdownEditor.stories.d.ts +5 -110
- package/dist/types/src/components/MarkdownEditor/MarkdownEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownEditor/MarkdownEditorContent.d.ts +32 -0
- package/dist/types/src/components/MarkdownEditor/MarkdownEditorContent.d.ts.map +1 -0
- package/dist/types/src/components/MarkdownEditor/MarkdownEditorToolbar.d.ts +13 -0
- package/dist/types/src/components/MarkdownEditor/MarkdownEditorToolbar.d.ts.map +1 -0
- package/dist/types/src/components/MarkdownSettings/MarkdownSettings.d.ts +4 -4
- package/dist/types/src/components/MarkdownSettings/MarkdownSettings.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownSettings/MarkdownSettings.stories.d.ts +94 -0
- package/dist/types/src/components/MarkdownSettings/MarkdownSettings.stories.d.ts.map +1 -0
- package/dist/types/src/components/MarkdownSettings/index.d.ts +1 -1
- package/dist/types/src/components/MarkdownSettings/index.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/MarkdownCard/MarkdownCard.d.ts +8 -0
- package/dist/types/src/containers/MarkdownCard/MarkdownCard.d.ts.map +1 -0
- package/dist/types/src/containers/MarkdownCard/MarkdownCard.stories.d.ts +9 -0
- package/dist/types/src/containers/MarkdownCard/MarkdownCard.stories.d.ts.map +1 -0
- package/dist/types/src/containers/MarkdownCard/index.d.ts +2 -0
- package/dist/types/src/containers/MarkdownCard/index.d.ts.map +1 -0
- package/dist/types/src/containers/MarkdownCard/snippet.d.ts +17 -0
- package/dist/types/src/containers/MarkdownCard/snippet.d.ts.map +1 -0
- package/dist/types/src/containers/MarkdownContainer/MarkdownContainer.d.ts +36 -0
- package/dist/types/src/containers/MarkdownContainer/MarkdownContainer.d.ts.map +1 -0
- package/dist/types/src/containers/MarkdownContainer/MarkdownContainer.stories.d.ts +77 -0
- package/dist/types/src/containers/MarkdownContainer/MarkdownContainer.stories.d.ts.map +1 -0
- package/dist/types/src/containers/MarkdownContainer/index.d.ts +3 -0
- package/dist/types/src/containers/MarkdownContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +5 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +3 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useEditorMenuOptions.d.ts +9 -0
- package/dist/types/src/hooks/useEditorMenuOptions.d.ts.map +1 -0
- package/dist/types/src/hooks/useExtensions.d.ts +24 -0
- package/dist/types/src/hooks/useExtensions.d.ts.map +1 -0
- package/dist/types/src/hooks/useLinkQuery.d.ts +4 -0
- package/dist/types/src/hooks/useLinkQuery.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -2
- package/dist/types/src/index.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/operations/create-markdown.d.ts +5 -0
- package/dist/types/src/operations/create-markdown.d.ts.map +1 -0
- package/dist/types/src/operations/create.d.ts +5 -0
- package/dist/types/src/operations/create.d.ts.map +1 -0
- package/dist/types/src/operations/create.test.d.ts +2 -0
- package/dist/types/src/operations/create.test.d.ts.map +1 -0
- package/dist/types/src/operations/definitions.d.ts +64 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/open.d.ts +5 -0
- package/dist/types/src/operations/open.d.ts.map +1 -0
- package/dist/types/src/operations/scroll-to-anchor.d.ts +5 -0
- package/dist/types/src/operations/scroll-to-anchor.d.ts.map +1 -0
- package/dist/types/src/operations/set-view-mode.d.ts +5 -0
- package/dist/types/src/operations/set-view-mode.d.ts.map +1 -0
- package/dist/types/src/operations/update.d.ts +5 -0
- package/dist/types/src/operations/update.d.ts.map +1 -0
- package/dist/types/src/operations/update.test.d.ts +2 -0
- package/dist/types/src/operations/update.test.d.ts.map +1 -0
- package/dist/types/src/testing.d.ts +6 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +53 -31
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Markdown.d.ts +30 -31
- package/dist/types/src/types/Markdown.d.ts.map +1 -1
- package/dist/types/src/types/Settings.d.ts +17 -0
- package/dist/types/src/types/Settings.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts +33 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +5 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +4 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +2 -2
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +7 -4
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/src/util.test.d.ts +2 -0
- package/dist/types/src/util.test.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +111 -64
- package/src/MarkdownPlugin.tsx +75 -100
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/markdown-blueprint.ts +44 -0
- package/src/capabilities/anchor-sort.ts +29 -22
- package/src/capabilities/app-graph-serializer.ts +55 -44
- package/src/capabilities/artifact-definition.ts +82 -84
- package/src/capabilities/blueprint-definition.ts +9 -31
- package/src/capabilities/index.ts +12 -12
- package/src/capabilities/node.ts +11 -0
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +110 -104
- package/src/capabilities/settings.ts +30 -18
- package/src/capabilities/state.ts +41 -25
- package/src/cli/index.ts +5 -0
- package/src/cli/plugin.ts +39 -0
- package/src/components/MarkdownEditor/FileUpload.tsx +63 -0
- package/src/components/MarkdownEditor/MarkdownEditor.stories.tsx +62 -40
- package/src/components/MarkdownEditor/MarkdownEditor.tsx +252 -267
- package/src/components/MarkdownEditor/MarkdownEditorContent.tsx +170 -0
- package/src/components/MarkdownEditor/MarkdownEditorToolbar.tsx +47 -0
- package/src/components/MarkdownSettings/MarkdownSettings.stories.tsx +39 -0
- package/src/components/MarkdownSettings/MarkdownSettings.tsx +23 -96
- package/src/components/MarkdownSettings/index.ts +1 -1
- package/src/components/index.ts +4 -5
- package/src/containers/MarkdownCard/MarkdownCard.stories.tsx +67 -0
- package/src/containers/MarkdownCard/MarkdownCard.tsx +68 -0
- package/src/containers/MarkdownCard/index.ts +5 -0
- package/src/containers/MarkdownCard/snippet.ts +52 -0
- package/src/containers/MarkdownContainer/MarkdownContainer.stories.tsx +135 -0
- package/src/containers/MarkdownContainer/MarkdownContainer.tsx +145 -0
- package/src/containers/MarkdownContainer/index.ts +6 -0
- package/src/containers/index.ts +10 -0
- package/src/hooks/index.ts +3 -1
- package/src/hooks/useEditorMenuOptions.ts +68 -0
- package/src/hooks/useExtensions.tsx +264 -0
- package/src/hooks/useLinkQuery.ts +108 -0
- package/src/index.ts +4 -2
- package/src/meta.ts +6 -6
- package/src/operations/create-markdown.ts +20 -0
- package/src/operations/create.conversations.json +1 -0
- package/src/operations/create.test.ts +98 -0
- package/src/operations/create.ts +27 -0
- package/src/operations/definitions.ts +120 -0
- package/src/operations/index.ts +16 -0
- package/src/operations/open.ts +25 -0
- package/src/operations/scroll-to-anchor.ts +39 -0
- package/src/operations/set-view-mode.ts +24 -0
- package/src/operations/update.conversations.json +1 -0
- package/src/operations/update.test.ts +215 -0
- package/src/operations/update.ts +51 -0
- package/src/testing.ts +27 -0
- package/src/translations.ts +26 -32
- package/src/types/Markdown.ts +23 -31
- package/src/types/Settings.ts +65 -0
- package/src/types/capabilities.ts +50 -0
- package/src/types/events.ts +14 -0
- package/src/types/index.ts +5 -2
- package/src/types/types.ts +3 -2
- package/src/util.test.ts +44 -0
- package/src/util.tsx +81 -12
- package/dist/lib/browser/MarkdownCard-AGWOTODZ.mjs +0 -83
- package/dist/lib/browser/MarkdownCard-AGWOTODZ.mjs.map +0 -7
- package/dist/lib/browser/MarkdownContainer-MV2UNAUV.mjs +0 -751
- package/dist/lib/browser/MarkdownContainer-MV2UNAUV.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-YWJI3BKT.mjs +0 -32
- package/dist/lib/browser/anchor-sort-YWJI3BKT.mjs.map +0 -7
- package/dist/lib/browser/app-graph-serializer-KYDFCUOW.mjs +0 -51
- package/dist/lib/browser/app-graph-serializer-KYDFCUOW.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-BHRMFZAC.mjs +0 -11
- package/dist/lib/browser/chunk-6KU5DKP7.mjs +0 -51
- package/dist/lib/browser/chunk-6KU5DKP7.mjs.map +0 -7
- package/dist/lib/browser/chunk-HBBEHOP3.mjs +0 -106
- package/dist/lib/browser/chunk-HBBEHOP3.mjs.map +0 -7
- package/dist/lib/browser/chunk-O6XUPW6S.mjs +0 -53
- package/dist/lib/browser/chunk-O6XUPW6S.mjs.map +0 -7
- package/dist/lib/browser/chunk-ODB2PTBP.mjs +0 -28
- package/dist/lib/browser/chunk-ODB2PTBP.mjs.map +0 -7
- package/dist/lib/browser/chunk-OY6CGPOO.mjs +0 -16
- package/dist/lib/browser/chunk-OY6CGPOO.mjs.map +0 -7
- package/dist/lib/browser/chunk-XMT6PMU5.mjs +0 -79
- package/dist/lib/browser/chunk-XMT6PMU5.mjs.map +0 -7
- package/dist/lib/browser/chunk-Z5PDJNBV.mjs +0 -22
- package/dist/lib/browser/chunk-Z5PDJNBV.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-XHVCZZHU.mjs +0 -62
- package/dist/lib/browser/intent-resolver-XHVCZZHU.mjs.map +0 -7
- package/dist/lib/browser/react-surface-3A2GO3BN.mjs +0 -215
- package/dist/lib/browser/react-surface-3A2GO3BN.mjs.map +0 -7
- package/dist/lib/browser/settings-XY265Y2Q.mjs +0 -28
- package/dist/lib/browser/settings-XY265Y2Q.mjs.map +0 -7
- package/dist/lib/browser/state-6QODXCSZ.mjs +0 -37
- package/dist/lib/browser/state-6QODXCSZ.mjs.map +0 -7
- package/dist/lib/browser/toolkit-YA65QX2S.mjs +0 -76
- package/dist/lib/browser/toolkit-YA65QX2S.mjs.map +0 -7
- package/dist/lib/node-esm/MarkdownCard-B2IWTFOC.mjs +0 -84
- package/dist/lib/node-esm/MarkdownCard-B2IWTFOC.mjs.map +0 -7
- package/dist/lib/node-esm/MarkdownContainer-J2R3DLCQ.mjs +0 -752
- package/dist/lib/node-esm/MarkdownContainer-J2R3DLCQ.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-FCRYL2FX.mjs +0 -33
- package/dist/lib/node-esm/anchor-sort-FCRYL2FX.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-serializer-FAUQM3BH.mjs +0 -52
- package/dist/lib/node-esm/app-graph-serializer-FAUQM3BH.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-XYFKMIDR.mjs +0 -12
- package/dist/lib/node-esm/chunk-7RDNIMTF.mjs +0 -24
- package/dist/lib/node-esm/chunk-7RDNIMTF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CB2R4YIY.mjs +0 -17
- package/dist/lib/node-esm/chunk-CB2R4YIY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-FVI7LPC3.mjs +0 -107
- package/dist/lib/node-esm/chunk-FVI7LPC3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-FWZKC6X5.mjs +0 -80
- package/dist/lib/node-esm/chunk-FWZKC6X5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VCG2U522.mjs +0 -29
- package/dist/lib/node-esm/chunk-VCG2U522.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XO3IEQJE.mjs +0 -54
- package/dist/lib/node-esm/chunk-XO3IEQJE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZBXV4ON7.mjs +0 -52
- package/dist/lib/node-esm/chunk-ZBXV4ON7.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-7A2EXGZQ.mjs +0 -63
- package/dist/lib/node-esm/intent-resolver-7A2EXGZQ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-RCLL5WVQ.mjs +0 -216
- package/dist/lib/node-esm/react-surface-RCLL5WVQ.mjs.map +0 -7
- package/dist/lib/node-esm/settings-H3UDD3KO.mjs +0 -29
- package/dist/lib/node-esm/settings-H3UDD3KO.mjs.map +0 -7
- package/dist/lib/node-esm/state-W3PECOJX.mjs +0 -38
- package/dist/lib/node-esm/state-W3PECOJX.mjs.map +0 -7
- package/dist/lib/node-esm/toolkit-HSIKUGNK.mjs +0 -77
- package/dist/lib/node-esm/toolkit-HSIKUGNK.mjs.map +0 -7
- package/dist/types/src/capabilities/capabilities.d.ts +0 -12
- package/dist/types/src/capabilities/capabilities.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/toolkit.d.ts +0 -4
- package/dist/types/src/capabilities/toolkit.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownCard/MarkdownCard.d.ts +0 -7
- package/dist/types/src/components/MarkdownCard/MarkdownCard.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownCard/MarkdownCard.stories.d.ts +0 -9
- package/dist/types/src/components/MarkdownCard/MarkdownCard.stories.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownCard/index.d.ts +0 -4
- package/dist/types/src/components/MarkdownCard/index.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownContainer.d.ts +0 -18
- package/dist/types/src/components/MarkdownContainer.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownContainer.stories.d.ts +0 -55
- package/dist/types/src/components/MarkdownContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/Suggestions.stories.d.ts +0 -11
- package/dist/types/src/components/Suggestions.stories.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar.stories.d.ts +0 -48
- package/dist/types/src/components/Toolbar.stories.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/dist/types/src/extensions.d.ts +0 -22
- package/dist/types/src/extensions.d.ts.map +0 -1
- package/dist/types/src/functions/diff.d.ts +0 -6
- package/dist/types/src/functions/diff.d.ts.map +0 -1
- package/dist/types/src/functions/index.d.ts +0 -3
- package/dist/types/src/functions/index.d.ts.map +0 -1
- package/dist/types/src/functions/open.d.ts +0 -7
- package/dist/types/src/functions/open.d.ts.map +0 -1
- package/dist/types/src/hooks/useSelectCurrentThread.d.ts +0 -6
- package/dist/types/src/hooks/useSelectCurrentThread.d.ts.map +0 -1
- package/dist/types/src/types/MarkdownAction.d.ts +0 -34
- package/dist/types/src/types/MarkdownAction.d.ts.map +0 -1
- package/src/capabilities/capabilities.ts +0 -21
- package/src/capabilities/intent-resolver.ts +0 -58
- package/src/capabilities/toolkit.ts +0 -49
- package/src/components/MarkdownCard/MarkdownCard.stories.tsx +0 -76
- package/src/components/MarkdownCard/MarkdownCard.tsx +0 -76
- package/src/components/MarkdownCard/index.ts +0 -9
- package/src/components/MarkdownContainer.stories.tsx +0 -109
- package/src/components/MarkdownContainer.tsx +0 -257
- package/src/components/Suggestions.stories.tsx +0 -219
- package/src/components/Toolbar.stories.tsx +0 -118
- package/src/events.ts +0 -11
- package/src/extensions.tsx +0 -300
- package/src/functions/diff.ts +0 -37
- package/src/functions/index.ts +0 -6
- package/src/functions/open.ts +0 -32
- package/src/hooks/useSelectCurrentThread.tsx +0 -56
- package/src/types/MarkdownAction.ts +0 -29
- /package/dist/lib/browser/{blueprint-definition-BHRMFZAC.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/node-esm/{blueprint-definition-XYFKMIDR.mjs.map → chunk-HSLMI22Q.mjs.map} +0 -0
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Function from 'effect/Function';
|
|
6
|
-
import React, { useCallback } from 'react';
|
|
7
|
-
|
|
8
|
-
import { LayoutAction, chain, createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
9
|
-
import { Obj } from '@dxos/echo';
|
|
10
|
-
import { type PreviewProps } from '@dxos/plugin-preview';
|
|
11
|
-
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
12
|
-
import { IconButton, useTranslation } from '@dxos/react-ui';
|
|
13
|
-
import { Card } from '@dxos/react-ui-stack';
|
|
14
|
-
import { DataType } from '@dxos/schema';
|
|
15
|
-
|
|
16
|
-
import { meta } from '../../meta';
|
|
17
|
-
import { Markdown } from '../../types';
|
|
18
|
-
import { getContentSnippet, getFallbackName } from '../../util';
|
|
19
|
-
|
|
20
|
-
// TODO(burdon): Factor out.
|
|
21
|
-
const getTitle = (subject: Markdown.Document | DataType.Text, fallback: string) => {
|
|
22
|
-
if (Obj.instanceOf(Markdown.Document, subject)) {
|
|
23
|
-
return subject.name ?? subject.fallbackName ?? getFallbackName(subject.content?.target?.content ?? fallback);
|
|
24
|
-
} else if (Obj.instanceOf(DataType.Text, subject)) {
|
|
25
|
-
return getFallbackName(subject.content);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
// TODO(burdon): Factor out.
|
|
30
|
-
const getSnippet = (subject: Markdown.Document | DataType.Text, fallback: string) => {
|
|
31
|
-
if (Obj.instanceOf(Markdown.Document, subject)) {
|
|
32
|
-
return Obj.getDescription(subject) || getContentSnippet(subject.content?.target?.content ?? fallback);
|
|
33
|
-
} else if (Obj.instanceOf(DataType.Text, subject)) {
|
|
34
|
-
return getContentSnippet(subject.content ?? fallback);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export type MarkdownCardProps = PreviewProps<Markdown.Document | DataType.Text>;
|
|
39
|
-
|
|
40
|
-
export const MarkdownCard = ({ subject, role }: MarkdownCardProps) => {
|
|
41
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
42
|
-
const { t } = useTranslation(meta.id);
|
|
43
|
-
const snippet = getSnippet(subject, t('fallback abstract'));
|
|
44
|
-
|
|
45
|
-
// TODO(wittjosiah): Factor out so this component isn't dependent on the app framework.
|
|
46
|
-
const handleNavigate = useCallback(
|
|
47
|
-
() =>
|
|
48
|
-
dispatch(
|
|
49
|
-
Function.pipe(
|
|
50
|
-
createIntent(LayoutAction.UpdatePopover, {
|
|
51
|
-
part: 'popover',
|
|
52
|
-
subject: null,
|
|
53
|
-
options: { state: false, anchorId: '' },
|
|
54
|
-
}),
|
|
55
|
-
chain(LayoutAction.Open, { part: 'main', subject: [fullyQualifiedId(subject)] }),
|
|
56
|
-
),
|
|
57
|
-
),
|
|
58
|
-
[dispatch, subject],
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<Card.SurfaceRoot role={role}>
|
|
63
|
-
<Card.Heading classNames='flex items-center'>
|
|
64
|
-
{getTitle(subject, t('fallback title'))}
|
|
65
|
-
<span className='grow' />
|
|
66
|
-
<IconButton
|
|
67
|
-
iconOnly
|
|
68
|
-
icon='ph--arrow-right--regular'
|
|
69
|
-
label={t('navigate to document label')}
|
|
70
|
-
onClick={handleNavigate}
|
|
71
|
-
/>
|
|
72
|
-
</Card.Heading>
|
|
73
|
-
{snippet && <Card.Text classNames='line-clamp-3 text-sm text-description'>{snippet}</Card.Text>}
|
|
74
|
-
</Card.SurfaceRoot>
|
|
75
|
-
);
|
|
76
|
-
};
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
-
import React, { useMemo } from 'react';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
type Capabilities,
|
|
10
|
-
IntentPlugin,
|
|
11
|
-
LayoutAction,
|
|
12
|
-
SettingsPlugin,
|
|
13
|
-
Surface,
|
|
14
|
-
createIntent,
|
|
15
|
-
useIntentDispatcher,
|
|
16
|
-
} from '@dxos/app-framework';
|
|
17
|
-
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
18
|
-
import { Obj, Query } from '@dxos/echo';
|
|
19
|
-
import { AttentionPlugin } from '@dxos/plugin-attention';
|
|
20
|
-
import { ClientPlugin } from '@dxos/plugin-client';
|
|
21
|
-
import { GraphPlugin } from '@dxos/plugin-graph';
|
|
22
|
-
import { PreviewPlugin } from '@dxos/plugin-preview';
|
|
23
|
-
import { SpacePlugin } from '@dxos/plugin-space';
|
|
24
|
-
import { StorybookLayoutPlugin } from '@dxos/plugin-storybook-layout';
|
|
25
|
-
import { ThemePlugin } from '@dxos/plugin-theme';
|
|
26
|
-
import { faker } from '@dxos/random';
|
|
27
|
-
import { useQuery, useSpace } from '@dxos/react-client/echo';
|
|
28
|
-
import { useAsyncEffect } from '@dxos/react-ui';
|
|
29
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
30
|
-
import { defaultTx } from '@dxos/react-ui-theme';
|
|
31
|
-
import { DataType } from '@dxos/schema';
|
|
32
|
-
import { type ValueGenerator, createObjectFactory } from '@dxos/schema/testing';
|
|
33
|
-
|
|
34
|
-
import { MarkdownPlugin } from '../MarkdownPlugin';
|
|
35
|
-
import { translations } from '../translations';
|
|
36
|
-
import { Markdown } from '../types';
|
|
37
|
-
|
|
38
|
-
faker.seed(1);
|
|
39
|
-
|
|
40
|
-
const generator: ValueGenerator = faker as any;
|
|
41
|
-
|
|
42
|
-
const DefaultStory = () => {
|
|
43
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
44
|
-
const space = useSpace();
|
|
45
|
-
const [doc] = useQuery(space, Query.type(Markdown.Document));
|
|
46
|
-
const data = useMemo(() => ({ subject: doc }), [doc]);
|
|
47
|
-
|
|
48
|
-
useAsyncEffect(async () => {
|
|
49
|
-
if (space) {
|
|
50
|
-
await dispatch(createIntent(LayoutAction.SwitchWorkspace, { part: 'workspace', subject: space.id }));
|
|
51
|
-
}
|
|
52
|
-
}, [space, dispatch]);
|
|
53
|
-
|
|
54
|
-
return <Surface role='article' data={data} limit={1} />;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const meta = {
|
|
58
|
-
title: 'plugins/plugin-markdown/MarkdownContainer',
|
|
59
|
-
render: DefaultStory,
|
|
60
|
-
decorators: [
|
|
61
|
-
withTheme,
|
|
62
|
-
withPluginManager({
|
|
63
|
-
plugins: [
|
|
64
|
-
ClientPlugin({
|
|
65
|
-
types: [Markdown.Document, DataType.Text, DataType.Person, DataType.Organization],
|
|
66
|
-
onClientInitialized: async ({ client }) => {
|
|
67
|
-
await client.halo.createIdentity();
|
|
68
|
-
await client.spaces.waitUntilReady();
|
|
69
|
-
await client.spaces.default.waitUntilReady();
|
|
70
|
-
const space = client.spaces.default;
|
|
71
|
-
const queue = space.queues.create();
|
|
72
|
-
const alice = Obj.make(DataType.Person, { fullName: 'Alice' });
|
|
73
|
-
const acme = Obj.make(DataType.Organization, { name: 'ACME' });
|
|
74
|
-
await queue.append([alice, acme]);
|
|
75
|
-
const doc = Markdown.makeDocument({
|
|
76
|
-
name: 'Test',
|
|
77
|
-
content: `# Test\n\n})\n\n})`,
|
|
78
|
-
});
|
|
79
|
-
space.db.add(doc);
|
|
80
|
-
const createObjects = createObjectFactory(space.db, generator);
|
|
81
|
-
await createObjects([{ type: DataType.Organization, count: 10 }]);
|
|
82
|
-
await space.db.flush({ indexes: true });
|
|
83
|
-
},
|
|
84
|
-
}),
|
|
85
|
-
SpacePlugin({}),
|
|
86
|
-
GraphPlugin(),
|
|
87
|
-
IntentPlugin(),
|
|
88
|
-
SettingsPlugin(),
|
|
89
|
-
// UI
|
|
90
|
-
ThemePlugin({ tx: defaultTx }),
|
|
91
|
-
AttentionPlugin(),
|
|
92
|
-
MarkdownPlugin(),
|
|
93
|
-
PreviewPlugin(),
|
|
94
|
-
StorybookLayoutPlugin({}),
|
|
95
|
-
],
|
|
96
|
-
}),
|
|
97
|
-
],
|
|
98
|
-
parameters: {
|
|
99
|
-
layout: 'fullscreen',
|
|
100
|
-
controls: { disable: true },
|
|
101
|
-
translations,
|
|
102
|
-
},
|
|
103
|
-
} satisfies Meta<typeof Capabilities>;
|
|
104
|
-
|
|
105
|
-
export default meta;
|
|
106
|
-
|
|
107
|
-
type Story = StoryObj<typeof meta>;
|
|
108
|
-
|
|
109
|
-
export const Default: Story = {};
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Rx } from '@effect-rx/rx-react';
|
|
6
|
-
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
7
|
-
import { createPortal } from 'react-dom';
|
|
8
|
-
|
|
9
|
-
import { Capabilities, Surface, useAppGraph, useCapabilities, usePluginManager } from '@dxos/app-framework';
|
|
10
|
-
import { DXN, Filter, Obj, Query, Type } from '@dxos/echo';
|
|
11
|
-
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
12
|
-
import { SpaceCapabilities } from '@dxos/plugin-space';
|
|
13
|
-
import { useClient } from '@dxos/react-client';
|
|
14
|
-
import { fullyQualifiedId, getSpace } from '@dxos/react-client/echo';
|
|
15
|
-
import { toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
16
|
-
import { type SelectionManager } from '@dxos/react-ui-attention';
|
|
17
|
-
import {
|
|
18
|
-
type PopoverMenuGroup,
|
|
19
|
-
type PopoverMenuItem,
|
|
20
|
-
type PreviewLinkRef,
|
|
21
|
-
type PreviewOptions,
|
|
22
|
-
insertAtCursor,
|
|
23
|
-
insertAtLineStart,
|
|
24
|
-
} from '@dxos/react-ui-editor';
|
|
25
|
-
import { DataType } from '@dxos/schema';
|
|
26
|
-
|
|
27
|
-
import { useExtensions } from '../extensions';
|
|
28
|
-
import { Markdown } from '../types';
|
|
29
|
-
import { getFallbackName } from '../util';
|
|
30
|
-
|
|
31
|
-
import { MarkdownEditor, type MarkdownEditorProps } from './MarkdownEditor';
|
|
32
|
-
|
|
33
|
-
export type MarkdownContainerProps = Pick<
|
|
34
|
-
MarkdownEditorProps,
|
|
35
|
-
'role' | 'extensionProviders' | 'viewMode' | 'editorStateStore' | 'onViewModeChange'
|
|
36
|
-
> & {
|
|
37
|
-
id: string;
|
|
38
|
-
object: Markdown.Document | DataType.Text | any;
|
|
39
|
-
settings: Markdown.Settings;
|
|
40
|
-
selectionManager?: SelectionManager;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const MarkdownContainer = ({
|
|
44
|
-
id,
|
|
45
|
-
role,
|
|
46
|
-
object,
|
|
47
|
-
settings,
|
|
48
|
-
selectionManager,
|
|
49
|
-
viewMode,
|
|
50
|
-
editorStateStore,
|
|
51
|
-
onViewModeChange,
|
|
52
|
-
}: MarkdownContainerProps) => {
|
|
53
|
-
const { t } = useTranslation();
|
|
54
|
-
const scrollPastEnd = role === 'article';
|
|
55
|
-
const doc = Obj.instanceOf(Markdown.Document, object) ? object : undefined;
|
|
56
|
-
const text = Obj.instanceOf(DataType.Text, object) ? object : undefined;
|
|
57
|
-
const [previewBlocks, setPreviewBlocks] = useState<{ link: PreviewLinkRef; el: HTMLElement }[]>([]);
|
|
58
|
-
const previewOptions = useMemo(
|
|
59
|
-
(): PreviewOptions => ({
|
|
60
|
-
addBlockContainer: (link, el) => {
|
|
61
|
-
setPreviewBlocks((prev) => [...prev, { link, el }]);
|
|
62
|
-
},
|
|
63
|
-
removeBlockContainer: (link) => {
|
|
64
|
-
setPreviewBlocks((prev) => prev.filter(({ link: prevLink }) => prevLink.ref !== link.ref));
|
|
65
|
-
},
|
|
66
|
-
}),
|
|
67
|
-
[],
|
|
68
|
-
);
|
|
69
|
-
const extensions = useExtensions({
|
|
70
|
-
document: doc,
|
|
71
|
-
text,
|
|
72
|
-
id,
|
|
73
|
-
settings,
|
|
74
|
-
selectionManager,
|
|
75
|
-
viewMode,
|
|
76
|
-
editorStateStore,
|
|
77
|
-
previewOptions,
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
// TODO(wittjosiah): Factor out.
|
|
81
|
-
const manager = usePluginManager();
|
|
82
|
-
const resolve = useCallback(
|
|
83
|
-
(typename: string) =>
|
|
84
|
-
manager.context.getCapabilities(Capabilities.Metadata).find(({ id }) => id === typename)?.metadata ?? {},
|
|
85
|
-
[manager],
|
|
86
|
-
);
|
|
87
|
-
const space = getSpace(object);
|
|
88
|
-
const objectForms = useCapabilities(SpaceCapabilities.ObjectForm);
|
|
89
|
-
const schemaWhiteList = useCapabilities(ClientCapabilities.SchemaWhiteList);
|
|
90
|
-
const filter = useMemo(
|
|
91
|
-
() =>
|
|
92
|
-
Filter.or(
|
|
93
|
-
...objectForms.map((form) => Filter.type(form.objectSchema)),
|
|
94
|
-
...schemaWhiteList.flat().map((schema) => Filter.typename(Type.getTypename(schema))),
|
|
95
|
-
),
|
|
96
|
-
[objectForms, schemaWhiteList],
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
const handleLinkQuery = useCallback(
|
|
100
|
-
async (query?: string): Promise<PopoverMenuGroup[]> => {
|
|
101
|
-
const name = query?.startsWith('@') ? query.slice(1).toLowerCase() : (query?.toLowerCase() ?? '');
|
|
102
|
-
const results = await space?.db.query(Query.select(filter)).run();
|
|
103
|
-
// TODO(wittjosiah): Use `Obj.Any` type.
|
|
104
|
-
const getLabel = (object: any) => {
|
|
105
|
-
const label = Obj.getLabel(object);
|
|
106
|
-
if (label) {
|
|
107
|
-
return label;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// TODO(wittjosiah): Remove metadata labels.
|
|
111
|
-
const type = Obj.getTypename(object)!;
|
|
112
|
-
const metadata = resolve(type);
|
|
113
|
-
return metadata.label?.(object) || ['object name placeholder', { ns: type, default: 'New object' }];
|
|
114
|
-
};
|
|
115
|
-
const items =
|
|
116
|
-
results?.objects
|
|
117
|
-
.filter((object) => toLocalizedString(getLabel(object), t).toLowerCase().includes(name))
|
|
118
|
-
// TODO(wittjosiah): Remove `any` type.
|
|
119
|
-
.map((object: any): PopoverMenuItem => {
|
|
120
|
-
const metadata = resolve(Obj.getTypename(object)!);
|
|
121
|
-
const label = toLocalizedString(getLabel(object), t);
|
|
122
|
-
return {
|
|
123
|
-
id: object.id,
|
|
124
|
-
label,
|
|
125
|
-
icon: metadata.icon,
|
|
126
|
-
onSelect: (view, head) => {
|
|
127
|
-
const link = `[${label}](${Obj.getDXN(object)})`;
|
|
128
|
-
if (query?.startsWith('@')) {
|
|
129
|
-
insertAtLineStart(view, head, `!${link}\n`);
|
|
130
|
-
} else {
|
|
131
|
-
insertAtCursor(view, head, `${link} `);
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
};
|
|
135
|
-
}) ?? [];
|
|
136
|
-
return [{ id: 'echo', items }];
|
|
137
|
-
},
|
|
138
|
-
[filter, resolve, space],
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
// TODO(burdon): Reconcile variants.
|
|
142
|
-
const editor = doc ? (
|
|
143
|
-
<DocumentEditor
|
|
144
|
-
id={fullyQualifiedId(object)}
|
|
145
|
-
role={role}
|
|
146
|
-
document={doc}
|
|
147
|
-
extensions={extensions}
|
|
148
|
-
viewMode={viewMode}
|
|
149
|
-
settings={settings}
|
|
150
|
-
scrollPastEnd={scrollPastEnd}
|
|
151
|
-
onViewModeChange={onViewModeChange}
|
|
152
|
-
onLinkQuery={space ? handleLinkQuery : undefined}
|
|
153
|
-
/>
|
|
154
|
-
) : text ? (
|
|
155
|
-
<MarkdownEditor
|
|
156
|
-
id={id}
|
|
157
|
-
role={role}
|
|
158
|
-
initialValue={text.content}
|
|
159
|
-
extensions={extensions}
|
|
160
|
-
viewMode={viewMode}
|
|
161
|
-
toolbar={settings.toolbar}
|
|
162
|
-
inputMode={settings.editorInputMode}
|
|
163
|
-
scrollPastEnd={scrollPastEnd}
|
|
164
|
-
onViewModeChange={onViewModeChange}
|
|
165
|
-
onLinkQuery={space ? handleLinkQuery : undefined}
|
|
166
|
-
/>
|
|
167
|
-
) : (
|
|
168
|
-
<MarkdownEditor
|
|
169
|
-
id={id}
|
|
170
|
-
role={role}
|
|
171
|
-
initialValue={object.text}
|
|
172
|
-
extensions={extensions}
|
|
173
|
-
viewMode={viewMode}
|
|
174
|
-
toolbar={settings.toolbar}
|
|
175
|
-
inputMode={settings.editorInputMode}
|
|
176
|
-
scrollPastEnd={scrollPastEnd}
|
|
177
|
-
onViewModeChange={onViewModeChange}
|
|
178
|
-
onLinkQuery={space ? handleLinkQuery : undefined}
|
|
179
|
-
/>
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
return (
|
|
183
|
-
<>
|
|
184
|
-
{editor}
|
|
185
|
-
{previewBlocks.map(({ link, el }) => (
|
|
186
|
-
<PreviewBlock key={link.ref} link={link} el={el} />
|
|
187
|
-
))}
|
|
188
|
-
</>
|
|
189
|
-
);
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
// TODO(wittjosiah): This shouldn't be "card" but "block".
|
|
193
|
-
// It's not a preview card but an interactive embedded object.
|
|
194
|
-
const PreviewBlock = ({ link, el }: { link: PreviewLinkRef; el: HTMLElement }) => {
|
|
195
|
-
const client = useClient();
|
|
196
|
-
const dxn = DXN.parse(link.ref);
|
|
197
|
-
const subject = client.graph.ref(dxn).target;
|
|
198
|
-
const data = useMemo(() => ({ subject }), [subject]);
|
|
199
|
-
|
|
200
|
-
return createPortal(<Surface role='card--transclusion' data={data} limit={1} />, el);
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
type DocumentEditorProps = Omit<MarkdownContainerProps, 'object' | 'extensionProviders' | 'editorStateStore'> &
|
|
204
|
-
Pick<MarkdownEditorProps, 'id' | 'scrollPastEnd' | 'extensions' | 'onLinkQuery'> & {
|
|
205
|
-
document: Markdown.Document;
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
export const DocumentEditor = ({ id, document: doc, settings, viewMode, ...props }: DocumentEditorProps) => {
|
|
209
|
-
const space = getSpace(doc);
|
|
210
|
-
|
|
211
|
-
// Migrate gradually to `fallbackName`.
|
|
212
|
-
useEffect(() => {
|
|
213
|
-
if (typeof doc.fallbackName === 'string') {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
const fallbackName = doc.content?.target?.content ? getFallbackName(doc.content.target.content) : undefined;
|
|
218
|
-
if (fallbackName) {
|
|
219
|
-
doc.fallbackName = fallbackName;
|
|
220
|
-
}
|
|
221
|
-
}, [doc, doc.content]);
|
|
222
|
-
|
|
223
|
-
// File dragging.
|
|
224
|
-
const [upload] = useCapabilities(Capabilities.FileUploader);
|
|
225
|
-
const handleFileUpload = useMemo(() => {
|
|
226
|
-
if (space === undefined || upload === undefined) {
|
|
227
|
-
return undefined;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// TODO(burdon): Re-order props: space, file.
|
|
231
|
-
return async (file: File) => upload!(file, space);
|
|
232
|
-
}, [space, upload]);
|
|
233
|
-
|
|
234
|
-
const { graph } = useAppGraph();
|
|
235
|
-
const customActions = useMemo(() => {
|
|
236
|
-
return Rx.make((get) => {
|
|
237
|
-
const actions = get(graph.actions(id));
|
|
238
|
-
const nodes = actions.filter((action) => action.properties.disposition === 'toolbar');
|
|
239
|
-
return { nodes, edges: nodes.map((node) => ({ source: 'root', target: node.id })) };
|
|
240
|
-
});
|
|
241
|
-
}, [graph]);
|
|
242
|
-
|
|
243
|
-
return (
|
|
244
|
-
<MarkdownEditor
|
|
245
|
-
id={id}
|
|
246
|
-
initialValue={doc.content?.target?.content}
|
|
247
|
-
viewMode={viewMode}
|
|
248
|
-
toolbar={settings.toolbar}
|
|
249
|
-
customActions={customActions}
|
|
250
|
-
inputMode={settings.editorInputMode}
|
|
251
|
-
onFileUpload={handleFileUpload}
|
|
252
|
-
{...props}
|
|
253
|
-
/>
|
|
254
|
-
);
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
export default MarkdownContainer;
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Meta } from '@storybook/react-vite';
|
|
6
|
-
import * as Function from 'effect/Function';
|
|
7
|
-
import * as Match from 'effect/Match';
|
|
8
|
-
import * as Option from 'effect/Option';
|
|
9
|
-
import * as Schema from 'effect/Schema';
|
|
10
|
-
import React, { type FC, useEffect, useMemo, useState } from 'react';
|
|
11
|
-
|
|
12
|
-
import { Capabilities, IntentPlugin, SettingsPlugin, useCapability, useIntentDispatcher } from '@dxos/app-framework';
|
|
13
|
-
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
14
|
-
import { Obj, Ref, Type } from '@dxos/echo';
|
|
15
|
-
import { invariant } from '@dxos/invariant';
|
|
16
|
-
import { ClientPlugin } from '@dxos/plugin-client';
|
|
17
|
-
import { GraphPlugin } from '@dxos/plugin-graph';
|
|
18
|
-
import { PreviewPlugin } from '@dxos/plugin-preview';
|
|
19
|
-
import { SpacePlugin } from '@dxos/plugin-space';
|
|
20
|
-
import { StorybookLayoutPlugin } from '@dxos/plugin-storybook-layout';
|
|
21
|
-
import { ThemePlugin } from '@dxos/plugin-theme';
|
|
22
|
-
import { faker } from '@dxos/random';
|
|
23
|
-
import { createDocAccessor, fullyQualifiedId, toCursorRange, useQueue, useSpace } from '@dxos/react-client/echo';
|
|
24
|
-
import { IconButton, Toolbar } from '@dxos/react-ui';
|
|
25
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
26
|
-
import { type EditorSelection, type Range, useTextEditor } from '@dxos/react-ui-editor';
|
|
27
|
-
import { StackItem } from '@dxos/react-ui-stack';
|
|
28
|
-
import { defaultTx } from '@dxos/react-ui-theme';
|
|
29
|
-
import { DataType } from '@dxos/schema';
|
|
30
|
-
import { render } from '@dxos/storybook-utils';
|
|
31
|
-
|
|
32
|
-
import { MarkdownCapabilities } from '../capabilities';
|
|
33
|
-
import { MarkdownPlugin } from '../MarkdownPlugin';
|
|
34
|
-
import { meta } from '../meta';
|
|
35
|
-
import { translations } from '../translations';
|
|
36
|
-
import { Markdown } from '../types';
|
|
37
|
-
|
|
38
|
-
import { MarkdownContainer } from './MarkdownContainer';
|
|
39
|
-
|
|
40
|
-
faker.seed(1);
|
|
41
|
-
|
|
42
|
-
const TestItem = Schema.Struct({
|
|
43
|
-
title: Schema.String.annotations({
|
|
44
|
-
title: 'Title',
|
|
45
|
-
description: 'Product title',
|
|
46
|
-
}),
|
|
47
|
-
description: Schema.String.annotations({
|
|
48
|
-
title: 'Description',
|
|
49
|
-
description: 'Product description',
|
|
50
|
-
}),
|
|
51
|
-
}).pipe(
|
|
52
|
-
Type.Obj({
|
|
53
|
-
typename: 'dxos.org/type/Test',
|
|
54
|
-
version: '0.1.0',
|
|
55
|
-
}),
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
const TestChat: FC<{ doc: Markdown.Document; content: string }> = ({ doc, content }) => {
|
|
59
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
60
|
-
const { parentRef } = useTextEditor({ initialValue: content });
|
|
61
|
-
const { editorState } = useCapability(MarkdownCapabilities.State);
|
|
62
|
-
|
|
63
|
-
const space = useSpace();
|
|
64
|
-
const queueDxn = useMemo(() => space && space.queues.create().dxn, [space]);
|
|
65
|
-
const queue = useQueue<DataType.Message>(queueDxn);
|
|
66
|
-
|
|
67
|
-
const handleInsert = async () => {
|
|
68
|
-
invariant(space);
|
|
69
|
-
invariant(queue);
|
|
70
|
-
await queue.append([
|
|
71
|
-
Obj.make(DataType.Message, {
|
|
72
|
-
created: new Date().toISOString(),
|
|
73
|
-
sender: { role: 'assistant' },
|
|
74
|
-
blocks: [{ _tag: 'text', text: 'Hello' }],
|
|
75
|
-
}),
|
|
76
|
-
]);
|
|
77
|
-
const message = queue.objects.at(-1);
|
|
78
|
-
invariant(message);
|
|
79
|
-
|
|
80
|
-
const text = await doc.content.load();
|
|
81
|
-
const accessor = createDocAccessor(text, ['content']);
|
|
82
|
-
const cursor = Function.pipe(
|
|
83
|
-
editorState.getState(fullyQualifiedId(doc))?.selection,
|
|
84
|
-
Option.fromNullable,
|
|
85
|
-
Option.map(selectionToRange),
|
|
86
|
-
Option.map((range) => toCursorRange(accessor, range.from, range.to)),
|
|
87
|
-
Option.getOrUndefined,
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
// {
|
|
91
|
-
// const ref = refFromDXN(new DXN(DXN.kind.QUEUE, [...queue.dxn.parts, message.id]));
|
|
92
|
-
// const message = deref(ref);
|
|
93
|
-
// }
|
|
94
|
-
|
|
95
|
-
// void dispatch(
|
|
96
|
-
// createIntent(CollaborationActions.InsertContent, {
|
|
97
|
-
// target: doc as any as Type.Expando,
|
|
98
|
-
// object: Ref.fromDXN(new DXN(DXN.kind.QUEUE, [...queue.dxn.parts, message.id])),
|
|
99
|
-
// at: cursor,
|
|
100
|
-
// label: 'Proposal',
|
|
101
|
-
// }),
|
|
102
|
-
// );
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
return (
|
|
106
|
-
<StackItem.Content toolbar>
|
|
107
|
-
<Toolbar.Root>
|
|
108
|
-
<IconButton icon='ph--plus--regular' disabled={!queue} label='Insert' onClick={handleInsert} />
|
|
109
|
-
</Toolbar.Root>
|
|
110
|
-
<div ref={parentRef} className='p-4' />
|
|
111
|
-
</StackItem.Content>
|
|
112
|
-
);
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const DefaultStory = ({ document, chat }: { document: string; chat: string }) => {
|
|
116
|
-
const space = useSpace();
|
|
117
|
-
const [doc, setDoc] = useState<Markdown.Document>();
|
|
118
|
-
const settings = useCapability(Capabilities.SettingsStore).getStore<Markdown.Settings>(meta.id)!.value;
|
|
119
|
-
const { editorState } = useCapability(MarkdownCapabilities.State);
|
|
120
|
-
|
|
121
|
-
useEffect(() => {
|
|
122
|
-
if (!space) {
|
|
123
|
-
return undefined;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const doc = space.db.add(
|
|
127
|
-
Markdown.makeDocument({
|
|
128
|
-
name: 'Test',
|
|
129
|
-
content: document.replaceAll(/\[(\w+)\]/g, (_, label) => {
|
|
130
|
-
const obj = space.db.add(Obj.make(TestItem, { title: label, description: faker.lorem.paragraph() }));
|
|
131
|
-
const dxn = Ref.make(obj).dxn.toString();
|
|
132
|
-
return `[${label}](${dxn})`;
|
|
133
|
-
}),
|
|
134
|
-
}),
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
setDoc(doc);
|
|
138
|
-
}, [space]);
|
|
139
|
-
|
|
140
|
-
if (!space || !doc) {
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// TODO(burdon): Layout issue.
|
|
145
|
-
return (
|
|
146
|
-
<div className='grid grid-cols-2 bs-full overflow-hidden'>
|
|
147
|
-
<MarkdownContainer id={doc.id} object={doc} settings={settings} editorStateStore={editorState} />
|
|
148
|
-
<TestChat doc={doc} content={chat} />
|
|
149
|
-
</div>
|
|
150
|
-
);
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
const storybook: Meta<typeof DefaultStory> = {
|
|
154
|
-
title: 'plugins/plugin-markdown/Suggestions',
|
|
155
|
-
render: render(DefaultStory),
|
|
156
|
-
decorators: [
|
|
157
|
-
withTheme,
|
|
158
|
-
withPluginManager({
|
|
159
|
-
plugins: [
|
|
160
|
-
ClientPlugin({
|
|
161
|
-
types: [Markdown.Document, TestItem],
|
|
162
|
-
onClientInitialized: async ({ client }) => {
|
|
163
|
-
await client.halo.createIdentity();
|
|
164
|
-
},
|
|
165
|
-
}),
|
|
166
|
-
SpacePlugin({}),
|
|
167
|
-
GraphPlugin(),
|
|
168
|
-
IntentPlugin(),
|
|
169
|
-
SettingsPlugin(),
|
|
170
|
-
|
|
171
|
-
// UI
|
|
172
|
-
ThemePlugin({ tx: defaultTx }),
|
|
173
|
-
MarkdownPlugin(),
|
|
174
|
-
PreviewPlugin(),
|
|
175
|
-
StorybookLayoutPlugin({}),
|
|
176
|
-
],
|
|
177
|
-
}),
|
|
178
|
-
],
|
|
179
|
-
parameters: {
|
|
180
|
-
layout: 'fullscreen',
|
|
181
|
-
controls: {
|
|
182
|
-
disable: true,
|
|
183
|
-
},
|
|
184
|
-
translations,
|
|
185
|
-
},
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
export default storybook;
|
|
189
|
-
|
|
190
|
-
type Story = Meta<typeof DefaultStory>;
|
|
191
|
-
|
|
192
|
-
export const Default: Story = {
|
|
193
|
-
args: {
|
|
194
|
-
chat: 'Hello\n',
|
|
195
|
-
document: [
|
|
196
|
-
'# Test',
|
|
197
|
-
'',
|
|
198
|
-
faker.lorem.paragraph(1),
|
|
199
|
-
'',
|
|
200
|
-
'This is a [DXOS] story that tests [ECHO] references inside the Markdown plugin.',
|
|
201
|
-
'',
|
|
202
|
-
faker.lorem.paragraph(3),
|
|
203
|
-
'',
|
|
204
|
-
].join('\n'),
|
|
205
|
-
},
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
// TODO(wittjosiah): Factor out.
|
|
209
|
-
const selectionToRange = Match.type<EditorSelection>().pipe(
|
|
210
|
-
Match.when(
|
|
211
|
-
({ head, anchor }) => (head ? head > anchor : false),
|
|
212
|
-
({ head, anchor }) => ({ from: anchor, to: head! }) as Range,
|
|
213
|
-
),
|
|
214
|
-
Match.when(
|
|
215
|
-
({ head, anchor }) => (head ? head < anchor : false),
|
|
216
|
-
({ head, anchor }) => ({ from: head!, to: anchor }) as Range,
|
|
217
|
-
),
|
|
218
|
-
Match.orElse(({ anchor }) => ({ from: anchor, to: anchor }) as Range),
|
|
219
|
-
);
|