Index: openacs-4/packages/acs-templating/acs-templating.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/acs-templating.info,v diff -u -r1.59 -r1.60 --- openacs-4/packages/acs-templating/acs-templating.info 23 Aug 2017 18:10:03 -0000 1.59 +++ openacs-4/packages/acs-templating/acs-templating.info 5 Dec 2017 15:37:18 -0000 1.60 @@ -9,7 +9,7 @@ f t - + OpenACS Templating library. 2017-08-06 @@ -27,7 +27,7 @@ GPL version 2 3 - + Index: openacs-4/packages/acs-templating/tcl/richtext-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/richtext-procs.tcl,v diff -u -r1.54 -r1.55 --- openacs-4/packages/acs-templating/tcl/richtext-procs.tcl 1 Oct 2017 12:16:05 -0000 1.54 +++ openacs-4/packages/acs-templating/tcl/richtext-procs.tcl 5 Dec 2017 15:37:18 -0000 1.55 @@ -190,19 +190,22 @@ ad_proc -public -deprecated template::widget::richtext_htmlarea { element_reference tag_attributes } { Implements the richtext widget, which offers rich text editing options. - If the acs-templating.UseHtmlAreaForRichtextP parameter is set to true (1), this will use the htmlArea WYSIWYG editor widget. - Otherwise, it will use a normal textarea, with a drop-down to select a format. The available formats are: + If the acs-templating.UseHtmlAreaForRichtextP parameter is set to true (1), + this will use the htmlArea WYSIWYG editor widget. + Otherwise, it will use a normal textarea, with a drop-down to select a format. + The available formats are:
  • Enhanced text = Allows HTML, but automatically inserts line and paragraph breaks. -
  • Plain text = Automatically inserts line and paragraph breaks, and quotes all HTML-specific characters, such as less-than, greater-than, etc. +
  • Plain text = Automatically inserts line and paragraph breaks, + and quotes all HTML-specific characters, such as less-than, greater-than, etc.
  • Fixed-width text = Same as plain text, but conserves spacing; useful for tabular data.
  • HTML = normal HTML.
- You can also parameterize the richtext widget with a 'htmlarea_p' attribute, which can be true or false, and which will override the parameter setting. + You can also parameterize the richtext widget with a 'htmlarea_p' attribute, + which can be true or false, and which will override the parameter setting. @see template::widget::richtext } { - upvar $element_reference element if { [info exists element(html)] } { @@ -317,8 +320,7 @@ @return On success, this function returns a dict with success 1 } { - if {$editor ni $::template::util::richtext::editors} { - ns_log warning "richtext: no editor with name $editor is registered" + if {![require_editor -editor $editor]} { return {success 0} } @@ -332,6 +334,41 @@ set ::template::util::richtext::editors {} +# +# Check if an editor package of this kind is installed +# +ad_proc -private template::util::richtext::require_editor { + -editor +} { + Check, whether this editor package is installed. +} { + if {$editor ni $::template::util::richtext::editors} { + ns_log warning "richtext: no editor with name $editor is registered" + return 0 + } + return 1 +} + + +ad_proc -public template::util::richtext::get_tag { + {-options {}} +} { + + Return tag name for the markup; normally a "textarea", but some + editors might use e.g. a "div". If the fuction is defined for the + editor, call it. + +} { + set tag textarea + if {[dict exists $options editor] + && [info commands ::richtext::[dict get $options editor]::get_tag] ne "" + } { + set tag [::richtext::[dict get $options editor]::get_tag -options $options] + } + return $tag +} + + ad_proc -public template::util::richtext::register_editor { editor } { Make an rich-text editor known to the templating system. @@ -497,6 +534,8 @@ upvar $element_reference element set output "" + + #ns_log notice "widget::richtext: richtext-options? [info exists element(options)] HTML? [info exists element(html)]" if { [info exists element(html)] } { array set attributes $element(html) @@ -532,21 +571,22 @@ } } - if { ([info exists element(htmlarea_p)] && $element(htmlarea_p) ne "") } { + if { [info exists element(htmlarea_p)] && $element(htmlarea_p) ne "" } { set htmlarea_p [template::util::is_true $element(htmlarea_p)] } else { set htmlarea_p [parameter::get \ -package_id $package_id_templating \ -parameter "UseHtmlAreaForRichtextP" \ -default 0] } - + set edit_item_tag [::template::util::richtext::get_tag -options [array get options]] set format_menu [menu $element(id).format [template::util::richtext::format_options] $format {}] - set output [textarea_internal $element(id) attributes $contents] + set output [textarea_internal $element(id) attributes $contents "edit" $edit_item_tag] # Spell-checker array set spellcheck [template::util::spellcheck::spellcheck_properties \ -element_ref element] + #ns_log notice "widget::richtext: $htmlarea_p, spellcheck [array get spellcheck] OPTIONS [array get options]" if { $htmlarea_p } { # figure out, which rich text editor to use @@ -574,7 +614,7 @@ -text_id $attributes(id) \ -editor $richtextEditor \ -options [array get options]] - ns_log debug "::template::util::richtext::initialize_widget -> $result" + ns_log debug "widget::richtext: ::template::util::richtext::initialize_widget -> $result" if {[dict get $result success] == 1} { # Index: openacs-4/packages/acs-templating/tcl/spellcheck-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/spellcheck-procs.tcl,v diff -u -r1.23 -r1.24 --- openacs-4/packages/acs-templating/tcl/spellcheck-procs.tcl 7 Aug 2017 23:48:02 -0000 1.23 +++ openacs-4/packages/acs-templating/tcl/spellcheck-procs.tcl 5 Dec 2017 15:37:18 -0000 1.24 @@ -383,28 +383,26 @@ set spellcheck_p 0 } else { - - array set widget_info [string trim [parameter::get_from_package_key \ -package_key acs-templating \ -parameter SpellcheckFormWidgets \ -default ""]] - + set spellcheck_p [expr {[array size widget_info] && ($element(widget) eq "richtext" || $element(widget) eq "textarea" || $element(widget) eq "text") - && $element(widget) in [array names widget_info]}] - + && [info exists widget_info($element(widget))] + && [set widget_info($element(widget))] + }] } if { $spellcheck_p } { # This is not a submit; we are rendering the form element for the first time and # since the spellcheck "sub widget" is to be displayed we'll also want to know # which option should be selected by default. - set spellcheck(render_p) 1 - set spellcheck(perform_p) 1 + array set spellcheck {render_p 1 perform_p 1} if { $widget_info(${element(widget)}) } { set spellcheck(selected_option) [nsv_get spellchecker default_lang] @@ -414,8 +412,7 @@ } else { - set spellcheck(render_p) 0 - set spellcheck(perform_p) 0 + array set spellcheck {render_p 0 perform_p 0} # set this to something so the script won't choke. set spellcheck(selected_option) ":nospell:" Index: openacs-4/packages/acs-templating/tcl/widget-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/widget-procs.tcl,v diff -u -r1.55 -r1.56 --- openacs-4/packages/acs-templating/tcl/widget-procs.tcl 1 Oct 2017 12:16:05 -0000 1.55 +++ openacs-4/packages/acs-templating/tcl/widget-procs.tcl 5 Dec 2017 15:37:18 -0000 1.56 @@ -308,6 +308,7 @@ attribute_reference {value {}} {mode edit} + {tag textarea} } { Do the actual construction of a textarea widget, called by various user-callable widgets. @@ -324,24 +325,29 @@ upvar $attribute_reference attributes if { $mode ne "edit" } { - set output {} + set output "" if { $value ne "" } { - append output "[ns_quotehtml $value]" + append output \ + [ns_quotehtml $value] \ + "" } } else { - set output "" + append output ">[ns_quotehtml $value]" } - + return $output }