scrivito
Version:
Scrivito is a professional, yet easy to use SaaS Enterprise Content Management Service, built for digital agencies and medium to large businesses. It is completely maintenance-free, cost-effective, and has unprecedented performance and security.
33 lines (24 loc) • 917 B
text/typescript
import { uiAdapter } from 'scrivito_sdk/app_support/ui_adapter';
import { equals, onReset } from 'scrivito_sdk/common';
import { BasicWidget } from 'scrivito_sdk/models';
let widgetHighlightingEnabled = false;
export function toggleWidgetHighlighting(value: boolean): void {
widgetHighlightingEnabled = value;
}
// Exported for test purposes only
export function isWidgetHighlightingEnabled(): boolean {
return !!widgetHighlightingEnabled;
}
export function isWidgetHighlighted(widget: BasicWidget): boolean {
if (!isWidgetHighlightingEnabled()) return false;
const highlightedWidget = uiAdapter?.getHighlightedWidget();
if (!highlightedWidget) return false;
return (
highlightedWidget.objId === widget.obj().id() &&
highlightedWidget.widgetId === widget.id() &&
equals(highlightedWidget.objSpaceId, widget.objSpaceId())
);
}
onReset(() => {
widgetHighlightingEnabled = false;
});