@dxos/react-ui-editor 0.4.8 → 0.4.9-main.1057b49
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 +33 -44
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +3 -0
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +3 -0
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/automerge.stories.d.ts +3 -0
- package/dist/types/src/extensions/automerge/automerge.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextEditor.stories.d.ts +3 -0
- package/dist/types/src/hooks/useTextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/package.json +23 -24
- package/src/components/Toolbar/Toolbar.stories.tsx +0 -1
- package/src/components/Toolbar/Toolbar.tsx +38 -32
- package/src/index.ts +0 -1
- package/src/translations.ts +3 -0
|
@@ -24,6 +24,8 @@ import {
|
|
|
24
24
|
TextHFive,
|
|
25
25
|
TextHSix,
|
|
26
26
|
TextItalic,
|
|
27
|
+
CaretDown,
|
|
28
|
+
Check,
|
|
27
29
|
} from '@phosphor-icons/react';
|
|
28
30
|
import { createContext } from '@radix-ui/react-context';
|
|
29
31
|
import React, { type PropsWithChildren, useEffect, useRef, useState } from 'react';
|
|
@@ -32,13 +34,14 @@ import { useDropzone } from 'react-dropzone';
|
|
|
32
34
|
import {
|
|
33
35
|
DensityProvider,
|
|
34
36
|
ElevationProvider,
|
|
35
|
-
Select,
|
|
36
37
|
Toolbar as NaturalToolbar,
|
|
37
38
|
Tooltip,
|
|
38
39
|
type ThemedClassName,
|
|
39
40
|
type ToolbarToggleGroupItemProps as NaturalToolbarToggleGroupItemProps,
|
|
40
41
|
type ToolbarButtonProps as NaturalToolbarButtonProps,
|
|
41
42
|
useTranslation,
|
|
43
|
+
DropdownMenu,
|
|
44
|
+
Button,
|
|
42
45
|
} from '@dxos/react-ui';
|
|
43
46
|
import { getSize } from '@dxos/react-ui-theme';
|
|
44
47
|
|
|
@@ -156,9 +159,9 @@ const MarkdownHeading = () => {
|
|
|
156
159
|
}
|
|
157
160
|
}}
|
|
158
161
|
>
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
+
{/* TODO(thure): `Select` encounters a ref error if used here (repro: select a heading, then select another
|
|
163
|
+
heading). Determine the root cause and fix or report to Radix. */}
|
|
164
|
+
<DropdownMenu.Root
|
|
162
165
|
open={selectOpen}
|
|
163
166
|
onOpenChange={(nextOpen: boolean) => {
|
|
164
167
|
if (!nextOpen) {
|
|
@@ -166,39 +169,42 @@ const MarkdownHeading = () => {
|
|
|
166
169
|
}
|
|
167
170
|
return setSelectOpen(nextOpen);
|
|
168
171
|
}}
|
|
169
|
-
onValueChange={(value) => onAction?.({ type: 'heading', data: parseInt(value) })}
|
|
170
172
|
>
|
|
171
173
|
<Tooltip.Trigger asChild>
|
|
172
174
|
<NaturalToolbar.Button asChild>
|
|
173
|
-
<
|
|
174
|
-
<
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
<DropdownMenu.Trigger asChild>
|
|
176
|
+
<Button variant='ghost' classNames={buttonStyles} disabled={value === null}>
|
|
177
|
+
<span className='sr-only'>{t('heading label')}</span>
|
|
178
|
+
<HeadingIcon className={iconStyles} />
|
|
179
|
+
<CaretDown />
|
|
180
|
+
</Button>
|
|
181
|
+
</DropdownMenu.Trigger>
|
|
177
182
|
</NaturalToolbar.Button>
|
|
178
183
|
</Tooltip.Trigger>
|
|
179
|
-
<
|
|
180
|
-
<
|
|
181
|
-
<
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
184
|
+
<DropdownMenu.Portal>
|
|
185
|
+
<DropdownMenu.Content classNames='is-min md:is-min' onCloseAutoFocus={(e) => e.preventDefault()}>
|
|
186
|
+
<DropdownMenu.Viewport>
|
|
187
|
+
{Object.keys(HeadingIcons).map((level) => {
|
|
188
|
+
const Icon = HeadingIcons[level];
|
|
189
|
+
return (
|
|
190
|
+
<DropdownMenu.CheckboxItem
|
|
191
|
+
key={level}
|
|
192
|
+
checked={value === level}
|
|
193
|
+
onClick={() => onAction?.({ type: 'heading', data: level })}
|
|
194
|
+
>
|
|
195
|
+
<span className='sr-only'>{t('heading level label', { count: parseInt(level) })}</span>
|
|
196
|
+
<Icon className={iconStyles} />
|
|
197
|
+
<DropdownMenu.ItemIndicator>
|
|
198
|
+
<Check />
|
|
199
|
+
</DropdownMenu.ItemIndicator>
|
|
200
|
+
</DropdownMenu.CheckboxItem>
|
|
201
|
+
);
|
|
202
|
+
})}
|
|
203
|
+
</DropdownMenu.Viewport>
|
|
204
|
+
<DropdownMenu.Arrow />
|
|
205
|
+
</DropdownMenu.Content>
|
|
206
|
+
</DropdownMenu.Portal>
|
|
207
|
+
</DropdownMenu.Root>
|
|
202
208
|
<Tooltip.Portal>
|
|
203
209
|
<Tooltip.Content {...tooltipProps}>
|
|
204
210
|
{t('heading label')}
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,6 @@ export { type EditorView, keymap } from '@codemirror/view';
|
|
|
9
9
|
export { tags } from '@lezer/highlight';
|
|
10
10
|
|
|
11
11
|
export { TextKind } from '@dxos/protocols/proto/dxos/echo/model/text';
|
|
12
|
-
export { Doc, YText, YXmlFragment } from '@dxos/text-model'; // TODO(burdon): Remove.
|
|
13
12
|
|
|
14
13
|
export * from './components';
|
|
15
14
|
export * from './extensions';
|
package/src/translations.ts
CHANGED
|
@@ -22,6 +22,9 @@ export default [
|
|
|
22
22
|
'image label': 'Insert image',
|
|
23
23
|
'heading label': 'Heading level',
|
|
24
24
|
'table label': 'Create table',
|
|
25
|
+
'heading level label_zero': 'Paragraph',
|
|
26
|
+
'heading level label_one': 'Heading level {{count}}',
|
|
27
|
+
'heading level label_other': 'Heading level {{count}}',
|
|
25
28
|
},
|
|
26
29
|
},
|
|
27
30
|
},
|