@dxos/react-ui-editor 0.4.2-main.0e5b9e5 → 0.4.2-main.21916d1

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.
Files changed (35) hide show
  1. package/dist/lib/browser/index.mjs +203 -145
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts +20 -0
  5. package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts.map +1 -1
  6. package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +20 -0
  7. package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
  8. package/dist/types/src/components/TextEditor/automerge.stories.d.ts +20 -0
  9. package/dist/types/src/components/TextEditor/automerge.stories.d.ts.map +1 -1
  10. package/dist/types/src/components/TextEditor/hooks.stories.d.ts +20 -0
  11. package/dist/types/src/components/TextEditor/hooks.stories.d.ts.map +1 -1
  12. package/dist/types/src/components/Toolbar/Toolbar.d.ts +7 -10
  13. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
  14. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +23 -6
  15. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
  16. package/dist/types/src/index.d.ts +1 -1
  17. package/dist/types/src/index.d.ts.map +1 -1
  18. package/dist/types/src/styles/index.d.ts +1 -0
  19. package/dist/types/src/styles/index.d.ts.map +1 -1
  20. package/dist/types/src/styles/layout.d.ts +2 -0
  21. package/dist/types/src/styles/layout.d.ts.map +1 -0
  22. package/dist/types/src/translations.d.ts +20 -0
  23. package/dist/types/src/translations.d.ts.map +1 -0
  24. package/package.json +24 -24
  25. package/src/components/TextEditor/MarkdownEditor.stories.tsx +13 -16
  26. package/src/components/TextEditor/TextEditor.stories.tsx +11 -14
  27. package/src/components/TextEditor/TextEditor.tsx +3 -3
  28. package/src/components/TextEditor/automerge.stories.tsx +6 -8
  29. package/src/components/TextEditor/hooks.stories.tsx +15 -16
  30. package/src/components/Toolbar/Toolbar.stories.tsx +16 -12
  31. package/src/components/Toolbar/Toolbar.tsx +156 -129
  32. package/src/index.ts +1 -1
  33. package/src/styles/index.ts +1 -0
  34. package/src/styles/layout.ts +6 -0
  35. package/src/translations.ts +25 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-editor",
3
- "version": "0.4.2-main.0e5b9e5",
3
+ "version": "0.4.2-main.21916d1",
4
4
  "description": "Document editing experience within a DXOS shell.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -36,20 +36,20 @@
36
36
  "lodash.pick": "^4.4.0",
37
37
  "lodash.sortby": "^4.7.0",
38
38
  "style-mod": "^4.1.0",
39
- "@dxos/async": "0.4.2-main.0e5b9e5",
40
- "@dxos/automerge": "0.4.2-main.0e5b9e5",
41
- "@dxos/context": "0.4.2-main.0e5b9e5",
42
- "@dxos/debug": "0.4.2-main.0e5b9e5",
43
- "@dxos/display-name": "0.4.2-main.0e5b9e5",
44
- "@dxos/invariant": "0.4.2-main.0e5b9e5",
45
- "@dxos/echo-schema": "0.4.2-main.0e5b9e5",
46
- "@dxos/log": "0.4.2-main.0e5b9e5",
47
- "@dxos/react-async": "0.4.2-main.0e5b9e5",
48
- "@dxos/protocols": "0.4.2-main.0e5b9e5",
49
- "@dxos/react-ui-theme": "0.4.2-main.0e5b9e5",
50
- "@dxos/text-model": "0.4.2-main.0e5b9e5",
51
- "@dxos/react-ui": "0.4.2-main.0e5b9e5",
52
- "@dxos/util": "0.4.2-main.0e5b9e5"
39
+ "@dxos/async": "0.4.2-main.21916d1",
40
+ "@dxos/context": "0.4.2-main.21916d1",
41
+ "@dxos/debug": "0.4.2-main.21916d1",
42
+ "@dxos/display-name": "0.4.2-main.21916d1",
43
+ "@dxos/invariant": "0.4.2-main.21916d1",
44
+ "@dxos/echo-schema": "0.4.2-main.21916d1",
45
+ "@dxos/log": "0.4.2-main.21916d1",
46
+ "@dxos/protocols": "0.4.2-main.21916d1",
47
+ "@dxos/react-async": "0.4.2-main.21916d1",
48
+ "@dxos/react-ui": "0.4.2-main.21916d1",
49
+ "@dxos/react-ui-theme": "0.4.2-main.21916d1",
50
+ "@dxos/automerge": "0.4.2-main.21916d1",
51
+ "@dxos/text-model": "0.4.2-main.21916d1",
52
+ "@dxos/util": "0.4.2-main.21916d1"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@automerge/automerge-repo-network-broadcastchannel": "^1.1.0",
@@ -76,20 +76,20 @@
76
76
  "vite-plugin-top-level-await": "^1.4.1",
