SUpport to change language mode in antedit

This commit is contained in:
mrsang 2021-05-01 12:17:00 +02:00
parent cda5ff741e
commit 42bc787eae
8 changed files with 34 additions and 12 deletions

View File

@ -6,4 +6,5 @@ The editor functionality can be extended by its extension mechanism.
Extension can be developed/released/isntalled by the editor itself.
### Change logs
- 0.1.8-a: Allow to change language mode
- 0.1.7-a: Add keyboard shortcut support to extension actions

View File

@ -6,4 +6,5 @@ The editor functionality can be extended by its extension mechanism.
Extension can be developed/released/isntalled by the editor itself.
### Change logs
- 0.1.8-a: Allow to change language mode
- 0.1.7-a: Add keyboard shortcut support to extension actions

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,7 @@
"author": "Xuan Sang LE",
"email": "mrsang@iohub.dev"
},
"version":"0.1.7-a",
"version":"0.1.8-a",
"category":"Development",
"iconclass":"bi bi-journal-code",
"mimes":[

Binary file not shown.

View File

@ -7,7 +7,7 @@
"author": "Xuan Sang LE",
"email": "mrsang@iohub.dev"
},
"version":"0.1.7-a",
"version":"0.1.8-a",
"category":"Development",
"iconclass":"bi bi-journal-code",
"mimes":[

View File

@ -102,7 +102,10 @@ namespace OS {
getModes(): GenericObject<any>[] {
//const list = [];
//return list;
return monaco.languages.getLanguages();
return monaco.languages.getLanguages().map(e=>{
(e as GenericObject<any>).text = e.aliases[0];
return e;
});
}
@ -131,6 +134,9 @@ namespace OS {
* @memberof MonacoEditorModel
*/
setMode(m: GenericObject<any>): void {
monaco.editor.setModelLanguage(this.editor.getModel(), m.id);
if(this.onstatuschange)
this.onstatuschange(this.getEditorStatus());
}

View File

@ -216,14 +216,6 @@ namespace OS {
$(wrapper).css('visibility', 'visible');
this.setup();
this.eum.active.openFile(file);
/*this.load(new Promise((resolve, reject) => {
require.config({ paths: { 'vs': "pkg://MonacoCore/vs".asFileHandle().getlink() }});
require(['vs/editor/editor.main'], () => {
resolve(undefined);
});
}))*/
}
/**
@ -321,7 +313,29 @@ namespace OS {
if (this.setting.showBottomBar === undefined) {
this.setting.showBottomBar = false;
}
//TODO: support change editor model languages
const extension = {
name: "Editor",
text: __("Editor")
};
const action = {
name: "langmode",
text: __("Change language mode"),
shortcut: 'CTRL-K'
}
this.eum.addAction(extension, action, async (e) =>
{
try{
const data = await this.openDialog("SelectionDialog", {
"title": __("Select language"),
data: this.eum.active.getModes()
});
this.eum.active.setMode(data);
}catch(e)
{
}
});
this.loadExtensionMetaData();
this.toggleSideBar();
this.toggleSplitMode();