lean4monaco 1.0.29 → 1.0.30
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 +56 -15
- package/dist/leanmonaco.js +5 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
[](https://github.com/hhu-adam/lean4monaco/blob/main/LICENSE)
|
|
2
|
+
[](https://www.npmjs.com/package/lean4monaco)
|
|
3
|
+
[](https://github.com/hhu-adam/lean4monaco/actions/workflows/test.yml)
|
|
4
|
+
|
|
1
5
|
# Lean 4 Monaco
|
|
2
6
|
|
|
3
7
|
Provides browser support for running Lean in a Monaco editor.
|
|
@@ -21,25 +25,51 @@ one or more editors can be created using `LeanMonacoEditor`. Here is an example
|
|
|
21
25
|
how to use the classes using React:
|
|
22
26
|
|
|
23
27
|
```ts
|
|
24
|
-
import { LeanMonaco, LeanMonacoEditor } from 'lean4monaco'
|
|
28
|
+
import { LeanMonaco, LeanMonacoEditor, LeanMonacoOptions } from 'lean4monaco'
|
|
25
29
|
|
|
26
30
|
[...]
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
32
|
+
// Refs for the editor and infoview
|
|
33
|
+
const editorRef = useRef<HTMLDivElement>(null)
|
|
34
|
+
const infoviewRef = useRef<HTMLDivElement>(null)
|
|
35
|
+
|
|
36
|
+
// Lean4monaco options
|
|
37
|
+
const [options, setOptions] = useState<LeanMonacoOptions>({
|
|
38
|
+
websocket: {
|
|
39
|
+
url: 'ws://localhost:8080/'
|
|
40
|
+
},
|
|
41
|
+
htmlElement: undefined, // The wrapper div for monaco
|
|
42
|
+
vscode: {
|
|
43
|
+
"editor.wordWrap": true,
|
|
44
|
+
}
|
|
42
45
|
})
|
|
46
|
+
|
|
47
|
+
// Optional: restrict monaco's extend (e.g. context menu) to the editor itself
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
setOptions({...options, htmlElement: editorRef.current ?? undefined})
|
|
50
|
+
}, [editorRef])
|
|
51
|
+
|
|
52
|
+
// Start infoview and editor(s)
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
// You must create a single `LeanMonaco` instance (infoview), but you can create multiple
|
|
55
|
+
// `LeanMonacoEditor` instances (editor)
|
|
56
|
+
// You must await `leanMonaco.start` or use `await leanMonaco.whenReady` before
|
|
57
|
+
// starting the editors!
|
|
58
|
+
const leanMonaco = new LeanMonaco()
|
|
59
|
+
const leanMonacoEditor = new LeanMonacoEditor()
|
|
60
|
+
|
|
61
|
+
leanMonaco.setInfoviewElement(infoviewRef.current!)
|
|
62
|
+
|
|
63
|
+
;(async () => {
|
|
64
|
+
await leanMonaco.start(options)
|
|
65
|
+
await leanMonacoEditor.start(editorRef.current!, '/project/test.lean', '#check Nat')
|
|
66
|
+
})()
|
|
67
|
+
|
|
68
|
+
return () => {
|
|
69
|
+
leanMonaco.dispose()
|
|
70
|
+
leanMonacoEditor.dispose()
|
|
71
|
+
}
|
|
72
|
+
}, [options, infoviewRef, editorRef])
|
|
43
73
|
```
|
|
44
74
|
|
|
45
75
|
### Configure vite
|
|
@@ -164,3 +194,14 @@ Some random errors we encountered. If you have more, please share them.
|
|
|
164
194
|
|
|
165
195
|
* Warnings about `glob` and `inflight` come from `copyfiles`: see [copyfiles#132](https://github.com/calvinmetcalf/copyfiles/pull/132)
|
|
166
196
|
* Warning about ` @types/cypress` comes from `cypress-iframe`
|
|
197
|
+
|
|
198
|
+
## Development
|
|
199
|
+
|
|
200
|
+
You can run
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
npm install
|
|
204
|
+
npm run test
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
for the automated cypress tests.
|
package/dist/leanmonaco.js
CHANGED
|
@@ -32,13 +32,7 @@ export class LeanMonaco {
|
|
|
32
32
|
infoviewEl;
|
|
33
33
|
disposed = false;
|
|
34
34
|
async start(options) {
|
|
35
|
-
|
|
36
|
-
console.debug('[LeanMonaco]: not starting because container is null');
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
console.debug('[LeanMonaco]: starting');
|
|
41
|
-
}
|
|
35
|
+
console.debug('[LeanMonaco]: starting');
|
|
42
36
|
if (LeanMonaco.activeInstance == this) {
|
|
43
37
|
console.warn('A LeanMonaco instance cannot be started twice.');
|
|
44
38
|
return;
|
|
@@ -68,7 +62,10 @@ export class LeanMonaco {
|
|
|
68
62
|
...getConfigurationServiceOverride(),
|
|
69
63
|
...getLanguagesServiceOverride(),
|
|
70
64
|
...getModelServiceOverride()
|
|
71
|
-
},
|
|
65
|
+
},
|
|
66
|
+
// The wrapper HTML element determines the extend of certain monaco features
|
|
67
|
+
// such as the right-click context menu.
|
|
68
|
+
options.htmlElement ?? undefined, {
|
|
72
69
|
workspaceProvider: {
|
|
73
70
|
trusted: true,
|
|
74
71
|
workspace: {
|