@dxos/react-ui-editor 0.3.11-main.1caa3af → 0.3.11-main.1d8382a
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 +1492 -989
- 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 +8 -12
- package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +5 -2
- 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/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 +4 -2
- package/dist/types/src/extensions/comments.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 +3 -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 +10 -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 +9 -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/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/cursor.d.ts +17 -0
- package/dist/types/src/util/cursor.d.ts.map +1 -0
- package/dist/types/src/util/index.d.ts +3 -0
- package/dist/types/src/util/index.d.ts.map +1 -0
- package/dist/types/src/util/util.d.ts.map +1 -0
- package/package.json +22 -21
- package/src/components/TextEditor/MarkdownEditor.stories.tsx +24 -24
- package/src/components/TextEditor/TextEditor.stories.tsx +17 -5
- package/src/components/TextEditor/TextEditor.tsx +57 -51
- package/src/{hooks/automerge → components/TextEditor}/automerge.stories.tsx +66 -6
- package/src/components/TextEditor/codemirror.stories.ts +3 -2
- 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 +51 -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 +316 -0
- package/src/{components/TextEditor/extensions → extensions}/code.ts +4 -5
- package/src/{components/TextEditor/extensions → extensions}/comments.ts +51 -19
- package/src/{components/TextEditor/extensions → extensions}/hr.ts +2 -3
- package/src/extensions/image.ts +87 -0
- package/src/{components/TextEditor/extensions → extensions}/index.ts +3 -2
- package/src/{components/TextEditor/extensions → extensions}/link.ts +112 -58
- package/src/extensions/listener.ts +35 -0
- package/src/{components/TextEditor/extensions → extensions}/markdown/highlight.ts +4 -5
- package/src/{components/TextEditor/extensions → extensions}/table.ts +9 -3
- package/src/{components/TextEditor/extensions → extensions}/tasklist.ts +1 -3
- package/src/{components/TextEditor/extensions → extensions}/typewriter.ts +1 -1
- package/src/extensions/yjs/cursor.ts +21 -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 +21 -94
- package/src/hooks/{yjs/space-provider.ts → yjs.ts} +71 -19
- package/src/index.ts +5 -0
- package/src/styles/index.ts +1 -0
- package/src/styles/tokens.ts +3 -0
- package/src/testing/replicator.ts +10 -15
- package/src/{components/TextEditor/themes → themes}/default.ts +40 -34
- package/src/util/cursor.ts +29 -0
- package/src/util/index.ts +6 -0
- 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 +0 -9
- 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 -23
- 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}/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}/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}/util.ts +0 -0
|
@@ -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,7 +4,7 @@
|
|
|
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
9
|
// TODO(burdon): Can we erase All of the default CM styles?
|
|
10
10
|
// TODO(burdon): Theme styles seem to be added multiple times?
|
|
@@ -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,17 @@ 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
89
|
},
|
|
90
|
-
'
|
|
90
|
+
'.cm-activeLine': {
|
|
91
91
|
background: 'inherit',
|
|
92
92
|
},
|
|
93
93
|
|
|
@@ -131,28 +131,28 @@ export const defaultTheme: ThemeStyles = {
|
|
|
131
131
|
mixBlendMode: 'screen',
|
|
132
132
|
},
|
|
133
133
|
|
|
134
|
-
'
|
|
134
|
+
'.cm-ySelectionInfo': {
|
|
135
135
|
padding: '2px 4px',
|
|
136
136
|
marginBlockStart: '-4px',
|
|
137
137
|
},
|
|
138
|
-
'
|
|
138
|
+
'.cm-ySelection, & .cm-selectionMatch': {
|
|
139
139
|
paddingBlockStart: '.15em',
|
|
140
140
|
paddingBlockEnd: '.15em',
|
|
141
141
|
},
|
|
142
|
-
'
|
|
142
|
+
'.cm-ySelectionCaret': {
|
|
143
143
|
display: 'inline-block',
|
|
144
144
|
insetBlockStart: '.1em',
|
|
145
145
|
blockSize: '1.4em',
|
|
146
146
|
verticalAlign: 'top',
|
|
147
147
|
},
|
|
148
|
-
'
|
|
148
|
+
'.cm-yLineSelection': {
|
|
149
149
|
margin: 0,
|
|
150
150
|
},
|
|
151
151
|
|
|
152
152
|
//
|
|
153
153
|
// link
|
|
154
154
|
//
|
|
155
|
-
'
|
|
155
|
+
'.cm-link': {
|
|
156
156
|
color: get(tokens, 'extend.colors.primary.500'),
|
|
157
157
|
textDecorationLine: 'underline',
|
|
158
158
|
textDecorationThickness: '1px',
|
|
@@ -164,34 +164,34 @@ export const defaultTheme: ThemeStyles = {
|
|
|
164
164
|
//
|
|
165
165
|
// tooltip
|
|
166
166
|
//
|
|
167
|
-
'
|
|
167
|
+
'.cm-tooltip': {
|
|
168
168
|
border: 'none',
|
|
169
169
|
},
|
|
170
|
-
'
|
|
170
|
+
'.cm-tooltip-below': {},
|
|
171
171
|
|
|
172
172
|
//
|
|
173
173
|
// autocomplete
|
|
174
174
|
//
|
|
175
|
-
'
|
|
175
|
+
'.cm-tooltip-autocomplete': {
|
|
176
176
|
marginTop: '4px',
|
|
177
177
|
marginLeft: '-3px',
|
|
178
178
|
},
|
|
179
|
-
'
|
|
180
|
-
'
|
|
181
|
-
'
|
|
179
|
+
'.cm-tooltip-autocomplete ul li': {},
|
|
180
|
+
'.cm-tooltip-autocomplete ul li[aria-selected]': {},
|
|
181
|
+
'.cm-completionIcon': {
|
|
182
182
|
display: 'none',
|
|
183
183
|
},
|
|
184
|
-
'
|
|
184
|
+
'.cm-completionLabel': {
|
|
185
185
|
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
186
186
|
},
|
|
187
|
-
'
|
|
187
|
+
'.cm-completionMatchedText': {
|
|
188
188
|
textDecoration: 'none',
|
|
189
189
|
},
|
|
190
190
|
|
|
191
191
|
//
|
|
192
192
|
// widgets
|
|
193
193
|
//
|
|
194
|
-
'
|
|
194
|
+
'.cm-widgetBuffer': {
|
|
195
195
|
display: 'none',
|
|
196
196
|
height: 0,
|
|
197
197
|
},
|
|
@@ -199,26 +199,32 @@ export const defaultTheme: ThemeStyles = {
|
|
|
199
199
|
//
|
|
200
200
|
// table
|
|
201
201
|
//
|
|
202
|
-
'
|
|
202
|
+
'.cm-table *': {
|
|
203
203
|
fontFamily: `${get(tokens, 'fontFamily.mono', []).join(',')} !important`,
|
|
204
204
|
textDecoration: 'none !important',
|
|
205
205
|
},
|
|
206
|
-
'
|
|
206
|
+
'.cm-table-head': {
|
|
207
207
|
padding: '2px 16px 2px 0px',
|
|
208
208
|
borderBottom: `1px solid ${get(tokens, 'extend.colors.neutral.500')}`,
|
|
209
209
|
fontWeight: 100,
|
|
210
210
|
textAlign: 'left',
|
|
211
211
|
color: get(tokens, 'extend.colors.neutral.500'),
|
|
212
212
|
},
|
|
213
|
-
'
|
|
213
|
+
'.cm-table-cell': {
|
|
214
214
|
padding: '2px 16px 2px 0px',
|
|
215
215
|
},
|
|
216
216
|
|
|
217
217
|
//
|
|
218
218
|
// image
|
|
219
219
|
//
|
|
220
|
-
'
|
|
221
|
-
|
|
220
|
+
'.cm-image': {
|
|
221
|
+
display: 'block',
|
|
222
|
+
height: '0',
|
|
223
|
+
},
|
|
224
|
+
'.cm-image.cm-loaded-image': {
|
|
225
|
+
height: 'auto',
|
|
226
|
+
borderTop: '0.5rem solid transparent',
|
|
227
|
+
borderBottom: '0.5rem solid transparent',
|
|
222
228
|
},
|
|
223
229
|
|
|
224
230
|
//
|
|
@@ -250,14 +256,14 @@ export const defaultTheme: ThemeStyles = {
|
|
|
250
256
|
* </div>
|
|
251
257
|
* </div
|
|
252
258
|
*/
|
|
253
|
-
'
|
|
259
|
+
'.cm-panels': {
|
|
254
260
|
border: `1px solid ${get(tokens, 'extend.colors.neutral.200')}`,
|
|
255
261
|
},
|
|
256
|
-
'
|
|
262
|
+
'.cm-panel': {
|
|
257
263
|
background: get(tokens, 'extend.colors.neutral.50'),
|
|
258
264
|
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
259
265
|
},
|
|
260
|
-
'
|
|
266
|
+
'.cm-button': {
|
|
261
267
|
margin: '4px',
|
|
262
268
|
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
263
269
|
background: get(tokens, 'extend.colors.neutral.100'),
|
|
@@ -271,32 +277,32 @@ export const defaultTheme: ThemeStyles = {
|
|
|
271
277
|
backgroundImage: 'none',
|
|
272
278
|
},
|
|
273
279
|
},
|
|
274
|
-
'
|
|
280
|
+
'.cm-panel input[type=checkbox]': {
|
|
275
281
|
marginRight: '0.4rem !important',
|
|
276
282
|
},
|
|
277
283
|
};
|
|
278
284
|
|
|
279
285
|
export const textTheme: ThemeStyles = {
|
|
280
|
-
'
|
|
286
|
+
'.cm-scroller': {
|
|
281
287
|
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
282
288
|
},
|
|
283
|
-
'
|
|
289
|
+
'.cm-placeholder': {
|
|
284
290
|
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
285
291
|
},
|
|
286
292
|
};
|
|
287
293
|
|
|
288
294
|
export const markdownTheme: ThemeStyles = {
|
|
289
295
|
// NOTE: Must leave base font family as is (i.e., monospace) due to fenced code blocks.
|
|
290
|
-
'
|
|
296
|
+
'.cm-placeholder': {
|
|
291
297
|
fontFamily: get(tokens, 'fontFamily.body', []).join(','),
|
|
292
298
|
},
|
|
293
299
|
};
|
|
294
300
|
|
|
295
301
|
export const codeTheme: ThemeStyles = {
|
|
296
|
-
'
|
|
302
|
+
'.cm-scroller': {
|
|
297
303
|
fontFamily: get(tokens, 'fontFamily.mono', []).join(','),
|
|
298
304
|
},
|
|
299
|
-
'
|
|
305
|
+
'.cm-placeholder': {
|
|
300
306
|
fontFamily: get(tokens, 'fontFamily.mono', []).join(','),
|
|
301
307
|
},
|
|
302
308
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Facet } from '@codemirror/state';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Converts indexes into the text document into stable peer-independent cursors.
|
|
9
|
+
*
|
|
10
|
+
* See:
|
|
11
|
+
* - https://automerge.org/automerge/api-docs/js/functions/next.getCursor.html
|
|
12
|
+
* - https://github.com/yjs/yjs?tab=readme-ov-file#relative-positions
|
|
13
|
+
*
|
|
14
|
+
* @param {assoc} number Negative values will associate the cursor with the previous character
|
|
15
|
+
* while positive - with the next one.
|
|
16
|
+
*/
|
|
17
|
+
export interface CursorConverter {
|
|
18
|
+
toCursor(position: number, assoc?: -1 | 1 | undefined): string;
|
|
19
|
+
fromCursor(cursor: string): number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const DEFAULT_CURSOR_CONVERTER: CursorConverter = {
|
|
23
|
+
toCursor: (position) => position.toString(),
|
|
24
|
+
fromCursor: (cursor) => parseInt(cursor),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const CursorConverter = Facet.define<CursorConverter, CursorConverter>({
|
|
28
|
+
combine: (providers) => providers[0] ?? DEFAULT_CURSOR_CONVERTER,
|
|
29
|
+
});
|
|
@@ -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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"blast.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/blast.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAMnD,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,YAAY,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,gBAAgB,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,qBAAqB,EAAE;QAAE,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;IACpE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,MAAM,EAAE,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,YAU5B,CAAC;AAEF,eAAO,MAAM,KAAK,aAAa,QAAQ,YAAY,CAAC,KAAoB,SAmEvE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/code.ts"],"names":[],"mappings":"AAuDA,eAAO,MAAM,IAAI,+CA2ChB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/comments.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAA2B,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAWL,KAAK,IAAI,EACV,MAAM,kBAAkB,CAAC;AAS1B,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAc,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AA8B7F,KAAK,eAAe,GAAG;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAGF,KAAK,oBAAoB,GAAG,KAAK,GAC/B,YAAY,GAAG;IAEb,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACxB,CAAC;AAEJ,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG;IAC5C,MAAM,EAAE,oBAAoB,EAAE,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,eAAe;WAA+B,WAAW;cAAY,YAAY,EAAE;EAAK,CAAC;AA+FtG,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACjD;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC1C;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,IAAI,CAAC;CACjC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ,aAAa,eAAe,KAAQ,SA+LxD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hr.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/hr.ts"],"names":[],"mappings":"AAmDA,eAAO,MAAM,EAAE,+CAsBd,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/image.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,mBAAmB,CAAC;AAG3B,MAAM,MAAM,YAAY,GAAG,EAAE,CAAC;AAE9B,eAAO,MAAM,KAAK,aAAa,YAAY,KAAQ,SAMlD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/link.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,mBAAmB,CAAC;AAO3B,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,IAAI,aAAa,WAAW,KAAQ,SAMhD,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { StateField } from '@codemirror/state';
|
|
2
|
-
export type ListenerOptions = {
|
|
3
|
-
onChange: (text: string) => void;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* Based on https://github.com/codemirror/dev/issues/44#issuecomment-789093799
|
|
7
|
-
*/
|
|
8
|
-
export declare const listener: ({ onChange }: ListenerOptions) => StateField<null>;
|
|
9
|
-
//# sourceMappingURL=listener.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/listener.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,MAAM,eAAe,GAAG;IAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,CAAC;AAEnE;;GAEG;AACH,eAAO,MAAM,QAAQ,iBAAkB,eAAe,qBAWrD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/TextEditor/extensions/markdown/bundle.ts"],"names":[],"mappings":"AAUA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAYhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;GAOG;AAEH,eAAO,MAAM,cAAc,wDAIxB,qBAAqB,KAAG,SAAS,EA6CnC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/TextEditor/extensions/markdown/highlight.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAmB,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,KAAK,cAAc,EAAS,MAAM,iBAAiB,CAAC;AAgB7D;;;;GAIG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;CAgBxB,CAAC;AAaF,eAAO,MAAM,sBAAsB,EAAE,cAAc,EAKlD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,cAAe,OAAO,mBAgIxD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/TextEditor/extensions/markdown/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mention.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/mention.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;CACtC,CAAC;AAEF,eAAO,MAAM,OAAO,iBAAkB,cAAc,KAAG,SAmBtD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mermaid.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/mermaid.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAInD,eAAO,MAAM,OAAO,QAAO,SAE1B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/table.ts"],"names":[],"mappings":"AAKA,OAAO,EAAoB,KAAK,QAAQ,EAAmB,UAAU,EAAoB,MAAM,mBAAmB,CAAC;AASnH,MAAM,MAAM,YAAY,GAAG,EAAE,CAAC;AAE9B;;;GAGG;AACH,eAAO,MAAM,KAAK,aAAa,YAAY,8BAM1C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tasklist.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/tasklist.ts"],"names":[],"mappings":"AA+DA,MAAM,MAAM,eAAe,GAAG,EAAE,CAAC;AAEjC,eAAO,MAAM,QAAQ,aAAa,eAAe,4CAuDhD,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type Extension } from '@codemirror/state';
|
|
2
|
-
export type TooltipOptions = {
|
|
3
|
-
onHover: (el: Element, url: string) => void;
|
|
4
|
-
regexp?: RegExp;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* https://codemirror.net/examples/tooltip
|
|
8
|
-
* https://codemirror.net/docs/ref/#view.hoverTooltip
|
|
9
|
-
* https://github.com/codemirror/view/blob/main/src/tooltip.ts
|
|
10
|
-
*/
|
|
11
|
-
export declare const tooltip: ({ onHover, regexp }: TooltipOptions) => Extension;
|
|
12
|
-
//# sourceMappingURL=tooltip.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/tooltip.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAOnD,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,OAAO,wBAA8C,cAAc,KAAG,SAuC/E,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typewriter.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/typewriter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKnD,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAIF;;GAEG;AACH,eAAO,MAAM,UAAU,sBAA0C,WAAW,KAAQ,SAgDnF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/util.ts"],"names":[],"mappings":"AAMA;;GAEG;AAEH,eAAO,MAAM,eAAe,kCAOR,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/themes/default.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,WAAW,EAAU,MAAM,iBAAiB,CAAC;AAK3D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,EAAE,WA8P1B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,WAOvB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,WAK3B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,WAOvB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/themes/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"automerge.stories.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/automerge.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,uBAAuB,CAAC;AAQ/B,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAGtD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAG3C,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,IAAI,EAAE,CAAC;CACd,CAAC;;;;;;AA+DF,wBAIE;AAEF,eAAO,MAAM,OAAO,IAAK,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type * as A from '@dxos/automerge/automerge';
|
|
2
|
-
export type IDocHandle<T = any> = {
|
|
3
|
-
docSync(): A.Doc<T> | undefined;
|
|
4
|
-
change(callback: A.ChangeFn<T>, options?: A.ChangeOptions<T>): void;
|
|
5
|
-
changeAt(heads: A.Heads, callback: A.ChangeFn<T>, options?: A.ChangeOptions<T>): string[] | undefined;
|
|
6
|
-
addListener(event: 'change', listener: () => void): void;
|
|
7
|
-
removeListener(event: 'change', listener: () => void): void;
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=handle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/handle.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,CAAC,MAAM,2BAA2B,CAAC;AAEpD,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,GAAG,IAAI;IAChC,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAChC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACpE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IAEtG,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IACzD,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CAC7D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type EditorState, type Extension, StateEffect, StateField, type Transaction, type TransactionSpec } from '@codemirror/state';
|
|
2
|
-
import * as automerge from '@dxos/automerge/automerge';
|
|
3
|
-
import { type Heads, type Prop } from '@dxos/automerge/automerge';
|
|
4
|
-
import { type IDocHandle } from './handle';
|
|
5
|
-
export type Value = {
|
|
6
|
-
lastHeads: Heads;
|
|
7
|
-
path: Prop[];
|
|
8
|
-
unreconciledTransactions: Transaction[];
|
|
9
|
-
};
|
|
10
|
-
type UpdateHeads = {
|
|
11
|
-
newHeads: Heads;
|
|
12
|
-
};
|
|
13
|
-
export declare const effectType: import("@codemirror/state").StateEffectType<UpdateHeads>;
|
|
14
|
-
export declare const updateHeads: (newHeads: automerge.next.Heads) => StateEffect<UpdateHeads>;
|
|
15
|
-
export declare const getLastHeads: (state: EditorState, field: Field) => automerge.next.Heads;
|
|
16
|
-
export declare const getPath: (state: EditorState, field: Field) => Prop[];
|
|
17
|
-
export type Field = StateField<Value>;
|
|
18
|
-
export type AutomergePlugin = {
|
|
19
|
-
extension: Extension;
|
|
20
|
-
};
|
|
21
|
-
export declare const automergePlugin: (handle: IDocHandle, path: Prop[]) => AutomergePlugin;
|
|
22
|
-
export declare const reconcileAnnotationType: import("@codemirror/state").AnnotationType<unknown>;
|
|
23
|
-
export declare const isReconcileTx: (tr: Transaction) => boolean;
|
|
24
|
-
export declare const makeReconcile: (tr: TransactionSpec) => void;
|
|
25
|
-
export {};
|
|
26
|
-
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,SAAS,EAEd,WAAW,EACX,UAAU,EACV,KAAK,WAAW,EAChB,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAG3C,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,KAAK,CAAC;IACjB,IAAI,EAAE,IAAI,EAAE,CAAC;IACb,wBAAwB,EAAE,WAAW,EAAE,CAAC;CACzC,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,KAAK,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,UAAU,0DAAsC,CAAC;AAE9D,eAAO,MAAM,WAAW,sCAAsB,YAAY,WAAW,CAAgC,CAAC;AAEtG,eAAO,MAAM,YAAY,UAAW,WAAW,uCAAsD,CAAC;AAEtG,eAAO,MAAM,OAAO,UAAW,WAAW,mBAAiB,IAAI,EAA6B,CAAC;AAE7F,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;AAMtC,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,eAAe,WAAY,UAAU,QAAQ,IAAI,EAAE,KAAG,eA+DlE,CAAC;AAEF,eAAO,MAAM,uBAAuB,qDAA+B,CAAC;AAEpE,eAAO,MAAM,aAAa,OAAQ,WAAW,KAAG,OAAmD,CAAC;AAEpG,eAAO,MAAM,aAAa,OAAQ,eAAe,SAchD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"semaphore.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/semaphore.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,KAAK,KAAK,EAA8E,MAAM,UAAU,CAAC;AAIlH,KAAK,GAAG,CAAC,CAAC,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC/B,KAAK,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;AAE7B,KAAK,QAAQ,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,KAAK,KAAK,GAAG,SAAS,CAAC;AAE3F;;GAEG;AACH,qBAAa,cAAc;IACzB,MAAM,EAAG,KAAK,CAAC;IACf,YAAY,UAAS;IACrB,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAM;gBAEjB,KAAK,CAAC,EAAE,KAAK;IAMzB,SAAS,WAAY,UAAU,QAAQ,UAAU,UA0C/C;CACH"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type EditorState, type Transaction } from '@codemirror/state';
|
|
2
|
-
import { type Heads } from '@dxos/automerge/automerge';
|
|
3
|
-
import { type IDocHandle } from './handle';
|
|
4
|
-
import { type Field } from './plugin';
|
|
5
|
-
export declare const updateAutomerge: (field: Field, handle: IDocHandle, transactions: Transaction[], state: EditorState) => Heads | undefined;
|
|
6
|
-
//# sourceMappingURL=update-automerge.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update-automerge.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/update-automerge.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,WAAW,EAAa,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAElF,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC,eAAO,MAAM,eAAe,yBAElB,UAAU,gBACJ,WAAW,EAAE,SACpB,WAAW,KACjB,KAAK,GAAG,SAyBV,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update-codemirror.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/update-codemirror.ts"],"names":[],"mappings":"AAMA,OAAO,EAA8B,KAAK,eAAe,EAAoB,MAAM,mBAAmB,CAAC;AACvG,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAGL,KAAK,KAAK,EACV,KAAK,IAAI,EAGV,MAAM,2BAA2B,CAAC;AAInC,eAAO,MAAM,gBAAgB,SAAU,UAAU,aAAa,eAAe,UAAU,IAAI,EAAE,WAAW,KAAK,EAAE,SAiB9G,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cursors.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/yjs/cursors.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,WAAW;;;CAAsD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/yjs/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"space-provider.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/yjs/space-provider.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,iBAAiB,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAG/B,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGrD,KAAK,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;AAO7C;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,UAAU,CAAC,GAAG,CAAC;IACzD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IACvC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEtB,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,GAAG,EAAE,GAAG,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,SAAS,CAAA;KAAE;IA+BlH,IAAI,SAAS,IAAI,SAAS,CAEzB;IAED,OAAO,CAAC,sBAAsB;IAY9B,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,YAAY;IAoCpB,OAAO,CAAC,mBAAmB;CAG5B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"yjs.stories.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/yjs/yjs.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAEpB,OAAO,KAAmB,MAAM,OAAO,CAAC;;;;;;AAWxC,wBAIE;AA+BF,eAAO,MAAM,OAAO;;CAGnB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"yjs.test.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/yjs/yjs.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { syntaxTree } from '@codemirror/language';
|
|
6
|
-
import {
|
|
7
|
-
type EditorState,
|
|
8
|
-
type Extension,
|
|
9
|
-
type RangeSet,
|
|
10
|
-
RangeSetBuilder,
|
|
11
|
-
StateField,
|
|
12
|
-
type Transaction,
|
|
13
|
-
} from '@codemirror/state';
|
|
14
|
-
import { Decoration, EditorView, WidgetType } from '@codemirror/view';
|
|
15
|
-
|
|
16
|
-
export type ImageOptions = {};
|
|
17
|
-
|
|
18
|
-
export const image = (options: ImageOptions = {}): Extension => {
|
|
19
|
-
return StateField.define<RangeSet<any>>({
|
|
20
|
-
create: (state) => update(state, options),
|
|
21
|
-
update: (_: RangeSet<any>, tr: Transaction) => update(tr.state, options),
|
|
22
|
-
provide: (field) => EditorView.decorations.from(field),
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const update = (state: EditorState, options: ImageOptions) => {
|
|
27
|
-
const builder = new RangeSetBuilder();
|
|
28
|
-
const cursor = state.selection.main.head;
|
|
29
|
-
|
|
30
|
-
syntaxTree(state).iterate({
|
|
31
|
-
enter: (node) => {
|
|
32
|
-
if (node.name === 'Image') {
|
|
33
|
-
const urlNode = node.node.getChild('URL');
|
|
34
|
-
if (urlNode) {
|
|
35
|
-
const hide = state.readOnly || cursor < node.from || cursor > node.to;
|
|
36
|
-
const url = state.sliceDoc(urlNode.from, urlNode.to);
|
|
37
|
-
builder.add(
|
|
38
|
-
hide ? node.from : node.to,
|
|
39
|
-
node.to,
|
|
40
|
-
Decoration.replace({
|
|
41
|
-
block: true, // Prevent cursor from entering.
|
|
42
|
-
widget: new ImageWidget(url),
|
|
43
|
-
}),
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
return builder.finish();
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
class ImageWidget extends WidgetType {
|
|
54
|
-
constructor(readonly _url: string) {
|
|
55
|
-
super();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// TODO(burdon): Does this need to be unique for each position?
|
|
59
|
-
override eq(other: WidgetType) {
|
|
60
|
-
return this._url === (other as any as ImageWidget)._url;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
toDOM(view: EditorView) {
|
|
64
|
-
const img = document.createElement('img');
|
|
65
|
-
img.setAttribute('src', this._url);
|
|
66
|
-
img.setAttribute('class', 'cm-image');
|
|
67
|
-
return img;
|
|
68
|
-
}
|
|
69
|
-
}
|