Stackedit/src/components/Preview.vue

62 lines
1.1 KiB
Vue
Raw Normal View History

2017-07-23 18:42:08 +00:00
<template>
<div class="preview">
2017-07-31 09:04:01 +00:00
<div class="preview__inner" :style="{ 'padding-left': styles.previewPadding + 'px', 'padding-right': styles.previewPadding + 'px' }">
2017-07-23 18:42:08 +00:00
</div>
</div>
</template>
<script>
2017-07-31 09:04:01 +00:00
import { mapGetters } from 'vuex';
2017-07-23 18:42:08 +00:00
const appUri = `${window.location.protocol}//${window.location.host}`;
export default {
2017-07-31 09:04:01 +00:00
computed: mapGetters('layout', [
'styles',
2017-07-23 18:42:08 +00:00
]),
mounted() {
this.$el.addEventListener('click', (evt) => {
let elt = evt.target;
while (elt !== this.$el) {
if (elt.href && elt.href.match(/^https?:\/\//)
&& (!elt.hash || elt.href.slice(0, appUri.length) !== appUri)) {
evt.preventDefault();
const wnd = window.open(elt.href, '_blank');
wnd.focus();
return;
}
elt = elt.parentNode;
}
});
},
};
</script>
<style lang="scss">
.preview {
position: absolute;
width: 100%;
height: 100%;
overflow: auto;
}
.preview__inner {
margin: 0;
padding: 0 1035px 360px;
}
2017-07-31 09:04:01 +00:00
.preview__inner > :first-child {
& > h1,
& > h2,
& > h3,
& > h4,
& > h5,
& > h6 {
&:first-child {
margin-top: 0;
}
}
}
2017-07-23 18:42:08 +00:00
</style>