@dxos/react-ui-editor 0.3.11-main.668f0ff → 0.3.11-main.67451e9
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 +1696 -1327
- 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 +9 -8
- package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.d.ts +12 -17
- package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +6 -3
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/{hooks/automerge → components/TextEditor}/automerge.stories.d.ts +6 -1
- package/dist/types/src/components/TextEditor/automerge.stories.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/codemirror.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/comments.stories.d.ts +26 -0
- package/dist/types/src/components/TextEditor/comments.stories.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/index.d.ts +0 -2
- package/dist/types/src/components/TextEditor/index.d.ts.map +1 -1
- package/dist/types/src/{hooks/yjs → components/TextEditor}/yjs.stories.d.ts +1 -1
- package/dist/types/src/components/TextEditor/yjs.stories.d.ts.map +1 -0
- package/dist/types/src/extensions/autocomplete.d.ts.map +1 -0
- package/dist/types/src/extensions/automerge/automerge.d.ts +9 -0
- package/dist/types/src/extensions/automerge/automerge.d.ts.map +1 -0
- package/dist/types/src/extensions/automerge/cursor.d.ts +5 -0
- package/dist/types/src/extensions/automerge/cursor.d.ts.map +1 -0
- package/dist/types/src/extensions/automerge/defs.d.ts +26 -0
- package/dist/types/src/extensions/automerge/defs.d.ts.map +1 -0
- package/dist/types/src/extensions/automerge/index.d.ts +4 -0
- package/dist/types/src/extensions/automerge/index.d.ts.map +1 -0
- package/dist/types/src/{hooks → extensions}/automerge/semaphore.d.ts +4 -4
- package/dist/types/src/extensions/automerge/semaphore.d.ts.map +1 -0
- package/dist/types/src/extensions/automerge/update-automerge.d.ts +5 -0
- package/dist/types/src/extensions/automerge/update-automerge.d.ts.map +1 -0
- package/dist/types/src/extensions/automerge/update-codemirror.d.ts.map +1 -0
- package/dist/types/src/extensions/awareness.d.ts +46 -0
- package/dist/types/src/extensions/awareness.d.ts.map +1 -0
- package/dist/types/src/extensions/basic.d.ts.map +1 -0
- package/dist/types/src/extensions/blast.d.ts.map +1 -0
- package/dist/types/src/extensions/code.d.ts.map +1 -0
- package/dist/types/src/{components/TextEditor/extensions → extensions}/comments.d.ts +6 -4
- package/dist/types/src/extensions/comments.d.ts.map +1 -0
- package/dist/types/src/extensions/cursor.d.ts +25 -0
- package/dist/types/src/extensions/cursor.d.ts.map +1 -0
- package/dist/types/src/extensions/hr.d.ts.map +1 -0
- package/dist/types/src/extensions/image.d.ts.map +1 -0
- package/dist/types/src/{components/TextEditor/extensions → extensions}/index.d.ts +4 -2
- package/dist/types/src/extensions/index.d.ts.map +1 -0
- package/dist/types/src/{components/TextEditor/extensions → extensions}/link.d.ts +1 -0
- package/dist/types/src/extensions/link.d.ts.map +1 -0
- package/dist/types/src/extensions/listener.d.ts.map +1 -0
- package/dist/types/src/extensions/markdown/bundle.d.ts.map +1 -0
- package/dist/types/src/extensions/markdown/highlight.d.ts.map +1 -0
- package/dist/types/src/extensions/markdown/index.d.ts.map +1 -0
- package/dist/types/src/extensions/mention.d.ts.map +1 -0
- package/dist/types/src/extensions/table.d.ts.map +1 -0
- package/dist/types/src/extensions/tasklist.d.ts.map +1 -0
- package/dist/types/src/extensions/typewriter.d.ts.map +1 -0
- package/dist/types/src/extensions/yjs/cursor.d.ts +4 -0
- package/dist/types/src/extensions/yjs/cursor.d.ts.map +1 -0
- package/dist/types/src/extensions/yjs/index.d.ts +2 -0
- package/dist/types/src/extensions/yjs/index.d.ts.map +1 -0
- package/dist/types/src/extensions/yjs/yjs.d.ts +4 -0
- package/dist/types/src/extensions/yjs/yjs.d.ts.map +1 -0
- package/dist/types/src/extensions/yjs/yjs.test.d.ts.map +1 -0
- package/dist/types/src/hooks/automerge.d.ts +3 -0
- package/dist/types/src/hooks/automerge.d.ts.map +1 -0
- package/dist/types/src/hooks/awareness-provider.d.ts +28 -0
- package/dist/types/src/hooks/awareness-provider.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextModel.d.ts +4 -8
- package/dist/types/src/hooks/useTextModel.d.ts.map +1 -1
- package/dist/types/src/hooks/{yjs/space-provider.d.ts → yjs.d.ts} +8 -8
- package/dist/types/src/hooks/yjs.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +5 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/styles/cursors.d.ts.map +1 -0
- package/dist/types/src/styles/index.d.ts +1 -0
- package/dist/types/src/styles/index.d.ts.map +1 -1
- package/dist/types/src/styles/markdown.d.ts.map +1 -1
- package/dist/types/src/styles/tokens.d.ts +1 -0
- package/dist/types/src/styles/tokens.d.ts.map +1 -1
- package/dist/types/src/testing/replicator.d.ts +2 -2
- package/dist/types/src/testing/replicator.d.ts.map +1 -1
- package/dist/types/src/{components/TextEditor/themes → themes}/default.d.ts +1 -1
- package/dist/types/src/themes/default.d.ts.map +1 -0
- package/dist/types/src/themes/index.d.ts.map +1 -0
- package/dist/types/src/util.d.ts.map +1 -0
- package/package.json +23 -21
- package/src/components/TextEditor/MarkdownEditor.stories.tsx +36 -36
- package/src/components/TextEditor/TextEditor.stories.tsx +13 -34
- package/src/components/TextEditor/TextEditor.tsx +71 -67
- package/src/{hooks/automerge → components/TextEditor}/automerge.stories.tsx +66 -6
- package/src/components/TextEditor/codemirror.stories.ts +3 -2
- package/src/components/TextEditor/comments.stories.tsx +315 -0
- package/src/components/TextEditor/index.ts +0 -3
- package/src/{hooks/yjs → components/TextEditor}/yjs.stories.tsx +1 -1
- package/src/{components/TextEditor/extensions → extensions}/autocomplete.ts +18 -17
- package/src/extensions/automerge/automerge.ts +94 -0
- package/src/extensions/automerge/cursor.ts +52 -0
- package/src/extensions/automerge/defs.ts +62 -0
- package/src/extensions/automerge/index.ts +7 -0
- package/src/{hooks → extensions}/automerge/semaphore.ts +14 -12
- package/src/{hooks → extensions}/automerge/update-automerge.ts +5 -6
- package/src/{hooks → extensions}/automerge/update-codemirror.ts +13 -5
- package/src/extensions/awareness.ts +309 -0
- package/src/{components/TextEditor/extensions → extensions}/code.ts +14 -7
- package/src/{components/TextEditor/extensions → extensions}/comments.ts +49 -113
- package/src/extensions/cursor.ts +46 -0
- package/src/{components/TextEditor/extensions → extensions}/hr.ts +4 -5
- package/src/extensions/image.ts +87 -0
- package/src/{components/TextEditor/extensions → extensions}/index.ts +4 -2
- package/src/{components/TextEditor/extensions → extensions}/link.ts +116 -62
- package/src/extensions/listener.ts +35 -0
- package/src/{components/TextEditor/extensions → extensions}/markdown/highlight.ts +4 -13
- package/src/{components/TextEditor/extensions → extensions}/table.ts +10 -4
- package/src/{components/TextEditor/extensions → extensions}/tasklist.ts +3 -5
- package/src/{components/TextEditor/extensions → extensions}/typewriter.ts +1 -1
- package/src/extensions/yjs/cursor.ts +22 -0
- package/src/extensions/yjs/index.ts +5 -0
- package/src/{hooks → extensions}/yjs/yjs.test.ts +1 -25
- package/src/extensions/yjs/yjs.ts +16 -0
- package/src/hooks/automerge.ts +52 -0
- package/src/hooks/awareness-provider.ts +120 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useTextModel.ts +20 -96
- package/src/hooks/{yjs/space-provider.ts → yjs.ts} +49 -19
- package/src/index.ts +5 -0
- package/src/styles/index.ts +1 -0
- package/src/styles/markdown.ts +0 -2
- package/src/styles/tokens.ts +3 -0
- package/src/testing/replicator.ts +10 -15
- package/src/{components/TextEditor/themes → themes}/default.ts +53 -72
- package/dist/types/src/components/TextEditor/extensions/autocomplete.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/basic.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/blast.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/code.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/comments.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/hr.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/image.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/index.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/link.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/listener.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/markdown/bundle.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/markdown/highlight.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/markdown/index.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/mention.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/mermaid.d.ts +0 -3
- package/dist/types/src/components/TextEditor/extensions/mermaid.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/table.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/tasklist.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/tooltip.d.ts +0 -12
- package/dist/types/src/components/TextEditor/extensions/tooltip.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/typewriter.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/util.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/themes/default.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/themes/index.d.ts.map +0 -1
- package/dist/types/src/hooks/automerge/automerge.stories.d.ts.map +0 -1
- package/dist/types/src/hooks/automerge/handle.d.ts +0 -9
- package/dist/types/src/hooks/automerge/handle.d.ts.map +0 -1
- package/dist/types/src/hooks/automerge/index.d.ts +0 -3
- package/dist/types/src/hooks/automerge/index.d.ts.map +0 -1
- package/dist/types/src/hooks/automerge/plugin.d.ts +0 -26
- package/dist/types/src/hooks/automerge/plugin.d.ts.map +0 -1
- package/dist/types/src/hooks/automerge/semaphore.d.ts.map +0 -1
- package/dist/types/src/hooks/automerge/update-automerge.d.ts +0 -6
- package/dist/types/src/hooks/automerge/update-automerge.d.ts.map +0 -1
- package/dist/types/src/hooks/automerge/update-codemirror.d.ts.map +0 -1
- package/dist/types/src/hooks/yjs/cursors.d.ts.map +0 -1
- package/dist/types/src/hooks/yjs/index.d.ts +0 -3
- package/dist/types/src/hooks/yjs/index.d.ts.map +0 -1
- package/dist/types/src/hooks/yjs/space-provider.d.ts.map +0 -1
- package/dist/types/src/hooks/yjs/yjs.stories.d.ts.map +0 -1
- package/dist/types/src/hooks/yjs/yjs.test.d.ts.map +0 -1
- package/src/components/TextEditor/extensions/image.ts +0 -69
- package/src/components/TextEditor/extensions/listener.ts +0 -39
- package/src/components/TextEditor/extensions/mermaid.ts +0 -11
- package/src/components/TextEditor/extensions/tooltip.ts +0 -61
- package/src/hooks/automerge/handle.ts +0 -14
- package/src/hooks/automerge/index.ts +0 -6
- package/src/hooks/automerge/plugin.ts +0 -134
- package/src/hooks/yjs/index.ts +0 -6
- /package/dist/types/src/{components/TextEditor/extensions → extensions}/autocomplete.d.ts +0 -0
- /package/dist/types/src/{hooks → extensions}/automerge/update-codemirror.d.ts +0 -0
- /package/dist/types/src/{components/TextEditor/extensions → extensions}/basic.d.ts +0 -0
- /package/dist/types/src/{components/TextEditor/extensions → extensions}/blast.d.ts +0 -0
- /package/dist/types/src/{components/TextEditor/extensions → extensions}/code.d.ts +0 -0
- /package/dist/types/src/{components/TextEditor/extensions → extensions}/hr.d.ts +0 -0
- /package/dist/types/src/{components/TextEditor/extensions → extensions}/image.d.ts +0 -0
- /package/dist/types/src/{components/TextEditor/extensions → extensions}/listener.d.ts +0 -0
- /package/dist/types/src/{components/TextEditor/extensions → extensions}/markdown/bundle.d.ts +0 -0
- /package/dist/types/src/{components/TextEditor/extensions → extensions}/markdown/highlight.d.ts +0 -0
- /package/dist/types/src/{components/TextEditor/extensions → extensions}/markdown/index.d.ts +0 -0
- /package/dist/types/src/{components/TextEditor/extensions → extensions}/mention.d.ts +0 -0
- /package/dist/types/src/{components/TextEditor/extensions → extensions}/table.d.ts +0 -0
- /package/dist/types/src/{components/TextEditor/extensions → extensions}/tasklist.d.ts +0 -0
- /package/dist/types/src/{components/TextEditor/extensions → extensions}/typewriter.d.ts +0 -0
- /package/dist/types/src/{hooks → extensions}/yjs/yjs.test.d.ts +0 -0
- /package/dist/types/src/{hooks/yjs → styles}/cursors.d.ts +0 -0
- /package/dist/types/src/{components/TextEditor/themes → themes}/index.d.ts +0 -0
- /package/dist/types/src/{components/TextEditor/extensions/util.d.ts → util.d.ts} +0 -0
- /package/src/{components/TextEditor/extensions → extensions}/basic.ts +0 -0
- /package/src/{components/TextEditor/extensions → extensions}/blast.ts +0 -0
- /package/src/{components/TextEditor/extensions → extensions}/markdown/bundle.ts +0 -0
- /package/src/{components/TextEditor/extensions → extensions}/markdown/index.ts +0 -0
- /package/src/{components/TextEditor/extensions → extensions}/mention.ts +0 -0
- /package/src/{hooks/yjs → styles}/cursors.ts +0 -0
- /package/src/{components/TextEditor/themes → themes}/index.ts +0 -0
- /package/src/{components/TextEditor/extensions/util.ts → util.ts} +0 -0
|
@@ -2,36 +2,22 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type Extension
|
|
6
|
-
import get from 'lodash.get';
|
|
5
|
+
import { StateField, type Extension } from '@codemirror/state';
|
|
7
6
|
import { useEffect, useState } from 'react';
|
|
8
|
-
import
|
|
9
|
-
import type * as awarenessProtocol from 'y-protocols/awareness';
|
|
10
|
-
import * as Y from 'yjs';
|
|
7
|
+
import type * as YP from 'y-protocols/awareness';
|
|
11
8
|
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
type DocAccessor,
|
|
15
|
-
type Space,
|
|
16
|
-
type TextObject,
|
|
17
|
-
type AutomergeTextCompat,
|
|
18
|
-
getRawDoc,
|
|
19
|
-
isActualAutomergeObject,
|
|
20
|
-
} from '@dxos/react-client/echo';
|
|
9
|
+
import { isAutomergeObject, type DocAccessor, type Space, type TextObject } from '@dxos/react-client/echo';
|
|
21
10
|
import { type Identity } from '@dxos/react-client/halo';
|
|
22
11
|
import type { YText, YXmlFragment } from '@dxos/text-model';
|
|
23
|
-
import { arrayToString, stringToArray } from '@dxos/util';
|
|
24
12
|
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
13
|
+
import { createAutomergeModel } from './automerge';
|
|
14
|
+
import { createYjsModel } from './yjs';
|
|
27
15
|
|
|
28
|
-
// TODO(burdon):
|
|
29
|
-
type Awareness = awarenessProtocol.Awareness;
|
|
16
|
+
// TODO(burdon): Factor out defs.
|
|
30
17
|
|
|
31
18
|
/**
|
|
32
19
|
* State field makes the model available to other extensions.
|
|
33
20
|
*/
|
|
34
|
-
// TODO(burdon): Use facet?
|
|
35
21
|
export const modelState = StateField.define<EditorModel | undefined>({
|
|
36
22
|
create: () => undefined,
|
|
37
23
|
update: (model) => model,
|
|
@@ -44,20 +30,22 @@ export type Range = {
|
|
|
44
30
|
|
|
45
31
|
export type CommentRange = {
|
|
46
32
|
id: string;
|
|
47
|
-
// TODO(burdon):
|
|
48
|
-
cursor: string;
|
|
33
|
+
cursor: string; // TODO(burdon): Rename range.
|
|
49
34
|
};
|
|
50
35
|
|
|
51
36
|
// TODO(wittjosiah): Factor out to common package? @dxos/react-client?
|
|
52
37
|
export type EditorModel = {
|
|
53
38
|
id: string;
|
|
54
|
-
// TODO(burdon): Remove.
|
|
55
|
-
content: string | YText | YXmlFragment | DocAccessor;
|
|
56
39
|
text: () => string;
|
|
57
|
-
getCursorFromRange?: (value: Range) => string;
|
|
58
|
-
getRangeFromCursor?: (cursor: string) => Range;
|
|
59
40
|
extension?: Extension;
|
|
60
|
-
|
|
41
|
+
|
|
42
|
+
// TODO(burdon): Remove.
|
|
43
|
+
content: string | YText | YXmlFragment | DocAccessor;
|
|
44
|
+
|
|
45
|
+
// TODO(burdon): Move into extension.
|
|
46
|
+
awareness?: YP.Awareness;
|
|
47
|
+
|
|
48
|
+
// TODO(burdon): Remove.
|
|
61
49
|
peer?: {
|
|
62
50
|
id: string;
|
|
63
51
|
name?: string;
|
|
@@ -75,82 +63,18 @@ export type UseTextModelProps = {
|
|
|
75
63
|
// TODO(wittjosiah): Factor out to common package? @dxos/react-client?
|
|
76
64
|
export const useTextModel = (props: UseTextModelProps): EditorModel | undefined => {
|
|
77
65
|
const { identity, space, text } = props;
|
|
78
|
-
const [model, setModel] = useState<EditorModel | undefined>(
|
|
66
|
+
const [model, setModel] = useState<EditorModel | undefined>();
|
|
79
67
|
useEffect(() => setModel(createModel(props)), [identity, space, text]);
|
|
80
68
|
return model;
|
|
81
69
|
};
|
|
82
70
|
|
|
83
71
|
const createModel = (props: UseTextModelProps) => {
|
|
84
72
|
const { text } = props;
|
|
85
|
-
if (
|
|
73
|
+
if (isAutomergeObject(text)) {
|
|
86
74
|
return createAutomergeModel(props);
|
|
87
|
-
} else {
|
|
88
|
-
if (!text?.doc) {
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
91
|
-
|
|
75
|
+
} else if (text?.doc) {
|
|
92
76
|
return createYjsModel(props);
|
|
77
|
+
} else {
|
|
78
|
+
return undefined;
|
|
93
79
|
}
|
|
94
80
|
};
|
|
95
|
-
|
|
96
|
-
const createYjsModel = ({ identity, space, text }: UseTextModelProps): EditorModel => {
|
|
97
|
-
invariant(text?.doc && text?.content);
|
|
98
|
-
const provider = space
|
|
99
|
-
? new SpaceAwarenessProvider({ space, doc: text.doc, channel: `yjs.awareness.${text.id}` })
|
|
100
|
-
: undefined;
|
|
101
|
-
|
|
102
|
-
const model: EditorModel = {
|
|
103
|
-
id: text.doc.guid,
|
|
104
|
-
content: text.content,
|
|
105
|
-
text: () => text.content!.toString(),
|
|
106
|
-
// https://github.com/yjs/yjs?tab=readme-ov-file#relative-positions
|
|
107
|
-
getCursorFromRange: (range: Range) => {
|
|
108
|
-
const from = Y.encodeRelativePosition(Y.createRelativePositionFromTypeIndex(text.content as YText, range.from));
|
|
109
|
-
const to = Y.encodeRelativePosition(Y.createRelativePositionFromTypeIndex(text.content as YText, range.to, -1));
|
|
110
|
-
return [arrayToString(from), arrayToString(to)].join(':');
|
|
111
|
-
},
|
|
112
|
-
getRangeFromCursor: (cursor: string) => {
|
|
113
|
-
const parts = cursor.split(':');
|
|
114
|
-
const from = Y.createAbsolutePositionFromRelativePosition(
|
|
115
|
-
Y.decodeRelativePosition(stringToArray(parts[0])),
|
|
116
|
-
text.doc!,
|
|
117
|
-
);
|
|
118
|
-
const to = Y.createAbsolutePositionFromRelativePosition(
|
|
119
|
-
Y.decodeRelativePosition(stringToArray(parts[1])),
|
|
120
|
-
text.doc!,
|
|
121
|
-
);
|
|
122
|
-
return { from: from!.index, to: to!.index };
|
|
123
|
-
},
|
|
124
|
-
extension: [yCollab(text.content as YText, provider?.awareness), modelState.init(() => model)],
|
|
125
|
-
awareness: provider?.awareness,
|
|
126
|
-
peer: identity
|
|
127
|
-
? {
|
|
128
|
-
id: identity.identityKey.toHex(),
|
|
129
|
-
name: identity.profile?.displayName,
|
|
130
|
-
}
|
|
131
|
-
: undefined,
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
return model;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const createAutomergeModel = ({ identity, text }: UseTextModelProps): EditorModel => {
|
|
138
|
-
const obj = text as any as AutomergeTextCompat;
|
|
139
|
-
const doc = getRawDoc(obj, [obj.field]);
|
|
140
|
-
|
|
141
|
-
const model: EditorModel = {
|
|
142
|
-
id: obj.id,
|
|
143
|
-
content: doc,
|
|
144
|
-
text: () => get(doc.handle.docSync(), doc.path),
|
|
145
|
-
// TODO(burdon): https://automerge.org/automerge/api-docs/js/functions/next.getCursor.html
|
|
146
|
-
extension: [automergePlugin(doc.handle, doc.path), modelState.init(() => model)],
|
|
147
|
-
peer: identity
|
|
148
|
-
? {
|
|
149
|
-
id: identity.identityKey.toHex(),
|
|
150
|
-
name: identity.profile?.displayName,
|
|
151
|
-
}
|
|
152
|
-
: undefined,
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
return model;
|
|
156
|
-
};
|
|
@@ -5,14 +5,40 @@
|
|
|
5
5
|
import * as decoding from 'lib0/decoding';
|
|
6
6
|
import * as encoding from 'lib0/encoding';
|
|
7
7
|
import { Observable } from 'lib0/observable';
|
|
8
|
-
import * as
|
|
8
|
+
import * as YP from 'y-protocols/awareness';
|
|
9
9
|
import { type Doc } from 'yjs';
|
|
10
10
|
|
|
11
|
+
import { invariant } from '@dxos/invariant';
|
|
11
12
|
import { log } from '@dxos/log';
|
|
12
13
|
import { type Space } from '@dxos/react-client/echo';
|
|
13
14
|
import { type GossipMessage } from '@dxos/react-client/mesh';
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
import type { YText } from '@dxos/text-model';
|
|
16
|
+
|
|
17
|
+
import { type EditorModel, modelState, type UseTextModelProps } from './useTextModel';
|
|
18
|
+
import { yjs } from '../extensions';
|
|
19
|
+
|
|
20
|
+
export const createYjsModel = ({ identity, space, text }: UseTextModelProps): EditorModel => {
|
|
21
|
+
invariant(text?.doc && text?.content);
|
|
22
|
+
const provider = space
|
|
23
|
+
? new YAwarenessProvider({ space, doc: text.doc, channel: `yjs.awareness.${text.id}` })
|
|
24
|
+
: undefined;
|
|
25
|
+
|
|
26
|
+
const model: EditorModel = {
|
|
27
|
+
id: text.doc.guid,
|
|
28
|
+
content: text.content,
|
|
29
|
+
text: () => text.content!.toString(),
|
|
30
|
+
extension: [modelState.init(() => model), yjs(text.content as YText, provider?.awareness)],
|
|
31
|
+
awareness: provider?.awareness,
|
|
32
|
+
peer: identity
|
|
33
|
+
? {
|
|
34
|
+
id: identity.identityKey.toHex(),
|
|
35
|
+
name: identity.profile?.displayName,
|
|
36
|
+
}
|
|
37
|
+
: undefined,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return model;
|
|
41
|
+
};
|
|
16
42
|
|
|
17
43
|
// Based on https://github.com/yjs/y-webrtc/blob/88baab2/src/y-webrtc.js.
|
|
18
44
|
|
|
@@ -22,16 +48,26 @@ const messageQueryAwareness = 3;
|
|
|
22
48
|
/**
|
|
23
49
|
* Yjs awareness provider on top of a DXOS space.
|
|
24
50
|
*/
|
|
25
|
-
export class
|
|
51
|
+
export class YAwarenessProvider extends Observable<any> {
|
|
26
52
|
private readonly _space: Space;
|
|
27
|
-
private readonly _awareness: Awareness;
|
|
53
|
+
private readonly _awareness: YP.Awareness;
|
|
28
54
|
private readonly _clientId: number;
|
|
29
55
|
private readonly _channel: string;
|
|
30
56
|
|
|
31
|
-
constructor({
|
|
57
|
+
constructor({
|
|
58
|
+
space,
|
|
59
|
+
doc,
|
|
60
|
+
channel,
|
|
61
|
+
awareness,
|
|
62
|
+
}: {
|
|
63
|
+
space: Space;
|
|
64
|
+
doc: Doc;
|
|
65
|
+
channel: string;
|
|
66
|
+
awareness?: YP.Awareness;
|
|
67
|
+
}) {
|
|
32
68
|
super();
|
|
33
69
|
this._space = space;
|
|
34
|
-
this._awareness = awareness ?? new
|
|
70
|
+
this._awareness = awareness ?? new YP.Awareness(doc);
|
|
35
71
|
this._channel = channel;
|
|
36
72
|
this._clientId = doc.clientID;
|
|
37
73
|
|
|
@@ -52,14 +88,11 @@ export class SpaceAwarenessProvider extends Observable<any> {
|
|
|
52
88
|
// Post local awareness state.
|
|
53
89
|
const encoderAwarenessState = encoding.createEncoder();
|
|
54
90
|
encoding.writeVarUint(encoderAwarenessState, messageAwareness);
|
|
55
|
-
encoding.writeVarUint8Array(
|
|
56
|
-
encoderAwarenessState,
|
|
57
|
-
awarenessProtocol.encodeAwarenessUpdate(this.awareness, [this._clientId]),
|
|
58
|
-
);
|
|
91
|
+
encoding.writeVarUint8Array(encoderAwarenessState, YP.encodeAwarenessUpdate(this.awareness, [this._clientId]));
|
|
59
92
|
void this._space.postMessage(this._channel, encoding.toUint8Array(encoderAwarenessState));
|
|
60
93
|
}
|
|
61
94
|
|
|
62
|
-
get awareness(): Awareness {
|
|
95
|
+
get awareness(): YP.Awareness {
|
|
63
96
|
return this._awareness;
|
|
64
97
|
}
|
|
65
98
|
|
|
@@ -68,10 +101,7 @@ export class SpaceAwarenessProvider extends Observable<any> {
|
|
|
68
101
|
const changedClients = added.concat(updated).concat(removed);
|
|
69
102
|
const encoderAwareness = encoding.createEncoder();
|
|
70
103
|
encoding.writeVarUint(encoderAwareness, messageAwareness);
|
|
71
|
-
encoding.writeVarUint8Array(
|
|
72
|
-
encoderAwareness,
|
|
73
|
-
awarenessProtocol.encodeAwarenessUpdate(this._awareness, changedClients),
|
|
74
|
-
);
|
|
104
|
+
encoding.writeVarUint8Array(encoderAwareness, YP.encodeAwarenessUpdate(this._awareness, changedClients));
|
|
75
105
|
void this._space.postMessage(this._channel, encoding.toUint8Array(encoderAwareness));
|
|
76
106
|
}
|
|
77
107
|
|
|
@@ -92,7 +122,7 @@ export class SpaceAwarenessProvider extends Observable<any> {
|
|
|
92
122
|
let sendReply = false;
|
|
93
123
|
switch (messageType) {
|
|
94
124
|
case messageAwareness: {
|
|
95
|
-
|
|
125
|
+
YP.applyAwarenessUpdate(this._awareness, decoding.readVarUint8Array(decoder), this);
|
|
96
126
|
break;
|
|
97
127
|
}
|
|
98
128
|
|
|
@@ -100,7 +130,7 @@ export class SpaceAwarenessProvider extends Observable<any> {
|
|
|
100
130
|
encoding.writeVarUint(encoder, messageAwareness);
|
|
101
131
|
encoding.writeVarUint8Array(
|
|
102
132
|
encoder,
|
|
103
|
-
|
|
133
|
+
YP.encodeAwarenessUpdate(this._awareness, Array.from(this._awareness.getStates().keys())),
|
|
104
134
|
);
|
|
105
135
|
sendReply = true;
|
|
106
136
|
break;
|
|
@@ -121,6 +151,6 @@ export class SpaceAwarenessProvider extends Observable<any> {
|
|
|
121
151
|
}
|
|
122
152
|
|
|
123
153
|
private _handleBeforeUnload() {
|
|
124
|
-
|
|
154
|
+
YP.removeAwarenessStates(this._awareness, [this._clientId], 'window unload');
|
|
125
155
|
}
|
|
126
156
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
export { TextKind } from '@dxos/protocols/proto/dxos/echo/model/text';
|
|
6
6
|
export { Doc, YText, YXmlFragment } from '@dxos/text-model';
|
|
7
7
|
export { type Extension } from '@codemirror/state';
|
|
8
|
+
export { type EditorView } from '@codemirror/view';
|
|
8
9
|
|
|
9
10
|
export * from './components';
|
|
11
|
+
export * from './extensions';
|
|
10
12
|
export * from './hooks';
|
|
13
|
+
export { getToken } from './styles';
|
|
14
|
+
export * from './themes';
|
|
15
|
+
export * from './util';
|
package/src/styles/index.ts
CHANGED
package/src/styles/markdown.ts
CHANGED
|
@@ -39,10 +39,8 @@ export const codeBlock = 'mlb-2 font-mono bg-neutral-500/10 p-3 rounded';
|
|
|
39
39
|
|
|
40
40
|
export const inlineUrl = mx(code, 'px-1');
|
|
41
41
|
|
|
42
|
-
// TODO(burdon): Replace with widget.
|
|
43
42
|
export const blockquote = mx('pl-1 mr-1 border-is-4 border-primary-500/70 dark:border-primary-500/30', light);
|
|
44
43
|
|
|
45
|
-
// TODO(burdon): Replace with widget.
|
|
46
44
|
export const horizontalRule =
|
|
47
45
|
'flex mlb-4 border-b text-neutral-100 dark:text-neutral-900 border-neutral-200 dark:border-neutral-800';
|
|
48
46
|
|
package/src/styles/tokens.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import get from 'lodash.get';
|
|
5
6
|
import type { StyleSpec } from 'style-mod';
|
|
6
7
|
|
|
7
8
|
import { tailwindConfig, type TailwindConfig } from '@dxos/react-ui-theme';
|
|
@@ -12,3 +13,5 @@ export type ThemeStyles = {
|
|
|
12
13
|
|
|
13
14
|
// TODO(thure): Why export the whole theme? Can this be done differently?
|
|
14
15
|
export const tokens: TailwindConfig['theme'] = tailwindConfig({}).theme;
|
|
16
|
+
|
|
17
|
+
export const getToken = (path: string, defaultValue: any = undefined) => get(tokens, path, defaultValue);
|
|
@@ -7,7 +7,7 @@ import * as decoding from 'lib0/decoding';
|
|
|
7
7
|
import * as encoding from 'lib0/encoding';
|
|
8
8
|
import { Observable } from 'lib0/observable';
|
|
9
9
|
import { useMemo } from 'react';
|
|
10
|
-
import * as
|
|
10
|
+
import * as YP from 'y-protocols/awareness';
|
|
11
11
|
import * as syncProtocol from 'y-protocols/sync';
|
|
12
12
|
import { Doc } from 'yjs';
|
|
13
13
|
|
|
@@ -15,9 +15,10 @@ import { Event } from '@dxos/async';
|
|
|
15
15
|
import { log } from '@dxos/log';
|
|
16
16
|
import { TextKind } from '@dxos/protocols/proto/dxos/echo/model/text';
|
|
17
17
|
|
|
18
|
-
import {
|
|
18
|
+
import { type EditorModel } from '../hooks';
|
|
19
|
+
import { cursorColor } from '../styles';
|
|
19
20
|
|
|
20
|
-
type Awareness =
|
|
21
|
+
type Awareness = YP.Awareness;
|
|
21
22
|
|
|
22
23
|
const messageSync = 0;
|
|
23
24
|
const messageAwareness = 1;
|
|
@@ -35,7 +36,7 @@ export class AwarenessProvider extends Observable<any> {
|
|
|
35
36
|
super();
|
|
36
37
|
this._remoteUpdate = update;
|
|
37
38
|
this._doc = doc;
|
|
38
|
-
this._awareness = awareness ?? new
|
|
39
|
+
this._awareness = awareness ?? new YP.Awareness(doc);
|
|
39
40
|
|
|
40
41
|
this._doc.on('update', this._handleDocUpdate.bind(this));
|
|
41
42
|
this._awareness.on('update', this._handleAwarenessUpdate.bind(this));
|
|
@@ -55,10 +56,7 @@ export class AwarenessProvider extends Observable<any> {
|
|
|
55
56
|
// Post local awareness state.
|
|
56
57
|
const encoderAwarenessState = encoding.createEncoder();
|
|
57
58
|
encoding.writeVarUint(encoderAwarenessState, messageAwareness);
|
|
58
|
-
encoding.writeVarUint8Array(
|
|
59
|
-
encoderAwarenessState,
|
|
60
|
-
awarenessProtocol.encodeAwarenessUpdate(this.awareness, [this._doc.clientID]),
|
|
61
|
-
);
|
|
59
|
+
encoding.writeVarUint8Array(encoderAwarenessState, YP.encodeAwarenessUpdate(this.awareness, [this._doc.clientID]));
|
|
62
60
|
void this._remoteUpdate.emit(encoding.toUint8Array(encoderAwarenessState));
|
|
63
61
|
}
|
|
64
62
|
|
|
@@ -79,10 +77,7 @@ export class AwarenessProvider extends Observable<any> {
|
|
|
79
77
|
const changedClients = added.concat(updated).concat(removed);
|
|
80
78
|
const encoderAwareness = encoding.createEncoder();
|
|
81
79
|
encoding.writeVarUint(encoderAwareness, messageAwareness);
|
|
82
|
-
encoding.writeVarUint8Array(
|
|
83
|
-
encoderAwareness,
|
|
84
|
-
awarenessProtocol.encodeAwarenessUpdate(this._awareness, changedClients),
|
|
85
|
-
);
|
|
80
|
+
encoding.writeVarUint8Array(encoderAwareness, YP.encodeAwarenessUpdate(this._awareness, changedClients));
|
|
86
81
|
this._remoteUpdate.emit(encoding.toUint8Array(encoderAwareness));
|
|
87
82
|
}
|
|
88
83
|
|
|
@@ -109,7 +104,7 @@ export class AwarenessProvider extends Observable<any> {
|
|
|
109
104
|
}
|
|
110
105
|
|
|
111
106
|
case messageAwareness: {
|
|
112
|
-
|
|
107
|
+
YP.applyAwarenessUpdate(this._awareness, decoding.readVarUint8Array(decoder), this);
|
|
113
108
|
break;
|
|
114
109
|
}
|
|
115
110
|
|
|
@@ -117,7 +112,7 @@ export class AwarenessProvider extends Observable<any> {
|
|
|
117
112
|
encoding.writeVarUint(encoder, messageAwareness);
|
|
118
113
|
encoding.writeVarUint8Array(
|
|
119
114
|
encoder,
|
|
120
|
-
|
|
115
|
+
YP.encodeAwarenessUpdate(this._awareness, Array.from(this._awareness.getStates().keys())),
|
|
121
116
|
);
|
|
122
117
|
sendReply = true;
|
|
123
118
|
break;
|
|
@@ -138,7 +133,7 @@ export class AwarenessProvider extends Observable<any> {
|
|
|
138
133
|
}
|
|
139
134
|
|
|
140
135
|
private _handleBeforeUnload() {
|
|
141
|
-
|
|
136
|
+
YP.removeAwarenessStates(this._awareness, [this._doc.clientID], 'window unload');
|
|
142
137
|
}
|
|
143
138
|
}
|
|
144
139
|
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import get from 'lodash.get';
|
|
6
6
|
|
|
7
|
-
import { type ThemeStyles, tokens } from '
|
|
7
|
+
import { type ThemeStyles, tokens } from '../styles';
|
|
8
8
|
|
|
9
|
-
// TODO(burdon): Can we
|
|
10
|
-
//
|
|
9
|
+
// TODO(burdon): Can we use @apply and import css file?
|
|
10
|
+
// https://tailwindcss.com/docs/reusing-styles#extracting-classes-with-apply?
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Minimal styles.
|
|
@@ -49,12 +49,12 @@ export const defaultTheme: ThemeStyles = {
|
|
|
49
49
|
'&.cm-focused': {
|
|
50
50
|
outline: 'none',
|
|
51
51
|
},
|
|
52
|
-
'
|
|
52
|
+
'.cm-scroller': {
|
|
53
53
|
overflow: 'visible',
|
|
54
54
|
fontFamily: get(tokens, 'fontFamily.mono', []).join(','),
|
|
55
55
|
},
|
|
56
56
|
|
|
57
|
-
'
|
|
57
|
+
'.cm-content': {
|
|
58
58
|
padding: 0,
|
|
59
59
|
// NOTE: Base font size (otherwise defined by HTML tag, which might be different for storybook).
|
|
60
60
|
fontSize: '16px',
|
|
@@ -77,17 +77,19 @@ export const defaultTheme: ThemeStyles = {
|
|
|
77
77
|
'&dark .cm-cursor, &dark .cm-dropCursor': {
|
|
78
78
|
borderLeft: '2px solid white',
|
|
79
79
|
},
|
|
80
|
-
'
|
|
80
|
+
'.cm-placeholder': {
|
|
81
81
|
fontWeight: 100,
|
|
82
82
|
},
|
|
83
83
|
|
|
84
84
|
//
|
|
85
85
|
// line
|
|
86
86
|
//
|
|
87
|
-
'
|
|
87
|
+
'.cm-line': {
|
|
88
88
|
paddingInline: 0,
|
|
89
|
+
// TODO(burdon): Other values leave gaps between lines when highlighted.
|
|
90
|
+
// lineHeight: 'normal',
|
|
89
91
|
},
|
|
90
|
-
'
|
|
92
|
+
'.cm-activeLine': {
|
|
91
93
|
background: 'inherit',
|
|
92
94
|
},
|
|
93
95
|
|
|
@@ -119,40 +121,10 @@ export const defaultTheme: ThemeStyles = {
|
|
|
119
121
|
backgroundColor: get(tokens, 'extend.colors.yellow.700'),
|
|
120
122
|
},
|
|
121
123
|
|
|
122
|
-
//
|
|
123
|
-
// collaboration
|
|
124
|
-
// TODO(burdon): Review classnames (YJS dependent?) Note: e2e tests depend on this class.
|
|
125
|
-
//
|
|
126
|
-
|
|
127
|
-
'&light .cm-ySelection, &light .cm-yLineSelection': {
|
|
128
|
-
mixBlendMode: 'multiply',
|
|
129
|
-
},
|
|
130
|
-
'&dark .cm-ySelection, &dark .cm-yLineSelection': {
|
|
131
|
-
mixBlendMode: 'screen',
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
'& .cm-ySelectionInfo': {
|
|
135
|
-
padding: '2px 4px',
|
|
136
|
-
marginBlockStart: '-4px',
|
|
137
|
-
},
|
|
138
|
-
'& .cm-ySelection, & .cm-selectionMatch': {
|
|
139
|
-
paddingBlockStart: '.15em',
|
|
140
|
-
paddingBlockEnd: '.15em',
|
|
141
|
-
},
|
|
142
|
-
'& .cm-ySelectionCaret': {
|
|
143
|
-
display: 'inline-block',
|
|
144
|
-
insetBlockStart: '.1em',
|
|
145
|
-
blockSize: '1.4em',
|
|
146
|
-
verticalAlign: 'top',
|
|
147
|
-
},
|
|
148
|
-
'& .cm-yLineSelection': {
|
|
149
|
-
margin: 0,
|
|
150
|
-
},
|
|
151
|
-
|
|
152
124
|
//
|
|
153
125
|
// link
|
|
154
126
|
//
|
|
155
|
-
'
|
|
127
|
+
'.cm-link': {
|
|
156
128
|
color: get(tokens, 'extend.colors.primary.500'),
|
|
157
129
|
textDecorationLine: 'underline',
|
|
158
130
|
textDecorationThickness: '1px',
|
|
@@ -164,34 +136,34 @@ export const defaultTheme: ThemeStyles = {
|
|
|
164
136
|
//
|
|
165
137
|
// tooltip
|
|
166
138
|
//
|
|
167
|
-
'
|
|
139
|
+
'.cm-tooltip': {
|
|
168
140
|
border: 'none',
|
|
169
141
|
},
|
|
170
|
-
'
|
|
142
|
+
'.cm-tooltip-below': {},
|
|
171
143
|
|
|
172
144
|
//
|
|
173
145
|
// autocomplete
|
|
174
146
|
//
|
|
175
|
-
'
|
|
147
|
+
'.cm-tooltip-autocomplete': {
|
|
176
148
|
marginTop: '4px',
|
|
177
149
|
marginLeft: '-3px',
|
|
178
150
|
},
|
|
179
|
-
'
|
|
180
|
-
'
|
|
181
|
-
'
|
|
151
|
+
'.cm-tooltip-autocomplete ul li': {},
|
|
152
|
+
'.cm-tooltip-autocomplete ul li[aria-selected]': {},
|
|
153
|
+
'.cm-completionIcon': {
|
|
182
154
|
display: 'none',
|
|
183
155
|
},
|
|
184
|
-
'
|
|
156
|
+
'.cm-completionLabel': {
|
|
185
157
|
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
186
158
|
},
|
|
187
|
-
'
|
|
159
|
+
'.cm-completionMatchedText': {
|
|
188
160
|
textDecoration: 'none',
|
|
189
161
|
},
|
|
190
162
|
|
|
191
163
|
//
|
|
192
164
|
// widgets
|
|
193
165
|
//
|
|
194
|
-
'
|
|
166
|
+
'.cm-widgetBuffer': {
|
|
195
167
|
display: 'none',
|
|
196
168
|
height: 0,
|
|
197
169
|
},
|
|
@@ -199,40 +171,47 @@ export const defaultTheme: ThemeStyles = {
|
|
|
199
171
|
//
|
|
200
172
|
// table
|
|
201
173
|
//
|
|
202
|
-
'
|
|
174
|
+
'.cm-table *': {
|
|
203
175
|
fontFamily: `${get(tokens, 'fontFamily.mono', []).join(',')} !important`,
|
|
204
176
|
textDecoration: 'none !important',
|
|
205
177
|
},
|
|
206
|
-
'
|
|
178
|
+
'.cm-table-head': {
|
|
207
179
|
padding: '2px 16px 2px 0px',
|
|
208
180
|
borderBottom: `1px solid ${get(tokens, 'extend.colors.neutral.500')}`,
|
|
209
181
|
fontWeight: 100,
|
|
210
182
|
textAlign: 'left',
|
|
211
183
|
color: get(tokens, 'extend.colors.neutral.500'),
|
|
212
184
|
},
|
|
213
|
-
'
|
|
185
|
+
'.cm-table-cell': {
|
|
214
186
|
padding: '2px 16px 2px 0px',
|
|
215
187
|
},
|
|
216
188
|
|
|
217
189
|
//
|
|
218
190
|
// image
|
|
219
191
|
//
|
|
220
|
-
'
|
|
221
|
-
|
|
192
|
+
'.cm-image': {
|
|
193
|
+
display: 'block',
|
|
194
|
+
height: '0',
|
|
195
|
+
},
|
|
196
|
+
'.cm-image.cm-loaded-image': {
|
|
197
|
+
height: 'auto',
|
|
198
|
+
borderTop: '0.5rem solid transparent',
|
|
199
|
+
borderBottom: '0.5rem solid transparent',
|
|
222
200
|
},
|
|
223
201
|
|
|
224
202
|
//
|
|
225
203
|
// font size
|
|
226
|
-
// TODO(thure): This appears to be the best or only way to set selection caret heights,
|
|
204
|
+
// TODO(thure): This appears to be the best or only way to set selection caret heights,
|
|
205
|
+
// but it's far more verbose than it needs to be.
|
|
227
206
|
//
|
|
228
|
-
...Object.keys(get(tokens, 'extend.fontSize', {})).reduce((acc: Record<string, any>, fontSize) => {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}, {}),
|
|
207
|
+
// ...Object.keys(get(tokens, 'extend.fontSize', {})).reduce((acc: Record<string, any>, fontSize) => {
|
|
208
|
+
// const height = get(tokens, ['extend', 'fontSize', fontSize, 1, 'lineHeight']);
|
|
209
|
+
//
|
|
210
|
+
// acc[`& .text-${fontSize} + .cm-ySelectionCaret`] = { height };
|
|
211
|
+
// acc[`& .text-${fontSize} + .cm-ySelection + .cm-ySelectionCaret`] = { height };
|
|
212
|
+
// acc[`& .text-${fontSize} + .cm-widgetBuffer + .cm-ySelectionCaret`] = { height };
|
|
213
|
+
// return acc;
|
|
214
|
+
// }, {}),
|
|
236
215
|
|
|
237
216
|
/**
|
|
238
217
|
* Panels
|
|
@@ -250,14 +229,14 @@ export const defaultTheme: ThemeStyles = {
|
|
|
250
229
|
* </div>
|
|
251
230
|
* </div
|
|
252
231
|
*/
|
|
253
|
-
'
|
|
232
|
+
'.cm-panels': {
|
|
254
233
|
border: `1px solid ${get(tokens, 'extend.colors.neutral.200')}`,
|
|
255
234
|
},
|
|
256
|
-
'
|
|
235
|
+
'.cm-panel': {
|
|
257
236
|
background: get(tokens, 'extend.colors.neutral.50'),
|
|
258
237
|
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
259
238
|
},
|
|
260
|
-
'
|
|
239
|
+
'.cm-button': {
|
|
261
240
|
margin: '4px',
|
|
262
241
|
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
263
242
|
background: get(tokens, 'extend.colors.neutral.100'),
|
|
@@ -271,32 +250,34 @@ export const defaultTheme: ThemeStyles = {
|
|
|
271
250
|
backgroundImage: 'none',
|
|
272
251
|
},
|
|
273
252
|
},
|
|
274
|
-
'
|
|
253
|
+
'.cm-panel input[type=checkbox]': {
|
|
275
254
|
marginRight: '0.4rem !important',
|
|
276
255
|
},
|
|
277
256
|
};
|
|
278
257
|
|
|
279
258
|
export const textTheme: ThemeStyles = {
|
|
280
|
-
'
|
|
259
|
+
'.cm-scroller': {
|
|
281
260
|
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
282
261
|
},
|
|
283
|
-
'
|
|
262
|
+
'.cm-placeholder': {
|
|
284
263
|
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
285
264
|
},
|
|
286
265
|
};
|
|
287
266
|
|
|
288
267
|
export const markdownTheme: ThemeStyles = {
|
|
289
|
-
|
|
290
|
-
|
|
268
|
+
'.cm-scroller': {
|
|
269
|
+
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
270
|
+
},
|
|
271
|
+
'.cm-placeholder': {
|
|
291
272
|
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
292
273
|
},
|
|
293
274
|
};
|
|
294
275
|
|
|
295
276
|
export const codeTheme: ThemeStyles = {
|
|
296
|
-
'
|
|
277
|
+
'.cm-scroller': {
|
|
297
278
|
fontFamily: get(tokens, 'fontFamily.mono', []).join(','),
|
|
298
279
|
},
|
|
299
|
-
'
|
|
280
|
+
'.cm-placeholder': {
|
|
300
281
|
fontFamily: get(tokens, 'fontFamily.mono', []).join(','),
|
|
301
282
|
},
|
|
302
283
|
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/autocomplete.ts"],"names":[],"mappings":"AAQA,OAAO,EAGL,KAAK,UAAU,EAGhB,MAAM,0BAA0B,CAAC;AAGlC,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAE5C,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,UAAU,EAAE,CAAC;CAC1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,iBAAkB,mBAAmB,4CAgC7D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"basic.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/basic.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAInD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,WAAW,uDAAwD,kBAAkB,KAAG,SAAS,EAa5E,CAAC"}
|