mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #8359 from creative-commoners/pulls/4/HTMLEditorSchema
Add schema information for HTMLEditorField
This commit is contained in:
commit
b555bb83b8
@ -224,4 +224,17 @@ abstract class HTMLEditorConfig
|
||||
* Initialise the editor on the client side
|
||||
*/
|
||||
abstract public function init();
|
||||
|
||||
/**
|
||||
* Provide additional schema data for the field this object configures
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getConfigSchemaData()
|
||||
{
|
||||
return [
|
||||
'attributes' => $this->getAttributes(),
|
||||
'editorjs' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace SilverStripe\Forms\HTMLEditor;
|
||||
|
||||
use SilverStripe\Assets\Shortcodes\ImageShortcodeProvider;
|
||||
use SilverStripe\Forms\FormField;
|
||||
use SilverStripe\Forms\TextareaField;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DataObjectInterface;
|
||||
@ -23,6 +24,10 @@ class HTMLEditorField extends TextareaField
|
||||
'Value' => 'HTMLText',
|
||||
];
|
||||
|
||||
protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_HTML;
|
||||
|
||||
protected $schemaComponent = 'HtmlEditorField';
|
||||
|
||||
/**
|
||||
* Use TinyMCE's GZIP compressor
|
||||
*
|
||||
@ -185,4 +190,12 @@ class HTMLEditorField extends TextareaField
|
||||
$this->getEditorConfig()->init();
|
||||
return parent::Field($properties);
|
||||
}
|
||||
|
||||
public function getSchemaStateDefaults()
|
||||
{
|
||||
$stateDefaults = parent::getSchemaStateDefaults();
|
||||
$config = $this->getEditorConfig();
|
||||
$stateDefaults['data'] = $config->getConfigSchemaData();
|
||||
return $stateDefaults;
|
||||
}
|
||||
}
|
||||
|
@ -751,6 +751,12 @@ class TinyMCEConfig extends HTMLEditorConfig
|
||||
Requirements::javascript($this->getScriptURL());
|
||||
}
|
||||
|
||||
public function getConfigSchemaData()
|
||||
{
|
||||
$data = parent::getConfigSchemaData();
|
||||
$data['editorjs'] = $this->getScriptURL();
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current tinyMCE language
|
||||
|
Loading…
Reference in New Issue
Block a user