Class humhub\modules\content\widgets\richtext\AbstractRichTextEditor
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 theedit
flag set to true. Note: Some Richtext implementation may not support all mentioned features and plugins.
Public Properties
Protected Properties
Property | Type | Description | Defined By |
---|---|---|---|
$mentioningRoute | string | humhub\modules\content\widgets\richtext\AbstractRichTextEditor |
Public Methods
Protected Methods
Method | Description | Defined 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
Event | Type | Description | Defined By |
---|---|---|---|
EVENT_CREATE | humhub\libs\WidgetCreateEvent | An event raised before creating a widget. | humhub\components\Widget |
Constants
Constant | Value | Description | Defined By |
---|---|---|---|
LAYOUT_BLOCK | 'block' | humhub\modules\content\widgets\richtext\AbstractRichTextEditor | |
LAYOUT_INLINE | 'inline' | humhub\modules\content\widgets\richtext\AbstractRichTextEditor |
Property Details
Defines if the default label should be rendered.
Defines the style/layout of the richtext
Richtext feature preset e.g: 'markdown', 'normal', 'full'
Renderer class definition
Method Details
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 |
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 ( ) |
public array getInputAttributes ( ) | ||
return | array | Attributes added to the hidden textarea input of the richtext |
---|
public boolean|string getLabel ( ) | ||
return | boolean|string | Returns the html label used for rendering |
---|
public string getMentioningUrl ( ) | ||
return | string | Returns the url used by the mention plugin |
---|
This method can be overwritten in order to prepend content after the actual rich text content.
public string prepend ( ) |
public void run ( ) |