Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/files_texteditor.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorVincent Petry <PVince81@yahoo.fr>2015-11-19 16:39:03 +0300
committerVincent Petry <PVince81@yahoo.fr>2015-11-19 16:39:03 +0300
commit5b868a0b7f02df145ef2fd2fe72cf42144c7dc37 (patch)
tree8019dbc7b65bb541876e82b07efe564ad856d828 /js
parentefa657933af2b913e877a39a32731afae64e22ff (diff)
Register "New text file" meu entry in "+" menu
Register an entry to create a new text file in the file app's "+" menu. After file creation, automatically open the editor.
Diffstat (limited to 'js')
-rw-r--r--js/editor.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/js/editor.js b/js/editor.js
index 341357b..11372e4 100644
--- a/js/editor.js
+++ b/js/editor.js
@@ -561,8 +561,46 @@ var Files_Texteditor = {
};
+Files_Texteditor.NewFileMenuPlugin = {
+
+ attach: function(menu) {
+ var fileList = menu.fileList;
+
+ // only attach to main file list, public view is not supported yet
+ if (fileList.id !== 'files') {
+ return;
+ }
+
+ // register the new menu entry
+ menu.addMenuEntry({
+ id: 'file',
+ displayName: t('files_texteditor', 'Text file'),
+ templateName: t('files_texteditor', 'New text file.txt'),
+ iconClass: 'icon-filetype-text',
+ fileType: 'file',
+ actionHandler: function(name) {
+ var dir = fileList.getCurrentDirectory();
+ // first create the file
+ fileList.createFile(name).then(function() {
+ // once the file got successfully created,
+ // open the editor
+ Files_Texteditor._onEditorTrigger(
+ name,
+ {
+ fileList: fileList,
+ dir: dir
+ }
+ );
+ });
+ }
+ });
+ }
+};
+
OCA.Files_Texteditor = Files_Texteditor;
+OC.Plugins.register('OCA.Files.NewFileMenu', Files_Texteditor.NewFileMenuPlugin);
+
$(document).ready(function () {
$('#editor').remove();
OCA.Files_Texteditor.initialize($('<div id="app-content-texteditor"></div>'));