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) { function attachGjsDirtyTracker(editor) {
if (!editor || typeof editor.on !== 'function') return () => {}; 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('update', onUpdate);
editor.on('component:update', onUpdate); editor.on('component:update', onComponentUpdate);
editor.on('component:selected', onSelect);
return () => { return () => {
try { try {
editor.off('update', onUpdate); editor.off('update', onUpdate);
editor.off('component:update', onUpdate); editor.off('component:update', onComponentUpdate);
editor.off('component:selected', onSelect);
} catch {} } catch {}
}; };
} }

View File

@@ -2248,7 +2248,9 @@ class ApiKernel
if (!$libKinds) return true; if (!$libKinds) return true;
if (preg_match($kindPattern, $html, $m)) { if (preg_match($kindPattern, $html, $m)) {
$kind = strtolower(trim((string)($m[2] ?? ''))); $kind = strtolower(trim((string)($m[2] ?? '')));
if ($kind !== '' && in_array($kind, $libKinds, true)) return true; if ($kind === '' || in_array($kind, $libKinds, true)) return true;
} else {
return true;
} }
} }
@@ -2258,7 +2260,9 @@ class ApiKernel
if (!$libKinds) return true; if (!$libKinds) return true;
if (preg_match($jsonLibKindPattern, $html, $m)) { if (preg_match($jsonLibKindPattern, $html, $m)) {
$kind = strtolower(trim((string)($m[1] ?? ''))); $kind = strtolower(trim((string)($m[1] ?? '')));
if ($kind !== '' && in_array($kind, $libKinds, true)) return true; if ($kind === '' || in_array($kind, $libKinds, true)) return true;
} else {
return true;
} }
} }