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} {
#