Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable23] display content first and then load menus #2228

Merged
merged 2 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/editor-rich.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor-rich.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/files-modal.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/files-modal.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions js/text-files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-files.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-text.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-text.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-viewer.js.map

Large diffs are not rendered by default.

44 changes: 33 additions & 11 deletions src/components/EditorWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@
{{ t('text', 'File could not be loaded. Please check your internet connection.') }} <a class="button primary" @click="reconnect">{{ t('text', 'Reconnect') }}</a>
</p>
</div>
<div v-if="displayed" id="editor-wrapper" :class="{'has-conflicts': hasSyncCollission, 'icon-loading': !initialLoading && !hasConnectionIssue, 'richEditor': isRichEditor, 'show-color-annotations': showAuthorAnnotations}">
<div id="editor">
<MenuBar v-if="!syncError && !readOnly"
<div v-if="displayed" id="editor-wrapper" :class="{'has-conflicts': hasSyncCollission, 'icon-loading': !contentLoaded && !hasConnectionIssue, 'richEditor': isRichEditor, 'show-color-annotations': showAuthorAnnotations}">
<div v-if="tiptap" id="editor">
<MenuBar v-if="renderMenus"
ref="menubar"
:editor="tiptap"
:file-path="relativePath"
:is-rich-editor="isRichEditor"
:is-public="isPublic"
:autohide="autohide">
:autohide="autohide"
:loaded.sync="menubarLoaded">
<div id="editor-session-list">
<div v-tooltip="lastSavedStatusTooltip" class="save-status" :class="lastSavedStatusClass">
{{ lastSavedStatus }}
Expand All @@ -52,12 +53,13 @@
</div>
<slot name="header" />
</MenuBar>
<div v-if="!menubarLoaded" class="menubar placeholder" />
<div ref="contentWrapper" class="content-wrapper">
<MenuBubble v-if="!readOnly && isRichEditor"
<MenuBubble v-if="renderMenus"
:editor="tiptap"
:content-wrapper="contentWrapper"
:file-path="relativePath" />
<EditorContent v-show="initialLoading"
<EditorContent v-show="contentLoaded"
class="editor__content"
:editor="tiptap" />
</div>
Expand Down Expand Up @@ -164,12 +166,13 @@ export default {

idle: false,
dirty: false,
initialLoading: false,
contentLoaded: false,
lastSavedString: '',
syncError: null,
hasConnectionIssue: false,
readOnly: true,
forceRecreate: false,
menubarLoaded: false,

saveStatusPolling: null,
contentWrapper: null,
Expand Down Expand Up @@ -232,6 +235,12 @@ export default {
displayed() {
return this.currentSession && this.active
},
renderMenus() {
return this.contentLoaded
&& this.isRichEditor
&& !this.syncError
&& !this.readOnly
},
},
watch: {
lastSavedStatus() {
Expand Down Expand Up @@ -404,7 +413,7 @@ export default {
.on('error', (error, data) => {
this.tiptap.setOptions({ editable: false })
if (error === ERROR_TYPE.SAVE_COLLISSION && (!this.syncError || this.syncError.type !== ERROR_TYPE.SAVE_COLLISSION)) {
this.initialLoading = true
this.contentLoaded = true
this.syncError = {
type: error,
data,
Expand All @@ -424,8 +433,8 @@ export default {
this.$emit('ready')
})
.on('stateChange', (state) => {
if (state.initialLoading && !this.initialLoading) {
this.initialLoading = true
if (state.initialLoading && !this.contentLoaded) {
this.contentLoaded = true
if (this.autofocus) {
this.tiptap.focus(1, 1)
}
Expand Down Expand Up @@ -470,7 +479,7 @@ export default {
},

reconnect() {
this.initialLoading = false
this.contentLoaded = false
this.hasConnectionIssue = false
if (this.syncService) {
this.syncService.close().then(() => {
Expand Down Expand Up @@ -673,6 +682,19 @@ export default {
padding-top: 50px;
}
}

.menubar.placeholder {
position: fixed;
position: -webkit-sticky;
position: sticky;
top: 0;
opacity: 0;
visibility: hidden;
height: 44px; // important for mobile so that the buttons are always inside the container
padding-top:3px;
padding-bottom: 3px;
}

</style>
<style lang="scss">
@import './../../css/style';
Expand Down
1 change: 1 addition & 0 deletions src/components/MenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export default {
clearInterval(this.checkInterval)
}
}, 100)
this.$emit('update:loaded', true)
},
beforeDestroy() {
window.removeEventListener('resize', this.getWindowWidth)
Expand Down