See if in preview or design mode in js

In a custom module for perspective, is there a way to see if you are in preview or design mode?

Its possible to see if we are in the designer or client, but is it also possible to see if we are in preview/design mode inside the designer?

I’d like to turn off some bits of my javascript during design mode. Is that possible?

1 Like

It looks like your frontend ComponentDesignDelegate should implement and return designerComponent(), and then we’ll automatically use a different component when you switch to/from design mode:

1 Like

Thx this is probably what i need, ill check if it works when i got time

Finally got the time to look into this.

Where to implement this? the ComponentMeta doesnt seem to be the right place xd
My next guess is web/packages/designer/ … unfortunatly there seems to be no example from this xd

So i came up with something like this…
components.forEach((c: ComponentDesignDelegate) => InteractionRegistry.registerInteractionDelegates(c));
similar to the registry of componentMetas, but this doesnt seem to do anything

Hmm, that looks correct:

Hmm i wonder what im doing wrong then :confused:

the

 ComponentMeta {
  getComponentType(){return TYPE}

matches the

ComponentDesignDelegate {
  type = TYPE;


Do they also have to be registered in the java designer/gatewayhook? If so how?

Ah, yeah, that might be it. DesignerHook for the Perspective module has getDesignerComponentRegistry(), which is essentially identical to the common ComponentRegistry; maybe try using that too.

1 Like

Something else came up so ill have to check later