@dxos/react-ui-editor 0.8.4-main.5acf9ea → 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/index.mjs +768 -452
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/node-esm/index.mjs +768 -452
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs.map +2 -2
- package/dist/types/src/components/Editor/Editor.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/EditorToolbar.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/blocks.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/formatting.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/headings.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/image.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/lists.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/search.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/util.d.ts +2 -2
- package/dist/types/src/components/EditorToolbar/util.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/view-mode.d.ts +1 -1
- package/dist/types/src/components/EditorToolbar/view-mode.d.ts.map +1 -1
- package/dist/types/src/components/Popover/CommandMenu.d.ts.map +1 -1
- package/dist/types/src/defaults.d.ts.map +1 -1
- package/dist/types/src/extensions/autocomplete.d.ts +1 -1
- package/dist/types/src/extensions/autocomplete.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/automerge.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/automerge.stories.d.ts +9 -18
- package/dist/types/src/extensions/automerge/automerge.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/defs.d.ts +1 -1
- package/dist/types/src/extensions/automerge/defs.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/sync.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/update-automerge.d.ts.map +1 -1
- package/dist/types/src/extensions/command/action.d.ts +1 -1
- package/dist/types/src/extensions/command/action.d.ts.map +1 -1
- package/dist/types/src/extensions/command/command-menu.d.ts +1 -1
- package/dist/types/src/extensions/command/command-menu.d.ts.map +1 -1
- package/dist/types/src/extensions/command/command.d.ts.map +1 -1
- package/dist/types/src/extensions/command/hint.d.ts.map +1 -1
- package/dist/types/src/extensions/command/state.d.ts +1 -1
- package/dist/types/src/extensions/command/state.d.ts.map +1 -1
- package/dist/types/src/extensions/command/typeahead.d.ts.map +1 -1
- package/dist/types/src/extensions/command/useCommandMenu.d.ts +1 -1
- package/dist/types/src/extensions/command/useCommandMenu.d.ts.map +1 -1
- package/dist/types/src/extensions/comments.d.ts +1 -1
- package/dist/types/src/extensions/comments.d.ts.map +1 -1
- package/dist/types/src/extensions/dnd.d.ts.map +1 -1
- package/dist/types/src/extensions/factories.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/action.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/bundle.d.ts +2 -0
- package/dist/types/src/extensions/markdown/bundle.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/changes.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/decorate.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/formatting.d.ts +1 -1
- package/dist/types/src/extensions/markdown/formatting.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/formatting.test.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/highlight.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/outliner.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/selection.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/tree.d.ts +1 -1
- package/dist/types/src/extensions/outliner/tree.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextEditor.d.ts.map +1 -1
- package/dist/types/src/stories/Command.stories.d.ts +12 -4
- package/dist/types/src/stories/Command.stories.d.ts.map +1 -1
- package/dist/types/src/stories/CommandMenu.stories.d.ts +10 -3
- package/dist/types/src/stories/CommandMenu.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Comments.stories.d.ts +21 -9
- package/dist/types/src/stories/Comments.stories.d.ts.map +1 -1
- package/dist/types/src/stories/EditorToolbar.stories.d.ts +39 -2
- package/dist/types/src/stories/EditorToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Experimental.stories.d.ts +22 -12
- package/dist/types/src/stories/Experimental.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Markdown.stories.d.ts +32 -42
- package/dist/types/src/stories/Markdown.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Outliner.stories.d.ts +15 -20
- package/dist/types/src/stories/Outliner.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Preview.stories.d.ts +21 -6
- package/dist/types/src/stories/Preview.stories.d.ts.map +1 -1
- package/dist/types/src/stories/TextEditor.stories.d.ts +38 -51
- package/dist/types/src/stories/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/stories/components/EditorStory.d.ts +3 -6
- package/dist/types/src/stories/components/EditorStory.d.ts.map +1 -1
- package/dist/types/src/styles/theme.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts +1 -0
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -1
- package/dist/types/src/util/cursor.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +44 -44
- package/src/components/Editor/Editor.tsx +1 -1
- package/src/components/EditorToolbar/EditorToolbar.tsx +40 -30
- package/src/components/EditorToolbar/blocks.ts +21 -24
- package/src/components/EditorToolbar/formatting.ts +22 -25
- package/src/components/EditorToolbar/headings.ts +10 -5
- package/src/components/EditorToolbar/image.ts +8 -4
- package/src/components/EditorToolbar/lists.ts +16 -19
- package/src/components/EditorToolbar/search.ts +8 -4
- package/src/components/EditorToolbar/util.ts +16 -5
- package/src/components/EditorToolbar/view-mode.ts +11 -6
- package/src/components/Popover/CommandMenu.tsx +3 -3
- package/src/components/Popover/RefDropdownMenu.tsx +1 -1
- package/src/components/Popover/RefPopover.tsx +4 -4
- package/src/defaults.ts +5 -2
- package/src/extensions/autocomplete.ts +3 -3
- package/src/extensions/automerge/automerge.stories.tsx +25 -18
- package/src/extensions/automerge/automerge.ts +4 -3
- package/src/extensions/automerge/defs.ts +1 -1
- package/src/extensions/automerge/sync.ts +1 -1
- package/src/extensions/automerge/update-automerge.ts +1 -1
- package/src/extensions/awareness/awareness.ts +2 -2
- package/src/extensions/command/action.ts +1 -1
- package/src/extensions/command/command-menu.ts +4 -3
- package/src/extensions/command/command.ts +3 -3
- package/src/extensions/command/hint.ts +2 -1
- package/src/extensions/command/placeholder.ts +1 -1
- package/src/extensions/command/state.ts +4 -3
- package/src/extensions/command/typeahead.ts +2 -2
- package/src/extensions/command/useCommandMenu.ts +2 -1
- package/src/extensions/comments.ts +13 -12
- package/src/extensions/dnd.ts +1 -1
- package/src/extensions/factories.ts +4 -3
- package/src/extensions/markdown/action.ts +2 -1
- package/src/extensions/markdown/bundle.ts +4 -1
- package/src/extensions/markdown/changes.ts +1 -1
- package/src/extensions/markdown/decorate.ts +7 -6
- package/src/extensions/markdown/formatting.test.ts +6 -6
- package/src/extensions/markdown/formatting.ts +3 -3
- package/src/extensions/markdown/highlight.ts +1 -1
- package/src/extensions/mention.ts +1 -1
- package/src/extensions/outliner/outliner.test.ts +3 -2
- package/src/extensions/outliner/outliner.ts +4 -3
- package/src/extensions/outliner/selection.ts +1 -1
- package/src/extensions/outliner/tree.test.ts +2 -1
- package/src/extensions/outliner/tree.ts +1 -1
- package/src/hooks/useTextEditor.ts +3 -3
- package/src/stories/Command.stories.tsx +12 -8
- package/src/stories/CommandMenu.stories.tsx +16 -14
- package/src/stories/Comments.stories.tsx +10 -6
- package/src/stories/EditorToolbar.stories.tsx +7 -7
- package/src/stories/Experimental.stories.tsx +12 -8
- package/src/stories/Markdown.stories.tsx +21 -17
- package/src/stories/Outliner.stories.tsx +14 -10
- package/src/stories/Preview.stories.tsx +27 -25
- package/src/stories/TextEditor.stories.tsx +36 -32
- package/src/stories/components/EditorStory.tsx +8 -9
- package/src/styles/theme.ts +8 -6
- package/src/testing/util.ts +2 -0
- package/src/translations.ts +1 -1
- package/src/util/cursor.ts +2 -1
@@ -4,19 +4,21 @@
|
|
4
4
|
|
5
5
|
import '@dxos-theme';
|
6
6
|
|
7
|
-
import
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
8
|
+
import React, { type KeyboardEvent, useState } from 'react';
|
8
9
|
|
9
|
-
import { Button, Icon, Input
|
10
|
+
import { Button, DropdownMenu, Icon, Input } from '@dxos/react-ui';
|
10
11
|
import { mx } from '@dxos/react-ui-theme';
|
11
|
-
import { withLayout, withTheme
|
12
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
12
13
|
|
13
|
-
import { EditorStory } from './components';
|
14
14
|
import { RefDropdownMenu } from '../components';
|
15
15
|
import { editorWidth } from '../defaults';
|
16
|
-
import {
|
16
|
+
import { type Action, command, floatingMenu } from '../extensions';
|
17
17
|
import { str } from '../testing';
|
18
18
|
import { createRenderer } from '../util';
|
19
19
|
|
20
|
+
import { EditorStory } from './components';
|
21
|
+
|
20
22
|
const CommandDialog = ({ onAction }: { onAction: (action?: Action) => void }) => {
|
21
23
|
const [text, setText] = useState('');
|
22
24
|
|
@@ -64,7 +66,7 @@ const CommandDialog = ({ onAction }: { onAction: (action?: Action) => void }) =>
|
|
64
66
|
);
|
65
67
|
};
|
66
68
|
|
67
|
-
const meta
|
69
|
+
const meta = {
|
68
70
|
title: 'ui/react-ui-editor/Command',
|
69
71
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
70
72
|
render: () => (
|
@@ -90,8 +92,10 @@ const meta: Meta<typeof EditorStory> = {
|
|
90
92
|
</RefDropdownMenu.Provider>
|
91
93
|
),
|
92
94
|
parameters: { layout: 'fullscreen' },
|
93
|
-
}
|
95
|
+
} satisfies Meta<typeof Button>;
|
94
96
|
|
95
97
|
export default meta;
|
96
98
|
|
97
|
-
|
99
|
+
type Story = StoryObj<typeof meta>;
|
100
|
+
|
101
|
+
export const Default: Story = {};
|
@@ -5,16 +5,15 @@
|
|
5
5
|
import '@dxos-theme';
|
6
6
|
|
7
7
|
import { type EditorView } from '@codemirror/view';
|
8
|
-
import { type StoryObj } from '@storybook/react-vite';
|
8
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
9
9
|
import React, { useCallback, useRef } from 'react';
|
10
10
|
|
11
11
|
import { Obj, Query } from '@dxos/echo';
|
12
12
|
import { faker } from '@dxos/random';
|
13
13
|
import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
|
14
|
-
import {
|
15
|
-
import { withLayout, withTheme
|
14
|
+
import { Testing, type ValueGenerator, createObjectFactory } from '@dxos/schema/testing';
|
15
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
16
16
|
|
17
|
-
import { EditorStory, names } from './components';
|
18
17
|
import {
|
19
18
|
CommandMenu,
|
20
19
|
type CommandMenuGroup,
|
@@ -26,10 +25,12 @@ import {
|
|
26
25
|
insertAtLineStart,
|
27
26
|
linkSlashCommands,
|
28
27
|
} from '../components';
|
29
|
-
import {
|
28
|
+
import { type UseCommandMenuOptions, useCommandMenu } from '../extensions';
|
30
29
|
import { str } from '../testing';
|
31
30
|
import { createElement } from '../util';
|
32
31
|
|
32
|
+
import { EditorStory, names } from './components';
|
33
|
+
|
33
34
|
const generator: ValueGenerator = faker as any;
|
34
35
|
|
35
36
|
type StoryProps = Omit<UseCommandMenuOptions, 'viewRef'> & { text: string };
|
@@ -63,18 +64,18 @@ const groups: CommandMenuGroup[] = [
|
|
63
64
|
},
|
64
65
|
];
|
65
66
|
|
66
|
-
const meta
|
67
|
+
const meta = {
|
67
68
|
title: 'ui/react-ui-editor/CommandMenu',
|
69
|
+
render: DefaultStory,
|
68
70
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
69
|
-
render: (args) => <DefaultStory {...args} />,
|
70
71
|
parameters: {
|
71
72
|
layout: 'fullscreen',
|
72
73
|
},
|
73
|
-
}
|
74
|
+
} satisfies Meta<typeof DefaultStory>;
|
74
75
|
|
75
76
|
export default meta;
|
76
77
|
|
77
|
-
type Story = StoryObj<
|
78
|
+
type Story = StoryObj<typeof meta>;
|
78
79
|
|
79
80
|
// TODO(burdon): Not working.
|
80
81
|
export const Slash: Story = {
|
@@ -99,7 +100,7 @@ export const Slash: Story = {
|
|
99
100
|
};
|
100
101
|
|
101
102
|
export const Link: Story = {
|
102
|
-
render: (args) => {
|
103
|
+
render: (args: StoryProps) => {
|
103
104
|
const { space } = useClientProvider();
|
104
105
|
const getMenu = useCallback(
|
105
106
|
async (trigger: string, query?: string): Promise<CommandMenuGroup[]> => {
|
@@ -139,10 +140,6 @@ export const Link: Story = {
|
|
139
140
|
|
140
141
|
return <DefaultStory {...args} getMenu={getMenu} />;
|
141
142
|
},
|
142
|
-
args: {
|
143
|
-
text: str('# Link', '', names.join(' '), ''),
|
144
|
-
trigger: ['/', '@'],
|
145
|
-
},
|
146
143
|
decorators: [
|
147
144
|
withClientProvider({
|
148
145
|
createSpace: true,
|
@@ -156,4 +153,9 @@ export const Link: Story = {
|
|
156
153
|
},
|
157
154
|
}),
|
158
155
|
],
|
156
|
+
args: {
|
157
|
+
text: str('# Link', '', names.join(' '), ''),
|
158
|
+
trigger: ['/', '@'],
|
159
|
+
getMenu: () => [],
|
160
|
+
},
|
159
161
|
};
|
@@ -5,33 +5,37 @@
|
|
5
5
|
import '@dxos-theme';
|
6
6
|
|
7
7
|
import { effect, useSignal } from '@preact/signals-react';
|
8
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
8
9
|
import React, { type FC } from 'react';
|
9
10
|
|
10
11
|
import { keySymbols, parseShortcut } from '@dxos/keyboard';
|
11
12
|
import { PublicKey } from '@dxos/keys';
|
12
13
|
import { log } from '@dxos/log';
|
13
|
-
import { withLayout, withTheme
|
14
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
14
15
|
|
15
|
-
import { EditorStory, content, longText } from './components';
|
16
16
|
import { annotations, comments, createExternalCommentSync } from '../extensions';
|
17
17
|
import { str } from '../testing';
|
18
18
|
import { type Comment } from '../types';
|
19
19
|
import { createRenderer } from '../util';
|
20
20
|
|
21
|
-
|
21
|
+
import { EditorStory, content, longText } from './components';
|
22
|
+
|
23
|
+
const meta = {
|
22
24
|
title: 'ui/react-ui-editor/Comments',
|
23
25
|
component: EditorStory,
|
24
26
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
25
27
|
parameters: { layout: 'fullscreen' },
|
26
|
-
}
|
28
|
+
} satisfies Meta<typeof EditorStory>;
|
27
29
|
|
28
30
|
export default meta;
|
29
31
|
|
32
|
+
type Story = StoryObj<typeof meta>;
|
33
|
+
|
30
34
|
//
|
31
35
|
// Comments
|
32
36
|
//
|
33
37
|
|
34
|
-
export const Comments = {
|
38
|
+
export const Comments: Story = {
|
35
39
|
render: () => {
|
36
40
|
const _comments = useSignal<Comment[]>([]);
|
37
41
|
return (
|
@@ -91,7 +95,7 @@ const CommentTooltip: FC<{ shortcut: string }> = ({ shortcut }) => {
|
|
91
95
|
// Annotations
|
92
96
|
//
|
93
97
|
|
94
|
-
export const Annotations = {
|
98
|
+
export const Annotations: Story = {
|
95
99
|
render: () => (
|
96
100
|
<EditorStory text={str('# Annotations', '', longText)} extensions={[annotations({ match: /volup/gi })]} />
|
97
101
|
),
|
@@ -4,26 +4,26 @@
|
|
4
4
|
|
5
5
|
import '@dxos-theme';
|
6
6
|
|
7
|
-
import { type StoryObj } from '@storybook/react-vite';
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
8
8
|
import React, { useCallback, useState } from 'react';
|
9
9
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
11
11
|
import { useThemeContext } from '@dxos/react-ui';
|
12
12
|
import { attentionSurface, mx } from '@dxos/react-ui-theme';
|
13
|
-
import {
|
13
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
14
14
|
|
15
15
|
import { EditorToolbar, useEditorToolbarState } from '../components';
|
16
16
|
import { editorWidth } from '../defaults';
|
17
17
|
import {
|
18
18
|
InputModeExtensions,
|
19
|
-
createMarkdownExtensions,
|
20
19
|
createBasicExtensions,
|
20
|
+
createMarkdownExtensions,
|
21
21
|
createThemeExtensions,
|
22
22
|
decorateMarkdown,
|
23
23
|
formattingKeymap,
|
24
24
|
useFormattingState,
|
25
25
|
} from '../extensions';
|
26
|
-
import {
|
26
|
+
import { type UseTextEditorProps, useTextEditor } from '../hooks';
|
27
27
|
import { translations } from '../translations';
|
28
28
|
import { type EditorInputMode, type EditorViewMode } from '../types';
|
29
29
|
|
@@ -43,7 +43,7 @@ const DefaultStory = ({ autoFocus, initialValue, placeholder }: StoryProps) => {
|
|
43
43
|
moveToEndOfLine: true,
|
44
44
|
extensions: [
|
45
45
|
editorInputMode ? InputModeExtensions[editorInputMode] : [],
|
46
|
-
createBasicExtensions({ placeholder, lineWrapping: true, readOnly: viewMode === 'readonly' }),
|
46
|
+
createBasicExtensions({ placeholder, lineWrapping: true, readOnly: viewMode === 'readonly', search: true }),
|
47
47
|
createMarkdownExtensions({ themeMode }),
|
48
48
|
createThemeExtensions({ themeMode, syntaxHighlighting: true }),
|
49
49
|
viewMode === 'source' ? [] : decorateMarkdown(),
|
@@ -75,12 +75,12 @@ const DefaultStory = ({ autoFocus, initialValue, placeholder }: StoryProps) => {
|
|
75
75
|
);
|
76
76
|
};
|
77
77
|
|
78
|
-
const meta
|
78
|
+
const meta = {
|
79
79
|
title: 'ui/react-ui-editor/EditorToolbar',
|
80
80
|
render: DefaultStory,
|
81
81
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
82
82
|
parameters: { translations, layout: 'fullscreen' },
|
83
|
-
}
|
83
|
+
} satisfies Meta<typeof DefaultStory>;
|
84
84
|
|
85
85
|
export default meta;
|
86
86
|
|
@@ -4,33 +4,37 @@
|
|
4
4
|
|
5
5
|
import '@dxos-theme';
|
6
6
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
7
8
|
import defaultsDeep from 'lodash.defaultsdeep';
|
8
9
|
import React from 'react';
|
9
10
|
|
10
11
|
import { log } from '@dxos/log';
|
11
12
|
import { faker } from '@dxos/random';
|
12
|
-
import { withLayout, withTheme
|
13
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
13
14
|
|
14
|
-
import {
|
15
|
-
import { typewriter, blast, defaultOptions, dropFile } from '../extensions';
|
15
|
+
import { blast, defaultOptions, dropFile, typewriter } from '../extensions';
|
16
16
|
import { str } from '../testing';
|
17
17
|
|
18
|
-
|
18
|
+
import { EditorStory, content } from './components';
|
19
|
+
|
20
|
+
const meta = {
|
19
21
|
title: 'ui/react-ui-editor/Experimental',
|
20
22
|
component: EditorStory,
|
21
23
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
22
24
|
parameters: { layout: 'fullscreen' },
|
23
|
-
}
|
25
|
+
} satisfies Meta<typeof EditorStory>;
|
24
26
|
|
25
27
|
export default meta;
|
26
28
|
|
29
|
+
type Story = StoryObj<typeof meta>;
|
30
|
+
|
27
31
|
//
|
28
32
|
// Typewriter
|
29
33
|
//
|
30
34
|
|
31
35
|
const typewriterItems = localStorage.getItem('dxos.org/plugin/markdown/typewriter')?.split(',');
|
32
36
|
|
33
|
-
export const Typewriter = {
|
37
|
+
export const Typewriter: Story = {
|
34
38
|
render: () => (
|
35
39
|
<EditorStory
|
36
40
|
text={str('# Typewriter', '', content.paragraphs, content.footer)}
|
@@ -43,7 +47,7 @@ export const Typewriter = {
|
|
43
47
|
// Blast
|
44
48
|
//
|
45
49
|
|
46
|
-
export const Blast = {
|
50
|
+
export const Blast: Story = {
|
47
51
|
render: () => (
|
48
52
|
<EditorStory
|
49
53
|
text={str('# Blast', '', content.paragraphs, content.codeblocks, content.paragraphs)}
|
@@ -70,7 +74,7 @@ export const Blast = {
|
|
70
74
|
// DND
|
71
75
|
//
|
72
76
|
|
73
|
-
export const DND = {
|
77
|
+
export const DND: Story = {
|
74
78
|
render: () => (
|
75
79
|
<EditorStory
|
76
80
|
text={str('# DND', '')}
|
@@ -5,32 +5,36 @@
|
|
5
5
|
import '@dxos-theme';
|
6
6
|
|
7
7
|
import { markdown } from '@codemirror/lang-markdown';
|
8
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
8
9
|
import React from 'react';
|
9
10
|
|
10
|
-
import { withLayout, withTheme
|
11
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
11
12
|
|
12
|
-
import { EditorStory, content, defaultExtensions, headings, renderLinkTooltip, text } from './components';
|
13
13
|
import { decorateMarkdown, image, linkTooltip, table } from '../extensions';
|
14
14
|
import { str } from '../testing';
|
15
15
|
|
16
|
-
|
16
|
+
import { EditorStory, content, defaultExtensions, headings, renderLinkTooltip, text } from './components';
|
17
|
+
|
18
|
+
const meta = {
|
17
19
|
title: 'ui/react-ui-editor/Markdown',
|
18
20
|
component: EditorStory,
|
19
21
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
20
22
|
parameters: { layout: 'fullscreen' },
|
21
|
-
}
|
23
|
+
} satisfies Meta<typeof EditorStory>;
|
22
24
|
|
23
25
|
export default meta;
|
24
26
|
|
27
|
+
type Story = StoryObj<typeof meta>;
|
28
|
+
|
25
29
|
//
|
26
30
|
// Default
|
27
31
|
//
|
28
32
|
|
29
|
-
export const Default = {
|
33
|
+
export const Default: Story = {
|
30
34
|
render: () => <EditorStory text={text} extensions={defaultExtensions} />,
|
31
35
|
};
|
32
36
|
|
33
|
-
export const Blockquote = {
|
37
|
+
export const Blockquote: Story = {
|
34
38
|
render: () => (
|
35
39
|
<EditorStory
|
36
40
|
text={str('> Blockquote', 'continuation', content.footer)}
|
@@ -40,23 +44,23 @@ export const Blockquote = {
|
|
40
44
|
),
|
41
45
|
};
|
42
46
|
|
43
|
-
export const Headings = {
|
47
|
+
export const Headings: Story = {
|
44
48
|
render: () => <EditorStory text={headings} extensions={decorateMarkdown({ numberedHeadings: { from: 2, to: 4 } })} />,
|
45
49
|
};
|
46
50
|
|
47
|
-
export const Links = {
|
51
|
+
export const Links: Story = {
|
48
52
|
render: () => <EditorStory text={str(content.links, content.footer)} extensions={[linkTooltip(renderLinkTooltip)]} />,
|
49
53
|
};
|
50
54
|
|
51
|
-
export const Image = {
|
55
|
+
export const Image: Story = {
|
52
56
|
render: () => <EditorStory text={str(content.image, content.footer)} extensions={[image()]} />,
|
53
57
|
};
|
54
58
|
|
55
|
-
export const Code = {
|
59
|
+
export const Code: Story = {
|
56
60
|
render: () => <EditorStory text={str(content.codeblocks, content.footer)} extensions={[decorateMarkdown()]} />,
|
57
61
|
};
|
58
62
|
|
59
|
-
export const Lists = {
|
63
|
+
export const Lists: Story = {
|
60
64
|
render: () => (
|
61
65
|
<EditorStory
|
62
66
|
text={str(content.tasks, '', content.bullets, '', content.numbered, content.footer)}
|
@@ -69,7 +73,7 @@ export const Lists = {
|
|
69
73
|
// Bullet List
|
70
74
|
//
|
71
75
|
|
72
|
-
export const BulletList = {
|
76
|
+
export const BulletList: Story = {
|
73
77
|
render: () => <EditorStory text={str(content.bullets, content.footer)} extensions={[decorateMarkdown()]} />,
|
74
78
|
};
|
75
79
|
|
@@ -77,7 +81,7 @@ export const BulletList = {
|
|
77
81
|
// Ordered List
|
78
82
|
//
|
79
83
|
|
80
|
-
export const OrderedList = {
|
84
|
+
export const OrderedList: Story = {
|
81
85
|
render: () => <EditorStory text={str(content.numbered, content.footer)} extensions={[decorateMarkdown()]} />,
|
82
86
|
};
|
83
87
|
|
@@ -85,13 +89,13 @@ export const OrderedList = {
|
|
85
89
|
// Task List
|
86
90
|
//
|
87
91
|
|
88
|
-
export const TaskList = {
|
92
|
+
export const TaskList: Story = {
|
89
93
|
render: () => (
|
90
94
|
<EditorStory text={str(content.tasks, content.footer)} extensions={[decorateMarkdown()]} debug='raw+tree' />
|
91
95
|
),
|
92
96
|
};
|
93
97
|
|
94
|
-
export const TaskListEmpty = {
|
98
|
+
export const TaskListEmpty: Story = {
|
95
99
|
render: () => <EditorStory text={str('- [ ] ')} extensions={[decorateMarkdown()]} debug='raw+tree' />,
|
96
100
|
};
|
97
101
|
|
@@ -99,7 +103,7 @@ export const TaskListEmpty = {
|
|
99
103
|
// Table
|
100
104
|
//
|
101
105
|
|
102
|
-
export const Table = {
|
106
|
+
export const Table: Story = {
|
103
107
|
render: () => <EditorStory text={str(content.table, content.footer)} extensions={[decorateMarkdown(), table()]} />,
|
104
108
|
};
|
105
109
|
|
@@ -107,7 +111,7 @@ export const Table = {
|
|
107
111
|
// Commented out
|
108
112
|
//
|
109
113
|
|
110
|
-
export const CommentedOut = {
|
114
|
+
export const CommentedOut: Story = {
|
111
115
|
render: () => (
|
112
116
|
<EditorStory
|
113
117
|
text={str('# Commented out', '', content.comment, content.footer)}
|
@@ -5,19 +5,21 @@
|
|
5
5
|
import '@dxos-theme';
|
6
6
|
|
7
7
|
import { type EditorView } from '@codemirror/view';
|
8
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
8
9
|
import React, { useRef } from 'react';
|
9
10
|
|
10
11
|
import { DropdownMenu } from '@dxos/react-ui';
|
11
12
|
import { withAttention } from '@dxos/react-ui-attention/testing';
|
12
|
-
import { withLayout, withTheme
|
13
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
13
14
|
|
14
|
-
import { EditorStory } from './components';
|
15
15
|
import { RefDropdownMenu } from '../components';
|
16
|
-
import {
|
16
|
+
import { deleteItem, hashtag, listItemToString, outliner, treeFacet } from '../extensions';
|
17
17
|
import { str } from '../testing';
|
18
18
|
|
19
|
+
import { EditorStory } from './components';
|
20
|
+
|
19
21
|
type StoryProps = {
|
20
|
-
text
|
22
|
+
text?: string;
|
21
23
|
};
|
22
24
|
|
23
25
|
const DefaultStory = ({ text }: StoryProps) => {
|
@@ -58,20 +60,22 @@ const DefaultStory = ({ text }: StoryProps) => {
|
|
58
60
|
);
|
59
61
|
};
|
60
62
|
|
61
|
-
const meta
|
63
|
+
const meta = {
|
62
64
|
title: 'ui/react-ui-editor/Outliner',
|
63
65
|
render: DefaultStory,
|
64
66
|
decorators: [withAttention, withTheme, withLayout({ fullscreen: true })],
|
65
67
|
parameters: { layout: 'fullscreen' },
|
66
|
-
}
|
68
|
+
} satisfies Meta<typeof DefaultStory>;
|
67
69
|
|
68
70
|
export default meta;
|
69
71
|
|
70
|
-
|
72
|
+
type Story = StoryObj<typeof meta>;
|
73
|
+
|
74
|
+
export const Empty: Story = {
|
71
75
|
args: {},
|
72
76
|
};
|
73
77
|
|
74
|
-
export const Basic = {
|
78
|
+
export const Basic: Story = {
|
75
79
|
args: {
|
76
80
|
text: str(
|
77
81
|
//
|
@@ -86,7 +90,7 @@ export const Basic = {
|
|
86
90
|
},
|
87
91
|
};
|
88
92
|
|
89
|
-
export const Nested = {
|
93
|
+
export const Nested: Story = {
|
90
94
|
args: {
|
91
95
|
text: str(
|
92
96
|
//
|
@@ -101,7 +105,7 @@ export const Nested = {
|
|
101
105
|
},
|
102
106
|
};
|
103
107
|
|
104
|
-
export const Continuation = {
|
108
|
+
export const Continuation: Story = {
|
105
109
|
args: {
|
106
110
|
text: str(
|
107
111
|
//
|
@@ -6,7 +6,8 @@ import '@dxos-theme';
|
|
6
6
|
|
7
7
|
import { syntaxTree } from '@codemirror/language';
|
8
8
|
import { type EditorView } from '@codemirror/view';
|
9
|
-
import
|
9
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
10
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
10
11
|
import { createPortal } from 'react-dom';
|
11
12
|
|
12
13
|
import { invariant } from '@dxos/invariant';
|
@@ -14,12 +15,13 @@ import { faker } from '@dxos/random';
|
|
14
15
|
import { Popover } from '@dxos/react-ui';
|
15
16
|
import { Card } from '@dxos/react-ui-stack';
|
16
17
|
import { hoverableControlItem, hoverableControlItemTransition, hoverableControls } from '@dxos/react-ui-theme';
|
17
|
-
import { withLayout, withTheme
|
18
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
19
|
+
import { trim } from '@dxos/util';
|
18
20
|
|
19
|
-
import { EditorStory } from './components';
|
20
21
|
import { PreviewProvider, useRefPopover } from '../components';
|
21
|
-
import {
|
22
|
-
|
22
|
+
import { type PreviewLinkRef, type PreviewLinkTarget, getLinkRef, image, preview } from '../extensions';
|
23
|
+
|
24
|
+
import { EditorStory } from './components';
|
23
25
|
|
24
26
|
const handlePreviewLookup = async ({ label, ref }: PreviewLinkRef): Promise<PreviewLinkTarget> => {
|
25
27
|
// Random text.
|
@@ -132,7 +134,7 @@ const PreviewBlock = ({ link, el, view }: { link: PreviewLinkRef; el: HTMLElemen
|
|
132
134
|
<Card.Toolbar classNames='is-min p-[--dx-cardSpacingInline]'>
|
133
135
|
{(link.suggest && (
|
134
136
|
<>
|
135
|
-
<Card.ToolbarIconButton label='Discard' icon=
|
137
|
+
<Card.ToolbarIconButton label='Discard' icon='ph--x--regular' onClick={handleDelete} />
|
136
138
|
{target && (
|
137
139
|
<Card.ToolbarIconButton
|
138
140
|
classNames='bg-successSurface text-successSurfaceText'
|
@@ -164,16 +166,18 @@ const PreviewBlock = ({ link, el, view }: { link: PreviewLinkRef; el: HTMLElemen
|
|
164
166
|
);
|
165
167
|
};
|
166
168
|
|
167
|
-
const meta
|
169
|
+
const meta = {
|
168
170
|
title: 'ui/react-ui-editor/Preview',
|
169
171
|
component: EditorStory,
|
170
172
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
171
173
|
parameters: { layout: 'fullscreen' },
|
172
|
-
}
|
174
|
+
} satisfies Meta<typeof EditorStory>;
|
173
175
|
|
174
176
|
export default meta;
|
175
177
|
|
176
|
-
|
178
|
+
type Story = StoryObj<typeof meta>;
|
179
|
+
|
180
|
+
export const Default: Story = {
|
177
181
|
render: () => {
|
178
182
|
const [view, setView] = useState<EditorView>();
|
179
183
|
const [previewBlocks, setPreviewBlocks] = useState<{ link: PreviewLinkRef; el: HTMLElement }[]>([]);
|
@@ -200,22 +204,20 @@ export const Default = {
|
|
200
204
|
<PreviewProvider onLookup={handlePreviewLookup}>
|
201
205
|
<EditorStory
|
202
206
|
ref={handleViewRef}
|
203
|
-
text={
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
'',
|
218
|
-
)}
|
207
|
+
text={trim`
|
208
|
+
# Preview
|
209
|
+
|
210
|
+
This project is part of the [DXOS][dxn:queue:data:123] SDK.
|
211
|
+
|
212
|
+
![DXOS][?dxn:queue:data:123]
|
213
|
+
|
214
|
+
It consists of [ECHO][dxn:queue:data:echo], [HALO][dxn:queue:data:halo], and [MESH][dxn:queue:data:mesh].
|
215
|
+
|
216
|
+
## Deep dive
|
217
|
+
|
218
|
+
![ECHO][dxn:queue:data:echo]
|
219
|
+
|
220
|
+
`}
|
219
221
|
extensions={extensions}
|
220
222
|
/>
|
221
223
|
<PreviewCard />
|