Abstract Class humhub\modules\content\widgets\richtext\RichText

Inheritancehumhub\modules\content\widgets\richtext\RichText » humhub\modules\content\widgets\richtext\AbstractRichText » humhub\widgets\JsWidget » humhub\components\Widget » yii\base\Widget
Available since version1.2

This class together with the humhub\modules\content\widgets\richtext\RichTextField class act as wrapper around the globally configured humhub\modules\content\widgets\richtext\AbstractRichText implementation and related humhub\modules\content\widgets\richtext\AbstractRichTextEditor as well as humhub\modules\content\widgets\richtext\AbstractRichTextProcessor by means of the configuration parameter richText.

This class should be used in favor of the actual humhub\modules\content\widgets\richtext\AbstractRichText implementations in order to be able to replace the default rich text on demand.

A rich text editor field can be added to a form as follows:

$form->field($model, 'richTextField')->widget(RichTextField::class);

This will render a rich text editor field related to the globally configured rich text implementation. After submitting and saving the model record holding the rich text, the postProcess() function should be called usually within the afterSave() function of the content record:

RichText::postProcess($this->richTextField, $this);

This will parse the rich text for features which require post-processing as Mentionings or Oembed.

The following line then can be used in a view to render the rich text output:

RichText::output($model->richTextField);

A preview of the rich text can be rendered as follows:

RichText::widget(['text' => $model->richTextField, 'minimal' => true, 'maxLength' => 60])

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$container string Html container element. humhub\widgets\JsWidget
$content string Html content. humhub\widgets\JsWidget
$edit boolean Enables the edit rendering mode humhub\modules\content\widgets\richtext\AbstractRichText
$encode boolean humhub\modules\content\widgets\richtext\AbstractRichText
$events [] humhub\widgets\JsWidget
$exclude array Can be used to exclude specific plugins from the set of defaults (preset) humhub\modules\content\widgets\richtext\AbstractRichText
$fadeIn boolean|string|integer humhub\widgets\JsWidget
$id string humhub\widgets\JsWidget
$include array Can be used to explicitly include specific plugins in addition to the set of defaults (preset) humhub\modules\content\widgets\richtext\AbstractRichText
$init mixed humhub\modules\content\widgets\richtext\AbstractRichText
$jsWidget string humhub\widgets\JsWidget
$markdown boolean Defines if this rich text is also used as client side markdown text. humhub\modules\content\widgets\richtext\AbstractRichText
$maxLength integer Setting used to truncate the rich text content, usually related to $minimal mode and used for previews humhub\modules\content\widgets\richtext\AbstractRichText
$minimal boolean Enables the minimal rendering mode used for example for previews, this mode should take the \humhub\modules\content\widgets\richtext\maxLenght setting into account for truncating the preview content. humhub\modules\content\widgets\richtext\AbstractRichText
$options humhub\widgets\JsWidget
$pluginOptions array Rich text plugin settings. humhub\modules\content\widgets\richtext\AbstractRichText
$preset string Defines a preset of rich text features and settings humhub\modules\content\widgets\richtext\AbstractRichText
$record mixed Can be used to identify the related record humhub\modules\content\widgets\richtext\AbstractRichText
$render boolean If set to false this widget won't be rendered humhub\components\Widget
$text string Text to display humhub\modules\content\widgets\richtext\AbstractRichText
$visible boolean humhub\widgets\JsWidget

Public Methods

Hide inherited methods

MethodDescriptionDefined By
editorWidget() humhub\modules\content\widgets\richtext\AbstractRichText
getData() Returns an array of data-* attributes to configure your clientside js widget. humhub\modules\content\widgets\richtext\AbstractRichText
getEditorClass() humhub\modules\content\widgets\richtext\RichText
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
getProcessor() humhub\modules\content\widgets\richtext\AbstractRichText
getProcessorClass() humhub\modules\content\widgets\richtext\RichText
init() humhub\modules\content\widgets\richtext\AbstractRichText
output() Renders the given text by means of the given config. humhub\modules\content\widgets\richtext\AbstractRichText
postProcess() Used for the post-processing of the rich text, normally called within humhub\modules\content\components\ContentActiveRecord::afterSave() of the related humhub\modules\content\components\ContentActiveRecord. humhub\modules\content\widgets\richtext\AbstractRichText
preview() Renders the given text in minimal render mode truncated by the maxLength parameter. humhub\modules\content\widgets\richtext\AbstractRichText
process() Process is a wrapper for the run method humhub\components\Widget
run() Default implementation of JsWidget. humhub\widgets\JsWidget
setDefaultOptions() Sets some default data options required by all widgets as the widget implementation and the widget evetns and initialization trigger. humhub\widgets\JsWidget
widget() Renders the rich text output by determining the configured rich text class. humhub\modules\content\widgets\richtext\RichText

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
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

Events

Hide inherited events

EventTypeDescriptionDefined By
EVENT_BEFORE_OUTPUT \humhub\modules\search\events\ParameterEvent With parameter 'output' humhub\modules\content\widgets\richtext\AbstractRichText
EVENT_CREATE humhub\libs\WidgetCreateEvent An event raised before creating a widget. humhub\components\Widget
EVENT_POST_PROCESS humhub\components\Event An event raised after the post-process phase of the rich text. humhub\modules\content\widgets\richtext\AbstractRichText

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
PRESET_DOCUMENT 'document' humhub\modules\content\widgets\richtext\AbstractRichText

Method Details

getEditorClass() public static method

public static string getEditorClass ( )
getProcessorClass() public static method

public static string getProcessorClass ( )
widget() public static method

Renders the rich text output by determining the configured rich text class.

public static void widget ( $config = [] )
$config