Skip to content

Commit 0b618ce

Browse files
authored
Merge pull request #7158 from nextcloud/backport/7130/stable31
[stable31] Refactor document status and menubar padding
2 parents e2de1a3 + edc1272 commit 0b618ce

File tree

10 files changed

+109
-25
lines changed

10 files changed

+109
-25
lines changed

cypress/e2e/conflict.spec.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ const variants = [
99
{ fixture: 'lines.txt', mime: 'text/plain' },
1010
{ fixture: 'test.md', mime: 'text/markdown' },
1111
]
12+
const getWrapper = () => cy.get('.text-editor__wrapper.has-conflicts')
1213

1314
variants.forEach(function({ fixture, mime }) {
1415
const user = randUser()
1516
const fileName = fixture
1617
const prefix = mime.replaceAll('/', '-')
1718
describe(`${mime} (${fileName})`, function() {
18-
const getWrapper = () => cy.get('.text-editor__wrapper.has-conflicts')
1919

2020
before(() => {
2121
cy.createUser(user)
@@ -117,6 +117,36 @@ variants.forEach(function({ fixture, mime }) {
117117
})
118118
})
119119

120+
describe('conflict dialog scroll behaviour', function() {
121+
const user = randUser()
122+
const fileName = 'long.md'
123+
124+
before(() => {
125+
cy.createUser(user)
126+
})
127+
128+
it('document status and collision resolution dialog elements are sticky', function() {
129+
cy.login(user)
130+
cy.createTestFolder()
131+
132+
createConflict(fileName, 'text/markdown')
133+
134+
cy.openFile(fileName)
135+
136+
cy.get('.text-editor .document-status')
137+
.should('contain', 'The file was overwritten.')
138+
getWrapper()
139+
.find('.text-editor__main h2')
140+
.contains('Third subheading')
141+
.scrollIntoView()
142+
143+
cy.get('.text-editor #resolve-conflicts')
144+
.should('be.visible')
145+
cy.get('.text-editor .document-status')
146+
.should('be.visible')
147+
})
148+
})
149+
120150
/**
121151
* @param {string} fileName - filename
122152
* @param {string} mime - mimetype

cypress/e2e/nodes/CodeBlock.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('Front matter support', function() {
7777
cy.getContent().find('code').eq(1).find('.hljs-keyword').eq(1).contains('function')
7878

7979
// Mermaid diagram
80-
cy.getEditor().find('.text-editor__wrapper').scrollTo('bottom')
80+
cy.get('#viewer .modal-container__content').scrollTo('bottom')
8181
cy.getContent().find('.split-view__preview').eq(2).should('be.visible')
8282
cy.get('.code-block').eq(2).find('code').should('not.be.visible')
8383
cy.get('.split-view__preview').find('svg .erDiagramTitleText')

cypress/fixtures/long.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Hello world
2+
3+
## First subheading
4+
5+
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
6+
7+
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
8+
9+
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
10+
11+
## Second subheading
12+
13+
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
14+
15+
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
16+
17+
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
18+
19+
## Third subheading
20+
21+
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.

src/components/CollisionResolveDialog.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ export default {
7070

7171
<style scoped lang="scss">
7272
#resolve-conflicts {
73+
position: sticky;
7374
display: flex;
75+
z-index: 1;
7476
margin: auto;
7577
padding: 0 var(--default-grid-baseline);
7678
button {

src/components/Editor.vue

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
ref="el"
99
data-text-el="editor-container"
1010
class="text-editor"
11+
:class="{ 'is-mobile': isMobile }"
1112
tabindex="-1"
1213
@keydown.stop="onKeyDown">
1314
<SkeletonLoading v-if="showLoadingSkeleton" />
@@ -55,12 +56,12 @@
5556
<Reader v-if="isResolvingConflict"
5657
:content="syncError.data.outsideChange"
5758
:is-rich-editor="isRichEditor" />
58-
<DocumentStatus :idle="idle"
59-
:lock="lock"
60-
:sync-error="syncError"
61-
:has-connection-issue="requireReconnect"
62-
@reconnect="reconnect" />
6359
</Wrapper>
60+
<DocumentStatus :idle="idle"
61+
:lock="lock"
62+
:sync-error="syncError"
63+
:has-connection-issue="requireReconnect"
64+
@reconnect="reconnect" />
6465
<Assistant v-if="hasEditor" />
6566
<Translate :show="translateModal"
6667
:content="translateContent"
@@ -259,6 +260,7 @@ export default {
259260
filteredSessions: {},
260261
261262
idle: false,
263+
lock: null,
262264
dirty: false,
263265
contentLoaded: false,
264266
syncError: null,
@@ -911,10 +913,18 @@ export default {
911913
.modal-container .text-editor {
912914
top: 0;
913915
height: calc(100vh - var(--header-height));
916+
917+
&.is-mobile {
918+
// TODO: Why is this required to prevent small scrolling container on mobile with short content?
919+
height: calc(
920+
100vh - var(--header-height) - 2 * var(--default-grid-baseline)
921+
);
922+
}
914923
}
915924
916925
.text-editor {
917-
display: block;
926+
display: flex;
927+
flex-direction: column;
918928
width: 100%;
919929
max-width: 100%;
920930
height: 100%;
@@ -925,7 +935,9 @@ export default {
925935
}
926936
927937
.text-editor .text-editor__wrapper.has-conflicts {
928-
height: calc(100% - 50px);
938+
// Make space for document status and conflict resolving dialog
939+
height: calc(100% - 48px - 54px);
940+
overflow-y: auto;
929941
}
930942
931943
#body-public {
@@ -955,9 +967,11 @@ export default {
955967
top: 0;
956968
opacity: 0;
957969
visibility: hidden;
958-
height: var(--default-clickable-area); // important for mobile so that the buttons are always inside the container
959-
padding-top:3px;
960-
padding-bottom: 3px;
970+
height: var(
971+
--default-clickable-area
972+
); // important for mobile so that the buttons are always inside the container
973+
border-bottom: 1px solid var(--color-border);
974+
padding-block: var(--default-grid-baseline);
961975
}
962976
963977
.text-editor--readonly-bar,
@@ -1000,7 +1014,10 @@ export default {
10001014
width: 50%;
10011015
#read-only-editor {
10021016
margin: 0px auto;
1003-
padding-top: 50px;
1017+
// Add height of the menubar as padding-top
1018+
padding-top: calc(
1019+
var(--default-clickable-area) + 2 * var(--default-grid-baseline)
1020+
);
10041021
overflow: initial;
10051022
}
10061023
}

src/components/Editor/DocumentStatus.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ export default {
7070

7171
<style scoped lang="scss">
7272
.document-status {
73-
position: absolute;
73+
position: sticky;
7474
bottom: calc(var(--default-grid-baseline) * 2);
7575
z-index: 100000;
7676
// max-height: 50px;
77-
margin: auto;
77+
margin-inline: auto;
7878
display: flex;
7979
width: 100%;
8080
justify-content: center;

src/components/Editor/MainContainer.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export default {
2929

3030
<style scoped lang="scss">
3131
.text-editor__main, .editor {
32+
display: flex;
33+
flex-direction: column;
3234
background: var(--color-main-background);
3335
color: var(--color-main-text);
3436
background-clip: padding-box;
@@ -37,4 +39,11 @@ export default {
3739
position: relative;
3840
width: 100%;
3941
}
42+
43+
.text-editor__main {
44+
&.is-mobile {
45+
flex-grow: 1;
46+
flex-direction: column-reverse;
47+
}
48+
}
4049
</style>

src/components/Editor/Wrapper.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default {
4848
props: {
4949
isResolvingConflict: {
5050
type: Boolean,
51-
require: true,
51+
default: false,
5252
},
5353
hasConnectionIssue: {
5454
type: Boolean,
@@ -130,16 +130,14 @@ export default {
130130
</script>
131131

132132
<style scoped lang="scss">
133-
134133
.text-editor__wrapper {
135134
display: flex;
135+
flex-grow: 1;
136+
136137
width: 100%;
137-
height: 100%;
138-
overflow: auto;
139138
140139
.ProseMirror {
141140
margin-top: 0 !important;
142141
}
143142
}
144-
145143
</style>

src/components/Menu/MenuBar.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
:class="{
1313
'text-menubar--ready': isReady,
1414
'text-menubar--hide': isHidden,
15-
'text-menubar--is-workspace': $isRichWorkspace
15+
'text-menubar--is-workspace': $isRichWorkspace,
16+
'is-mobile': $isMobile,
1617
}">
1718
<HelpModal v-if="displayHelp" @close="hideHelp" />
1819

@@ -227,20 +228,26 @@ export default {
227228
--background-blur: blur(10px);
228229
position: sticky;
229230
top: 0;
231+
bottom: var(--default-grid-baseline);
232+
width: 100%;
230233
z-index: 10021; // above modal-header so menubar is always on top
231234
background-color: var(--color-main-background-translucent);
232235
backdrop-filter: var(--background-blur);
233236
max-height: var(--default-clickable-area); // important for mobile so that the buttons are always inside the container
234237
border-bottom: 1px solid var(--color-border);
235-
padding-top:3px;
236-
padding-bottom: 3px;
238+
padding-block: var(--default-grid-baseline);
237239
238240
visibility: hidden;
239241
240242
display: flex;
241243
justify-content: flex-end;
242244
align-items: center;
243245
246+
&.is-mobile {
247+
border-top: 1px solid var(--color-border);
248+
border-bottom: unset;
249+
}
250+
244251
&.text-menubar--ready:not(.text-menubar--hide) {
245252
visibility: visible;
246253
animation-name: fadeInDown;

src/components/Menu/ReadonlyBar.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ export default defineComponent({
5555
<style scoped>
5656
.text-readonly-bar {
5757
display: flex;
58+
height: var(--default-clickable-area);
5859
border-bottom: 1px solid var(--color-border);
59-
padding-top: 3px;
60-
padding-bottom: 3px;
60+
padding-block: var(--default-grid-baseline);
6161
}
6262
.text-readonly-bar__entries {
6363
display: flex;

0 commit comments

Comments
 (0)