@dxos/plugin-markdown 0.8.4-main.67995b8 → 0.8.4-main.69d29f4
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/MarkdownCard-HFNNE4B4.mjs +12 -0
- package/dist/lib/browser/MarkdownCard-HFNNE4B4.mjs.map +7 -0
- package/dist/lib/browser/MarkdownContainer-V7EAADMF.mjs +12 -0
- package/dist/lib/browser/MarkdownContainer-V7EAADMF.mjs.map +7 -0
- package/dist/lib/browser/anchor-sort-WQ3TL7ZI.mjs +32 -0
- package/dist/lib/browser/anchor-sort-WQ3TL7ZI.mjs.map +7 -0
- package/dist/lib/browser/app-graph-serializer-ULZUJKOD.mjs +58 -0
- package/dist/lib/browser/app-graph-serializer-ULZUJKOD.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-TLV4PNZW.mjs +19 -0
- package/dist/lib/browser/blueprint-definition-TLV4PNZW.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +8 -0
- package/dist/lib/browser/blueprints/index.mjs.map +7 -0
- package/dist/lib/browser/chunk-BX73DASG.mjs +702 -0
- package/dist/lib/browser/chunk-BX73DASG.mjs.map +7 -0
- package/dist/lib/browser/chunk-CUGDX7KA.mjs +8 -0
- package/dist/lib/browser/chunk-CUGDX7KA.mjs.map +7 -0
- package/dist/lib/browser/chunk-FWQQW6KU.mjs +144 -0
- package/dist/lib/browser/chunk-FWQQW6KU.mjs.map +7 -0
- package/dist/lib/browser/{chunk-K7ZFMSC4.mjs → chunk-JOXYQLKH.mjs} +10 -7
- package/dist/lib/browser/chunk-JOXYQLKH.mjs.map +7 -0
- package/dist/lib/browser/chunk-KDKXFKDN.mjs +104 -0
- package/dist/lib/browser/chunk-KDKXFKDN.mjs.map +7 -0
- package/dist/lib/browser/chunk-LMO5UVKL.mjs +167 -0
- package/dist/lib/browser/chunk-LMO5UVKL.mjs.map +7 -0
- package/dist/lib/browser/chunk-S45ULIOG.mjs +101 -0
- package/dist/lib/browser/chunk-S45ULIOG.mjs.map +7 -0
- package/dist/lib/browser/chunk-VQ3WOAB6.mjs +60 -0
- package/dist/lib/browser/chunk-VQ3WOAB6.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +32 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +127 -137
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-EGCWOQKJ.mjs +53 -0
- package/dist/lib/browser/operation-resolver-EGCWOQKJ.mjs.map +7 -0
- package/dist/lib/browser/react-surface-64FZ7T7F.mjs +213 -0
- package/dist/lib/browser/react-surface-64FZ7T7F.mjs.map +7 -0
- package/dist/lib/browser/settings-JY5JE7MI.mjs +35 -0
- package/dist/lib/browser/settings-JY5JE7MI.mjs.map +7 -0
- package/dist/lib/browser/state-QE7VSJWJ.mjs +29 -0
- package/dist/lib/browser/state-QE7VSJWJ.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +10 -3
- package/dist/lib/node-esm/MarkdownCard-GMNXUWWR.mjs +13 -0
- package/dist/lib/node-esm/MarkdownCard-GMNXUWWR.mjs.map +7 -0
- package/dist/lib/node-esm/MarkdownContainer-LUSMORP2.mjs +13 -0
- package/dist/lib/node-esm/MarkdownContainer-LUSMORP2.mjs.map +7 -0
- package/dist/lib/node-esm/{anchor-sort-R6AAKYNG.mjs → anchor-sort-G7D5TAI6.mjs} +12 -12
- package/dist/lib/node-esm/anchor-sort-G7D5TAI6.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-serializer-W5YMQP7P.mjs +59 -0
- package/dist/lib/node-esm/app-graph-serializer-W5YMQP7P.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-HYFA7BKQ.mjs +20 -0
- package/dist/lib/node-esm/blueprint-definition-HYFA7BKQ.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +9 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-3JYPCC7M.mjs +105 -0
- package/dist/lib/node-esm/chunk-3JYPCC7M.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-YGNVDYMB.mjs → chunk-44VJC3QF.mjs} +10 -7
- package/dist/lib/node-esm/chunk-44VJC3QF.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-D4BCFPKK.mjs +703 -0
- package/dist/lib/node-esm/chunk-D4BCFPKK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-EYAFC4N7.mjs +145 -0
- package/dist/lib/node-esm/chunk-EYAFC4N7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KXEQCFMB.mjs +61 -0
- package/dist/lib/node-esm/chunk-KXEQCFMB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-PRV35A7Z.mjs +168 -0
- package/dist/lib/node-esm/chunk-PRV35A7Z.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SDTYEGGL.mjs +102 -0
- package/dist/lib/node-esm/chunk-SDTYEGGL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-W3IIKDV5.mjs +10 -0
- package/dist/lib/node-esm/chunk-W3IIKDV5.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +33 -0
- package/dist/lib/node-esm/cli/index.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +127 -137
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-2HIS2AQZ.mjs +54 -0
- package/dist/lib/node-esm/operation-resolver-2HIS2AQZ.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-PKEVHTJK.mjs +214 -0
- package/dist/lib/node-esm/react-surface-PKEVHTJK.mjs.map +7 -0
- package/dist/lib/node-esm/settings-4UGMPIRY.mjs +36 -0
- package/dist/lib/node-esm/settings-4UGMPIRY.mjs.map +7 -0
- package/dist/lib/node-esm/state-LXE5XIN4.mjs +30 -0
- package/dist/lib/node-esm/state-LXE5XIN4.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +10 -3
- package/dist/types/src/MarkdownPlugin.d.ts +2 -1
- package/dist/types/src/MarkdownPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/functions/create.d.ts +8 -0
- package/dist/types/src/blueprints/functions/create.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/create.test.d.ts +2 -0
- package/dist/types/src/blueprints/functions/create.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/index.d.ts +4 -0
- package/dist/types/src/blueprints/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/open.d.ts +7 -0
- package/dist/types/src/blueprints/functions/open.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/update.d.ts +6 -0
- package/dist/types/src/blueprints/functions/update.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/update.test.d.ts +2 -0
- package/dist/types/src/blueprints/functions/update.test.d.ts.map +1 -0
- 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 +21 -0
- package/dist/types/src/blueprints/markdown-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts +5 -0
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts.map +1 -0
- package/dist/types/src/capabilities/anchor-sort/index.d.ts +3 -0
- package/dist/types/src/capabilities/anchor-sort/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-serializer/app-graph-serializer.d.ts +5 -0
- package/dist/types/src/capabilities/app-graph-serializer/app-graph-serializer.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-serializer/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-serializer/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +5 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +10 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +7 -16
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/index.d.ts +3 -0
- package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/settings.d.ts +6 -0
- package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/index.d.ts +3 -0
- package/dist/types/src/capabilities/state/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/state.d.ts +5 -0
- package/dist/types/src/capabilities/state/state.d.ts.map +1 -0
- 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/MarkdownCard/MarkdownCard.d.ts +8 -0
- package/dist/types/src/components/MarkdownCard/MarkdownCard.d.ts.map +1 -0
- package/dist/types/src/components/MarkdownCard/MarkdownCard.stories.d.ts +9 -0
- package/dist/types/src/components/MarkdownCard/MarkdownCard.stories.d.ts.map +1 -0
- package/dist/types/src/components/MarkdownCard/index.d.ts +4 -0
- package/dist/types/src/components/MarkdownCard/index.d.ts.map +1 -0
- package/dist/types/src/components/MarkdownContainer.d.ts +21 -11
- package/dist/types/src/components/MarkdownContainer.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownContainer.stories.d.ts +55 -5
- package/dist/types/src/components/MarkdownContainer.stories.d.ts.map +1 -1
- 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 +43 -23
- package/dist/types/src/components/MarkdownEditor/MarkdownEditor.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownEditor/MarkdownEditor.stories.d.ts +8 -15
- package/dist/types/src/components/MarkdownEditor/MarkdownEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownEditor/MarkdownEditorContent.d.ts +30 -0
- package/dist/types/src/components/MarkdownEditor/MarkdownEditorContent.d.ts.map +1 -0
- package/dist/types/src/components/MarkdownEditor/MarkdownEditorToolbar.d.ts +12 -0
- package/dist/types/src/components/MarkdownEditor/MarkdownEditorToolbar.d.ts.map +1 -0
- package/dist/types/src/components/MarkdownSettings/MarkdownSettings.d.ts +4 -2
- package/dist/types/src/components/MarkdownSettings/MarkdownSettings.d.ts.map +1 -1
- package/dist/types/src/components/Suggestions.stories.d.ts +1 -2
- package/dist/types/src/components/Suggestions.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +7 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +3 -0
- 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 +21 -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/hooks/useSelectCurrentThread.d.ts +1 -1
- package/dist/types/src/hooks/useSelectCurrentThread.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +6 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +5 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Markdown.d.ts +18 -16
- package/dist/types/src/types/Markdown.d.ts.map +1 -1
- package/dist/types/src/types/MarkdownAction.d.ts +63 -39
- package/dist/types/src/types/MarkdownAction.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +22 -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 +3 -0
- 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 +6 -3
- 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 +94 -60
- package/src/MarkdownPlugin.tsx +81 -103
- package/src/blueprints/functions/create.conversations.json +1 -0
- package/src/blueprints/functions/create.test.ts +125 -0
- package/src/blueprints/functions/create.ts +34 -0
- package/src/blueprints/functions/index.ts +7 -0
- package/src/blueprints/functions/open.ts +33 -0
- package/src/blueprints/functions/update.conversations.json +1 -0
- package/src/blueprints/functions/update.test.ts +149 -0
- package/src/blueprints/functions/update.ts +38 -0
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/markdown-blueprint.ts +38 -0
- package/src/capabilities/anchor-sort/anchor-sort.ts +36 -0
- package/src/capabilities/anchor-sort/index.ts +7 -0
- package/src/capabilities/app-graph-serializer/app-graph-serializer.ts +59 -0
- package/src/capabilities/app-graph-serializer/index.ts +7 -0
- package/src/capabilities/artifact-definition/artifact-definition.ts +110 -0
- package/src/capabilities/artifact-definition/index.ts +7 -0
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +25 -0
- package/src/capabilities/blueprint-definition/index.ts +7 -0
- package/src/capabilities/index.ts +7 -11
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +45 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +100 -0
- package/src/capabilities/settings/index.ts +7 -0
- package/src/capabilities/settings/settings.ts +36 -0
- package/src/capabilities/state/index.ts +7 -0
- package/src/capabilities/state/state.ts +31 -0
- package/src/cli/index.ts +5 -0
- package/src/cli/plugin.ts +29 -0
- package/src/components/MarkdownCard/MarkdownCard.stories.tsx +58 -0
- package/src/components/MarkdownCard/MarkdownCard.tsx +62 -0
- package/src/components/MarkdownCard/index.ts +9 -0
- package/src/components/MarkdownContainer.stories.tsx +80 -57
- package/src/components/MarkdownContainer.tsx +104 -247
- package/src/components/MarkdownEditor/FileUpload.tsx +63 -0
- package/src/components/MarkdownEditor/MarkdownEditor.stories.tsx +57 -35
- package/src/components/MarkdownEditor/MarkdownEditor.tsx +220 -272
- package/src/components/MarkdownEditor/MarkdownEditorContent.tsx +162 -0
- package/src/components/MarkdownEditor/MarkdownEditorToolbar.tsx +66 -0
- package/src/components/MarkdownSettings/MarkdownSettings.tsx +94 -77
- package/src/components/Suggestions.stories.tsx +61 -66
- package/src/components/index.ts +10 -3
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useEditorMenuOptions.ts +68 -0
- package/src/{extensions.tsx → hooks/useExtensions.tsx} +77 -131
- package/src/hooks/useLinkQuery.ts +83 -0
- package/src/hooks/useSelectCurrentThread.tsx +38 -33
- package/src/index.ts +4 -3
- package/src/meta.ts +5 -8
- package/src/testing.ts +27 -0
- package/src/translations.ts +5 -0
- package/src/types/Markdown.ts +11 -9
- package/src/types/MarkdownAction.ts +52 -23
- package/src/types/capabilities.ts +38 -0
- package/src/types/events.ts +13 -0
- package/src/types/index.ts +4 -0
- package/src/types/types.ts +4 -2
- package/src/util.test.ts +44 -0
- package/src/util.tsx +82 -7
- package/dist/lib/browser/MarkdownContainer-NNBPE6A5.mjs +0 -779
- package/dist/lib/browser/MarkdownContainer-NNBPE6A5.mjs.map +0 -7
- package/dist/lib/browser/MarkdownPreview-7VG3K24R.mjs +0 -80
- package/dist/lib/browser/MarkdownPreview-7VG3K24R.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-Z7JQA7RL.mjs +0 -32
- package/dist/lib/browser/anchor-sort-Z7JQA7RL.mjs.map +0 -7
- package/dist/lib/browser/app-graph-serializer-ZT5OVF5G.mjs +0 -52
- package/dist/lib/browser/app-graph-serializer-ZT5OVF5G.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-7VNP5PCP.mjs +0 -145
- package/dist/lib/browser/artifact-definition-7VNP5PCP.mjs.map +0 -7
- package/dist/lib/browser/chunk-CD4E4K7J.mjs +0 -16
- package/dist/lib/browser/chunk-CD4E4K7J.mjs.map +0 -7
- package/dist/lib/browser/chunk-K7ZFMSC4.mjs.map +0 -7
- package/dist/lib/browser/chunk-VCUKIILA.mjs +0 -20
- package/dist/lib/browser/chunk-VCUKIILA.mjs.map +0 -7
- package/dist/lib/browser/chunk-VMX5SDGW.mjs +0 -50
- package/dist/lib/browser/chunk-VMX5SDGW.mjs.map +0 -7
- package/dist/lib/browser/chunk-YHMGUSO7.mjs +0 -80
- package/dist/lib/browser/chunk-YHMGUSO7.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZGY3DYC2.mjs +0 -30
- package/dist/lib/browser/chunk-ZGY3DYC2.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-EBEF7WEI.mjs +0 -60
- package/dist/lib/browser/intent-resolver-EBEF7WEI.mjs.map +0 -7
- package/dist/lib/browser/react-surface-ZPMZT4VU.mjs +0 -208
- package/dist/lib/browser/react-surface-ZPMZT4VU.mjs.map +0 -7
- package/dist/lib/browser/settings-MBDK4TWE.mjs +0 -28
- package/dist/lib/browser/settings-MBDK4TWE.mjs.map +0 -7
- package/dist/lib/browser/state-ZA6PZPUI.mjs +0 -37
- package/dist/lib/browser/state-ZA6PZPUI.mjs.map +0 -7
- package/dist/lib/node-esm/MarkdownContainer-Q6UO7DKT.mjs +0 -780
- package/dist/lib/node-esm/MarkdownContainer-Q6UO7DKT.mjs.map +0 -7
- package/dist/lib/node-esm/MarkdownPreview-UVWR2YK3.mjs +0 -81
- package/dist/lib/node-esm/MarkdownPreview-UVWR2YK3.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-R6AAKYNG.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-serializer-X4M5QEI6.mjs +0 -53
- package/dist/lib/node-esm/app-graph-serializer-X4M5QEI6.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-IRIILD7S.mjs +0 -146
- package/dist/lib/node-esm/artifact-definition-IRIILD7S.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6GCOJS4Y.mjs +0 -81
- package/dist/lib/node-esm/chunk-6GCOJS4Y.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-A7LLVI34.mjs +0 -22
- package/dist/lib/node-esm/chunk-A7LLVI34.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-B3J2M4YL.mjs +0 -17
- package/dist/lib/node-esm/chunk-B3J2M4YL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LZK3TLKM.mjs +0 -51
- package/dist/lib/node-esm/chunk-LZK3TLKM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RCIXKCVG.mjs +0 -31
- package/dist/lib/node-esm/chunk-RCIXKCVG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YGNVDYMB.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-L2UGZ72W.mjs +0 -61
- package/dist/lib/node-esm/intent-resolver-L2UGZ72W.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-3JJSTTQP.mjs +0 -209
- package/dist/lib/node-esm/react-surface-3JJSTTQP.mjs.map +0 -7
- package/dist/lib/node-esm/settings-LBDWWPZJ.mjs +0 -29
- package/dist/lib/node-esm/settings-LBDWWPZJ.mjs.map +0 -7
- package/dist/lib/node-esm/state-UIHO2SFZ.mjs +0 -38
- package/dist/lib/node-esm/state-UIHO2SFZ.mjs.map +0 -7
- package/dist/types/src/capabilities/anchor-sort.d.ts +0 -6
- package/dist/types/src/capabilities/anchor-sort.d.ts.map +0 -1
- package/dist/types/src/capabilities/app-graph-serializer.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-serializer.d.ts.map +0 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
- 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/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings.d.ts +0 -4
- package/dist/types/src/capabilities/settings.d.ts.map +0 -1
- package/dist/types/src/capabilities/state.d.ts +0 -11
- package/dist/types/src/capabilities/state.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownPreview/MarkdownPreview.d.ts +0 -6
- package/dist/types/src/components/MarkdownPreview/MarkdownPreview.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownPreview/MarkdownPreview.stories.d.ts +0 -10
- package/dist/types/src/components/MarkdownPreview/MarkdownPreview.stories.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownPreview/index.d.ts +0 -4
- package/dist/types/src/components/MarkdownPreview/index.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar.stories.d.ts +0 -11
- 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 -24
- package/dist/types/src/extensions.d.ts.map +0 -1
- package/src/capabilities/anchor-sort.ts +0 -30
- package/src/capabilities/app-graph-serializer.ts +0 -54
- package/src/capabilities/artifact-definition.ts +0 -116
- package/src/capabilities/capabilities.ts +0 -21
- package/src/capabilities/intent-resolver.ts +0 -57
- package/src/capabilities/react-surface.tsx +0 -114
- package/src/capabilities/settings.ts +0 -25
- package/src/capabilities/state.ts +0 -30
- package/src/components/MarkdownPreview/MarkdownPreview.stories.tsx +0 -77
- package/src/components/MarkdownPreview/MarkdownPreview.tsx +0 -73
- package/src/components/MarkdownPreview/index.ts +0 -9
- package/src/components/Toolbar.stories.tsx +0 -112
- package/src/events.ts +0 -11
|
@@ -2,253 +2,110 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
5
|
+
import { type Extension } from '@codemirror/state';
|
|
6
|
+
import { Atom } from '@effect-atom/atom-react';
|
|
7
|
+
import React, { forwardRef, useMemo } from 'react';
|
|
8
|
+
|
|
9
|
+
import { Common } from '@dxos/app-framework';
|
|
10
|
+
import { type SurfaceComponentProps, useAppGraph, useCapabilities } from '@dxos/app-framework/react';
|
|
11
|
+
import { Obj } from '@dxos/echo';
|
|
12
|
+
import { useActionRunner } from '@dxos/plugin-graph';
|
|
13
|
+
import { useObject } from '@dxos/react-client/echo';
|
|
15
14
|
import { type SelectionManager } from '@dxos/react-ui-attention';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
};
|
|
112
|
-
const items =
|
|
113
|
-
results?.objects
|
|
114
|
-
.filter((object) => toLocalizedString(getLabel(object), t).toLowerCase().includes(name))
|
|
115
|
-
// TODO(wittjosiah): Remove `any` type.
|
|
116
|
-
.map((object: any): CommandMenuItem => {
|
|
117
|
-
const metadata = resolve(Obj.getTypename(object)!);
|
|
118
|
-
const label = toLocalizedString(getLabel(object), t);
|
|
119
|
-
return {
|
|
120
|
-
id: object.id,
|
|
121
|
-
label,
|
|
122
|
-
icon: metadata.icon,
|
|
123
|
-
onSelect: (view, head) => {
|
|
124
|
-
const link = `[${label}][${Obj.getDXN(object)}]`;
|
|
125
|
-
if (query?.startsWith('@')) {
|
|
126
|
-
insertAtLineStart(view, head, `!${link}\n`);
|
|
127
|
-
} else {
|
|
128
|
-
insertAtCursor(view, head, `${link} `);
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
}) ?? [];
|
|
133
|
-
return [{ id: 'echo', items }];
|
|
134
|
-
},
|
|
135
|
-
[filter, resolve, space],
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
const editor = doc ? (
|
|
139
|
-
<DocumentEditor
|
|
140
|
-
id={fullyQualifiedId(object)}
|
|
141
|
-
role={role}
|
|
142
|
-
document={doc}
|
|
143
|
-
extensions={extensions}
|
|
144
|
-
viewMode={viewMode}
|
|
145
|
-
settings={settings}
|
|
146
|
-
scrollPastEnd={scrollPastEnd}
|
|
147
|
-
onViewModeChange={onViewModeChange}
|
|
148
|
-
onLinkQuery={space ? onLinkQuery : undefined}
|
|
149
|
-
/>
|
|
150
|
-
) : text ? (
|
|
151
|
-
<MarkdownEditor
|
|
152
|
-
id={id}
|
|
153
|
-
role={role}
|
|
154
|
-
initialValue={text.content}
|
|
155
|
-
extensions={extensions}
|
|
156
|
-
viewMode={viewMode}
|
|
157
|
-
toolbar={settings.toolbar}
|
|
158
|
-
inputMode={settings.editorInputMode}
|
|
159
|
-
scrollPastEnd={scrollPastEnd}
|
|
160
|
-
onViewModeChange={onViewModeChange}
|
|
161
|
-
onLinkQuery={space ? onLinkQuery : undefined}
|
|
162
|
-
/>
|
|
163
|
-
) : (
|
|
164
|
-
// TODO(burdon): Normalize with above.
|
|
165
|
-
<MarkdownEditor
|
|
166
|
-
id={id}
|
|
167
|
-
role={role}
|
|
168
|
-
initialValue={object.text}
|
|
169
|
-
extensions={extensions}
|
|
170
|
-
viewMode={viewMode}
|
|
171
|
-
toolbar={settings.toolbar}
|
|
172
|
-
inputMode={settings.editorInputMode}
|
|
173
|
-
scrollPastEnd={scrollPastEnd}
|
|
174
|
-
onViewModeChange={onViewModeChange}
|
|
175
|
-
onLinkQuery={space ? onLinkQuery : undefined}
|
|
176
|
-
/>
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
return (
|
|
180
|
-
<>
|
|
181
|
-
{editor}
|
|
182
|
-
{previewBlocks.map(({ link, el }) => (
|
|
183
|
-
<PreviewBlock key={link.ref} link={link} el={el} />
|
|
184
|
-
))}
|
|
185
|
-
</>
|
|
186
|
-
);
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
// TODO(wittjosiah): This shouldn't be "card" but "block".
|
|
190
|
-
// It's not a preview card but an interactive embedded object.
|
|
191
|
-
const PreviewBlock = ({ link, el }: { link: PreviewLinkRef; el: HTMLElement }) => {
|
|
192
|
-
const echoDXN = useMemo(() => DXN.parse(link.ref).asEchoDXN(), [link.ref]);
|
|
193
|
-
const space = useSpace(echoDXN?.spaceId);
|
|
194
|
-
const [subject] = useQuery(space, Query.select(Filter.ids(echoDXN?.echoId ?? '')));
|
|
195
|
-
const data = useMemo(() => ({ subject }), [subject]);
|
|
196
|
-
|
|
197
|
-
return createPortal(<Surface role='card--transclusion' data={data} limit={1} />, el);
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
type DocumentEditorProps = Omit<MarkdownContainerProps, 'object' | 'extensionProviders' | 'editorStateStore'> &
|
|
201
|
-
Pick<MarkdownEditorProps, 'id' | 'scrollPastEnd' | 'extensions' | 'onLinkQuery'> & {
|
|
202
|
-
document: Markdown.Document;
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
export const DocumentEditor = ({ id, document: doc, settings, viewMode, ...props }: DocumentEditorProps) => {
|
|
206
|
-
const space = getSpace(doc);
|
|
207
|
-
|
|
208
|
-
// Migrate gradually to `fallbackName`.
|
|
209
|
-
useEffect(() => {
|
|
210
|
-
if (typeof doc.fallbackName === 'string') {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
const fallbackName = doc.content?.target?.content ? getFallbackName(doc.content.target.content) : undefined;
|
|
215
|
-
if (fallbackName) {
|
|
216
|
-
doc.fallbackName = fallbackName;
|
|
217
|
-
}
|
|
218
|
-
}, [doc, doc.content]);
|
|
219
|
-
|
|
220
|
-
// File dragging.
|
|
221
|
-
const [upload] = useCapabilities(Capabilities.FileUploader);
|
|
222
|
-
const handleFileUpload = useMemo(() => {
|
|
223
|
-
if (space === undefined || upload === undefined) {
|
|
224
|
-
return undefined;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// TODO(burdon): Re-order props: space, file.
|
|
228
|
-
return async (file: File) => upload!(file, space);
|
|
229
|
-
}, [space, upload]);
|
|
230
|
-
|
|
231
|
-
const { graph } = useAppGraph();
|
|
232
|
-
const customActions = useMemo(() => {
|
|
233
|
-
return Rx.make((get) => {
|
|
234
|
-
const actions = get(graph.actions(id));
|
|
235
|
-
const nodes = actions.filter((action) => action.properties.disposition === 'toolbar');
|
|
236
|
-
return { nodes, edges: nodes.map((node) => ({ source: 'root', target: node.id })) };
|
|
237
|
-
});
|
|
238
|
-
}, [graph]);
|
|
239
|
-
|
|
240
|
-
return (
|
|
241
|
-
<MarkdownEditor
|
|
242
|
-
id={id}
|
|
243
|
-
initialValue={doc.content?.target?.content}
|
|
244
|
-
viewMode={viewMode}
|
|
245
|
-
toolbar={settings.toolbar}
|
|
246
|
-
customActions={customActions}
|
|
247
|
-
inputMode={settings.editorInputMode}
|
|
248
|
-
onFileUpload={handleFileUpload}
|
|
249
|
-
{...props}
|
|
250
|
-
/>
|
|
251
|
-
);
|
|
252
|
-
};
|
|
15
|
+
import { Layout } from '@dxos/react-ui-mosaic';
|
|
16
|
+
import { Text } from '@dxos/schema';
|
|
17
|
+
|
|
18
|
+
import { useLinkQuery } from '../hooks';
|
|
19
|
+
import { Markdown, MarkdownCapabilities, type MarkdownPluginState } from '../types';
|
|
20
|
+
|
|
21
|
+
import { MarkdownEditor, type MarkdownEditorContentProps, type MarkdownEditorRootProps } from './MarkdownEditor';
|
|
22
|
+
|
|
23
|
+
export type MarkdownContainerProps = SurfaceComponentProps<
|
|
24
|
+
Markdown.Document | Text.Text,
|
|
25
|
+
{
|
|
26
|
+
id: string;
|
|
27
|
+
settings: Markdown.Settings;
|
|
28
|
+
selectionManager?: SelectionManager;
|
|
29
|
+
} & Pick<MarkdownEditorRootProps, 'viewMode' | 'onViewModeChange'> &
|
|
30
|
+
Pick<MarkdownEditorContentProps, 'editorStateStore'> &
|
|
31
|
+
Pick<MarkdownPluginState, 'extensionProviders'>
|
|
32
|
+
>;
|
|
33
|
+
|
|
34
|
+
export const MarkdownContainer = forwardRef<HTMLDivElement, MarkdownContainerProps>(
|
|
35
|
+
({ role, subject: object, id, settings, extensionProviders, ...props }, forwardedRef) => {
|
|
36
|
+
const db = Obj.isObject(object) ? Obj.getDatabase(object) : undefined;
|
|
37
|
+
const attendableId = Obj.instanceOf(Markdown.Document, object) ? Obj.getDXN(object).toString() : undefined;
|
|
38
|
+
const [docContent] = useObject(Obj.instanceOf(Markdown.Document, object) ? object.content : undefined, 'content');
|
|
39
|
+
const [textContent] = useObject(Obj.instanceOf(Text.Text, object) ? object : undefined, 'content');
|
|
40
|
+
const initialValue = docContent ?? textContent;
|
|
41
|
+
|
|
42
|
+
// Extensions from other plugins.
|
|
43
|
+
// TODO(burdon): Document MarkdownPluginState.extensionProviders
|
|
44
|
+
const otherExtensionProviders = useCapabilities(MarkdownCapabilities.Extensions);
|
|
45
|
+
const extensions = useMemo<Extension[]>(() => {
|
|
46
|
+
if (!Obj.instanceOf(Markdown.Document, object) && !Obj.instanceOf(Text.Text, object)) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return [...(otherExtensionProviders ?? []), ...(extensionProviders ?? [])]
|
|
51
|
+
.flat()
|
|
52
|
+
.reduce((acc: Extension[], provider) => {
|
|
53
|
+
const extension =
|
|
54
|
+
typeof provider === 'function' ? provider({ document: object as Markdown.Document }) : provider;
|
|
55
|
+
if (extension) {
|
|
56
|
+
acc.push(extension);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return acc;
|
|
60
|
+
}, []);
|
|
61
|
+
}, [extensionProviders, otherExtensionProviders, object]);
|
|
62
|
+
|
|
63
|
+
// Toolbar actions from app graph.
|
|
64
|
+
const { graph } = useAppGraph();
|
|
65
|
+
const runAction = useActionRunner();
|
|
66
|
+
const customActions = useMemo(() => {
|
|
67
|
+
return Atom.make((get) => {
|
|
68
|
+
const actions = get(graph.actions(id));
|
|
69
|
+
const nodes = actions.filter((action) => action.properties.disposition === 'toolbar');
|
|
70
|
+
const edges = nodes.map((node) => ({ source: 'root', target: node.id }));
|
|
71
|
+
return { nodes, edges };
|
|
72
|
+
});
|
|
73
|
+
}, [graph]);
|
|
74
|
+
|
|
75
|
+
// File upload.
|
|
76
|
+
const [upload] = useCapabilities(Common.Capability.FileUploader);
|
|
77
|
+
const handleFileUpload = useMemo(() => {
|
|
78
|
+
if (!db || !upload) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return async (file: File) => upload(db, file);
|
|
83
|
+
}, [db, upload]);
|
|
84
|
+
|
|
85
|
+
// Query for @ refs.
|
|
86
|
+
const handleLinkQuery = useLinkQuery(db);
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<Layout.Main toolbar={settings.toolbar} ref={forwardedRef}>
|
|
90
|
+
<MarkdownEditor.Root
|
|
91
|
+
id={attendableId ?? id}
|
|
92
|
+
object={object}
|
|
93
|
+
extensions={extensions}
|
|
94
|
+
settings={settings}
|
|
95
|
+
onAction={runAction}
|
|
96
|
+
onFileUpload={handleFileUpload}
|
|
97
|
+
onLinkQuery={handleLinkQuery}
|
|
98
|
+
{...props}
|
|
99
|
+
>
|
|
100
|
+
{settings.toolbar && (
|
|
101
|
+
<MarkdownEditor.Toolbar id={attendableId ?? id} role={role} customActions={customActions} />
|
|
102
|
+
)}
|
|
103
|
+
<MarkdownEditor.Content initialValue={initialValue} scrollPastEnd={role === 'article'} />
|
|
104
|
+
<MarkdownEditor.Blocks />
|
|
105
|
+
</MarkdownEditor.Root>
|
|
106
|
+
</Layout.Main>
|
|
107
|
+
);
|
|
108
|
+
},
|
|
109
|
+
);
|
|
253
110
|
|
|
254
111
|
export default MarkdownContainer;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type EditorView } from '@codemirror/view';
|
|
6
|
+
import React, { forwardRef, useEffect, useImperativeHandle } from 'react';
|
|
7
|
+
import { createPortal } from 'react-dom';
|
|
8
|
+
import { useDropzone } from 'react-dropzone';
|
|
9
|
+
|
|
10
|
+
import { type Common } from '@dxos/app-framework';
|
|
11
|
+
import { addLink } from '@dxos/ui-editor';
|
|
12
|
+
|
|
13
|
+
export const IMAGE_FILES = ['.jpg', '.jpeg', '.png', '.gif'];
|
|
14
|
+
|
|
15
|
+
export type FileUploadAction = () => void;
|
|
16
|
+
|
|
17
|
+
export type FileUploadProps = {
|
|
18
|
+
editorView?: EditorView;
|
|
19
|
+
onFileUpload?: (file: File) => Promise<Common.FileInfo | undefined>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// TODO(burdon): Factor out.
|
|
23
|
+
// TODO(burdon): Move to root? (support drag into document via dropzone).
|
|
24
|
+
export const FileUpload = forwardRef<FileUploadAction, FileUploadProps>(
|
|
25
|
+
({ editorView, onFileUpload }, forwardedRef) => {
|
|
26
|
+
// https://react-dropzone.js.org
|
|
27
|
+
const { acceptedFiles, open, inputRef } = useDropzone({
|
|
28
|
+
disabled: !onFileUpload,
|
|
29
|
+
multiple: false,
|
|
30
|
+
noDrag: true,
|
|
31
|
+
accept: {
|
|
32
|
+
'image/*': IMAGE_FILES,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
useImperativeHandle(forwardedRef, () => open, []);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (editorView && acceptedFiles.length && onFileUpload) {
|
|
40
|
+
requestAnimationFrame(async () => {
|
|
41
|
+
// NOTE: Clone file since react-dropzone patches in a non-standard `path` property, which confuses IPFS.
|
|
42
|
+
const f = acceptedFiles[0];
|
|
43
|
+
const file = new File([f], f.name, {
|
|
44
|
+
type: f.type,
|
|
45
|
+
lastModified: f.lastModified,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// TODO(burdon): Factor out.
|
|
49
|
+
const info = await onFileUpload(file);
|
|
50
|
+
if (info) {
|
|
51
|
+
addLink({ url: info.url, image: true })(editorView);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}, [editorView, acceptedFiles, onFileUpload]);
|
|
56
|
+
|
|
57
|
+
if (!onFileUpload) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return <>{createPortal(<input ref={inputRef} />, document.body)} </>;
|
|
62
|
+
},
|
|
63
|
+
);
|
|
@@ -2,43 +2,74 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import React from 'react';
|
|
6
8
|
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
8
|
-
import React, { useMemo } from 'react';
|
|
9
|
-
|
|
10
|
-
import { IntentPlugin } from '@dxos/app-framework';
|
|
11
9
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
10
|
+
import { Filter, Obj } from '@dxos/echo';
|
|
11
|
+
import { ClientPlugin } from '@dxos/plugin-client';
|
|
12
|
+
import { corePlugins } from '@dxos/plugin-testing';
|
|
13
|
+
import { useQuery, useSpace } from '@dxos/react-client/echo';
|
|
14
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
15
|
+
import { useAttentionAttributes } from '@dxos/react-ui-attention';
|
|
16
|
+
import { translations as editorTranslations } from '@dxos/react-ui-editor';
|
|
17
|
+
import { Layout } from '@dxos/react-ui-mosaic';
|
|
16
18
|
|
|
17
|
-
import { MarkdownEditor, type MarkdownEditorProps } from './MarkdownEditor';
|
|
18
19
|
import { translations } from '../../translations';
|
|
20
|
+
import { Markdown } from '../../types';
|
|
21
|
+
|
|
22
|
+
import { MarkdownEditor, type MarkdownEditorRootProps } from './MarkdownEditor';
|
|
19
23
|
|
|
20
24
|
const content = Array.from({ length: 100 }, (_, i) => `Line ${i + 1}`).join('\n');
|
|
21
25
|
|
|
22
|
-
type StoryProps =
|
|
23
|
-
content?: string;
|
|
24
|
-
toolbar?: boolean;
|
|
25
|
-
};
|
|
26
|
+
type StoryProps = Omit<MarkdownEditorRootProps, 'id' | 'extensions'>;
|
|
26
27
|
|
|
27
|
-
const DefaultStory = (
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
28
|
+
const DefaultStory = (props: StoryProps) => {
|
|
29
|
+
const space = useSpace();
|
|
30
|
+
const [doc] = useQuery(space?.db, Filter.type(Markdown.Document));
|
|
31
|
+
const id = doc && Obj.getDXN(doc).toString();
|
|
32
|
+
const attentionAttrs = useAttentionAttributes(id);
|
|
33
|
+
if (!id) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div className='contents' {...attentionAttrs}>
|
|
39
|
+
<Layout.Main toolbar>
|
|
40
|
+
<MarkdownEditor.Root id={id} object={doc} {...props}>
|
|
41
|
+
<MarkdownEditor.Toolbar id={id} />
|
|
42
|
+
<MarkdownEditor.Content />
|
|
43
|
+
</MarkdownEditor.Root>
|
|
44
|
+
</Layout.Main>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
31
47
|
};
|
|
32
48
|
|
|
33
|
-
const meta: Meta<typeof
|
|
49
|
+
const meta: Meta<typeof DefaultStory> = {
|
|
34
50
|
title: 'plugins/plugin-markdown/MarkdownEditor',
|
|
35
|
-
component:
|
|
36
|
-
render: DefaultStory,
|
|
51
|
+
component: DefaultStory,
|
|
52
|
+
render: DefaultStory as any,
|
|
37
53
|
decorators: [
|
|
38
|
-
withPluginManager({ plugins: [IntentPlugin()] }),
|
|
39
|
-
withAttention,
|
|
40
54
|
withTheme,
|
|
41
|
-
withLayout({
|
|
55
|
+
withLayout({ layout: 'column' }),
|
|
56
|
+
withPluginManager({
|
|
57
|
+
plugins: [
|
|
58
|
+
...corePlugins(),
|
|
59
|
+
ClientPlugin({
|
|
60
|
+
types: [Markdown.Document],
|
|
61
|
+
onClientInitialized: ({ client }) =>
|
|
62
|
+
Effect.gen(function* () {
|
|
63
|
+
yield* Effect.promise(() => client.halo.createIdentity());
|
|
64
|
+
yield* Effect.promise(() => client.spaces.waitUntilReady());
|
|
65
|
+
const space = client.spaces.default;
|
|
66
|
+
yield* Effect.promise(() => space.waitUntilReady());
|
|
67
|
+
|
|
68
|
+
space.db.add(Markdown.make({ content }));
|
|
69
|
+
}),
|
|
70
|
+
}),
|
|
71
|
+
],
|
|
72
|
+
}),
|
|
42
73
|
],
|
|
43
74
|
parameters: {
|
|
44
75
|
translations: [...translations, ...editorTranslations],
|
|
@@ -47,15 +78,6 @@ const meta: Meta<typeof MarkdownEditor> = {
|
|
|
47
78
|
|
|
48
79
|
export default meta;
|
|
49
80
|
|
|
50
|
-
|
|
51
|
-
args: {
|
|
52
|
-
content,
|
|
53
|
-
},
|
|
54
|
-
};
|
|
81
|
+
type Story = StoryObj<typeof meta>;
|
|
55
82
|
|
|
56
|
-
export const
|
|
57
|
-
args: {
|
|
58
|
-
toolbar: true,
|
|
59
|
-
content,
|
|
60
|
-
},
|
|
61
|
-
};
|
|
83
|
+
export const Default: Story = {};
|