@dxos/react-ui-editor 0.3.10-main.dcfebef → 0.3.10-main.e38869c
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 +1181 -372
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts +23 -2
- package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.d.ts +2 -1
- package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +3 -0
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/autocomplete.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/basic.d.ts +2 -1
- package/dist/types/src/components/TextEditor/extensions/basic.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/blast.d.ts +25 -0
- package/dist/types/src/components/TextEditor/extensions/blast.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/code.d.ts +2 -0
- package/dist/types/src/components/TextEditor/extensions/code.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/comments.d.ts +2 -2
- package/dist/types/src/components/TextEditor/extensions/comments.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/demo.d.ts +2 -1
- package/dist/types/src/components/TextEditor/extensions/demo.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/experimental.d.ts +1 -1
- package/dist/types/src/components/TextEditor/extensions/experimental.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/highlight.d.ts +24 -0
- package/dist/types/src/components/TextEditor/extensions/highlight.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/image.d.ts +4 -0
- package/dist/types/src/components/TextEditor/extensions/image.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/index.d.ts +6 -0
- package/dist/types/src/components/TextEditor/extensions/index.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/link.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/listener.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/markdown/bundle.d.ts +10 -1
- package/dist/types/src/components/TextEditor/extensions/markdown/bundle.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/markdown/highlight.d.ts +9 -3
- package/dist/types/src/components/TextEditor/extensions/markdown/highlight.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/mention.d.ts +6 -0
- package/dist/types/src/components/TextEditor/extensions/mention.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/table.d.ts +8 -0
- package/dist/types/src/components/TextEditor/extensions/table.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/tasklist.d.ts +2 -1
- package/dist/types/src/components/TextEditor/extensions/tasklist.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/themes/default.d.ts +5 -0
- package/dist/types/src/components/TextEditor/themes/default.d.ts.map +1 -1
- package/dist/types/src/hooks/automerge/automerge.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextModel.d.ts +6 -0
- package/dist/types/src/hooks/useTextModel.d.ts.map +1 -1
- package/dist/types/src/{components/TextEditor → hooks/yjs}/yjs.stories.d.ts +2 -2
- package/dist/types/src/hooks/yjs/yjs.stories.d.ts.map +1 -0
- package/dist/types/src/styles/markdown.d.ts +3 -2
- package/dist/types/src/styles/markdown.d.ts.map +1 -1
- package/dist/types/src/testing/replicator.d.ts.map +1 -1
- package/package.json +23 -21
- package/src/components/TextEditor/MarkdownEditor.stories.tsx +124 -32
- package/src/components/TextEditor/TextEditor.stories.tsx +12 -1
- package/src/components/TextEditor/TextEditor.tsx +31 -24
- package/src/components/TextEditor/extensions/autocomplete.ts +5 -20
- package/src/components/TextEditor/extensions/basic.ts +6 -4
- package/src/components/TextEditor/extensions/blast.ts +373 -0
- package/src/components/TextEditor/extensions/code.ts +99 -0
- package/src/components/TextEditor/extensions/comments.ts +29 -46
- package/src/components/TextEditor/extensions/demo.ts +4 -1
- package/src/components/TextEditor/extensions/experimental.tsx +15 -36
- package/src/components/TextEditor/extensions/highlight.ts +128 -0
- package/src/components/TextEditor/extensions/image.ts +67 -0
- package/src/components/TextEditor/extensions/index.ts +6 -0
- package/src/components/TextEditor/extensions/link.ts +17 -25
- package/src/components/TextEditor/extensions/listener.ts +3 -3
- package/src/components/TextEditor/extensions/markdown/bundle.ts +45 -37
- package/src/components/TextEditor/extensions/markdown/highlight.ts +148 -108
- package/src/components/TextEditor/extensions/mention.ts +31 -0
- package/src/components/TextEditor/extensions/table.ts +119 -0
- package/src/components/TextEditor/extensions/tasklist.ts +42 -28
- package/src/components/TextEditor/themes/default.ts +98 -4
- package/src/hooks/automerge/automerge.stories.tsx +1 -0
- package/src/hooks/useTextModel.ts +9 -0
- package/src/{components/TextEditor → hooks/yjs}/yjs.stories.tsx +2 -2
- package/src/styles/markdown.ts +15 -8
- package/src/testing/replicator.ts +1 -0
- package/dist/types/src/components/TextEditor/yjs.stories.d.ts.map +0 -1
|
@@ -9,6 +9,7 @@ import { basicSetup } from 'codemirror';
|
|
|
9
9
|
import get from 'lodash.get';
|
|
10
10
|
import React, { useEffect, useRef, useState } from 'react';
|
|
11
11
|
|
|
12
|
+
// TODO(burdon): Why separate imports?
|
|
12
13
|
import { type Prop } from '@dxos/automerge/automerge';
|
|
13
14
|
import { type DocHandle, Repo } from '@dxos/automerge/automerge-repo';
|
|
14
15
|
|
|
@@ -26,12 +26,19 @@ import { SpaceAwarenessProvider } from './yjs';
|
|
|
26
26
|
// TODO(burdon): Move.
|
|
27
27
|
type Awareness = awarenessProtocol.Awareness;
|
|
28
28
|
|
|
29
|
+
export type DocumentRange = {
|
|
30
|
+
id: string;
|
|
31
|
+
from: number;
|
|
32
|
+
to: number;
|
|
33
|
+
};
|
|
34
|
+
|
|
29
35
|
// TODO(wittjosiah): Factor out to common package? @dxos/react-client?
|
|
30
36
|
export type EditorModel = {
|
|
31
37
|
id: string;
|
|
32
38
|
// TODO(burdon): Remove.
|
|
33
39
|
content: string | YText | YXmlFragment | DocAccessor;
|
|
34
40
|
text: () => string;
|
|
41
|
+
ranges: DocumentRange[];
|
|
35
42
|
extension?: Extension;
|
|
36
43
|
awareness?: Awareness;
|
|
37
44
|
peer?: {
|
|
@@ -80,6 +87,7 @@ const createYjsModel = ({ identity, space, text }: UseTextModelOptions): EditorM
|
|
|
80
87
|
id: text.doc.guid,
|
|
81
88
|
content: text.content,
|
|
82
89
|
text: () => text.content!.toString(),
|
|
90
|
+
ranges: [],
|
|
83
91
|
extension: yCollab(text.content as YText, provider?.awareness),
|
|
84
92
|
awareness: provider?.awareness,
|
|
85
93
|
peer: identity
|
|
@@ -99,6 +107,7 @@ const createAutomergeModel = ({ identity, text }: UseTextModelOptions): EditorMo
|
|
|
99
107
|
id: obj.id,
|
|
100
108
|
content: doc,
|
|
101
109
|
text: () => get(doc.handle.docSync(), doc.path),
|
|
110
|
+
ranges: [],
|
|
102
111
|
extension: automergePlugin(doc.handle, doc.path),
|
|
103
112
|
peer: identity
|
|
104
113
|
? {
|
|
@@ -12,10 +12,11 @@ import { ClientRepeater, textGenerator, useDataGenerator } from '@dxos/react-cli
|
|
|
12
12
|
import { useId, Input } from '@dxos/react-ui';
|
|
13
13
|
import { withTheme } from '@dxos/storybook-utils';
|
|
14
14
|
|
|
15
|
-
import { MarkdownEditor } from '
|
|
15
|
+
import { MarkdownEditor } from '../../components';
|
|
16
16
|
import { Replicator, useYjsModel } from '../../testing';
|
|
17
17
|
|
|
18
18
|
export default {
|
|
19
|
+
title: 'react-ui-editor/YJS',
|
|
19
20
|
component: MarkdownEditor,
|
|
20
21
|
decorators: [withTheme],
|
|
21
22
|
};
|
|
@@ -50,7 +51,6 @@ const Story = () => {
|
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
export const Default = {
|
|
53
|
-
title: 'react-ui-editor/YJS',
|
|
54
54
|
// TODO(wittjosiah): Decorator for doing this without clients being initialized?
|
|
55
55
|
render: () => <ClientRepeater count={2} Component={Story} />,
|
|
56
56
|
};
|
package/src/styles/markdown.ts
CHANGED
|
@@ -6,14 +6,20 @@ import { mx } from '@dxos/react-ui-theme';
|
|
|
6
6
|
|
|
7
7
|
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
8
8
|
|
|
9
|
+
// TODO(burdon): Better way to align vertically than negative margin? Font-specific?
|
|
9
10
|
// https://tailwindcss.com/docs/font-weight
|
|
10
|
-
export const
|
|
11
|
-
1: 'mbs-4 mbe-2 font-medium text-inherit no-underline text-4xl',
|
|
12
|
-
2: 'mbs-4 mbe-2 font-medium text-inherit no-underline text-3xl',
|
|
13
|
-
3: 'mbs-4 mbe-2 font-medium text-inherit no-underline text-2xl',
|
|
14
|
-
4: 'mbs-4 mbe-2 font-medium text-inherit no-underline text-xl',
|
|
15
|
-
5: 'mbs-4 mbe-2 font-medium text-inherit no-underline text-lg',
|
|
16
|
-
6: 'mbs-4 mbe-2 font-medium text-inherit no-underline',
|
|
11
|
+
export const headings: Record<HeadingLevel, string[]> = {
|
|
12
|
+
1: ['mbs-4 mbe-2 font-medium text-inherit no-underline text-4xl', '-ml-[10px]'],
|
|
13
|
+
2: ['mbs-4 mbe-2 font-medium text-inherit no-underline text-3xl', '-ml-[8px]'],
|
|
14
|
+
3: ['mbs-4 mbe-2 font-medium text-inherit no-underline text-2xl', '-ml-[7px]'],
|
|
15
|
+
4: ['mbs-4 mbe-2 font-medium text-inherit no-underline text-xl', '-ml-[6px]'],
|
|
16
|
+
5: ['mbs-4 mbe-2 font-medium text-inherit no-underline text-lg', '-ml-[5px]'],
|
|
17
|
+
6: ['mbs-4 mbe-2 font-medium text-inherit no-underline', '-ml-[4px]'],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const heading = (level: HeadingLevel, readonly?: boolean) => {
|
|
21
|
+
const [style, offset] = headings[level];
|
|
22
|
+
return mx(style, readonly && offset);
|
|
17
23
|
};
|
|
18
24
|
|
|
19
25
|
export const text = 'text-neutral-800 dark:text-neutral-200';
|
|
@@ -37,7 +43,8 @@ export const inlineUrl = mx(code, 'px-1');
|
|
|
37
43
|
export const blockquote = mx('pl-1 mr-1 border-is-4 border-primary-500/70 dark:border-primary-500/30', light);
|
|
38
44
|
|
|
39
45
|
// TODO(burdon): Replace with widget.
|
|
40
|
-
export const horizontalRule =
|
|
46
|
+
export const horizontalRule =
|
|
47
|
+
'flex mlb-4 border-b text-neutral-100 dark:text-neutral-900 border-neutral-200 dark:border-neutral-800';
|
|
41
48
|
|
|
42
49
|
// TODO(thure): Tailwind was not seeing `[&>li:before]:content-["•"]` as a utility class, but it would work if instead of `"•"` it was `"X"`… why?
|
|
43
50
|
export const unorderedList =
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"yjs.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/TextEditor/yjs.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAEpB,OAAO,KAAmB,MAAM,OAAO,CAAC;;;;;AAWxC,wBAGE;AA+BF,eAAO,MAAM,OAAO;;;CAInB,CAAC"}
|