diff --git a/html-editor-lib.pl b/html-editor-lib.pl index 930e04a76..bf83dbdec 100644 --- a/html-editor-lib.pl +++ b/html-editor-lib.pl @@ -133,15 +133,13 @@ EOF } } -sub html_editor_parts +sub html_editor_toolbar { -my ($part, $type) = @_; +my ($opts) = @_; -# Editor toolbars -if ($part eq 'toolbar') { - # Toolbar for mail editor - if ($type eq 'mail') { - return +# Toolbar for mail editor +if ($opts->{'type'} eq 'simple') { + return <{'type'} eq 'advanced') { + return < const mail_init_editor = function() { - const targ = document.querySelector('[name="body"]'), + const targ = document.querySelector('[name="@{[$opts->{'textarea'}]}"]'), qs = Quill.import('attributors/style/size'), qf = Quill.import('attributors/style/font'), escapeHTML_ = function(htmlStr) { @@ -234,7 +231,7 @@ my $html_editor_init_script = 'Resize', ], }, - toolbar: @{[&html_editor_parts('toolbar', $type)]}, + toolbar: @{[&html_editor_toolbar($opts)]}, }, bounds: '.ql-compose-container', theme: 'snow' @@ -287,4 +284,34 @@ EOF return $html_editor_init_script; } +sub html_editor +{ +my ($opts) = @_; +# Get template +my $html_editor_template = + &html_editor_template($opts); +# Get toolbar styling +my $html_editor_styles_toolbar = + &html_editor_styles('toolbar'); +# Load bundles +my ($html_editor_load_scripts); +my %tinfo = &get_theme_info($current_theme); +if (!$tinfo{'spa'}) { + # Load HTML editor files and dependencies + $html_editor_load_scripts = + &html_editor_load_bundle($opts); + } + +# HTML editor init +$opts->{'load'} = !$tinfo{'spa'}; +my $html_editor_init_scripts = + &html_editor_init_script($opts); + +# Return complete HTML editor +return $html_editor_template . + $html_editor_styles_toolbar . + $html_editor_load_scripts . + $html_editor_init_scripts; +} + 1; \ No newline at end of file diff --git a/mailboxes/reply_mail.cgi b/mailboxes/reply_mail.cgi index 20fd1a048..a180a9d2b 100755 --- a/mailboxes/reply_mail.cgi +++ b/mailboxes/reply_mail.cgi @@ -443,26 +443,23 @@ if ($in{'new'}) { # Output message body input print &ui_table_start($text{'reply_body'}, "width=100%", 2, undef, &ui_links_row(\@bodylinks)); -my $html_editor_quote = &iframe_quote($quote); -my $html_editor_template; -my $html_editor_styles; -my $html_editor_scripts; -my $html_editor_load_scripts; + +# Process email quote +$quote = &iframe_quote($quote); + +# Get HTML editor and replies +my $html_editor = &html_editor( + { textarea => 'body', + type => 'simple', + extra => + { js => ['highlight/highlight'], + css => ['highlight/highlight'] }, + quote => length($quote), + after => + { editor => $quote } + }); + if ($html_edit) { - $html_editor_template = &html_editor_template({after => {editor => $html_editor_quote}}); - $html_editor_styles = &html_editor_styles('toolbar'); - my %tinfo = &get_theme_info($current_theme); - if (!$tinfo{'spa'}) { - # Load HTML editor files - $html_editor_load_scripts = - &html_editor_load_bundle( - {extra => - {js => ['highlight/highlight'], - css => ['highlight/highlight']}}); - } - # HTML editor init - $html_editor_scripts = - &html_editor_init_script('mail', {load => !$tinfo{'spa'}}); $sig =~ s/\n/
/g, $sig =~ s/^\s+//g, $sig = "

$sig

" @@ -470,10 +467,7 @@ if ($html_edit) { print &ui_table_row(undef, &ui_textarea("body", $sig, 16, 80, undef, 0, "style='display: none' id=body"). - $html_editor_template. - $html_editor_styles. - $html_editor_load_scripts. - $html_editor_scripts, 2); + $html_editor, 2); } else { # Show text editing area