|
|
@ -216,6 +216,7 @@ function redo(editor) {
|
|
|
|
* Preview action.
|
|
|
|
* Preview action.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function togglePreview(editor) {
|
|
|
|
function togglePreview(editor) {
|
|
|
|
|
|
|
|
var toolbar_div = document.getElementsByClassName('editor-toolbar')[0];
|
|
|
|
var toolbar = editor.toolbar.preview;
|
|
|
|
var toolbar = editor.toolbar.preview;
|
|
|
|
var parse = editor.constructor.markdown;
|
|
|
|
var parse = editor.constructor.markdown;
|
|
|
|
var cm = editor.codemirror;
|
|
|
|
var cm = editor.codemirror;
|
|
|
@ -231,7 +232,7 @@ function togglePreview(editor) {
|
|
|
|
/\s*editor-preview-active\s*/g, ''
|
|
|
|
/\s*editor-preview-active\s*/g, ''
|
|
|
|
);
|
|
|
|
);
|
|
|
|
toolbar.className = toolbar.className.replace(/\s*active\s*/g, '');
|
|
|
|
toolbar.className = toolbar.className.replace(/\s*active\s*/g, '');
|
|
|
|
editor.toolbar.className = editor.toolbar.className.replace(/\s*disabled-for-preview\s*/g, '');
|
|
|
|
toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview\s*/g, '');
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
/* When the preview button is clicked for the first time,
|
|
|
|
/* When the preview button is clicked for the first time,
|
|
|
|
* give some time for the transition from editor.css to fire and the view to slide from right to left,
|
|
|
|
* give some time for the transition from editor.css to fire and the view to slide from right to left,
|
|
|
@ -241,7 +242,7 @@ function togglePreview(editor) {
|
|
|
|
preview.className += ' editor-preview-active'
|
|
|
|
preview.className += ' editor-preview-active'
|
|
|
|
}, 1);
|
|
|
|
}, 1);
|
|
|
|
toolbar.className += ' active';
|
|
|
|
toolbar.className += ' active';
|
|
|
|
editor.toolbar.className += ' disabled-for-preview';
|
|
|
|
toolbar_div.className += ' disabled-for-preview';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var text = cm.getValue();
|
|
|
|
var text = cm.getValue();
|
|
|
|
preview.innerHTML = parse(text);
|
|
|
|
preview.innerHTML = parse(text);
|
|
|
|