0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Initial pass at Editor Toolbar - Undo and Redo.

This commit is contained in:
G.Ambatte
2021-09-19 19:26:44 +12:00
parent aec8133046
commit 9bc52b412c
3 changed files with 35 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
/*eslint max-lines: ["warn", {"max": 300, "skipBlankLines": true, "skipComments": true}]*/
require('./editor.less');
const React = require('react');
const createClass = require('create-react-class');
@@ -198,6 +199,21 @@ const Editor = createClass({
}
},
renderEditorToolbar : function(){
return <div className='editorToolbar'>
<span className='undo'
onClick={this.refs.codeEditor?.undo}
title='Undo'>
<i className='fas fa-undo' />
</span>
<span className='redo'
onClick={this.refs.codeEditor?.redo}
title='Redo'>
<i className='fas fa-redo' />
</span>
</div>;
},
render : function(){
this.highlightCustomMarkdown();
return (
@@ -211,6 +227,7 @@ const Editor = createClass({
renderer={this.props.renderer} />
{this.renderEditor()}
{!this.isMeta() && this.renderEditorToolbar()}
</div>
);
}

View File

@@ -50,4 +50,16 @@
.tooltipLeft("Jump to brew page");
}
.editorToolbar{
position: absolute;
top: 5px;
left: 50%;
color: black;
font-size: 13px;
z-index: 9;
span {
padding: 2px 5px;
}
}
}

View File

@@ -112,6 +112,12 @@ const CodeEditor = createClass({
updateSize : function(){
this.codeMirror.refresh();
},
redo : function(){
this.codeMirror.redo();
},
undo : function(){
this.codeMirror.undo();
},
//----------------------//
render : function(){