@dxos/react-ui-editor 0.6.11-staging.a542fc9 → 0.6.11

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 (33) hide show
  1. package/dist/lib/browser/index.mjs +126 -73
  2. package/dist/lib/browser/index.mjs.map +3 -3
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/types/src/InputMode.stories.d.ts.map +1 -1
  5. package/dist/types/src/TextEditor.stories.d.ts +10 -2
  6. package/dist/types/src/TextEditor.stories.d.ts.map +1 -1
  7. package/dist/types/src/defaults.d.ts.map +1 -1
  8. package/dist/types/src/extensions/automerge/automerge.stories.d.ts +0 -1
  9. package/dist/types/src/extensions/automerge/automerge.stories.d.ts.map +1 -1
  10. package/dist/types/src/extensions/factories.d.ts +5 -1
  11. package/dist/types/src/extensions/factories.d.ts.map +1 -1
  12. package/dist/types/src/extensions/folding.d.ts.map +1 -1
  13. package/dist/types/src/extensions/markdown/bundle.d.ts.map +1 -1
  14. package/dist/types/src/extensions/markdown/decorate.d.ts.map +1 -1
  15. package/dist/types/src/extensions/util/react.d.ts +4 -0
  16. package/dist/types/src/extensions/util/react.d.ts.map +1 -1
  17. package/dist/types/src/hooks/useTextEditor.d.ts +2 -2
  18. package/dist/types/src/hooks/useTextEditor.d.ts.map +1 -1
  19. package/dist/types/src/styles/markdown.d.ts.map +1 -1
  20. package/dist/types/src/styles/theme.d.ts.map +1 -1
  21. package/package.json +24 -24
  22. package/src/InputMode.stories.tsx +8 -10
  23. package/src/TextEditor.stories.tsx +58 -32
  24. package/src/defaults.ts +5 -3
  25. package/src/extensions/automerge/automerge.stories.tsx +5 -6
  26. package/src/extensions/factories.ts +15 -4
  27. package/src/extensions/folding.tsx +17 -4
  28. package/src/extensions/markdown/bundle.ts +1 -5
  29. package/src/extensions/markdown/decorate.ts +40 -23
  30. package/src/extensions/util/react.tsx +15 -0
  31. package/src/hooks/useTextEditor.ts +3 -5
  32. package/src/styles/markdown.ts +0 -2
  33. package/src/styles/theme.ts +12 -8
@@ -17,7 +17,7 @@ import {
17
17
  } from 'react';
18
18
 
19
19
  import { log } from '@dxos/log';
20
- import { isNotFalsy, type MaybeFunction } from '@dxos/util';
20
+ import { getProviderValue, isNotFalsy, type MaybeProvider } from '@dxos/util';
21
21
 
22
22
  import { createEditorStateTransaction, documentId, editorInputMode, type EditorSelection } from '../extensions';
23
23
  import { logChanges } from '../util';
@@ -57,13 +57,11 @@ let instanceCount = 0;
57
57
  * Hook for creating editor.
58
58
  */
59
59
  export const useTextEditor = (
60
- props: MaybeFunction<UseTextEditorProps> = {},
60
+ props: MaybeProvider<UseTextEditorProps> = {},
61
61
  deps: DependencyList = [],
62
62
  ): UseTextEditor => {
63
63
  const { id, initialValue, extensions, autoFocus, scrollTo, selection, moveToEndOfLine, debug } =
64
- useMemo<UseTextEditorProps>(() => {
65
- return typeof props === 'function' ? props() : props;
66
- }, deps ?? []);
64
+ useMemo<UseTextEditorProps>(() => getProviderValue(props), deps ?? []);
67
65
 
68
66
  // NOTE: Increments by 2 in strict mode.
69
67
  const [instanceId] = useState(() => `text-editor-${++instanceCount}`);
@@ -16,8 +16,6 @@ const headings: Record<HeadingLevel, string> = {
16
16
  6: 'text-md',
17
17
  };
18
18
 
19
- // TODO(burdon): Define theme as facet (used in multiple extensions).
20
- // TODO(burdon): Organize theme styles for widgets.
21
19
  export const theme = {
22
20
  mark: 'opacity-50',
23
21
  code: 'font-mono !no-underline text-neutral-700 dark:text-neutral-300',
@@ -73,16 +73,19 @@ export const defaultTheme: ThemeStyles = {
73
73
  * NOTE: Gutters should have the same top margin as the content.
74
74
  */
75
75
  '.cm-gutters': {
76
- background: 'unset',
76
+ background: 'var(--surface-bg)',
77
77
  },
78
78
  '.cm-gutter': {},
79
+ '.cm-gutter.cm-lineNumbers .cm-gutterElement': {
80
+ minWidth: '40px',
81
+ alignContent: 'center',
82
+ },
83
+ /**
84
+ * Height is set to match the corresponding line.
85
+ */
79
86
  '.cm-gutterElement': {
87
+ alignItems: 'center',
80
88
  fontSize: '16px',
81
- lineHeight: 1.5,
82
- },
83
-
84
- '.cm-lineNumbers': {
85
- minWidth: '36px',
86
89
  },
87
90
 
88
91
  /**
@@ -198,13 +201,14 @@ export const defaultTheme: ThemeStyles = {
198
201
  * </div>
199
202
  * </div
200
203
  */
201
- // TODO(burdon): Apply react-ui-theme or replace panel.
204
+ // TODO(burdon): Implement custom panel (with icon buttons).
202
205
  '.cm-panels': {},
203
206
  '.cm-panel': {
204
207
  fontFamily: fontBody,
205
- backgroundColor: 'var(--dx-base)',
208
+ backgroundColor: 'var(--surface-bg)',
206
209
  },
207
210
  '.cm-panel input, .cm-panel button, .cm-panel label': {
211
+ color: 'var(--dx-subdued)',
208
212
  fontFamily: fontBody,
209
213
  fontSize: '14px',
210
214
  all: 'unset',