mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-07-03 08:04:29 -06:00
Merge pull request #6 from NextStepWebs/development
Disabled toolbar buttons during preview, Fix bugs
This commit is contained in:
commit
1c105115dd
2
simplemde.min.css
vendored
2
simplemde.min.css
vendored
File diff suppressed because one or more lines are too long
6
simplemde.min.js
vendored
6
simplemde.min.js
vendored
File diff suppressed because one or more lines are too long
@ -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,6 +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, '');
|
||||||
|
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,
|
||||||
@ -240,12 +242,16 @@ function togglePreview(editor) {
|
|||||||
preview.className += ' editor-preview-active'
|
preview.className += ' editor-preview-active'
|
||||||
}, 1);
|
}, 1);
|
||||||
toolbar.className += ' active';
|
toolbar.className += ' active';
|
||||||
|
toolbar_div.className += ' disabled-for-preview';
|
||||||
}
|
}
|
||||||
var text = cm.getValue();
|
var text = cm.getValue();
|
||||||
preview.innerHTML = parse(text);
|
preview.innerHTML = parse(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _replaceSelection(cm, active, start, end) {
|
function _replaceSelection(cm, active, start, end) {
|
||||||
|
if (/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
|
||||||
|
return;
|
||||||
|
|
||||||
var text;
|
var text;
|
||||||
var startPoint = cm.getCursor('start');
|
var startPoint = cm.getCursor('start');
|
||||||
var endPoint = cm.getCursor('end');
|
var endPoint = cm.getCursor('end');
|
||||||
@ -270,6 +276,9 @@ function _replaceSelection(cm, active, start, end) {
|
|||||||
|
|
||||||
|
|
||||||
function _toggleLine(cm, name) {
|
function _toggleLine(cm, name) {
|
||||||
|
if (/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
|
||||||
|
return;
|
||||||
|
|
||||||
var stat = getState(cm);
|
var stat = getState(cm);
|
||||||
var startPoint = cm.getCursor('start');
|
var startPoint = cm.getCursor('start');
|
||||||
var endPoint = cm.getCursor('end');
|
var endPoint = cm.getCursor('end');
|
||||||
@ -304,6 +313,9 @@ function _toggleLine(cm, name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _toggleBlock(editor, type, start_chars, end_chars) {
|
function _toggleBlock(editor, type, start_chars, end_chars) {
|
||||||
|
if (/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
|
||||||
|
return;
|
||||||
|
|
||||||
end_chars = (typeof end_chars === 'undefined') ? start_chars : end_chars;
|
end_chars = (typeof end_chars === 'undefined') ? start_chars : end_chars;
|
||||||
var cm = editor.codemirror;
|
var cm = editor.codemirror;
|
||||||
var stat = getState(cm);
|
var stat = getState(cm);
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
border-bottom-right-radius: 4px;
|
border-bottom-right-radius: 4px;
|
||||||
padding: 10px
|
padding: 10px
|
||||||
}
|
}
|
||||||
|
.CodeMirror-scroll {
|
||||||
|
min-height: 300px;
|
||||||
|
}
|
||||||
:-webkit-full-screen {
|
:-webkit-full-screen {
|
||||||
background: #f9f9f5;
|
background: #f9f9f5;
|
||||||
padding: .5em 1em;
|
padding: .5em 1em;
|
||||||
@ -96,6 +99,11 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
right: 10px
|
right: 10px
|
||||||
}
|
}
|
||||||
|
.editor-toolbar.disabled-for-preview a:not(.fa-eye){
|
||||||
|
pointer-events:none;
|
||||||
|
background:#fff;
|
||||||
|
border:none;
|
||||||
|
}
|
||||||
.editor-statusbar {
|
.editor-statusbar {
|
||||||
padding: 8px 10px;
|
padding: 8px 10px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
@ -120,7 +128,7 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
background: #fff;
|
background: #fafafa;
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
display: none
|
display: none
|
||||||
@ -256,6 +264,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {
|
|||||||
padding-bottom: 30px;
|
padding-bottom: 30px;
|
||||||
padding-right: 30px;
|
padding-right: 30px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
min-height: 300px;
|
||||||
outline: 0;
|
outline: 0;
|
||||||
position: relative
|
position: relative
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user