@dxos/react-ui-chat 0.8.4-main.f9ba587 → 0.8.4-main.fffef41
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 +68 -232
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +68 -232
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/ChatDialog/ChatDialog.d.ts +1 -1
- package/dist/types/src/components/ChatDialog/ChatDialog.d.ts.map +1 -1
- package/dist/types/src/components/ChatDialog/ChatDialog.stories.d.ts +35 -5
- package/dist/types/src/components/ChatDialog/ChatDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatEditor/ChatEditor.d.ts +5 -7
- package/dist/types/src/components/ChatEditor/ChatEditor.d.ts.map +1 -1
- package/dist/types/src/components/ChatEditor/ChatEditor.stories.d.ts +20 -5
- package/dist/types/src/components/ChatEditor/ChatEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatEditor/references.d.ts +4 -0
- package/dist/types/src/components/ChatEditor/references.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -34
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +40 -38
- package/src/components/ChatDialog/ChatDialog.stories.tsx +9 -10
- package/src/components/ChatDialog/ChatDialog.tsx +9 -9
- package/src/components/ChatEditor/ChatEditor.stories.tsx +24 -23
- package/src/components/ChatEditor/ChatEditor.tsx +33 -65
- package/src/components/ChatEditor/references.ts +18 -12
- package/src/index.ts +1 -0
- package/src/translations.ts +1 -40
- package/dist/types/src/components/ChatEditor/autocomplete.d.ts +0 -25
- package/dist/types/src/components/ChatEditor/autocomplete.d.ts.map +0 -1
- package/src/components/ChatEditor/autocomplete.ts +0 -218
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-chat",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.fffef41",
|
|
4
4
|
"description": "Chat components.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
+
"source": "./src/index.ts",
|
|
12
13
|
"types": "./dist/types/src/index.d.ts",
|
|
13
14
|
"browser": "./dist/lib/browser/index.mjs",
|
|
14
15
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
@@ -23,50 +24,51 @@
|
|
|
23
24
|
"src"
|
|
24
25
|
],
|
|
25
26
|
"dependencies": {
|
|
26
|
-
"@codemirror/autocomplete": "^6.
|
|
27
|
-
"@codemirror/language": "^6.
|
|
28
|
-
"@codemirror/search": "^6.5.
|
|
29
|
-
"@codemirror/state": "^6.
|
|
30
|
-
"@codemirror/view": "^6.
|
|
27
|
+
"@codemirror/autocomplete": "^6.19.0",
|
|
28
|
+
"@codemirror/language": "^6.11.3",
|
|
29
|
+
"@codemirror/search": "^6.5.11",
|
|
30
|
+
"@codemirror/state": "^6.5.2",
|
|
31
|
+
"@codemirror/view": "^6.38.4",
|
|
32
|
+
"@fluentui/react-tabster": "^9.24.2",
|
|
31
33
|
"@preact-signals/safe-react": "^0.9.0",
|
|
32
|
-
"@preact/signals-core": "^1.
|
|
34
|
+
"@preact/signals-core": "^1.12.1",
|
|
33
35
|
"@radix-ui/react-accordion": "1.2.3",
|
|
34
36
|
"@radix-ui/react-context": "1.1.1",
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
42
|
-
"@dxos/react-ui-
|
|
43
|
-
"@dxos/react-ui-editor": "0.8.4-main.
|
|
44
|
-
"@dxos/react-ui-
|
|
45
|
-
"@dxos/react-ui-
|
|
46
|
-
"@dxos/react-ui-
|
|
47
|
-
"@dxos/react-ui
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/react-ui-
|
|
50
|
-
"@dxos/
|
|
37
|
+
"@dxos/echo": "0.8.4-main.fffef41",
|
|
38
|
+
"@dxos/async": "0.8.4-main.fffef41",
|
|
39
|
+
"@dxos/invariant": "0.8.4-main.fffef41",
|
|
40
|
+
"@dxos/live-object": "0.8.4-main.fffef41",
|
|
41
|
+
"@dxos/log": "0.8.4-main.fffef41",
|
|
42
|
+
"@dxos/debug": "0.8.4-main.fffef41",
|
|
43
|
+
"@dxos/react-ui-components": "0.8.4-main.fffef41",
|
|
44
|
+
"@dxos/react-ui-dnd": "0.8.4-main.fffef41",
|
|
45
|
+
"@dxos/react-ui-editor": "0.8.4-main.fffef41",
|
|
46
|
+
"@dxos/react-ui-sfx": "0.8.4-main.fffef41",
|
|
47
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.fffef41",
|
|
48
|
+
"@dxos/react-ui-text-tooltip": "0.8.4-main.fffef41",
|
|
49
|
+
"@dxos/react-ui": "0.8.4-main.fffef41",
|
|
50
|
+
"@dxos/util": "0.8.4-main.fffef41",
|
|
51
|
+
"@dxos/react-ui-theme": "0.8.4-main.fffef41",
|
|
52
|
+
"@dxos/react-ui-types": "0.8.4-main.fffef41"
|
|
51
53
|
},
|
|
52
54
|
"devDependencies": {
|
|
53
|
-
"@types/react": "~
|
|
54
|
-
"@types/react-dom": "~
|
|
55
|
-
"effect": "3.
|
|
56
|
-
"react": "~
|
|
57
|
-
"react-dom": "~
|
|
58
|
-
"vite": "
|
|
59
|
-
"@dxos/echo": "0.8.4-main.
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/
|
|
55
|
+
"@types/react": "~19.2.2",
|
|
56
|
+
"@types/react-dom": "~19.2.2",
|
|
57
|
+
"effect": "3.18.3",
|
|
58
|
+
"react": "~19.2.0",
|
|
59
|
+
"react-dom": "~19.2.0",
|
|
60
|
+
"vite": "7.1.9",
|
|
61
|
+
"@dxos/echo": "0.8.4-main.fffef41",
|
|
62
|
+
"@dxos/react-client": "0.8.4-main.fffef41",
|
|
63
|
+
"@dxos/storybook-utils": "0.8.4-main.fffef41",
|
|
64
|
+
"@dxos/random": "0.8.4-main.fffef41"
|
|
63
65
|
},
|
|
64
66
|
"peerDependencies": {
|
|
65
|
-
"effect": "3.13.3",
|
|
66
|
-
"react": "
|
|
67
|
-
"react-dom": "
|
|
68
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
69
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
67
|
+
"effect": "^3.13.3",
|
|
68
|
+
"react": "^19.0.0",
|
|
69
|
+
"react-dom": "^19.0.0",
|
|
70
|
+
"@dxos/react-ui": "0.8.4-main.fffef41",
|
|
71
|
+
"@dxos/react-ui-theme": "0.8.4-main.fffef41"
|
|
70
72
|
},
|
|
71
73
|
"publishConfig": {
|
|
72
74
|
"access": "public"
|
|
@@ -2,20 +2,19 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type StoryObj, type Meta } from '@storybook/react-vite';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useState } from 'react';
|
|
9
7
|
|
|
10
8
|
import { Input, Toolbar } from '@dxos/react-ui';
|
|
11
|
-
import {
|
|
9
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
12
10
|
|
|
13
|
-
import { ChatDialog } from './ChatDialog';
|
|
14
11
|
import { translations } from '../../translations';
|
|
15
12
|
|
|
13
|
+
import { ChatDialog } from './ChatDialog';
|
|
14
|
+
|
|
16
15
|
const items = Array.from({ length: 100 }, (_, i) => `Item ${i}`);
|
|
17
16
|
|
|
18
|
-
const meta
|
|
17
|
+
const meta = {
|
|
19
18
|
title: 'ui/react-ui-chat/ChatDialog',
|
|
20
19
|
component: ChatDialog.Root,
|
|
21
20
|
render: (args) => {
|
|
@@ -43,7 +42,7 @@ const meta: Meta<typeof ChatDialog.Root> = {
|
|
|
43
42
|
</div>
|
|
44
43
|
))}
|
|
45
44
|
</ChatDialog.Content>
|
|
46
|
-
<ChatDialog.Footer classNames='
|
|
45
|
+
<ChatDialog.Footer classNames='pli-2 items-center'>
|
|
47
46
|
<Input.Root>
|
|
48
47
|
<Input.TextInput classNames='border-none' placeholder='Test' />
|
|
49
48
|
</Input.Root>
|
|
@@ -52,14 +51,14 @@ const meta: Meta<typeof ChatDialog.Root> = {
|
|
|
52
51
|
</>
|
|
53
52
|
);
|
|
54
53
|
},
|
|
55
|
-
decorators: [withTheme, withLayout({
|
|
54
|
+
decorators: [withTheme, withLayout({ container: 'column' })],
|
|
56
55
|
parameters: {
|
|
57
56
|
translations,
|
|
58
57
|
},
|
|
59
|
-
}
|
|
58
|
+
} satisfies Meta<typeof ChatDialog.Root>;
|
|
60
59
|
|
|
61
60
|
export default meta;
|
|
62
61
|
|
|
63
|
-
type Story = StoryObj<typeof
|
|
62
|
+
type Story = StoryObj<typeof meta>;
|
|
64
63
|
|
|
65
64
|
export const Default: Story = {};
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { createContext } from '@radix-ui/react-context';
|
|
6
6
|
import React, { type Dispatch, type PropsWithChildren, type SetStateAction, useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import { Dialog, Icon, IconButton,
|
|
9
|
-
import {
|
|
8
|
+
import { Dialog, Icon, IconButton, type ThemedClassName, useControlledState } from '@dxos/react-ui';
|
|
9
|
+
import { ResizeHandle, type Size, resizeAttributes, sizeStyle } from '@dxos/react-ui-dnd';
|
|
10
10
|
import { mx } from '@dxos/react-ui-theme';
|
|
11
11
|
|
|
12
12
|
const preventDefault = (event: Event) => event.preventDefault();
|
|
@@ -14,7 +14,7 @@ const preventDefault = (event: Event) => event.preventDefault();
|
|
|
14
14
|
// TODO(burdon): Factor out.
|
|
15
15
|
const Endcap = ({ children }: PropsWithChildren) => {
|
|
16
16
|
return (
|
|
17
|
-
<div className='grid
|
|
17
|
+
<div className='grid is-[var(--rail-action)] bs-[var(--rail-action)] items-center justify-center'>{children}</div>
|
|
18
18
|
);
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -47,15 +47,15 @@ type ChatDialogRootProps = PropsWithChildren<{
|
|
|
47
47
|
|
|
48
48
|
const ChatDialogRoot = ({
|
|
49
49
|
children,
|
|
50
|
-
open:
|
|
51
|
-
expanded:
|
|
50
|
+
open: openParam = false,
|
|
51
|
+
expanded: expandedParam = false,
|
|
52
52
|
onOpenChange,
|
|
53
53
|
onExpandedChange,
|
|
54
54
|
onEscape,
|
|
55
55
|
}: ChatDialogRootProps) => {
|
|
56
56
|
const [size, setSize] = useState<Size>('min-content');
|
|
57
|
-
const [open, setOpen] = useControlledState<boolean>(
|
|
58
|
-
const [expanded, setExpanded] = useControlledState<boolean>(
|
|
57
|
+
const [open, setOpen] = useControlledState<boolean>(openParam, onOpenChange);
|
|
58
|
+
const [expanded, setExpanded] = useControlledState<boolean>(expandedParam, onExpandedChange);
|
|
59
59
|
|
|
60
60
|
// NOTE: We set the min size to 5rem (80px), and the header and prompt bar to 40px (i.e., the rail-size) each.
|
|
61
61
|
// The dialog has no vertical padding and has box-content so that when closed it collapses to the size of the header and prompt bar.
|
|
@@ -108,7 +108,7 @@ const ChatDialogHeader = ({ classNames, title }: ChatDialogHeaderProps) => {
|
|
|
108
108
|
</Dialog.Close>
|
|
109
109
|
</Endcap>
|
|
110
110
|
<Dialog.Title
|
|
111
|
-
classNames='flex
|
|
111
|
+
classNames='flex is-full justify-center text-sm text-subdued select-none cursor-pointer'
|
|
112
112
|
onClick={() => setExpanded((expanded) => !expanded)}
|
|
113
113
|
>
|
|
114
114
|
{title}
|
|
@@ -144,7 +144,7 @@ const ChatDialogContent = ({ children, classNames }: ChatDialogContentProps) =>
|
|
|
144
144
|
return (
|
|
145
145
|
<div
|
|
146
146
|
className={mx(
|
|
147
|
-
'flex flex-col overflow-y-auto border-t border-
|
|
147
|
+
'flex flex-col overflow-y-auto border-t border-be border-subduedSeparator',
|
|
148
148
|
'transition-[block-size] ease-in-out duration-0 [&:not([data-dx-resizing="true"])]:duration-200',
|
|
149
149
|
classNames,
|
|
150
150
|
)}
|
|
@@ -2,18 +2,17 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type StoryObj, type Meta } from '@storybook/react-vite';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
|
|
9
7
|
import { log } from '@dxos/log';
|
|
10
|
-
import { withTheme } from '@dxos/
|
|
8
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
9
|
+
|
|
10
|
+
import { translations } from '../../translations';
|
|
11
11
|
|
|
12
12
|
import { ChatEditor } from './ChatEditor';
|
|
13
13
|
import { type ReferenceData } from './references';
|
|
14
|
-
import { translations } from '../../translations';
|
|
15
14
|
|
|
16
|
-
const meta
|
|
15
|
+
const meta = {
|
|
17
16
|
title: 'ui/react-ui-chat/ChatEditor',
|
|
18
17
|
component: ChatEditor,
|
|
19
18
|
decorators: [withTheme],
|
|
@@ -21,13 +20,13 @@ const meta: Meta<typeof ChatEditor> = {
|
|
|
21
20
|
layout: 'centered',
|
|
22
21
|
translations,
|
|
23
22
|
},
|
|
24
|
-
}
|
|
23
|
+
} satisfies Meta<typeof ChatEditor>;
|
|
25
24
|
|
|
26
25
|
export default meta;
|
|
27
26
|
|
|
28
|
-
const classNames = '
|
|
27
|
+
const classNames = 'is-[20rem] p-2 border border-separator';
|
|
29
28
|
|
|
30
|
-
type Story = StoryObj<typeof
|
|
29
|
+
type Story = StoryObj<typeof meta>;
|
|
31
30
|
|
|
32
31
|
export const Default: Story = {
|
|
33
32
|
args: {
|
|
@@ -35,31 +34,33 @@ export const Default: Story = {
|
|
|
35
34
|
},
|
|
36
35
|
};
|
|
37
36
|
|
|
37
|
+
// TODO(burdon): Restore and reconcile with suggest/typeahead.
|
|
38
38
|
export const WithSuggestions: Story = {
|
|
39
39
|
args: {
|
|
40
40
|
classNames,
|
|
41
41
|
onSubmit: (text) => {
|
|
42
42
|
log('onSubmit', { text });
|
|
43
43
|
},
|
|
44
|
-
onSuggest: (text) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
// onSuggest: (text) => {
|
|
45
|
+
// const trimmed = text.trim().toLowerCase();
|
|
46
|
+
// if (trimmed.length < 2) {
|
|
47
|
+
// return [];
|
|
48
|
+
// }
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
// const suggestions = [
|
|
51
|
+
// 'Create a kanban board',
|
|
52
|
+
// 'Create a new project',
|
|
53
|
+
// 'Find flights to Tokyo',
|
|
54
|
+
// "Let's play chess",
|
|
55
|
+
// 'Show me Paris on a map',
|
|
56
|
+
// ];
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
},
|
|
58
|
+
// return suggestions.filter((s) => s.toLowerCase().startsWith(text));
|
|
59
|
+
// },
|
|
60
60
|
},
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
+
// TODO(burdon): Replace.
|
|
63
64
|
const references: ReferenceData[] = [
|
|
64
65
|
{
|
|
65
66
|
uri: 'dxn:echo:@:AAAAAAAA',
|
|
@@ -3,89 +3,57 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Extension } from '@codemirror/state';
|
|
6
|
-
import React, { forwardRef,
|
|
6
|
+
import React, { forwardRef, useMemo } from 'react';
|
|
7
7
|
|
|
8
8
|
import { type ThemedClassName, useThemeContext } from '@dxos/react-ui';
|
|
9
9
|
import {
|
|
10
10
|
type BasicExtensionsOptions,
|
|
11
|
+
Editor,
|
|
12
|
+
type EditorController,
|
|
13
|
+
type SubmitOptions,
|
|
11
14
|
type UseTextEditorProps,
|
|
12
15
|
createBasicExtensions,
|
|
13
16
|
createThemeExtensions,
|
|
14
|
-
|
|
17
|
+
submit,
|
|
15
18
|
} from '@dxos/react-ui-editor';
|
|
16
|
-
import {
|
|
17
|
-
import { isNonNullable } from '@dxos/util';
|
|
19
|
+
import { isTruthy } from '@dxos/util';
|
|
18
20
|
|
|
19
|
-
import {
|
|
20
|
-
import { references as referencesExtension, type ReferencesOptions } from './references';
|
|
21
|
+
import { type ReferencesOptions } from './references';
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export interface ChatEditorController {
|
|
25
|
-
focus(): void;
|
|
26
|
-
setText(text: string): void;
|
|
27
|
-
}
|
|
23
|
+
export interface ChatEditorController extends EditorController {}
|
|
28
24
|
|
|
29
25
|
export type ChatEditorProps = ThemedClassName<
|
|
30
26
|
{
|
|
31
27
|
extensions?: Extension;
|
|
32
28
|
references?: ReferencesOptions;
|
|
33
|
-
} &
|
|
34
|
-
Pick<UseTextEditorProps, 'autoFocus'> &
|
|
35
|
-
Pick<BasicExtensionsOptions, 'lineWrapping' | 'placeholder'>
|
|
29
|
+
} & (SubmitOptions &
|
|
30
|
+
Pick<UseTextEditorProps, 'id' | 'autoFocus'> &
|
|
31
|
+
Pick<BasicExtensionsOptions, 'lineWrapping' | 'placeholder'>)
|
|
36
32
|
>;
|
|
37
33
|
|
|
38
|
-
export const
|
|
39
|
-
(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
references ? referencesExtension({ provider: references.provider }) : [],
|
|
52
|
-
createBasicExtensions({
|
|
53
|
-
bracketMatching: false,
|
|
54
|
-
lineWrapping,
|
|
55
|
-
placeholder,
|
|
56
|
-
}),
|
|
57
|
-
extensions,
|
|
58
|
-
].filter(isNonNullable),
|
|
59
|
-
},
|
|
60
|
-
[themeMode, extensions, onSubmit, onSuggest],
|
|
61
|
-
);
|
|
34
|
+
export const useChatExtensions = ({ extensions, lineWrapping = false, placeholder, onSubmit }: ChatEditorProps) => {
|
|
35
|
+
const { themeMode } = useThemeContext();
|
|
36
|
+
return useMemo<Extension[]>(
|
|
37
|
+
() =>
|
|
38
|
+
[
|
|
39
|
+
createThemeExtensions({ themeMode }),
|
|
40
|
+
createBasicExtensions({ bracketMatching: false, lineWrapping, placeholder }),
|
|
41
|
+
submit({ onSubmit }),
|
|
42
|
+
extensions,
|
|
43
|
+
].filter(isTruthy),
|
|
44
|
+
[themeMode, extensions, onSubmit],
|
|
45
|
+
);
|
|
46
|
+
};
|
|
62
47
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
view?.dispatch({
|
|
73
|
-
changes: {
|
|
74
|
-
from: 0,
|
|
75
|
-
to: view.state.doc.length,
|
|
76
|
-
insert: text,
|
|
77
|
-
},
|
|
78
|
-
selection: {
|
|
79
|
-
anchor: text.length,
|
|
80
|
-
head: text.length,
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
},
|
|
86
|
-
[view, onSubmit],
|
|
48
|
+
export const ChatEditor = forwardRef<ChatEditorController, ChatEditorProps>(
|
|
49
|
+
({ classNames, autoFocus, extensions: extensionsParam, lineWrapping = false, placeholder, onSubmit }, forwardRef) => {
|
|
50
|
+
const extensions = useChatExtensions({ extensions: extensionsParam, lineWrapping, placeholder, onSubmit });
|
|
51
|
+
|
|
52
|
+
// TODO(burdon): Popover.
|
|
53
|
+
return (
|
|
54
|
+
<Editor.Root ref={forwardRef}>
|
|
55
|
+
<Editor.Content classNames={classNames} autoFocus={autoFocus} extensions={extensions} />
|
|
56
|
+
</Editor.Root>
|
|
87
57
|
);
|
|
88
|
-
|
|
89
|
-
return <div ref={parentRef} className={mx('is-full', classNames)} />;
|
|
90
58
|
},
|
|
91
59
|
);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { autocompletion, completionKeymap
|
|
5
|
+
import { type CompletionResult, autocompletion, completionKeymap } from '@codemirror/autocomplete';
|
|
6
6
|
import { type Extension, RangeSet } from '@codemirror/state';
|
|
7
7
|
import {
|
|
8
8
|
Decoration,
|
|
@@ -19,10 +19,14 @@ import { invariant } from '@dxos/invariant';
|
|
|
19
19
|
|
|
20
20
|
// TODO(dmaretskyi): Consider adding details renderer for when you hover over the reference.
|
|
21
21
|
export type ReferenceData = {
|
|
22
|
-
uri: string;
|
|
22
|
+
uri: string; // TODO(burdon): Rename dxn.
|
|
23
23
|
label: string;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated
|
|
28
|
+
*/
|
|
29
|
+
// TODO(burdon): Remove.
|
|
26
30
|
export interface ReferencesProvider {
|
|
27
31
|
getReferences({ query }: { query: string }): Promise<ReferenceData[]>;
|
|
28
32
|
resolveReference({ uri }: { uri: string }): Promise<ReferenceData | null>;
|
|
@@ -45,7 +49,9 @@ export type ReferencesOptions = {
|
|
|
45
49
|
|
|
46
50
|
/**
|
|
47
51
|
* Lookup object references.
|
|
52
|
+
* @deprecated
|
|
48
53
|
*/
|
|
54
|
+
// TODO(burdon): Remove.
|
|
49
55
|
export const references = ({ provider, triggerCharacter = '@', debug = false }: ReferencesOptions): Extension => {
|
|
50
56
|
invariant(triggerCharacter.length === 1);
|
|
51
57
|
|
|
@@ -103,7 +109,7 @@ export const references = ({ provider, triggerCharacter = '@', debug = false }:
|
|
|
103
109
|
},
|
|
104
110
|
{
|
|
105
111
|
decorations: (v) => v.decorations,
|
|
106
|
-
provide: (
|
|
112
|
+
provide: () => [
|
|
107
113
|
EditorView.atomicRanges.of(
|
|
108
114
|
(view): DecorationSet => view.plugin(decorationField)?.decorations ?? RangeSet.empty,
|
|
109
115
|
),
|
|
@@ -158,18 +164,18 @@ class ReferenceWidget extends WidgetType {
|
|
|
158
164
|
super();
|
|
159
165
|
}
|
|
160
166
|
|
|
161
|
-
override
|
|
162
|
-
|
|
163
|
-
span.textContent = `@ ${this.data.label}`;
|
|
164
|
-
span.className = 'cm-reference-pill';
|
|
165
|
-
return span;
|
|
167
|
+
override ignoreEvent() {
|
|
168
|
+
return true;
|
|
166
169
|
}
|
|
167
170
|
|
|
168
|
-
override eq(other:
|
|
169
|
-
return
|
|
171
|
+
override eq(other: this) {
|
|
172
|
+
return this.data.uri === other.data.uri;
|
|
170
173
|
}
|
|
171
174
|
|
|
172
|
-
override
|
|
173
|
-
|
|
175
|
+
override toDOM() {
|
|
176
|
+
const span = document.createElement('span');
|
|
177
|
+
span.textContent = `@${this.data.label}`;
|
|
178
|
+
span.className = 'cm-reference-pill';
|
|
179
|
+
return span;
|
|
174
180
|
}
|
|
175
181
|
}
|
package/src/index.ts
CHANGED
package/src/translations.ts
CHANGED
|
@@ -9,46 +9,7 @@ export const translationKey = 'react-ui-chat';
|
|
|
9
9
|
export const translations = [
|
|
10
10
|
{
|
|
11
11
|
'en-US': {
|
|
12
|
-
[translationKey]: {
|
|
13
|
-
'templates label': 'Templates',
|
|
14
|
-
'open ambient chat label': 'Open Assistant',
|
|
15
|
-
'assistant chat label': 'Assistant',
|
|
16
|
-
'plugin name': 'Assistant',
|
|
17
|
-
'object placeholder': 'New prompt',
|
|
18
|
-
'create object label': 'Create prompt',
|
|
19
|
-
'create trigger label': 'Create trigger',
|
|
20
|
-
'create stack section label': 'Create prompt',
|
|
21
|
-
'command placeholder': 'Enter slash command...',
|
|
22
|
-
'template placeholder': 'Enter template...',
|
|
23
|
-
'value placeholder': 'Enter value...',
|
|
24
|
-
'prompt rules label': 'Prompt Rules',
|
|
25
|
-
'typename placeholder': 'Enter typename of objects which this template is for',
|
|
26
|
-
'description placeholder': 'Enter description of when this template should be used',
|
|
27
|
-
'select preset template placeholder': 'Select preset',
|
|
28
|
-
'service registry label': 'Service Registry',
|
|
29
|
-
|
|
30
|
-
'sequence logs label': 'Logs',
|
|
31
|
-
|
|
32
|
-
'assistant dialog title': 'Assistant',
|
|
33
|
-
'open assistant label': 'Open assistant',
|
|
34
|
-
|
|
35
|
-
'search input placeholder': 'Search...',
|
|
36
|
-
'chat input placeholder': 'Ask a question...',
|
|
37
|
-
'chat stop': 'Cancel request.',
|
|
38
|
-
|
|
39
|
-
'button save': 'Save',
|
|
40
|
-
'button run': 'Run',
|
|
41
|
-
|
|
42
|
-
'prompt placeholder': 'Ask a question...',
|
|
43
|
-
'microphone button': 'Click to speak',
|
|
44
|
-
'cancel processing button': 'Stop processing',
|
|
45
|
-
|
|
46
|
-
'settings default label': 'Default',
|
|
47
|
-
'settings custom prompts label': 'Use custom prompts',
|
|
48
|
-
'settings llm provider label': 'LLM provider',
|
|
49
|
-
'settings edge llm model label': 'Remote language model',
|
|
50
|
-
'settings ollama llm model label': 'Ollama language model',
|
|
51
|
-
},
|
|
12
|
+
[translationKey]: {},
|
|
52
13
|
},
|
|
53
14
|
},
|
|
54
15
|
] as const satisfies Resource[];
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type Extension } from '@codemirror/state';
|
|
2
|
-
export type AutocompleteOptions = {
|
|
3
|
-
/**
|
|
4
|
-
* Callback triggered when Enter is pressed.
|
|
5
|
-
* @param text The current text in the editor
|
|
6
|
-
* @returns true if the editor should reset the document.
|
|
7
|
-
*/
|
|
8
|
-
onSubmit?: (text: string) => boolean | void;
|
|
9
|
-
/**
|
|
10
|
-
* Function that returns a list of suggestions based on the current text.
|
|
11
|
-
* @param text The current text before the cursor
|
|
12
|
-
* @returns Array of suggestion strings
|
|
13
|
-
*/
|
|
14
|
-
onSuggest?: (text: string) => string[];
|
|
15
|
-
/**
|
|
16
|
-
* ESC pressed.
|
|
17
|
-
*/
|
|
18
|
-
onCancel?: () => void;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Creates an autocomplete extension that shows inline suggestions.
|
|
22
|
-
* Pressing Tab will complete the suggestion.
|
|
23
|
-
*/
|
|
24
|
-
export declare const autocomplete: ({ onSubmit, onSuggest, onCancel }: AutocompleteOptions) => Extension;
|
|
25
|
-
//# sourceMappingURL=autocomplete.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../../../src/components/ChatEditor/autocomplete.ts"],"names":[],"mappings":"AAIA,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAWzD,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,CAAC;IAE5C;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IAEvC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AAEF;;;GAGG;AAEH,eAAO,MAAM,YAAY,GAAI,mCAAmC,mBAAmB,KAAG,SA+JrF,CAAC"}
|