mirror of
https://github.com/mickael-kerjean/filestash
synced 2026-01-04 06:43:18 +01:00
feature (editor): provide different choices for keybinding - #80
This commit is contained in:
parent
3421faa4b5
commit
96cfd1a623
5 changed files with 15 additions and 4 deletions
|
|
@ -27,7 +27,7 @@
|
|||
- Image viewer
|
||||
- Quick access: frequently access folders are pin to the homepage
|
||||
- Stateless
|
||||
- Emacs keybindings `;)`
|
||||
- Emacs, VIM or Sublime keybindings `;)`
|
||||
|
||||
# Screenshots
|
||||
<p align="center">
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@ export class Editor extends React.Component {
|
|||
});
|
||||
|
||||
|
||||
this.loadMode(this.props.filename)
|
||||
this.loadKeybinding()
|
||||
.then(() => this.loadMode(this.props.filename))
|
||||
.then((res) => new Promise((done) => this.setState({loading: false}, () => done(res))))
|
||||
.then(loadCodeMirror.bind(this))
|
||||
.then(() => {
|
||||
|
|
@ -96,7 +97,7 @@ export class Editor extends React.Component {
|
|||
value: this.props.content,
|
||||
lineNumbers: true,
|
||||
mode: mode,
|
||||
keyMap: config.god_editor_mode ? "emacs" : "default",
|
||||
keyMap: config.editor,
|
||||
lineWrapping: true,
|
||||
foldOptions: {
|
||||
widget: "..."
|
||||
|
|
@ -194,6 +195,13 @@ export class Editor extends React.Component {
|
|||
.then((module) => Promise.resolve([module.default, mode: mode]));
|
||||
}
|
||||
|
||||
loadKeybinding(){
|
||||
if(config.editor === "emacs" || !config.editor){
|
||||
return Promise.resolve();
|
||||
}
|
||||
return import(/* webpackChunkName: "editor" */'./editor/keymap_'+config.editor);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="component_editor">
|
||||
|
|
|
|||
1
client/pages/viewerpage/editor/keymap_sublime.js
Normal file
1
client/pages/viewerpage/editor/keymap_sublime.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
import 'codemirror/keymap/sublime.js';
|
||||
1
client/pages/viewerpage/editor/keymap_vim.js
Normal file
1
client/pages/viewerpage/editor/keymap_vim.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
import 'codemirror/keymap/vim.js';
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
module.exports = {
|
||||
god_editor_mode: true,
|
||||
// editor keybinding can be either: "sublime", "emacs", "vim"
|
||||
editor: "emacs",
|
||||
fork_button: true,
|
||||
search: {
|
||||
enable: true,
|
||||
|
|
|
|||
Loading…
Reference in a new issue