@dxos/react-ui-editor 0.8.4-main.b97322e → 0.8.4-main.f5c0578

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 (122) hide show
  1. package/dist/lib/browser/index.mjs +299 -249
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/browser/testing/index.mjs.map +2 -2
  5. package/dist/lib/node-esm/index.mjs +299 -249
  6. package/dist/lib/node-esm/index.mjs.map +4 -4
  7. package/dist/lib/node-esm/meta.json +1 -1
  8. package/dist/lib/node-esm/testing/index.mjs.map +2 -2
  9. package/dist/types/src/components/Editor/Editor.d.ts.map +1 -1
  10. package/dist/types/src/components/EditorToolbar/blocks.d.ts.map +1 -1
  11. package/dist/types/src/components/EditorToolbar/formatting.d.ts.map +1 -1
  12. package/dist/types/src/components/EditorToolbar/headings.d.ts.map +1 -1
  13. package/dist/types/src/components/EditorToolbar/lists.d.ts.map +1 -1
  14. package/dist/types/src/components/EditorToolbar/util.d.ts.map +1 -1
  15. package/dist/types/src/components/EditorToolbar/view-mode.d.ts +1 -1
  16. package/dist/types/src/components/EditorToolbar/view-mode.d.ts.map +1 -1
  17. package/dist/types/src/extensions/autocomplete.d.ts +1 -1
  18. package/dist/types/src/extensions/autocomplete.d.ts.map +1 -1
  19. package/dist/types/src/extensions/automerge/automerge.d.ts.map +1 -1
  20. package/dist/types/src/extensions/automerge/automerge.stories.d.ts.map +1 -1
  21. package/dist/types/src/extensions/automerge/defs.d.ts +1 -1
  22. package/dist/types/src/extensions/automerge/defs.d.ts.map +1 -1
  23. package/dist/types/src/extensions/automerge/sync.d.ts.map +1 -1
  24. package/dist/types/src/extensions/automerge/update-automerge.d.ts.map +1 -1
  25. package/dist/types/src/extensions/command/action.d.ts +1 -1
  26. package/dist/types/src/extensions/command/action.d.ts.map +1 -1
  27. package/dist/types/src/extensions/command/command-menu.d.ts +1 -1
  28. package/dist/types/src/extensions/command/command-menu.d.ts.map +1 -1
  29. package/dist/types/src/extensions/command/command.d.ts.map +1 -1
  30. package/dist/types/src/extensions/command/hint.d.ts.map +1 -1
  31. package/dist/types/src/extensions/command/state.d.ts +1 -1
  32. package/dist/types/src/extensions/command/state.d.ts.map +1 -1
  33. package/dist/types/src/extensions/command/typeahead.d.ts.map +1 -1
  34. package/dist/types/src/extensions/command/useCommandMenu.d.ts +1 -1
  35. package/dist/types/src/extensions/command/useCommandMenu.d.ts.map +1 -1
  36. package/dist/types/src/extensions/comments.d.ts +1 -1
  37. package/dist/types/src/extensions/comments.d.ts.map +1 -1
  38. package/dist/types/src/extensions/dnd.d.ts.map +1 -1
  39. package/dist/types/src/extensions/factories.d.ts.map +1 -1
  40. package/dist/types/src/extensions/markdown/action.d.ts.map +1 -1
  41. package/dist/types/src/extensions/markdown/changes.d.ts.map +1 -1
  42. package/dist/types/src/extensions/markdown/decorate.d.ts.map +1 -1
  43. package/dist/types/src/extensions/markdown/formatting.d.ts +1 -1
  44. package/dist/types/src/extensions/markdown/formatting.d.ts.map +1 -1
  45. package/dist/types/src/extensions/markdown/formatting.test.d.ts.map +1 -1
  46. package/dist/types/src/extensions/markdown/highlight.d.ts.map +1 -1
  47. package/dist/types/src/extensions/outliner/outliner.d.ts.map +1 -1
  48. package/dist/types/src/extensions/outliner/selection.d.ts.map +1 -1
  49. package/dist/types/src/extensions/outliner/tree.d.ts +1 -1
  50. package/dist/types/src/extensions/outliner/tree.d.ts.map +1 -1
  51. package/dist/types/src/hooks/useTextEditor.d.ts.map +1 -1
  52. package/dist/types/src/stories/Command.stories.d.ts.map +1 -1
  53. package/dist/types/src/stories/CommandMenu.stories.d.ts.map +1 -1
  54. package/dist/types/src/stories/Comments.stories.d.ts.map +1 -1
  55. package/dist/types/src/stories/EditorToolbar.stories.d.ts.map +1 -1
  56. package/dist/types/src/stories/Experimental.stories.d.ts.map +1 -1
  57. package/dist/types/src/stories/Markdown.stories.d.ts.map +1 -1
  58. package/dist/types/src/stories/Outliner.stories.d.ts.map +1 -1
  59. package/dist/types/src/stories/Preview.stories.d.ts.map +1 -1
  60. package/dist/types/src/stories/TextEditor.stories.d.ts.map +1 -1
  61. package/dist/types/src/stories/components/EditorStory.d.ts.map +1 -1
  62. package/dist/types/src/styles/theme.d.ts.map +1 -1
  63. package/dist/types/src/testing/util.d.ts +1 -0
  64. package/dist/types/src/testing/util.d.ts.map +1 -1
  65. package/dist/types/src/util/cursor.d.ts.map +1 -1
  66. package/dist/types/tsconfig.tsbuildinfo +1 -1
  67. package/package.json +40 -37
  68. package/src/components/Editor/Editor.tsx +1 -1
  69. package/src/components/EditorToolbar/EditorToolbar.tsx +1 -1
  70. package/src/components/EditorToolbar/blocks.ts +3 -2
  71. package/src/components/EditorToolbar/formatting.ts +3 -2
  72. package/src/components/EditorToolbar/headings.ts +2 -1
  73. package/src/components/EditorToolbar/lists.ts +3 -2
  74. package/src/components/EditorToolbar/util.ts +1 -1
  75. package/src/components/EditorToolbar/view-mode.ts +2 -1
  76. package/src/components/Popover/RefDropdownMenu.tsx +1 -1
  77. package/src/components/Popover/RefPopover.tsx +4 -4
  78. package/src/extensions/autocomplete.ts +3 -3
  79. package/src/extensions/automerge/automerge.stories.tsx +4 -4
  80. package/src/extensions/automerge/automerge.ts +4 -3
  81. package/src/extensions/automerge/defs.ts +1 -1
  82. package/src/extensions/automerge/sync.ts +1 -1
  83. package/src/extensions/automerge/update-automerge.ts +1 -1
  84. package/src/extensions/awareness/awareness.ts +2 -2
  85. package/src/extensions/command/action.ts +1 -1
  86. package/src/extensions/command/command-menu.ts +4 -3
  87. package/src/extensions/command/command.ts +3 -3
  88. package/src/extensions/command/hint.ts +2 -1
  89. package/src/extensions/command/placeholder.ts +1 -1
  90. package/src/extensions/command/state.ts +4 -3
  91. package/src/extensions/command/typeahead.ts +2 -2
  92. package/src/extensions/command/useCommandMenu.ts +2 -1
  93. package/src/extensions/comments.ts +7 -6
  94. package/src/extensions/dnd.ts +1 -1
  95. package/src/extensions/factories.ts +4 -3
  96. package/src/extensions/markdown/action.ts +2 -1
  97. package/src/extensions/markdown/bundle.ts +1 -1
  98. package/src/extensions/markdown/changes.ts +1 -1
  99. package/src/extensions/markdown/decorate.ts +7 -6
  100. package/src/extensions/markdown/formatting.test.ts +6 -6
  101. package/src/extensions/markdown/formatting.ts +3 -3
  102. package/src/extensions/markdown/highlight.ts +1 -1
  103. package/src/extensions/mention.ts +1 -1
  104. package/src/extensions/outliner/outliner.test.ts +3 -2
  105. package/src/extensions/outliner/outliner.ts +4 -3
  106. package/src/extensions/outliner/selection.ts +1 -1
  107. package/src/extensions/outliner/tree.test.ts +2 -1
  108. package/src/extensions/outliner/tree.ts +1 -1
  109. package/src/hooks/useTextEditor.ts +3 -3
  110. package/src/stories/Command.stories.tsx +6 -5
  111. package/src/stories/CommandMenu.stories.tsx +5 -4
  112. package/src/stories/Comments.stories.tsx +3 -2
  113. package/src/stories/EditorToolbar.stories.tsx +3 -3
  114. package/src/stories/Experimental.stories.tsx +4 -3
  115. package/src/stories/Markdown.stories.tsx +3 -2
  116. package/src/stories/Outliner.stories.tsx +4 -3
  117. package/src/stories/Preview.stories.tsx +21 -22
  118. package/src/stories/TextEditor.stories.tsx +15 -14
  119. package/src/stories/components/EditorStory.tsx +5 -5
  120. package/src/styles/theme.ts +4 -3
  121. package/src/testing/util.ts +2 -0
  122. package/src/util/cursor.ts +2 -1
