diff --git a/prose/prose.js b/prose/prose.js index cb39c6d..964688f 100644 --- a/prose/prose.js +++ b/prose/prose.js @@ -118,3 +118,4 @@ class ProseMirrorView { let place = document.querySelector("#editor"); let view = new ProseMirrorView(place, $content.value); +window.editorView = view; diff --git a/templates/classic.tmpl b/templates/classic.tmpl index 58f82c7..b3029f1 100644 --- a/templates/classic.tmpl +++ b/templates/classic.tmpl @@ -348,13 +348,27 @@ } catch (e) {} }; var fonts = document.querySelectorAll('nav#font-picker a.font'); + var setFontClass = function(fontClass) { + return (state, dispatch) => { + if (dispatch && window.editorView) { + window.editorView.view.dom.classList.remove("norm", "sans", "wrap"); + window.editorView.view.dom.classList.add(fontClass); + } + return true; + } + } + var changeEditorFont = function(fontClass) { + if (window.editorView) { + const command = setFontClass(fontClass); + command(window.editorView.view.state, window.editorView.view.dispatch); + } + }; for (var i=0; i {changeEditorFont(selectedFont)}); var sfe = document.querySelector('nav#font-picker a.font.'+selectedFont); if (sfe != null) { sfe.click();