@dxos/plugin-markdown 0.8.4-main.c1de068 → 0.8.4-main.e098934
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-HMPNQMNG.mjs} +260 -287
- package/dist/lib/browser/MarkdownContainer-HMPNQMNG.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-5YKFUHRU.mjs +11 -0
- package/dist/lib/browser/blueprint-definition-5YKFUHRU.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-F6JJLKLN.mjs +102 -0
- package/dist/lib/browser/chunk-F6JJLKLN.mjs.map +7 -0
- 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-XE66SH4O.mjs +22 -0
- package/dist/lib/browser/chunk-XE66SH4O.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/index.mjs +34 -21
- 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-NY5K2I5R.mjs} +53 -44
- package/dist/lib/browser/react-surface-NY5K2I5R.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/toolkit-2AJTHG74.mjs +74 -0
- package/dist/lib/browser/toolkit-2AJTHG74.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-5FTROSXN.mjs} +260 -287
- package/dist/lib/node-esm/MarkdownContainer-5FTROSXN.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-GVW67KGV.mjs +12 -0
- package/dist/lib/node-esm/blueprint-definition-GVW67KGV.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-DVK63TD3.mjs +103 -0
- package/dist/lib/node-esm/chunk-DVK63TD3.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-CWTFQSN7.mjs → chunk-O6EXWGGS.mjs} +8 -9
- package/dist/lib/node-esm/chunk-O6EXWGGS.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Q2BREK2M.mjs +24 -0
- package/dist/lib/node-esm/chunk-Q2BREK2M.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/index.mjs +34 -21
- 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-AUWSLYJS.mjs} +53 -44
- package/dist/lib/node-esm/react-surface-AUWSLYJS.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/toolkit-RC44I2MI.mjs +75 -0
- package/dist/lib/node-esm/toolkit-RC44I2MI.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 +12 -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/capabilities/toolkit.d.ts +4 -0
- package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
- 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 +2 -2
- 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 +3 -5
- package/dist/types/src/extensions.d.ts.map +1 -1
- 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 +3 -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 +49 -44
- package/src/MarkdownPlugin.tsx +21 -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 +3 -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/capabilities/toolkit.ts +47 -0
- 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 +11 -10
- package/src/components/MarkdownEditor/MarkdownEditor.stories.tsx +10 -7
- package/src/components/MarkdownEditor/MarkdownEditor.tsx +28 -30
- package/src/components/MarkdownSettings/MarkdownSettings.tsx +81 -78
- package/src/components/Suggestions.stories.tsx +25 -28
- package/src/components/Toolbar.stories.tsx +19 -14
- package/src/components/index.ts +1 -1
- package/src/events.ts +2 -2
- package/src/extensions.tsx +10 -38
- package/src/functions/diff.ts +35 -0
- package/src/functions/index.ts +6 -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-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.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-7X6TPTJK.mjs.map +0 -7
- 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
|
@@ -2,25 +2,25 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Capabilities,
|
|
5
|
+
import { Capabilities, type PluginContext, contributes } from '@dxos/app-framework';
|
|
6
6
|
import { LocalStorageStore } from '@dxos/local-storage';
|
|
7
7
|
import { type EditorViewMode, createEditorStateStore } from '@dxos/react-ui-editor';
|
|
8
8
|
|
|
9
|
+
import { meta } from '../meta';
|
|
10
|
+
import { type Markdown, type MarkdownPluginState } from '../types';
|
|
11
|
+
|
|
9
12
|
import { MarkdownCapabilities } from './capabilities';
|
|
10
|
-
import { MARKDOWN_PLUGIN } from '../meta';
|
|
11
|
-
import { type MarkdownPluginState, type MarkdownSettingsProps } from '../types';
|
|
12
13
|
|
|
13
14
|
export default (context: PluginContext) => {
|
|
14
|
-
const state = new LocalStorageStore<MarkdownPluginState>(
|
|
15
|
+
const state = new LocalStorageStore<MarkdownPluginState>(meta.id, { extensionProviders: [], viewMode: {} });
|
|
15
16
|
state.prop({ key: 'viewMode', type: LocalStorageStore.json<{ [key: string]: EditorViewMode }>() });
|
|
16
17
|
|
|
17
18
|
// TODO(wittjosiah): Fold into state.
|
|
18
|
-
const editorState = createEditorStateStore(`${
|
|
19
|
+
const editorState = createEditorStateStore(`${meta.id}/editor`);
|
|
19
20
|
|
|
20
21
|
const getViewMode = (id: string) => {
|
|
21
|
-
const defaultViewMode = context
|
|
22
|
-
.
|
|
23
|
-
.getStore<MarkdownSettingsProps>(MARKDOWN_PLUGIN)!.value.defaultViewMode;
|
|
22
|
+
const defaultViewMode = context.getCapability(Capabilities.SettingsStore).getStore<Markdown.Settings>(meta.id)!
|
|
23
|
+
.value.defaultViewMode;
|
|
24
24
|
return (id && state.values.viewMode[id]) || defaultViewMode;
|
|
25
25
|
};
|
|
26
26
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { AiTool, AiToolkit } from '@effect/ai';
|
|
6
|
+
import { Effect, Schema } from 'effect';
|
|
7
|
+
|
|
8
|
+
import { Capabilities, type Capability, type PluginContext, contributes, createIntent } from '@dxos/app-framework';
|
|
9
|
+
import { invariant } from '@dxos/invariant';
|
|
10
|
+
import { getActiveSpace } from '@dxos/plugin-space';
|
|
11
|
+
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
12
|
+
|
|
13
|
+
import { MarkdownAction } from '../types';
|
|
14
|
+
|
|
15
|
+
// TODO(burdon): Reconcile with functions (currently reuses plugin framework intents).
|
|
16
|
+
class Toolkit extends AiToolkit.make(
|
|
17
|
+
AiTool.make('create-document', {
|
|
18
|
+
description: 'Creates a new markdown document.',
|
|
19
|
+
parameters: {
|
|
20
|
+
name: Schema.optional(Schema.String),
|
|
21
|
+
content: Schema.optional(Schema.String),
|
|
22
|
+
},
|
|
23
|
+
// TODO(wittjosiah): Return document.
|
|
24
|
+
success: Schema.Any,
|
|
25
|
+
failure: Schema.Never,
|
|
26
|
+
}),
|
|
27
|
+
) {
|
|
28
|
+
static layer = (context: PluginContext) =>
|
|
29
|
+
Toolkit.toLayer({
|
|
30
|
+
'create-document': ({ name, content }) => {
|
|
31
|
+
const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
32
|
+
const space = getActiveSpace(context);
|
|
33
|
+
invariant(space, 'No active space');
|
|
34
|
+
|
|
35
|
+
return Effect.gen(function* () {
|
|
36
|
+
const { object } = yield* dispatch(createIntent(MarkdownAction.Create, { name, content }));
|
|
37
|
+
yield* dispatch(createIntent(SpaceAction.AddObject, { object, target: space }));
|
|
38
|
+
return { id: object.id };
|
|
39
|
+
}).pipe(Effect.orDie);
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default (context: PluginContext): Capability<any>[] => [
|
|
45
|
+
contributes(Capabilities.Toolkit, Toolkit),
|
|
46
|
+
contributes(Capabilities.ToolkitHandler, Toolkit.layer(context)),
|
|
47
|
+
];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
import { IntentPlugin } from '@dxos/app-framework';
|
|
11
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
|
+
import { Markdown } from '@dxos/plugin-markdown/types';
|
|
13
|
+
import { faker } from '@dxos/random';
|
|
14
|
+
import { CardContainer } from '@dxos/react-ui-stack/testing';
|
|
15
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
16
|
+
|
|
17
|
+
import { translations } from '../../translations';
|
|
18
|
+
|
|
19
|
+
import { MarkdownCard } from './MarkdownCard';
|
|
20
|
+
|
|
21
|
+
faker.seed(1234);
|
|
22
|
+
|
|
23
|
+
const meta: Meta<typeof MarkdownCard> = {
|
|
24
|
+
title: 'plugins/plugin-markdown/Card',
|
|
25
|
+
component: MarkdownCard,
|
|
26
|
+
render: ({ role, subject, ...args }) => {
|
|
27
|
+
return (
|
|
28
|
+
<CardContainer icon='ph--text-aa--regular' role={role}>
|
|
29
|
+
<MarkdownCard role={role} subject={subject} {...args} />
|
|
30
|
+
</CardContainer>
|
|
31
|
+
);
|
|
32
|
+
},
|
|
33
|
+
decorators: [
|
|
34
|
+
withPluginManager({
|
|
35
|
+
plugins: [IntentPlugin()],
|
|
36
|
+
}),
|
|
37
|
+
withTheme,
|
|
38
|
+
withLayout(),
|
|
39
|
+
],
|
|
40
|
+
parameters: {
|
|
41
|
+
layout: 'centered',
|
|
42
|
+
translations,
|
|
43
|
+
},
|
|
44
|
+
tags: ['cards'],
|
|
45
|
+
} satisfies Meta<typeof MarkdownCard>;
|
|
46
|
+
|
|
47
|
+
export default meta;
|
|
48
|
+
|
|
49
|
+
type Story = StoryObj<typeof meta>;
|
|
50
|
+
|
|
51
|
+
export const Popover: Story = {
|
|
52
|
+
args: {
|
|
53
|
+
role: 'card--popover',
|
|
54
|
+
subject: Markdown.makeDocument({
|
|
55
|
+
name: faker.lorem.words(3),
|
|
56
|
+
content: faker.lorem.paragraphs(3),
|
|
57
|
+
}),
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const Intrinsic: Story = {
|
|
62
|
+
args: {
|
|
63
|
+
role: 'card--intrinsic',
|
|
64
|
+
subject: Markdown.makeDocument({
|
|
65
|
+
name: faker.lorem.words(3),
|
|
66
|
+
content: faker.lorem.paragraphs(3),
|
|
67
|
+
}),
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const Extrinsic: Story = {
|
|
72
|
+
args: {
|
|
73
|
+
role: 'card--extrinsic',
|
|
74
|
+
subject: Markdown.makeDocument({
|
|
75
|
+
name: faker.lorem.words(3),
|
|
76
|
+
content: faker.lorem.paragraphs(3),
|
|
77
|
+
}),
|
|
78
|
+
},
|
|
79
|
+
};
|
package/src/components/{MarkdownPreview/MarkdownPreview.tsx → MarkdownCard/MarkdownCard.tsx}
RENAMED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { pipe } from 'effect';
|
|
6
6
|
import React, { useCallback } from 'react';
|
|
7
7
|
|
|
8
|
-
import { chain, createIntent,
|
|
8
|
+
import { LayoutAction, chain, createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
9
9
|
import { Obj } from '@dxos/echo';
|
|
10
10
|
import { type PreviewProps } from '@dxos/plugin-preview';
|
|
11
11
|
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
@@ -13,13 +13,13 @@ import { Button, Icon, useTranslation } from '@dxos/react-ui';
|
|
|
13
13
|
import { Card } from '@dxos/react-ui-stack';
|
|
14
14
|
import { DataType } from '@dxos/schema';
|
|
15
15
|
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { meta } from '../../meta';
|
|
17
|
+
import { Markdown } from '../../types';
|
|
18
18
|
import { getAbstract, getFallbackName } from '../../util';
|
|
19
19
|
|
|
20
20
|
// TODO(burdon): Factor out.
|
|
21
|
-
const getTitle = (subject:
|
|
22
|
-
if (Obj.instanceOf(
|
|
21
|
+
const getTitle = (subject: Markdown.Document | DataType.Text, fallback: string) => {
|
|
22
|
+
if (Obj.instanceOf(Markdown.Document, subject)) {
|
|
23
23
|
return subject.name ?? subject.fallbackName ?? getFallbackName(subject.content?.target?.content ?? fallback);
|
|
24
24
|
} else if (Obj.instanceOf(DataType.Text, subject)) {
|
|
25
25
|
return getFallbackName(subject.content);
|
|
@@ -27,17 +27,19 @@ const getTitle = (subject: DocumentType | DataType.Text, fallback: string) => {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
// TODO(burdon): Factor out.
|
|
30
|
-
const getSnippet = (subject:
|
|
31
|
-
if (Obj.instanceOf(
|
|
30
|
+
const getSnippet = (subject: Markdown.Document | DataType.Text, fallback: string) => {
|
|
31
|
+
if (Obj.instanceOf(Markdown.Document, subject)) {
|
|
32
32
|
return getAbstract(subject.content?.target?.content ?? fallback);
|
|
33
33
|
} else if (Obj.instanceOf(DataType.Text, subject)) {
|
|
34
34
|
return getAbstract(subject.content);
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
export
|
|
38
|
+
export type MarkdownCardProps = PreviewProps<Markdown.Document | DataType.Text>;
|
|
39
|
+
|
|
40
|
+
export const MarkdownCard = ({ subject, role }: MarkdownCardProps) => {
|
|
39
41
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
40
|
-
const { t } = useTranslation(
|
|
42
|
+
const { t } = useTranslation(meta.id);
|
|
41
43
|
const snippet = getSnippet(subject, t('fallback abstract'));
|
|
42
44
|
|
|
43
45
|
// TODO(wittjosiah): Factor out so this component isn't dependent on the app framework.
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
import React, { useMemo } from 'react';
|
|
9
9
|
|
|
10
|
-
import { Capabilities,
|
|
10
|
+
import { Capabilities, IntentPlugin, SettingsPlugin, Surface, contributes } from '@dxos/app-framework';
|
|
11
11
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
12
|
import { todo } from '@dxos/debug';
|
|
13
|
-
import {
|
|
13
|
+
import { Query, Type } from '@dxos/echo';
|
|
14
14
|
import { AttentionPlugin } from '@dxos/plugin-attention';
|
|
15
15
|
import { ClientPlugin } from '@dxos/plugin-client';
|
|
16
16
|
import { GraphPlugin } from '@dxos/plugin-graph';
|
|
@@ -22,12 +22,12 @@ import { faker } from '@dxos/random';
|
|
|
22
22
|
import { useQuery, useSpace } from '@dxos/react-client/echo';
|
|
23
23
|
import { defaultTx } from '@dxos/react-ui-theme';
|
|
24
24
|
import { DataType } from '@dxos/schema';
|
|
25
|
-
import {
|
|
25
|
+
import { Testing, type ValueGenerator, createObjectFactory } from '@dxos/schema/testing';
|
|
26
26
|
import { withLayout } from '@dxos/storybook-utils';
|
|
27
27
|
|
|
28
28
|
import { MarkdownPlugin } from '../MarkdownPlugin';
|
|
29
29
|
import { translations } from '../translations';
|
|
30
|
-
import {
|
|
30
|
+
import { Markdown } from '../types';
|
|
31
31
|
|
|
32
32
|
faker.seed(1);
|
|
33
33
|
|
|
@@ -35,13 +35,13 @@ const generator: ValueGenerator = faker as any;
|
|
|
35
35
|
|
|
36
36
|
const DefaultStory = () => {
|
|
37
37
|
const space = useSpace();
|
|
38
|
-
const [doc] = useQuery(space, Query.type(
|
|
38
|
+
const [doc] = useQuery(space, Query.type(Markdown.Document));
|
|
39
39
|
const data = useMemo(() => ({ subject: doc }), [doc]);
|
|
40
40
|
|
|
41
41
|
return <Surface role='article' data={data} />;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
const meta
|
|
44
|
+
const meta = {
|
|
45
45
|
title: 'plugins/plugin-markdown/MarkdownContainer',
|
|
46
46
|
render: DefaultStory,
|
|
47
47
|
decorators: [
|
|
@@ -51,16 +51,13 @@ const meta: Meta<typeof DefaultStory> = {
|
|
|
51
51
|
ThemePlugin({ tx: defaultTx }),
|
|
52
52
|
StorybookLayoutPlugin(),
|
|
53
53
|
ClientPlugin({
|
|
54
|
-
types: [
|
|
55
|
-
onClientInitialized: async (
|
|
54
|
+
types: [Markdown.Document, DataType.Text, Testing.Contact],
|
|
55
|
+
onClientInitialized: async ({ client }) => {
|
|
56
56
|
await client.halo.createIdentity();
|
|
57
57
|
await client.spaces.waitUntilReady();
|
|
58
58
|
await client.spaces.default.waitUntilReady();
|
|
59
59
|
const space = client.spaces.default;
|
|
60
|
-
const doc =
|
|
61
|
-
name: 'Test',
|
|
62
|
-
content: Ref.make(Obj.make(DataType.Text, { content: '# Test\n\n' })),
|
|
63
|
-
});
|
|
60
|
+
const doc = Markdown.makeDocument({ name: 'Test', content: '# Test\n\n' });
|
|
64
61
|
space.db.add(doc);
|
|
65
62
|
const createObjects = createObjectFactory(space.db, generator);
|
|
66
63
|
await createObjects([{ type: Testing.Contact, count: 10 }]);
|
|
@@ -94,10 +91,10 @@ const meta: Meta<typeof DefaultStory> = {
|
|
|
94
91
|
translations,
|
|
95
92
|
controls: { disable: true },
|
|
96
93
|
},
|
|
97
|
-
}
|
|
94
|
+
} satisfies Meta<typeof Capabilities>;
|
|
98
95
|
|
|
99
96
|
export default meta;
|
|
100
97
|
|
|
101
|
-
type Story =
|
|
98
|
+
type Story = StoryObj<typeof meta>;
|
|
102
99
|
|
|
103
100
|
export const Default: Story = {};
|
|
@@ -16,29 +16,30 @@ import { type SelectionManager } from '@dxos/react-ui-attention';
|
|
|
16
16
|
import {
|
|
17
17
|
type CommandMenuGroup,
|
|
18
18
|
type CommandMenuItem,
|
|
19
|
-
insertAtCursor,
|
|
20
|
-
insertAtLineStart,
|
|
21
19
|
type PreviewLinkRef,
|
|
22
20
|
type PreviewOptions,
|
|
21
|
+
insertAtCursor,
|
|
22
|
+
insertAtLineStart,
|
|
23
23
|
} from '@dxos/react-ui-editor';
|
|
24
24
|
import { DataType } from '@dxos/schema';
|
|
25
25
|
|
|
26
|
-
import { MarkdownEditor, type MarkdownEditorProps } from './MarkdownEditor';
|
|
27
26
|
import { useExtensions } from '../extensions';
|
|
28
|
-
import {
|
|
27
|
+
import { Markdown } from '../types';
|
|
29
28
|
import { getFallbackName } from '../util';
|
|
30
29
|
|
|
30
|
+
import { MarkdownEditor, type MarkdownEditorProps } from './MarkdownEditor';
|
|
31
|
+
|
|
31
32
|
export type MarkdownContainerProps = Pick<
|
|
32
33
|
MarkdownEditorProps,
|
|
33
34
|
'role' | 'extensionProviders' | 'viewMode' | 'editorStateStore' | 'onViewModeChange'
|
|
34
35
|
> & {
|
|
35
36
|
id: string;
|
|
36
|
-
object:
|
|
37
|
-
settings:
|
|
37
|
+
object: Markdown.Document | DataType.Text | any;
|
|
38
|
+
settings: Markdown.Settings;
|
|
38
39
|
selectionManager?: SelectionManager;
|
|
39
40
|
};
|
|
40
41
|
|
|
41
|
-
const MarkdownContainer = ({
|
|
42
|
+
export const MarkdownContainer = ({
|
|
42
43
|
id,
|
|
43
44
|
role,
|
|
44
45
|
object,
|
|
@@ -50,7 +51,7 @@ const MarkdownContainer = ({
|
|
|
50
51
|
}: MarkdownContainerProps) => {
|
|
51
52
|
const { t } = useTranslation();
|
|
52
53
|
const scrollPastEnd = role === 'article';
|
|
53
|
-
const doc = Obj.instanceOf(
|
|
54
|
+
const doc = Obj.instanceOf(Markdown.Document, object) ? object : undefined;
|
|
54
55
|
const text = Obj.instanceOf(DataType.Text, object) ? object : undefined;
|
|
55
56
|
const [previewBlocks, setPreviewBlocks] = useState<{ link: PreviewLinkRef; el: HTMLElement }[]>([]);
|
|
56
57
|
const previewOptions = useMemo(
|
|
@@ -121,7 +122,7 @@ const MarkdownContainer = ({
|
|
|
121
122
|
label,
|
|
122
123
|
icon: metadata.icon,
|
|
123
124
|
onSelect: (view, head) => {
|
|
124
|
-
const link = `[${label}]
|
|
125
|
+
const link = `[${label}](${Obj.getDXN(object)})`;
|
|
125
126
|
if (query?.startsWith('@')) {
|
|
126
127
|
insertAtLineStart(view, head, `!${link}\n`);
|
|
127
128
|
} else {
|
|
@@ -199,7 +200,7 @@ const PreviewBlock = ({ link, el }: { link: PreviewLinkRef; el: HTMLElement }) =
|
|
|
199
200
|
|
|
200
201
|
type DocumentEditorProps = Omit<MarkdownContainerProps, 'object' | 'extensionProviders' | 'editorStateStore'> &
|
|
201
202
|
Pick<MarkdownEditorProps, 'id' | 'scrollPastEnd' | 'extensions' | 'onLinkQuery'> & {
|
|
202
|
-
document:
|
|
203
|
+
document: Markdown.Document;
|
|
203
204
|
};
|
|
204
205
|
|
|
205
206
|
export const DocumentEditor = ({ id, document: doc, settings, viewMode, ...props }: DocumentEditorProps) => {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
import React, { useMemo } from 'react';
|
|
9
9
|
|
|
10
10
|
import { IntentPlugin } from '@dxos/app-framework';
|
|
@@ -14,9 +14,10 @@ import { withAttention } from '@dxos/react-ui-attention/testing';
|
|
|
14
14
|
import { automerge, translations as editorTranslations } from '@dxos/react-ui-editor';
|
|
15
15
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
16
16
|
|
|
17
|
-
import { MarkdownEditor, type MarkdownEditorProps } from './MarkdownEditor';
|
|
18
17
|
import { translations } from '../../translations';
|
|
19
18
|
|
|
19
|
+
import { MarkdownEditor, type MarkdownEditorProps } from './MarkdownEditor';
|
|
20
|
+
|
|
20
21
|
const content = Array.from({ length: 100 }, (_, i) => `Line ${i + 1}`).join('\n');
|
|
21
22
|
|
|
22
23
|
type StoryProps = MarkdownEditorProps & {
|
|
@@ -30,9 +31,9 @@ const DefaultStory = ({ content = '# Test', toolbar }: StoryProps) => {
|
|
|
30
31
|
return <MarkdownEditor id='test' initialValue={doc.content} extensions={extensions} toolbar={toolbar} />;
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
const meta
|
|
34
|
+
const meta = {
|
|
34
35
|
title: 'plugins/plugin-markdown/MarkdownEditor',
|
|
35
|
-
component: MarkdownEditor,
|
|
36
|
+
component: MarkdownEditor as any,
|
|
36
37
|
render: DefaultStory,
|
|
37
38
|
decorators: [
|
|
38
39
|
withPluginManager({ plugins: [IntentPlugin()] }),
|
|
@@ -43,17 +44,19 @@ const meta: Meta<typeof MarkdownEditor> = {
|
|
|
43
44
|
parameters: {
|
|
44
45
|
translations: [...translations, ...editorTranslations],
|
|
45
46
|
},
|
|
46
|
-
}
|
|
47
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
47
48
|
|
|
48
49
|
export default meta;
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
type Story = StoryObj<typeof meta>;
|
|
52
|
+
|
|
53
|
+
export const Default: Story = {
|
|
51
54
|
args: {
|
|
52
55
|
content,
|
|
53
56
|
},
|
|
54
57
|
};
|
|
55
58
|
|
|
56
|
-
export const WithToolbar = {
|
|
59
|
+
export const WithToolbar: Story = {
|
|
57
60
|
args: {
|
|
58
61
|
toolbar: true,
|
|
59
62
|
content,
|
|
@@ -3,26 +3,26 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type EditorView } from '@codemirror/view';
|
|
6
|
-
import React, { forwardRef,
|
|
6
|
+
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
|
7
7
|
import { useDropzone } from 'react-dropzone';
|
|
8
8
|
|
|
9
9
|
import { type FileInfo } from '@dxos/app-framework';
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
11
|
import { toLocalizedString, useThemeContext, useTranslation } from '@dxos/react-ui';
|
|
12
12
|
import {
|
|
13
|
-
CommandMenu,
|
|
14
13
|
type CommandMenuGroup,
|
|
14
|
+
CommandMenuProvider,
|
|
15
15
|
type DNDOptions,
|
|
16
|
+
Domino,
|
|
16
17
|
type EditorInputMode,
|
|
17
18
|
type EditorSelectionState,
|
|
18
19
|
type EditorStateStore,
|
|
19
20
|
EditorToolbar,
|
|
20
21
|
type EditorToolbarActionGraphProps,
|
|
21
22
|
type EditorViewMode,
|
|
22
|
-
|
|
23
|
+
type UseCommandMenuOptions,
|
|
23
24
|
type UseTextEditorProps,
|
|
24
25
|
addLink,
|
|
25
|
-
createElement,
|
|
26
26
|
coreSlashCommands,
|
|
27
27
|
createBasicExtensions,
|
|
28
28
|
createMarkdownExtensions,
|
|
@@ -34,26 +34,25 @@ import {
|
|
|
34
34
|
linkSlashCommands,
|
|
35
35
|
processEditorPayload,
|
|
36
36
|
stackItemContentEditorClassNames,
|
|
37
|
+
useCommandMenu,
|
|
37
38
|
useEditorToolbarState,
|
|
38
39
|
useFormattingState,
|
|
39
40
|
useTextEditor,
|
|
40
|
-
useCommandMenu,
|
|
41
|
-
type UseCommandMenuOptions,
|
|
42
41
|
} from '@dxos/react-ui-editor';
|
|
43
42
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
44
|
-
import {
|
|
43
|
+
import { isNonNullable, isNotFalsy } from '@dxos/util';
|
|
45
44
|
|
|
46
45
|
import { useSelectCurrentThread } from '../../hooks';
|
|
47
|
-
import {
|
|
46
|
+
import { meta } from '../../meta';
|
|
48
47
|
import { type MarkdownPluginState } from '../../types';
|
|
49
48
|
|
|
50
49
|
export type MarkdownEditorProps = {
|
|
51
50
|
id: string;
|
|
52
51
|
role?: string;
|
|
52
|
+
toolbar?: boolean;
|
|
53
53
|
inputMode?: EditorInputMode;
|
|
54
54
|
scrollPastEnd?: boolean;
|
|
55
55
|
slashCommandGroups?: CommandMenuGroup[];
|
|
56
|
-
toolbar?: boolean;
|
|
57
56
|
customActions?: EditorToolbarActionGraphProps['customActions'];
|
|
58
57
|
// TODO(wittjosiah): Generalize custom toolbar actions (e.g. comment, upload, etc.)
|
|
59
58
|
viewMode?: EditorViewMode;
|
|
@@ -70,7 +69,7 @@ export type MarkdownEditorProps = {
|
|
|
70
69
|
* This allows it to be used as a common editor for markdown content on arbitrary backends (e.g. files).
|
|
71
70
|
*/
|
|
72
71
|
export const MarkdownEditor = ({
|
|
73
|
-
extensions:
|
|
72
|
+
extensions: extensionsParam,
|
|
74
73
|
slashCommandGroups,
|
|
75
74
|
onLinkQuery,
|
|
76
75
|
...props
|
|
@@ -100,32 +99,30 @@ export const MarkdownEditor = ({
|
|
|
100
99
|
trigger,
|
|
101
100
|
placeholder: {
|
|
102
101
|
delay: 3_000,
|
|
103
|
-
content: () =>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
102
|
+
content: () =>
|
|
103
|
+
Domino.of('div')
|
|
104
|
+
.child(
|
|
105
|
+
Domino.of('span').text('Press'),
|
|
106
|
+
...trigger.map((text) =>
|
|
107
|
+
Domino.of('span')
|
|
108
|
+
.classNames('border border-separator rounded-sm mx-1 px-1.5 pt-[1px] pb-[2px]')
|
|
109
|
+
.text(text),
|
|
110
|
+
),
|
|
111
|
+
Domino.of('span').text('for commands.'),
|
|
112
|
+
)
|
|
113
|
+
.build(),
|
|
115
114
|
},
|
|
116
115
|
getMenu,
|
|
117
116
|
};
|
|
118
117
|
}, [getMenu]);
|
|
119
118
|
|
|
120
|
-
const { commandMenu, groupsRef,
|
|
121
|
-
|
|
122
|
-
const extensions = useMemo(() => [_extensions, commandMenu].filter(isNotFalsy), [_extensions, commandMenu]);
|
|
119
|
+
const { commandMenu, groupsRef, ...commandMenuProps } = useCommandMenu(options);
|
|
120
|
+
const extensions = useMemo(() => [extensionsParam, commandMenu].filter(isNotFalsy), [extensionsParam, commandMenu]);
|
|
123
121
|
|
|
124
122
|
return (
|
|
125
|
-
<
|
|
123
|
+
<CommandMenuProvider groups={groupsRef.current} {...commandMenuProps}>
|
|
126
124
|
<MarkdownEditorImpl ref={viewRef} {...props} extensions={extensions} />
|
|
127
|
-
|
|
128
|
-
</RefPopover>
|
|
125
|
+
</CommandMenuProvider>
|
|
129
126
|
);
|
|
130
127
|
};
|
|
131
128
|
|
|
@@ -147,7 +144,7 @@ const MarkdownEditorImpl = forwardRef<EditorView | undefined, MarkdownEditorProp
|
|
|
147
144
|
},
|
|
148
145
|
forwardedRef,
|
|
149
146
|
) => {
|
|
150
|
-
const { t } = useTranslation(
|
|
147
|
+
const { t } = useTranslation(meta.id);
|
|
151
148
|
const { themeMode } = useThemeContext();
|
|
152
149
|
const toolbarState = useEditorToolbarState({ viewMode });
|
|
153
150
|
const formattingObserver = useFormattingState(toolbarState);
|
|
@@ -185,8 +182,9 @@ const MarkdownEditorImpl = forwardRef<EditorView | undefined, MarkdownEditorProp
|
|
|
185
182
|
readOnly: viewMode === 'readonly',
|
|
186
183
|
placeholder: t('editor placeholder'),
|
|
187
184
|
scrollPastEnd: role === 'section' ? false : scrollPastEnd,
|
|
185
|
+
search: true,
|
|
188
186
|
}),
|
|
189
|
-
createMarkdownExtensions(
|
|
187
|
+
createMarkdownExtensions(),
|
|
190
188
|
createThemeExtensions({ themeMode, syntaxHighlighting: true, slots: editorSlots }),
|
|
191
189
|
editorGutter,
|
|
192
190
|
role !== 'section' && onFileUpload && dropFile({ onDrop: handleDrop }),
|