@dxos/react-ui-editor 0.8.4-main.c1de068 → 0.8.4-main.dedc0f3
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 +2074 -888
- 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 +2074 -888
- 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/components/Popover/RefDropdownMenu.d.ts +2 -9
- package/dist/types/src/components/Popover/RefDropdownMenu.d.ts.map +1 -1
- package/dist/types/src/components/Popover/RefPopover.d.ts +20 -17
- package/dist/types/src/components/Popover/RefPopover.d.ts.map +1 -1
- package/dist/types/src/defaults.d.ts.map +1 -1
- package/dist/types/src/extensions/autocomplete.d.ts +20 -7
- 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/autoscroll.d.ts +10 -0
- package/dist/types/src/extensions/autoscroll.d.ts.map +1 -0
- 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 +2 -7
- 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 +4 -4
- 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 +2 -7
- package/dist/types/src/extensions/factories.d.ts.map +1 -1
- package/dist/types/src/extensions/index.d.ts +2 -0
- package/dist/types/src/extensions/index.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 +8 -2
- package/dist/types/src/extensions/markdown/bundle.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/changes.d.ts +1 -1
- package/dist/types/src/extensions/markdown/changes.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/decorate.d.ts +9 -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/markdown/image.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/outliner.d.ts +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 +2 -2
- package/dist/types/src/extensions/outliner/tree.d.ts.map +1 -1
- package/dist/types/src/extensions/preview/preview.d.ts +3 -5
- package/dist/types/src/extensions/preview/preview.d.ts.map +1 -1
- package/dist/types/src/extensions/tags/extended-markdown.d.ts +10 -0
- package/dist/types/src/extensions/tags/extended-markdown.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/extended-markdown.test.d.ts +2 -0
- package/dist/types/src/extensions/tags/extended-markdown.test.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/index.d.ts +4 -0
- package/dist/types/src/extensions/tags/index.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/streamer.d.ts +12 -0
- package/dist/types/src/extensions/tags/streamer.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/xml-tags.d.ts +71 -0
- package/dist/types/src/extensions/tags/xml-tags.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/xml-util.d.ts +10 -0
- package/dist/types/src/extensions/tags/xml-util.d.ts.map +1 -0
- 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/Tags.stories.d.ts +17 -0
- package/dist/types/src/stories/Tags.stories.d.ts.map +1 -0
- 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/types/types.d.ts +1 -1
- package/dist/types/src/util/cursor.d.ts.map +1 -1
- package/dist/types/src/util/debug.d.ts +1 -1
- package/dist/types/src/util/debug.d.ts.map +1 -1
- package/dist/types/src/util/decorations.d.ts +4 -0
- package/dist/types/src/util/decorations.d.ts.map +1 -0
- package/dist/types/src/util/dom.d.ts +2 -12
- package/dist/types/src/util/dom.d.ts.map +1 -1
- package/dist/types/src/util/domino.d.ts +18 -0
- package/dist/types/src/util/domino.d.ts.map +1 -0
- package/dist/types/src/util/index.d.ts +2 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/react.d.ts +1 -1
- package/dist/types/src/util/react.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +57 -51
- 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 +20 -16
- package/src/components/Popover/RefPopover.tsx +63 -45
- package/src/defaults.ts +5 -2
- package/src/extensions/autocomplete.ts +204 -54
- 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/autoscroll.ts +151 -0
- package/src/extensions/awareness/awareness.ts +2 -2
- package/src/extensions/command/action.ts +1 -1
- package/src/extensions/command/command-menu.ts +6 -5
- package/src/extensions/command/command.ts +3 -3
- package/src/extensions/command/floating-menu.ts +1 -1
- 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 +5 -4
- package/src/extensions/comments.ts +18 -13
- package/src/extensions/dnd.ts +1 -1
- package/src/extensions/factories.ts +9 -21
- package/src/extensions/folding.tsx +2 -2
- package/src/extensions/index.ts +2 -0
- package/src/extensions/markdown/action.ts +2 -1
- package/src/extensions/markdown/bundle.ts +25 -3
- package/src/extensions/markdown/changes.ts +1 -1
- package/src/extensions/markdown/decorate.ts +23 -14
- 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/markdown/image.ts +3 -4
- package/src/extensions/markdown/table.ts +7 -1
- package/src/extensions/mention.ts +1 -1
- package/src/extensions/outliner/outliner.test.ts +3 -2
- package/src/extensions/outliner/outliner.ts +5 -4
- package/src/extensions/outliner/selection.ts +1 -1
- package/src/extensions/outliner/tree.test.ts +2 -1
- package/src/extensions/outliner/tree.ts +2 -2
- package/src/extensions/preview/preview.ts +59 -59
- package/src/extensions/tags/extended-markdown.test.ts +261 -0
- package/src/extensions/tags/extended-markdown.ts +78 -0
- package/src/extensions/tags/index.ts +7 -0
- package/src/extensions/tags/streamer.ts +244 -0
- package/src/extensions/tags/xml-tags.ts +335 -0
- package/src/extensions/tags/xml-util.ts +94 -0
- package/src/hooks/useTextEditor.ts +3 -3
- package/src/stories/Command.stories.tsx +24 -31
- package/src/stories/CommandMenu.stories.tsx +23 -22
- package/src/stories/Comments.stories.tsx +10 -6
- package/src/stories/EditorToolbar.stories.tsx +8 -8
- package/src/stories/Experimental.stories.tsx +12 -8
- package/src/stories/Markdown.stories.tsx +21 -17
- package/src/stories/Outliner.stories.tsx +17 -14
- package/src/stories/Preview.stories.tsx +27 -26
- package/src/stories/Tags.stories.tsx +81 -0
- package/src/stories/TextEditor.stories.tsx +40 -34
- package/src/stories/components/EditorStory.tsx +9 -10
- 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
- package/src/util/debug.ts +2 -2
- package/src/util/decorations.ts +21 -0
- package/src/util/dom.ts +5 -27
- package/src/util/domino.ts +51 -0
- package/src/util/index.ts +2 -0
- package/src/util/react.tsx +1 -1
@@ -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,8 +43,8 @@ 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' }),
|
47
|
-
createMarkdownExtensions(
|
46
|
+
createBasicExtensions({ placeholder, lineWrapping: true, readOnly: viewMode === 'readonly', search: true }),
|
47
|
+
createMarkdownExtensions(),
|
48
48
|
createThemeExtensions({ themeMode, syntaxHighlighting: true }),
|
49
49
|
viewMode === 'source' ? [] : decorateMarkdown(),
|
50
50
|
formattingKeymap(),
|
@@ -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 {
|
15
|
-
import {
|
16
|
-
import { outliner, listItemToString, treeFacet, deleteItem, hashtag } from '../extensions';
|
15
|
+
import { RefDropdownMenuProvider } from '../components';
|
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) => {
|
@@ -30,13 +32,12 @@ const DefaultStory = ({ text }: StoryProps) => {
|
|
30
32
|
};
|
31
33
|
|
32
34
|
return (
|
33
|
-
<
|
35
|
+
<RefDropdownMenuProvider>
|
34
36
|
<EditorStory
|
35
37
|
ref={viewRef}
|
36
38
|
text={text}
|
37
39
|
extensions={[outliner(), hashtag()]}
|
38
40
|
placeholder=''
|
39
|
-
slots={{}}
|
40
41
|
debug='raw+tree'
|
41
42
|
debugCustom={(view) => {
|
42
43
|
const tree = view.state.facet(treeFacet);
|
@@ -54,24 +55,26 @@ const DefaultStory = ({ text }: StoryProps) => {
|
|
54
55
|
<DropdownMenu.Arrow />
|
55
56
|
</DropdownMenu.Content>
|
56
57
|
</DropdownMenu.Portal>
|
57
|
-
</
|
58
|
+
</RefDropdownMenuProvider>
|
58
59
|
);
|
59
60
|
};
|
60
61
|
|
61
|
-
const meta
|
62
|
+
const meta = {
|
62
63
|
title: 'ui/react-ui-editor/Outliner',
|
63
64
|
render: DefaultStory,
|
64
65
|
decorators: [withAttention, withTheme, withLayout({ fullscreen: true })],
|
65
66
|
parameters: { layout: 'fullscreen' },
|
66
|
-
}
|
67
|
+
} satisfies Meta<typeof DefaultStory>;
|
67
68
|
|
68
69
|
export default meta;
|
69
70
|
|
70
|
-
|
71
|
+
type Story = StoryObj<typeof meta>;
|
72
|
+
|
73
|
+
export const Empty: Story = {
|
71
74
|
args: {},
|
72
75
|
};
|
73
76
|
|
74
|
-
export const Basic = {
|
77
|
+
export const Basic: Story = {
|
75
78
|
args: {
|
76
79
|
text: str(
|
77
80
|
//
|
@@ -86,7 +89,7 @@ export const Basic = {
|
|
86
89
|
},
|
87
90
|
};
|
88
91
|
|
89
|
-
export const Nested = {
|
92
|
+
export const Nested: Story = {
|
90
93
|
args: {
|
91
94
|
text: str(
|
92
95
|
//
|
@@ -101,7 +104,7 @@ export const Nested = {
|
|
101
104
|
},
|
102
105
|
};
|
103
106
|
|
104
|
-
export const Continuation = {
|
107
|
+
export const Continuation: Story = {
|
105
108
|
args: {
|
106
109
|
text: str(
|
107
110
|
//
|
@@ -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,20 +166,21 @@ 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 }[]>([]);
|
180
|
-
|
181
184
|
const extensions = useMemo(() => {
|
182
185
|
return [
|
183
186
|
image(),
|
@@ -200,22 +203,20 @@ export const Default = {
|
|
200
203
|
<PreviewProvider onLookup={handlePreviewLookup}>
|
201
204
|
<EditorStory
|
202
205
|
ref={handleViewRef}
|
203
|
-
text={
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
'',
|
218
|
-
)}
|
206
|
+
text={trim`
|
207
|
+
# Preview
|
208
|
+
|
209
|
+
This project is part of the [DXOS](dxn:queue:data:123) SDK.
|
210
|
+
|
211
|
+

|
212
|
+
|
213
|
+
It consists of [ECHO](dxn:queue:data:echo), [HALO](dxn:queue:data:halo), and [MESH](dxn:queue:data:mesh).
|
214
|
+
|
215
|
+
## Deep dive
|
216
|
+
|
217
|
+

|
218
|
+
|
219
|
+
`}
|
219
220
|
extensions={extensions}
|
220
221
|
/>
|
221
222
|
<PreviewCard />
|
@@ -0,0 +1,81 @@
|
|
1
|
+
//
|
2
|
+
// Copyright 2025 DXOS.org
|
3
|
+
//
|
4
|
+
|
5
|
+
import '@dxos-theme';
|
6
|
+
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
8
|
+
import React, { useState } from 'react';
|
9
|
+
import { createPortal } from 'react-dom';
|
10
|
+
|
11
|
+
import { useThemeContext } from '@dxos/react-ui';
|
12
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
13
|
+
import { trim } from '@dxos/util';
|
14
|
+
|
15
|
+
import {
|
16
|
+
type XmlWidgetRegistry,
|
17
|
+
type XmlWidgetState,
|
18
|
+
createBasicExtensions,
|
19
|
+
createThemeExtensions,
|
20
|
+
decorateMarkdown,
|
21
|
+
extendedMarkdown,
|
22
|
+
xmlTags,
|
23
|
+
} from '../extensions';
|
24
|
+
import { useTextEditor } from '../hooks';
|
25
|
+
|
26
|
+
const registry = {
|
27
|
+
// <test/>
|
28
|
+
['test' as const]: {
|
29
|
+
block: true,
|
30
|
+
Component: () => <div className='p-2 border border-separator rounded'>Test</div>,
|
31
|
+
},
|
32
|
+
} satisfies XmlWidgetRegistry;
|
33
|
+
|
34
|
+
const DefaultStory = ({ text }: { text?: string }) => {
|
35
|
+
const { themeMode } = useThemeContext();
|
36
|
+
const [widgets, setWidgets] = useState<XmlWidgetState[]>([]);
|
37
|
+
const { parentRef } = useTextEditor({
|
38
|
+
initialValue: text,
|
39
|
+
extensions: [
|
40
|
+
createThemeExtensions({ themeMode }),
|
41
|
+
createBasicExtensions({ lineWrapping: true, readOnly: true }),
|
42
|
+
decorateMarkdown(),
|
43
|
+
extendedMarkdown({ registry }),
|
44
|
+
xmlTags({ registry, setWidgets }),
|
45
|
+
],
|
46
|
+
});
|
47
|
+
|
48
|
+
return (
|
49
|
+
<>
|
50
|
+
<div ref={parentRef} className='is-full p-4' />
|
51
|
+
{widgets.map(({ Component, root, id, ...props }) => (
|
52
|
+
<div key={id}>{createPortal(<Component {...props} />, root)}</div>
|
53
|
+
))}
|
54
|
+
</>
|
55
|
+
);
|
56
|
+
};
|
57
|
+
|
58
|
+
const text = trim`
|
59
|
+
# Tags
|
60
|
+
|
61
|
+
<test id="123" />
|
62
|
+
|
63
|
+
React widget above.
|
64
|
+
`;
|
65
|
+
|
66
|
+
const meta = {
|
67
|
+
title: 'ui/react-ui-editor/Tags',
|
68
|
+
render: DefaultStory,
|
69
|
+
decorators: [withTheme, withLayout({ fullscreen: true })],
|
70
|
+
parameters: { layout: 'fullscreen' },
|
71
|
+
} satisfies Meta<typeof DefaultStory>;
|
72
|
+
|
73
|
+
export default meta;
|
74
|
+
|
75
|
+
type Story = StoryObj<typeof meta>;
|
76
|
+
|
77
|
+
export const Default: Story = {
|
78
|
+
args: {
|
79
|
+
text,
|
80
|
+
},
|
81
|
+
};
|