Löschen/Deaktiveunrg

This commit is contained in:
2026-02-01 02:05:32 +01:00
parent 2aebef3352
commit d0ff6cb426
2 changed files with 33 additions and 5 deletions

View File

@@ -155,13 +155,37 @@ export function initEditor() {
function attachGjsDirtyTracker(editor) {
if (!editor || typeof editor.on !== 'function') return () => {};
const onUpdate = () => markDirty();
let selectionJustChanged = false;
let selectionTimer = null;
const onSelect = () => {
selectionJustChanged = true;
if (selectionTimer) clearTimeout(selectionTimer);
selectionTimer = setTimeout(() => {
selectionJustChanged = false;
selectionTimer = null;
}, 120);
};
const onUpdate = () => {
if (selectionJustChanged) return;
markDirty();
};
const onComponentUpdate = (model) => {
const changed = (model && typeof model.changedAttributes === 'function')
? model.changedAttributes()
: (model && model.changed) ? model.changed : null;
const keys = changed ? Object.keys(changed) : [];
if (keys.length === 1 && keys[0] === 'status') return;
if (selectionJustChanged && keys.length === 0) return;
markDirty();
};
editor.on('update', onUpdate);
editor.on('component:update', onUpdate);
editor.on('component:update', onComponentUpdate);
editor.on('component:selected', onSelect);
return () => {
try {
editor.off('update', onUpdate);
editor.off('component:update', onUpdate);
editor.off('component:update', onComponentUpdate);
editor.off('component:selected', onSelect);
} catch {}
};
}