Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/conf/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,7 @@ wysiwyg_editor = ckeditor

#
# Defines options available in the toolbar
# If enabling the ability to add images with option 'Image', be aware that for the image styling/resizing to work you will need to disable HTMLPurifier `purify_all_text_input = 0`
wysiwyg_editor_toolbar = {
formatting = [Bold, Italic, Underline, Strike, -, Subscript, Superscript, Font, FontSize, NumberedList, BulletedList, Outdent, Indent, Blockquote, Link],
misc = [SelectAll, Undo, Redo, -, Source, Maximize, RemoveFormat]
Expand Down
7 changes: 5 additions & 2 deletions app/helpers/displayHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -6405,13 +6405,15 @@ function caGetCK5Toolbar(array $options=null) : ?array {
'textcolor' => ['code' => 'fontColor'],
'background' => ['code' => 'fontBackgroundColor'],

'highlight' => ['code' => 'highlight'],
'blockquote' => ['code' => 'blockQuote'],
'link' => ['code' => 'link'],
'image' => ['code' => 'linkImage'],
'image' => ['code' => 'insertImage'],
'video' => ['code' => 'mediaEmbed'],
'formula' => ['code' => 'formula'],
'align' => ['code' => 'alignment'],

'specialcharacters' => ['code' => 'specialCharacters'],
'numberedlist' => ['code' => 'numberedList'],
'bulletedlist' => ['code' => 'bulletedList'],
'checkList' => ['code' => 'todoList'],
Expand All @@ -6420,7 +6422,8 @@ function caGetCK5Toolbar(array $options=null) : ?array {
'source' => ['code' => 'sourceEditing'],

'undo' => ['code' => 'undo'],
'redo' => ['code' => 'redo']
'redo' => ['code' => 'redo'],
'-' => ['code' => '|']
];

$toolbar = $config->get(strtolower((caGetOption('type', $options, 'editor') )!== 'content') ? 'wysiwyg_editor_toolbar' : 'wysiwyg_content_editor_toolbar');
Expand Down
159 changes: 134 additions & 25 deletions app/helpers/htmlFormHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ function caHTMLTextInput($name, $attributes=null, $options=null) {
if ($use_wysiwyg_editor) {
$o_config = Configuration::load();
$use_editor = $o_config->get('wysiwyg_editor');
$height_w_suffix = is_numeric($height) ? "{$height}px" : $height;
switch($use_editor) {
case 'ckeditor':
AssetLoadManager::register("ck5");
Expand All @@ -214,28 +215,136 @@ function caHTMLTextInput($name, $attributes=null, $options=null) {
$element .= "
<script type=\"module\">
import {
ClassicEditor, BlockQuote, BlockToolbar, Bold, Code, Essentials, FontBackgroundColor, Font, FontColor, FontFamily,
FontSize, GeneralHtmlSupport, Heading, Highlight, HtmlComment, ImageBlock, ImageCaption, ImageInline,
ImageTextAlternative, Indent, IndentBlock, Italic, Link, List, ListProperties, MediaEmbed,
Paragraph, PasteFromOffice, RemoveFormat, SelectAll, SourceEditing, SpecialCharacters, SpecialCharactersArrows,
SpecialCharactersCurrency, SpecialCharactersEssentials, SpecialCharactersLatin, SpecialCharactersMathematical,
SpecialCharactersText, Strikethrough, Subscript, Superscript, TextTransformation, TodoList, Underline, Undo, LinkImage
ClassicEditor,
BlockQuote,
BlockToolbar,
Bold,
Code,
Essentials,
FontBackgroundColor,
Font,
FontColor,
FontFamily,
FontSize,
GeneralHtmlSupport,
Heading,
Highlight,
HtmlComment,
ImageBlock,
ImageCaption,
ImageEditing,
ImageInline,
ImageInsertViaUrl,
ImageResize,
ImageStyle,
ImageTextAlternative,
ImageToolbar,
Indent,
IndentBlock,
Italic,
Link,
LinkImage,
List,
ListProperties,
MediaEmbed,
Paragraph,
PasteFromOffice,
RemoveFormat,
SelectAll,
SourceEditing,
SpecialCharacters,
SpecialCharactersArrows,
SpecialCharactersCurrency,
SpecialCharactersEssentials,
SpecialCharactersLatin,
SpecialCharactersMathematical,
SpecialCharactersText,
Strikethrough,
Subscript,
Superscript,
TextTransformation,
TodoList,
Underline,
Undo
} from 'ckeditor5';

ClassicEditor
.create( document.querySelector( '#{$name}' ), {
plugins: [
BlockQuote, BlockToolbar, Bold, Code, Essentials, FontBackgroundColor, FontColor, FontFamily, FontSize,
GeneralHtmlSupport, Heading, Highlight, HtmlComment, ImageBlock, ImageCaption, ImageInline,
ImageTextAlternative, Indent, IndentBlock, Italic, Link, List, ListProperties, MediaEmbed,
Paragraph, PasteFromOffice, RemoveFormat, SelectAll, SourceEditing, SpecialCharacters,
SpecialCharactersArrows, SpecialCharactersCurrency, SpecialCharactersEssentials,
SpecialCharactersLatin, SpecialCharactersMathematical, SpecialCharactersText, Strikethrough,
Subscript, Superscript, TextTransformation, TodoList, Underline, Undo, LinkImage
import { ResizableHeight } from 'ckresizeable';

ClassicEditor.create( document.querySelector( '#{$name}' ), {
plugins: [
BlockQuote,
BlockToolbar,
Bold,
Code,
Essentials,
FontBackgroundColor,
Font,
FontColor,
FontFamily,
FontSize,
GeneralHtmlSupport,
Heading,
Highlight,
HtmlComment,
ImageBlock,
ImageCaption,
ImageEditing,
ImageInline,
ImageInsertViaUrl,
ImageResize,
ImageStyle,
ImageTextAlternative,
ImageToolbar,
Indent,
IndentBlock,
Italic,
Link,
LinkImage,
List,
ListProperties,
MediaEmbed,
Paragraph,
PasteFromOffice,
RemoveFormat,
ResizableHeight,
SelectAll,
SourceEditing,
SpecialCharacters,
SpecialCharactersArrows,
SpecialCharactersCurrency,
SpecialCharactersEssentials,
SpecialCharactersLatin,
SpecialCharactersMathematical,
SpecialCharactersText,
Strikethrough,
Subscript,
Superscript,
TextTransformation,
TodoList,
Underline,
Undo
],
toolbar: {
items: ".json_encode($toolbar).",
shouldNotGroupWhenFull: true
shouldNotGroupWhenFull: false
},
image: {
toolbar: [
'toggleImageCaption',
'imageTextAlternative',
'|',
'imageStyle:inline',
'imageStyle:wrapText',
'imageStyle:breakText',
'|',
'resizeImage'
]
},
ResizableHeight: {
resize: true,
height: '{$height_w_suffix}',
minHeight: '50px',
maxHeight: '1500px'
}
} ).then(editor => {
// Add current instance to list of initialized editors
Expand All @@ -248,13 +357,13 @@ function caHTMLTextInput($name, $attributes=null, $options=null) {


$attr_string = _caHTMLMakeAttributeString($attributes, $options);
$element .= "<div id=\"{$name}_container\" style='width: {$width}px; height: {$height}px; overflow-y: auto;'>
$element .= "<div id=\"{$name}_container\">
<{$tag_name} name=\"{$name}\" id=\"{$name}\">{$attributes['value']}</{$tag_name}></div>
<style>
#{$name}_container .ck-editor__editable_inline {
min-height: calc({$height}px - 100px);
}
</style>";
<style>
#{$name}_container .ck-editor__editable_inline {
min-height: calc({$height}px - 100px);
}
</style>";
break;
case 'quilljs';
default:
Expand Down Expand Up @@ -288,8 +397,8 @@ function caHTMLTextInput($name, $attributes=null, $options=null) {
break;
}

$o_config = Configuration::load();
if(!is_array($va_toolbar_config = $o_config->getAssoc(caGetOption('cktoolbar', $options, 'wysiwyg_editor_toolbar')))) { $va_toolbar_config = []; }
// $o_config = Configuration::load();
// if(!is_array($va_toolbar_config = $o_config->getAssoc(caGetOption('cktoolbar', $options, 'wysiwyg_editor_toolbar')))) { $va_toolbar_config = []; }
} elseif ($is_textarea) {
$value = $attributes['value'] ?? null;
if ($attributes['size'] ?? null) { $attributes['cols'] = $attributes['size']; }
Expand Down
15 changes: 12 additions & 3 deletions app/helpers/utilityHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -5042,9 +5042,18 @@ function caQuoteRegexDelimiter(string $regex, string $delimiter) : string {
*
*/
function caGetHTMLPurifier(?array $options=null) : HTMLPurifier {
$config = HTMLPurifier_Config::createDefault();
$config->set('URI.DisableExternalResources', !Configuration::load()->get('purify_allow_external_references'));
$config->set('Cache.SerializerPath', Configuration::load()->get('purify_serializer_path'));
$config = HTMLPurifier_Config::createDefault();
//$config->set('HTML.DefinitionID','enduser-customize.html tutorial');
$config->set('HTML.Allowed','*[style|class],img[src|width|height|style|alt],p,div,strong,em,i,u,s,sub,sup,figure,figcaption,ul,li,h1,h2,h3,h4,h5,h6,ol,blockquote,a[href|title],br');
//$config->set('URI.DisableExternalResources', !Configuration::load()->get('purify_allow_external_references'));
//$config->set('Cache.SerializerPath', Configuration::load()->get('purify_serializer_path'));
//$config->set('CSS.AllowTricky',true);
//$config->set('CSS.Trusted',true);
$config->set('Cache.DefinitionImpl',null); //Remove this later
$def = $config->getHTMLDefinition(true);
$def->addElement('figcaption', 'Block', 'Flow', 'Common');
$def->addElement('figure','Block','Optional:(figcaption,Flow) | (Flow,figcaption) | Flow', 'Common');

return new HTMLPurifier($config);
}
# ----------------------------------------
Expand Down
129 changes: 115 additions & 14 deletions app/lib/Attributes/Values/TextAttributeValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,31 +416,132 @@ public function htmlFormElement($element_info, $options=null) {
$element .= "
<script type=\"module\">
import {
ClassicEditor, BlockQuote, BlockToolbar, Bold, Code, Essentials, FontBackgroundColor, Font, FontColor, FontFamily,
FontSize, GeneralHtmlSupport, Heading, Highlight, HtmlComment, ImageBlock, ImageCaption, ImageInline,
ImageTextAlternative, Indent, IndentBlock, Italic, Link, List, ListProperties, MediaEmbed,
Paragraph, PasteFromOffice, RemoveFormat, SelectAll, SourceEditing, SpecialCharacters, SpecialCharactersArrows,
SpecialCharactersCurrency, SpecialCharactersEssentials, SpecialCharactersLatin, SpecialCharactersMathematical,
SpecialCharactersText, Strikethrough, Subscript, Superscript, TextTransformation, TodoList, Underline, Undo, LinkImage
ClassicEditor,
BlockQuote,
BlockToolbar,
Bold,
Code,
Essentials,
FontBackgroundColor,
Font,
FontColor,
FontFamily,
FontSize,
GeneralHtmlSupport,
Heading,
Highlight,
HtmlComment,
ImageBlock,
ImageCaption,
ImageEditing,
ImageInline,
ImageInsertViaUrl,
ImageResize,
ImageStyle,
ImageTextAlternative,
ImageToolbar,
Indent,
IndentBlock,
Italic,
Link,
LinkImage,
List,
ListProperties,
MediaEmbed,
Paragraph,
PasteFromOffice,
RemoveFormat,
SelectAll,
SourceEditing,
SpecialCharacters,
SpecialCharactersArrows,
SpecialCharactersCurrency,
SpecialCharactersEssentials,
SpecialCharactersLatin,
SpecialCharactersMathematical,
SpecialCharactersText,
Strikethrough,
Subscript,
Superscript,
TextTransformation,
TodoList,
Underline,
Undo
} from 'ckeditor5';

import { ResizableHeight} from 'ckresizeable';

ClassicEditor
.create( document.querySelector( '#{fieldNamePrefix}{$element_info['element_id']}_{n}' ), {
plugins: [
BlockQuote, BlockToolbar, Bold, Code, Essentials, FontBackgroundColor, FontColor, FontFamily, FontSize,
GeneralHtmlSupport, Heading, Highlight, HtmlComment, ImageBlock, ImageCaption, ImageInline,
ImageTextAlternative, Indent, IndentBlock, Italic, Link, List, ListProperties, MediaEmbed,
Paragraph, PasteFromOffice, RemoveFormat, SelectAll, SourceEditing, SpecialCharacters,
SpecialCharactersArrows, SpecialCharactersCurrency, SpecialCharactersEssentials,
SpecialCharactersLatin, SpecialCharactersMathematical, SpecialCharactersText, Strikethrough,
Subscript, Superscript, TextTransformation, TodoList, Underline, Undo, LinkImage, ResizableHeight
BlockQuote,
BlockToolbar,
Bold,
Code,
Essentials,
FontBackgroundColor,
Font,
FontColor,
FontFamily,
FontSize,
GeneralHtmlSupport,
Heading,
Highlight,
HtmlComment,
ImageBlock,
ImageCaption,
ImageEditing,
ImageInline,
ImageInsertViaUrl,
ImageResize,
ImageStyle,
ImageTextAlternative,
ImageToolbar,
Indent,
IndentBlock,
Italic,
Link,
LinkImage,
List,
ListProperties,
MediaEmbed,
Paragraph,
PasteFromOffice,
RemoveFormat,
ResizableHeight,
SelectAll,
SourceEditing,
SpecialCharacters,
SpecialCharactersArrows,
SpecialCharactersCurrency,
SpecialCharactersEssentials,
SpecialCharactersLatin,
SpecialCharactersMathematical,
SpecialCharactersText,
Strikethrough,
Subscript,
Superscript,
TextTransformation,
TodoList,
Underline,
Undo
],
toolbar: {
items: ".json_encode(caGetCK5Toolbar()).",
shouldNotGroupWhenFull: true
shouldNotGroupWhenFull: false
},
image: {
toolbar: [
'toggleImageCaption',
'imageTextAlternative',
'|',
'imageStyle:inline',
'imageStyle:wrapText',
'imageStyle:breakText',
'|',
'resizeImage'
]
},
ResizableHeight: {
resize: true,
height: '{$height_w_suffix}',
Expand Down