Preview without fullscreen

pull/196/head
Nick Denry 4 years ago
parent 41fef9ae3e
commit b7093dabc3

@ -31,6 +31,11 @@
width: 50% !important; width: 50% !important;
} }
.CodeMirror-sided--no-fullscreen {
position: relative;
float: left;
}
.CodeMirror-placeholder { .CodeMirror-placeholder {
opacity: .5; opacity: .5;
} }
@ -195,6 +200,10 @@
text-align: right; text-align: right;
} }
.editor-statusbar.sided--no-fullscreen {
clear: both;
}
.editor-statusbar span { .editor-statusbar span {
display: inline-block; display: inline-block;
min-width: 4em; min-width: 4em;
@ -243,6 +252,14 @@
display: block display: block
} }
.editor-preview-active-side--no-fullscreen {
height: auto;
position: static;
min-height: calc(300px + 22px);
width: calc(50% - 0px);
float: right;
}
.editor-preview-active { .editor-preview-active {
display: block display: block
} }

@ -858,6 +858,18 @@ function toggleSideBySide(editor) {
var toolbarButton = editor.toolbarElements && editor.toolbarElements['side-by-side']; var toolbarButton = editor.toolbarElements && editor.toolbarElements['side-by-side'];
var useSideBySideListener = false; var useSideBySideListener = false;
if (/editor-preview-active-side/.test(preview.className)) { if (/editor-preview-active-side/.test(preview.className)) {
if (cm.getOption('sideBySideFullscreen')) {
cm.setOption('sideBySideFullscreen', false);
wrapper.className = wrapper.className.replace(
/\s*CodeMirror-sided--no-fullscreen\s*/g, ''
);
preview.className = preview.className.replace(
/\s*editor-preview-active-side--no-fullscreen\s*/g, ''
);
editor.gui.statusbar.className = editor.gui.statusbar.className.replace(
/\s*sided--no-fullscreen\s*/g, ''
);
}
preview.className = preview.className.replace( preview.className = preview.className.replace(
/\s*editor-preview-active-side\s*/g, '' /\s*editor-preview-active-side\s*/g, ''
); );
@ -868,8 +880,16 @@ function toggleSideBySide(editor) {
// 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,
// instead of just appearing. // instead of just appearing.
setTimeout(function () { setTimeout(function () {
if (!cm.getOption('fullScreen')) if (!cm.getOption('fullScreen')) {
toggleFullScreen(editor); if (editor.options.sideBySideFullscreen === false) {
cm.setOption('sideBySideFullscreen', true);
wrapper.className += ' CodeMirror-sided--no-fullscreen';
preview.className += ' editor-preview-active-side--no-fullscreen';
editor.gui.statusbar.className += ' sided--no-fullscreen';
} else {
toggleFullScreen(editor);
}
}
preview.className += ' editor-preview-active-side'; preview.className += ' editor-preview-active-side';
}, 1); }, 1);
if (toolbarButton) toolbarButton.className += ' active'; if (toolbarButton) toolbarButton.className += ' active';

Loading…
Cancel
Save