@dxos/react-ui-editor 0.8.1-main.ba2dec9 → 0.8.1-staging.5be625a
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 +10 -10
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +10 -10
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +10 -10
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/extensions/factories.d.ts +1 -0
- package/dist/types/src/extensions/factories.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextEditor.d.ts +3 -3
- package/dist/types/src/hooks/useTextEditor.d.ts.map +1 -1
- package/dist/types/src/styles/theme.d.ts.map +1 -1
- package/package.json +28 -28
- package/src/extensions/factories.ts +1 -0
- package/src/hooks/useTextEditor.ts +17 -8
- package/src/styles/stack-item-content-class-names.ts +1 -1
- package/src/styles/theme.ts +1 -0
- package/src/util/debug.ts +1 -1
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
import { EditorState, type EditorStateConfig } from '@codemirror/state';
|
6
6
|
import { EditorView } from '@codemirror/view';
|
7
|
-
import { useFocusableGroup } from '@fluentui/react-tabster';
|
7
|
+
import { useFocusableGroup, type TabsterTypes } from '@fluentui/react-tabster';
|
8
8
|
import {
|
9
9
|
type DependencyList,
|
10
10
|
type KeyboardEventHandler,
|
@@ -19,14 +19,14 @@ import {
|
|
19
19
|
import { log } from '@dxos/log';
|
20
20
|
import { getProviderValue, isNotFalsy, type MaybeProvider } from '@dxos/util';
|
21
21
|
|
22
|
-
import {
|
22
|
+
import { type EditorSelection, documentId, createEditorStateTransaction, editorInputMode } from '../extensions';
|
23
23
|
import { debugDispatcher } from '../util';
|
24
24
|
|
25
25
|
export type UseTextEditor = {
|
26
26
|
// TODO(burdon): Rename.
|
27
27
|
parentRef: RefObject<HTMLDivElement>;
|
28
28
|
view?: EditorView;
|
29
|
-
focusAttributes
|
29
|
+
focusAttributes?: TabsterTypes.TabsterDOMAttribute & {
|
30
30
|
tabIndex: 0;
|
31
31
|
onKeyUp: KeyboardEventHandler<HTMLDivElement>;
|
32
32
|
};
|
@@ -55,7 +55,7 @@ export type UseTextEditorProps = Pick<EditorStateConfig, 'extensions'> & {
|
|
55
55
|
let instanceCount = 0;
|
56
56
|
|
57
57
|
/**
|
58
|
-
*
|
58
|
+
* Creates codemirror text editor.
|
59
59
|
*/
|
60
60
|
export const useTextEditor = (
|
61
61
|
props: MaybeProvider<UseTextEditorProps> = {},
|
@@ -155,9 +155,11 @@ export const useTextEditor = (
|
|
155
155
|
}
|
156
156
|
}, [autoFocus, view]);
|
157
157
|
|
158
|
-
const
|
158
|
+
const focusableGroupAttrs = useFocusableGroup({
|
159
159
|
tabBehavior: 'limited',
|
160
|
-
ignoreDefaultKeydown: {
|
160
|
+
ignoreDefaultKeydown: {
|
161
|
+
Escape: view?.state.facet(editorInputMode).noTabster,
|
162
|
+
},
|
161
163
|
});
|
162
164
|
|
163
165
|
// Focus editor on Enter (e.g., when tabbing to this component).
|
@@ -176,6 +178,13 @@ export const useTextEditor = (
|
|
176
178
|
[view],
|
177
179
|
);
|
178
180
|
|
179
|
-
|
180
|
-
|
181
|
+
return {
|
182
|
+
parentRef,
|
183
|
+
view,
|
184
|
+
focusAttributes: {
|
185
|
+
tabIndex: 0 as const,
|
186
|
+
...focusableGroupAttrs,
|
187
|
+
onKeyUp: handleKeyUp,
|
188
|
+
},
|
189
|
+
};
|
181
190
|
};
|
@@ -7,7 +7,7 @@ import { mx } from '@dxos/react-ui-theme';
|
|
7
7
|
export const stackItemContentEditorClassNames = (role?: string) =>
|
8
8
|
mx(
|
9
9
|
'dx-focus-ring-inset data-[toolbar=disabled]:pbs-2 attention-surface',
|
10
|
-
role === '
|
10
|
+
role === 'section' ? '[&_.cm-scroller]:overflow-hidden [&_.cm-scroller]:min-bs-24' : 'min-bs-0',
|
11
11
|
);
|
12
12
|
|
13
13
|
export const stackItemContentToolbarClassNames = (role?: string) =>
|
package/src/styles/theme.ts
CHANGED