@dxos/plugin-markdown 0.8.4-main.2e9d522 → 0.8.4-main.3eb6e50203
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-7VIO7R66.mjs +11 -0
- package/dist/lib/browser/MarkdownCard-7VIO7R66.mjs.map +7 -0
- package/dist/lib/browser/MarkdownContainer-6E43EDAU.mjs +11 -0
- package/dist/lib/browser/MarkdownContainer-6E43EDAU.mjs.map +7 -0
- package/dist/lib/browser/anchor-sort-JBAZRPE7.mjs +33 -0
- package/dist/lib/browser/anchor-sort-JBAZRPE7.mjs.map +7 -0
- package/dist/lib/browser/app-graph-serializer-6Q5YBUPW.mjs +59 -0
- package/dist/lib/browser/app-graph-serializer-6Q5YBUPW.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-6HOAW2E6.mjs +20 -0
- package/dist/lib/browser/blueprint-definition-6HOAW2E6.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-LHDCHDBW.mjs → chunk-2AAD3W6X.mjs} +14 -9
- package/dist/lib/browser/chunk-2AAD3W6X.mjs.map +7 -0
- package/dist/lib/browser/chunk-4GT3QWMK.mjs +167 -0
- package/dist/lib/browser/chunk-4GT3QWMK.mjs.map +7 -0
- package/dist/lib/browser/chunk-6SM75KL3.mjs +8 -0
- package/dist/lib/browser/chunk-6SM75KL3.mjs.map +7 -0
- package/dist/lib/browser/chunk-7AQTX6D5.mjs +105 -0
- package/dist/lib/browser/chunk-7AQTX6D5.mjs.map +7 -0
- package/dist/lib/browser/chunk-EZZFREFN.mjs +58 -0
- package/dist/lib/browser/chunk-EZZFREFN.mjs.map +7 -0
- package/dist/lib/browser/chunk-HHRUUWGH.mjs +796 -0
- package/dist/lib/browser/chunk-HHRUUWGH.mjs.map +7 -0
- package/dist/lib/browser/chunk-HQTBT5IY.mjs +176 -0
- package/dist/lib/browser/chunk-HQTBT5IY.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +33 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +131 -136
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-UBQUPSXC.mjs +53 -0
- package/dist/lib/browser/operation-resolver-UBQUPSXC.mjs.map +7 -0
- package/dist/lib/browser/react-surface-7Z6AB26V.mjs +213 -0
- package/dist/lib/browser/react-surface-7Z6AB26V.mjs.map +7 -0
- package/dist/lib/browser/settings-V2XOFSD5.mjs +36 -0
- package/dist/lib/browser/settings-V2XOFSD5.mjs.map +7 -0
- package/dist/lib/browser/state-6Y3JB64H.mjs +29 -0
- package/dist/lib/browser/state-6Y3JB64H.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +13 -14
- package/dist/lib/node-esm/MarkdownCard-YC3R2TQW.mjs +12 -0
- package/dist/lib/node-esm/MarkdownCard-YC3R2TQW.mjs.map +7 -0
- package/dist/lib/node-esm/MarkdownContainer-TTRUOXU6.mjs +12 -0
- package/dist/lib/node-esm/MarkdownContainer-TTRUOXU6.mjs.map +7 -0
- package/dist/lib/node-esm/anchor-sort-IQMDZRA3.mjs +34 -0
- package/dist/lib/node-esm/anchor-sort-IQMDZRA3.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-serializer-STEPJH57.mjs +60 -0
- package/dist/lib/node-esm/app-graph-serializer-STEPJH57.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-UGDFF5OZ.mjs +21 -0
- package/dist/lib/node-esm/blueprint-definition-UGDFF5OZ.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-AGZOFIK2.mjs +10 -0
- package/dist/lib/node-esm/chunk-AGZOFIK2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-D46D75SK.mjs +797 -0
- package/dist/lib/node-esm/chunk-D46D75SK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-DCKB3AVD.mjs +59 -0
- package/dist/lib/node-esm/chunk-DCKB3AVD.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-K2IIYNCG.mjs +106 -0
- package/dist/lib/node-esm/chunk-K2IIYNCG.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-LOZVC2WA.mjs +177 -0
- package/dist/lib/node-esm/chunk-LOZVC2WA.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-VIR2ABYE.mjs → chunk-MLZQCT2N.mjs} +14 -9
- package/dist/lib/node-esm/chunk-MLZQCT2N.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-USKAPINH.mjs +168 -0
- package/dist/lib/node-esm/chunk-USKAPINH.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +34 -0
- package/dist/lib/node-esm/cli/index.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +131 -136
- 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-QAGXDA5E.mjs +54 -0
- package/dist/lib/node-esm/operation-resolver-QAGXDA5E.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-VIXAH5CF.mjs +214 -0
- package/dist/lib/node-esm/react-surface-VIXAH5CF.mjs.map +7 -0
- package/dist/lib/node-esm/settings-EXSH2KF4.mjs +37 -0
- package/dist/lib/node-esm/settings-EXSH2KF4.mjs.map +7 -0
- package/dist/lib/node-esm/state-TVF2XT2T.mjs +30 -0
- package/dist/lib/node-esm/state-TVF2XT2T.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +13 -14
- 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 +14 -0
- package/dist/types/src/blueprints/functions/open.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/update.d.ts +19 -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 +6 -0
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts.map +1 -0
- package/dist/types/src/capabilities/anchor-sort/index.d.ts +3 -0
- package/dist/types/src/capabilities/anchor-sort/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/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 +11 -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 +7 -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 +22 -12
- package/dist/types/src/components/MarkdownContainer.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownContainer.stories.d.ts +84 -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 +6 -4
- package/dist/types/src/components/MarkdownSettings/MarkdownSettings.d.ts.map +1 -1
- package/dist/types/src/components/Suggestions.stories.d.ts +3 -4
- 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 +4 -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 +36 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Markdown.d.ts +45 -0
- package/dist/types/src/types/Markdown.d.ts.map +1 -0
- package/dist/types/src/types/MarkdownAction.d.ts +66 -0
- package/dist/types/src/types/MarkdownAction.d.ts.map +1 -0
- 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 +5 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +4 -60
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +17 -5
- 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 +99 -56
- package/src/MarkdownPlugin.tsx +82 -103
- package/src/blueprints/functions/create.conversations.json +1 -0
- package/src/blueprints/functions/create.test.ts +92 -0
- package/src/blueprints/functions/create.ts +35 -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 +215 -0
- package/src/blueprints/functions/update.ts +79 -0
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/markdown-blueprint.ts +38 -0
- package/src/capabilities/anchor-sort/anchor-sort.ts +37 -0
- package/src/capabilities/anchor-sort/index.ts +7 -0
- package/src/capabilities/app-graph-serializer/app-graph-serializer.ts +60 -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 +26 -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 +102 -0
- package/src/capabilities/settings/index.ts +7 -0
- package/src/capabilities/settings/settings.ts +37 -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 +30 -0
- package/src/components/MarkdownCard/MarkdownCard.stories.tsx +58 -0
- package/src/components/MarkdownCard/MarkdownCard.tsx +64 -0
- package/src/components/MarkdownCard/index.ts +9 -0
- package/src/components/MarkdownContainer.stories.tsx +81 -61
- package/src/components/MarkdownContainer.tsx +106 -247
- package/src/components/MarkdownEditor/FileUpload.tsx +63 -0
- package/src/components/MarkdownEditor/MarkdownEditor.stories.tsx +58 -36
- package/src/components/MarkdownEditor/MarkdownEditor.tsx +226 -272
- package/src/components/MarkdownEditor/MarkdownEditorContent.tsx +162 -0
- package/src/components/MarkdownEditor/MarkdownEditorToolbar.tsx +66 -0
- package/src/components/MarkdownSettings/MarkdownSettings.tsx +97 -80
- package/src/components/Suggestions.stories.tsx +66 -72
- 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} +78 -131
- package/src/hooks/useLinkQuery.ts +83 -0
- package/src/hooks/useSelectCurrentThread.tsx +39 -34
- package/src/index.ts +7 -3
- package/src/meta.ts +9 -10
- package/src/testing.ts +27 -0
- package/src/translations.ts +9 -2
- package/src/types/Markdown.ts +57 -0
- package/src/types/MarkdownAction.ts +59 -0
- package/src/types/capabilities.ts +38 -0
- package/src/types/events.ts +14 -0
- package/src/types/index.ts +6 -1
- package/src/types/types.ts +7 -50
- package/src/util.test.ts +44 -0
- package/src/util.tsx +100 -11
- package/dist/lib/browser/MarkdownContainer-F3WEEIBX.mjs +0 -778
- package/dist/lib/browser/MarkdownContainer-F3WEEIBX.mjs.map +0 -7
- package/dist/lib/browser/MarkdownPreview-S3C7CGAV.mjs +0 -80
- package/dist/lib/browser/MarkdownPreview-S3C7CGAV.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-UKJJ7ZNP.mjs +0 -32
- package/dist/lib/browser/anchor-sort-UKJJ7ZNP.mjs.map +0 -7
- package/dist/lib/browser/app-graph-serializer-ICLAF662.mjs +0 -52
- package/dist/lib/browser/app-graph-serializer-ICLAF662.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-R2YYWOPN.mjs +0 -145
- package/dist/lib/browser/artifact-definition-R2YYWOPN.mjs.map +0 -7
- package/dist/lib/browser/chunk-777RIED6.mjs +0 -16
- package/dist/lib/browser/chunk-777RIED6.mjs.map +0 -7
- package/dist/lib/browser/chunk-EPTSAJZM.mjs +0 -22
- package/dist/lib/browser/chunk-EPTSAJZM.mjs.map +0 -7
- package/dist/lib/browser/chunk-LFML7LC6.mjs +0 -51
- package/dist/lib/browser/chunk-LFML7LC6.mjs.map +0 -7
- package/dist/lib/browser/chunk-LHDCHDBW.mjs.map +0 -7
- package/dist/lib/browser/chunk-PHTD5DTR.mjs +0 -20
- package/dist/lib/browser/chunk-PHTD5DTR.mjs.map +0 -7
- package/dist/lib/browser/chunk-UANWRJZU.mjs +0 -79
- package/dist/lib/browser/chunk-UANWRJZU.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-3MXYO3MW.mjs +0 -64
- package/dist/lib/browser/intent-resolver-3MXYO3MW.mjs.map +0 -7
- package/dist/lib/browser/react-surface-C3Z423TV.mjs +0 -206
- package/dist/lib/browser/react-surface-C3Z423TV.mjs.map +0 -7
- package/dist/lib/browser/settings-KN75ZQY6.mjs +0 -28
- package/dist/lib/browser/settings-KN75ZQY6.mjs.map +0 -7
- package/dist/lib/browser/state-LZWTAS65.mjs +0 -37
- package/dist/lib/browser/state-LZWTAS65.mjs.map +0 -7
- package/dist/lib/node-esm/MarkdownContainer-VOUHL6IU.mjs +0 -779
- package/dist/lib/node-esm/MarkdownContainer-VOUHL6IU.mjs.map +0 -7
- package/dist/lib/node-esm/MarkdownPreview-77UFEWXT.mjs +0 -81
- package/dist/lib/node-esm/MarkdownPreview-77UFEWXT.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-IPIS5D5B.mjs +0 -33
- package/dist/lib/node-esm/anchor-sort-IPIS5D5B.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-serializer-FLBXQKKR.mjs +0 -53
- package/dist/lib/node-esm/app-graph-serializer-FLBXQKKR.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-MLTAY4LK.mjs +0 -146
- package/dist/lib/node-esm/artifact-definition-MLTAY4LK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7X6TPTJK.mjs +0 -22
- package/dist/lib/node-esm/chunk-7X6TPTJK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ACFGXH2K.mjs +0 -17
- package/dist/lib/node-esm/chunk-ACFGXH2K.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CWTFQSN7.mjs +0 -52
- package/dist/lib/node-esm/chunk-CWTFQSN7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CXG7GMYP.mjs +0 -24
- package/dist/lib/node-esm/chunk-CXG7GMYP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JEEQLO7C.mjs +0 -80
- package/dist/lib/node-esm/chunk-JEEQLO7C.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VIR2ABYE.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-BZYWV53A.mjs +0 -65
- package/dist/lib/node-esm/intent-resolver-BZYWV53A.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-TTTBYNI2.mjs +0 -207
- package/dist/lib/node-esm/react-surface-TTTBYNI2.mjs.map +0 -7
- package/dist/lib/node-esm/settings-KVP7TVX7.mjs +0 -29
- package/dist/lib/node-esm/settings-KVP7TVX7.mjs.map +0 -7
- package/dist/lib/node-esm/state-NW3W4JCQ.mjs +0 -38
- package/dist/lib/node-esm/state-NW3W4JCQ.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 -42
- 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/dist/types/src/types/schema.d.ts +0 -35
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capabilities/anchor-sort.ts +0 -30
- package/src/capabilities/app-graph-serializer.ts +0 -52
- package/src/capabilities/artifact-definition.ts +0 -116
- package/src/capabilities/capabilities.ts +0 -20
- package/src/capabilities/intent-resolver.ts +0 -63
- package/src/capabilities/react-surface.tsx +0 -113
- package/src/capabilities/settings.ts +0 -25
- package/src/capabilities/state.ts +0 -31
- package/src/components/MarkdownPreview/MarkdownPreview.stories.tsx +0 -81
- package/src/components/MarkdownPreview/MarkdownPreview.tsx +0 -73
- package/src/components/MarkdownPreview/index.ts +0 -9
- package/src/components/Toolbar.stories.tsx +0 -113
- package/src/events.ts +0 -11
- package/src/types/schema.ts +0 -39
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { Obj, Ref, Type } from '@dxos/echo';
|
|
8
|
+
import { DescriptionAnnotation, FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';
|
|
9
|
+
import { Text } from '@dxos/schema';
|
|
10
|
+
import { EditorInputMode, EditorViewMode } from '@dxos/ui-editor/types';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Document Item type.
|
|
14
|
+
*/
|
|
15
|
+
export const Document = Schema.Struct({
|
|
16
|
+
name: Schema.optional(Schema.String),
|
|
17
|
+
description: Schema.optional(Schema.String),
|
|
18
|
+
fallbackName: Schema.String.pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
19
|
+
content: Type.Ref(Text.Text).pipe(FormInputAnnotation.set(false)),
|
|
20
|
+
}).pipe(
|
|
21
|
+
Type.object({
|
|
22
|
+
typename: 'dxos.org/type/Document',
|
|
23
|
+
version: '0.1.0',
|
|
24
|
+
}),
|
|
25
|
+
LabelAnnotation.set(['name', 'fallbackName']),
|
|
26
|
+
DescriptionAnnotation.set('description'),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export type Document = Schema.Schema.Type<typeof Document>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Document factory.
|
|
33
|
+
*/
|
|
34
|
+
export const make = ({
|
|
35
|
+
content = '',
|
|
36
|
+
...props
|
|
37
|
+
}: Partial<{ name: string; fallbackName: string; content: string }> = {}) =>
|
|
38
|
+
Obj.make(Document, { ...props, content: Ref.make(Text.make(content)) });
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Plugin settings.
|
|
42
|
+
*/
|
|
43
|
+
export const Settings = Schema.mutable(
|
|
44
|
+
Schema.Struct({
|
|
45
|
+
defaultViewMode: EditorViewMode,
|
|
46
|
+
editorInputMode: Schema.optional(EditorInputMode),
|
|
47
|
+
experimental: Schema.optional(Schema.Boolean),
|
|
48
|
+
debug: Schema.optional(Schema.Boolean),
|
|
49
|
+
toolbar: Schema.optional(Schema.Boolean),
|
|
50
|
+
typewriter: Schema.optional(Schema.String),
|
|
51
|
+
// TODO(burdon): Per document settings.
|
|
52
|
+
numberedHeadings: Schema.optional(Schema.Boolean),
|
|
53
|
+
folding: Schema.optional(Schema.Boolean),
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
export interface Settings extends Schema.Schema.Type<typeof Settings> {}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { Operation } from '@dxos/operation';
|
|
9
|
+
import { SpaceSchema } from '@dxos/react-client/echo';
|
|
10
|
+
import { Collection } from '@dxos/schema';
|
|
11
|
+
import { EditorViewMode } from '@dxos/ui-editor/types';
|
|
12
|
+
|
|
13
|
+
import { meta } from '../meta';
|
|
14
|
+
|
|
15
|
+
import { Document } from './Markdown';
|
|
16
|
+
|
|
17
|
+
const MARKDOWN_OPERATION = `${meta.id}/operation`;
|
|
18
|
+
|
|
19
|
+
export namespace MarkdownOperation {
|
|
20
|
+
export const OnCreateSpace = Operation.make({
|
|
21
|
+
meta: { key: `${MARKDOWN_OPERATION}/on-create-space`, name: 'On Create Space' },
|
|
22
|
+
services: [Capability.Service],
|
|
23
|
+
schema: {
|
|
24
|
+
input: Schema.Struct({
|
|
25
|
+
space: SpaceSchema,
|
|
26
|
+
rootCollection: Collection.Collection,
|
|
27
|
+
isDefault: Schema.optional(Schema.Boolean),
|
|
28
|
+
}),
|
|
29
|
+
output: Schema.Void,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export const Create = Operation.make({
|
|
34
|
+
meta: { key: `${MARKDOWN_OPERATION}/create`, name: 'Create Markdown Document' },
|
|
35
|
+
services: [Capability.Service],
|
|
36
|
+
schema: {
|
|
37
|
+
input: Schema.Struct({
|
|
38
|
+
name: Schema.optional(Schema.String),
|
|
39
|
+
content: Schema.optional(Schema.String),
|
|
40
|
+
}),
|
|
41
|
+
output: Schema.Struct({
|
|
42
|
+
object: Document,
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// TODO(wittjosiah): This appears to be unused.
|
|
48
|
+
export const SetViewMode = Operation.make({
|
|
49
|
+
meta: { key: `${MARKDOWN_OPERATION}/set-view-mode`, name: 'Set View Mode' },
|
|
50
|
+
services: [Capability.Service],
|
|
51
|
+
schema: {
|
|
52
|
+
input: Schema.Struct({
|
|
53
|
+
id: Schema.String,
|
|
54
|
+
viewMode: EditorViewMode,
|
|
55
|
+
}),
|
|
56
|
+
output: Schema.Void,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Atom } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
7
|
+
|
|
8
|
+
import { Capability } from '@dxos/app-framework';
|
|
9
|
+
import { type EditorStateStore, type EditorViewMode } from '@dxos/ui-editor';
|
|
10
|
+
|
|
11
|
+
import { meta } from '../meta';
|
|
12
|
+
|
|
13
|
+
import type * as Markdown from './Markdown';
|
|
14
|
+
import { type MarkdownExtensionProvider } from './types';
|
|
15
|
+
|
|
16
|
+
/** Schema for persisted markdown state. */
|
|
17
|
+
export const MarkdownStateSchema = Schema.mutable(
|
|
18
|
+
Schema.Struct({
|
|
19
|
+
viewMode: Schema.Record({ key: Schema.String, value: Schema.String }),
|
|
20
|
+
}),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export type MarkdownState = {
|
|
24
|
+
viewMode: Record<string, EditorViewMode>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export namespace MarkdownCapabilities {
|
|
28
|
+
export const Settings = Capability.make<Atom.Writable<Markdown.Settings>>(`${meta.id}/capability/settings`);
|
|
29
|
+
|
|
30
|
+
/** Persisted state atom for view mode per document. */
|
|
31
|
+
export const State = Capability.make<Atom.Writable<MarkdownState>>(`${meta.id}/capability/state`);
|
|
32
|
+
|
|
33
|
+
/** Editor state store for cursor positions, scroll state, etc. */
|
|
34
|
+
export const EditorState = Capability.make<EditorStateStore>(`${meta.id}/capability/editor-state`);
|
|
35
|
+
|
|
36
|
+
// TODO(burdon): Move to ./types (external API)?
|
|
37
|
+
export const Extensions = Capability.make<MarkdownExtensionProvider[]>(`${meta.id}/capability/extensions`);
|
|
38
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type ActivationEvent } from '@dxos/app-framework';
|
|
6
|
+
import { AppActivationEvents } from '@dxos/app-toolkit';
|
|
7
|
+
|
|
8
|
+
import { meta } from '../meta';
|
|
9
|
+
|
|
10
|
+
export namespace MarkdownEvents {
|
|
11
|
+
export const SetupExtensions: ActivationEvent.ActivationEvent = AppActivationEvents.createStateEvent(
|
|
12
|
+
`${meta.id}/event/setup-extensions`,
|
|
13
|
+
);
|
|
14
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -2,5 +2,10 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
export * from './
|
|
5
|
+
export * as MarkdownAction from './MarkdownAction';
|
|
6
|
+
export { MarkdownOperation } from './MarkdownAction';
|
|
7
|
+
export * as Markdown from './Markdown';
|
|
8
|
+
|
|
9
|
+
export * from './capabilities';
|
|
10
|
+
export * from './events';
|
|
6
11
|
export * from './types';
|
package/src/types/types.ts
CHANGED
|
@@ -2,44 +2,17 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { type Extension } from '@codemirror/state';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import { type Extension } from '@dxos/react-ui-editor';
|
|
9
|
-
import { EditorInputMode, EditorViewMode } from '@dxos/react-ui-editor/types';
|
|
7
|
+
import { type EditorViewMode } from '@dxos/ui-editor/types';
|
|
10
8
|
|
|
11
|
-
import {
|
|
12
|
-
import { MARKDOWN_PLUGIN } from '../meta';
|
|
9
|
+
import { type Document } from './Markdown';
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
// TODO(burdon): Remove these from ./types since not part of plugin-markdown API?
|
|
12
|
+
// TODO(wittjosiah): MarkdownExtensionProvider is a part of the MarkdownCapabilities api which should be in ./types.
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
input: Schema.Struct({
|
|
19
|
-
spaceId: Type.SpaceId,
|
|
20
|
-
name: Schema.optional(Schema.String),
|
|
21
|
-
content: Schema.optional(Schema.String),
|
|
22
|
-
}),
|
|
23
|
-
output: Schema.Struct({
|
|
24
|
-
object: DocumentType,
|
|
25
|
-
}),
|
|
26
|
-
}) {}
|
|
27
|
-
|
|
28
|
-
export class SetViewMode extends Schema.TaggedClass<SetViewMode>()(`${MARKDOWN_ACTION}/set-view-mode`, {
|
|
29
|
-
input: Schema.Struct({
|
|
30
|
-
id: Schema.String,
|
|
31
|
-
viewMode: EditorViewMode,
|
|
32
|
-
}),
|
|
33
|
-
output: Schema.Void,
|
|
34
|
-
}) {}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export type MarkdownProperties = Record<string, any>;
|
|
38
|
-
|
|
39
|
-
// TODO(burdon): Async.
|
|
40
|
-
export type MarkdownExtensionProvider = (props: { document?: DocumentType }) => Extension | undefined;
|
|
41
|
-
|
|
42
|
-
export type OnChange = (text: string) => void;
|
|
14
|
+
// TODO(burdon): Async?
|
|
15
|
+
export type MarkdownExtensionProvider = (props: { document?: Document }) => Extension | undefined;
|
|
43
16
|
|
|
44
17
|
export type MarkdownPluginState = {
|
|
45
18
|
// Codemirror extensions provided by other plugins.
|
|
@@ -49,19 +22,3 @@ export type MarkdownPluginState = {
|
|
|
49
22
|
// View mode per document.
|
|
50
23
|
viewMode: Record<string, EditorViewMode>;
|
|
51
24
|
};
|
|
52
|
-
|
|
53
|
-
export const MarkdownSettingsSchema = Schema.mutable(
|
|
54
|
-
Schema.Struct({
|
|
55
|
-
defaultViewMode: EditorViewMode,
|
|
56
|
-
editorInputMode: Schema.optional(EditorInputMode),
|
|
57
|
-
experimental: Schema.optional(Schema.Boolean),
|
|
58
|
-
debug: Schema.optional(Schema.Boolean),
|
|
59
|
-
toolbar: Schema.optional(Schema.Boolean),
|
|
60
|
-
typewriter: Schema.optional(Schema.String),
|
|
61
|
-
// TODO(burdon): Per document settings.
|
|
62
|
-
numberedHeadings: Schema.optional(Schema.Boolean),
|
|
63
|
-
folding: Schema.optional(Schema.Boolean),
|
|
64
|
-
}),
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
export type MarkdownSettingsProps = Schema.Schema.Type<typeof MarkdownSettingsSchema>;
|
package/src/util.test.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { trim } from '@dxos/util';
|
|
8
|
+
|
|
9
|
+
import { getFallbackName } from './util';
|
|
10
|
+
|
|
11
|
+
describe('markdown utils', () => {
|
|
12
|
+
it('getFallbackName', () => {
|
|
13
|
+
const tests = [
|
|
14
|
+
{
|
|
15
|
+
content: '',
|
|
16
|
+
expected: '',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
content: trim`
|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
# Welcome to Composer by DXOS
|
|
23
|
+
|
|
24
|
+
## What is Composer?
|
|
25
|
+
`,
|
|
26
|
+
expected: 'Welcome to Composer by DXOS',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
content: trim`
|
|
30
|
+

|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
This document is about the decetralized platform DXOS.
|
|
35
|
+
`,
|
|
36
|
+
expected: 'This document is about the…',
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
tests.forEach(({ content, expected }) => {
|
|
41
|
+
expect(getFallbackName(content)).toBe(expected);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
package/src/util.tsx
CHANGED
|
@@ -3,11 +3,25 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { debounce } from '@dxos/async';
|
|
6
|
-
import { Obj
|
|
6
|
+
import { Obj } from '@dxos/echo';
|
|
7
7
|
import { type TypedObjectSerializer } from '@dxos/plugin-space/types';
|
|
8
|
-
import { DataType } from '@dxos/schema';
|
|
9
8
|
|
|
10
|
-
import {
|
|
9
|
+
import { Markdown } from './types';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Checks if an object conforms to the interface needed to render an editor.
|
|
13
|
+
* @deprecated Use Schema.instanceOf(Markdown.Document, data)
|
|
14
|
+
*/
|
|
15
|
+
// TODO(burdon): Normalize types (from FilesPlugin).
|
|
16
|
+
export const isEditorModel = (data: any): data is { id: string; text: string } =>
|
|
17
|
+
data &&
|
|
18
|
+
typeof data === 'object' &&
|
|
19
|
+
'id' in data &&
|
|
20
|
+
typeof data.id === 'string' &&
|
|
21
|
+
'text' in data &&
|
|
22
|
+
typeof data.text === 'string';
|
|
23
|
+
|
|
24
|
+
export type MarkdownProperties = Record<string, any>;
|
|
11
25
|
|
|
12
26
|
export const isMarkdownProperties = (data: unknown): data is MarkdownProperties =>
|
|
13
27
|
(Obj.isObject(data) as boolean)
|
|
@@ -18,22 +32,97 @@ export const isMarkdownProperties = (data: unknown): data is MarkdownProperties
|
|
|
18
32
|
|
|
19
33
|
const nonTitleChars = /[^\w ]/g;
|
|
20
34
|
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
// Lines matching these patterns are skipped.
|
|
36
|
+
const skipPatterns = [
|
|
37
|
+
/^!\[/, // Image.
|
|
38
|
+
/^---\s*$/, // Horizontal rule.
|
|
39
|
+
/^```/, // Code block fence.
|
|
40
|
+
/^\s*$/, // Empty or whitespace-only.
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
// Patterns to extract title text (first capture group is used).
|
|
44
|
+
const titlePatterns = [
|
|
45
|
+
/^#{1,6}\s+(.+)/, // Heading.
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Extracts a fallback name by scanning lines for the first heading or text fragment.
|
|
50
|
+
*/
|
|
51
|
+
export const getFallbackName = (content = ''): string => {
|
|
52
|
+
const len = content.length;
|
|
53
|
+
|
|
54
|
+
let i = 0;
|
|
55
|
+
while (i < len) {
|
|
56
|
+
// Find end of line.
|
|
57
|
+
let lineEnd = i;
|
|
58
|
+
while (lineEnd < len && content[lineEnd] !== '\n') {
|
|
59
|
+
lineEnd++;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const line = content.slice(i, lineEnd).trim();
|
|
63
|
+
i = lineEnd + 1;
|
|
64
|
+
|
|
65
|
+
// Skip lines matching skip patterns.
|
|
66
|
+
if (skipPatterns.some((pattern) => pattern.test(line))) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Check for title patterns.
|
|
71
|
+
for (const pattern of titlePatterns) {
|
|
72
|
+
const match = pattern.exec(line);
|
|
73
|
+
if (match) {
|
|
74
|
+
const text = match[1].replaceAll(nonTitleChars, '').trim();
|
|
75
|
+
if (text.length > 0) {
|
|
76
|
+
return text;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Use line as plain text fallback.
|
|
82
|
+
const maxLen = 32;
|
|
83
|
+
const text = line.replaceAll(nonTitleChars, '').trim();
|
|
84
|
+
if (text.length > 0) {
|
|
85
|
+
if (text.length > maxLen) {
|
|
86
|
+
const words = text.split(/\s+/);
|
|
87
|
+
let result = '';
|
|
88
|
+
for (const word of words) {
|
|
89
|
+
const next = result.length === 0 ? word : result + ' ' + word;
|
|
90
|
+
if (next.length > maxLen) {
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
result = next;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return result + '…';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return text;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return '';
|
|
23
104
|
};
|
|
24
105
|
|
|
25
|
-
|
|
26
|
-
|
|
106
|
+
// TODO(burdon): Option to strip Markdown.
|
|
107
|
+
export const getContentSnippet = (content = '') => {
|
|
108
|
+
const abstract = content
|
|
109
|
+
.split('\n')
|
|
110
|
+
.filter((line) => !line.startsWith('!'))
|
|
111
|
+
.filter((line) => line.trim() !== '');
|
|
112
|
+
|
|
113
|
+
return abstract.slice(0, 3).join('\n') ?? '';
|
|
27
114
|
};
|
|
28
115
|
|
|
29
|
-
export const setFallbackName = debounce((doc:
|
|
116
|
+
export const setFallbackName = debounce((doc: Markdown.Document, content = '') => {
|
|
30
117
|
const name = getFallbackName(content);
|
|
31
118
|
if (doc.fallbackName !== name) {
|
|
32
|
-
doc
|
|
119
|
+
Obj.change(doc, (d) => {
|
|
120
|
+
d.fallbackName = name;
|
|
121
|
+
});
|
|
33
122
|
}
|
|
34
123
|
}, 200);
|
|
35
124
|
|
|
36
|
-
export const serializer: TypedObjectSerializer<
|
|
125
|
+
export const serializer: TypedObjectSerializer<Markdown.Document> = {
|
|
37
126
|
serialize: async ({ object }): Promise<string> => {
|
|
38
127
|
const { content } = await object.content.load();
|
|
39
128
|
return JSON.stringify({ name: object.name, fallbackName: object.fallbackName, content });
|
|
@@ -41,6 +130,6 @@ export const serializer: TypedObjectSerializer<DocumentType> = {
|
|
|
41
130
|
|
|
42
131
|
deserialize: async ({ content: serialized }) => {
|
|
43
132
|
const { name, fallbackName, content } = JSON.parse(serialized);
|
|
44
|
-
return
|
|
133
|
+
return Markdown.make({ name, fallbackName, content });
|
|
45
134
|
},
|
|
46
135
|
};
|