mirror of
https://github.com/ONLYOFFICE/web-apps.git
synced 2026-02-10 18:05:32 +08:00
Add supported VBA for monaco
This commit is contained in:
1
vendor/monaco/MonacoEditor.html
vendored
1
vendor/monaco/MonacoEditor.html
vendored
@ -36,6 +36,7 @@
|
||||
var params = getUrlParams();
|
||||
window.editorType = params["editorType"]; // word/cell/slide
|
||||
window.editorTheme = params["editorTheme"]; // dark/light
|
||||
window.language = params["language"]; //javascript/vba
|
||||
</script>
|
||||
<script src="./MonacoEditorCode.js"></script>
|
||||
</body>
|
||||
|
||||
13
vendor/monaco/MonacoEditorCode.js
vendored
13
vendor/monaco/MonacoEditorCode.js
vendored
@ -34,7 +34,8 @@ var codeEditor = new window.MonacoEditor();
|
||||
codeEditor.create("editor", window.editorTheme === "dark" ? "vs-dark" : "vs-light", "", {
|
||||
minimap: {
|
||||
enabled: false
|
||||
}
|
||||
},
|
||||
language: window.language
|
||||
}, function() {
|
||||
_postMessage({
|
||||
command: 'monacoEditorReady',
|
||||
@ -42,10 +43,12 @@ codeEditor.create("editor", window.editorTheme === "dark" ? "vs-dark" : "vs-ligh
|
||||
});
|
||||
});
|
||||
|
||||
codeEditor.addLibrary({
|
||||
url: "./libs/" + window.editorType + "/api.js",
|
||||
name : "onlyoffice"
|
||||
});
|
||||
if(window.language == 'javascript') {
|
||||
codeEditor.addLibrary({
|
||||
url: "./libs/" + window.editorType + "/api.js",
|
||||
name : "onlyoffice"
|
||||
});
|
||||
}
|
||||
|
||||
var _postMessage = function(msg) {
|
||||
window.parent && window.JSON && window.parent.postMessage(window.JSON.stringify(msg), "*");
|
||||
|
||||
18
vendor/monaco/monaco.js
vendored
18
vendor/monaco/monaco.js
vendored
@ -62,6 +62,7 @@
|
||||
for (let i in this.options)
|
||||
options[i] = this.options[i];
|
||||
|
||||
this._registerLanguage(options.language);
|
||||
this.editor = monaco.editor.create(document.getElementById(this.parent), options);
|
||||
this._loadLibraries();
|
||||
this._loadEvents();
|
||||
@ -119,6 +120,23 @@
|
||||
monaco.languages.typescript.javascriptDefaults.addExtraLib(libraries[i].code, libraries[i].name);
|
||||
}
|
||||
};
|
||||
|
||||
MonacoEditor.prototype._registerLanguage = function(language) {
|
||||
if(language == 'vba') {
|
||||
monaco.languages.register({ id: 'vba' });
|
||||
monaco.languages.setMonarchTokensProvider('vba', {
|
||||
tokenizer: {
|
||||
root: [
|
||||
[/\b(?:Sub|End Sub|Function|End Function|If|Then|Else|End If|Dim|As|Set|New|For|Each|Next|Do|Loop|While|Wend|Select Case|Case|End Select|Exit|With|End With|Call|Private|Public|Const|GoTo|On Error)\b/, 'keyword'],
|
||||
[/"([^"]*)"/, 'string'],
|
||||
[/\b[A-Za-z_][A-Za-z0-9_]*\b/, 'identifier'],
|
||||
[/\d+/, 'number'],
|
||||
[/'.*$/, 'comment']
|
||||
]
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
MonacoEditor.prototype.dispose = function() {
|
||||
for (let i = 0; i < REGISTERED_EDITORS.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user