Skip to content
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
1 change: 0 additions & 1 deletion lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public function index(): TemplateResponse {
Util::addStyle(Application::APP_ID, 'grid');
Util::addStyle(Application::APP_ID, 'modal');
Util::addStyle(Application::APP_ID, 'tiptap');
Util::addStyle(Application::APP_ID, 'tables-style');

if (class_exists(LoadViewer::class)) {
$this->eventDispatcher->dispatchTyped(new LoadViewer());
Expand Down
28 changes: 25 additions & 3 deletions src/shared/components/ncEditor/NcEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export default {
textAppAvailable: !!window.OCA?.Text?.createEditor,
editor: null,
localValue: '',
observer: null,
initialized: false,
}
},

Expand Down Expand Up @@ -96,16 +98,36 @@ export default {

async mounted() {
this.localValue = this.text
await this.setupEditor()
this.editor?.setContent(this.localValue, false)
this.setupLazyInitialization()
},

beforeDestroy() {
this?.editor?.destroy()
this?.observer?.disconnect?.()
this?.editor?.destroy?.()
},

methods: {
t,
setupLazyInitialization() {
if (this.initialized) return

this.observer = new IntersectionObserver((entries) => {
for (const entry of entries) {
if (entry.isIntersecting && !this.initialized) {
this.initialized = true
this.setupEditor().then(() => {
this.editor?.setContent(this.localValue, false)
})
this.observer?.disconnect?.()
break
}
}
}, { rootMargin: '200px' })
this.$nextTick(() => {
const el = this.$el
if (el) this.observer.observe(el)
})
},
async setupEditor() {
this?.editor?.destroy()
if (this.textAppAvailable) {
Expand Down
Loading