2017-07-23 18:42:08 +00:00
|
|
|
<template>
|
|
|
|
<div class="editor">
|
2017-09-17 15:32:39 +00:00
|
|
|
<pre class="editor__inner markdown-highlighting" :style="{padding: styles.editorPadding}" :class="{monospaced: computedSettings.editor.monospacedFontOnly}"></pre>
|
2017-11-15 08:12:56 +00:00
|
|
|
<div class="gutter" :style="{left: styles.editorGutterLeft + 'px'}">
|
|
|
|
<comment-list v-if="styles.editorGutterWidth"></comment-list>
|
2018-03-12 00:45:54 +00:00
|
|
|
<editor-new-discussion-button v-if="!isCurrentTemp"></editor-new-discussion-button>
|
2017-11-15 08:12:56 +00:00
|
|
|
</div>
|
2017-07-23 18:42:08 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2017-07-31 09:04:01 +00:00
|
|
|
import { mapGetters } from 'vuex';
|
2017-11-15 08:12:56 +00:00
|
|
|
import CommentList from './gutters/CommentList';
|
|
|
|
import EditorNewDiscussionButton from './gutters/EditorNewDiscussionButton';
|
2018-09-19 08:59:22 +00:00
|
|
|
import store from '../store';
|
2017-07-23 18:42:08 +00:00
|
|
|
|
|
|
|
export default {
|
2017-11-10 23:39:51 +00:00
|
|
|
components: {
|
2017-11-15 08:12:56 +00:00
|
|
|
CommentList,
|
|
|
|
EditorNewDiscussionButton,
|
2017-11-10 23:39:51 +00:00
|
|
|
},
|
2017-09-17 15:32:39 +00:00
|
|
|
computed: {
|
2018-03-12 00:45:54 +00:00
|
|
|
...mapGetters('file', [
|
|
|
|
'isCurrentTemp',
|
|
|
|
]),
|
2017-09-17 15:32:39 +00:00
|
|
|
...mapGetters('layout', [
|
|
|
|
'styles',
|
|
|
|
]),
|
|
|
|
...mapGetters('data', [
|
|
|
|
'computedSettings',
|
|
|
|
]),
|
|
|
|
},
|
2017-11-10 23:39:51 +00:00
|
|
|
mounted() {
|
|
|
|
const editorElt = this.$el.querySelector('.editor__inner');
|
|
|
|
const onDiscussionEvt = cb => (evt) => {
|
|
|
|
let elt = evt.target;
|
|
|
|
while (elt && elt !== editorElt) {
|
|
|
|
if (elt.discussionId) {
|
|
|
|
cb(elt.discussionId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
elt = elt.parentNode;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-11-15 08:12:56 +00:00
|
|
|
const classToggler = toggle => (discussionId) => {
|
|
|
|
editorElt.getElementsByClassName(`discussion-editor-highlighting--${discussionId}`)
|
|
|
|
.cl_each(elt => elt.classList.toggle('discussion-editor-highlighting--hover', toggle));
|
|
|
|
document.getElementsByClassName(`comment--discussion-${discussionId}`)
|
|
|
|
.cl_each(elt => elt.classList.toggle('comment--hover', toggle));
|
|
|
|
};
|
|
|
|
|
|
|
|
editorElt.addEventListener('mouseover', onDiscussionEvt(classToggler(true)));
|
|
|
|
editorElt.addEventListener('mouseout', onDiscussionEvt(classToggler(false)));
|
2017-11-10 23:39:51 +00:00
|
|
|
editorElt.addEventListener('click', onDiscussionEvt((discussionId) => {
|
2018-09-19 08:59:22 +00:00
|
|
|
store.commit('discussion/setCurrentDiscussionId', discussionId);
|
2017-11-10 23:39:51 +00:00
|
|
|
}));
|
2017-11-15 08:12:56 +00:00
|
|
|
|
2017-11-10 23:39:51 +00:00
|
|
|
this.$watch(
|
2018-09-19 08:59:22 +00:00
|
|
|
() => store.state.discussion.currentDiscussionId,
|
2017-11-10 23:39:51 +00:00
|
|
|
(discussionId, oldDiscussionId) => {
|
|
|
|
if (oldDiscussionId) {
|
2017-11-15 08:12:56 +00:00
|
|
|
editorElt.querySelectorAll(`.discussion-editor-highlighting--${oldDiscussionId}`)
|
2017-11-10 23:39:51 +00:00
|
|
|
.cl_each(elt => elt.classList.remove('discussion-editor-highlighting--selected'));
|
|
|
|
}
|
|
|
|
if (discussionId) {
|
2017-11-15 08:12:56 +00:00
|
|
|
editorElt.querySelectorAll(`.discussion-editor-highlighting--${discussionId}`)
|
2017-11-10 23:39:51 +00:00
|
|
|
.cl_each(elt => elt.classList.add('discussion-editor-highlighting--selected'));
|
|
|
|
}
|
2018-05-06 00:46:33 +00:00
|
|
|
},
|
|
|
|
);
|
2017-11-10 23:39:51 +00:00
|
|
|
},
|
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-07-23 18:42:08 +00:00
|
|
|
|
|
|
|
.editor {
|
|
|
|
position: absolute;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
overflow: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.editor__inner {
|
2017-08-03 17:08:12 +00:00
|
|
|
margin: 0;
|
2017-07-25 18:20:52 +00:00
|
|
|
font-family: $font-family-main;
|
2017-07-23 18:42:08 +00:00
|
|
|
font-variant-ligatures: no-common-ligatures;
|
|
|
|
white-space: pre-wrap;
|
|
|
|
word-break: break-word;
|
|
|
|
word-wrap: break-word;
|
|
|
|
|
|
|
|
* {
|
2017-07-25 23:34:01 +00:00
|
|
|
line-height: $line-height-base;
|
2017-07-23 18:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.cledit-section {
|
|
|
|
font-family: inherit;
|
|
|
|
}
|
|
|
|
|
|
|
|
.hide {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.monospaced {
|
|
|
|
font-family: $font-family-monospace !important;
|
|
|
|
font-size: $font-size-monospace !important;
|
|
|
|
|
|
|
|
* {
|
|
|
|
font-size: inherit !important;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|