Merge branch '251014-enrich' into 251011-einvoice

* 251014-enrich:
  NOALYSS: use TinyMCE
This commit is contained in:
sparkyx 2025-10-14 17:26:57 +02:00
commit eba3d6f5c8
3 changed files with 80 additions and 10 deletions

View file

@ -130,7 +130,7 @@ function id$(ID) {
} else if (document.all) {
return document.all[ID];
} else {
document.debug_noalyss&&console.error(`id$ ${ID}`)
document.debug_noalyss&&console.error(`id$ ${ID} not found`)
return undefined;
}
}
@ -4713,4 +4713,66 @@ Widget.prototype.toggle_full_size=function (widget_domid) {
(function(){window.addEventListener("onload", (event) => {remove_waiting_box()});})();
*/
var bookmark=new Bookmark();
//var bookmark=new Bookmark();
Noalyss = function () {
}
/**
* Activate TinyMCE
* @param {string} domid id of the dom element
* @param {string} mode min for minimum or full , gives an error if the mode doesn't exist
* @returns {undefined}
*/
Noalyss.prototype.activate_tinymce=function (domid,mode) {
tinymce.remove('#'+domid);
if ( mode == 'min' || ! mode )
{
tinymce.init({
selector: 'textarea#'+domid,
height: 500,
menubar: false,
toolbar: 'undo redo | ' +
'bold italic underline forecolor backcolor |fontsize styles ' +
' | bullist numlist | ' +
'removeformat | help',
content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:16px }',
promotion: false,
license_key:'gpl',
statusbar: false,
branding: false
});
} else if ( mode == "full")
{
/**
toolbar: 'undo redo ' +
'bold italic underline strikethrough | hr quickimage | forecolor backcolor|emoticons |fontsize styles ' +
' table tabledelete |' +
' | link unlink bullist numlist | ' +
'removeformat | help',
content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:16px }',
*/
tinymce.init({
selector: 'textarea#'+domid,
height: 500,
menubar: false,
plugins:'link lists emoticons quickbars pagebreak table',
toolbar: 'undo redo ' +
'bold italic underline strikethrough | hr quickimage | forecolor backcolor|emoticons |fontsize styles ' +
' table tabledelete |' +
' | link unlink bullist numlist | ' +
'removeformat | help',
content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:16px }',
promotion: false,
license_key:'gpl',
statusbar: false,
branding: false
});
}else {
console.error(`Noalyss.activate_tinymce unknow mode`);
}
}
noalyss=new Noalyss();

View file

@ -2784,6 +2784,8 @@ EOF;
echo js_include('acc_currency.js');
echo js_include('taggroup.js');
echo js_include('noalyss_checkbox.js');
echo js_include('tinymce/tinymce.min.js');
if (DEBUGNOALYSS > 1) {
echo js_include('noalyss_debug.js');
}

View file

@ -49,11 +49,11 @@ class ITextarea extends HtmlInput
/**
* @brief set enrichText to plain or enrich , enrich for WYSIWYG function, plain, plain textarea and choose
* to display a button to switch to a WYSIWYG
* @param mixed $enrich
* @param mixed $enrich plain , enrich (full option) , min (minimum options)
*/
public function set_enrichText($enrich)
{
if ( ! in_array($enrich,['plain','enrich'])) {
if ( ! in_array($enrich,['plain','enrich',"min"])) {
throw new \Exception("IT57.Invalid option");
}
$this->enrichText = $enrich;
@ -83,12 +83,18 @@ class ITextarea extends HtmlInput
<textarea name="{$this->name}" id="{$this->id}" {$this->style}>{$this->value}</textarea>
<script type="text/javascript">
(function() {
new nicEditor({
buttonList : ['fontSize','fontFamily','fontFormat','bold','italic','underline',
'strikethrough','subscript','superscript','link','unlink','bgcolor','forecolor','indent','outdent','ol',
'ul','left','center','right','justify','hr','removeformat'],
'iconsPath': 'image/nicEditorIcons.gif'
}).panelInstance('{$this->id}');
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');
})();
</script>
EOF;