Skip to content

Commit

Permalink
fix: Avoid absolute positioning in viewer
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliushaertl committed Aug 7, 2023
1 parent 246f158 commit 67f0101
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ export default {
</style>
<style lang="scss">
@import './../css/variables';
@import './../css/style';
@import './../css/print';
Expand Down
33 changes: 30 additions & 3 deletions src/components/ViewerComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
:share-token="shareToken"
:mime="mime"
:show-outline-outside="showOutlineOutside" />
<Component :is="readerComponent" v-else :content="content" />
<div v-else
id="editor-container"
data-text-el="editor-container"
class="text-editor source-viewer">
<Component :is="readerComponent" :content="content" />
</div>
</template>

<script>
Expand Down Expand Up @@ -102,6 +107,9 @@ export default {
},
watch: {
source() {
this.loadFileContent()
},
active() {
this.loadFileContent()
},
Expand All @@ -120,7 +128,7 @@ export default {
methods: {
async loadFileContent() {
if (!this.isEditable && this.content === '') {
if (!this.isEditable) {
const response = await axios.get(this.source)
this.content = response.data
this.contentLoaded = true
Expand All @@ -131,15 +139,34 @@ export default {
}
</script>
<style lang="scss" scoped>
.text-editor {
.text-editor:not(.viewer__file--hidden) {
overflow: scroll;
top: 0;
width: 100%;
max-width: 100%;
height: 100%;
left: 0;
margin: 0 auto;
position: relative;
background-color: var(--color-main-background);
&.source-viewer {
.text-editor__content-wrapper {
margin-top: var(--header-height);
}
}
}
</style>
<style lang="scss">
@import './../css/variables';
@media only screen and (max-width: 512px) {
// on mobile, modal-container has top: 50px
.text-editor {
top: auto;
}
}
.viewer[data-handler='text'] .modal-wrapper .modal-container {
bottom: 0;
}
</style>
8 changes: 1 addition & 7 deletions src/css/style.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
@use 'sass:math';

:root {
--text-editor-max-width: 670px
}

.modal-container .text-editor {
position: absolute;
}
@import './variables';

.ProseMirror-hideselection {
caret-color: transparent;
Expand Down
4 changes: 4 additions & 0 deletions src/css/variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:root {
--text-editor-max-width: 670px
}

0 comments on commit 67f0101

Please sign in to comment.