]> BookStack Code Mirror - bookstack/commitdiff
Lexical: Fixed issues with content not saving
authorDan Brown <redacted>
Thu, 27 Mar 2025 14:13:18 +0000 (14:13 +0000)
committerDan Brown <redacted>
Thu, 27 Mar 2025 14:13:18 +0000 (14:13 +0000)
Found that saving via Ctrl+Enter did not save as logic to load editor
output into form was bypassed, which this fixes by ensuring submit
events are raised during for this shortcut.

Submit handling also gets a timeout added since, at least in FF,
requestSubmit did not re-submit a form while in a submit event.

resources/js/components/page-editor.js
resources/js/components/wysiwyg-editor.js

index 64cd601a9203163dffc0141178390ca960a23da3..81378e944c045249a22a81913c120dbfd64a12db 100644 (file)
@@ -112,7 +112,7 @@ export class PageEditor extends Component {
     }
 
     savePage() {
-        this.container.closest('form').submit();
+        this.container.closest('form').requestSubmit();
     }
 
     async saveDraft() {
index 56dbe8d7c5f199d06a50facf5394d8e9a1034bc7..5a25819006913a5630d4664b5464e8420e5c8919 100644 (file)
@@ -25,6 +25,7 @@ export class WysiwygEditor extends Component {
                 textDirection: this.$opts.textDirection,
                 translations,
             });
+            window.wysiwyg = this.editor;
         });
 
         let handlingFormSubmit = false;
@@ -38,7 +39,9 @@ export class WysiwygEditor extends Component {
                 handlingFormSubmit = true;
                 this.editor.getContentAsHtml().then(html => {
                     this.input.value = html;
-                    this.input.form.submit();
+                    setTimeout(() => {
+                        this.input.form.requestSubmit();
+                    }, 5);
                 });
             } else {
                 handlingFormSubmit = false;