@singapore-editor/solid 0.1.1
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/README.md +37 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +238 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @singapore-editor/solid
|
|
2
|
+
|
|
3
|
+
Solid bindings for `@singapore-editor/core`.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @singapore-editor/core @singapore-editor/solid solid-js
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { createEditor } from '@singapore-editor/solid'
|
|
15
|
+
import '@singapore-editor/core/style.css'
|
|
16
|
+
|
|
17
|
+
export function EditorPanel() {
|
|
18
|
+
const controller = createEditor({
|
|
19
|
+
document: {
|
|
20
|
+
documentId: 'example.ts',
|
|
21
|
+
text: 'const value = 1;\n',
|
|
22
|
+
languageId: 'typescript',
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
return <div ref={controller.element} />
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`element` is a ref callback. The binding creates the editor after Solid mounts the component and
|
|
31
|
+
disposes it when the Solid owner is cleaned up. Call `createEditor` inside a component or Solid root.
|
|
32
|
+
|
|
33
|
+
## Exports
|
|
34
|
+
|
|
35
|
+
- `createEditor` creates a Solid-owned editor controller.
|
|
36
|
+
- The controller exposes Solid accessors for editor state, snapshots, text, change metadata, and
|
|
37
|
+
command helpers.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type EditorControlledSelection } from '@singapore-editor/core';
|
|
2
|
+
import { Editor, type EditorChangeHandler, type EditorCommandContext, type EditorCommandId, type EditorDocumentMode, type EditorEditability, type EditorEditInput, type EditorEditOptions, type EditorKeymapOptions, type EditorOpenDocumentOptions, type EditorOptions, type EditorRangeDecoration, type EditorScrollMode, type EditorScrollPosition, type EditorSetSelectionOptions, type EditorSetTextOptions, type EditorState, type EditorSuspiciousCharactersOptions } from '@singapore-editor/core/editor';
|
|
3
|
+
import type { TextReadSnapshot } from '@singapore-editor/core/document';
|
|
4
|
+
import type { EditorSyntaxLanguageId } from '@singapore-editor/core/syntax';
|
|
5
|
+
import type { EditorTheme, HiddenCharactersMode } from '@singapore-editor/core/rendering';
|
|
6
|
+
import type { EditorContributionChange, EditorViewContributionUpdateKind, EditorViewSnapshot } from '@singapore-editor/core/extensions';
|
|
7
|
+
import { type Accessor } from 'solid-js';
|
|
8
|
+
export type SolidEditorReactiveValue<T> = T | Accessor<T>;
|
|
9
|
+
export type SolidEditorDocument = {
|
|
10
|
+
readonly documentId?: string;
|
|
11
|
+
readonly revision?: string | number;
|
|
12
|
+
readonly text: string;
|
|
13
|
+
readonly documentMode?: EditorDocumentMode;
|
|
14
|
+
readonly languageId?: EditorSyntaxLanguageId | null;
|
|
15
|
+
readonly scrollPosition?: EditorScrollPosition;
|
|
16
|
+
};
|
|
17
|
+
export type SolidEditorSelection = EditorControlledSelection;
|
|
18
|
+
export type SolidEditorOptions = Omit<EditorOptions, 'editability' | 'fontFamily' | 'fontSize' | 'gutterLeadingInset' | 'hiddenCharacters' | 'keymap' | 'lineHeight' | 'onChange' | 'rangeDecorations' | 'rowGap' | 'scrollMode' | 'suspiciousCharacters' | 'tabMovesFocus' | 'tabSize' | 'theme' | 'wordWrap'> & {
|
|
19
|
+
readonly document?: SolidEditorReactiveValue<SolidEditorDocument | null | undefined>;
|
|
20
|
+
readonly editability?: SolidEditorReactiveValue<EditorEditability | undefined>;
|
|
21
|
+
readonly fontFamily?: SolidEditorReactiveValue<string | undefined>;
|
|
22
|
+
readonly fontSize?: SolidEditorReactiveValue<number | undefined>;
|
|
23
|
+
readonly gutterLeadingInset?: SolidEditorReactiveValue<number | undefined>;
|
|
24
|
+
readonly theme?: SolidEditorReactiveValue<EditorTheme | null | undefined>;
|
|
25
|
+
readonly hiddenCharacters?: SolidEditorReactiveValue<HiddenCharactersMode | undefined>;
|
|
26
|
+
readonly keymap?: SolidEditorReactiveValue<EditorKeymapOptions | undefined>;
|
|
27
|
+
readonly lineHeight?: SolidEditorReactiveValue<number | undefined>;
|
|
28
|
+
readonly rangeDecorations?: SolidEditorReactiveValue<readonly EditorRangeDecoration[] | undefined>;
|
|
29
|
+
readonly rowGap?: SolidEditorReactiveValue<number | undefined>;
|
|
30
|
+
readonly scrollMode?: SolidEditorReactiveValue<EditorScrollMode | undefined>;
|
|
31
|
+
readonly selection?: SolidEditorReactiveValue<SolidEditorSelection | null | undefined>;
|
|
32
|
+
readonly scrollPosition?: SolidEditorReactiveValue<EditorScrollPosition | null | undefined>;
|
|
33
|
+
readonly suspiciousCharacters?: SolidEditorReactiveValue<EditorSuspiciousCharactersOptions | undefined>;
|
|
34
|
+
readonly tabMovesFocus?: SolidEditorReactiveValue<boolean | undefined>;
|
|
35
|
+
readonly tabSize?: SolidEditorReactiveValue<number | undefined>;
|
|
36
|
+
readonly wordWrap?: SolidEditorReactiveValue<boolean | undefined>;
|
|
37
|
+
readonly onChange?: EditorChangeHandler;
|
|
38
|
+
};
|
|
39
|
+
export type SolidEditorCommands = {
|
|
40
|
+
focus(): void;
|
|
41
|
+
openDocument(document: EditorOpenDocumentOptions): void;
|
|
42
|
+
setText(text: string, options?: EditorSetTextOptions): void;
|
|
43
|
+
edit(editOrEdits: EditorEditInput, options?: EditorEditOptions): void;
|
|
44
|
+
setSelection(anchor: number, head?: number, options?: EditorSetSelectionOptions): void;
|
|
45
|
+
setScrollPosition(scrollPosition: EditorScrollPosition): void;
|
|
46
|
+
dispatchCommand(command: EditorCommandId, context?: EditorCommandContext): boolean;
|
|
47
|
+
openFind(): boolean;
|
|
48
|
+
openFindReplace(): boolean;
|
|
49
|
+
closeFind(): boolean;
|
|
50
|
+
findNext(): boolean;
|
|
51
|
+
findPrevious(): boolean;
|
|
52
|
+
replaceOne(): boolean;
|
|
53
|
+
replaceAll(): boolean;
|
|
54
|
+
selectAllMatches(): boolean;
|
|
55
|
+
};
|
|
56
|
+
export type SolidEditorController = {
|
|
57
|
+
/** Pass as a JSX ref; creates the editor after Solid mounts and disposes it with its owner. */
|
|
58
|
+
element(element: HTMLElement): void;
|
|
59
|
+
editor: Accessor<Editor | null>;
|
|
60
|
+
state: Accessor<EditorState | null>;
|
|
61
|
+
snapshot: Accessor<EditorViewSnapshot | null>;
|
|
62
|
+
textSnapshot: Accessor<TextReadSnapshot | null>;
|
|
63
|
+
/** The whole text of the current revision: O(document length) on the first read of each one. */
|
|
64
|
+
materializeFullText: Accessor<string>;
|
|
65
|
+
lastChange: Accessor<EditorContributionChange | null>;
|
|
66
|
+
updateKind: Accessor<EditorViewContributionUpdateKind | null>;
|
|
67
|
+
dispose(): void;
|
|
68
|
+
readonly commands: SolidEditorCommands;
|
|
69
|
+
};
|
|
70
|
+
export declare function createEditor(options?: SolidEditorOptions): SolidEditorController;
|
|
71
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,yBAAyB,EAE/B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,MAAM,EACN,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,oBA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,WAAW,GAAG,IAAI,CAAA;IACnC,MAAM,EAAE,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAC/B,KAAK,EAAE,QAAQ,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IACnC,QAAQ,EAAE,QAAQ,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAA;IAC7C,YAAY,EAAE,QAAQ,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAA;IAC/C,gGAAgG;IAChG,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IACrC,UAAU,EAAE,QAAQ,CAAC,wBAAwB,GAAG,IAAI,CAAC,CAAA;IACrD,UAAU,EAAE,QAAQ,CAAC,gCAAgC,GAAG,IAAI,CAAC,CAAA;IAC7D,OAAO,IAAI,IAAI,CAAA;IACf,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAA;CACvC,CAAA;AAcD,wBAAgB,YAAY,CAAC,OAAO,GAAE,kBAAuB,GAAG,qBAAqB,CAoEpF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { EDITOR_OPTION_DESCRIPTORS, createEditorOptionSync } from "@singapore-editor/core";
|
|
2
|
+
import { Editor } from "@singapore-editor/core/editor";
|
|
3
|
+
import { batch, createEffect, createSignal, onCleanup, onMount, untrack } from "solid-js";
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
var NO_DOCUMENT = Symbol("no-document");
|
|
6
|
+
function createEditor(options = {}) {
|
|
7
|
+
const [editor, setEditor] = createSignal(null);
|
|
8
|
+
const [state, setState] = createSignal(null);
|
|
9
|
+
const [snapshot, setSnapshot] = createSignal(null);
|
|
10
|
+
const [textSnapshot, setTextSource] = createSignal(null);
|
|
11
|
+
const fullText = createLazyFullTextAccessor(textSnapshot);
|
|
12
|
+
const setTextSnapshot = (next) => {
|
|
13
|
+
fullText.release(next);
|
|
14
|
+
setTextSource(() => next);
|
|
15
|
+
};
|
|
16
|
+
const [lastChange, setLastChange] = createSignal(null);
|
|
17
|
+
const [updateKind, setUpdateKind] = createSignal(null);
|
|
18
|
+
const runtime = {
|
|
19
|
+
getEditor: editor,
|
|
20
|
+
setEditor,
|
|
21
|
+
setState,
|
|
22
|
+
setSnapshot,
|
|
23
|
+
setTextSnapshot,
|
|
24
|
+
setLastChange,
|
|
25
|
+
setUpdateKind
|
|
26
|
+
};
|
|
27
|
+
const documentState = createDocumentState();
|
|
28
|
+
const optionSync = createEditorOptionSync();
|
|
29
|
+
let lifecycle = "pending";
|
|
30
|
+
let pendingHost = null;
|
|
31
|
+
const dispose = () => {
|
|
32
|
+
pendingHost = null;
|
|
33
|
+
disposeEditor(runtime);
|
|
34
|
+
fullText.clear();
|
|
35
|
+
documentState.clear();
|
|
36
|
+
optionSync.reset();
|
|
37
|
+
};
|
|
38
|
+
const mount = (element) => {
|
|
39
|
+
if (lifecycle === "disposed") return;
|
|
40
|
+
if (lifecycle === "pending") {
|
|
41
|
+
pendingHost = element;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
dispose();
|
|
45
|
+
mountEditor(element, options, runtime, documentState, optionSync);
|
|
46
|
+
};
|
|
47
|
+
onMount(() => {
|
|
48
|
+
lifecycle = "ready";
|
|
49
|
+
if (pendingHost) mount(pendingHost);
|
|
50
|
+
});
|
|
51
|
+
createReactiveEffects(options, runtime, documentState, optionSync);
|
|
52
|
+
onCleanup(() => {
|
|
53
|
+
lifecycle = "disposed";
|
|
54
|
+
dispose();
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
element: mount,
|
|
58
|
+
editor,
|
|
59
|
+
state,
|
|
60
|
+
snapshot,
|
|
61
|
+
textSnapshot,
|
|
62
|
+
materializeFullText: fullText.read,
|
|
63
|
+
lastChange,
|
|
64
|
+
updateKind,
|
|
65
|
+
dispose,
|
|
66
|
+
commands: createCommands(editor, documentState)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** Holds at most the current source and its text, and lets go as soon as the source moves on. */
|
|
70
|
+
function createLazyFullTextAccessor(textSnapshot) {
|
|
71
|
+
let cachedSource = null;
|
|
72
|
+
let cachedText = "";
|
|
73
|
+
const readWholeRevision = () => {
|
|
74
|
+
const source = textSnapshot();
|
|
75
|
+
if (source === cachedSource) return cachedText;
|
|
76
|
+
cachedSource = source;
|
|
77
|
+
cachedText = source ? source.readRange(0, source.length) : "";
|
|
78
|
+
return cachedText;
|
|
79
|
+
};
|
|
80
|
+
const clear = () => {
|
|
81
|
+
cachedSource = null;
|
|
82
|
+
cachedText = "";
|
|
83
|
+
};
|
|
84
|
+
const release = (next) => {
|
|
85
|
+
if (next !== cachedSource) clear();
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
read: readWholeRevision,
|
|
89
|
+
clear,
|
|
90
|
+
release
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function mountEditor(element, options, runtime, documentState, optionSync) {
|
|
94
|
+
const instance = new Editor(element, createConstructorOptions(options, runtime));
|
|
95
|
+
batch(() => {
|
|
96
|
+
runtime.setEditor(instance);
|
|
97
|
+
runtime.setState(instance.getState());
|
|
98
|
+
runtime.setTextSnapshot(instance.getTextSnapshot());
|
|
99
|
+
});
|
|
100
|
+
untrack(() => {
|
|
101
|
+
syncDocument(instance, readReactive(options.document), documentState);
|
|
102
|
+
for (const descriptor of EDITOR_OPTION_DESCRIPTORS) optionSync.apply(instance, descriptor, controlledOptionInput(options, descriptor.name));
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function createConstructorOptions(options, runtime) {
|
|
106
|
+
const { document: _document, editability, fontFamily, fontSize, gutterLeadingInset, hiddenCharacters, keymap, lineHeight, onChange, plugins, rangeDecorations, rowGap, scrollMode, scrollPosition: _scrollPosition, selection: _selection, suspiciousCharacters, tabMovesFocus, tabSize, theme, wordWrap, ...constructorOptions } = options;
|
|
107
|
+
return untrack(() => ({
|
|
108
|
+
...constructorOptions,
|
|
109
|
+
editability: readReactive(editability),
|
|
110
|
+
fontFamily: readReactive(fontFamily),
|
|
111
|
+
fontSize: readReactive(fontSize),
|
|
112
|
+
gutterLeadingInset: readReactive(gutterLeadingInset),
|
|
113
|
+
hiddenCharacters: readReactive(hiddenCharacters),
|
|
114
|
+
keymap: readReactive(keymap),
|
|
115
|
+
lineHeight: readReactive(lineHeight),
|
|
116
|
+
rangeDecorations: readReactive(rangeDecorations),
|
|
117
|
+
rowGap: readReactive(rowGap),
|
|
118
|
+
scrollMode: readReactive(scrollMode),
|
|
119
|
+
suspiciousCharacters: readReactive(suspiciousCharacters),
|
|
120
|
+
tabMovesFocus: readReactive(tabMovesFocus),
|
|
121
|
+
tabSize: readReactive(tabSize),
|
|
122
|
+
theme: readReactive(theme) ?? void 0,
|
|
123
|
+
wordWrap: readReactive(wordWrap),
|
|
124
|
+
plugins: [createSolidSyncPlugin(runtime), ...plugins ?? []],
|
|
125
|
+
onChange: (state, change) => {
|
|
126
|
+
syncChange(runtime, state, change);
|
|
127
|
+
onChange?.(state, change);
|
|
128
|
+
}
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
function createReactiveEffects(options, runtime, documentState, optionSync) {
|
|
132
|
+
createEffect(() => syncDocument(runtime.getEditor(), readReactive(options.document), documentState));
|
|
133
|
+
for (const descriptor of EDITOR_OPTION_DESCRIPTORS) createEffect(() => optionSync.apply(runtime.getEditor(), descriptor, controlledOptionInput(options, descriptor.name)));
|
|
134
|
+
}
|
|
135
|
+
function controlledOptionInput(options, name) {
|
|
136
|
+
return readReactive(options[name]);
|
|
137
|
+
}
|
|
138
|
+
function createSolidSyncPlugin(runtime) {
|
|
139
|
+
return {
|
|
140
|
+
name: "solid-editor-sync",
|
|
141
|
+
activate: (context) => context.registerViewContribution({ createContribution: () => ({
|
|
142
|
+
update: (snapshot, kind, change) => syncSnapshot(runtime, snapshot, kind, change ?? null),
|
|
143
|
+
dispose: () => void 0
|
|
144
|
+
}) })
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function syncSnapshot(runtime, snapshot, kind, change) {
|
|
148
|
+
batch(() => {
|
|
149
|
+
runtime.setSnapshot(snapshot);
|
|
150
|
+
runtime.setTextSnapshot(snapshot.textSnapshot);
|
|
151
|
+
runtime.setLastChange(change);
|
|
152
|
+
runtime.setUpdateKind(kind);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function syncChange(runtime, state, change) {
|
|
156
|
+
const editor = runtime.getEditor();
|
|
157
|
+
batch(() => {
|
|
158
|
+
runtime.setState(state);
|
|
159
|
+
runtime.setTextSnapshot(editor?.getTextSnapshot() ?? null);
|
|
160
|
+
runtime.setLastChange(change);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function syncDocument(editor, document, state) {
|
|
164
|
+
if (!editor) return;
|
|
165
|
+
const key = documentKey(document);
|
|
166
|
+
if (key === state.key()) return;
|
|
167
|
+
state.setKey(key);
|
|
168
|
+
if (!document) {
|
|
169
|
+
editor.clearDocument();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
editor.openDocument({
|
|
173
|
+
documentId: document.documentId,
|
|
174
|
+
documentMode: document.documentMode,
|
|
175
|
+
languageId: document.languageId,
|
|
176
|
+
scrollPosition: document.scrollPosition,
|
|
177
|
+
text: document.text
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
function disposeEditor(runtime) {
|
|
181
|
+
const editor = runtime.getEditor();
|
|
182
|
+
if (!editor) return;
|
|
183
|
+
editor.dispose();
|
|
184
|
+
batch(() => {
|
|
185
|
+
runtime.setEditor(null);
|
|
186
|
+
runtime.setState(null);
|
|
187
|
+
runtime.setSnapshot(null);
|
|
188
|
+
runtime.setTextSnapshot(null);
|
|
189
|
+
runtime.setLastChange(null);
|
|
190
|
+
runtime.setUpdateKind(null);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
function createCommands(editor, documentState) {
|
|
194
|
+
return {
|
|
195
|
+
focus: () => editor()?.focus(),
|
|
196
|
+
openDocument: (document) => {
|
|
197
|
+
documentState.setKey(documentKey(document));
|
|
198
|
+
editor()?.openDocument(document);
|
|
199
|
+
},
|
|
200
|
+
setText: (text, options) => editor()?.setText(text, options),
|
|
201
|
+
edit: (editOrEdits, options) => editor()?.edit(editOrEdits, options),
|
|
202
|
+
setSelection: (anchor, head, options) => editor()?.setSelection(anchor, head, options),
|
|
203
|
+
setScrollPosition: (scrollPosition) => editor()?.setScrollPosition(scrollPosition),
|
|
204
|
+
dispatchCommand: (command, context) => editor()?.dispatchCommand(command, context) ?? false,
|
|
205
|
+
openFind: () => editor()?.openFind() ?? false,
|
|
206
|
+
openFindReplace: () => editor()?.openFindReplace() ?? false,
|
|
207
|
+
closeFind: () => editor()?.closeFind() ?? false,
|
|
208
|
+
findNext: () => editor()?.findNext() ?? false,
|
|
209
|
+
findPrevious: () => editor()?.findPrevious() ?? false,
|
|
210
|
+
replaceOne: () => editor()?.replaceOne() ?? false,
|
|
211
|
+
replaceAll: () => editor()?.replaceAll() ?? false,
|
|
212
|
+
selectAllMatches: () => editor()?.selectAllMatches() ?? false
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function createDocumentState() {
|
|
216
|
+
let key = NO_DOCUMENT;
|
|
217
|
+
return {
|
|
218
|
+
key: () => key,
|
|
219
|
+
setKey: (nextKey) => {
|
|
220
|
+
key = nextKey;
|
|
221
|
+
},
|
|
222
|
+
clear: () => {
|
|
223
|
+
key = NO_DOCUMENT;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
function documentKey(document) {
|
|
228
|
+
if (!document) return NO_DOCUMENT;
|
|
229
|
+
return `${document.documentId ?? ""}\u0000${document.documentMode ?? ""}\u0000${document.revision ?? ""}`;
|
|
230
|
+
}
|
|
231
|
+
function readReactive(value) {
|
|
232
|
+
if (typeof value !== "function") return value;
|
|
233
|
+
return value();
|
|
234
|
+
}
|
|
235
|
+
//#endregion
|
|
236
|
+
export { createEditor };
|
|
237
|
+
|
|
238
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n createEditorOptionSync,\n EDITOR_OPTION_DESCRIPTORS,\n type EditorControlledOptionName,\n type EditorControlledSelection,\n type EditorOptionSync,\n} from '@singapore-editor/core'\nimport {\n Editor,\n type EditorChangeHandler,\n type EditorCommandContext,\n type EditorCommandId,\n type EditorDocumentMode,\n type EditorEditability,\n type EditorEditInput,\n type EditorEditOptions,\n type EditorKeymapOptions,\n type EditorOpenDocumentOptions,\n type EditorOptions,\n type EditorRangeDecoration,\n type EditorScrollMode,\n type EditorScrollPosition,\n type EditorSetSelectionOptions,\n type EditorSetTextOptions,\n type EditorState,\n type EditorSuspiciousCharactersOptions,\n} from '@singapore-editor/core/editor'\nimport type { TextReadSnapshot } from '@singapore-editor/core/document'\nimport type { EditorSyntaxLanguageId } from '@singapore-editor/core/syntax'\nimport type { EditorTheme, HiddenCharactersMode } from '@singapore-editor/core/rendering'\nimport type {\n EditorContributionChange,\n EditorPlugin,\n EditorViewContributionUpdateKind,\n EditorViewSnapshot,\n} from '@singapore-editor/core/extensions'\nimport {\n batch,\n createEffect,\n createSignal,\n onCleanup,\n onMount,\n untrack,\n type Accessor,\n} from 'solid-js'\n\nexport type SolidEditorReactiveValue<T> = T | Accessor<T>\n\nexport type SolidEditorDocument = {\n readonly documentId?: string\n readonly revision?: string | number\n readonly text: string\n readonly documentMode?: EditorDocumentMode\n readonly languageId?: EditorSyntaxLanguageId | null\n readonly scrollPosition?: EditorScrollPosition\n}\n\nexport type SolidEditorSelection = EditorControlledSelection\n\nexport type SolidEditorOptions = Omit<\n EditorOptions,\n | 'editability'\n | 'fontFamily'\n | 'fontSize'\n | 'gutterLeadingInset'\n | 'hiddenCharacters'\n | 'keymap'\n | 'lineHeight'\n | 'onChange'\n | 'rangeDecorations'\n | 'rowGap'\n | 'scrollMode'\n | 'suspiciousCharacters'\n | 'tabMovesFocus'\n | 'tabSize'\n | 'theme'\n | 'wordWrap'\n> & {\n readonly document?: SolidEditorReactiveValue<SolidEditorDocument | null | undefined>\n readonly editability?: SolidEditorReactiveValue<EditorEditability | undefined>\n readonly fontFamily?: SolidEditorReactiveValue<string | undefined>\n readonly fontSize?: SolidEditorReactiveValue<number | undefined>\n readonly gutterLeadingInset?: SolidEditorReactiveValue<number | undefined>\n readonly theme?: SolidEditorReactiveValue<EditorTheme | null | undefined>\n readonly hiddenCharacters?: SolidEditorReactiveValue<HiddenCharactersMode | undefined>\n readonly keymap?: SolidEditorReactiveValue<EditorKeymapOptions | undefined>\n readonly lineHeight?: SolidEditorReactiveValue<number | undefined>\n readonly rangeDecorations?: SolidEditorReactiveValue<readonly EditorRangeDecoration[] | undefined>\n readonly rowGap?: SolidEditorReactiveValue<number | undefined>\n readonly scrollMode?: SolidEditorReactiveValue<EditorScrollMode | undefined>\n readonly selection?: SolidEditorReactiveValue<SolidEditorSelection | null | undefined>\n readonly scrollPosition?: SolidEditorReactiveValue<EditorScrollPosition | null | undefined>\n readonly suspiciousCharacters?: SolidEditorReactiveValue<\n EditorSuspiciousCharactersOptions | undefined\n >\n readonly tabMovesFocus?: SolidEditorReactiveValue<boolean | undefined>\n readonly tabSize?: SolidEditorReactiveValue<number | undefined>\n readonly wordWrap?: SolidEditorReactiveValue<boolean | undefined>\n readonly onChange?: EditorChangeHandler\n}\n\nexport type SolidEditorCommands = {\n focus(): void\n openDocument(document: EditorOpenDocumentOptions): void\n setText(text: string, options?: EditorSetTextOptions): void\n edit(editOrEdits: EditorEditInput, options?: EditorEditOptions): void\n setSelection(anchor: number, head?: number, options?: EditorSetSelectionOptions): void\n setScrollPosition(scrollPosition: EditorScrollPosition): void\n dispatchCommand(command: EditorCommandId, context?: EditorCommandContext): boolean\n openFind(): boolean\n openFindReplace(): boolean\n closeFind(): boolean\n findNext(): boolean\n findPrevious(): boolean\n replaceOne(): boolean\n replaceAll(): boolean\n selectAllMatches(): boolean\n}\n\nexport type SolidEditorController = {\n /** Pass as a JSX ref; creates the editor after Solid mounts and disposes it with its owner. */\n element(element: HTMLElement): void\n editor: Accessor<Editor | null>\n state: Accessor<EditorState | null>\n snapshot: Accessor<EditorViewSnapshot | null>\n textSnapshot: Accessor<TextReadSnapshot | null>\n /** The whole text of the current revision: O(document length) on the first read of each one. */\n materializeFullText: Accessor<string>\n lastChange: Accessor<EditorContributionChange | null>\n updateKind: Accessor<EditorViewContributionUpdateKind | null>\n dispose(): void\n readonly commands: SolidEditorCommands\n}\n\ntype SolidEditorRuntime = {\n readonly getEditor: Accessor<Editor | null>\n readonly setEditor: (editor: Editor | null) => void\n readonly setState: (state: EditorState | null) => void\n readonly setSnapshot: (snapshot: EditorViewSnapshot | null) => void\n readonly setTextSnapshot: (snapshot: TextReadSnapshot | null) => void\n readonly setLastChange: (change: EditorContributionChange | null) => void\n readonly setUpdateKind: (kind: EditorViewContributionUpdateKind | null) => void\n}\n\nconst NO_DOCUMENT = Symbol('no-document')\n\nexport function createEditor(options: SolidEditorOptions = {}): SolidEditorController {\n const [editor, setEditor] = createSignal<Editor | null>(null)\n const [state, setState] = createSignal<EditorState | null>(null)\n const [snapshot, setSnapshot] = createSignal<EditorViewSnapshot | null>(null)\n const [textSnapshot, setTextSource] = createSignal<TextReadSnapshot | null>(null)\n const fullText = createLazyFullTextAccessor(textSnapshot)\n // Any new source — an edit, a replaced or closed document — ends the cached pair's revision.\n const setTextSnapshot = (next: TextReadSnapshot | null): void => {\n fullText.release(next)\n setTextSource(() => next)\n }\n const [lastChange, setLastChange] = createSignal<EditorContributionChange | null>(null)\n const [updateKind, setUpdateKind] = createSignal<EditorViewContributionUpdateKind | null>(null)\n const runtime = {\n getEditor: editor,\n setEditor,\n setState,\n setSnapshot,\n setTextSnapshot,\n setLastChange,\n setUpdateKind,\n } satisfies SolidEditorRuntime\n const documentState = createDocumentState()\n const optionSync = createEditorOptionSync()\n\n let lifecycle: 'pending' | 'ready' | 'disposed' = 'pending'\n let pendingHost: HTMLElement | null = null\n\n const dispose = (): void => {\n pendingHost = null\n disposeEditor(runtime)\n fullText.clear()\n documentState.clear()\n optionSync.reset()\n }\n\n const mount = (element: HTMLElement): void => {\n if (lifecycle === 'disposed') return\n if (lifecycle === 'pending') {\n pendingHost = element\n return\n }\n dispose()\n mountEditor(element, options, runtime, documentState, optionSync)\n }\n\n onMount(() => {\n lifecycle = 'ready'\n if (pendingHost) mount(pendingHost)\n })\n createReactiveEffects(options, runtime, documentState, optionSync)\n onCleanup(() => {\n lifecycle = 'disposed'\n dispose()\n })\n\n return {\n element: mount,\n editor,\n state,\n snapshot,\n textSnapshot,\n materializeFullText: fullText.read,\n lastChange,\n updateKind,\n dispose,\n commands: createCommands(editor, documentState),\n }\n}\n\ntype LazyFullTextAccessor = {\n readonly read: Accessor<string>\n readonly clear: () => void\n /** Drops the cached pair unless it belongs to `next`; never reads `next` itself. */\n readonly release: (next: TextReadSnapshot | null) => void\n}\n\n/** Holds at most the current source and its text, and lets go as soon as the source moves on. */\nfunction createLazyFullTextAccessor(\n textSnapshot: Accessor<TextReadSnapshot | null>,\n): LazyFullTextAccessor {\n let cachedSource: TextReadSnapshot | null = null\n let cachedText = ''\n\n const readWholeRevision = (): string => {\n const source = textSnapshot()\n if (source === cachedSource) return cachedText\n\n cachedSource = source\n cachedText = source ? source.readRange(0, source.length) : ''\n return cachedText\n }\n const clear = (): void => {\n cachedSource = null\n cachedText = ''\n }\n const release = (next: TextReadSnapshot | null): void => {\n if (next !== cachedSource) clear()\n }\n return { read: readWholeRevision, clear, release }\n}\n\nfunction mountEditor(\n element: HTMLElement,\n options: SolidEditorOptions,\n runtime: SolidEditorRuntime,\n documentState: SolidEditorDocumentState,\n optionSync: EditorOptionSync,\n): void {\n const instance = new Editor(element, createConstructorOptions(options, runtime))\n\n batch(() => {\n runtime.setEditor(instance)\n runtime.setState(instance.getState())\n runtime.setTextSnapshot(instance.getTextSnapshot())\n })\n\n untrack(() => {\n syncDocument(instance, readReactive(options.document), documentState)\n for (const descriptor of EDITOR_OPTION_DESCRIPTORS) {\n optionSync.apply(instance, descriptor, controlledOptionInput(options, descriptor.name))\n }\n })\n}\n\nfunction createConstructorOptions(\n options: SolidEditorOptions,\n runtime: SolidEditorRuntime,\n): EditorOptions {\n const {\n document: _document,\n editability,\n fontFamily,\n fontSize,\n gutterLeadingInset,\n hiddenCharacters,\n keymap,\n lineHeight,\n onChange,\n plugins,\n rangeDecorations,\n rowGap,\n scrollMode,\n scrollPosition: _scrollPosition,\n selection: _selection,\n suspiciousCharacters,\n tabMovesFocus,\n tabSize,\n theme,\n wordWrap,\n ...constructorOptions\n } = options\n\n return untrack((): EditorOptions => ({\n ...constructorOptions,\n editability: readReactive(editability),\n fontFamily: readReactive(fontFamily),\n fontSize: readReactive(fontSize),\n gutterLeadingInset: readReactive(gutterLeadingInset),\n hiddenCharacters: readReactive(hiddenCharacters),\n keymap: readReactive(keymap),\n lineHeight: readReactive(lineHeight),\n rangeDecorations: readReactive(rangeDecorations),\n rowGap: readReactive(rowGap),\n scrollMode: readReactive(scrollMode),\n suspiciousCharacters: readReactive(suspiciousCharacters),\n tabMovesFocus: readReactive(tabMovesFocus),\n tabSize: readReactive(tabSize),\n theme: readReactive(theme) ?? undefined,\n wordWrap: readReactive(wordWrap),\n plugins: [createSolidSyncPlugin(runtime), ...(plugins ?? [])],\n onChange: (state, change) => {\n syncChange(runtime, state, change)\n onChange?.(state, change)\n },\n }))\n}\n\nfunction createReactiveEffects(\n options: SolidEditorOptions,\n runtime: SolidEditorRuntime,\n documentState: SolidEditorDocumentState,\n optionSync: EditorOptionSync,\n): void {\n createEffect(() =>\n syncDocument(runtime.getEditor(), readReactive(options.document), documentState),\n )\n // One effect per descriptor, so each option tracks only the source it was given.\n for (const descriptor of EDITOR_OPTION_DESCRIPTORS) {\n createEffect(() =>\n optionSync.apply(\n runtime.getEditor(),\n descriptor,\n controlledOptionInput(options, descriptor.name),\n ),\n )\n }\n}\n\nfunction controlledOptionInput(\n options: SolidEditorOptions,\n name: EditorControlledOptionName,\n): unknown {\n return readReactive(options[name] as SolidEditorReactiveValue<unknown>)\n}\n\nfunction createSolidSyncPlugin(runtime: SolidEditorRuntime): EditorPlugin {\n return {\n name: 'solid-editor-sync',\n activate: (context) =>\n context.registerViewContribution({\n createContribution: () => ({\n update: (snapshot, kind, change) => syncSnapshot(runtime, snapshot, kind, change ?? null),\n dispose: () => undefined,\n }),\n }),\n }\n}\n\nfunction syncSnapshot(\n runtime: SolidEditorRuntime,\n snapshot: EditorViewSnapshot,\n kind: EditorViewContributionUpdateKind,\n change: EditorContributionChange | null,\n): void {\n batch(() => {\n runtime.setSnapshot(snapshot)\n runtime.setTextSnapshot(snapshot.textSnapshot)\n runtime.setLastChange(change)\n runtime.setUpdateKind(kind)\n })\n}\n\nfunction syncChange(\n runtime: SolidEditorRuntime,\n state: EditorState,\n change: EditorContributionChange | null,\n): void {\n const editor = runtime.getEditor()\n\n batch(() => {\n runtime.setState(state)\n runtime.setTextSnapshot(editor?.getTextSnapshot() ?? null)\n runtime.setLastChange(change)\n })\n}\n\nfunction syncDocument(\n editor: Editor | null,\n document: SolidEditorDocument | null | undefined,\n state: SolidEditorDocumentState,\n): void {\n if (!editor) return\n\n const key = documentKey(document)\n if (key === state.key()) return\n\n state.setKey(key)\n if (!document) {\n editor.clearDocument()\n return\n }\n\n editor.openDocument({\n documentId: document.documentId,\n documentMode: document.documentMode,\n languageId: document.languageId,\n scrollPosition: document.scrollPosition,\n text: document.text,\n })\n}\n\nfunction disposeEditor(runtime: SolidEditorRuntime): void {\n const editor = runtime.getEditor()\n if (!editor) return\n\n editor.dispose()\n batch(() => {\n runtime.setEditor(null)\n runtime.setState(null)\n runtime.setSnapshot(null)\n runtime.setTextSnapshot(null)\n runtime.setLastChange(null)\n runtime.setUpdateKind(null)\n })\n}\n\nfunction createCommands(\n editor: Accessor<Editor | null>,\n documentState: SolidEditorDocumentState,\n): SolidEditorCommands {\n return {\n focus: () => editor()?.focus(),\n openDocument: (document) => {\n documentState.setKey(documentKey(document))\n editor()?.openDocument(document)\n },\n setText: (text, options) => editor()?.setText(text, options),\n edit: (editOrEdits, options) => editor()?.edit(editOrEdits, options),\n setSelection: (anchor, head, options) => editor()?.setSelection(anchor, head, options),\n setScrollPosition: (scrollPosition) => editor()?.setScrollPosition(scrollPosition),\n dispatchCommand: (command, context) => editor()?.dispatchCommand(command, context) ?? false,\n openFind: () => editor()?.openFind() ?? false,\n openFindReplace: () => editor()?.openFindReplace() ?? false,\n closeFind: () => editor()?.closeFind() ?? false,\n findNext: () => editor()?.findNext() ?? false,\n findPrevious: () => editor()?.findPrevious() ?? false,\n replaceOne: () => editor()?.replaceOne() ?? false,\n replaceAll: () => editor()?.replaceAll() ?? false,\n selectAllMatches: () => editor()?.selectAllMatches() ?? false,\n }\n}\n\ntype SolidEditorDocumentState = {\n key(): SolidEditorDocumentKey\n setKey(key: SolidEditorDocumentKey): void\n clear(): void\n}\n\ntype SolidEditorDocumentKey = string | typeof NO_DOCUMENT\n\nfunction createDocumentState(): SolidEditorDocumentState {\n let key: SolidEditorDocumentKey = NO_DOCUMENT\n\n return {\n key: () => key,\n setKey: (nextKey) => {\n key = nextKey\n },\n clear: () => {\n key = NO_DOCUMENT\n },\n }\n}\n\nfunction documentKey(document: SolidEditorDocument | null | undefined): SolidEditorDocumentKey {\n if (!document) return NO_DOCUMENT\n\n return `${document.documentId ?? ''}\\u0000${document.documentMode ?? ''}\\u0000${\n document.revision ?? ''\n }`\n}\n\nfunction readReactive<T>(value: SolidEditorReactiveValue<T> | undefined): T | undefined {\n if (typeof value !== 'function') return value\n\n return (value as Accessor<T>)()\n}\n"],"mappings":";;;;AAgJA,IAAM,cAAc,OAAO,aAAa;AAExC,SAAgB,aAAa,UAA8B,CAAC,GAA0B;CACpF,MAAM,CAAC,QAAQ,aAAa,aAA4B,IAAI;CAC5D,MAAM,CAAC,OAAO,YAAY,aAAiC,IAAI;CAC/D,MAAM,CAAC,UAAU,eAAe,aAAwC,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OAAO;EACL,WAAW;EACX,SAAS,YAAY;GACnB,MAAM;EACR;EACA,aAAa;GACX,MAAM;EACR;CACF;AACF;AAEA,SAAS,YAAY,UAA0E;CAC7F,IAAI,CAAC,UAAU,OAAO;CAEtB,OAAO,GAAG,SAAS,cAAc,GAAG,QAAQ,SAAS,gBAAgB,GAAG,QACtE,SAAS,YAAY;AAEzB;AAEA,SAAS,aAAgB,OAA+D;CACtF,IAAI,OAAO,UAAU,YAAY,OAAO;CAExC,OAAQ,MAAsB;AAChC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@singapore-editor/solid",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"files": [
|
|
5
|
+
"README.md",
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public",
|
|
18
|
+
"registry": "https://registry.npmjs.org/"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "bun ../../scripts/build-package.ts",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"typecheck": "tsgo --noEmit",
|
|
24
|
+
"lint": "oxlint .",
|
|
25
|
+
"format": "oxfmt --write .",
|
|
26
|
+
"format:check": "oxfmt --check ."
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@singapore-editor/core": "0.1.2"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^26.6.3",
|
|
33
|
+
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
34
|
+
"happy-dom": "^20.14.5",
|
|
35
|
+
"oxfmt": "0.70.0",
|
|
36
|
+
"oxlint": "1.85.0",
|
|
37
|
+
"solid-js": "^1.9.15",
|
|
38
|
+
"typescript": "~6.0.3",
|
|
39
|
+
"vitest": "^5.0.2"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@singapore-editor/core": "0.1.2",
|
|
43
|
+
"solid-js": ">=1.8 <2"
|
|
44
|
+
}
|
|
45
|
+
}
|