@dxos/react-ui-editor 0.8.2-main.5ca3450 → 0.8.2-main.600d381
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 +1591 -1523
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +1383 -1316
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +1591 -1523
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/EditorToolbar/EditorToolbar.d.ts +1 -1
- package/dist/types/src/components/EditorToolbar/EditorToolbar.d.ts.map +1 -1
- package/dist/types/src/{stories/InputMode.stories.d.ts → components/EditorToolbar/EditorToolbar.stories.d.ts} +3 -7
- package/dist/types/src/components/EditorToolbar/EditorToolbar.stories.d.ts.map +1 -0
- package/dist/types/src/components/EditorToolbar/blocks.d.ts +4 -3
- package/dist/types/src/components/EditorToolbar/blocks.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/comment.d.ts +4 -3
- package/dist/types/src/components/EditorToolbar/comment.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/formatting.d.ts +4 -3
- package/dist/types/src/components/EditorToolbar/formatting.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/headings.d.ts +4 -3
- package/dist/types/src/components/EditorToolbar/headings.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/image.d.ts +16 -0
- package/dist/types/src/components/EditorToolbar/image.d.ts.map +1 -0
- package/dist/types/src/components/EditorToolbar/lists.d.ts +4 -3
- package/dist/types/src/components/EditorToolbar/lists.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/search.d.ts +17 -0
- package/dist/types/src/components/EditorToolbar/search.d.ts.map +1 -0
- package/dist/types/src/components/EditorToolbar/util.d.ts +11 -17
- package/dist/types/src/components/EditorToolbar/util.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/view-mode.d.ts +4 -3
- package/dist/types/src/components/EditorToolbar/view-mode.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +0 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/package.json +28 -28
- package/src/components/EditorToolbar/EditorToolbar.stories.tsx +90 -0
- package/src/components/EditorToolbar/EditorToolbar.tsx +30 -31
- package/src/components/EditorToolbar/blocks.ts +27 -6
- package/src/components/EditorToolbar/comment.ts +11 -4
- package/src/components/EditorToolbar/formatting.ts +34 -7
- package/src/components/EditorToolbar/headings.ts +9 -8
- package/src/components/EditorToolbar/image.ts +16 -0
- package/src/components/EditorToolbar/lists.ts +26 -7
- package/src/components/EditorToolbar/search.ts +19 -0
- package/src/components/EditorToolbar/util.ts +14 -14
- package/src/components/EditorToolbar/view-mode.ts +9 -8
- package/src/hooks/index.ts +0 -1
- package/dist/types/src/hooks/useActionHandler.d.ts +0 -4
- package/dist/types/src/hooks/useActionHandler.d.ts.map +0 -1
- package/dist/types/src/stories/InputMode.stories.d.ts.map +0 -1
- package/src/hooks/useActionHandler.ts +0 -12
- package/src/stories/InputMode.stories.tsx +0 -124
@@ -2,10 +2,13 @@
|
|
2
2
|
// Copyright 2025 DXOS.org
|
3
3
|
//
|
4
4
|
|
5
|
+
import { type EditorView } from '@codemirror/view';
|
6
|
+
|
5
7
|
import { type NodeArg } from '@dxos/app-graph';
|
6
8
|
import { type ToolbarMenuActionGroupProperties } from '@dxos/react-ui-menu';
|
7
9
|
|
8
10
|
import { createEditorAction, createEditorActionGroup, type EditorToolbarState } from './util';
|
11
|
+
import { setHeading } from '../../extensions';
|
9
12
|
import { translationKey } from '../../translations';
|
10
13
|
|
11
14
|
const createHeadingGroupAction = (value: string) =>
|
@@ -20,7 +23,7 @@ const createHeadingGroupAction = (value: string) =>
|
|
20
23
|
'ph--text-h--regular',
|
21
24
|
);
|
22
25
|
|
23
|
-
const createHeadingActions = (
|
26
|
+
const createHeadingActions = (getView: () => EditorView) =>
|
24
27
|
Object.entries({
|
25
28
|
'0': 'ph--paragraph--regular',
|
26
29
|
'1': 'ph--text-h-one--regular',
|
@@ -31,12 +34,10 @@ const createHeadingActions = (value: string) =>
|
|
31
34
|
'6': 'ph--text-h-six--regular',
|
32
35
|
}).map(([levelStr, icon]) => {
|
33
36
|
const level = parseInt(levelStr);
|
34
|
-
return createEditorAction(
|
35
|
-
|
37
|
+
return createEditorAction(`heading--${levelStr}`, () => setHeading(level)(getView()), {
|
38
|
+
label: ['heading level label', { count: level, ns: translationKey }],
|
36
39
|
icon,
|
37
|
-
|
38
|
-
`heading--${levelStr}`,
|
39
|
-
);
|
40
|
+
});
|
40
41
|
});
|
41
42
|
|
42
43
|
const computeHeadingValue = (state: EditorToolbarState) => {
|
@@ -45,10 +46,10 @@ const computeHeadingValue = (state: EditorToolbarState) => {
|
|
45
46
|
return header ? header[1] : blockType === 'paragraph' || !blockType ? '0' : '';
|
46
47
|
};
|
47
48
|
|
48
|
-
export const createHeadings = (state: EditorToolbarState) => {
|
49
|
+
export const createHeadings = (state: EditorToolbarState, getView: () => EditorView) => {
|
49
50
|
const headingValue = computeHeadingValue(state);
|
50
51
|
const headingGroupAction = createHeadingGroupAction(headingValue);
|
51
|
-
const headingActions = createHeadingActions(
|
52
|
+
const headingActions = createHeadingActions(getView);
|
52
53
|
return {
|
53
54
|
nodes: [headingGroupAction as NodeArg<any>, ...headingActions],
|
54
55
|
edges: [
|
@@ -0,0 +1,16 @@
|
|
1
|
+
//
|
2
|
+
// Copyright 2025 DXOS.org
|
3
|
+
//
|
4
|
+
|
5
|
+
import { createEditorAction } from './util';
|
6
|
+
|
7
|
+
const createImageUploadAction = (onImageUpload: () => void) =>
|
8
|
+
createEditorAction('image', onImageUpload, {
|
9
|
+
testId: 'editor.toolbar.image',
|
10
|
+
icon: 'ph--image-square--regular',
|
11
|
+
});
|
12
|
+
|
13
|
+
export const createImageUpload = (onImageUpload: () => void) => ({
|
14
|
+
nodes: [createImageUploadAction(onImageUpload)],
|
15
|
+
edges: [{ source: 'root', target: 'image' }],
|
16
|
+
});
|
@@ -2,11 +2,13 @@
|
|
2
2
|
// Copyright 2025 DXOS.org
|
3
3
|
//
|
4
4
|
|
5
|
+
import { type EditorView } from '@codemirror/view';
|
6
|
+
|
5
7
|
import { type NodeArg } from '@dxos/app-graph';
|
6
8
|
import { type ToolbarMenuActionGroupProperties } from '@dxos/react-ui-menu';
|
7
9
|
|
8
10
|
import { createEditorAction, createEditorActionGroup, type EditorToolbarState } from './util';
|
9
|
-
import {
|
11
|
+
import { addList, List, removeList } from '../../extensions';
|
10
12
|
|
11
13
|
const listStyles = {
|
12
14
|
bullet: 'ph--list-bullets--regular',
|
@@ -21,15 +23,32 @@ const createListGroupAction = (value: string) =>
|
|
21
23
|
value,
|
22
24
|
} as ToolbarMenuActionGroupProperties);
|
23
25
|
|
24
|
-
const createListActions = (value: string) =>
|
25
|
-
Object.entries(listStyles).map(([listStyle, icon]) =>
|
26
|
-
|
27
|
-
|
26
|
+
const createListActions = (value: string, getView: () => EditorView) =>
|
27
|
+
Object.entries(listStyles).map(([listStyle, icon]) => {
|
28
|
+
const checked = value === listStyle;
|
29
|
+
return createEditorAction(
|
30
|
+
`list-${listStyle}`,
|
31
|
+
() => {
|
32
|
+
const view = getView();
|
33
|
+
if (!view) {
|
34
|
+
return;
|
35
|
+
}
|
36
|
+
|
37
|
+
const listType = listStyle === 'ordered' ? List.Ordered : listStyle === 'bullet' ? List.Bullet : List.Task;
|
38
|
+
if (checked) {
|
39
|
+
removeList(listType)(view);
|
40
|
+
} else {
|
41
|
+
addList(listType)(view);
|
42
|
+
}
|
43
|
+
},
|
44
|
+
{ checked, icon },
|
45
|
+
);
|
46
|
+
});
|
28
47
|
|
29
|
-
export const createLists = (state: EditorToolbarState) => {
|
48
|
+
export const createLists = (state: EditorToolbarState, getView: () => EditorView) => {
|
30
49
|
const value = state.listStyle ?? '';
|
31
50
|
const listGroupAction = createListGroupAction(value);
|
32
|
-
const listActionsMap = createListActions(value);
|
51
|
+
const listActionsMap = createListActions(value, getView);
|
33
52
|
return {
|
34
53
|
nodes: [listGroupAction as NodeArg<any>, ...listActionsMap],
|
35
54
|
edges: [
|
@@ -0,0 +1,19 @@
|
|
1
|
+
//
|
2
|
+
// Copyright 2025 DXOS.org
|
3
|
+
//
|
4
|
+
|
5
|
+
import { openSearchPanel } from '@codemirror/search';
|
6
|
+
import { type EditorView } from '@codemirror/view';
|
7
|
+
|
8
|
+
import { createEditorAction } from './util';
|
9
|
+
|
10
|
+
const createSearchAction = (getView: () => EditorView) =>
|
11
|
+
createEditorAction('search', () => openSearchPanel(getView()), {
|
12
|
+
testId: 'editor.toolbar.search',
|
13
|
+
icon: 'ph--magnifying-glass--regular',
|
14
|
+
});
|
15
|
+
|
16
|
+
export const createSearch = (getView: () => EditorView) => ({
|
17
|
+
nodes: [createSearchAction(getView)],
|
18
|
+
edges: [{ source: 'root', target: 'search' }],
|
19
|
+
});
|
@@ -2,21 +2,23 @@
|
|
2
2
|
// Copyright 2025 DXOS.org
|
3
3
|
//
|
4
4
|
|
5
|
+
import { type EditorView } from '@codemirror/view';
|
5
6
|
import { useMemo } from 'react';
|
6
7
|
|
8
|
+
import { type Action } from '@dxos/app-graph';
|
7
9
|
import { live, type Live } from '@dxos/live-object';
|
8
|
-
import { type
|
10
|
+
import { type ThemedClassName } from '@dxos/react-ui';
|
9
11
|
import {
|
10
12
|
type MenuSeparator,
|
11
13
|
type MenuItemGroup,
|
12
14
|
type ToolbarMenuActionGroupProperties,
|
13
|
-
type MenuActionProperties,
|
14
15
|
createMenuAction,
|
15
16
|
createMenuItemGroup,
|
16
17
|
type ActionGraphProps,
|
18
|
+
type MenuActionProperties,
|
17
19
|
} from '@dxos/react-ui-menu';
|
18
20
|
|
19
|
-
import type { EditorAction,
|
21
|
+
import type { EditorAction, EditorViewMode, Formatting } from '../../extensions';
|
20
22
|
import { translationKey } from '../../translations';
|
21
23
|
|
22
24
|
export type EditorToolbarState = Formatting &
|
@@ -31,16 +33,18 @@ export type EditorToolbarFeatureFlags = Partial<{
|
|
31
33
|
formatting: boolean;
|
32
34
|
lists: boolean;
|
33
35
|
blocks: boolean;
|
34
|
-
comment: boolean;
|
35
36
|
search: boolean;
|
36
|
-
|
37
|
+
// TODO(wittjosiah): Factor out. Depend on plugin-level capabilities.
|
38
|
+
comment: boolean;
|
39
|
+
image: () => void;
|
40
|
+
viewMode: (mode: EditorViewMode) => void;
|
37
41
|
}>;
|
38
42
|
|
39
43
|
export type EditorToolbarActionGraphProps = {
|
40
44
|
state: Live<EditorToolbarState>;
|
45
|
+
getView: () => EditorView;
|
41
46
|
// TODO(wittjosiah): Control positioning.
|
42
47
|
customActions?: () => ActionGraphProps;
|
43
|
-
onAction: (action: EditorAction) => void;
|
44
48
|
};
|
45
49
|
|
46
50
|
export type EditorToolbarProps = ThemedClassName<
|
@@ -49,17 +53,13 @@ export type EditorToolbarProps = ThemedClassName<
|
|
49
53
|
|
50
54
|
export type EditorToolbarItem = EditorAction | MenuItemGroup | MenuSeparator;
|
51
55
|
|
52
|
-
export const createEditorAction = (
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
id: string = payload.type,
|
57
|
-
) => createMenuAction(id, { icon, label, ...payload }) as EditorAction;
|
56
|
+
export const createEditorAction = (id: string, invoke: () => void, properties: Partial<MenuActionProperties>) => {
|
57
|
+
const { label = [`${id} label`, { ns: translationKey }], ...rest } = properties;
|
58
|
+
return createMenuAction(id, invoke, { label, ...rest }) as Action<MenuActionProperties>;
|
59
|
+
};
|
58
60
|
|
59
61
|
export const createEditorActionGroup = (
|
60
62
|
id: string,
|
61
63
|
props: Omit<ToolbarMenuActionGroupProperties, 'icon'>,
|
62
64
|
icon?: string,
|
63
65
|
) => createMenuItemGroup(id, { icon, iconOnly: true, ...props });
|
64
|
-
|
65
|
-
export const editorToolbarSearch = createEditorAction({ type: 'search' }, 'ph--magnifying-glass--regular');
|
@@ -6,6 +6,7 @@ import { type NodeArg } from '@dxos/app-graph';
|
|
6
6
|
import { type ToolbarMenuActionGroupProperties } from '@dxos/react-ui-menu';
|
7
7
|
|
8
8
|
import { createEditorAction, createEditorActionGroup, type EditorToolbarState } from './util';
|
9
|
+
import { type EditorViewMode } from '../../extensions';
|
9
10
|
import { translationKey } from '../../translations';
|
10
11
|
|
11
12
|
const createViewModeGroupAction = (value: string) =>
|
@@ -20,24 +21,24 @@ const createViewModeGroupAction = (value: string) =>
|
|
20
21
|
'ph--eye--regular',
|
21
22
|
);
|
22
23
|
|
23
|
-
const createViewModeActions = (value: string) =>
|
24
|
+
const createViewModeActions = (value: string, onViewModeChange: (mode: EditorViewMode) => void) =>
|
24
25
|
Object.entries({
|
25
26
|
preview: 'ph--eye--regular',
|
26
27
|
source: 'ph--pencil-simple--regular',
|
27
28
|
readonly: 'ph--pencil-slash--regular',
|
28
29
|
}).map(([viewMode, icon]) => {
|
29
|
-
|
30
|
-
|
30
|
+
const checked = viewMode === value;
|
31
|
+
return createEditorAction(`view-mode--${viewMode}`, () => onViewModeChange(viewMode as EditorViewMode), {
|
32
|
+
label: [`${viewMode} mode label`, { ns: translationKey }],
|
33
|
+
checked,
|
31
34
|
icon,
|
32
|
-
|
33
|
-
`view-mode--${viewMode}`,
|
34
|
-
);
|
35
|
+
});
|
35
36
|
});
|
36
37
|
|
37
|
-
export const createViewMode = (state: EditorToolbarState) => {
|
38
|
+
export const createViewMode = (state: EditorToolbarState, onViewModeChange: (mode: EditorViewMode) => void) => {
|
38
39
|
const value = state.viewMode ?? 'source';
|
39
40
|
const viewModeGroupAction = createViewModeGroupAction(value);
|
40
|
-
const viewModeActions = createViewModeActions(value);
|
41
|
+
const viewModeActions = createViewModeActions(value, onViewModeChange);
|
41
42
|
return {
|
42
43
|
nodes: [viewModeGroupAction as NodeArg<any>, ...viewModeActions],
|
43
44
|
edges: [
|
package/src/hooks/index.ts
CHANGED
@@ -1,4 +0,0 @@
|
|
1
|
-
import { type EditorView } from '@codemirror/view';
|
2
|
-
import { type EditorAction } from '../extensions';
|
3
|
-
export declare const useActionHandler: (view?: EditorView | null) => (action: EditorAction) => void | null | undefined;
|
4
|
-
//# sourceMappingURL=useActionHandler.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useActionHandler.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useActionHandler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,KAAK,YAAY,EAAwB,MAAM,eAAe,CAAC;AAExE,eAAO,MAAM,gBAAgB,GAAI,OAAO,UAAU,GAAG,IAAI,cAC3B,YAAY,4BACzC,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"InputMode.stories.d.ts","sourceRoot":"","sources":["../../../../src/stories/InputMode.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAmB,MAAM,OAAO,CAAC;AAiBxC,OAAO,EAAmC,KAAK,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGpF,KAAK,UAAU,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,kBAAkB,CAAC;AAqEpF,eAAO,MAAM,OAAO;;CAanB,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;;CAMpB,CAAC;;;iEAxFwE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0FpF,wBAKE"}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
//
|
2
|
-
// Copyright 2024 DXOS.org
|
3
|
-
//
|
4
|
-
|
5
|
-
import { type EditorView } from '@codemirror/view';
|
6
|
-
import { useCallback } from 'react';
|
7
|
-
|
8
|
-
import { type EditorAction, processEditorPayload } from '../extensions';
|
9
|
-
|
10
|
-
export const useActionHandler = (view?: EditorView | null) => {
|
11
|
-
return useCallback((action: EditorAction) => view && processEditorPayload(view, action.properties), [view]);
|
12
|
-
};
|
@@ -1,124 +0,0 @@
|
|
1
|
-
//
|
2
|
-
// Copyright 2024 DXOS.org
|
3
|
-
//
|
4
|
-
|
5
|
-
import '@dxos-theme';
|
6
|
-
|
7
|
-
import React, { useState } from 'react';
|
8
|
-
|
9
|
-
import { Toolbar as NaturalToolbar, Select, useThemeContext } from '@dxos/react-ui';
|
10
|
-
import { attentionSurface, mx } from '@dxos/react-ui-theme';
|
11
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
12
|
-
|
13
|
-
import { EditorToolbar, useEditorToolbarState } from '../components';
|
14
|
-
import {
|
15
|
-
type EditorInputMode,
|
16
|
-
decorateMarkdown,
|
17
|
-
createMarkdownExtensions,
|
18
|
-
formattingKeymap,
|
19
|
-
useFormattingState,
|
20
|
-
createBasicExtensions,
|
21
|
-
createThemeExtensions,
|
22
|
-
InputModeExtensions,
|
23
|
-
} from '../extensions';
|
24
|
-
import { useActionHandler, useTextEditor, type UseTextEditorProps } from '../hooks';
|
25
|
-
import translations from '../translations';
|
26
|
-
|
27
|
-
type StoryProps = { placeholder?: string; readOnly?: boolean } & UseTextEditorProps;
|
28
|
-
|
29
|
-
const DefaultStory = ({ autoFocus, initialValue, placeholder, readOnly }: StoryProps) => {
|
30
|
-
const { themeMode } = useThemeContext();
|
31
|
-
const toolbarState = useEditorToolbarState({ viewMode: 'source' });
|
32
|
-
const trackFormatting = useFormattingState(toolbarState);
|
33
|
-
const [editorInputMode, _setEditorInputMode] = useState<EditorInputMode>('default');
|
34
|
-
const { parentRef, view } = useTextEditor(
|
35
|
-
() => ({
|
36
|
-
autoFocus,
|
37
|
-
initialValue,
|
38
|
-
moveToEndOfLine: true,
|
39
|
-
extensions: [
|
40
|
-
editorInputMode ? InputModeExtensions[editorInputMode] : [],
|
41
|
-
createBasicExtensions({ placeholder, lineWrapping: true, readOnly }),
|
42
|
-
createMarkdownExtensions({ themeMode }),
|
43
|
-
createThemeExtensions({ themeMode, syntaxHighlighting: true }),
|
44
|
-
decorateMarkdown(),
|
45
|
-
formattingKeymap(),
|
46
|
-
trackFormatting,
|
47
|
-
],
|
48
|
-
}),
|
49
|
-
[editorInputMode, themeMode, placeholder, readOnly],
|
50
|
-
);
|
51
|
-
|
52
|
-
const handleAction = useActionHandler(view);
|
53
|
-
|
54
|
-
// TODO(marijn): This doesn't update the state on view changes.
|
55
|
-
// Also not sure if view is even guaranteed to exist at this point.
|
56
|
-
return (
|
57
|
-
<div role='none' className={mx('fixed inset-0 flex flex-col')}>
|
58
|
-
{toolbarState && <EditorToolbar onAction={handleAction} state={toolbarState} />}
|
59
|
-
<div role='none' className='grow overflow-hidden'>
|
60
|
-
<div className={attentionSurface} ref={parentRef} />
|
61
|
-
</div>
|
62
|
-
</div>
|
63
|
-
);
|
64
|
-
};
|
65
|
-
|
66
|
-
const _EditorInputModeToolbar = ({
|
67
|
-
editorInputMode,
|
68
|
-
setEditorInputMode,
|
69
|
-
}: {
|
70
|
-
editorInputMode: EditorInputMode;
|
71
|
-
setEditorInputMode: (mode: EditorInputMode) => void;
|
72
|
-
}) => {
|
73
|
-
return (
|
74
|
-
<Select.Root value={editorInputMode} onValueChange={(value) => setEditorInputMode(value as EditorInputMode)}>
|
75
|
-
<NaturalToolbar.Button asChild>
|
76
|
-
<Select.TriggerButton variant='ghost'>{editorInputMode}</Select.TriggerButton>
|
77
|
-
</NaturalToolbar.Button>
|
78
|
-
<Select.Portal>
|
79
|
-
<Select.Content>
|
80
|
-
<Select.ScrollUpButton />
|
81
|
-
<Select.Viewport>
|
82
|
-
{['default', 'vim'].map((mode) => (
|
83
|
-
<Select.Option key={mode} value={mode}>
|
84
|
-
{mode}
|
85
|
-
</Select.Option>
|
86
|
-
))}
|
87
|
-
</Select.Viewport>
|
88
|
-
<Select.ScrollDownButton />
|
89
|
-
<Select.Arrow />
|
90
|
-
</Select.Content>
|
91
|
-
</Select.Portal>
|
92
|
-
</Select.Root>
|
93
|
-
);
|
94
|
-
};
|
95
|
-
|
96
|
-
export const Default = {
|
97
|
-
render: () => {
|
98
|
-
const { themeMode } = useThemeContext();
|
99
|
-
const { parentRef } = useTextEditor({
|
100
|
-
extensions: [
|
101
|
-
//
|
102
|
-
createBasicExtensions({ placeholder: 'Enter text...' }),
|
103
|
-
createThemeExtensions({ themeMode }),
|
104
|
-
],
|
105
|
-
});
|
106
|
-
|
107
|
-
return <div ref={parentRef} className={attentionSurface} />;
|
108
|
-
},
|
109
|
-
};
|
110
|
-
|
111
|
-
export const Markdown = {
|
112
|
-
args: {
|
113
|
-
autoFocus: true,
|
114
|
-
placeholder: 'Text...',
|
115
|
-
initialValue: '# Demo\n\nThis is a document.\n\n',
|
116
|
-
},
|
117
|
-
};
|
118
|
-
|
119
|
-
export default {
|
120
|
-
title: 'ui/react-ui-editor/InputMode',
|
121
|
-
render: DefaultStory,
|
122
|
-
decorators: [withTheme, withLayout({ fullscreen: true, tooltips: true })],
|
123
|
-
parameters: { translations, layout: 'fullscreen' },
|
124
|
-
};
|