2017-07-23 18:42:08 +00:00
|
|
|
<template>
|
2017-11-26 20:58:24 +00:00
|
|
|
<div class="layout" :class="{'layout--revision': revisionContent}">
|
2017-10-02 00:34:48 +00:00
|
|
|
<div class="layout__panel flex flex--row" :class="{'flex--end': styles.showSideBar}">
|
2017-11-15 08:12:56 +00:00
|
|
|
<div class="layout__panel layout__panel--explorer" v-show="styles.showExplorer" :aria-hidden="!styles.showExplorer" :style="{width: styles.layoutOverflow ? '100%' : constants.explorerWidth + 'px'}">
|
2017-07-28 20:04:12 +00:00
|
|
|
<explorer></explorer>
|
|
|
|
</div>
|
2018-01-21 00:11:05 +00:00
|
|
|
<div class="layout__panel flex flex--column" tour-step-anchor="welcome,end" :style="{width: styles.innerWidth + 'px'}">
|
2017-11-15 08:12:56 +00:00
|
|
|
<div class="layout__panel layout__panel--navigation-bar" v-show="styles.showNavigationBar" :style="{height: constants.navigationBarHeight + 'px'}">
|
2017-07-28 20:04:12 +00:00
|
|
|
<navigation-bar></navigation-bar>
|
|
|
|
</div>
|
2017-11-15 08:12:56 +00:00
|
|
|
<div class="layout__panel flex flex--row" :style="{height: styles.innerHeight + 'px'}">
|
|
|
|
<div class="layout__panel layout__panel--editor" v-show="styles.showEditor" :style="{width: (styles.editorWidth + styles.editorGutterWidth) + 'px', fontSize: styles.fontSize + 'px'}">
|
|
|
|
<div class="gutter" :style="{left: styles.editorGutterLeft + 'px'}">
|
|
|
|
<div class="gutter__background" v-if="styles.editorGutterWidth" :style="{width: styles.editorGutterWidth + 'px'}"></div>
|
2017-11-10 23:39:51 +00:00
|
|
|
</div>
|
2017-07-28 20:04:12 +00:00
|
|
|
<editor></editor>
|
2017-11-15 08:12:56 +00:00
|
|
|
<div class="gutter" :style="{left: styles.editorGutterLeft + 'px'}">
|
|
|
|
<sticky-comment v-if="styles.editorGutterWidth && stickyComment === 'top'"></sticky-comment>
|
|
|
|
<current-discussion v-if="styles.editorGutterWidth"></current-discussion>
|
|
|
|
</div>
|
2017-07-28 20:04:12 +00:00
|
|
|
</div>
|
2017-11-15 08:12:56 +00:00
|
|
|
<div class="layout__panel layout__panel--button-bar" v-show="styles.showEditor" :style="{width: constants.buttonBarWidth + 'px'}">
|
2017-07-23 18:42:08 +00:00
|
|
|
<button-bar></button-bar>
|
|
|
|
</div>
|
2017-11-15 08:12:56 +00:00
|
|
|
<div class="layout__panel layout__panel--preview" v-show="styles.showPreview" :style="{width: (styles.previewWidth + styles.previewGutterWidth) + 'px', fontSize: styles.fontSize + 'px'}">
|
|
|
|
<div class="gutter" :style="{left: styles.previewGutterLeft + 'px'}">
|
|
|
|
<div class="gutter__background" v-if="styles.previewGutterWidth" :style="{width: styles.previewGutterWidth + 'px'}"></div>
|
2017-11-10 23:39:51 +00:00
|
|
|
</div>
|
2017-07-23 18:42:08 +00:00
|
|
|
<preview></preview>
|
2017-11-15 08:12:56 +00:00
|
|
|
<div class="gutter" :style="{left: styles.previewGutterLeft + 'px'}">
|
|
|
|
<sticky-comment v-if="styles.previewGutterWidth && stickyComment === 'top'"></sticky-comment>
|
|
|
|
<current-discussion v-if="styles.previewGutterWidth"></current-discussion>
|
|
|
|
</div>
|
2017-07-23 18:42:08 +00:00
|
|
|
</div>
|
2018-01-14 16:27:06 +00:00
|
|
|
<div class="layout__panel layout__panel--find-replace" v-if="showFindReplace">
|
|
|
|
<find-replace></find-replace>
|
|
|
|
</div>
|
2017-07-23 18:42:08 +00:00
|
|
|
</div>
|
2017-11-15 08:12:56 +00:00
|
|
|
<div class="layout__panel layout__panel--status-bar" v-show="styles.showStatusBar" :style="{height: constants.statusBarHeight + 'px'}">
|
2017-07-28 20:04:12 +00:00
|
|
|
<status-bar></status-bar>
|
2017-07-23 18:42:08 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2017-11-15 08:12:56 +00:00
|
|
|
<div class="layout__panel layout__panel--side-bar" v-show="styles.showSideBar" :style="{width: styles.layoutOverflow ? '100%' : constants.sideBarWidth + 'px'}">
|
2017-07-28 20:04:12 +00:00
|
|
|
<side-bar></side-bar>
|
2017-07-23 18:42:08 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-03-12 00:45:54 +00:00
|
|
|
<tour v-if="!light && !layoutSettings.welcomeTourFinished"></tour>
|
2017-07-23 18:42:08 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2017-11-15 08:12:56 +00:00
|
|
|
import { mapState, mapGetters, mapActions } from 'vuex';
|
2017-07-23 18:42:08 +00:00
|
|
|
import NavigationBar from './NavigationBar';
|
|
|
|
import ButtonBar from './ButtonBar';
|
|
|
|
import StatusBar from './StatusBar';
|
2017-07-28 20:04:12 +00:00
|
|
|
import Explorer from './Explorer';
|
|
|
|
import SideBar from './SideBar';
|
2017-07-23 18:42:08 +00:00
|
|
|
import Editor from './Editor';
|
|
|
|
import Preview from './Preview';
|
2018-01-21 00:11:05 +00:00
|
|
|
import Tour from './Tour';
|
2017-11-15 08:12:56 +00:00
|
|
|
import StickyComment from './gutters/StickyComment';
|
|
|
|
import CurrentDiscussion from './gutters/CurrentDiscussion';
|
2017-11-04 16:59:48 +00:00
|
|
|
import FindReplace from './FindReplace';
|
2017-07-23 18:42:08 +00:00
|
|
|
import editorSvc from '../services/editorSvc';
|
2018-04-11 14:52:07 +00:00
|
|
|
import markdownConversionSvc from '../services/markdownConversionSvc';
|
2018-09-19 08:59:22 +00:00
|
|
|
import store from '../store';
|
2017-07-23 18:42:08 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
NavigationBar,
|
|
|
|
ButtonBar,
|
|
|
|
StatusBar,
|
2017-07-28 20:04:12 +00:00
|
|
|
Explorer,
|
|
|
|
SideBar,
|
2017-07-23 18:42:08 +00:00
|
|
|
Editor,
|
|
|
|
Preview,
|
2018-01-21 00:11:05 +00:00
|
|
|
Tour,
|
2017-11-15 08:12:56 +00:00
|
|
|
StickyComment,
|
|
|
|
CurrentDiscussion,
|
2017-11-04 16:59:48 +00:00
|
|
|
FindReplace,
|
2017-07-23 18:42:08 +00:00
|
|
|
},
|
2017-07-31 09:04:01 +00:00
|
|
|
computed: {
|
2018-03-12 00:45:54 +00:00
|
|
|
...mapState([
|
|
|
|
'light',
|
|
|
|
]),
|
2017-11-26 20:58:24 +00:00
|
|
|
...mapState('content', [
|
|
|
|
'revisionContent',
|
|
|
|
]),
|
2017-11-15 08:12:56 +00:00
|
|
|
...mapState('discussion', [
|
|
|
|
'stickyComment',
|
|
|
|
]),
|
2017-07-31 09:04:01 +00:00
|
|
|
...mapGetters('layout', [
|
2017-08-06 00:58:39 +00:00
|
|
|
'constants',
|
2017-07-31 09:04:01 +00:00
|
|
|
'styles',
|
|
|
|
]),
|
2018-01-21 00:11:05 +00:00
|
|
|
...mapGetters('data', [
|
|
|
|
'layoutSettings',
|
|
|
|
]),
|
2017-11-04 16:59:48 +00:00
|
|
|
showFindReplace() {
|
2018-09-19 08:59:22 +00:00
|
|
|
return !!store.state.findReplace.type;
|
2017-11-04 16:59:48 +00:00
|
|
|
},
|
2017-07-31 09:04:01 +00:00
|
|
|
},
|
2017-07-23 18:42:08 +00:00
|
|
|
methods: {
|
2017-11-05 20:54:12 +00:00
|
|
|
...mapActions('layout', [
|
2017-07-31 09:04:01 +00:00
|
|
|
'updateBodySize',
|
2017-07-23 18:42:08 +00:00
|
|
|
]),
|
|
|
|
saveSelection: () => editorSvc.saveSelection(true),
|
|
|
|
},
|
|
|
|
created() {
|
2018-04-11 14:52:07 +00:00
|
|
|
markdownConversionSvc.init(); // Needs to be inited before mount
|
2017-07-31 09:04:01 +00:00
|
|
|
this.updateBodySize();
|
|
|
|
window.addEventListener('resize', this.updateBodySize);
|
2017-07-23 18:42:08 +00:00
|
|
|
window.addEventListener('keyup', this.saveSelection);
|
|
|
|
window.addEventListener('mouseup', this.saveSelection);
|
2017-11-10 23:39:51 +00:00
|
|
|
window.addEventListener('focusin', this.saveSelection);
|
2017-07-23 18:42:08 +00:00
|
|
|
window.addEventListener('contextmenu', this.saveSelection);
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
const editorElt = this.$el.querySelector('.editor__inner');
|
2017-08-03 17:08:12 +00:00
|
|
|
const previewElt = this.$el.querySelector('.preview__inner-2');
|
2017-07-23 18:42:08 +00:00
|
|
|
const tocElt = this.$el.querySelector('.toc__inner');
|
|
|
|
editorSvc.init(editorElt, previewElt, tocElt);
|
2017-11-04 16:59:48 +00:00
|
|
|
|
|
|
|
// Focus on the editor every time reader mode is disabled
|
2018-03-15 13:51:39 +00:00
|
|
|
const focus = () => {
|
|
|
|
if (this.styles.showEditor) {
|
|
|
|
editorSvc.clEditor.focus();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
setTimeout(focus, 100);
|
|
|
|
this.$watch(() => this.styles.showEditor, focus);
|
2017-07-23 18:42:08 +00:00
|
|
|
},
|
|
|
|
destroyed() {
|
|
|
|
window.removeEventListener('resize', this.updateStyle);
|
2017-08-06 00:58:39 +00:00
|
|
|
window.removeEventListener('keyup', this.saveSelection);
|
|
|
|
window.removeEventListener('mouseup', this.saveSelection);
|
2017-11-10 23:39:51 +00:00
|
|
|
window.removeEventListener('focusin', this.saveSelection);
|
2017-08-06 00:58:39 +00:00
|
|
|
window.removeEventListener('contextmenu', this.saveSelection);
|
2017-07-23 18:42:08 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
2018-05-06 00:46:33 +00:00
|
|
|
@import '../styles/variables.scss';
|
2017-08-03 17:08:12 +00:00
|
|
|
|
2017-07-28 20:04:12 +00:00
|
|
|
.layout {
|
2017-07-23 18:42:08 +00:00
|
|
|
position: absolute;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
|
2017-07-28 20:04:12 +00:00
|
|
|
.layout__panel {
|
|
|
|
position: relative;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
flex: none;
|
2017-11-10 23:39:51 +00:00
|
|
|
overflow: hidden;
|
2017-07-23 18:42:08 +00:00
|
|
|
}
|
|
|
|
|
2017-07-28 20:04:12 +00:00
|
|
|
.layout__panel--navigation-bar {
|
2017-12-17 15:08:52 +00:00
|
|
|
background-color: $navbar-bg;
|
2017-07-23 18:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.layout__panel--status-bar {
|
|
|
|
background-color: #007acc;
|
|
|
|
}
|
|
|
|
|
2017-07-28 20:04:12 +00:00
|
|
|
.layout__panel--editor {
|
2018-01-14 16:27:06 +00:00
|
|
|
background-color: $editor-background-light;
|
2018-01-10 21:45:34 +00:00
|
|
|
|
|
|
|
.app--dark & {
|
|
|
|
background-color: $editor-background-dark;
|
|
|
|
}
|
2017-11-15 08:12:56 +00:00
|
|
|
|
|
|
|
.gutter__background,
|
|
|
|
.comment-list__current-discussion,
|
|
|
|
.sticky-comment,
|
|
|
|
.current-discussion {
|
2018-01-14 16:27:06 +00:00
|
|
|
background-color: mix(#000, $editor-background-light, 6.7%);
|
2018-01-10 21:45:34 +00:00
|
|
|
|
|
|
|
.app--dark & {
|
2018-01-14 16:27:06 +00:00
|
|
|
background-color: mix(#fff, $editor-background-dark, 6.7%);
|
2018-01-10 21:45:34 +00:00
|
|
|
}
|
2017-11-15 08:12:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-10 21:45:34 +00:00
|
|
|
$preview-background-light: #f3f3f3;
|
|
|
|
$preview-background-dark: #252525;
|
2017-11-15 08:12:56 +00:00
|
|
|
|
|
|
|
.layout__panel--preview,
|
|
|
|
.layout__panel--button-bar {
|
2018-01-14 16:27:06 +00:00
|
|
|
background-color: $preview-background-light;
|
2018-01-10 21:45:34 +00:00
|
|
|
|
|
|
|
.app--dark & {
|
|
|
|
background-color: $preview-background-dark;
|
|
|
|
}
|
2017-07-23 18:42:08 +00:00
|
|
|
}
|
|
|
|
|
2017-08-06 00:58:39 +00:00
|
|
|
.layout__panel--preview {
|
2017-11-15 08:12:56 +00:00
|
|
|
.gutter__background,
|
|
|
|
.comment-list__current-discussion,
|
|
|
|
.sticky-comment,
|
|
|
|
.current-discussion {
|
2018-01-10 21:45:34 +00:00
|
|
|
background-color: mix(#000, $preview-background-light, 6.7%);
|
2017-11-15 08:12:56 +00:00
|
|
|
}
|
2017-08-06 00:58:39 +00:00
|
|
|
}
|
|
|
|
|
2017-08-04 08:20:50 +00:00
|
|
|
.layout__panel--explorer,
|
|
|
|
.layout__panel--side-bar {
|
2018-04-07 15:00:31 +00:00
|
|
|
background-color: #ddd;
|
2017-07-28 07:40:24 +00:00
|
|
|
}
|
2017-11-04 16:59:48 +00:00
|
|
|
|
|
|
|
.layout__panel--find-replace {
|
|
|
|
background-color: #e6e6e6;
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
bottom: 0;
|
|
|
|
width: 300px;
|
|
|
|
height: auto;
|
|
|
|
border-top-right-radius: $border-radius-base;
|
|
|
|
}
|
2017-07-23 18:42:08 +00:00
|
|
|
</style>
|