77
77
  "vite-plugin-wasm": "^3.3.0",
78
78
  "vitest": "^1.2.1",
79
- "@dxos/config": "0.4.2-main.0e5b9e5",
80
- "@dxos/echo-signals": "0.4.2-main.0e5b9e5",
81
- "@dxos/keyboard": "0.4.2-main.0e5b9e5",
82
- "@dxos/echo-typegen": "0.4.2-main.0e5b9e5",
83
- "@dxos/random": "0.4.2-main.0e5b9e5",
84
- "@dxos/react-client": "0.4.2-main.0e5b9e5",
85
- "@dxos/react-ui": "0.4.2-main.0e5b9e5",
86
- "@dxos/storybook-utils": "0.4.2-main.0e5b9e5"
79
+ "@dxos/config": "0.4.2-main.21916d1",
80
+ "@dxos/echo-signals": "0.4.2-main.21916d1",
81
+ "@dxos/echo-typegen": "0.4.2-main.21916d1",
82
+ "@dxos/random": "0.4.2-main.21916d1",
83
+ "@dxos/keyboard": "0.4.2-main.21916d1",
84
+ "@dxos/react-client": "0.4.2-main.21916d1",
85
+ "@dxos/storybook-utils": "0.4.2-main.21916d1",
86
+ "@dxos/react-ui": "0.4.2-main.21916d1"
87
87
  },
88
88
  "peerDependencies": {
89
89
  "@phosphor-icons/react": "^2.0.5",
90
90
  "react": "^18.2.0",
91
91
  "react-dom": "^18.2.0",
92
- "@dxos/react-client": "0.4.2-main.0e5b9e5"
92
+ "@dxos/react-client": "0.4.2-main.21916d1"
93
93
  },
94
94
  "publishConfig": {
95
95
  "access": "public"
@@ -14,7 +14,7 @@ import { TextObject } from '@dxos/echo-schema';
14
14
  import { keySymbols, parseShortcut } from '@dxos/keyboard';
15
15
  import { PublicKey } from '@dxos/keys';
16
16
  import { faker } from '@dxos/random';
17
- import { fixedInsetFlexLayout, getSize, groupSurface, mx } from '@dxos/react-ui-theme';
17
+ import { getSize, mx, textBlockWidth } from '@dxos/react-ui-theme';
18
18
  import { withTheme } from '@dxos/storybook-utils';
19
19
 
20
20
  import { MarkdownEditor, type TextEditorProps } from './TextEditor';
@@ -39,6 +39,7 @@ import {
39
39
  annotations,
40
40
  } from '../../extensions';
41
41
  import { type Comment, useTextModel } from '../../hooks';
42
+ import translations from '../../translations';
42
43
 
43
44
  faker.seed(101);
44
45
 
@@ -224,21 +225,16 @@ const Story = ({ text, comments, placeholder = 'New document.', ...props }: Stor
224
225
  }
225
226
 
226
227
  return (
227
- <div className={mx(fixedInsetFlexLayout, groupSurface)}>
228
- <div className='flex h-full justify-center'>
229
- <div className='flex flex-col h-full w-[800px] overflow-y-auto'>
230
- <MarkdownEditor
231
- ref={view}
232
- model={model}
233
- placeholder={placeholder}
234
- slots={{
235
- editor: { className: 'bs-full p-2 bg-white dark:bg-black' },
236
- }}
237
- {...props}
238
- />
239
- </div>
240
- </div>
241
- </div>
228
+ <MarkdownEditor
229
+ ref={view}
230
+ model={model}
231
+ placeholder={placeholder}
232
+ slots={{
233
+ root: { className: mx(textBlockWidth, 'min-bs-dvh') },
234
+ editor: { className: 'min-bs-dvh p-2 bg-white dark:bg-black' },
235
+ }}
236
+ {...props}
237
+ />
242
238
  );
243
239
  };
