@dxos/react-ui-editor 0.8.4-main.c1de068 → 0.8.4-main.fd6878d
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 +299 -249
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/node-esm/index.mjs +299 -249
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs.map +2 -2
- package/dist/types/src/components/Editor/Editor.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/blocks.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/formatting.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/headings.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/lists.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/util.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/view-mode.d.ts +1 -1
- package/dist/types/src/components/EditorToolbar/view-mode.d.ts.map +1 -1
- package/dist/types/src/extensions/autocomplete.d.ts +1 -1
- package/dist/types/src/extensions/autocomplete.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/automerge.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/automerge.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/defs.d.ts +1 -1
- package/dist/types/src/extensions/automerge/defs.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/sync.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/update-automerge.d.ts.map +1 -1
- package/dist/types/src/extensions/command/action.d.ts +1 -1
- package/dist/types/src/extensions/command/action.d.ts.map +1 -1
- package/dist/types/src/extensions/command/command-menu.d.ts +1 -1
- package/dist/types/src/extensions/command/command-menu.d.ts.map +1 -1
- package/dist/types/src/extensions/command/command.d.ts.map +1 -1
- package/dist/types/src/extensions/command/hint.d.ts.map +1 -1
- package/dist/types/src/extensions/command/state.d.ts +1 -1
- package/dist/types/src/extensions/command/state.d.ts.map +1 -1
- package/dist/types/src/extensions/command/typeahead.d.ts.map +1 -1
- package/dist/types/src/extensions/command/useCommandMenu.d.ts +1 -1
- package/dist/types/src/extensions/command/useCommandMenu.d.ts.map +1 -1
- package/dist/types/src/extensions/comments.d.ts +1 -1
- package/dist/types/src/extensions/comments.d.ts.map +1 -1
- package/dist/types/src/extensions/dnd.d.ts.map +1 -1
- package/dist/types/src/extensions/factories.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/action.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/changes.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/decorate.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/formatting.d.ts +1 -1
- package/dist/types/src/extensions/markdown/formatting.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/formatting.test.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/highlight.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/outliner.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/selection.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/tree.d.ts +1 -1
- package/dist/types/src/extensions/outliner/tree.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextEditor.d.ts.map +1 -1
- package/dist/types/src/stories/Command.stories.d.ts.map +1 -1
- package/dist/types/src/stories/CommandMenu.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Comments.stories.d.ts.map +1 -1
- package/dist/types/src/stories/EditorToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Experimental.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Markdown.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Outliner.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Preview.stories.d.ts.map +1 -1
- package/dist/types/src/stories/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/stories/components/EditorStory.d.ts.map +1 -1
- package/dist/types/src/styles/theme.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts +1 -0
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/src/util/cursor.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +40 -37
- package/src/components/Editor/Editor.tsx +1 -1
- package/src/components/EditorToolbar/EditorToolbar.tsx +1 -1
- package/src/components/EditorToolbar/blocks.ts +3 -2
- package/src/components/EditorToolbar/formatting.ts +3 -2
- package/src/components/EditorToolbar/headings.ts +2 -1
- package/src/components/EditorToolbar/lists.ts +3 -2
- package/src/components/EditorToolbar/util.ts +1 -1
- package/src/components/EditorToolbar/view-mode.ts +2 -1
- package/src/components/Popover/RefDropdownMenu.tsx +1 -1
- package/src/components/Popover/RefPopover.tsx +4 -4
- package/src/extensions/autocomplete.ts +3 -3
- package/src/extensions/automerge/automerge.stories.tsx +4 -4
- package/src/extensions/automerge/automerge.ts +4 -3
- package/src/extensions/automerge/defs.ts +1 -1
- package/src/extensions/automerge/sync.ts +1 -1
- package/src/extensions/automerge/update-automerge.ts +1 -1
- package/src/extensions/awareness/awareness.ts +2 -2
- package/src/extensions/command/action.ts +1 -1
- package/src/extensions/command/command-menu.ts +4 -3
- package/src/extensions/command/command.ts +3 -3
- package/src/extensions/command/hint.ts +2 -1
- package/src/extensions/command/placeholder.ts +1 -1
- package/src/extensions/command/state.ts +4 -3
- package/src/extensions/command/typeahead.ts +2 -2
- package/src/extensions/command/useCommandMenu.ts +2 -1
- package/src/extensions/comments.ts +7 -6
- package/src/extensions/dnd.ts +1 -1
- package/src/extensions/factories.ts +4 -3
- package/src/extensions/markdown/action.ts +2 -1
- package/src/extensions/markdown/bundle.ts +1 -1
- package/src/extensions/markdown/changes.ts +1 -1
- package/src/extensions/markdown/decorate.ts +7 -6
- package/src/extensions/markdown/formatting.test.ts +6 -6
- package/src/extensions/markdown/formatting.ts +3 -3
- package/src/extensions/markdown/highlight.ts +1 -1
- package/src/extensions/mention.ts +1 -1
- package/src/extensions/outliner/outliner.test.ts +3 -2
- package/src/extensions/outliner/outliner.ts +4 -3
- package/src/extensions/outliner/selection.ts +1 -1
- package/src/extensions/outliner/tree.test.ts +2 -1
- package/src/extensions/outliner/tree.ts +1 -1
- package/src/hooks/useTextEditor.ts +3 -3
- package/src/stories/Command.stories.tsx +6 -5
- package/src/stories/CommandMenu.stories.tsx +5 -4
- package/src/stories/Comments.stories.tsx +3 -2
- package/src/stories/EditorToolbar.stories.tsx +3 -3
- package/src/stories/Experimental.stories.tsx +4 -3
- package/src/stories/Markdown.stories.tsx +3 -2
- package/src/stories/Outliner.stories.tsx +4 -3
- package/src/stories/Preview.stories.tsx +21 -22
- package/src/stories/TextEditor.stories.tsx +15 -14
- package/src/stories/components/EditorStory.tsx +5 -5
- package/src/styles/theme.ts +4 -3
- package/src/testing/util.ts +2 -0
- 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,
|
17
|
-
import { type
|
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 {
|
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 {
|
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,
|
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
|
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 {
|
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 {
|
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
|
20
|
+
import { type MaybeProvider, getProviderValue, isNotFalsy } from '@dxos/util';
|
21
21
|
|
22
|
-
import { type EditorSelection,
|
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, {
|
7
|
+
import React, { type KeyboardEvent, useState } from 'react';
|
8
8
|
|
9
|
-
import { Button, Icon, Input
|
9
|
+
import { Button, DropdownMenu, Icon, Input } from '@dxos/react-ui';
|
10
10
|
import { mx } from '@dxos/react-ui-theme';
|
11
|
-
import { withLayout, withTheme
|
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 {
|
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 {
|
15
|
-
import { withLayout, withTheme
|
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 {
|
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
|
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 {
|
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
|
12
|
+
import { type Meta, withLayout, withTheme } from '@dxos/storybook-utils';
|
13
13
|
|
14
|
-
import {
|
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
|
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
|
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 {
|
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, {
|
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
|
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 {
|
22
|
-
|
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=
|
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={
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
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
|
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,
|
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 {
|
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 {
|
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,
|
package/src/styles/theme.ts
CHANGED
@@ -155,7 +155,7 @@ export const defaultTheme: ThemeStyles = {
|
|
155
155
|
* Tooltip.
|
156
156
|
*/
|
157
157
|
'.cm-tooltip': {
|
158
|
-
background: 'var(--dx-
|
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-
|
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-
|
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)',
|
package/src/testing/util.ts
CHANGED
package/src/util/cursor.ts
CHANGED
@@ -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
|