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

display content first and then load menus #2226

Merged
merged 2 commits into from
Mar 8, 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.

42 changes: 32 additions & 10 deletions src/components/EditorWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
{{ 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="tiptap && !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"
:sync-service="syncService"
Expand All @@ -44,6 +44,7 @@
:is-rich-editor="isRichEditor"
:is-public="isPublic"
:autohide="autohide"
:loaded.sync="menubarLoaded"
@show-help="showHelp">
<div id="editor-session-list">
<div v-tooltip="lastSavedStatusTooltip" class="save-status" :class="lastSavedStatusClass">
Expand All @@ -55,12 +56,13 @@
</div>
<slot name="header" />
</MenuBar>
<div v-if="!menubarLoaded" class="menubar placeholder" />
<div ref="contentWrapper" class="content-wrapper">
<MenuBubble v-if="tiptap && !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 @@ -170,12 +172,13 @@ export default {

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

saveStatusPolling: null,
displayHelp: false,
Expand Down Expand Up @@ -242,6 +245,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 @@ -416,7 +425,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 @@ -436,8 +445,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.readOnly) {
this.tiptap.commands.focus()
}
Expand Down Expand Up @@ -482,7 +491,7 @@ export default {
},

reconnect() {
this.initialLoading = false
this.contentLoaded = false
this.hasConnectionIssue = false
if (this.syncService) {
this.syncService.close().then(() => {
Expand Down Expand Up @@ -694,6 +703,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 @@ -313,6 +313,7 @@ export default {
clearInterval(this.checkInterval)
}
}, 100)
this.$emit('update:loaded', true)
},
beforeDestroy() {
window.removeEventListener('resize', this.getWindowWidth)
Expand Down