244
240
 
@@ -247,6 +243,7 @@ export default {
247
243
  component: MarkdownEditor,
248
244
  decorators: [withTheme],
249
245
  render: Story,
246
+ parameters: { translations, layout: 'fullscreen' },
250
247
  };
251
248
 
252
249
  const defaults = [
@@ -7,12 +7,13 @@ import '@dxosTheme';
7
7
  import React, { useState } from 'react';
8
8
 
9
9
  import { TextObject } from '@dxos/echo-schema';
10
- import { fixedInsetFlexLayout, groupSurface, mx } from '@dxos/react-ui-theme';
10
+ import { mx, textBlockWidth } from '@dxos/react-ui-theme';
11
11
  import { withTheme } from '@dxos/storybook-utils';
12
12
 
13
13
  import { TextEditor, type TextEditorProps } from './TextEditor';
14
14
  import { listener } from '../../extensions';
15
15
  import { useTextModel } from '../../hooks';
16
+ import translations from '../../translations';
16
17
 
17
18
  const initialText = [
18
19
  '# TextEditor',
@@ -36,19 +37,14 @@ const Story = ({
36
37
  }
37
38
 
38
39
  return (
39
- <div className={mx(fixedInsetFlexLayout, groupSurface)}>
40
- <div className='flex justify-center'>
41
- <div className='flex flex-col w-[800px] overflow-y-auto'>
42
- <TextEditor
43
- model={model}
44
- slots={{
45
- editor: { className: 'bs-full p-2 bg-white dark:bg-black' },
46
- }}
47
- {...props}
48
- />
49
- </div>
50
- </div>
51
- </div>
40
+ <TextEditor
41
+ model={model}
42
+ slots={{
43
+ root: { className: mx(textBlockWidth, 'min-bs-dvh') },
44
+ editor: { className: 'min-bs-dvh p-2 bg-white dark:bg-black' },
45
+ }}
46
+ {...props}
47
+ />
52
48
  );
53
49
  };
54
50
 
@@ -57,6 +53,7 @@ export default {
57
53
  component: TextEditor,
58
54
  decorators: [withTheme],
59
55
  render: Story,
56
+ parameters: { translations, layout: 'fullscreen' },
60
57
  };
61
58
 
62
59
  export const Default = {
@@ -20,7 +20,7 @@ import React, {
20
20
 
21
21
  import { log } from '@dxos/log';
22
22
  import { useThemeContext } from '@dxos/react-ui';
23
- import { focusRing, mx } from '@dxos/react-ui-theme';
23
+ import { focusRing } from '@dxos/react-ui-theme';
24
24
  import { isNotFalsy } from '@dxos/util';
25
25
 
26
26
  import { createBasicBundle, createMarkdownExtensions } from '../../extensions';
@@ -259,10 +259,10 @@ export const MarkdownEditor = forwardRef<EditorView, TextEditorProps>(
259
259
 
260
260
  export const defaultSlots: TextEditorSlots = {
261
261
  root: {
262
- className: mx('grow', focusRing),
262
+ className: focusRing,
263
263
  },
264
264
  editor: {
265
- className: 'bs-full',
265
+ className: 'min-bs-full',
266
266
  },
267
267
  };
268
268
 
@@ -23,6 +23,7 @@ import { MarkdownEditor } from './TextEditor';
23
23
  import { type IDocHandle, automerge, awareness, createBasicBundle } from '../../extensions';
24
24
  import { useTextEditor, useTextModel } from '../../hooks';
25
25
  import { defaultTheme } from '../../themes';
26
+ import translations from '../../translations';
26
27
 
27
28
  const initialContent = 'Hello world!';
28
29
 
@@ -83,9 +84,9 @@ const Story = () => {
83
84
  }
84
85
 
85
86
  return (
86
- <div className='grid grid-cols-2 gap-4'>
87
- <Editor handle={object1} />
88
- <Editor handle={object2} />
87
+ <div role='none' className='grid grid-cols-2 bs-full is-full gap-2'>
88
+ <Editor handle={object1} path={['text']} />
89
+ <Editor handle={object2} path={['text']} />
89
90
  </div>
90
91
  );
91
92
  };
@@ -94,6 +95,7 @@ export default {
94
95
  title: 'react-ui-editor/Automerge',
95
96
  component: Editor,
96
97
  render: () => <Story />,
98
+ parameters: { translations, layout: 'fullscreen' },
97
99
  };
98
100
 
99
101
  export const Default = {};
@@ -113,11 +115,7 @@ const EchoStory = ({ spaceKey }: { spaceKey: PublicKey }) => {
113
115
  return null;
114
116
  }
115
117
 
116
- return (
117
- <div className='flex flex-col w-full p-2'>
118
- <MarkdownEditor model={model} slots={{ editor: { className: 'bg-white p-2' } }} />
119
- </div>
120
- );
118
+ return <MarkdownEditor model={model} />;
121
119
  };
122
120
 
123
121
  export const WithEcho = {
@@ -7,7 +7,7 @@ import '@dxosTheme';
7
7
  import React from 'react';
8
8
 
9
9
  import { useThemeContext } from '@dxos/react-ui';
10
- import { fixedInsetFlexLayout, groupSurface, mx } from '@dxos/react-ui-theme';
10
+ import { mx, textBlockWidth } from '@dxos/react-ui-theme';
11
11
  import { withTheme } from '@dxos/storybook-utils';
12
12
 
13
13
  import { TextEditor } from './TextEditor';
@@ -24,7 +24,9 @@ import {
24
24
  useFormattingState,
25
25
  } from '../../extensions';
26
26
  import { createDataExtensions, createThemeExtensions, useActionHandler, useTextEditor } from '../../hooks';
27
+ import { editorWithToolbarLayout } from '../../styles/layout';
27
28
  import { markdownTheme } from '../../themes';
29
+ import translations from '../../translations';
28
30
  import { Toolbar } from '../Toolbar';
29
31
 
30
32
  // TODO(burdon): Demo toolbar with hooks.
@@ -53,11 +55,7 @@ const Story = ({ autoFocus, placeholder, doc, readonly }: StoryProps) => {
53
55
  themeMode,
54
56
  theme: markdownTheme,
55
57
  slots: {
56
- // TODO(burdon): Document classes re base theme.
57
- // Semantic tokens (e.g., replacement of input surface).
58
- editor: {
59
- className: 'h-full p-4 bg-white text-black dark:bg-black dark:text-white',
60
- },
58
+ editor: { className: 'min-bs-full' },
61
59
  },
62
60
  }),
63
61
  // TODO(burdon): Move lineWrapping.
@@ -80,16 +78,16 @@ const Story = ({ autoFocus, placeholder, doc, readonly }: StoryProps) => {
80
78
  // FIXME This doesn't update the state on view changes. Also not
81
79
  // sure if view is even guaranteed to exist at this point.
82
80
  return (
83
- <div className={mx(fixedInsetFlexLayout, groupSurface)}>
84
- <div className='flex h-full justify-center'>
85
- <div className='flex flex-col h-full w-[800px]'>
86
- <Toolbar.Root onAction={handleAction} state={formattingState}>
87
- <Toolbar.Markdown />
88
- </Toolbar.Root>
89
-
90
- {/* TODO(burdon): Handle scrolling in component wrapper (like this). */}
91
- <div role='none' className='h-full overflow-y-auto' ref={parentRef} />
92
- </div>
81
+ <div role='none' className={mx('fixed inset-0', editorWithToolbarLayout)}>
82
+ <Toolbar.Root onAction={handleAction} state={formattingState} classNames={textBlockWidth}>
83
+ <Toolbar.Markdown />
84
+ </Toolbar.Root>
85
+ <div role='none' className='overflow-y-auto'>
86
+ <div
87
+ role='textbox'
88
+ className={mx(textBlockWidth, 'min-bs-full p-4 surface-attention fg-base')}
89
+ ref={parentRef}
90
+ />
93
91
  </div>
94
92
  </div>
95
93
  );
@@ -100,6 +98,7 @@ export default {
100
98
  component: TextEditor,
101
99
  decorators: [withTheme],
102
100
  render: (args: StoryProps) => <Story {...args} />,
101
+ parameters: { translations, layout: 'fullscreen' },
103
102
  };
104
103
 
105
104
  export const Default = {
@@ -9,7 +9,7 @@ import React, { type FC, useMemo, useState } from 'react';
9
9
  import { TextObject } from '@dxos/echo-schema';
10
10
  import { PublicKey } from '@dxos/keys';
11
11
  import { faker } from '@dxos/random';
12
- import { fixedInsetFlexLayout, groupSurface, mx } from '@dxos/react-ui-theme';
12
+ import { mx, textBlockWidth } from '@dxos/react-ui-theme';
13
13
  import { withTheme } from '@dxos/storybook-utils';
14
14
 
15
15
  import { Toolbar } from './Toolbar';
@@ -25,6 +25,8 @@ import {
25
25
  useFormattingState,
26
26
  } from '../../extensions';
27
27
  import { type Comment, useActionHandler, useEditorView, useTextModel } from '../../hooks';
28
+ import { editorWithToolbarLayout } from '../../styles';
29
+ import translations from '../../translations';
28
30
  import { MarkdownEditor } from '../TextEditor';
29
31
 
30
32
  faker.seed(101);
@@ -63,17 +65,18 @@ const Story: FC<{ content: string }> = ({ content }) => {
63
65
  }
64
66
 
65
67
  return (
66
- <div className={mx(fixedInsetFlexLayout, groupSurface)}>
67
- <div className='flex h-full justify-center'>
68
- <div className='flex flex-col h-full w-[800px]'>
69
- <Toolbar.Root onAction={handleAction} state={formattingState}>
70
- <Toolbar.Markdown />
71
- <Toolbar.Separator />
72
- <Toolbar.Extended />
73
- </Toolbar.Root>
74
- <MarkdownEditor ref={editorRef} model={model} extensions={extensions} />
75
- </div>
76
- </div>
68
+ <div role='none' className={mx('fixed inset-0', editorWithToolbarLayout)}>
69
+ <Toolbar.Root onAction={handleAction} state={formattingState} classNames={textBlockWidth}>
70
+ <Toolbar.Markdown />
71
+ <Toolbar.Separator />
72
+ <Toolbar.Extended />
73
+ </Toolbar.Root>
74
+ <MarkdownEditor
75
+ ref={editorRef}
76
+ model={model}
77
+ extensions={extensions}
78
+ slots={{ root: { className: mx(textBlockWidth, 'pli-2') } }}
79
+ />
77
80
  </div>
78
81
  );
79
82
  };
@@ -83,6 +86,7 @@ export default {
83
86
  component: Toolbar,
84
87
  render: (args: any) => <Story {...args} />,
85
88
  decorators: [withTheme],
89
+ parameters: { translations, layout: 'fullscreen' },
86
90
  };
87
91
 
88
92
  const content = [