@dxos/plugin-markdown 0.8.4-main.bc674ce → 0.8.4-main.c351d160a8
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/{chunk-WIPSLZ6L.mjs → MarkdownCard-R6VVXOMN.mjs} +27 -26
- package/dist/lib/browser/MarkdownCard-R6VVXOMN.mjs.map +7 -0
- package/dist/lib/browser/{chunk-KDKXFKDN.mjs → MarkdownContainer-LSOAAG6R.mjs} +48 -25
- package/dist/lib/browser/MarkdownContainer-LSOAAG6R.mjs.map +7 -0
- package/dist/lib/browser/MarkdownSettings-OD7AJSSJ.mjs +106 -0
- package/dist/lib/browser/MarkdownSettings-OD7AJSSJ.mjs.map +7 -0
- package/dist/lib/browser/{anchor-sort-WQ3TL7ZI.mjs → anchor-sort-35SV33JX.mjs} +6 -4
- package/dist/lib/browser/anchor-sort-35SV33JX.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-serializer-ULZUJKOD.mjs → app-graph-serializer-RMUNNVUY.mjs} +9 -7
- package/dist/lib/browser/app-graph-serializer-RMUNNVUY.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-SFGTWLSY.mjs +18 -0
- package/dist/lib/browser/blueprint-definition-SFGTWLSY.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +5 -4
- package/dist/lib/browser/{chunk-LMO5UVKL.mjs → chunk-4CSOMIT4.mjs} +29 -61
- package/dist/lib/browser/chunk-4CSOMIT4.mjs.map +7 -0
- package/dist/lib/browser/chunk-646I24Q2.mjs +178 -0
- package/dist/lib/browser/chunk-646I24Q2.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BX73DASG.mjs → chunk-B6S4YQWZ.mjs} +285 -206
- package/dist/lib/browser/chunk-B6S4YQWZ.mjs.map +7 -0
- package/dist/lib/browser/chunk-RYZHVXZ5.mjs +28 -0
- package/dist/lib/browser/chunk-RYZHVXZ5.mjs.map +7 -0
- package/dist/lib/browser/{chunk-CUGDX7KA.mjs → chunk-WU3CQIPM.mjs} +2 -2
- package/dist/lib/browser/{chunk-JOXYQLKH.mjs → chunk-YKXQWJX6.mjs} +9 -4
- package/dist/lib/browser/chunk-YKXQWJX6.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +15 -13
- package/dist/lib/browser/cli/index.mjs.map +3 -3
- package/dist/lib/browser/index.mjs +49 -48
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{operation-resolver-EGCWOQKJ.mjs → operation-resolver-MVI2ZJ7M.mjs} +6 -18
- package/dist/lib/browser/operation-resolver-MVI2ZJ7M.mjs.map +7 -0
- package/dist/lib/browser/react-surface-OJYNFGZB.mjs +117 -0
- package/dist/lib/browser/react-surface-OJYNFGZB.mjs.map +7 -0
- package/dist/lib/browser/{settings-JY5JE7MI.mjs → settings-R722LDFD.mjs} +8 -5
- package/dist/lib/browser/settings-R722LDFD.mjs.map +7 -0
- package/dist/lib/browser/{state-QE7VSJWJ.mjs → state-MRJLGZW4.mjs} +7 -5
- package/dist/lib/{node-esm/state-LXE5XIN4.mjs.map → browser/state-MRJLGZW4.mjs.map} +2 -2
- package/dist/lib/browser/types/index.mjs +2 -1
- package/dist/lib/node-esm/{chunk-RQP7G7XW.mjs → MarkdownCard-EE3Q2JPL.mjs} +27 -26
- package/dist/lib/node-esm/MarkdownCard-EE3Q2JPL.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-3JYPCC7M.mjs → MarkdownContainer-NMFVVFBR.mjs} +48 -25
- package/dist/lib/node-esm/MarkdownContainer-NMFVVFBR.mjs.map +7 -0
- package/dist/lib/node-esm/MarkdownSettings-U7GJ4OP3.mjs +107 -0
- package/dist/lib/node-esm/MarkdownSettings-U7GJ4OP3.mjs.map +7 -0
- package/dist/lib/node-esm/{anchor-sort-G7D5TAI6.mjs → anchor-sort-QCV4U222.mjs} +6 -4
- package/dist/lib/node-esm/anchor-sort-QCV4U222.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-serializer-W5YMQP7P.mjs → app-graph-serializer-I27YTNDW.mjs} +9 -7
- package/dist/lib/node-esm/app-graph-serializer-I27YTNDW.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-VZEIBTAP.mjs +19 -0
- package/dist/lib/node-esm/blueprint-definition-VZEIBTAP.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +5 -4
- package/dist/lib/node-esm/{chunk-PRV35A7Z.mjs → chunk-2LVNBTQT.mjs} +29 -61
- package/dist/lib/node-esm/chunk-2LVNBTQT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CW4FZNMZ.mjs +29 -0
- package/dist/lib/node-esm/chunk-CW4FZNMZ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-W3IIKDV5.mjs → chunk-HVAZON2M.mjs} +2 -2
- package/dist/lib/node-esm/chunk-KHTJJ45U.mjs +179 -0
- package/dist/lib/node-esm/chunk-KHTJJ45U.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-44VJC3QF.mjs → chunk-TR2NZYXO.mjs} +9 -4
- package/dist/lib/node-esm/chunk-TR2NZYXO.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-D4BCFPKK.mjs → chunk-VG2PIENM.mjs} +285 -206
- package/dist/lib/node-esm/chunk-VG2PIENM.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +15 -13
- package/dist/lib/node-esm/cli/index.mjs.map +3 -3
- package/dist/lib/node-esm/index.mjs +49 -48
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{operation-resolver-2HIS2AQZ.mjs → operation-resolver-6TK6ARJ6.mjs} +6 -18
- package/dist/lib/node-esm/operation-resolver-6TK6ARJ6.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-UVNCUX77.mjs +118 -0
- package/dist/lib/node-esm/react-surface-UVNCUX77.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-4UGMPIRY.mjs → settings-RDYNOKVE.mjs} +8 -5
- package/dist/lib/node-esm/settings-RDYNOKVE.mjs.map +7 -0
- package/dist/lib/node-esm/{state-LXE5XIN4.mjs → state-7HQSNXXQ.mjs} +7 -5
- package/dist/lib/{browser/state-QE7VSJWJ.mjs.map → node-esm/state-7HQSNXXQ.mjs.map} +2 -2
- package/dist/lib/node-esm/types/index.mjs +2 -1
- package/dist/types/src/MarkdownPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/functions/create.d.ts.map +1 -1
- package/dist/types/src/blueprints/functions/index.d.ts +41 -3
- package/dist/types/src/blueprints/functions/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/functions/open.d.ts +8 -1
- package/dist/types/src/blueprints/functions/open.d.ts.map +1 -1
- package/dist/types/src/blueprints/functions/update.d.ts +16 -3
- package/dist/types/src/blueprints/functions/update.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +1 -1
- package/dist/types/src/blueprints/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/markdown-blueprint.d.ts +3 -20
- package/dist/types/src/blueprints/markdown-blueprint.d.ts.map +1 -1
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts +3 -2
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts.map +1 -1
- package/dist/types/src/capabilities/anchor-sort/index.d.ts +1 -1
- package/dist/types/src/capabilities/anchor-sort/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-serializer/app-graph-serializer.d.ts +2 -2
- package/dist/types/src/capabilities/app-graph-serializer/app-graph-serializer.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-serializer/index.d.ts +1 -1
- package/dist/types/src/capabilities/app-graph-serializer/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +1 -1
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +3 -7
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +1 -1
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings/index.d.ts +1 -1
- package/dist/types/src/capabilities/settings/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings/settings.d.ts +3 -2
- package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -1
- package/dist/types/src/capabilities/state/state.d.ts +1 -1
- package/dist/types/src/cli/plugin.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownEditor/FileUpload.d.ts +2 -2
- package/dist/types/src/components/MarkdownEditor/FileUpload.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownEditor/MarkdownEditor.d.ts +5 -3
- package/dist/types/src/components/MarkdownEditor/MarkdownEditor.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownEditor/MarkdownEditor.stories.d.ts +1 -1
- package/dist/types/src/components/MarkdownEditor/MarkdownEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownEditor/MarkdownEditorContent.d.ts +2 -0
- package/dist/types/src/components/MarkdownEditor/MarkdownEditorContent.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownEditor/MarkdownEditorToolbar.d.ts +5 -5
- package/dist/types/src/components/MarkdownEditor/MarkdownEditorToolbar.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -8
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/MarkdownCard/MarkdownCard.d.ts.map +1 -0
- package/dist/types/src/containers/MarkdownCard/MarkdownCard.stories.d.ts.map +1 -0
- package/dist/types/src/{components → containers}/MarkdownCard/index.d.ts +0 -1
- package/dist/types/src/containers/MarkdownCard/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/MarkdownContainer}/MarkdownContainer.d.ts +6 -6
- package/dist/types/src/containers/MarkdownContainer/MarkdownContainer.d.ts.map +1 -0
- package/dist/types/src/{components → containers/MarkdownContainer}/MarkdownContainer.stories.d.ts +31 -1
- 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/{components → containers}/MarkdownSettings/MarkdownSettings.d.ts.map +1 -1
- package/dist/types/src/containers/MarkdownSettings/index.d.ts +3 -0
- package/dist/types/src/containers/MarkdownSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +6 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useExtensions.d.ts +3 -3
- package/dist/types/src/hooks/useExtensions.d.ts.map +1 -1
- 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 +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +30 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Markdown.d.ts +1 -1
- package/dist/types/src/types/Markdown.d.ts.map +1 -1
- package/dist/types/src/types/MarkdownAction.d.ts +2 -22
- package/dist/types/src/types/MarkdownAction.d.ts.map +1 -1
- package/dist/types/src/types/events.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +1 -1
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +64 -57
- package/src/MarkdownPlugin.tsx +29 -38
- package/src/blueprints/functions/create.conversations.json +1 -1
- package/src/blueprints/functions/create.test.ts +24 -57
- package/src/blueprints/functions/create.ts +6 -5
- package/src/blueprints/functions/index.ts +11 -3
- package/src/blueprints/functions/open.ts +10 -10
- package/src/blueprints/functions/update.conversations.json +1 -1
- package/src/blueprints/functions/update.test.ts +133 -67
- package/src/blueprints/functions/update.ts +54 -13
- package/src/blueprints/index.ts +1 -1
- package/src/blueprints/markdown-blueprint.ts +14 -6
- package/src/capabilities/anchor-sort/anchor-sort.ts +3 -2
- package/src/capabilities/app-graph-serializer/app-graph-serializer.ts +5 -4
- package/src/capabilities/artifact-definition/artifact-definition.ts +2 -2
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +6 -14
- package/src/capabilities/operation-resolver/operation-resolver.ts +3 -14
- package/src/capabilities/react-surface/react-surface.tsx +30 -19
- package/src/capabilities/settings/settings.ts +3 -2
- package/src/capabilities/state/state.ts +2 -2
- package/src/cli/plugin.ts +5 -5
- package/src/components/MarkdownEditor/FileUpload.tsx +2 -2
- package/src/components/MarkdownEditor/MarkdownEditor.stories.tsx +25 -22
- package/src/components/MarkdownEditor/MarkdownEditor.tsx +44 -17
- package/src/components/MarkdownEditor/MarkdownEditorContent.tsx +6 -5
- package/src/components/MarkdownEditor/MarkdownEditorToolbar.tsx +13 -13
- package/src/components/index.ts +2 -14
- package/src/{components → containers}/MarkdownCard/MarkdownCard.stories.tsx +17 -7
- package/src/{components → containers}/MarkdownCard/MarkdownCard.tsx +21 -24
- package/src/{components → containers}/MarkdownCard/index.ts +0 -2
- package/src/{components → containers/MarkdownContainer}/MarkdownContainer.stories.tsx +22 -9
- package/src/{components → containers/MarkdownContainer}/MarkdownContainer.tsx +57 -34
- package/src/containers/MarkdownContainer/index.ts +6 -0
- package/src/{components → containers}/MarkdownSettings/MarkdownSettings.tsx +24 -24
- package/src/containers/MarkdownSettings/index.ts +7 -0
- package/src/containers/index.ts +11 -0
- package/src/hooks/useEditorMenuOptions.ts +1 -1
- package/src/hooks/useExtensions.tsx +52 -89
- package/src/hooks/useLinkQuery.ts +3 -3
- package/src/hooks/useSelectCurrentThread.tsx +6 -6
- package/src/index.ts +2 -0
- package/src/meta.ts +1 -1
- package/src/testing.ts +2 -2
- package/src/translations.ts +3 -0
- package/src/types/Markdown.ts +13 -5
- package/src/types/MarkdownAction.ts +3 -18
- package/src/types/capabilities.ts +4 -4
- package/src/types/events.ts +4 -3
- package/src/util.tsx +2 -2
- package/dist/lib/browser/MarkdownCard-WHK3ORP7.mjs +0 -12
- package/dist/lib/browser/MarkdownCard-WHK3ORP7.mjs.map +0 -7
- package/dist/lib/browser/MarkdownContainer-V7EAADMF.mjs +0 -12
- package/dist/lib/browser/MarkdownContainer-V7EAADMF.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-WQ3TL7ZI.mjs.map +0 -7
- package/dist/lib/browser/app-graph-serializer-ULZUJKOD.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-TLV4PNZW.mjs +0 -19
- package/dist/lib/browser/blueprint-definition-TLV4PNZW.mjs.map +0 -7
- package/dist/lib/browser/chunk-BX73DASG.mjs.map +0 -7
- package/dist/lib/browser/chunk-FWQQW6KU.mjs +0 -144
- package/dist/lib/browser/chunk-FWQQW6KU.mjs.map +0 -7
- package/dist/lib/browser/chunk-JOXYQLKH.mjs.map +0 -7
- package/dist/lib/browser/chunk-KDKXFKDN.mjs.map +0 -7
- package/dist/lib/browser/chunk-LMO5UVKL.mjs.map +0 -7
- package/dist/lib/browser/chunk-S45ULIOG.mjs +0 -101
- package/dist/lib/browser/chunk-S45ULIOG.mjs.map +0 -7
- package/dist/lib/browser/chunk-WIPSLZ6L.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-EGCWOQKJ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-SRPLD3ED.mjs +0 -213
- package/dist/lib/browser/react-surface-SRPLD3ED.mjs.map +0 -7
- package/dist/lib/browser/settings-JY5JE7MI.mjs.map +0 -7
- package/dist/lib/node-esm/MarkdownCard-WJPLQTFS.mjs +0 -13
- package/dist/lib/node-esm/MarkdownCard-WJPLQTFS.mjs.map +0 -7
- package/dist/lib/node-esm/MarkdownContainer-LUSMORP2.mjs +0 -13
- package/dist/lib/node-esm/MarkdownContainer-LUSMORP2.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-G7D5TAI6.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-serializer-W5YMQP7P.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-HYFA7BKQ.mjs +0 -20
- package/dist/lib/node-esm/blueprint-definition-HYFA7BKQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3JYPCC7M.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-44VJC3QF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-D4BCFPKK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EYAFC4N7.mjs +0 -145
- package/dist/lib/node-esm/chunk-EYAFC4N7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PRV35A7Z.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RQP7G7XW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SDTYEGGL.mjs +0 -102
- package/dist/lib/node-esm/chunk-SDTYEGGL.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-2HIS2AQZ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-RONSOJIQ.mjs +0 -214
- package/dist/lib/node-esm/react-surface-RONSOJIQ.mjs.map +0 -7
- package/dist/lib/node-esm/settings-4UGMPIRY.mjs.map +0 -7
- package/dist/types/src/components/MarkdownCard/MarkdownCard.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownCard/MarkdownCard.stories.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownCard/index.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownContainer.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownSettings/index.d.ts +0 -2
- package/dist/types/src/components/MarkdownSettings/index.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/src/components/MarkdownSettings/index.ts +0 -5
- package/src/components/Suggestions.stories.tsx +0 -215
- /package/dist/lib/browser/{chunk-CUGDX7KA.mjs.map → chunk-WU3CQIPM.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-W3IIKDV5.mjs.map → chunk-HVAZON2M.mjs.map} +0 -0
- /package/dist/types/src/{components → containers}/MarkdownCard/MarkdownCard.d.ts +0 -0
- /package/dist/types/src/{components → containers}/MarkdownCard/MarkdownCard.stories.d.ts +0 -0
- /package/dist/types/src/{components → containers}/MarkdownSettings/MarkdownSettings.d.ts +0 -0
|
@@ -6,59 +6,33 @@ import { describe, expect, it } from '@effect/vitest';
|
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
import * as Layer from 'effect/Layer';
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
AiConversation,
|
|
13
|
-
type ContextBinding,
|
|
14
|
-
GenerationObserver,
|
|
15
|
-
makeToolExecutionServiceFromFunctions,
|
|
16
|
-
makeToolResolverFromFunctions,
|
|
17
|
-
} from '@dxos/assistant';
|
|
9
|
+
import { MemoizedAiService } from '@dxos/ai/testing';
|
|
10
|
+
import { AiContextService, AiConversationService } from '@dxos/assistant';
|
|
11
|
+
import { AssistantTestLayer } from '@dxos/assistant/testing';
|
|
18
12
|
import { Blueprint } from '@dxos/blueprints';
|
|
19
13
|
import { SpaceProperties } from '@dxos/client-protocol';
|
|
20
|
-
import { Obj, Query, Ref } from '@dxos/echo';
|
|
21
|
-
import {
|
|
22
|
-
import { acquireReleaseResource } from '@dxos/effect';
|
|
14
|
+
import { Database, Obj, Query, Ref } from '@dxos/echo';
|
|
15
|
+
import { Collection } from '@dxos/echo';
|
|
23
16
|
import { TestHelpers } from '@dxos/effect/testing';
|
|
24
|
-
import {
|
|
25
|
-
import { FunctionInvocationServiceLayerTest, TestDatabaseLayer } from '@dxos/functions-runtime/testing';
|
|
17
|
+
import { FunctionInvocationService } from '@dxos/functions';
|
|
26
18
|
import { invariant } from '@dxos/invariant';
|
|
27
19
|
import { ObjectId } from '@dxos/keys';
|
|
28
20
|
import { Markdown } from '@dxos/plugin-markdown/types';
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
21
|
+
import { HasSubject } from '@dxos/types';
|
|
22
|
+
import { trim } from '@dxos/util';
|
|
31
23
|
|
|
32
|
-
import { WithProperties
|
|
33
|
-
import
|
|
24
|
+
import { WithProperties } from '../../testing';
|
|
25
|
+
import MarkdownBlueprint from '../markdown-blueprint';
|
|
34
26
|
|
|
35
27
|
import update from './update';
|
|
36
28
|
|
|
37
29
|
ObjectId.dangerouslyDisableRandomness();
|
|
38
30
|
|
|
39
|
-
const TestLayer =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
)
|
|
44
|
-
Layer.provideMerge(
|
|
45
|
-
FunctionInvocationServiceLayerTest({
|
|
46
|
-
functions: MarkdownBlueprint.functions,
|
|
47
|
-
}),
|
|
48
|
-
),
|
|
49
|
-
Layer.provideMerge(
|
|
50
|
-
Layer.mergeAll(
|
|
51
|
-
TestAiService(),
|
|
52
|
-
TestDatabaseLayer({
|
|
53
|
-
spaceKey: 'fixed',
|
|
54
|
-
indexing: { vector: true },
|
|
55
|
-
types: [SpaceProperties, Collection.Collection, Blueprint.Blueprint, Markdown.Document, HasSubject.HasSubject],
|
|
56
|
-
}),
|
|
57
|
-
CredentialsService.configuredLayer([]),
|
|
58
|
-
TracingService.layerNoop,
|
|
59
|
-
),
|
|
60
|
-
),
|
|
61
|
-
);
|
|
31
|
+
const TestLayer = AssistantTestLayer({
|
|
32
|
+
functions: [...MarkdownBlueprint.functions],
|
|
33
|
+
types: [SpaceProperties, Collection.Collection, Blueprint.Blueprint, Markdown.Document, HasSubject.HasSubject],
|
|
34
|
+
tracing: 'pretty',
|
|
35
|
+
});
|
|
62
36
|
|
|
63
37
|
describe('update', () => {
|
|
64
38
|
it.effect(
|
|
@@ -69,16 +43,16 @@ describe('update', () => {
|
|
|
69
43
|
name: 'BlueYard',
|
|
70
44
|
content: 'Founders and portfolio of BlueYard.',
|
|
71
45
|
});
|
|
72
|
-
yield* Database.
|
|
46
|
+
yield* Database.add(doc);
|
|
73
47
|
|
|
74
48
|
yield* FunctionInvocationService.invokeFunction(update, {
|
|
75
|
-
|
|
76
|
-
|
|
49
|
+
doc: Ref.make(doc),
|
|
50
|
+
edits: [{ oldString: 'Founders', newString: '# Founders' }],
|
|
77
51
|
});
|
|
78
52
|
|
|
79
|
-
const updatedDoc = yield* Database.
|
|
53
|
+
const updatedDoc = yield* Database.resolve(Obj.getDXN(doc), Markdown.Document);
|
|
80
54
|
expect(updatedDoc.name).toBe(doc.name);
|
|
81
|
-
const text = yield* Database.
|
|
55
|
+
const text = yield* Database.load(updatedDoc.content);
|
|
82
56
|
expect(text.content).toBe('# Founders and portfolio of BlueYard.');
|
|
83
57
|
},
|
|
84
58
|
WithProperties,
|
|
@@ -91,25 +65,16 @@ describe('update', () => {
|
|
|
91
65
|
'create and update a markdown document',
|
|
92
66
|
Effect.fnUntraced(
|
|
93
67
|
function* (_) {
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const markdownBlueprint = yield* Database.Service.add(Obj.clone(MarkdownBlueprint.make()));
|
|
99
|
-
yield* Effect.promise(() =>
|
|
100
|
-
conversation.context.bind({
|
|
101
|
-
blueprints: [Ref.make(markdownBlueprint)],
|
|
102
|
-
}),
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
const observer = GenerationObserver.fromPrinter(new ConsolePrinter());
|
|
68
|
+
const markdownBlueprint = yield* Database.add(Obj.clone(MarkdownBlueprint.make()));
|
|
69
|
+
yield* AiContextService.bindContext({
|
|
70
|
+
blueprints: [Ref.make(markdownBlueprint)],
|
|
71
|
+
});
|
|
106
72
|
|
|
107
|
-
yield*
|
|
108
|
-
observer,
|
|
73
|
+
yield* AiConversationService.run({
|
|
109
74
|
prompt: `Create a document with a cookie recipe.`,
|
|
110
75
|
});
|
|
111
76
|
{
|
|
112
|
-
const docs = yield* Database.
|
|
77
|
+
const docs = yield* Database.runQuery(Query.type(Markdown.Document));
|
|
113
78
|
if (docs.length !== 1) {
|
|
114
79
|
throw new Error(`Expected 1 document; got ${docs.length}: ${docs.map((_) => _.name)}`);
|
|
115
80
|
}
|
|
@@ -118,16 +83,15 @@ describe('update', () => {
|
|
|
118
83
|
invariant(Obj.instanceOf(Markdown.Document, doc));
|
|
119
84
|
console.log({
|
|
120
85
|
name: doc.name,
|
|
121
|
-
content: yield* Database.
|
|
86
|
+
content: yield* Database.load(doc.content).pipe(Effect.map((_) => _.content)),
|
|
122
87
|
});
|
|
123
88
|
}
|
|
124
89
|
|
|
125
|
-
yield*
|
|
126
|
-
observer,
|
|
90
|
+
yield* AiConversationService.run({
|
|
127
91
|
prompt: 'Add a section with a holiday-themed variation.',
|
|
128
92
|
});
|
|
129
93
|
{
|
|
130
|
-
const docs = yield* Database.
|
|
94
|
+
const docs = yield* Database.runQuery(Query.type(Markdown.Document));
|
|
131
95
|
if (docs.length !== 1) {
|
|
132
96
|
throw new Error(`Expected 1 document; got ${docs.length}: ${docs.map((_) => _.name)}`);
|
|
133
97
|
}
|
|
@@ -136,12 +100,114 @@ describe('update', () => {
|
|
|
136
100
|
invariant(Obj.instanceOf(Markdown.Document, doc));
|
|
137
101
|
console.log({
|
|
138
102
|
name: doc.name,
|
|
139
|
-
content: yield* Database.
|
|
103
|
+
content: yield* Database.load(doc.content).pipe(Effect.map((_) => _.content)),
|
|
140
104
|
});
|
|
141
105
|
}
|
|
142
106
|
},
|
|
143
107
|
WithProperties,
|
|
144
|
-
Effect.provide(TestLayer),
|
|
108
|
+
Effect.provide(AiConversationService.layerNewQueue().pipe(Layer.provideMerge(TestLayer))),
|
|
109
|
+
TestHelpers.provideTestContext,
|
|
110
|
+
),
|
|
111
|
+
MemoizedAiService.isGenerationEnabled() ? 240_000 : 30_000,
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
it.scoped(
|
|
115
|
+
'update existing document',
|
|
116
|
+
Effect.fnUntraced(
|
|
117
|
+
function* (_) {
|
|
118
|
+
const document = yield* Database.add(
|
|
119
|
+
Markdown.make({
|
|
120
|
+
name: 'Cookie Recipe',
|
|
121
|
+
content: trim`
|
|
122
|
+
Ingredients:
|
|
123
|
+
- 2 cups of ???
|
|
124
|
+
- 1 cup of sugar
|
|
125
|
+
- 1 cup of butter
|
|
126
|
+
- 1 cup of eggs
|
|
127
|
+
`,
|
|
128
|
+
}),
|
|
129
|
+
);
|
|
130
|
+
const markdownBlueprint = yield* Database.add(Obj.clone(MarkdownBlueprint.make()));
|
|
131
|
+
yield* AiContextService.bindContext({
|
|
132
|
+
blueprints: [Ref.make(markdownBlueprint)],
|
|
133
|
+
objects: [Ref.make(document)],
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
yield* AiConversationService.run({
|
|
137
|
+
prompt: 'Add the missing ingredient (its flour).',
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
{
|
|
141
|
+
const docs = yield* Database.runQuery(Query.type(Markdown.Document));
|
|
142
|
+
if (docs.length !== 1) {
|
|
143
|
+
throw new Error(`Expected 1 document; got ${docs.length}: ${docs.map((_) => _.name)}`);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const doc = docs[0];
|
|
147
|
+
invariant(Obj.instanceOf(Markdown.Document, doc));
|
|
148
|
+
const content = yield* Database.load(doc.content).pipe(Effect.map((_) => _.content));
|
|
149
|
+
console.log({
|
|
150
|
+
name: doc.name,
|
|
151
|
+
content: yield* Database.load(doc.content).pipe(Effect.map((_) => _.content)),
|
|
152
|
+
});
|
|
153
|
+
expect(content.toLowerCase()).toContain('flour');
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
WithProperties,
|
|
157
|
+
Effect.provide(AiConversationService.layerNewQueue().pipe(Layer.provideMerge(TestLayer))),
|
|
158
|
+
TestHelpers.provideTestContext,
|
|
159
|
+
),
|
|
160
|
+
MemoizedAiService.isGenerationEnabled() ? 240_000 : 30_000,
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
it.scoped(
|
|
164
|
+
'add lines to document one by one',
|
|
165
|
+
Effect.fnUntraced(
|
|
166
|
+
function* (_) {
|
|
167
|
+
const document = yield* Database.add(
|
|
168
|
+
Markdown.make({
|
|
169
|
+
name: 'Shopping list',
|
|
170
|
+
content: trim`
|
|
171
|
+
# Shopping list
|
|
172
|
+
`,
|
|
173
|
+
}),
|
|
174
|
+
);
|
|
175
|
+
const markdownBlueprint = yield* Database.add(Obj.clone(MarkdownBlueprint.make()));
|
|
176
|
+
yield* AiContextService.bindContext({
|
|
177
|
+
blueprints: [Ref.make(markdownBlueprint)],
|
|
178
|
+
objects: [Ref.make(document)],
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
yield* AiConversationService.run({
|
|
182
|
+
prompt: 'Add milk to the shopping list.',
|
|
183
|
+
});
|
|
184
|
+
yield* AiConversationService.run({
|
|
185
|
+
prompt: 'Add bread to the shopping list.',
|
|
186
|
+
});
|
|
187
|
+
yield* AiConversationService.run({
|
|
188
|
+
prompt: 'Add eggs to the shopping list.',
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
{
|
|
192
|
+
const docs = yield* Database.runQuery(Query.type(Markdown.Document));
|
|
193
|
+
if (docs.length !== 1) {
|
|
194
|
+
throw new Error(`Expected 1 document; got ${docs.length}: ${docs.map((_) => _.name)}`);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const doc = docs[0];
|
|
198
|
+
invariant(Obj.instanceOf(Markdown.Document, doc));
|
|
199
|
+
const content = yield* Database.load(doc.content).pipe(Effect.map((_) => _.content));
|
|
200
|
+
console.log({
|
|
201
|
+
name: doc.name,
|
|
202
|
+
content: yield* Database.load(doc.content).pipe(Effect.map((_) => _.content)),
|
|
203
|
+
});
|
|
204
|
+
expect(content.toLowerCase()).toContain('milk');
|
|
205
|
+
expect(content.toLowerCase()).toContain('bread');
|
|
206
|
+
expect(content.toLowerCase()).toContain('eggs');
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
WithProperties,
|
|
210
|
+
Effect.provide(AiConversationService.layerNewQueue().pipe(Layer.provideMerge(TestLayer))),
|
|
145
211
|
TestHelpers.provideTestContext,
|
|
146
212
|
),
|
|
147
213
|
MemoizedAiService.isGenerationEnabled() ? 240_000 : 30_000,
|
|
@@ -2,37 +2,78 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { next as A, type Doc } from '@automerge/automerge';
|
|
5
6
|
import * as Effect from 'effect/Effect';
|
|
6
7
|
import * as Schema from 'effect/Schema';
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { createDocAccessor } from '@dxos/echo-db';
|
|
9
|
+
import { Database, Ref } from '@dxos/echo';
|
|
10
|
+
import { DocAccessor, createDocAccessor } from '@dxos/echo-db';
|
|
11
11
|
import { defineFunction } from '@dxos/functions';
|
|
12
12
|
import { trim } from '@dxos/util';
|
|
13
13
|
|
|
14
14
|
import { Markdown } from '../../types';
|
|
15
15
|
|
|
16
|
+
const Edit = Schema.Struct({
|
|
17
|
+
oldString: Schema.String.annotations({
|
|
18
|
+
description: 'The text to find in the document.',
|
|
19
|
+
}),
|
|
20
|
+
newString: Schema.String.annotations({
|
|
21
|
+
description: 'The text to replace it with.',
|
|
22
|
+
}),
|
|
23
|
+
replaceAll: Schema.optional(Schema.Boolean).annotations({
|
|
24
|
+
description: 'If true, replaces all occurrences. Defaults to false (first occurrence only).',
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
|
|
16
28
|
// TODO(wittjosiah): Reconcile with ThreadAction.AddProposal.
|
|
29
|
+
// Based on opencode's MutilEdit tool: https://deepwiki.com/search/how-does-text-edit-tool-work_a159bc76-5401-424e-b29f-f087d1ea4f78
|
|
17
30
|
export default defineFunction({
|
|
18
|
-
key: 'dxos.
|
|
31
|
+
key: 'org.dxos.function.markdown.update',
|
|
19
32
|
name: 'Update',
|
|
20
33
|
description: trim`
|
|
21
|
-
Applies a set of
|
|
34
|
+
Applies a set of edits to the markdown document.
|
|
22
35
|
`,
|
|
23
36
|
inputSchema: Schema.Struct({
|
|
24
|
-
|
|
37
|
+
doc: Ref.Ref(Markdown.Document).annotations({
|
|
25
38
|
description: 'The ID of the markdown document.',
|
|
26
39
|
}),
|
|
27
|
-
|
|
28
|
-
description: 'The
|
|
40
|
+
edits: Schema.Array(Edit).annotations({
|
|
41
|
+
description: 'The edits to apply to the document. Each edit finds oldString and replaces it with newString.',
|
|
29
42
|
}),
|
|
30
43
|
}),
|
|
31
|
-
outputSchema: Schema.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
44
|
+
outputSchema: Schema.Struct({
|
|
45
|
+
newContent: Schema.String,
|
|
46
|
+
}),
|
|
47
|
+
handler: Effect.fn(function* ({ data: { doc, edits } }) {
|
|
48
|
+
const content = yield* doc.pipe(
|
|
49
|
+
Database.load,
|
|
50
|
+
Effect.map((_) => _.content),
|
|
51
|
+
Effect.flatMap(Database.load),
|
|
52
|
+
);
|
|
35
53
|
const accessor = createDocAccessor(content, ['content']);
|
|
36
|
-
|
|
54
|
+
|
|
55
|
+
for (const edit of edits) {
|
|
56
|
+
accessor.handle.change((doc: Doc<typeof content>) => {
|
|
57
|
+
const text = DocAccessor.getValue<string>(accessor);
|
|
58
|
+
if (edit.replaceAll) {
|
|
59
|
+
let idx = text.indexOf(edit.oldString);
|
|
60
|
+
while (idx !== -1) {
|
|
61
|
+
A.splice(doc, accessor.path as A.Prop[], idx, edit.oldString.length, edit.newString);
|
|
62
|
+
const updated = DocAccessor.getValue<string>(accessor);
|
|
63
|
+
idx = updated.indexOf(edit.oldString, idx + edit.newString.length);
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
const idx = text.indexOf(edit.oldString);
|
|
67
|
+
if (idx === -1) {
|
|
68
|
+
throw new Error(`Edit not found: ${JSON.stringify(edit.oldString)}`);
|
|
69
|
+
}
|
|
70
|
+
A.splice(doc, accessor.path as A.Prop[], idx, edit.oldString.length, edit.newString);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
newContent: DocAccessor.getValue<string>(accessor),
|
|
77
|
+
};
|
|
37
78
|
}),
|
|
38
79
|
});
|
package/src/blueprints/index.ts
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { type AppCapabilities } from '@dxos/app-toolkit';
|
|
5
6
|
import { Blueprint, Template } from '@dxos/blueprints';
|
|
6
|
-
import { type FunctionDefinition } from '@dxos/functions';
|
|
7
7
|
import { trim } from '@dxos/util';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { MarkdownFunctions } from './functions';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const BLUEPRINT_KEY = 'org.dxos.blueprint.markdown';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
const functions = Object.values(MarkdownFunctions);
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const make = () =>
|
|
16
16
|
Blueprint.make({
|
|
17
|
-
key:
|
|
17
|
+
key: BLUEPRINT_KEY,
|
|
18
18
|
name: 'Markdown',
|
|
19
19
|
tools: Blueprint.toolDefinitions({ functions }),
|
|
20
20
|
instructions: Template.make({
|
|
@@ -36,3 +36,11 @@ export const make = () =>
|
|
|
36
36
|
`,
|
|
37
37
|
}),
|
|
38
38
|
});
|
|
39
|
+
|
|
40
|
+
const blueprint: AppCapabilities.BlueprintDefinition = {
|
|
41
|
+
key: BLUEPRINT_KEY,
|
|
42
|
+
functions,
|
|
43
|
+
make,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default blueprint;
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
|
-
import { Capability
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
8
9
|
import { Relation } from '@dxos/echo';
|
|
9
10
|
import { createDocAccessor, getRangeFromCursor } from '@dxos/echo-db';
|
|
10
11
|
import { type AnchoredTo } from '@dxos/types';
|
|
@@ -13,7 +14,7 @@ import { Markdown } from '../../types';
|
|
|
13
14
|
|
|
14
15
|
export default Capability.makeModule(() =>
|
|
15
16
|
Effect.succeed(
|
|
16
|
-
Capability.contributes(
|
|
17
|
+
Capability.contributes(AppCapabilities.AnchorSort, {
|
|
17
18
|
key: Markdown.Document.typename,
|
|
18
19
|
sort: (anchorA: AnchoredTo.AnchoredTo, anchorB: AnchoredTo.AnchoredTo) => {
|
|
19
20
|
const doc = Relation.getTarget(anchorA) as Markdown.Document;
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
8
9
|
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { Collection } from '@dxos/echo';
|
|
9
11
|
import { SpaceOperation } from '@dxos/plugin-space/types';
|
|
10
12
|
import { isSpace } from '@dxos/react-client/echo';
|
|
11
|
-
import { Collection } from '@dxos/schema';
|
|
12
13
|
|
|
13
14
|
import { translations } from '../../translations';
|
|
14
15
|
import { Markdown, MarkdownOperation } from '../../types';
|
|
@@ -18,7 +19,7 @@ export default Capability.makeModule(
|
|
|
18
19
|
// Get context for lazy capability access in callbacks.
|
|
19
20
|
const capabilities = yield* Capability.Service;
|
|
20
21
|
|
|
21
|
-
return Capability.contributes(
|
|
22
|
+
return Capability.contributes(AppCapabilities.AppGraphSerializer, [
|
|
22
23
|
{
|
|
23
24
|
inputType: Markdown.Document.typename,
|
|
24
25
|
outputType: 'text/markdown',
|
|
@@ -44,7 +45,7 @@ export default Capability.makeModule(
|
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
const { invokePromise } = capabilities.get(
|
|
48
|
+
const { invokePromise } = capabilities.get(Capabilities.OperationInvoker);
|
|
48
49
|
const createResult = await invokePromise(MarkdownOperation.Create, { name: data.name, content: data.data });
|
|
49
50
|
if (!createResult.data?.object) {
|
|
50
51
|
return undefined;
|
|
@@ -9,7 +9,7 @@ import * as Effect from 'effect/Effect';
|
|
|
9
9
|
import * as Schema from 'effect/Schema';
|
|
10
10
|
|
|
11
11
|
import { ToolResult, createTool } from '@dxos/ai';
|
|
12
|
-
import {
|
|
12
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
13
13
|
import { ArtifactId, createArtifactElement } from '@dxos/assistant';
|
|
14
14
|
import { defineArtifact } from '@dxos/blueprints';
|
|
15
15
|
import { Obj } from '@dxos/echo';
|
|
@@ -105,6 +105,6 @@ export default Capability.makeModule(() =>
|
|
|
105
105
|
],
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
return Capability.contributes(
|
|
108
|
+
return Capability.contributes(Capabilities.ArtifactDefinition, definition);
|
|
109
109
|
}),
|
|
110
110
|
);
|
|
@@ -4,22 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
|
-
import { Capability
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
8
9
|
|
|
9
10
|
import { MarkdownBlueprint } from '../../blueprints';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Capability.Capability<typeof Common.Capability.BlueprintDefinition>,
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
const blueprintDefinition = Capability.makeModule<[], BlueprintCapabilities>(() =>
|
|
19
|
-
Effect.succeed([
|
|
20
|
-
Capability.contributes(Common.Capability.Functions, functions),
|
|
21
|
-
Capability.contributes(Common.Capability.BlueprintDefinition, MarkdownBlueprint.make()),
|
|
22
|
-
]),
|
|
23
|
-
);
|
|
12
|
+
const blueprintDefinition = Capability.makeModule<
|
|
13
|
+
[],
|
|
14
|
+
Capability.Capability<typeof AppCapabilities.BlueprintDefinition>[]
|
|
15
|
+
>(() => Effect.succeed([Capability.contributes(AppCapabilities.BlueprintDefinition, MarkdownBlueprint)]));
|
|
24
16
|
|
|
25
17
|
export default blueprintDefinition;
|
|
@@ -4,25 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import { Obj, Ref, Type } from '@dxos/echo';
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
8
|
import { OperationResolver } from '@dxos/operation';
|
|
10
|
-
import { Collection } from '@dxos/schema';
|
|
11
9
|
|
|
12
10
|
import { Markdown, MarkdownCapabilities, MarkdownOperation } from '../../types';
|
|
13
11
|
|
|
14
12
|
export default Capability.makeModule(
|
|
15
13
|
Effect.fnUntraced(function* () {
|
|
16
|
-
return Capability.contributes(
|
|
17
|
-
OperationResolver.make({
|
|
18
|
-
operation: MarkdownOperation.OnCreateSpace,
|
|
19
|
-
handler: Effect.fnUntraced(function* ({ rootCollection }) {
|
|
20
|
-
const collection = Collection.makeManaged({ key: Type.getTypename(Markdown.Document) });
|
|
21
|
-
Obj.change(rootCollection, (c) => {
|
|
22
|
-
c.objects.push(Ref.make(collection));
|
|
23
|
-
});
|
|
24
|
-
}),
|
|
25
|
-
}),
|
|
14
|
+
return Capability.contributes(Capabilities.OperationResolver, [
|
|
26
15
|
OperationResolver.make({
|
|
27
16
|
operation: MarkdownOperation.Create,
|
|
28
17
|
handler: ({ name, content }) =>
|
|
@@ -34,7 +23,7 @@ export default Capability.makeModule(
|
|
|
34
23
|
OperationResolver.make({
|
|
35
24
|
operation: MarkdownOperation.SetViewMode,
|
|
36
25
|
handler: Effect.fnUntraced(function* ({ id, viewMode }) {
|
|
37
|
-
yield*
|
|
26
|
+
yield* Capabilities.updateAtomValue(MarkdownCapabilities.State, (current) => ({
|
|
38
27
|
...current,
|
|
39
28
|
viewMode: { ...current.viewMode, [id]: viewMode },
|
|
40
29
|
}));
|
|
@@ -5,37 +5,47 @@
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
import React, { forwardRef, useCallback, useMemo } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
9
|
import {
|
|
10
|
-
|
|
10
|
+
Surface,
|
|
11
11
|
useAtomCapability,
|
|
12
12
|
useAtomCapabilityState,
|
|
13
13
|
useCapability,
|
|
14
14
|
useSettingsState,
|
|
15
|
-
} from '@dxos/app-framework/
|
|
15
|
+
} from '@dxos/app-framework/ui';
|
|
16
|
+
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
17
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
16
18
|
import { Obj } from '@dxos/echo';
|
|
17
19
|
import { AttentionCapabilities } from '@dxos/plugin-attention';
|
|
18
20
|
import { Text } from '@dxos/schema';
|
|
19
21
|
import { type EditorViewMode } from '@dxos/ui-editor';
|
|
20
22
|
|
|
21
|
-
import { MarkdownCard, MarkdownContainer, type MarkdownContainerProps, MarkdownSettings } from '../../
|
|
23
|
+
import { MarkdownCard, MarkdownContainer, type MarkdownContainerProps, MarkdownSettings } from '../../containers';
|
|
22
24
|
import { meta } from '../../meta';
|
|
23
25
|
import { Markdown, MarkdownCapabilities } from '../../types';
|
|
24
26
|
|
|
25
27
|
export default Capability.makeModule(() =>
|
|
26
28
|
Effect.succeed(
|
|
27
|
-
Capability.contributes(
|
|
28
|
-
|
|
29
|
-
id: `${meta.id}
|
|
29
|
+
Capability.contributes(Capabilities.ReactSurface, [
|
|
30
|
+
Surface.create({
|
|
31
|
+
id: `${meta.id}.surface.document`,
|
|
30
32
|
role: ['article', 'section', 'tabpanel'],
|
|
31
|
-
filter: (data): data is { subject: Markdown.Document; variant: undefined } =>
|
|
32
|
-
Obj.instanceOf(Markdown.Document, data.subject) && !data.variant,
|
|
33
|
+
filter: (data): data is { attendableId: string; subject: Markdown.Document; variant: undefined } =>
|
|
34
|
+
typeof data.attendableId === 'string' && Obj.instanceOf(Markdown.Document, data.subject) && !data.variant,
|
|
33
35
|
component: ({ data, role, ref }) => {
|
|
34
|
-
return
|
|
36
|
+
return (
|
|
37
|
+
<Container
|
|
38
|
+
id={Obj.getDXN(data.subject).toString()}
|
|
39
|
+
attendableId={data.attendableId}
|
|
40
|
+
subject={data.subject}
|
|
41
|
+
role={role}
|
|
42
|
+
ref={ref}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
35
45
|
},
|
|
36
46
|
}),
|
|
37
|
-
|
|
38
|
-
id: `${meta.id}
|
|
47
|
+
Surface.create({
|
|
48
|
+
id: `${meta.id}.surface.text`,
|
|
39
49
|
role: ['article', 'section', 'tabpanel'],
|
|
40
50
|
filter: (data): data is { id: string; subject: Text.Text } =>
|
|
41
51
|
typeof data.id === 'string' && Obj.instanceOf(Text.Text, data.subject),
|
|
@@ -43,18 +53,18 @@ export default Capability.makeModule(() =>
|
|
|
43
53
|
return <Container id={data.id} subject={data.subject} role={role} />;
|
|
44
54
|
},
|
|
45
55
|
}),
|
|
46
|
-
|
|
47
|
-
id: `${meta.id}
|
|
56
|
+
Surface.create({
|
|
57
|
+
id: `${meta.id}.surface.plugin-settings`,
|
|
48
58
|
role: 'article',
|
|
49
|
-
filter: (data): data is { subject:
|
|
50
|
-
|
|
59
|
+
filter: (data): data is { subject: AppCapabilities.Settings } =>
|
|
60
|
+
AppCapabilities.isSettings(data.subject) && data.subject.prefix === meta.id,
|
|
51
61
|
component: ({ data: { subject } }) => {
|
|
52
62
|
const { settings, updateSettings } = useSettingsState<Markdown.Settings>(subject.atom);
|
|
53
63
|
return <MarkdownSettings settings={settings} onSettingsChange={updateSettings} />;
|
|
54
64
|
},
|
|
55
65
|
}),
|
|
56
|
-
|
|
57
|
-
id: `${meta.id}
|
|
66
|
+
Surface.create({
|
|
67
|
+
id: `${meta.id}.surface.preview`,
|
|
58
68
|
role: 'card--content',
|
|
59
69
|
filter: (data): data is { subject: Markdown.Document | Text.Text } =>
|
|
60
70
|
Obj.instanceOf(Markdown.Document, data.subject) || Obj.instanceOf(Text.Text, data.subject),
|
|
@@ -68,7 +78,7 @@ export default Capability.makeModule(() =>
|
|
|
68
78
|
* Common wrapper.
|
|
69
79
|
*/
|
|
70
80
|
const Container = forwardRef<HTMLDivElement, SurfaceComponentProps<Markdown.Document | Text.Text, { id: string }>>(
|
|
71
|
-
({ id, subject, role }, forwardedRef) => {
|
|
81
|
+
({ id, attendableId, subject, role }, forwardedRef) => {
|
|
72
82
|
const selectionManager = useCapability(AttentionCapabilities.Selection);
|
|
73
83
|
const settings = useAtomCapability(MarkdownCapabilities.Settings);
|
|
74
84
|
const [state, setState] = useAtomCapabilityState(MarkdownCapabilities.State);
|
|
@@ -87,6 +97,7 @@ const Container = forwardRef<HTMLDivElement, SurfaceComponentProps<Markdown.Docu
|
|
|
87
97
|
role={role}
|
|
88
98
|
subject={subject}
|
|
89
99
|
id={id}
|
|
100
|
+
attendableId={attendableId}
|
|
90
101
|
settings={settings}
|
|
91
102
|
selectionManager={selectionManager}
|
|
92
103
|
extensionProviders={extensionProviders}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
|
-
import { Capability
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
8
9
|
import { createKvsStore } from '@dxos/effect';
|
|
9
10
|
|
|
10
11
|
import { meta } from '../../meta';
|
|
@@ -26,7 +27,7 @@ export default Capability.makeModule(() =>
|
|
|
26
27
|
|
|
27
28
|
return [
|
|
28
29
|
Capability.contributes(MarkdownCapabilities.Settings, settingsAtom),
|
|
29
|
-
Capability.contributes(
|
|
30
|
+
Capability.contributes(AppCapabilities.Settings, {
|
|
30
31
|
prefix: meta.id,
|
|
31
32
|
schema: Markdown.Settings,
|
|
32
33
|
atom: settingsAtom,
|