diff options
author | Julius Härtl <jus@bitgrid.net> | 2019-04-13 21:28:28 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-04-13 21:28:28 +0300 |
commit | 1bdb0ff3eaa0f8a874bbf306ca5fe8a45f8e6ff4 (patch) | |
tree | 69363d95e38dc7b02a55c4e2cf3a9149f75cbb46 /src/files.js | |
parent | 66adbbbe655ef62f1545a39c2bf31630455af8da (diff) |
Add first working version of collaborative editing
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'src/files.js')
-rw-r--r-- | src/files.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/files.js b/src/files.js new file mode 100644 index 000000000..d64cd4076 --- /dev/null +++ b/src/files.js @@ -0,0 +1,60 @@ +/* + * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net> + * + * @author Julius Härtl <jus@bitgrid.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +const 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', 'New text document'), + templateName: t('files_texteditor', 'New text document.md'), + iconClass: 'icon-filetype-text', + fileType: 'file', + actionHandler: function (name) { + var dir = fileList.getCurrentDirectory(); + // first create the file + fileList.createFile(name).then(function () { + // TODO: open editor + }); + } + }); + } +}; +OC.Plugins.register('OCA.Files.NewFileMenu', newFileMenuPlugin); + +import Editor from './components/Editor' +$(document).ready(function() { +OCA.Viewer.registerHandler({ + id: 'text', + mimes: ['text/markdown'], + component: Editor, + group: null +}); +}); |