@@ -7,21 +7,21 @@ import { EditorState, type StateCommand } from '@codemirror/state';
7
7
  import { describe, expect, test } from 'vitest';
8
8
 
9
9
  import {
10
+ type Formatting,
11
+ Inline,
12
+ List,
10
13
  addBlockquote,
11
14
  addCodeblock,
12
15
  addLink,
13
16
  addList,
14
17
  addStyle,
15
18
  getFormatting,
16
- removeStyle,
17
- removeLink,
18
- removeList,
19
19
  removeBlockquote,
20
20
  removeCodeblock,
21
+ removeLink,
22
+ removeList,
23
+ removeStyle,
21
24
  setHeading,
22
- Inline,
23
- List,
24
- type Formatting,
25
25
  } from './formatting';
26
26
 
27
27
  export const emptyFormatting: Formatting = {
@@ -7,14 +7,14 @@ import { syntaxTree } from '@codemirror/language';
7
7
  import {
8
8
  type ChangeSpec,
9
9
  EditorSelection,
10
- type Extension,
11
10
  type EditorState,
11
+ type Extension,
12
12
  type Line,
13
13
  type StateCommand,
14
14
  type Text,
15
15
  } from '@codemirror/state';
16
- import { EditorView, keymap, type ViewUpdate } from '@codemirror/view';
17
- import { type SyntaxNodeRef, type SyntaxNode } from '@lezer/common';
16
+ import { EditorView, type ViewUpdate, keymap } from '@codemirror/view';
17
+ import { type SyntaxNode, type SyntaxNodeRef } from '@lezer/common';
18
18
  import { useCallback, useMemo } from 'react';
19
19
 
20
20
  import { debounceAndThrottle } from '@dxos/async';
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { markdownLanguage } from '@codemirror/lang-markdown';
6
6
  import { HighlightStyle } from '@codemirror/language';
7
- import { tags, styleTags, Tag } from '@lezer/highlight';
7
+ import { Tag, styleTags, tags } from '@lezer/highlight';
8
8
  import { type MarkdownConfig, Table } from '@lezer/markdown';
9
9
 
10
10
  import { fontBody, theme } from '../../styles';
@@ -2,7 +2,7 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { autocompletion, type CompletionContext, type CompletionResult } from '@codemirror/autocomplete';
5
+ import { type CompletionContext, type CompletionResult, autocompletion } from '@codemirror/autocomplete';
6
6
  import type { Extension } from '@codemirror/state';
7
7
 
8
8
  import { log } from '@dxos/log';
@@ -6,11 +6,12 @@ import { EditorSelection, EditorState } from '@codemirror/state';
6
6
  import { EditorView } from '@codemirror/view';
7
7
  import { describe, test } from 'vitest';
8
8
 
9
- import { indentItemLess, indentItemMore, moveItemDown, moveItemUp } from './commands';
10
- import { listItemToString, outlinerTree, treeFacet } from './tree';
11
9
  import { str } from '../../testing';
12
10
  import { createMarkdownExtensions } from '../markdown';
13
11
 
12
+ import { indentItemLess, indentItemMore, moveItemDown, moveItemUp } from './commands';
13
+ import { listItemToString, outlinerTree, treeFacet } from './tree';
14
+
14
15
  const lines = [
15
16
  '- [ ] 1',
16
17
  '- [ ] 2',
@@ -7,12 +7,13 @@ import { Decoration, type DecorationSet, EditorView, ViewPlugin, type ViewUpdate
7
7
 
8
8
  import { mx } from '@dxos/react-ui-theme';
9
9
 
10
+ import { floatingMenu } from '../command';
11
+ import { decorateMarkdown } from '../markdown';
12
+
10
13
  import { commands } from './commands';
11
14
  import { editor } from './editor';
12
- import { selectionCompartment, selectionFacet, selectionEquals } from './selection';
15
+ import { selectionCompartment, selectionEquals, selectionFacet } from './selection';
13
16
  import { outlinerTree, treeFacet } from './tree';
14
- import { floatingMenu } from '../command';
15
- import { decorateMarkdown } from '../markdown';
16
17
 
17
18
  // ISSUES:
18
19
  // TODO(burdon): Remove requirement for continuous lines to be indented (so that user's can't accidentally delete them and break the layout).
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  import { Compartment, type EditorState, Facet, type SelectionRange } from '@codemirror/state';
6
- import { type EditorView, type Command } from '@codemirror/view';
6
+ import { type Command, type EditorView } from '@codemirror/view';
7
7
 
8
8
  import { treeFacet } from './tree';
9
9
 
@@ -6,10 +6,11 @@ import { markdown, markdownLanguage } from '@codemirror/lang-markdown';
6
6
  import { EditorState } from '@codemirror/state';
7
7
  import { beforeEach, describe, test } from 'vitest';
8
8
 
9
- import { outlinerTree, treeFacet, listItemToString, type Item } from './tree';
10
9
  import { str } from '../../testing';
11
10
  import { type Range } from '../../types';
12
11
 
12
+ import { type Item, listItemToString, outlinerTree, treeFacet } from './tree';
13
+
13
14
  const lines = [
14
15
  '- [ ] 1',
15
16
  '- [ ] 2',
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  import { syntaxTree } from '@codemirror/language';
6
- import { StateField, type Transaction, type Extension, type EditorState } from '@codemirror/state';
6
+ import { type EditorState, type Extension, StateField, type Transaction } from '@codemirror/state';
7
7
  import { Facet } from '@codemirror/state';
8
8
  import { type SyntaxNode } from '@lezer/common';
9
9
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { EditorState, type EditorStateConfig, type Text } from '@codemirror/state';
6
6
  import { EditorView } from '@codemirror/view';
7
- import { useFocusableGroup, type TabsterTypes } from '@fluentui/react-tabster';
7
+ import { type TabsterTypes, useFocusableGroup } from '@fluentui/react-tabster';
8
8
  import {
9
9
  type DependencyList,
10
10
  type KeyboardEventHandler,
@@ -17,9 +17,9 @@ import {
17
17
  } from 'react';
18
18
 
19
19
  import { log } from '@dxos/log';
20
- import { getProviderValue, isNotFalsy, type MaybeProvider } from '@dxos/util';
20
+ import { type MaybeProvider, getProviderValue, isNotFalsy } from '@dxos/util';
21
21
 
22
- import { type EditorSelection, documentId, createEditorStateTransaction, editorInputMode } from '../extensions';
22
+ import { type EditorSelection, createEditorStateTransaction, documentId, editorInputMode } from '../extensions';
23
23
  import { debugDispatcher } from '../util';
24
24
 
25
25
  let instanceCount = 0;
@@ -4,19 +4,20 @@
4
4
 
5
5
  import '@dxos-theme';
6
6
 
7
- import React, { useState, type KeyboardEvent } from 'react';
7
+ import React, { type KeyboardEvent, useState } from 'react';
8
8
 
9
- import { Button, Icon, Input, DropdownMenu } from '@dxos/react-ui';
9
+ import { Button, DropdownMenu, Icon, Input } from '@dxos/react-ui';
10
10
  import { mx } from '@dxos/react-ui-theme';
11
- import { withLayout, withTheme, type Meta } from '@dxos/storybook-utils';
11
+ import { type Meta, withLayout, withTheme } from '@dxos/storybook-utils';
12
12
 
13
- import { EditorStory } from './components';
14
13
  import { RefDropdownMenu } from '../components';
15
14
  import { editorWidth } from '../defaults';
16
- import { command, type Action, floatingMenu } from '../extensions';
15
+ import { type Action, command, floatingMenu } from '../extensions';
17
16
  import { str } from '../testing';
18
17
  import { createRenderer } from '../util';
19
18
 
19
+ import { EditorStory } from './components';
20
+
20
21
  const CommandDialog = ({ onAction }: { onAction: (action?: Action) => void }) => {
21
22
  const [text, setText] = useState('');
22
23
 
@@ -11,10 +11,9 @@ import React, { useCallback, useRef } from 'react';
11
11
  import { Obj, Query } from '@dxos/echo';
12
12
  import { faker } from '@dxos/random';
13
13
  import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
14
- import { createObjectFactory, Testing, type ValueGenerator } from '@dxos/schema/testing';
15
- import { withLayout, withTheme, type Meta } from '@dxos/storybook-utils';
14
+ import { Testing, type ValueGenerator, createObjectFactory } from '@dxos/schema/testing';
15
+ import { type Meta, withLayout, withTheme } from '@dxos/storybook-utils';
16
16
 
17
- import { EditorStory, names } from './components';
18
17
  import {
19
18
  CommandMenu,
20
19
  type CommandMenuGroup,
@@ -26,10 +25,12 @@ import {
26
25
  insertAtLineStart,
27
26
  linkSlashCommands,
28
27
  } from '../components';
29
- import { useCommandMenu, type UseCommandMenuOptions } from '../extensions';
28
+ import { type UseCommandMenuOptions, useCommandMenu } from '../extensions';
30
29
  import { str } from '../testing';
31
30
  import { createElement } from '../util';
32
31
 
32
+ import { EditorStory, names } from './components';
33
+
33
34
  const generator: ValueGenerator = faker as any;
34
35
 
35
36
  type StoryProps = Omit<UseCommandMenuOptions, 'viewRef'> & { text: string };
@@ -10,14 +10,15 @@ import React, { type FC } from 'react';
10
10
  import { keySymbols, parseShortcut } from '@dxos/keyboard';
11
11
  import { PublicKey } from '@dxos/keys';
12
12
  import { log } from '@dxos/log';
13
- import { withLayout, withTheme, type Meta } from '@dxos/storybook-utils';
13
+ import { type Meta, withLayout, withTheme } from '@dxos/storybook-utils';
14
14
 
15
- import { EditorStory, content, longText } from './components';
16
15
  import { annotations, comments, createExternalCommentSync } from '../extensions';
17
16
  import { str } from '../testing';
18
17
  import { type Comment } from '../types';
19
18
  import { createRenderer } from '../util';
20
19
 
20
+ import { EditorStory, content, longText } from './components';
21
+
21
22
  const meta: Meta<typeof EditorStory> = {
22
23
  title: 'ui/react-ui-editor/Comments',
23
24
  component: EditorStory,
@@ -16,14 +16,14 @@ import { EditorToolbar, useEditorToolbarState } from '../components';
16
16
  import { editorWidth } from '../defaults';
17
17
  import {
18
18
  InputModeExtensions,
19
- createMarkdownExtensions,
20
19
  createBasicExtensions,
20
+ createMarkdownExtensions,
21
21
  createThemeExtensions,
22
22
  decorateMarkdown,
23
23
  formattingKeymap,
24
24
  useFormattingState,
25
25
  } from '../extensions';
26
- import { useTextEditor, type UseTextEditorProps } from '../hooks';
26
+ import { type UseTextEditorProps, useTextEditor } from '../hooks';
27
27
  import { translations } from '../translations';
28
28
  import { type EditorInputMode, type EditorViewMode } from '../types';
29
29
 
@@ -43,7 +43,7 @@ const DefaultStory = ({ autoFocus, initialValue, placeholder }: StoryProps) => {
43
43
  moveToEndOfLine: true,
44
44
  extensions: [
45
45
  editorInputMode ? InputModeExtensions[editorInputMode] : [],
46
- createBasicExtensions({ placeholder, lineWrapping: true, readOnly: viewMode === 'readonly' }),
46
+ createBasicExtensions({ placeholder, lineWrapping: true, readOnly: viewMode === 'readonly', search: true }),
47
47
  createMarkdownExtensions({ themeMode }),
48
48
  createThemeExtensions({ themeMode, syntaxHighlighting: true }),
49
49
  viewMode === 'source' ? [] : decorateMarkdown(),
@@ -9,12 +9,13 @@ import React from 'react';
9
9
 
10
10
  import { log } from '@dxos/log';
11
11
  import { faker } from '@dxos/random';
12
- import { withLayout, withTheme, type Meta } from '@dxos/storybook-utils';
12
+ import { type Meta, withLayout, withTheme } from '@dxos/storybook-utils';
13
13
 
14
- import { EditorStory, content } from './components';
15
- import { typewriter, blast, defaultOptions, dropFile } from '../extensions';
14
+ import { blast, defaultOptions, dropFile, typewriter } from '../extensions';
16
15
  import { str } from '../testing';
17
16
 
17
+ import { EditorStory, content } from './components';
18
+
18
19
  const meta: Meta<typeof EditorStory> = {
19
20
  title: 'ui/react-ui-editor/Experimental',
20
21
  component: EditorStory,
@@ -7,12 +7,13 @@ import '@dxos-theme';
7
7
  import { markdown } from '@codemirror/lang-markdown';
8
8
  import React from 'react';
9
9
 
10
- import { withLayout, withTheme, type Meta } from '@dxos/storybook-utils';
10
+ import { type Meta, withLayout, withTheme } from '@dxos/storybook-utils';
11
11
 
12
- import { EditorStory, content, defaultExtensions, headings, renderLinkTooltip, text } from './components';
13
12
  import { decorateMarkdown, image, linkTooltip, table } from '../extensions';
14
13
  import { str } from '../testing';
15
14
 
15
+ import { EditorStory, content, defaultExtensions, headings, renderLinkTooltip, text } from './components';
16
+
16
17
  const meta: Meta<typeof EditorStory> = {
17
18
  title: 'ui/react-ui-editor/Markdown',
18
19
  component: EditorStory,
@@ -9,13 +9,14 @@ import React, { useRef } from 'react';
9
9
 
10
10
  import { DropdownMenu } from '@dxos/react-ui';
11
11
  import { withAttention } from '@dxos/react-ui-attention/testing';
12
- import { withLayout, withTheme, type Meta } from '@dxos/storybook-utils';
12
+ import { type Meta, withLayout, withTheme } from '@dxos/storybook-utils';
13
13
 
14
- import { EditorStory } from './components';
15
14
  import { RefDropdownMenu } from '../components';
16
- import { outliner, listItemToString, treeFacet, deleteItem, hashtag } from '../extensions';
15
+ import { deleteItem, hashtag, listItemToString, outliner, treeFacet } from '../extensions';
17
16
  import { str } from '../testing';
18
17
 
18
+ import { EditorStory } from './components';
19
+
19
20
  type StoryProps = {
20
21
  text: string;
21
22
  };
@@ -6,7 +6,7 @@ import '@dxos-theme';
6
6
 
7
7
  import { syntaxTree } from '@codemirror/language';
8
8
  import { type EditorView } from '@codemirror/view';
9
- import React, { useState, useEffect, useMemo, useCallback } from 'react';
9
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
10
10
  import { createPortal } from 'react-dom';
11
11
 
12
12
  import { invariant } from '@dxos/invariant';
@@ -14,12 +14,13 @@ import { faker } from '@dxos/random';
14
14
  import { Popover } from '@dxos/react-ui';
15
15
  import { Card } from '@dxos/react-ui-stack';
16
16
  import { hoverableControlItem, hoverableControlItemTransition, hoverableControls } from '@dxos/react-ui-theme';
17
- import { withLayout, withTheme, type Meta } from '@dxos/storybook-utils';
17
+ import { type Meta, withLayout, withTheme } from '@dxos/storybook-utils';
18
+ import { trim } from '@dxos/util';
18
19
 
19
- import { EditorStory } from './components';
20
20
  import { PreviewProvider, useRefPopover } from '../components';
21
- import { preview, image, type PreviewLinkRef, type PreviewLinkTarget, getLinkRef } from '../extensions';
22
- import { str } from '../testing';
21
+ import { type PreviewLinkRef, type PreviewLinkTarget, getLinkRef, image, preview } from '../extensions';
22
+
23
+ import { EditorStory } from './components';
23
24
 
24
25
  const handlePreviewLookup = async ({ label, ref }: PreviewLinkRef): Promise<PreviewLinkTarget> => {
25
26
  // Random text.
@@ -132,7 +133,7 @@ const PreviewBlock = ({ link, el, view }: { link: PreviewLinkRef; el: HTMLElemen
132
133
  <Card.Toolbar classNames='is-min p-[--dx-cardSpacingInline]'>
133
134
  {(link.suggest && (
134
135
  <>
135
- <Card.ToolbarIconButton label='Discard' icon={'ph--x--regular'} onClick={handleDelete} />
136
+ <Card.ToolbarIconButton label='Discard' icon='ph--x--regular' onClick={handleDelete} />
136
137
  {target && (
137
138
  <Card.ToolbarIconButton
138
139
  classNames='bg-successSurface text-successSurfaceText'
@@ -200,22 +201,20 @@ export const Default = {
200
201
  <PreviewProvider onLookup={handlePreviewLookup}>
201
202
  <EditorStory
202
203
  ref={handleViewRef}
203
- text={str(
204
- '# Preview',
205
- '',
206
- 'This project is part of the [DXOS][dxn:queue:data:123] SDK.',
207
- '',
208
- '![DXOS][?dxn:queue:data:123]',
209
- '',
210
- 'It consists of [ECHO][dxn:queue:data:echo], [HALO][dxn:queue:data:halo], and [MESH][dxn:queue:data:mesh].',
211
- '',
212
- '## Deep dive',
213
- '',
214
- '![ECHO][dxn:queue:data:echo]',
215
- '',
216
- '',
217
- '',
218
- )}
204
+ text={trim`
205
+ # Preview
206
+
207
+ This project is part of the [DXOS][dxn:queue:data:123] SDK.
208
+
209
+ ![DXOS][?dxn:queue:data:123]
210
+
211
+ It consists of [ECHO][dxn:queue:data:echo], [HALO][dxn:queue:data:halo], and [MESH][dxn:queue:data:mesh].
212
+
213
+ ## Deep dive
214
+
215
+ ![ECHO][dxn:queue:data:echo]
216
+
217
+ `}
219
218
  extensions={extensions}
220
219
  />
221
220
  <PreviewCard />
@@ -9,21 +9,8 @@ import { openSearchPanel } from '@codemirror/search';
9
9
  import React from 'react';
10
10
 
11
11
  import { log } from '@dxos/log';
12
- import { withLayout, withTheme, type Meta } from '@dxos/storybook-utils';
12
+ import { type Meta, withLayout, withTheme } from '@dxos/storybook-utils';
13
13
 
14
- import {
15
- EditorStory,
16
- allExtensions,
17
- content,
18
- defaultExtensions,
19
- global,
20
- largeWithImages,
21
- links,
22
- longText,
23
- names,
24
- renderLinkButton,
25
- text,
26
- } from './components';
27
14
  import { editorMonospace } from '../defaults';
28
15
  import {
29
16
  InputModeExtensions,
@@ -39,6 +26,20 @@ import {
39
26
  } from '../extensions';
40
27
  import { str } from '../testing';
41
28
 
29
+ import {
30
+ EditorStory,
31
+ allExtensions,
32
+ content,
33
+ defaultExtensions,
34
+ global,
35
+ largeWithImages,
36
+ links,
37
+ longText,
38
+ names,
39
+ renderLinkButton,
40
+ text,
41
+ } from './components';
42
+
42
43
  const meta: Meta<typeof EditorStory> = {
43
44
  title: 'ui/react-ui-editor/TextEditor',
44
45
  component: EditorStory,
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  import { type EditorView } from '@codemirror/view';
6
- import React, { type ReactNode, forwardRef, useEffect, useState, useImperativeHandle, useMemo } from 'react';
6
+ import React, { type ReactNode, forwardRef, useEffect, useImperativeHandle, useMemo, useState } from 'react';
7
7
 
8
8
  import { Expando } from '@dxos/echo-schema';
9
9
  import { invariant } from '@dxos/invariant';
@@ -16,17 +16,17 @@ import { JsonFilter } from '@dxos/react-ui-syntax-highlighter';
16
16
  import { mx } from '@dxos/react-ui-theme';
17
17
  import { isNonNullable } from '@dxos/util';
18
18
 
19
- import { editorSlots, editorGutter } from '../../defaults';
19
+ import { editorGutter, editorSlots } from '../../defaults';
20
20
  import {
21
21
  type DebugNode,
22
22
  type ThemeExtensionsOptions,
23
- createDataExtensions,
24
23
  createBasicExtensions,
24
+ createDataExtensions,
25
25
  createMarkdownExtensions,
26
26
  createThemeExtensions,
27
27
  debugTree,
28
28
  } from '../../extensions';
29
- import { useTextEditor, type UseTextEditorProps } from '../../hooks';
29
+ import { type UseTextEditorProps, useTextEditor } from '../../hooks';
30
30
 
31
31
  // Type definitions.
32
32
  export type DebugMode = 'raw' | 'tree' | 'raw+tree';
@@ -112,7 +112,7 @@ export const EditorComponent = forwardRef<EditorView | undefined, StoryProps>(
112
112
  initialValue: text,
113
113
  extensions: [
114
114
  createDataExtensions({ id, text: createDocAccessor(object, ['content']) }),
115
- createBasicExtensions({ readOnly, placeholder, lineNumbers, scrollPastEnd: true }),
115
+ createBasicExtensions({ readOnly, placeholder, lineNumbers, scrollPastEnd: true, search: true }),
116
116
  createMarkdownExtensions({ themeMode }),
117
117
  createThemeExtensions({ themeMode, syntaxHighlighting: true, slots }),
118
118
  editorGutter,
@@ -155,7 +155,7 @@ export const defaultTheme: ThemeStyles = {
155
155
  * Tooltip.
156
156
  */
157
157
  '.cm-tooltip': {
158
- background: 'var(--dx-baseSurface)',
158
+ background: 'var(--dx-modalSurface)',
159
159
  },
160
160
  '.cm-tooltip-below': {},
161
161
 
@@ -176,7 +176,8 @@ export const defaultTheme: ThemeStyles = {
176
176
  padding: '4px',
177
177
  },
178
178
  '.cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected]': {
179
- background: 'var(--dx-hoverSurface)',
179
+ background: 'var(--dx-accentSurface)',
180
+ color: 'var(--dx-accentSurfaceText)',
180
181
  },
181
182
  '.cm-tooltip.cm-tooltip-autocomplete > ul > completion-section': {
182
183
  paddingLeft: '4px !important',
@@ -232,7 +233,7 @@ export const defaultTheme: ThemeStyles = {
232
233
  outline: '1px solid transparent',
233
234
  },
234
235
  '.cm-panel input, .cm-panel button': {
235
- backgroundColor: 'var(--dx-input)',
236
+ backgroundColor: 'var(--dx-inputSurface)',
236
237
  },
237
238
  '.cm-panel input:focus, .cm-panel button:focus': {
238
239
  outline: '1px solid var(--dx-neutralFocusIndicator)',
@@ -2,4 +2,6 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
+ /** deprecated Replace with @dxos/util trim */
6
+ // TODO(burdon): Remove
5
7
  export const str = (...lines: string[]) => lines.join('\n');
@@ -4,9 +4,10 @@
4
4
 
5
5
  import { type EditorState } from '@codemirror/state';
6
6
 
7
- import { singleValueFacet } from './facet';
8
7
  import { type Range } from '../types';
9
8
 
9
+ import { singleValueFacet } from './facet';
10
+
10
11
  /**
11
12
  * Determines if two ranges overlap.
12
13
  * A range is considered to overlap if there is any intersection