@dxos/react-ui-thread 0.8.4-main.7ace549 → 0.8.4-main.937b3ca

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/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-thread",
3
- "version": "0.8.4-main.7ace549",
3
+ "version": "0.8.4-main.937b3ca",
4
4
  "description": "A set of components to use with threads, including comments and messages.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
7
11
  "license": "MIT",
8
12
  "author": "DXOS.org",
9
- "sideEffects": true,
13
+ "sideEffects": false,
10
14
  "type": "module",
11
15
  "exports": {
12
16
  ".": {
@@ -24,33 +28,32 @@
24
28
  "src"
25
29
  ],
26
30
  "dependencies": {
27
- "@preact-signals/safe-react": "^0.9.0",
28
31
  "@radix-ui/react-primitive": "2.0.2",
29
32
  "date-fns": "^3.3.1",
30
- "@dxos/react-ui-editor": "0.8.4-main.7ace549",
31
- "@dxos/util": "0.8.4-main.7ace549"
33
+ "@dxos/react-ui-editor": "0.8.4-main.937b3ca",
34
+ "@dxos/ui-editor": "0.8.4-main.937b3ca",
35
+ "@dxos/util": "0.8.4-main.937b3ca"
32
36
  },
33
37
  "devDependencies": {
34
- "@types/react": "~19.2.2",
35
- "@types/react-dom": "~19.2.2",
36
- "react": "~19.2.0",
37
- "react-dom": "~19.2.0",
38
+ "@types/react": "~19.2.7",
39
+ "@types/react-dom": "~19.2.3",
40
+ "react": "~19.2.3",
41
+ "react-dom": "~19.2.3",
38
42
  "vite": "7.1.9",
39
- "@dxos/echo": "0.8.4-main.7ace549",
40
- "@dxos/echo-db": "0.8.4-main.7ace549",
41
- "@dxos/keys": "0.8.4-main.7ace549",
42
- "@dxos/live-object": "0.8.4-main.7ace549",
43
- "@dxos/log": "0.8.4-main.7ace549",
44
- "@dxos/random": "0.8.4-main.7ace549",
45
- "@dxos/react-ui": "0.8.4-main.7ace549",
46
- "@dxos/react-ui-theme": "0.8.4-main.7ace549",
47
- "@dxos/storybook-utils": "0.8.4-main.7ace549"
43
+ "@dxos/keys": "0.8.4-main.937b3ca",
44
+ "@dxos/echo-db": "0.8.4-main.937b3ca",
45
+ "@dxos/log": "0.8.4-main.937b3ca",
46
+ "@dxos/random": "0.8.4-main.937b3ca",
47
+ "@dxos/react-ui": "0.8.4-main.937b3ca",
48
+ "@dxos/storybook-utils": "0.8.4-main.937b3ca",
49
+ "@dxos/echo": "0.8.4-main.937b3ca",
50
+ "@dxos/ui-theme": "0.8.4-main.937b3ca"
48
51
  },
49
52
  "peerDependencies": {
50
- "react": "^19.0.0",
51
- "react-dom": "^19.0.0",
52
- "@dxos/react-ui": "0.8.4-main.7ace549",
53
- "@dxos/react-ui-theme": "0.8.4-main.7ace549"
53
+ "react": "~19.2.3",
54
+ "react-dom": "~19.2.3",
55
+ "@dxos/ui-theme": "0.8.4-main.937b3ca",
56
+ "@dxos/react-ui": "0.8.4-main.937b3ca"
54
57
  },
55
58
  "publishConfig": {
56
59
  "access": "public"
@@ -7,7 +7,7 @@ import React, { useState } from 'react';
7
7
 
8
8
  import { PublicKey } from '@dxos/keys';
9
9
  import { withTheme } from '@dxos/react-ui/testing';
10
- import { hoverableControls, hoverableFocusedWithinControls } from '@dxos/react-ui-theme';
10
+ import { hoverableControls, hoverableFocusedWithinControls } from '@dxos/ui-theme';
11
11
 
12
12
  import { type MessageEntity, MessageStoryText } from '../testing';
13
13
  import { Thread } from '../Thread';
@@ -5,10 +5,10 @@
5
5
  import { formatDistanceToNow } from 'date-fns/formatDistanceToNow';
6
6
  import React, { type ComponentPropsWithRef, type ComponentPropsWithoutRef, forwardRef } from 'react';
7
7
 
8
- // TODO(burdon): Remove dep.
9
8
  import { Avatar, type ThemedClassName, useTranslation } from '@dxos/react-ui';
10
- import { type UseTextEditorProps, keymap, listener, useTextEditor } from '@dxos/react-ui-editor';
11
- import { focusRing, mx } from '@dxos/react-ui-theme';
9
+ import { type UseTextEditorProps, useTextEditor } from '@dxos/react-ui-editor';
10
+ import { keymap, listener } from '@dxos/ui-editor';
11
+ import { focusRing, mx } from '@dxos/ui-theme';
12
12
  import { hexToEmoji, hexToHue, isTruthy } from '@dxos/util';
13
13
 
14
14
  import { translationKey } from '../translations';
@@ -5,27 +5,29 @@
5
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
  import React, { type FC, useEffect, useMemo, useRef, useState } from 'react';
7
7
 
8
- import { Expando } from '@dxos/echo/internal';
8
+ import { Obj } from '@dxos/echo';
9
+ import { TestSchema } from '@dxos/echo/testing';
9
10
  import { PublicKey } from '@dxos/keys';
10
11
  import { log } from '@dxos/log';
11
12
  import { faker } from '@dxos/random';
12
13
  import { Icon, IconButton, useThemeContext } from '@dxos/react-ui';
13
14
  import { withTheme } from '@dxos/react-ui/testing';
15
+ import { useTextEditor } from '@dxos/react-ui-editor';
14
16
  import {
15
17
  type Comment,
16
18
  type CommentsOptions,
19
+ type EditorView,
17
20
  type Range,
18
21
  comments,
19
22
  createBasicExtensions,
20
23
  createThemeExtensions,
24
+ documentId,
21
25
  listener,
22
26
  scrollThreadIntoView,
23
- useComments,
24
- useTextEditor,
25
- } from '@dxos/react-ui-editor';
26
- import { hoverableControls, hoverableFocusedWithinControls } from '@dxos/react-ui-theme';
27
+ setComments,
28
+ } from '@dxos/ui-editor';
29
+ import { hoverableControls, hoverableFocusedWithinControls } from '@dxos/ui-theme';
27
30
 
28
- import { Obj } from '../../../../core/echo/echo/src';
29
31
  import { MessageBody, MessageHeading, MessageRoot, MessageTextbox } from '../Message';
30
32
  import { type MessageEntity } from '../testing';
31
33
  import { translations } from '../translations';
@@ -36,13 +38,31 @@ faker.seed(101);
36
38
 
37
39
  const authorId = PublicKey.random().toHex();
38
40
 
41
+ /**
42
+ * @deprecated This hook will be removed in future versions. Use the new comment sync extension instead.
43
+ * Update comments state field.
44
+ */
45
+ const useComments = (view: EditorView | null | undefined, id: string, comments?: Comment[]) => {
46
+ useEffect(() => {
47
+ if (view) {
48
+ // Check same document.
49
+ // NOTE: Hook might be called before editor state is updated.
50
+ if (id === view.state.facet(documentId)) {
51
+ view.dispatch({
52
+ effects: setComments.of({ id, comments: comments ?? [] }),
53
+ });
54
+ }
55
+ }
56
+ });
57
+ };
58
+
39
59
  //
40
60
  // Editor
41
61
  //
42
62
 
43
63
  const Editor: FC<{
44
64
  id?: string;
45
- item: Expando;
65
+ initialValue: string;
46
66
  comments: Comment[];
47
67
  selected?: string;
48
68
  onCreateComment: CommentsOptions['onCreate'];
@@ -51,7 +71,7 @@ const Editor: FC<{
51
71
  onSelectComment: CommentsOptions['onSelect'];
52
72
  }> = ({
53
73
  id = 'test',
54
- item,
74
+ initialValue,
55
75
  selected: selectedValue,
56
76
  comments: commentRanges,
57
77
  onCreateComment,
@@ -65,7 +85,7 @@ const Editor: FC<{
65
85
  const { parentRef, view } = useTextEditor(
66
86
  () => ({
67
87
  id,
68
- initialValue: item.content,
88
+ initialValue: initialValue,
69
89
  extensions: [
70
90
  createBasicExtensions(),
71
91
  createThemeExtensions({ themeMode }),
@@ -78,7 +98,7 @@ const Editor: FC<{
78
98
  }),
79
99
  ],
80
100
  }),
81
- [id, item, themeMode],
101
+ [id, initialValue, themeMode],
82
102
  );
83
103
  useComments(view, id, commentRanges);
84
104
  useEffect(() => {
@@ -141,7 +161,7 @@ const StoryThread: FC<{
141
161
 
142
162
  const handleCreateMessage = () => {
143
163
  if (messageRef.current?.length) {
144
- const message = Obj.make(Expando, {
164
+ const message = Obj.make(TestSchema.Expando, {
145
165
  timestamp: new Date().toISOString(),
146
166
  sender: { identityKey: authorId },
147
167
  text: messageRef.current,
@@ -236,7 +256,7 @@ type StoryProps = {
236
256
  };
237
257
 
238
258
  const DefaultStory = ({ text, autoCreate }: StoryProps) => {
239
- const [item] = useState(() => Obj.make(Expando, { content: text ?? '' }));
259
+ const [item] = useState(() => Obj.make(TestSchema.Expando, { content: text ?? '' }));
240
260
  const [threads, setThreads] = useState<StoryCommentThread[]>([]);
241
261
  const [selected, setSelected] = useState<string>();
242
262
 
@@ -330,7 +350,7 @@ const DefaultStory = ({ text, autoCreate }: StoryProps) => {
330
350
  <main className='fixed inset-0 grid grid-cols-[1fr_24rem]'>
331
351
  <div role='none' className='max-bs-full overflow-y-auto p-4'>
332
352
  <Editor
333
- item={item}
353
+ initialValue={item.content}
334
354
  selected={selected}
335
355
  comments={comments}
336
356
  onCreateComment={handleCreateComment}
@@ -8,8 +8,8 @@ import React, { useMemo, useRef, useState } from 'react';
8
8
  import { PublicKey } from '@dxos/keys';
9
9
  import { faker } from '@dxos/random';
10
10
  import { withTheme } from '@dxos/react-ui/testing';
11
- import { createBasicExtensions, createThemeExtensions } from '@dxos/react-ui-editor';
12
- import { hoverableControls, hoverableFocusedWithinControls } from '@dxos/react-ui-theme';
11
+ import { createBasicExtensions, createThemeExtensions } from '@dxos/ui-editor';
12
+ import { hoverableControls, hoverableFocusedWithinControls } from '@dxos/ui-theme';
13
13
 
14
14
  import { MessageRoot, MessageTextbox } from '../Message';
15
15
  import { type MessageEntity, MessageStoryText } from '../testing';
@@ -5,7 +5,7 @@
5
5
  import React, { type ComponentPropsWithRef, forwardRef } from 'react';
6
6
 
7
7
  import { Icon, type ThemedClassName, useTranslation } from '@dxos/react-ui';
8
- import { hoverableControlItem, hoverableFocusedWithinControls, mx } from '@dxos/react-ui-theme';
8
+ import { hoverableControlItem, hoverableFocusedWithinControls, mx } from '@dxos/ui-theme';
9
9
 
10
10
  import { translationKey } from '../translations';
11
11
  import type { ThreadEntity } from '../types';
package/src/testing.tsx CHANGED
@@ -5,7 +5,7 @@
5
5
  import React from 'react';
6
6
 
7
7
  import { IconButton } from '@dxos/react-ui';
8
- import { hoverableControlItem, hoverableControls, hoverableFocusedWithinControls, mx } from '@dxos/react-ui-theme';
8
+ import { hoverableControlItem, hoverableControls, hoverableFocusedWithinControls, mx } from '@dxos/ui-theme';
9
9
 
10
10
  import { MessageBody, MessageHeading } from './Message';
11
11
  import { type MessageMetadata } from './types';
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { type Resource } from '@dxos/react-ui';
6
6
 
7
- export const translationKey = 'react-ui-thread';
7
+ export const translationKey = '@dxos/react-ui-thread';
8
8
 
9
9
  export const translations = [
10
10
  {