mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-11-08 06:28:29 +01:00
update Antedit
This commit is contained in:
parent
afade6884e
commit
2813117cc0
@ -6,6 +6,7 @@ The editor functionality can be extended by its extension mechanism.
|
||||
Extension can be developed/released/isntalled by the editor itself.
|
||||
|
||||
### Change logs
|
||||
- 0.1.13-b: Allow file upload in file view, add menu context in tabbar
|
||||
- 0.1.12-b: fix recent files not adding correctly
|
||||
- 0.1.11-b: fix file type parsing from path
|
||||
- 0.1.10-b: Antedit now has it own extension manager
|
||||
|
@ -6,6 +6,7 @@ The editor functionality can be extended by its extension mechanism.
|
||||
Extension can be developed/released/isntalled by the editor itself.
|
||||
|
||||
### Change logs
|
||||
- 0.1.13-b: Allow file upload in file view, add menu context in tabbar
|
||||
- 0.1.12-b: fix recent files not adding correctly
|
||||
- 0.1.11-b: fix file type parsing from path
|
||||
- 0.1.10-b: Antedit now has it own extension manager
|
||||
|
File diff suppressed because one or more lines are too long
@ -7,7 +7,7 @@
|
||||
"author": "Xuan Sang LE",
|
||||
"email": "mrsang@iohub.dev"
|
||||
},
|
||||
"version": "0.1.12-b",
|
||||
"version": "0.1.13-b",
|
||||
"category": "Development",
|
||||
"iconclass": "bi bi-journal-code",
|
||||
"mimes": [
|
||||
|
Binary file not shown.
@ -7,7 +7,7 @@
|
||||
"author": "Xuan Sang LE",
|
||||
"email": "mrsang@iohub.dev"
|
||||
},
|
||||
"version": "0.1.12-b",
|
||||
"version": "0.1.13-b",
|
||||
"category": "Development",
|
||||
"iconclass": "bi bi-journal-code",
|
||||
"mimes": [
|
||||
|
@ -1,5 +1,5 @@
|
||||
namespace OS {
|
||||
declare var $:any;
|
||||
//declare var $:any;
|
||||
export namespace application {
|
||||
|
||||
/**
|
||||
@ -69,6 +69,9 @@ namespace OS {
|
||||
*/
|
||||
private container: HTMLElement;
|
||||
|
||||
/**
|
||||
* Editor status monitoring
|
||||
*/
|
||||
onstatuschange: (stat: GenericObject<any>) => void;
|
||||
|
||||
/**
|
||||
@ -190,12 +193,11 @@ namespace OS {
|
||||
/**
|
||||
* Close a tab when a file is closed
|
||||
*
|
||||
* @private
|
||||
* @param {GUI.tag.ListViewItemTag} it reference to the tab to close
|
||||
* @returns {boolean}
|
||||
* @memberof BaseEditorModel
|
||||
*/
|
||||
private closeTab(it: GUI.tag.ListViewItemTag): boolean {
|
||||
closeTab(it: GUI.tag.ListViewItemTag): boolean {
|
||||
this.tabbar.delete(it);
|
||||
const cnt = this.tabbar.items.length;
|
||||
|
||||
@ -387,6 +389,28 @@ namespace OS {
|
||||
return this.dirties().length > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set model tabbar menu context event
|
||||
*
|
||||
* @memberof BaseEditorModel
|
||||
*/
|
||||
setTabbarCtxMenu(items: GenericObject<any>[], handle:(tab:GUI.tag.ListViewItemTag, mdata: GenericObject<any>) => void): void
|
||||
{
|
||||
this.tabbar.contextmenuHandle = (evt, m) => {
|
||||
m.items = items;
|
||||
m.onmenuselect = (e) => {
|
||||
if(handle)
|
||||
{
|
||||
/**
|
||||
* get the tab under the cursor
|
||||
*/
|
||||
const tab = $(evt.target).closest("afx-list-item");
|
||||
handle(tab[0], e.data.item.data);
|
||||
}
|
||||
};
|
||||
return m.show(evt);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the editor instance
|
||||
|
@ -332,15 +332,17 @@ namespace OS {
|
||||
|
||||
monaco.editor.setTheme("vs-dark");
|
||||
// add editor instance
|
||||
this.eum
|
||||
.add(new OS.application.MonacoEditorModel(
|
||||
const left_editor = new OS.application.MonacoEditorModel(
|
||||
this,
|
||||
this.find("left-tabbar") as GUI.tag.TabBarTag,
|
||||
this.find("left-editorarea")) as BaseEditorModel)
|
||||
.add(new OS.application.MonacoEditorModel(
|
||||
this.find("left-editorarea")) as BaseEditorModel;
|
||||
const right_editor = new OS.application.MonacoEditorModel(
|
||||
this,
|
||||
this.find("right-tabbar") as GUI.tag.TabBarTag,
|
||||
this.find("right-editorarea")) as BaseEditorModel);
|
||||
this.find("right-editorarea")) as BaseEditorModel;
|
||||
left_editor.setTabbarCtxMenu(this.tb_ctxmenu, (tab, data) => this.tabbar_ctx_menu_handle(tab,data, left_editor));
|
||||
right_editor.setTabbarCtxMenu(this.tb_ctxmenu, (tab, data) => this.tabbar_ctx_menu_handle(tab,data, right_editor));
|
||||
this.eum.add(left_editor).add(right_editor);
|
||||
this.eum.onstatuschange = (st) =>
|
||||
this.updateStatus(st)
|
||||
$(wrapper).css('visibility', 'visible');
|
||||
@ -348,6 +350,54 @@ namespace OS {
|
||||
this.eum.active.openFile(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the context menu items
|
||||
*/
|
||||
private get tb_ctxmenu(): GenericObject<any>[]
|
||||
{
|
||||
return [
|
||||
{ text: "__(Close)", id: "close" },
|
||||
{ text: "__(Close All)", id: "close-all" },
|
||||
{ text: "__(Move to other side)", id: "mv-side" },
|
||||
];
|
||||
}
|
||||
|
||||
private tabbar_ctx_menu_handle(tab: GUI.tag.ListViewItemTag, data: GenericObject<any>, model: BaseEditorModel): void {
|
||||
switch(data.id)
|
||||
{
|
||||
case "close":
|
||||
if(!tab)
|
||||
{
|
||||
return;
|
||||
}
|
||||
model.closeTab(tab);
|
||||
break;
|
||||
case "close-all":
|
||||
model.closeAll();
|
||||
model.openFile("Untitled".asFileHandle() as EditorFileHandle)
|
||||
break;
|
||||
case "mv-side":
|
||||
if(!tab)
|
||||
{
|
||||
return;
|
||||
}
|
||||
let other_model = this.eum.editors[0];
|
||||
if(model == other_model)
|
||||
{
|
||||
other_model = this.eum.editors[1];
|
||||
}
|
||||
other_model.openFile(tab.data as EditorFileHandle);
|
||||
model.closeTab(tab);
|
||||
if(this.split_mode == false)
|
||||
{
|
||||
this.toggleSplitMode();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the text editor
|
||||
*
|
||||
@ -390,6 +440,7 @@ namespace OS {
|
||||
{ text: "__(New folder)", id: "newdir" },
|
||||
{ text: "__(Rename)", id: "rename" },
|
||||
{ text: "__(Delete)", id: "delete" },
|
||||
{ text: "__(Upload)", id: "upload" },
|
||||
];
|
||||
m.onmenuselect = (e) => {
|
||||
return this.ctxFileMenuHandle(e);
|
||||
@ -806,7 +857,7 @@ namespace OS {
|
||||
} catch (e) {
|
||||
return this.error(
|
||||
__("Fail to create: {0}", e.stack),
|
||||
e
|
||||
__e(e)
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -826,7 +877,7 @@ namespace OS {
|
||||
} catch (e) {
|
||||
return this.error(
|
||||
__("Fail to create: {0}", dir.path),
|
||||
e
|
||||
__e(e)
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -852,7 +903,7 @@ namespace OS {
|
||||
} catch (e) {
|
||||
return this.error(
|
||||
__("Fail to rename: {0}", file.path),
|
||||
e
|
||||
__e(e)
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -881,11 +932,23 @@ namespace OS {
|
||||
} catch (e) {
|
||||
return this.error(
|
||||
__("Fail to delete: {0}", file.path),
|
||||
e
|
||||
__e(e)
|
||||
);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "upload":
|
||||
if(!dir)
|
||||
{
|
||||
return;
|
||||
}
|
||||
dir.upload()
|
||||
.then((d) => {
|
||||
this.notify(__("File uploaded to: {0}", dir.path));
|
||||
return this.fileview.update(dir.path);
|
||||
})
|
||||
.catch((e) => this.error(__("Unable to upload file: {e}", e.toString()), __e(e)));
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
@ -1287,6 +1350,7 @@ namespace OS {
|
||||
ed.onstatuschange = cb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dirties(): EditorFileHandle[] {
|
||||
let list = [];
|
||||
|
@ -45,7 +45,7 @@
|
||||
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Antedit/README.md",
|
||||
"category": "Development",
|
||||
"author": "Xuan Sang LE",
|
||||
"version": "0.1.12-b",
|
||||
"version": "0.1.13-b",
|
||||
"dependencies": ["MonacoCore@0.23.0-r"],
|
||||
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Antedit/build/release/Antedit.zip"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user