File modules/template_engine/components/html/component_editor/EditorComponent.class.php
Last commit: Mon Apr 12 23:46:06 2021 +0200 Jan Dankert New: Smaller CSS-Files, because third-party-CSS (editors...) is loaded dynamically if necessary.
1 <?php 2 3 namespace template_engine\components\html\component_editor; 4 5 use template_engine\components\html\FieldComponent; 6 use template_engine\element\CMSElement; 7 use template_engine\element\HtmlElement; 8 use template_engine\element\Value; 9 use template_engine\element\ValueExpression; 10 11 class EditorComponent extends FieldComponent 12 { 13 public $type; 14 public $name; 15 public $default; 16 public $mode ='htmlmixed'; 17 public $extension =''; 18 public $mimetype = ''; 19 20 public function createElement() 21 { 22 $textarea = new CMSElement('textarea'); 23 $textarea->addAttribute('name',$this->name); 24 25 $textarea->addStyleClass('input')->addStyleClass('editor')->setEscaping(false); 26 27 switch( $this->type ) 28 { 29 case 'html': 30 $textarea->addStyleClass('html-editor')->addAttribute('id','pageelement_edit_editor'); 31 32 33 break; 34 35 case 'wiki': 36 $textarea->addStyleClass('wiki-editor'); 37 break; 38 39 case 'text': 40 case 'raw': 41 $textarea->addStyleClass('text-editor'); 42 break; 43 44 case 'markdown': 45 $textarea->setEscaping(true)->addStyleClass('markdown-editor'); 46 break; 47 48 case 'code': 49 $textarea->setEscaping(true); 50 $textarea->addStyleClass('code-editor') 51 ->addAttribute('data-extension',$this->extension) 52 ->addAttribute('data-mimetype',$this->mimetype) 53 ->addAttribute('data-mode',$this->mode); 54 break; 55 56 57 default: 58 throw new \LogicException("Unknown editor type: ".$this->type); 59 } 60 61 if ( $this->default ) 62 $textarea->content( $this->default ); 63 else 64 $textarea->content(Value::createExpression(ValueExpression::TYPE_DATA_VAR,$this->name)); 65 66 $trix = (new HtmlElement('trix-editor'))->addAttribute('input',$this->name); 67 68 return (new HtmlElement('div'))->addChild( $textarea )->addChild( $trix ); 69 } 70 }
Downloadmodules/template_engine/components/html/component_editor/EditorComponent.class.php
History Mon, 12 Apr 2021 23:46:06 +0200 Jan Dankert New: Smaller CSS-Files, because third-party-CSS (editors...) is loaded dynamically if necessary. Thu, 25 Feb 2021 01:22:10 +0100 Jan Dankert New: Edit all page elements in 1 view. Wed, 14 Oct 2020 22:36:29 +0200 Jan Dankert Refactoring: Fixed the namespace in component classes, now the are able to be load by the standard autoloader. Wed, 14 Oct 2020 22:20:22 +0200 Jan Dankert Refactoring: Renamed component folders, because 'if' is no valid namespace fragment.