@dxos/react-ui-editor 0.4.8-main.5f46a83 → 0.4.8-main.97e86fe
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 +796 -797
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/automerge.stories.d.ts.map +1 -1
- package/dist/types/src/{hooks → extensions/awareness}/awareness-provider.d.ts +1 -1
- package/dist/types/src/extensions/awareness/awareness-provider.d.ts.map +1 -0
- package/dist/types/src/extensions/awareness/awareness.d.ts.map +1 -0
- package/dist/types/src/extensions/awareness/index.d.ts +3 -0
- package/dist/types/src/extensions/awareness/index.d.ts.map +1 -0
- 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/cursor.d.ts +1 -1
- package/dist/types/src/extensions/cursor.d.ts.map +1 -1
- package/dist/types/src/{hooks/extension-utils.d.ts → extensions/factories.d.ts} +2 -7
- package/dist/types/src/extensions/factories.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +2 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -1
- package/dist/types/src/{hooks/defs.d.ts → extensions/types.d.ts} +1 -1
- package/dist/types/src/extensions/types.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +1 -3
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useDocAccessor.d.ts +7 -0
- package/dist/types/src/hooks/useDocAccessor.d.ts.map +1 -0
- package/package.json +24 -24
- package/src/components/TextEditor/TextEditor.stories.tsx +5 -7
- package/src/components/Toolbar/Toolbar.stories.tsx +5 -9
- package/src/extensions/automerge/automerge.stories.tsx +2 -1
- package/src/{hooks → extensions/awareness}/awareness-provider.ts +1 -1
- package/src/extensions/{awareness.ts → awareness/awareness.ts} +1 -1
- package/src/extensions/awareness/index.ts +6 -0
- package/src/extensions/comments.ts +1 -1
- package/src/extensions/cursor.ts +1 -1
- package/src/{hooks/extension-utils.ts → extensions/factories.ts} +3 -21
- package/src/extensions/index.ts +2 -0
- package/src/extensions/markdown/decorate.ts +1 -1
- package/src/{hooks/defs.ts → extensions/types.ts} +1 -0
- package/src/hooks/index.ts +1 -4
- package/src/hooks/useDocAccessor.ts +21 -0
- package/src/hooks/useTextEditor.stories.tsx +1 -1
- package/dist/types/src/extensions/awareness.d.ts.map +0 -1
- package/dist/types/src/hooks/awareness-provider.d.ts.map +0 -1
- package/dist/types/src/hooks/defs.d.ts.map +0 -1
- package/dist/types/src/hooks/extension-utils.d.ts.map +0 -1
- /package/dist/types/src/extensions/{awareness.d.ts → awareness/awareness.d.ts} +0 -0
|
@@ -15,8 +15,12 @@ import { withTheme } from '@dxos/storybook-utils';
|
|
|
15
15
|
|
|
16
16
|
import { Toolbar } from './Toolbar';
|
|
17
17
|
import {
|
|
18
|
+
type Comment,
|
|
18
19
|
decorateMarkdown,
|
|
19
20
|
comments,
|
|
21
|
+
createBasicExtensions,
|
|
22
|
+
createDataExtensions,
|
|
23
|
+
createThemeExtensions,
|
|
20
24
|
formattingKeymap,
|
|
21
25
|
table,
|
|
22
26
|
useComments,
|
|
@@ -24,15 +28,7 @@ import {
|
|
|
24
28
|
createMarkdownExtensions,
|
|
25
29
|
image,
|
|
26
30
|
} from '../../extensions';
|
|
27
|
-
import {
|
|
28
|
-
type Comment,
|
|
29
|
-
createBasicExtensions,
|
|
30
|
-
createDataExtensions,
|
|
31
|
-
createThemeExtensions,
|
|
32
|
-
useActionHandler,
|
|
33
|
-
useDocAccessor,
|
|
34
|
-
useTextEditor,
|
|
35
|
-
} from '../../hooks';
|
|
31
|
+
import { useActionHandler, useDocAccessor, useTextEditor } from '../../hooks';
|
|
36
32
|
import translations from '../../translations';
|
|
37
33
|
|
|
38
34
|
faker.seed(101);
|
|
@@ -17,8 +17,9 @@ import { useThemeContext } from '@dxos/react-ui';
|
|
|
17
17
|
import { withTheme } from '@dxos/storybook-utils';
|
|
18
18
|
|
|
19
19
|
import { automerge } from './automerge';
|
|
20
|
-
import {
|
|
20
|
+
import { useTextEditor } from '../../hooks';
|
|
21
21
|
import translations from '../../translations';
|
|
22
|
+
import { createBasicExtensions, createThemeExtensions } from '../factories';
|
|
22
23
|
|
|
23
24
|
const initialContent = 'Hello world!';
|
|
24
25
|
|
|
@@ -9,7 +9,7 @@ import { log } from '@dxos/log';
|
|
|
9
9
|
import { type Space } from '@dxos/react-client/echo';
|
|
10
10
|
import { type GossipMessage } from '@dxos/react-client/mesh';
|
|
11
11
|
|
|
12
|
-
import { type AwarenessInfo, type AwarenessPosition, type AwarenessProvider, type AwarenessState } from '
|
|
12
|
+
import { type AwarenessInfo, type AwarenessPosition, type AwarenessProvider, type AwarenessState } from './awareness';
|
|
13
13
|
|
|
14
14
|
type ProtocolMessage =
|
|
15
15
|
| {
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import { Event } from '@dxos/async';
|
|
17
17
|
import { Context } from '@dxos/context';
|
|
18
18
|
|
|
19
|
-
import { Cursor, type CursorConverter } from '
|
|
19
|
+
import { Cursor, type CursorConverter } from '../cursor';
|
|
20
20
|
|
|
21
21
|
export interface AwarenessProvider {
|
|
22
22
|
remoteStateChange: Event<void>;
|
|
@@ -13,7 +13,7 @@ import { log } from '@dxos/log';
|
|
|
13
13
|
import { nonNullable } from '@dxos/util';
|
|
14
14
|
|
|
15
15
|
import { Cursor } from './cursor';
|
|
16
|
-
import { type Comment, type Range } from '
|
|
16
|
+
import { type Comment, type Range } from './types';
|
|
17
17
|
import { getToken } from '../styles';
|
|
18
18
|
import { callbackWrapper } from '../util';
|
|
19
19
|
|
package/src/extensions/cursor.ts
CHANGED
|
@@ -17,10 +17,9 @@ import {
|
|
|
17
17
|
scrollPastEnd,
|
|
18
18
|
} from '@codemirror/view';
|
|
19
19
|
import defaultsDeep from 'lodash.defaultsdeep';
|
|
20
|
-
import { useMemo } from 'react';
|
|
21
20
|
|
|
22
21
|
import { generateName } from '@dxos/display-name';
|
|
23
|
-
import {
|
|
22
|
+
import { type DocAccessor } from '@dxos/echo-schema';
|
|
24
23
|
import { log } from '@dxos/log';
|
|
25
24
|
import { type Space } from '@dxos/react-client/echo';
|
|
26
25
|
import { type Identity } from '@dxos/react-client/halo';
|
|
@@ -28,8 +27,8 @@ import { type ThemeMode } from '@dxos/react-ui';
|
|
|
28
27
|
import { type HuePalette, hueTokens } from '@dxos/react-ui-theme';
|
|
29
28
|
import { hexToHue, isNotFalsy } from '@dxos/util';
|
|
30
29
|
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
30
|
+
import { automerge } from './automerge';
|
|
31
|
+
import { awareness, SpaceAwarenessProvider } from './awareness';
|
|
33
32
|
import { type ThemeStyles } from '../styles';
|
|
34
33
|
import { defaultTheme } from '../themes';
|
|
35
34
|
|
|
@@ -117,9 +116,6 @@ const defaultSlots = {
|
|
|
117
116
|
editor: {
|
|
118
117
|
className: 'w-full bs-full',
|
|
119
118
|
},
|
|
120
|
-
content: {
|
|
121
|
-
className: '!p-2',
|
|
122
|
-
},
|
|
123
119
|
};
|
|
124
120
|
|
|
125
121
|
export const createThemeExtensions = ({ theme, themeMode, slots: _slots }: ThemeExtensionsOptions = {}): Extension => {
|
|
@@ -169,17 +165,3 @@ export const createDataExtensions = ({ id, text, space, identity }: DataExtensio
|
|
|
169
165
|
|
|
170
166
|
return extensions;
|
|
171
167
|
};
|
|
172
|
-
|
|
173
|
-
// TODO(burdon): Factor out.
|
|
174
|
-
export const useDocAccessor = <T = any>(
|
|
175
|
-
text: TextObject,
|
|
176
|
-
): { id: string; doc: string | undefined; accessor: DocAccessor<T> } => {
|
|
177
|
-
return useMemo(
|
|
178
|
-
() => ({
|
|
179
|
-
id: text.id,
|
|
180
|
-
doc: getTextContent(text),
|
|
181
|
-
accessor: createDocAccessor<T>(text),
|
|
182
|
-
}),
|
|
183
|
-
[text],
|
|
184
|
-
);
|
|
185
|
-
};
|
package/src/extensions/index.ts
CHANGED
|
@@ -13,8 +13,10 @@ export * from './cursor';
|
|
|
13
13
|
export * from './cursor-line-margin';
|
|
14
14
|
export * from './doc';
|
|
15
15
|
export * from './dnd';
|
|
16
|
+
export * from './factories';
|
|
16
17
|
export * from './listener';
|
|
17
18
|
export * from './markdown';
|
|
18
19
|
export * from './mention';
|
|
19
20
|
export * from './modes';
|
|
21
|
+
export * from './types';
|
|
20
22
|
export * from './typewriter';
|
|
@@ -48,7 +48,7 @@ class CheckboxWidget extends WidgetType {
|
|
|
48
48
|
|
|
49
49
|
override toDOM(view: EditorView) {
|
|
50
50
|
const input = document.createElement('input');
|
|
51
|
-
input.className = 'cm-task-checkbox';
|
|
51
|
+
input.className = 'cm-task-checkbox ch-checkbox ch-focus-ring -mbs-0.5';
|
|
52
52
|
input.type = 'checkbox';
|
|
53
53
|
input.checked = this._checked;
|
|
54
54
|
if (view.state.readOnly) {
|
package/src/hooks/index.ts
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { createDocAccessor, type DocAccessor, getTextContent, type TextObject } from '@dxos/echo-schema';
|
|
8
|
+
|
|
9
|
+
// TODO(burdon): Factor out.
|
|
10
|
+
export const useDocAccessor = <T = any>(
|
|
11
|
+
text: TextObject,
|
|
12
|
+
): { id: string; doc: string | undefined; accessor: DocAccessor<T> } => {
|
|
13
|
+
return useMemo(
|
|
14
|
+
() => ({
|
|
15
|
+
id: text.id,
|
|
16
|
+
doc: getTextContent(text),
|
|
17
|
+
accessor: createDocAccessor<T>(text),
|
|
18
|
+
}),
|
|
19
|
+
[text],
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -10,10 +10,10 @@ import { Toolbar as NaturalToolbar, Select, useThemeContext, Tooltip } from '@dx
|
|
|
10
10
|
import { attentionSurface, mx, textBlockWidth } from '@dxos/react-ui-theme';
|
|
11
11
|
import { withTheme } from '@dxos/storybook-utils';
|
|
12
12
|
|
|
13
|
-
import { createBasicExtensions, createThemeExtensions } from './extension-utils';
|
|
14
13
|
import { useActionHandler } from './useActionHandler';
|
|
15
14
|
import { useTextEditor } from './useTextEditor';
|
|
16
15
|
import { Toolbar } from '../components';
|
|
16
|
+
import { createBasicExtensions, createThemeExtensions } from '../extensions';
|
|
17
17
|
import {
|
|
18
18
|
type EditorMode,
|
|
19
19
|
EditorModes,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"awareness.d.ts","sourceRoot":"","sources":["../../../../src/extensions/awareness.ts"],"names":[],"mappings":"AAIA,OAAO,EAAc,KAAK,EAAE,KAAK,SAAS,EAAwB,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAEL,KAAK,aAAa,EAClB,UAAU,EACV,KAAK,WAAW,EAEhB,KAAK,UAAU,EAEhB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAKpC,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAE/B,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,IAAI,IAAI,CAAC;IAEd,eAAe,IAAI,cAAc,EAAE,CAAC;IACpC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,GAAG,SAAS,GAAG,IAAI,CAAC;CACvD;AAYD,eAAO,MAAM,iBAAiB,6CAE5B,CAAC;AAKH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,aAAa,GAA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;AAEF;;GAEG;AACH,qBAAa,sBAAuB,YAAW,iBAAiB;IAC9D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAqC;IAEnE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IAEtC,OAAO,CAAC,IAAI,CAAC,CAAU;IACvB,OAAO,CAAC,SAAS,CAAC,CAAe;IACjC,OAAO,CAAC,WAAW,CAAC,CAAiB;IAErC,SAAgB,iBAAiB,cAAqB;gBAE1C,MAAM,EAAE,uBAAuB;IAO3C,IAAI;IAqCJ,KAAK;IAML,eAAe,IAAI,cAAc,EAAE;IAInC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,GAAG,SAAS,GAAG,IAAI;IAWrD,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,kBAAkB;CAK3B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../../src/hooks/defs.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAGF,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extension-utils.d.ts","sourceRoot":"","sources":["../../../../src/hooks/extension-utils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAehE,OAAO,EAAqC,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEzG,OAAO,EAAE,KAAK,KAAK,EAAE,MA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