Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Being aware of the current editor context can be useful if you need to hit different URLs for content, do rendering or other things conditionally. The status information is retrievable in both frameworks integrating SPA development in Magnolia – Angular and ReactJS.

In Angular

Developer mode check

In the Angular framework, the status of an SPA page being in the developer mode can be checked by calling the isDevMode() function, which is part of the @angular/core library.

Editor/preview check (Angular and ReactJS)

To find out in Angular whether your SPA page is running in the page editor or in its page preview mode, inject

  • either the EditorContextService from the @magnolia/angular-editor,
  • or the EditorContextHelper from the @magnolia/react-editor,

depending on which framework you are using, Angular or ReactJS. respectively. You can then call the following functions to get the status:

  • inEditor()
  • inEditorPreview()

In ReactJS

Developer mode check

...

(Angular)

In the Angular framework,

...

the status of an SPA page being in the developer mode

...

can be checked by calling the isDevMode() function, which is part of the @angular/core library.

Developer mode check (ReactJS)

To retrieve the status of the developer mode in ReactJS,

After assigning static contextType = EditorContext you can call the following functions to get the status:

  • this.context.isDevMode

Editor/preview check

...

make sure that you import {

...

EditorContext} from the @magnolia/react-editor, and that the class of YourComponent extends the React.Component

After assigning static contextType = EditorContext you can call the following functions to get the status:

  • this.context.inEditor this.context.inEditorPreviewisDevMode