TinyMCE: different type of editor :full,minimal, no-toolbar, plain

This commit is contained in:
sparkyx 2025-10-17 10:18:40 +02:00
parent a28b1c7228
commit 4a5ad9a580
5 changed files with 66 additions and 27 deletions

View file

@ -53,9 +53,10 @@ class ITextarea extends HtmlInput
*/
public function set_enrichText($enrich)
{
if ( ! in_array($enrich,['plain','enrich',"min"])) {
throw new \Exception("IT57.Invalid option");
if ( ! in_array($enrich,['enrich','plain','full',"minimal","no-toolbar"])) {
throw new \Exception("IT57.Invalid option [$enrich]");
}
if ( $enrich == 'enrich') $enrich='full';
$this->enrichText = $enrich;
return $this;
}
@ -69,36 +70,26 @@ class ITextarea extends HtmlInput
$this->value=($p_value==null)?$this->value:$p_value;
$this->id=($this->id=="")?$this->name:$this->id;
if ( $this->readOnly==true) return $this->display();
if ( empty($this->id)) $this->id=$this->name;
if ( $this->enrichText == "plain" ) {
$r="";
$r.='<TEXTAREA '.$this->style.' name="'.$this->name.'" id="'.$this->id.'"';
$r.='>';
$r.=$this->value;
$r.="</TEXTAREA>";
} elseif ($this->enrichText=='enrich') {
if ( empty($this->id)) $this->id=$this->name;
} else {
$r=<<<EOF
<textarea name="{$this->name}" id="{$this->id}" {$this->style}>{$this->value}</textarea>
<script type="text/javascript">
(function() {
noalyss.activate_tinymce('{$this->name}','full');
})();
</script>
EOF;
}elseif ($this->enrichText=='min') {
if ( empty($this->id)) $this->id=$this->name;
$r=<<<EOF
<textarea name="{$this->name}" id="{$this->id}" {$this->style}>{$this->value}</textarea>
<script type="text/javascript">
(function() {
noalyss.activate_tinymce('{$this->name}','min');
noalyss.activate_tinymce('{$this->name}','{$this->enrichText}');
})();
</script>
EOF;
}
return $r;
}