@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.
@@ -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 { editorInputMode, type EditorSelection, documentId, createEditorStateTransaction } from '../extensions';
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: ReturnType<typeof useFocusableGroup> & {
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
- * Hook for creating editor.
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 focusableGroup = useFocusableGroup({
158
+ const focusableGroupAttrs = useFocusableGroup({
159
159
  tabBehavior: 'limited',
160
- ignoreDefaultKeydown: { Escape: view?.state.facet(editorInputMode).noTabster },
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
- const focusAttributes = { tabIndex: 0 as const, ...focusableGroup, onKeyUp: handleKeyUp };
180
- return { parentRef, view, focusAttributes };
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 === 'article' ? 'min-bs-0' : '[&_.cm-scroller]:overflow-hidden [&_.cm-scroller]:min-bs-24',
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) =>
@@ -137,6 +137,7 @@ export const defaultTheme: ThemeStyles = {
137
137
  '.cm-link': {
138
138
  textDecorationLine: 'underline',
139
139
  textDecorationThickness: '1px',
140
+ textDecorationColor: 'var(--dx-separator)',
140
141
  textUnderlineOffset: '2px',
141
142
  borderRadius: '.125rem',
142
143
  },
package/src/util/debug.ts CHANGED
@@ -59,6 +59,6 @@ export const logChanges = (trs: readonly Transaction[]) => {
59
59
  .filter(Boolean);
60
60
 
61
61
  if (changes.length) {
62
- log.info('changes', { changes });
62
+ log('changes', { changes });
63
63
  }
64
64
  };