Add a toolbar to Codemirror editor

Signed-off-by: Edgar Zanella Alvarenga <e@vaz.io>
This commit is contained in:
Edgar Zanella Alvarenga 2018-06-19 16:03:32 +02:00
parent 82c7f9d07c
commit a8b664fdb5
5 changed files with 202 additions and 0 deletions

View file

@ -30,6 +30,8 @@ import {
import {
debug,
DROPBOX_APP_KEY,
GOOGLE_API_KEY,
GOOGLE_CLIENT_ID,
noteid,
noteurl,
urlpath,
@ -566,6 +568,9 @@ var previousFocusOnEditor = null
function checkEditorStyle () {
var desireHeight = editorInstance.statusBar ? (ui.area.edit.height() - editorInstance.statusBar.outerHeight()) : ui.area.edit.height()
if (editorInstance.toolBar) {
desireHeight = desireHeight - editorInstance.toolBar.outerHeight()
}
// set editor height and min height based on scrollbar style and mode
var scrollbarStyle = editor.getOption('scrollbarStyle')
if (scrollbarStyle === 'overlay' || appState.currentMode === modeType.both) {
@ -804,6 +809,10 @@ function changeMode (type) {
editorInstance.addStatusBar()
editorInstance.updateStatusBar()
}
// add and update tool bar
if (!editorInstance.toolBar) {
editorInstance.addToolBar()
}
// work around foldGutter might not init properly
editor.setOption('foldGutter', false)
editor.setOption('foldGutter', true)