(configuration as any).woltlabBbcode = bbcodes;
if (features.autosave !== "") {
- initializeAutosave(features.autosave, configuration);
+ initializeAutosave(element, configuration, features.autosave);
}
dispatchToCkeditor(element).setupConfiguration({
import { escapeHTML } from "../../StringUtil";
import type { ClassicEditor, EditorConfig } from "./Types";
-import { dispatchToCkeditor } from "./Event";
+import { dispatchToCkeditor, listenToCkeditor } from "./Event";
type Payload = {
html: string;
});
}
-export function initializeAutosave(autosave: string, configuration: EditorConfig): void {
+export function initializeAutosave(element: HTMLElement, configuration: EditorConfig, identifier: string): void {
removeExpiredDrafts();
configuration.autosave = {
save(editor) {
- saveDraft(autosave, editor.data.get());
+ saveDraft(identifier, editor.data.get());
return Promise.resolve();
},
waitingTime: 15_000,
};
+
+ listenToCkeditor(element).reset(() => deleteDraft(identifier));
}
const configuration = (0, Configuration_1.createConfigurationFor)(features);
configuration.woltlabBbcode = bbcodes;
if (features.autosave !== "") {
- (0, Autosave_1.initializeAutosave)(features.autosave, configuration);
+ (0, Autosave_1.initializeAutosave)(element, configuration, features.autosave);
}
(0, Event_1.dispatchToCkeditor)(element).setupConfiguration({
configuration,
}
});
}
- function initializeAutosave(autosave, configuration) {
+ function initializeAutosave(element, configuration, identifier) {
removeExpiredDrafts();
configuration.autosave = {
save(editor) {
- saveDraft(autosave, editor.data.get());
+ saveDraft(identifier, editor.data.get());
return Promise.resolve();
},
waitingTime: 15000,
};
+ (0, Event_1.listenToCkeditor)(element).reset(() => deleteDraft(identifier));
}
exports.initializeAutosave = initializeAutosave;
});