@dxos/react-ui-editor 0.8.4-main.ef1bc66f44 → 0.8.4-main.effb148878
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/browser/index.mjs +796 -755
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +39 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +796 -755
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/translations.mjs +41 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/types/src/components/Editor/Editor.d.ts +36 -25
- package/dist/types/src/components/Editor/Editor.d.ts.map +1 -1
- package/dist/types/src/components/Editor/Editor.stories.d.ts +4 -4
- package/dist/types/src/components/Editor/Editor.stories.d.ts.map +1 -1
- package/dist/types/src/components/{EditorContent/EditorContent.d.ts → Editor/EditorView.d.ts} +5 -5
- package/dist/types/src/components/Editor/EditorView.d.ts.map +1 -0
- package/dist/types/src/components/Editor/controller.d.ts.map +1 -0
- package/dist/types/src/components/EditorMenuProvider/EditorMenuProvider.d.ts +1 -3
- package/dist/types/src/components/EditorMenuProvider/EditorMenuProvider.d.ts.map +1 -1
- package/dist/types/src/components/EditorMenuProvider/menu-presets.d.ts.map +1 -1
- package/dist/types/src/components/EditorMenuProvider/menu.d.ts.map +1 -1
- package/dist/types/src/components/EditorMenuProvider/popover.d.ts +2 -1
- package/dist/types/src/components/EditorMenuProvider/popover.d.ts.map +1 -1
- package/dist/types/src/components/EditorMenuProvider/useEditorMenu.d.ts.map +1 -1
- package/dist/types/src/components/EditorPreviewProvider/EditorPreviewProvider.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/EditorToolbar.d.ts +2 -2
- package/dist/types/src/components/EditorToolbar/EditorToolbar.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/blocks.d.ts +4 -18
- package/dist/types/src/components/EditorToolbar/blocks.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/formatting.d.ts +4 -18
- package/dist/types/src/components/EditorToolbar/formatting.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/headings.d.ts +4 -18
- package/dist/types/src/components/EditorToolbar/headings.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/image.d.ts +3 -8
- package/dist/types/src/components/EditorToolbar/image.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/index.d.ts +1 -2
- package/dist/types/src/components/EditorToolbar/index.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/lists.d.ts +6 -0
- package/dist/types/src/components/EditorToolbar/lists.d.ts.map +1 -0
- package/dist/types/src/components/EditorToolbar/search.d.ts +3 -8
- package/dist/types/src/components/EditorToolbar/search.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/types.d.ts +6 -0
- package/dist/types/src/components/EditorToolbar/types.d.ts.map +1 -0
- package/dist/types/src/components/EditorToolbar/view-mode.d.ts +5 -19
- package/dist/types/src/components/EditorToolbar/view-mode.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/extensions/Assistant.stories.d.ts +10 -0
- package/dist/types/src/extensions/Assistant.stories.d.ts.map +1 -0
- package/dist/types/src/extensions/assistant-extension.d.ts +24 -0
- package/dist/types/src/extensions/assistant-extension.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +2 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useBasicMarkdownExtensions.d.ts +25 -0
- package/dist/types/src/hooks/useBasicMarkdownExtensions.d.ts.map +1 -0
- package/dist/types/src/hooks/useTextEditor.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/stories/Automerge.stories.d.ts +25 -24
- package/dist/types/src/stories/Automerge.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Comments.stories.d.ts +2 -2
- package/dist/types/src/stories/Comments.stories.d.ts.map +1 -1
- package/dist/types/src/stories/EditorToolbar.stories.d.ts +28 -26
- package/dist/types/src/stories/EditorToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Experimental.stories.d.ts +3 -3
- package/dist/types/src/stories/Experimental.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Markdown.stories.d.ts +2 -2
- package/dist/types/src/stories/Markdown.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Outliner.stories.d.ts +2 -2
- package/dist/types/src/stories/Outliner.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Popover.stories.d.ts +2 -2
- package/dist/types/src/stories/Popover.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Preview.stories.d.ts +2 -2
- package/dist/types/src/stories/Preview.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Tags.stories.d.ts.map +1 -1
- package/dist/types/src/stories/TextEditor.stories.d.ts +2 -2
- package/dist/types/src/stories/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Theme.stories.d.ts.map +1 -1
- package/dist/types/src/stories/components/EditorStory.d.ts +4 -4
- package/dist/types/src/stories/components/EditorStory.d.ts.map +1 -1
- package/dist/types/src/stories/components/util.d.ts +3 -2
- package/dist/types/src/stories/components/util.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +24 -24
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util/react.d.ts +2 -5
- package/dist/types/src/util/react.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +77 -68
- package/src/components/Editor/Editor.stories.tsx +15 -21
- package/src/components/Editor/Editor.tsx +54 -53
- package/src/components/Editor/EditorView.tsx +102 -0
- package/src/components/EditorMenuProvider/EditorMenuProvider.tsx +19 -24
- package/src/components/EditorMenuProvider/menu-presets.ts +1 -0
- package/src/components/EditorMenuProvider/popover.ts +3 -1
- package/src/components/EditorMenuProvider/useEditorMenu.ts +8 -1
- package/src/components/EditorPreviewProvider/EditorPreviewProvider.tsx +1 -1
- package/src/components/EditorToolbar/EditorToolbar.tsx +31 -65
- package/src/components/EditorToolbar/blocks.ts +54 -46
- package/src/components/EditorToolbar/formatting.ts +44 -45
- package/src/components/EditorToolbar/headings.ts +44 -50
- package/src/components/EditorToolbar/image.ts +16 -21
- package/src/components/EditorToolbar/index.ts +2 -3
- package/src/components/EditorToolbar/lists.ts +58 -0
- package/src/components/EditorToolbar/search.ts +16 -21
- package/src/components/EditorToolbar/types.ts +8 -0
- package/src/components/EditorToolbar/view-mode.ts +37 -43
- package/src/components/index.ts +0 -3
- package/src/extensions/Assistant.stories.tsx +112 -0
- package/src/extensions/assistant-extension.tsx +223 -0
- package/src/extensions/index.ts +5 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useBasicMarkdownExtensions.ts +55 -0
- package/src/index.ts +1 -4
- package/src/stories/Automerge.stories.tsx +18 -16
- package/src/stories/Comments.stories.tsx +6 -6
- package/src/stories/EditorToolbar.stories.tsx +37 -65
- package/src/stories/Experimental.stories.tsx +12 -12
- package/src/stories/Markdown.stories.tsx +2 -2
- package/src/stories/Outliner.stories.tsx +4 -5
- package/src/stories/Popover.stories.tsx +10 -11
- package/src/stories/Preview.stories.tsx +51 -43
- package/src/stories/Tags.stories.tsx +5 -5
- package/src/stories/TextEditor.stories.tsx +2 -2
- package/src/stories/Theme.stories.tsx +4 -4
- package/src/stories/components/EditorStory.tsx +19 -12
- package/src/stories/components/util.tsx +49 -50
- package/src/translations.ts +29 -24
- package/src/util/react.tsx +4 -13
- package/dist/types/src/components/EditorContent/EditorContent.d.ts.map +0 -1
- package/dist/types/src/components/EditorContent/controller.d.ts.map +0 -1
- package/dist/types/src/components/EditorContent/index.d.ts +0 -3
- package/dist/types/src/components/EditorContent/index.d.ts.map +0 -1
- package/dist/types/src/components/EditorToolbar/actions.d.ts +0 -24
- package/dist/types/src/components/EditorToolbar/actions.d.ts.map +0 -1
- package/dist/types/src/components/EditorToolbar/useEditorToolbar.d.ts +0 -11
- package/dist/types/src/components/EditorToolbar/useEditorToolbar.d.ts.map +0 -1
- package/dist/types/src/stories/CommandDialog.stories.d.ts +0 -14
- package/dist/types/src/stories/CommandDialog.stories.d.ts.map +0 -1
- package/src/components/EditorContent/EditorContent.tsx +0 -83
- package/src/components/EditorContent/index.ts +0 -6
- package/src/components/EditorToolbar/actions.ts +0 -87
- package/src/components/EditorToolbar/useEditorToolbar.ts +0 -20
- package/src/stories/CommandDialog.stories.tsx +0 -81
- /package/dist/types/src/components/{EditorContent → Editor}/controller.d.ts +0 -0
- /package/src/components/{EditorContent → Editor}/controller.ts +0 -0
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type EditorView } from '@codemirror/view';
|
|
6
|
-
|
|
7
|
-
import { type Node } from '@dxos/app-graph';
|
|
8
|
-
import {
|
|
9
|
-
type MenuItemGroup,
|
|
10
|
-
type ToolbarMenuActionGroupProperties,
|
|
11
|
-
createMenuAction,
|
|
12
|
-
createMenuItemGroup,
|
|
13
|
-
} from '@dxos/react-ui-menu';
|
|
14
|
-
import { List, addList, removeList } from '@dxos/ui-editor';
|
|
15
|
-
import { type MenuActionProperties } from '@dxos/ui-types';
|
|
16
|
-
|
|
17
|
-
import { translationKey } from '../../translations';
|
|
18
|
-
|
|
19
|
-
import { type EditorToolbarState } from './useEditorToolbar';
|
|
20
|
-
|
|
21
|
-
const listStyles = {
|
|
22
|
-
bullet: 'ph--list-bullets--regular',
|
|
23
|
-
ordered: 'ph--list-numbers--regular',
|
|
24
|
-
task: 'ph--list-checks--regular',
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const createLists = (state: EditorToolbarState, getView: () => EditorView) => {
|
|
28
|
-
const value = state.listStyle ?? '';
|
|
29
|
-
const listGroupAction = createListGroupAction(value);
|
|
30
|
-
const listActionsMap = createListActions(value, getView);
|
|
31
|
-
return {
|
|
32
|
-
nodes: [listGroupAction as Node.NodeArg<any>, ...listActionsMap],
|
|
33
|
-
edges: [
|
|
34
|
-
{ source: 'root', target: 'list' },
|
|
35
|
-
...listActionsMap.map(({ id }) => ({ source: listGroupAction.id, target: id })),
|
|
36
|
-
],
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const createEditorAction = (id: string, props: Partial<MenuActionProperties>, invoke: () => void) => {
|
|
41
|
-
const { label = [`${id} label`, { ns: translationKey }], ...rest } = props;
|
|
42
|
-
|
|
43
|
-
return createMenuAction(id, invoke, {
|
|
44
|
-
label,
|
|
45
|
-
...rest,
|
|
46
|
-
}) as Node.Action<MenuActionProperties>;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const createEditorActionGroup = (
|
|
50
|
-
id: string,
|
|
51
|
-
props: Omit<ToolbarMenuActionGroupProperties, 'icon'>,
|
|
52
|
-
icon?: string,
|
|
53
|
-
): MenuItemGroup<ToolbarMenuActionGroupProperties> => {
|
|
54
|
-
const { label = [`${id} label`, { ns: translationKey }], ...rest } = props;
|
|
55
|
-
|
|
56
|
-
return createMenuItemGroup(id, {
|
|
57
|
-
label,
|
|
58
|
-
icon,
|
|
59
|
-
iconOnly: true,
|
|
60
|
-
...rest,
|
|
61
|
-
}) as MenuItemGroup<ToolbarMenuActionGroupProperties>;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const createListGroupAction = (value: string) =>
|
|
65
|
-
createEditorActionGroup('list', {
|
|
66
|
-
variant: 'toggleGroup',
|
|
67
|
-
selectCardinality: 'single',
|
|
68
|
-
value,
|
|
69
|
-
} as ToolbarMenuActionGroupProperties);
|
|
70
|
-
|
|
71
|
-
const createListActions = (value: string, getView: () => EditorView) =>
|
|
72
|
-
Object.entries(listStyles).map(([listStyle, icon]) => {
|
|
73
|
-
const checked = value === listStyle;
|
|
74
|
-
return createEditorAction(`list-${listStyle}`, { checked, icon }, () => {
|
|
75
|
-
const view = getView();
|
|
76
|
-
if (!view) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const listType = listStyle === 'ordered' ? List.Ordered : listStyle === 'bullet' ? List.Bullet : List.Task;
|
|
81
|
-
if (checked) {
|
|
82
|
-
removeList(listType)(view);
|
|
83
|
-
} else {
|
|
84
|
-
addList(listType)(view);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Atom } from '@effect-atom/atom-react';
|
|
6
|
-
import { useMemo } from 'react';
|
|
7
|
-
|
|
8
|
-
import { type EditorViewMode, type Formatting } from '@dxos/ui-editor';
|
|
9
|
-
|
|
10
|
-
// TODO(burdon): Move to extensions.
|
|
11
|
-
export type EditorToolbarState = { viewMode?: EditorViewMode } & Formatting;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Creates an atom for editor toolbar state.
|
|
15
|
-
* @deprecated Use Editor.Root
|
|
16
|
-
*/
|
|
17
|
-
export const useEditorToolbar = (initialState: EditorToolbarState = {}): Atom.Writable<EditorToolbarState> => {
|
|
18
|
-
// TODO(wittjosiah): Including initialState in the deps causes reactivity issues.
|
|
19
|
-
return useMemo(() => Atom.make<EditorToolbarState>(initialState), []);
|
|
20
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
-
import React, { type KeyboardEvent, useState } from 'react';
|
|
7
|
-
|
|
8
|
-
import { type Button, IconButton, Input } from '@dxos/react-ui';
|
|
9
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
10
|
-
import { editorWidth, join } from '@dxos/ui-editor';
|
|
11
|
-
import { mx } from '@dxos/ui-theme';
|
|
12
|
-
|
|
13
|
-
import { EditorStory } from './components';
|
|
14
|
-
|
|
15
|
-
// TODO(burdon): Reimplement with Popover.
|
|
16
|
-
const CommandDialog = ({ onAction }: { onAction: (action?: any) => void }) => {
|
|
17
|
-
const [text, setText] = useState('');
|
|
18
|
-
|
|
19
|
-
const handleInsert = () => {
|
|
20
|
-
// TODO(burdon): Use queue ref.
|
|
21
|
-
const link = ``;
|
|
22
|
-
onAction(text.length ? { type: 'insert', text: link } : undefined);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
|
|
26
|
-
switch (event.key) {
|
|
27
|
-
case 'Enter': {
|
|
28
|
-
handleInsert();
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
case 'Escape': {
|
|
32
|
-
onAction();
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<div className='flex is-full justify-center'>
|
|
40
|
-
<div
|
|
41
|
-
className={mx(
|
|
42
|
-
'flex is-full p-2 gap-2 items-center bg-modalSurface border border-separator rounded-md',
|
|
43
|
-
editorWidth,
|
|
44
|
-
)}
|
|
45
|
-
>
|
|
46
|
-
<Input.Root>
|
|
47
|
-
<Input.TextInput
|
|
48
|
-
autoFocus={true}
|
|
49
|
-
placeholder='Ask a question...'
|
|
50
|
-
value={text}
|
|
51
|
-
onChange={(ev) => setText(ev.target.value)}
|
|
52
|
-
onKeyDown={handleKeyDown}
|
|
53
|
-
/>
|
|
54
|
-
</Input.Root>
|
|
55
|
-
<IconButton
|
|
56
|
-
icon='ph--x--regular'
|
|
57
|
-
label='Cancel'
|
|
58
|
-
iconOnly
|
|
59
|
-
variant='ghost'
|
|
60
|
-
classNames='pli-0'
|
|
61
|
-
onClick={() => onAction({ type: 'cancel' })}
|
|
62
|
-
/>
|
|
63
|
-
</div>
|
|
64
|
-
</div>
|
|
65
|
-
);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const meta = {
|
|
69
|
-
title: 'ui/react-ui-editor/CommandDialog',
|
|
70
|
-
render: () => <EditorStory text={join('# Command', '', '')} extensions={[]} />,
|
|
71
|
-
decorators: [withTheme()],
|
|
72
|
-
parameters: {
|
|
73
|
-
layout: 'fullscreen',
|
|
74
|
-
},
|
|
75
|
-
} satisfies Meta<typeof Button>;
|
|
76
|
-
|
|
77
|
-
export default meta;
|
|
78
|
-
|
|
79
|
-
type Story = StoryObj<typeof meta>;
|
|
80
|
-
|
|
81
|
-
export const Default: Story = {};
|
|
File without changes
|
|
File without changes
|