ReactEditor
extends PluginBase
in package
NB: Deleting this class will break plugin API, since plugins then would have to extend PluginBase in the namespace instead of this class. This is especially a problem for plugins that should work on both 2.73 and 3.x, so please don't delete this class.
Table of Contents
Constants
- STG_NAME_REACT_EDITOR = "editorEnabled"
Properties
- $description : mixed
- $name : mixed
- $storage : mixed
Methods
- beforeAdminMenuRender() : void
- Append new menu item to the admin topbar
- beforeDeactivate() : mixed
- beforeRenderSurveySidemenu() : mixed
- renders the survey side-menu to link the classic editor to the React editor
- beforeSurveyAdminView() : void
- Validates theme compatibility when a survey is opened in the admin view.
- createUniqueWrongUrlFormatNotification() : void
- Creates a unique notification for the current user when the React editor is enabled but the URL format is not set to 'path'.
- init() : void
- initEditor() : mixed
- redirects to the React editor if it is enabled
- newDirectRequest() : void
- Saves if the users wants to activate or deactivate the new react editor
- redirectToDifferentCreateSurveyRoute() : void
- Change survey create url when editor is enabled
- renderActivateEditorModal() : void
- hasEditorSettingInDatabase() : bool
- Checks if the editorEnabled setting exists in settings_user table for current user
- hasPathUrlFormat() : bool
- Checks if the application's URL format is set to 'path'.
- isBackendAccess() : bool
- If user is a logged-in user we can assume, that backend is accessed right now.
- isEditorEnabled() : bool
- Checks if the React editor is enabled for the current user.
- warnIfIncompatibleTheme() : void
- Shows a warning flash message if the survey's effective theme is not compatible with the React editor.
Constants
STG_NAME_REACT_EDITOR
public
mixed
STG_NAME_REACT_EDITOR
= "editorEnabled"
Properties
$description
protected
static mixed
$description
= 'Activate/deactivate the new react editor'
$name
protected
static mixed
$name
= 'ReactEditor'
$storage
protected
mixed
$storage
= 'DbStorage'
Methods
beforeAdminMenuRender()
Append new menu item to the admin topbar
public
beforeAdminMenuRender() : void
beforeDeactivate()
public
beforeDeactivate() : mixed
beforeRenderSurveySidemenu()
renders the survey side-menu to link the classic editor to the React editor
public
beforeRenderSurveySidemenu() : mixed
beforeSurveyAdminView()
Validates theme compatibility when a survey is opened in the admin view.
public
beforeSurveyAdminView() : void
When the React editor is enabled, this method checks whether the survey is using the 'Fruity TwentyThree' theme. If a different theme is detected, a warning flash message is displayed to inform the user.
createUniqueWrongUrlFormatNotification()
Creates a unique notification for the current user when the React editor is enabled but the URL format is not set to 'path'.
public
createUniqueWrongUrlFormatNotification() : void
This method checks if the editor is enabled and if the URL format requirement is not met. If both conditions are true, it creates a high-importance notification informing the user about the URL format requirement for the React editor.
init()
public
init() : void
initEditor()
redirects to the React editor if it is enabled
public
initEditor() : mixed
newDirectRequest()
Saves if the users wants to activate or deactivate the new react editor
public
newDirectRequest() : void
Tags
redirectToDifferentCreateSurveyRoute()
Change survey create url when editor is enabled
public
redirectToDifferentCreateSurveyRoute() : void
Tags
renderActivateEditorModal()
public
renderActivateEditorModal() : void
hasEditorSettingInDatabase()
Checks if the editorEnabled setting exists in settings_user table for current user
private
hasEditorSettingInDatabase() : bool
Return values
boolhasPathUrlFormat()
Checks if the application's URL format is set to 'path'.
private
hasPathUrlFormat() : bool
This method verifies whether the URL manager is configured to use the 'path' format, which is required for the React editor to function properly.
Return values
bool —True if the URL format is 'path', false otherwise.
isBackendAccess()
If user is a logged-in user we can assume, that backend is accessed right now.
private
isBackendAccess() : bool
Return values
boolisEditorEnabled()
Checks if the React editor is enabled for the current user.
private
isEditorEnabled([bool $urlFormatCheck = true ]) : bool
This method first checks the user's settings in the database. If a user setting exists and the URL format requirement is met (when checked), it returns the user's preference. If no user setting exists, it falls back to the application's default configuration value, still respecting the URL format requirement.
Parameters
- $urlFormatCheck : bool = true
-
Whether to check if the URL format is set to 'path'. Defaults to true. When false, skips the URL format validation.
Return values
bool —True if the React editor is enabled and URL format requirements are met (when checked), false otherwise.
warnIfIncompatibleTheme()
Shows a warning flash message if the survey's effective theme is not compatible with the React editor.
private
warnIfIncompatibleTheme(Survey|null $survey) : void
If Survey::getTemplateEffectiveName() throws (e.g. when the survey inherits a missing group template), the exception is caught and the theme is treated as incompatible so the warning is still shown.
Parameters
- $survey : Survey|null