diff --git a/public/assets/js/ui-editor.js b/public/assets/js/ui-editor.js index 6394455..aae3440 100644 --- a/public/assets/js/ui-editor.js +++ b/public/assets/js/ui-editor.js @@ -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 {} }; } diff --git a/src/ApiKernel.php b/src/ApiKernel.php index 4f7f24a..6e18be4 100644 --- a/src/ApiKernel.php +++ b/src/ApiKernel.php @@ -2248,7 +2248,9 @@ class ApiKernel if (!$libKinds) return true; if (preg_match($kindPattern, $html, $m)) { $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 (preg_match($jsonLibKindPattern, $html, $m)) { $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; } }