Lexical: Fixed issues with content not saving

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.
This commit is contained in:
Dan Brown 2025-03-27 14:13:18 +00:00
parent 0ec0913846
commit 5c6671b3bf
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
2 changed files with 5 additions and 2 deletions
resources/js/components

@ -112,7 +112,7 @@ export class PageEditor extends Component {
}
savePage() {
this.container.closest('form').submit();
this.container.closest('form').requestSubmit();
}
async saveDraft() {

@ -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;