Class humhub\modules\content\widgets\richtext\AbstractRichTextEditor

Inheritancehumhub\modules\content\widgets\richtext\AbstractRichTextEditor » humhub\modules\ui\form\widgets\JsInputWidget » humhub\widgets\JsWidget » humhub\components\Widget » yii\base\Widget
Subclasseshumhub\modules\content\widgets\richtext\HumHubRichTextEditor, humhub\modules\content\widgets\richtext\ProsemirrorRichTextEditor, humhub\modules\content\widgets\richtext\RichTextField, humhub\widgets\RichtextField
Available since version1.3

Abstract class for RichTextEditor implementations.

Most RichTextEditor fields will use some kind of contenteditable element in combination with an underlying input field.

A RichTextEditor feature set may vary between implementations, and is ideally configurable for a single instance through plugin settings like:

  • $preset: select a preset as 'markdown', 'normal', 'full' or a custom preset provided by an other module
  • $plugins: set plugin options
  • ┬žincludes: include some additional plugins
  • $exclude: exclude some specific plugins

Some common plugin extensions are

  • placeholder
  • mention
  • oembed
  • emoji

This abstract class provides direct settings of some core plugins as $placeholder and $mentionUrl. Other plugin settings can be configured by means of the $plugins array.

To render the RichtText output for a given plain text use the static output() function, which internally will determine the configured RichText class to transform the text into the output format required by the RichText e.g. Markdown or directly HTML.

Note: the output() function by default is also used in editor edit mode with the edit flag set to true. Note: Some Richtext implementation may not support all mentioned features and plugins.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$attribute string The model attribute that this widget is associated with. humhub\modules\ui\form\widgets\JsInputWidget
$container string Html container element. humhub\widgets\JsWidget
$content string Html content. humhub\widgets\JsWidget
$disabled boolean humhub\modules\content\widgets\richtext\AbstractRichTextEditor
$disabledText string humhub\modules\content\widgets\richtext\AbstractRichTextEditor
$events [] humhub\widgets\JsWidget
$exclude array humhub\modules\content\widgets\richtext\AbstractRichTextEditor
$fadeIn boolean|string|integer humhub\widgets\JsWidget
$focus boolean humhub\modules\content\widgets\richtext\AbstractRichTextEditor
$form \yii\widgets\ActiveForm humhub\modules\ui\form\widgets\JsInputWidget
$id string humhub\widgets\JsWidget
$include array humhub\modules\content\widgets\richtext\AbstractRichTextEditor
$init mixed humhub\modules\content\widgets\richtext\AbstractRichTextEditor
$jsWidget string humhub\widgets\JsWidget
$label boolean Defines if the default label should be rendered. humhub\modules\content\widgets\richtext\AbstractRichTextEditor
$layout string Defines the style/layout of the richtext humhub\modules\content\widgets\richtext\AbstractRichTextEditor
$mentioningUrl string humhub\modules\content\widgets\richtext\AbstractRichTextEditor
$model \yii\base\Model The data model that this widget is associated with. humhub\modules\ui\form\widgets\JsInputWidget
$name string The input name. humhub\modules\ui\form\widgets\JsInputWidget
$options array The HTML attributes for the input tag. humhub\modules\ui\form\widgets\JsInputWidget
$placeholder string humhub\modules\content\widgets\richtext\AbstractRichTextEditor
$pluginOptions array humhub\modules\content\widgets\richtext\AbstractRichTextEditor
$preset string Richtext feature preset e. humhub\modules\content\widgets\richtext\AbstractRichTextEditor
$render boolean If set to false this widget won't be rendered humhub\components\Widget
$renderer [] Renderer class definition humhub\modules\content\widgets\richtext\AbstractRichTextEditor
$value string The input value. humhub\modules\ui\form\widgets\JsInputWidget
$visible boolean humhub\modules\content\widgets\richtext\AbstractRichTextEditor
$widgetLayout string Defines an optional layout humhub\components\Widget

Public Methods

Hide inherited methods

MethodDescriptionDefined By
beforeRun() Initializes the widget. humhub\modules\ui\form\widgets\JsInputWidget
getData() Returns an array of data-* attributes to configure your clientside js widget. humhub\modules\content\widgets\richtext\AbstractRichTextEditor
getId() Returns the html id of this widget, if no id is set this function will generate an id if $autoGenerate is set to true (default). humhub\widgets\JsWidget
getInputAttributes() humhub\modules\content\widgets\richtext\AbstractRichTextEditor
getLabel() humhub\modules\content\widgets\richtext\AbstractRichTextEditor
getLayoutViewParams() Returns an array of view parameter used if \humhub\components\layout is set. humhub\components\Widget
getMentioningUrl() humhub\modules\content\widgets\richtext\AbstractRichTextEditor
prepend() This method can be overwritten in order to prepend content after the actual rich text content. humhub\modules\content\widgets\richtext\AbstractRichTextEditor
process() Process is a wrapper for the run method humhub\components\Widget
run() humhub\modules\content\widgets\richtext\AbstractRichTextEditor
setDefaultOptions() Sets some default data options required by all widgets as the widget implementation and the widget events and initialization trigger. humhub\widgets\JsWidget
widget() Creates a widget instance and runs it. humhub\components\Widget

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
editOutput() Returns the content formatted for editing by means of the configured $renderer. humhub\modules\content\widgets\richtext\AbstractRichTextEditor
getAttributes() Returns all html attributes for used by this widget and will normally inserted in the widgets root html element. humhub\widgets\JsWidget
getOptions() Assembles all widget attributes and data settings of this widget. humhub\widgets\JsWidget
getValue() humhub\modules\ui\form\widgets\JsInputWidget
hasModel() humhub\modules\ui\form\widgets\JsInputWidget

Events

Hide inherited events

EventTypeDescriptionDefined By
EVENT_CREATE humhub\libs\WidgetCreateEvent An event raised before creating a widget. humhub\components\Widget

Property Details

$disabled public property
public boolean $disabled false
$disabledText public property
public string $disabledText false
$exclude public property
public array $exclude = []
$focus public property
public boolean $focus false
$include public property
public array $include = []
$init public property
public mixed $init true
$label public property

Defines if the default label should be rendered.

public boolean $label false
$layout public property

Defines the style/layout of the richtext

public string $layout self::LAYOUT_BLOCK
$mentioningRoute protected property
protected string $mentioningRoute "/user/search/mentioning"
$mentioningUrl public property
public string $mentioningUrl null
$placeholder public property
public string $placeholder null
$pluginOptions public property
public array $pluginOptions = []
$preset public property

Richtext feature preset e.g: 'markdown', 'normal', 'full'

public string $preset null
$renderer public static property

Renderer class definition

public static [] $renderer null
$visible public property
public boolean $visible true

Method Details

editOutput() protected method

Returns the content formatted for editing by means of the configured $renderer.

This function will call humhub\modules\content\widgets\richtext\RichText::output() with given richtext settings and edit = true.

protected string editOutput ( $content )
$content
getData() public method

Returns an array of data-* attributes to configure your clientside js widget.

Note that this function does not require to add the data- prefix. This will be done by Yii.

The data-* attributes should be inserted to the widgets root element.

public [] getData ( )
getInputAttributes() public method

public array getInputAttributes ( )
return array

Attributes added to the hidden textarea input of the richtext

getLabel() public method

public boolean|string getLabel ( )
return boolean|string

Returns the html label used for rendering

getMentioningUrl() public method

public string getMentioningUrl ( )
return string

Returns the url used by the mention plugin

prepend() public method

This method can be overwritten in order to prepend content after the actual rich text content.

public string prepend ( )
run() public method

public void run ( )