From bef825c4e0bc64a8dcee69d78f60b6abc9872e02 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Sat, 3 Oct 2026 13:33:14 +0300 Subject: [PATCH] optimize add list style --- .../template_builder/dynamic_document.vue | 23 +- .../template_builder/dynamic_insert_menu.vue | 334 ++++++++---------- .../template_builder/dynamic_menu.vue | 4 +- .../template_builder/dynamic_section.vue | 91 +++-- 4 files changed, 218 insertions(+), 234 deletions(-) diff --git a/app/javascript/template_builder/dynamic_document.vue b/app/javascript/template_builder/dynamic_document.vue index c87ad5b07..4408d2d84 100644 --- a/app/javascript/template_builder/dynamic_document.vue +++ b/app/javascript/template_builder/dynamic_document.vue @@ -51,6 +51,7 @@ @add-custom-field="$emit('add-custom-field', $event)" @set-draw="$emit('set-draw', $event)" @add-attachment="document.attachments.push($event)" + @add-list="ensureListsStyle" /> @@ -189,15 +190,8 @@ export default { } } }, - watch: { - bodyDom: { - immediate: true, - handler () { - this.listsStyle = this.bodyDom.querySelector('body > style[data-lists]')?.textContent || null - - this.ensureListsStyle(this.bodyDom) - } - } + created () { + this.loadListsStyle() }, mounted () { this.isMounted = true @@ -244,6 +238,8 @@ export default { } }, reloadContent () { + this.loadListsStyle() + this.sectionRefs.forEach((ref) => ref.reloadContent()) }, onBeforeUnload (event) { @@ -269,8 +265,6 @@ export default { }) }, onSectionUpdate (section, { editor }) { - this.ensureListsStyle(editor.view.dom) - clearTimeout(this.saveTimer) this.saveTimer = setTimeout(async () => { @@ -279,8 +273,11 @@ export default { delete this.saveTimer }, 1000) }, - ensureListsStyle (root) { - if (this.listsStyle || !root.querySelector('[class*="doc-list-"]')) return + loadListsStyle () { + this.listsStyle = this.bodyDom.querySelector('body > style[data-lists]')?.textContent || null + }, + ensureListsStyle () { + if (this.listsStyle) return const style = this.bodyDom.createElement('style') diff --git a/app/javascript/template_builder/dynamic_insert_menu.vue b/app/javascript/template_builder/dynamic_insert_menu.vue index ae328914e..62656b89d 100644 --- a/app/javascript/template_builder/dynamic_insert_menu.vue +++ b/app/javascript/template_builder/dynamic_insert_menu.vue @@ -1,185 +1,159 @@