@dxos/plugin-markdown 0.8.4-main.2e9d522 → 0.8.4-main.5ea62a8
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/{MarkdownPreview-S3C7CGAV.mjs → MarkdownCard-JLUQITYK.mjs} +16 -16
- package/dist/lib/browser/MarkdownCard-JLUQITYK.mjs.map +7 -0
- package/dist/lib/browser/{MarkdownContainer-F3WEEIBX.mjs → MarkdownContainer-7M37DXAD.mjs} +263 -260
- package/dist/lib/browser/MarkdownContainer-7M37DXAD.mjs.map +7 -0
- package/dist/lib/browser/{anchor-sort-UKJJ7ZNP.mjs → anchor-sort-E33BSTYF.mjs} +5 -5
- package/dist/lib/browser/anchor-sort-E33BSTYF.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-serializer-ICLAF662.mjs → app-graph-serializer-OX62DNPT.mjs} +10 -11
- package/dist/lib/browser/app-graph-serializer-OX62DNPT.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-Z3RQGWUD.mjs +11 -0
- package/dist/lib/browser/blueprint-definition-Z3RQGWUD.mjs.map +7 -0
- package/dist/lib/browser/chunk-BEE7VQPU.mjs +78 -0
- package/dist/lib/browser/chunk-BEE7VQPU.mjs.map +7 -0
- package/dist/lib/browser/chunk-D7UYVHL6.mjs +20 -0
- package/dist/lib/browser/{chunk-PHTD5DTR.mjs.map → chunk-D7UYVHL6.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-LFML7LC6.mjs → chunk-LAVZ2W6X.mjs} +8 -9
- package/dist/lib/browser/chunk-LAVZ2W6X.mjs.map +7 -0
- package/dist/lib/browser/chunk-ODB2PTBP.mjs +28 -0
- package/dist/lib/browser/chunk-ODB2PTBP.mjs.map +7 -0
- package/dist/lib/browser/chunk-OY6CGPOO.mjs +16 -0
- package/dist/lib/browser/chunk-OY6CGPOO.mjs.map +7 -0
- package/dist/lib/browser/{chunk-LHDCHDBW.mjs → chunk-Z7P6JGGW.mjs} +6 -5
- package/dist/lib/browser/chunk-Z7P6JGGW.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZVVKLB5L.mjs +121 -0
- package/dist/lib/browser/chunk-ZVVKLB5L.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +26 -20
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/intent-resolver-WDDH56JC.mjs +62 -0
- package/dist/lib/browser/intent-resolver-WDDH56JC.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-C3Z423TV.mjs → react-surface-LN2XK2UN.mjs} +53 -44
- package/dist/lib/browser/react-surface-LN2XK2UN.mjs.map +7 -0
- package/dist/lib/browser/{settings-KN75ZQY6.mjs → settings-AABBTB4Q.mjs} +5 -5
- package/dist/lib/browser/settings-AABBTB4Q.mjs.map +7 -0
- package/dist/lib/browser/{state-LZWTAS65.mjs → state-FTHQQX7V.mjs} +7 -7
- package/dist/lib/browser/state-FTHQQX7V.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +6 -14
- package/dist/lib/node-esm/{MarkdownPreview-77UFEWXT.mjs → MarkdownCard-XL5EVSJ7.mjs} +16 -16
- package/dist/lib/node-esm/MarkdownCard-XL5EVSJ7.mjs.map +7 -0
- package/dist/lib/node-esm/{MarkdownContainer-VOUHL6IU.mjs → MarkdownContainer-K3BPAGWO.mjs} +263 -260
- package/dist/lib/node-esm/MarkdownContainer-K3BPAGWO.mjs.map +7 -0
- package/dist/lib/node-esm/{anchor-sort-IPIS5D5B.mjs → anchor-sort-ALP2NH24.mjs} +5 -5
- package/dist/lib/node-esm/anchor-sort-ALP2NH24.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-serializer-FLBXQKKR.mjs → app-graph-serializer-56TD3BMX.mjs} +10 -11
- package/dist/lib/node-esm/app-graph-serializer-56TD3BMX.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-735OAX33.mjs +12 -0
- package/dist/lib/node-esm/blueprint-definition-735OAX33.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ACFGXH2K.mjs → chunk-CB2R4YIY.mjs} +5 -5
- package/dist/lib/node-esm/chunk-CB2R4YIY.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-FXILAQ5F.mjs +79 -0
- package/dist/lib/node-esm/chunk-FXILAQ5F.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-VIR2ABYE.mjs → chunk-J7A6TUB2.mjs} +6 -5
- package/dist/lib/node-esm/chunk-J7A6TUB2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-JPXFCBC4.mjs +22 -0
- package/dist/lib/node-esm/{chunk-7X6TPTJK.mjs.map → chunk-JPXFCBC4.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-CWTFQSN7.mjs → chunk-O6EXWGGS.mjs} +8 -9
- package/dist/lib/node-esm/chunk-O6EXWGGS.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VCG2U522.mjs +29 -0
- package/dist/lib/node-esm/chunk-VCG2U522.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Y422WR6A.mjs +122 -0
- package/dist/lib/node-esm/chunk-Y422WR6A.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +26 -20
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/intent-resolver-2I5HKCUU.mjs +63 -0
- package/dist/lib/node-esm/intent-resolver-2I5HKCUU.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-TTTBYNI2.mjs → react-surface-DJGGKYBD.mjs} +53 -44
- package/dist/lib/node-esm/react-surface-DJGGKYBD.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-KVP7TVX7.mjs → settings-CXGR6DH4.mjs} +5 -5
- package/dist/lib/node-esm/settings-CXGR6DH4.mjs.map +7 -0
- package/dist/lib/node-esm/{state-NW3W4JCQ.mjs → state-NWMQ3XAI.mjs} +7 -7
- package/dist/lib/node-esm/state-NWMQ3XAI.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +6 -14
- package/dist/types/src/MarkdownPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/anchor-sort.d.ts +2 -2
- package/dist/types/src/capabilities/app-graph-serializer.d.ts +1 -1
- package/dist/types/src/capabilities/app-graph-serializer.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts +1 -9
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +11 -10
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +1 -1
- package/dist/types/src/capabilities/state.d.ts +2 -2
- package/dist/types/src/capabilities/state.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownCard/MarkdownCard.d.ts +7 -0
- package/dist/types/src/components/MarkdownCard/MarkdownCard.d.ts.map +1 -0
- package/dist/types/src/components/MarkdownCard/MarkdownCard.stories.d.ts +10 -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 +5 -5
- package/dist/types/src/components/MarkdownContainer.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownContainer.stories.d.ts +50 -4
- package/dist/types/src/components/MarkdownContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownEditor/MarkdownEditor.d.ts +1 -1
- package/dist/types/src/components/MarkdownEditor/MarkdownEditor.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownEditor/MarkdownEditor.stories.d.ts +110 -12
- package/dist/types/src/components/MarkdownEditor/MarkdownEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownSettings/MarkdownSettings.d.ts +2 -2
- package/dist/types/src/components/MarkdownSettings/MarkdownSettings.d.ts.map +1 -1
- package/dist/types/src/components/Suggestions.stories.d.ts +2 -2
- package/dist/types/src/components/Suggestions.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar.stories.d.ts +44 -7
- package/dist/types/src/components/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/extensions.d.ts +4 -4
- package/dist/types/src/extensions.d.ts.map +1 -1
- package/dist/types/src/functions/create.d.ts +12 -0
- package/dist/types/src/functions/create.d.ts.map +1 -0
- package/dist/types/src/functions/diff.d.ts +6 -0
- package/dist/types/src/functions/diff.d.ts.map +1 -0
- package/dist/types/src/functions/index.d.ts +4 -0
- package/dist/types/src/functions/index.d.ts.map +1 -0
- package/dist/types/src/functions/open.d.ts +7 -0
- package/dist/types/src/functions/open.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Markdown.d.ts +43 -0
- package/dist/types/src/types/Markdown.d.ts.map +1 -0
- package/dist/types/src/types/MarkdownAction.d.ts +33 -0
- package/dist/types/src/types/MarkdownAction.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +3 -59
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +12 -3
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +46 -41
- package/src/MarkdownPlugin.tsx +14 -12
- package/src/capabilities/anchor-sort.ts +3 -3
- package/src/capabilities/app-graph-serializer.ts +7 -5
- package/src/capabilities/artifact-definition.ts +18 -23
- package/src/capabilities/blueprint-definition.ts +39 -0
- package/src/capabilities/capabilities.ts +5 -4
- package/src/capabilities/index.ts +2 -1
- package/src/capabilities/intent-resolver.ts +15 -21
- package/src/capabilities/react-surface.tsx +21 -19
- package/src/capabilities/settings.ts +3 -3
- package/src/capabilities/state.ts +8 -8
- package/src/components/MarkdownCard/MarkdownCard.stories.tsx +79 -0
- package/src/components/{MarkdownPreview/MarkdownPreview.tsx → MarkdownCard/MarkdownCard.tsx} +11 -9
- package/src/components/MarkdownCard/index.ts +9 -0
- package/src/components/MarkdownContainer.stories.tsx +12 -15
- package/src/components/MarkdownContainer.tsx +10 -9
- package/src/components/MarkdownEditor/MarkdownEditor.stories.tsx +10 -7
- package/src/components/MarkdownEditor/MarkdownEditor.tsx +9 -8
- package/src/components/MarkdownSettings/MarkdownSettings.tsx +81 -78
- package/src/components/Suggestions.stories.tsx +24 -27
- package/src/components/Toolbar.stories.tsx +18 -13
- package/src/components/index.ts +1 -1
- package/src/events.ts +2 -2
- package/src/extensions.tsx +12 -12
- package/src/functions/create.ts +23 -0
- package/src/functions/diff.ts +35 -0
- package/src/functions/index.ts +7 -0
- package/src/functions/open.ts +30 -0
- package/src/hooks/useSelectCurrentThread.tsx +3 -3
- package/src/index.ts +4 -1
- package/src/meta.ts +7 -8
- package/src/translations.ts +3 -2
- package/src/types/Markdown.ts +56 -0
- package/src/types/MarkdownAction.ts +29 -0
- package/src/types/index.ts +2 -1
- package/src/types/types.ts +6 -50
- package/src/util.tsx +20 -6
- package/dist/lib/browser/MarkdownContainer-F3WEEIBX.mjs.map +0 -7
- package/dist/lib/browser/MarkdownPreview-S3C7CGAV.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-UKJJ7ZNP.mjs.map +0 -7
- 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.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-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.map +0 -7
- package/dist/lib/browser/settings-KN75ZQY6.mjs.map +0 -7
- package/dist/lib/browser/state-LZWTAS65.mjs.map +0 -7
- package/dist/lib/node-esm/MarkdownContainer-VOUHL6IU.mjs.map +0 -7
- package/dist/lib/node-esm/MarkdownPreview-77UFEWXT.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-IPIS5D5B.mjs.map +0 -7
- 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-ACFGXH2K.mjs.map +0 -7
- 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.map +0 -7
- package/dist/lib/node-esm/settings-KVP7TVX7.mjs.map +0 -7
- package/dist/lib/node-esm/state-NW3W4JCQ.mjs.map +0 -7
- 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/types/schema.d.ts +0 -35
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/components/MarkdownPreview/MarkdownPreview.stories.tsx +0 -81
- package/src/components/MarkdownPreview/index.ts +0 -9
- package/src/types/schema.ts +0 -39
|
@@ -5,23 +5,20 @@
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
7
|
import { type Meta } from '@storybook/react-vite';
|
|
8
|
-
import { Match, Option,
|
|
8
|
+
import { Match, Option, Schema, pipe } from 'effect';
|
|
9
9
|
import React, { type FC, useEffect, useMemo, useState } from 'react';
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
12
|
Capabilities,
|
|
13
|
-
CollaborationActions,
|
|
14
13
|
IntentPlugin,
|
|
15
14
|
SettingsPlugin,
|
|
16
15
|
contributes,
|
|
17
|
-
createIntent,
|
|
18
16
|
useCapability,
|
|
19
17
|
useIntentDispatcher,
|
|
20
18
|
} from '@dxos/app-framework';
|
|
21
19
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
22
20
|
import { Obj, Ref, Type } from '@dxos/echo';
|
|
23
21
|
import { invariant } from '@dxos/invariant';
|
|
24
|
-
import { DXN } from '@dxos/keys';
|
|
25
22
|
import { ClientPlugin } from '@dxos/plugin-client';
|
|
26
23
|
import { PreviewPlugin } from '@dxos/plugin-preview';
|
|
27
24
|
import { SpacePlugin } from '@dxos/plugin-space';
|
|
@@ -30,18 +27,19 @@ import { ThemePlugin } from '@dxos/plugin-theme';
|
|
|
30
27
|
import { faker } from '@dxos/random';
|
|
31
28
|
import { createDocAccessor, fullyQualifiedId, toCursorRange, useQueue, useSpace } from '@dxos/react-client/echo';
|
|
32
29
|
import { IconButton, Toolbar } from '@dxos/react-ui';
|
|
33
|
-
import {
|
|
30
|
+
import { type EditorSelection, type Range, command, useTextEditor } from '@dxos/react-ui-editor';
|
|
34
31
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
35
32
|
import { defaultTx } from '@dxos/react-ui-theme';
|
|
36
33
|
import { DataType } from '@dxos/schema';
|
|
37
34
|
import { withLayout } from '@dxos/storybook-utils';
|
|
38
35
|
|
|
39
|
-
import MarkdownContainer from './MarkdownContainer';
|
|
40
|
-
import { MarkdownPlugin } from '../MarkdownPlugin';
|
|
41
36
|
import { MarkdownCapabilities } from '../capabilities';
|
|
42
|
-
import {
|
|
37
|
+
import { MarkdownPlugin } from '../MarkdownPlugin';
|
|
38
|
+
import { meta } from '../meta';
|
|
43
39
|
import { translations } from '../translations';
|
|
44
|
-
import {
|
|
40
|
+
import { Markdown } from '../types';
|
|
41
|
+
|
|
42
|
+
import { MarkdownContainer } from './MarkdownContainer';
|
|
45
43
|
|
|
46
44
|
faker.seed(1);
|
|
47
45
|
|
|
@@ -61,7 +59,7 @@ const TestItem = Schema.Struct({
|
|
|
61
59
|
}),
|
|
62
60
|
);
|
|
63
61
|
|
|
64
|
-
const TestChat: FC<{ doc:
|
|
62
|
+
const TestChat: FC<{ doc: Markdown.Document; content: string }> = ({ doc, content }) => {
|
|
65
63
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
66
64
|
const { parentRef } = useTextEditor({ initialValue: content });
|
|
67
65
|
const { editorState } = useCapability(MarkdownCapabilities.State);
|
|
@@ -98,14 +96,14 @@ const TestChat: FC<{ doc: DocumentType; content: string }> = ({ doc, content })
|
|
|
98
96
|
// const message = deref(ref);
|
|
99
97
|
// }
|
|
100
98
|
|
|
101
|
-
void dispatch(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
);
|
|
99
|
+
// void dispatch(
|
|
100
|
+
// createIntent(CollaborationActions.InsertContent, {
|
|
101
|
+
// target: doc as any as Type.Expando,
|
|
102
|
+
// object: Ref.fromDXN(new DXN(DXN.kind.QUEUE, [...queue.dxn.parts, message.id])),
|
|
103
|
+
// at: cursor,
|
|
104
|
+
// label: 'Proposal',
|
|
105
|
+
// }),
|
|
106
|
+
// );
|
|
109
107
|
};
|
|
110
108
|
|
|
111
109
|
return (
|
|
@@ -120,8 +118,8 @@ const TestChat: FC<{ doc: DocumentType; content: string }> = ({ doc, content })
|
|
|
120
118
|
|
|
121
119
|
const DefaultStory = ({ document, chat }: { document: string; chat: string }) => {
|
|
122
120
|
const space = useSpace();
|
|
123
|
-
const [doc, setDoc] = useState<
|
|
124
|
-
const settings = useCapability(Capabilities.SettingsStore).getStore<
|
|
121
|
+
const [doc, setDoc] = useState<Markdown.Document>();
|
|
122
|
+
const settings = useCapability(Capabilities.SettingsStore).getStore<Markdown.Settings>(meta.id)!.value;
|
|
125
123
|
const { editorState } = useCapability(MarkdownCapabilities.State);
|
|
126
124
|
|
|
127
125
|
useEffect(() => {
|
|
@@ -130,10 +128,8 @@ const DefaultStory = ({ document, chat }: { document: string; chat: string }) =>
|
|
|
130
128
|
}
|
|
131
129
|
|
|
132
130
|
const doc = space.db.add(
|
|
133
|
-
|
|
131
|
+
Markdown.makeDocument({
|
|
134
132
|
name: 'Test',
|
|
135
|
-
|
|
136
|
-
// Create links.
|
|
137
133
|
content: document.replaceAll(/\[(\w+)\]/g, (_, label) => {
|
|
138
134
|
const obj = space.db.add(Obj.make(TestItem, { title: label, description: faker.lorem.paragraph() }));
|
|
139
135
|
const dxn = Ref.make(obj).dxn.toString();
|
|
@@ -157,7 +153,8 @@ const DefaultStory = ({ document, chat }: { document: string; chat: string }) =>
|
|
|
157
153
|
);
|
|
158
154
|
};
|
|
159
155
|
|
|
160
|
-
|
|
156
|
+
// TODO(burdon): Make consistent.
|
|
157
|
+
const storybook: Meta<typeof DefaultStory> = {
|
|
161
158
|
title: 'plugins/plugin-markdown/Suggestions',
|
|
162
159
|
render: DefaultStory,
|
|
163
160
|
decorators: [
|
|
@@ -166,8 +163,8 @@ const meta: Meta<typeof DefaultStory> = {
|
|
|
166
163
|
ThemePlugin({ tx: defaultTx }),
|
|
167
164
|
StorybookLayoutPlugin(),
|
|
168
165
|
ClientPlugin({
|
|
169
|
-
types: [
|
|
170
|
-
onClientInitialized: async (
|
|
166
|
+
types: [Markdown.Document, TestItem],
|
|
167
|
+
onClientInitialized: async ({ client }) => {
|
|
171
168
|
await client.halo.createIdentity();
|
|
172
169
|
},
|
|
173
170
|
}),
|
|
@@ -187,7 +184,7 @@ const meta: Meta<typeof DefaultStory> = {
|
|
|
187
184
|
},
|
|
188
185
|
};
|
|
189
186
|
|
|
190
|
-
export default
|
|
187
|
+
export default storybook;
|
|
191
188
|
|
|
192
189
|
type Story = Meta<typeof DefaultStory>;
|
|
193
190
|
|
|
@@ -4,18 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
8
|
-
import React, {
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
|
+
import React, { useCallback, useState } from 'react';
|
|
9
9
|
|
|
10
|
-
import { Obj } from '@dxos/echo';
|
|
11
10
|
import { invariant } from '@dxos/invariant';
|
|
12
11
|
import { PublicKey } from '@dxos/keys';
|
|
13
12
|
import { faker } from '@dxos/random';
|
|
14
13
|
import { createDocAccessor } from '@dxos/react-client/echo';
|
|
15
14
|
import { useThemeContext } from '@dxos/react-ui';
|
|
16
15
|
import {
|
|
17
|
-
EditorToolbar,
|
|
18
16
|
type Comment,
|
|
17
|
+
EditorToolbar,
|
|
18
|
+
type EditorViewMode,
|
|
19
19
|
comments,
|
|
20
20
|
createBasicExtensions,
|
|
21
21
|
createDataExtensions,
|
|
@@ -26,19 +26,22 @@ import {
|
|
|
26
26
|
formattingKeymap,
|
|
27
27
|
translations,
|
|
28
28
|
useComments,
|
|
29
|
+
useEditorToolbarState,
|
|
29
30
|
useFormattingState,
|
|
30
31
|
useTextEditor,
|
|
31
|
-
useEditorToolbarState,
|
|
32
|
-
type EditorViewMode,
|
|
33
32
|
} from '@dxos/react-ui-editor';
|
|
34
33
|
import { DataType } from '@dxos/schema';
|
|
35
34
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
36
35
|
|
|
37
36
|
faker.seed(101);
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
type StoryProps = {
|
|
39
|
+
content?: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const DefaultStory = ({ content = '' }: StoryProps) => {
|
|
40
43
|
const { themeMode } = useThemeContext();
|
|
41
|
-
const [text] = useState(
|
|
44
|
+
const [text] = useState(DataType.makeText(content));
|
|
42
45
|
const toolbarState = useEditorToolbarState({ viewMode: 'preview' });
|
|
43
46
|
const formattingObserver = useFormattingState(toolbarState);
|
|
44
47
|
const { parentRef, view } = useTextEditor(() => {
|
|
@@ -94,19 +97,21 @@ const content = [
|
|
|
94
97
|
'',
|
|
95
98
|
].join('\n');
|
|
96
99
|
|
|
97
|
-
const meta
|
|
100
|
+
const meta = {
|
|
98
101
|
title: 'plugins/plugin-markdown/Toolbar',
|
|
99
|
-
component: EditorToolbar,
|
|
100
|
-
render: DefaultStory
|
|
102
|
+
component: EditorToolbar as any,
|
|
103
|
+
render: DefaultStory,
|
|
101
104
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
|
102
105
|
parameters: {
|
|
103
106
|
translations,
|
|
104
107
|
},
|
|
105
|
-
}
|
|
108
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
106
109
|
|
|
107
110
|
export default meta;
|
|
108
111
|
|
|
109
|
-
|
|
112
|
+
type Story = StoryObj<typeof meta>;
|
|
113
|
+
|
|
114
|
+
export const Default: Story = {
|
|
110
115
|
args: {
|
|
111
116
|
content,
|
|
112
117
|
},
|
package/src/components/index.ts
CHANGED
|
@@ -7,4 +7,4 @@ import { lazy } from 'react';
|
|
|
7
7
|
export * from './MarkdownSettings';
|
|
8
8
|
|
|
9
9
|
export const MarkdownContainer = lazy(() => import('./MarkdownContainer'));
|
|
10
|
-
export const
|
|
10
|
+
export const MarkdownCard = lazy(() => import('./MarkdownCard'));
|
package/src/events.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { Events } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { meta } from './meta';
|
|
8
8
|
|
|
9
9
|
export namespace MarkdownEvents {
|
|
10
|
-
export const SetupExtensions = Events.createStateEvent(`${
|
|
10
|
+
export const SetupExtensions = Events.createStateEvent(`${meta.id}/event/setup-extensions`);
|
|
11
11
|
}
|
package/src/extensions.tsx
CHANGED
|
@@ -7,27 +7,32 @@ import React, { type AnchorHTMLAttributes, type ReactNode, useMemo } from 'react
|
|
|
7
7
|
import { createRoot } from 'react-dom/client';
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
|
-
createIntent,
|
|
11
10
|
LayoutAction,
|
|
12
11
|
type PromiseIntentDispatcher,
|
|
12
|
+
createIntent,
|
|
13
13
|
useCapabilities,
|
|
14
14
|
useIntentDispatcher,
|
|
15
15
|
} from '@dxos/app-framework';
|
|
16
16
|
import { debounceAndThrottle } from '@dxos/async';
|
|
17
17
|
import { invariant } from '@dxos/invariant';
|
|
18
|
-
import { createDocAccessor, fullyQualifiedId, getSpace
|
|
18
|
+
import { type QueryResult, createDocAccessor, fullyQualifiedId, getSpace } from '@dxos/react-client/echo';
|
|
19
19
|
import { useIdentity } from '@dxos/react-client/halo';
|
|
20
20
|
import { Icon, ThemeProvider } from '@dxos/react-ui';
|
|
21
21
|
import { type SelectionManager } from '@dxos/react-ui-attention';
|
|
22
22
|
import {
|
|
23
23
|
type AutocompleteResult,
|
|
24
|
+
Cursor,
|
|
24
25
|
type EditorStateStore,
|
|
26
|
+
EditorView,
|
|
25
27
|
type EditorViewMode,
|
|
26
28
|
type Extension,
|
|
27
29
|
InputModeExtensions,
|
|
28
|
-
|
|
30
|
+
type PreviewOptions,
|
|
31
|
+
type RenderCallback,
|
|
29
32
|
autocomplete,
|
|
33
|
+
createDataExtensions,
|
|
30
34
|
decorateMarkdown,
|
|
35
|
+
documentId,
|
|
31
36
|
folding,
|
|
32
37
|
formattingKeymap,
|
|
33
38
|
linkTooltip,
|
|
@@ -35,27 +40,22 @@ import {
|
|
|
35
40
|
preview,
|
|
36
41
|
selectionState,
|
|
37
42
|
typewriter,
|
|
38
|
-
type RenderCallback,
|
|
39
|
-
EditorView,
|
|
40
|
-
documentId,
|
|
41
|
-
Cursor,
|
|
42
|
-
type PreviewOptions,
|
|
43
43
|
} from '@dxos/react-ui-editor';
|
|
44
44
|
import { defaultTx } from '@dxos/react-ui-theme';
|
|
45
45
|
import { type DataType } from '@dxos/schema';
|
|
46
46
|
import { isNotFalsy } from '@dxos/util';
|
|
47
47
|
|
|
48
48
|
import { MarkdownCapabilities } from './capabilities';
|
|
49
|
-
import { type
|
|
49
|
+
import { type Markdown } from './types';
|
|
50
50
|
import { setFallbackName } from './util';
|
|
51
51
|
|
|
52
52
|
type ExtensionsOptions = {
|
|
53
|
-
document?:
|
|
53
|
+
document?: Markdown.Document;
|
|
54
54
|
id?: string;
|
|
55
55
|
text?: DataType.Text;
|
|
56
56
|
dispatch?: PromiseIntentDispatcher;
|
|
57
|
-
query?: QueryResult<
|
|
58
|
-
settings:
|
|
57
|
+
query?: QueryResult<Markdown.Document>;
|
|
58
|
+
settings: Markdown.Settings;
|
|
59
59
|
selectionManager?: SelectionManager;
|
|
60
60
|
viewMode?: EditorViewMode;
|
|
61
61
|
editorStateStore?: EditorStateStore;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Effect, Schema } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { DatabaseService, defineFunction } from '@dxos/functions';
|
|
8
|
+
|
|
9
|
+
import { Markdown } from '../types';
|
|
10
|
+
|
|
11
|
+
// TODO(wittjosiah): Reconcile with MarkdownAction.Create.
|
|
12
|
+
export default defineFunction({
|
|
13
|
+
name: 'dxos.org/function/markdown/create',
|
|
14
|
+
description: 'Creates a new markdown document.',
|
|
15
|
+
inputSchema: Schema.Struct({
|
|
16
|
+
name: Schema.optional(Schema.String),
|
|
17
|
+
content: Schema.optional(Schema.String),
|
|
18
|
+
}),
|
|
19
|
+
outputSchema: Markdown.Document,
|
|
20
|
+
handler: Effect.fn(function* ({ data: { name, content } }) {
|
|
21
|
+
return yield* DatabaseService.add(Markdown.makeDocument({ name, content }));
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Effect, Schema } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { ArtifactId, applyDiffs } from '@dxos/assistant';
|
|
8
|
+
import { createDocAccessor } from '@dxos/echo-db';
|
|
9
|
+
import { DatabaseService, defineFunction } from '@dxos/functions';
|
|
10
|
+
import { trim } from '@dxos/util';
|
|
11
|
+
|
|
12
|
+
import { Markdown } from '../types';
|
|
13
|
+
|
|
14
|
+
// TODO(wittjosiah): Reconcile with ThreadAction.AddProposal.
|
|
15
|
+
export default defineFunction({
|
|
16
|
+
name: 'dxos.org/function/markdown/diff',
|
|
17
|
+
description: trim`
|
|
18
|
+
Applies a set of diffs to the markdown document.
|
|
19
|
+
`,
|
|
20
|
+
inputSchema: Schema.Struct({
|
|
21
|
+
id: ArtifactId.annotations({
|
|
22
|
+
description: 'The ID of the markdown document.',
|
|
23
|
+
}),
|
|
24
|
+
diffs: Schema.Array(Schema.String).annotations({
|
|
25
|
+
description: 'The diffs to apply to the document.',
|
|
26
|
+
}),
|
|
27
|
+
}),
|
|
28
|
+
outputSchema: Schema.Void,
|
|
29
|
+
handler: Effect.fn(function* ({ data: { id, diffs } }) {
|
|
30
|
+
const object = yield* DatabaseService.resolve(ArtifactId.toDXN(id), Markdown.Document);
|
|
31
|
+
const content = yield* Effect.promise(() => object.content.load());
|
|
32
|
+
const accessor = createDocAccessor(content, ['content']);
|
|
33
|
+
applyDiffs(accessor, diffs);
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Effect, Schema } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { ArtifactId } from '@dxos/assistant';
|
|
8
|
+
import { DatabaseService, defineFunction } from '@dxos/functions';
|
|
9
|
+
|
|
10
|
+
import { Markdown } from '../types';
|
|
11
|
+
|
|
12
|
+
export default defineFunction({
|
|
13
|
+
name: 'dxos.org/function/markdown/open',
|
|
14
|
+
description: 'Opens and reads the contents of a new markdown document.',
|
|
15
|
+
inputSchema: Schema.Struct({
|
|
16
|
+
id: ArtifactId.annotations({
|
|
17
|
+
description: 'The ID of the markdown document.',
|
|
18
|
+
}),
|
|
19
|
+
}),
|
|
20
|
+
outputSchema: Schema.Struct({
|
|
21
|
+
content: Schema.String,
|
|
22
|
+
}),
|
|
23
|
+
handler: Effect.fn(function* ({ data: { id } }) {
|
|
24
|
+
const object = yield* DatabaseService.resolve(ArtifactId.toDXN(id), Markdown.Document);
|
|
25
|
+
const { content } = yield* Effect.promise(() => object.content.load());
|
|
26
|
+
return {
|
|
27
|
+
content,
|
|
28
|
+
};
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
@@ -6,11 +6,11 @@ import { EditorView } from '@codemirror/view';
|
|
|
6
6
|
import { Schema } from 'effect';
|
|
7
7
|
import { useMemo } from 'react';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { LayoutAction, createResolver, useIntentResolver } from '@dxos/app-framework';
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
11
|
import { Cursor, setSelection } from '@dxos/react-ui-editor';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { meta } from '../meta';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Handle scrolling and selection of the current thread in a markdown editor.
|
|
@@ -52,5 +52,5 @@ export const useSelectCurrentThread = (editorView: EditorView | undefined, docum
|
|
|
52
52
|
[documentId, editorView],
|
|
53
53
|
);
|
|
54
54
|
|
|
55
|
-
useIntentResolver(
|
|
55
|
+
useIntentResolver(meta.id, scrollIntoViewResolver);
|
|
56
56
|
};
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -3,18 +3,17 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type PluginMeta } from '@dxos/app-framework';
|
|
6
|
-
|
|
7
|
-
export const MARKDOWN_PLUGIN = 'dxos.org/plugin/markdown';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
8
7
|
|
|
9
8
|
export const meta: PluginMeta = {
|
|
10
|
-
id:
|
|
9
|
+
id: 'dxos.org/plugin/markdown',
|
|
11
10
|
name: 'Markdown',
|
|
12
|
-
description: `
|
|
13
|
-
A
|
|
14
|
-
In addition to markdown capabilities,
|
|
15
|
-
|
|
11
|
+
description: trim`
|
|
12
|
+
A collaborative and extensible Markdown editor.
|
|
13
|
+
In addition to markdown capabilities, the plugin supports collaborative in-line comments.
|
|
14
|
+
You can use documents to extend the memory of your personal agents and add context for automated workflows.
|
|
16
15
|
`,
|
|
17
|
-
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-markdown',
|
|
18
16
|
icon: 'ph--text-aa--regular',
|
|
17
|
+
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-markdown',
|
|
19
18
|
screenshots: ['https://dxos.network/plugin-details-markdown-dark.png'],
|
|
20
19
|
};
|
package/src/translations.ts
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
import { type Resource } from '@dxos/react-ui';
|
|
6
6
|
|
|
7
7
|
import { meta } from './meta';
|
|
8
|
-
import {
|
|
8
|
+
import { Markdown } from './types';
|
|
9
9
|
|
|
10
10
|
export const translations = [
|
|
11
11
|
{
|
|
12
12
|
'en-US': {
|
|
13
|
-
[
|
|
13
|
+
[Markdown.Document.typename]: {
|
|
14
14
|
'typename label': 'Document',
|
|
15
15
|
'typename label_zero': 'Documents',
|
|
16
16
|
'typename label_one': 'Document',
|
|
@@ -21,6 +21,7 @@ export const translations = [
|
|
|
21
21
|
},
|
|
22
22
|
[meta.id]: {
|
|
23
23
|
'plugin name': 'Editor',
|
|
24
|
+
'settings title': 'Editor settings',
|
|
24
25
|
'choose markdown from space dialog title': 'Choose one or more documents to add',
|
|
25
26
|
// TODO(burdon): Style-guide for user-facing text (e.g., hints, questions, capitalization, etc.)
|
|
26
27
|
'empty choose markdown from space message': 'None available; try creating a new one instead?',
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { Obj, Ref, Type } from '@dxos/echo';
|
|
8
|
+
import { LabelAnnotation } from '@dxos/echo-schema';
|
|
9
|
+
import { EditorInputMode, EditorViewMode } from '@dxos/react-ui-editor/types';
|
|
10
|
+
import { DataType, ItemAnnotation } from '@dxos/schema';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Document Item type.
|
|
14
|
+
*/
|
|
15
|
+
export const Document = Schema.Struct({
|
|
16
|
+
name: Schema.optional(Schema.String),
|
|
17
|
+
fallbackName: Schema.optional(Schema.String),
|
|
18
|
+
content: Type.Ref(DataType.Text),
|
|
19
|
+
}).pipe(
|
|
20
|
+
Type.Obj({
|
|
21
|
+
typename: 'dxos.org/type/Document',
|
|
22
|
+
version: '0.1.0',
|
|
23
|
+
}),
|
|
24
|
+
LabelAnnotation.set(['name', 'fallbackName']),
|
|
25
|
+
ItemAnnotation.set(true),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export type Document = Schema.Schema.Type<typeof Document>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Document factory.
|
|
32
|
+
*/
|
|
33
|
+
export const makeDocument = ({
|
|
34
|
+
content = '',
|
|
35
|
+
...props
|
|
36
|
+
}: Partial<{ name: string; fallbackName: string; content: string }> = {}) =>
|
|
37
|
+
Obj.make(Document, { ...props, content: Ref.make(DataType.makeText(content)) });
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Plugin settings.
|
|
41
|
+
*/
|
|
42
|
+
export const Settings = Schema.mutable(
|
|
43
|
+
Schema.Struct({
|
|
44
|
+
defaultViewMode: EditorViewMode,
|
|
45
|
+
editorInputMode: Schema.optional(EditorInputMode),
|
|
46
|
+
experimental: Schema.optional(Schema.Boolean),
|
|
47
|
+
debug: Schema.optional(Schema.Boolean),
|
|
48
|
+
toolbar: Schema.optional(Schema.Boolean),
|
|
49
|
+
typewriter: Schema.optional(Schema.String),
|
|
50
|
+
// TODO(burdon): Per document settings.
|
|
51
|
+
numberedHeadings: Schema.optional(Schema.Boolean),
|
|
52
|
+
folding: Schema.optional(Schema.Boolean),
|
|
53
|
+
}),
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
export interface Settings extends Schema.Schema.Type<typeof Settings> {}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { EditorViewMode } from '@dxos/react-ui-editor/types';
|
|
8
|
+
|
|
9
|
+
import { meta } from '../meta';
|
|
10
|
+
|
|
11
|
+
import { Document } from './Markdown';
|
|
12
|
+
|
|
13
|
+
export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {
|
|
14
|
+
input: Schema.Struct({
|
|
15
|
+
name: Schema.optional(Schema.String),
|
|
16
|
+
content: Schema.optional(Schema.String),
|
|
17
|
+
}),
|
|
18
|
+
output: Schema.Struct({
|
|
19
|
+
object: Document,
|
|
20
|
+
}),
|
|
21
|
+
}) {}
|
|
22
|
+
|
|
23
|
+
export class SetViewMode extends Schema.TaggedClass<SetViewMode>()(`${meta.id}/action/set-view-mode`, {
|
|
24
|
+
input: Schema.Struct({
|
|
25
|
+
id: Schema.String,
|
|
26
|
+
viewMode: EditorViewMode,
|
|
27
|
+
}),
|
|
28
|
+
output: Schema.Void,
|
|
29
|
+
}) {}
|
package/src/types/index.ts
CHANGED
package/src/types/types.ts
CHANGED
|
@@ -2,44 +2,16 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema } from 'effect';
|
|
6
|
-
|
|
7
|
-
import { Type } from '@dxos/echo';
|
|
8
5
|
import { type Extension } from '@dxos/react-ui-editor';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
import { DocumentType } from './schema';
|
|
12
|
-
import { MARKDOWN_PLUGIN } from '../meta';
|
|
13
|
-
|
|
14
|
-
const MARKDOWN_ACTION = `${MARKDOWN_PLUGIN}/action`;
|
|
15
|
-
|
|
16
|
-
export namespace MarkdownAction {
|
|
17
|
-
export class Create extends Schema.TaggedClass<Create>()(MARKDOWN_ACTION, {
|
|
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
|
-
}) {}
|
|
6
|
+
import { type EditorViewMode } from '@dxos/react-ui-editor/types';
|
|
27
7
|
|
|
28
|
-
|
|
29
|
-
input: Schema.Struct({
|
|
30
|
-
id: Schema.String,
|
|
31
|
-
viewMode: EditorViewMode,
|
|
32
|
-
}),
|
|
33
|
-
output: Schema.Void,
|
|
34
|
-
}) {}
|
|
35
|
-
}
|
|
8
|
+
import { type Document } from './Markdown';
|
|
36
9
|
|
|
37
|
-
|
|
10
|
+
// TODO(burdon): Remove these from ./types since not part of plugin-markdown API?
|
|
11
|
+
// TODO(wittjosiah): MarkdownExtensionProvider is a part of the MarkdownCapabilities api which should be in ./types.
|
|
38
12
|
|
|
39
|
-
// TODO(burdon): Async
|
|
40
|
-
export type MarkdownExtensionProvider = (props: { document?:
|
|
41
|
-
|
|
42
|
-
export type OnChange = (text: string) => void;
|
|
13
|
+
// TODO(burdon): Async?
|
|
14
|
+
export type MarkdownExtensionProvider = (props: { document?: Document }) => Extension | undefined;
|
|
43
15
|
|
|
44
16
|
export type MarkdownPluginState = {
|
|
45
17
|
// Codemirror extensions provided by other plugins.
|
|
@@ -49,19 +21,3 @@ export type MarkdownPluginState = {
|
|
|
49
21
|
// View mode per document.
|
|
50
22
|
viewMode: Record<string, EditorViewMode>;
|
|
51
23
|
};
|
|
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>;
|