1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Changed autosave handling for better editor performance

This changes how the editors interact with the parent page-editor
compontent, which handles auto-saving.
Instead of blasting the full editor content upon any change to that
parent compontent, the editors just alert of a change, without the
content. The parent compontent then requests the editor content from the
editor component when it needs that data for an autosave.

For #3981
This commit is contained in:
Dan Brown
2023-02-23 12:30:27 +00:00
parent 31495758a9
commit 6545afacd6
5 changed files with 64 additions and 31 deletions

View File

@ -6,6 +6,10 @@ export class Actions {
*/
constructor(editor) {
this.editor = editor;
this.lastContent = {
html: '',
markdown: '',
};
}
updateAndRender() {
@ -13,11 +17,17 @@ export class Actions {
this.editor.config.inputEl.value = content;
const html = this.editor.markdown.render(content);
window.$events.emit('editor-html-change', html);
window.$events.emit('editor-markdown-change', content);
window.$events.emit('editor-html-change', '');
window.$events.emit('editor-markdown-change', '');
this.lastContent.html = html;
this.lastContent.markdown = content;
this.editor.display.patchWithHtml(html);
}
getContent() {
return this.lastContent;
}
insertImage() {
const cursorPos = this.editor.cm.getCursor('from');
/** @type {ImageManager} **/