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.20 -r1.21
--- openacs-4/packages/acs-templating/tcl/richtext-procs.tcl 13 Dec 2005 13:34:30 -0000 1.20
+++ openacs-4/packages/acs-templating/tcl/richtext-procs.tcl 4 Jun 2006 00:45:48 -0000 1.21
@@ -237,9 +237,9 @@
append output [textarea_internal "$element(id)" attributes $contents]
if { $htmlarea_p } {
- append output ""
+ append output ""
} else {
- append output "
Format: [menu "$element(id).format" [template::util::richtext::format_options] $format attributes]"
+ append output "
Format: [menu $element(id).format [template::util::richtext::format_options] $format attributes]"
}
# Spell-checker
@@ -262,77 +262,187 @@
ad_proc -public template::widget::richtext { element_reference tag_attributes } {
- Implements the richtext widget, which offers rich text editing options.
+ Implements the richtext widget, which offers rich text editing options.
- This version supports the rte editor.
+ This version supports the rte and xinha editor.
-
- 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:
-
+ The default editor in wysigwig mode is rte. In oder to use xinha, one + has to use 'editor xinha' in the options of the form field. The following + options for xinha may be specified: +
+ GetHtml CharacterMap ContextMenu FullScreen + ListType TableOperations EditTag LangMarks Abbreviation ++
+ These options are used by the OacsFs plugin +
+ {options {editor xinha plugins {OacsFs} height 350px javascript { + xinha_config.toolbar = [ + ['popupeditor', 'bold','italic','createlink','insertimage','separator'], + ['killword','removeformat'] ]; + }}} ++
+ text:richtext(richtext),nospell,optional + {label #xowiki.content#} + {options {editor xinha plugins OacsFs height 350px file_types %pdf%}} + {html {rows 15 cols 50 style {width: 100%}}} +- Derived from the htmlarea richtext widget for htmlarea by lars@pinds.com - - modified for RTE http://www.kevinroth.com/ by davis@xarg.net + Caveat: the three adp-files needed for the OpenACS file selector + (insert-image, insert-ilink and file-selector) + are currently part of the xowiki package, since acs-templating + is per default not mounted. This is hopefully only a temporal situation + and we find a better place. +
+ Note that the rich-rext editor interacts with blank-master.tcl and + blank-master.adp. +
+ Derived from the htmlarea richtext widget for htmlarea by lars@pinds.com
+ modified for RTE http://www.kevinroth.com/ by davis@xarg.net
+ xinha support by gustaf.neumann@wu-wien.ac.at
} {
- upvar $element_reference element
+ upvar $element_reference element
+ set output ""
+
+ if { [info exists element(html)] } {
+ array set attributes $element(html)
+ }
- if { [info exists element(html)] } {
- array set attributes $element(html)
- }
+ array set attributes $tag_attributes
- array set attributes $tag_attributes
+ if { [info exists element(value)] } {
+ set contents [template::util::richtext::get_property contents $element(value)]
+ set format [template::util::richtext::get_property format $element(value)]
+ } else {
+ set contents {}
+ set format {}
+ }
- if { [info exists element(value)] } {
- set contents [template::util::richtext::get_property contents $element(value)]
- set format [template::util::richtext::get_property format $element(value)]
+ array set options [expr {[info exists element(options)] ?
+ $element(options) : ""}]
+
+ if { $element(mode) eq "edit" } {
+ set attributes(id) "richtext__$element(form_id)__$element(id)"
+ set package_id_templating [apm_package_id_from_key "acs-templating"]
+
+ if { [exists_and_not_null element(htmlarea_p)] } {
+ set htmlarea_p [template::util::is_true $element(htmlarea_p)]
} else {
- set contents {}
- set format {}
+ set htmlarea_p [parameter::get \
+ -package_id $package_id_templating \
+ -parameter "UseHtmlAreaForRichtextP" \
+ -default 0]
}
- if { [string equal $element(mode) "edit"] } {
+ set format_menu [menu $element(id).format [template::util::richtext::format_options] $format {}]
+ set output [textarea_internal $element(id) attributes $contents]
- set attributes(id) "richtext__$element(form_id)__$element(id)"
+ if { $htmlarea_p } {
+ # figure out, which rich text editor to use
+ set richtextEditor [expr {[info exists options(editor)] ?
+ $options(editor) : [parameter::get \
+ -package_id $package_id_templating \
+ -parameter "RichTextEditor" \
+ -default "rte"]}]
+ # Tell the blank-master to include the special stuff
+ # for the richtext widget in the page header
+ set ::acs_blank_master($richtextEditor) 1
+
+ if {$richtextEditor eq "rte"} {
+ lappend ::acs_blank_master__htmlareas $element(form_id)
+ # quote contents for javascript.
+ set contents [string map {\n \\n \r {} "'" "&\#39"} $contents]
- if { [exists_and_not_null element(htmlarea_p)] } {
- set htmlarea_p [template::util::is_true $element(htmlarea_p)]
- } else {
- set htmlarea_p [parameter::get \
- -package_id [apm_package_id_from_key "acs-templating"] \
- -parameter "UseHtmlAreaForRichtextP" \
- -default 0]
- }
+ # What we are generating here is the call to write the richtext widget
+ # but we also need to pass what to generate in for browsers for
+ # which the richtext widget won't work but which do have js enabled
+ # should output since we need the format widget (this for Safari among
+ # some others)
+ append output "\n"
- set output "[textarea_internal $element(id) attributes $contents]\n
Format: [menu $element(id).format [template::util::richtext::format_options] {} {}]"
+ set output ""
+ } elseif {$richtextEditor eq "xinha"} {
+
+ append output "\n"
+ append output "\n"
+
+ # we have a xinha richtext widget, specified by "options {editor xinha}"
+ # The following options are supported:
+ # editor plugins width height folder_id fs_package_id
+ #
+ if {[info exists options(plugins)]} {
+ set plugins $options(plugins)
+ } else {
+ set plugins [parameter::get \
+ -package_id $package_id_templating \
+ -parameter "XinhaDefaultPlugins" \
+ -default ""]
- if { $htmlarea_p } {
- # Tell the blank-master to include the special stuff for htmlArea in the page header
- global acs_blank_master__htmlareas
- lappend acs_blank_master__htmlareas $element(form_id)
+ # GetHtml CharacterMap ContextMenu FullScreen
+ # ListType TableOperations EditTag LangMarks Abbreviation
+ }
+ set quoted [list]
+ foreach e $plugins {lappend quoted '$e'}
+ set ::acs_blank_master(xinha.plugins) [join $quoted ", "]
- # quote contents for javascript.
- set contents [string map {\n \\n \r {} "'" "&\#39"} $contents]
+ set xinha_options ""
+ foreach e {width height folder_id fs_package_id file_types} {
+ if {[info exists options($e)]} {
+ append xinha_options "xinha_config.$e = '$options($e)';\n"
+ }
+ }
+ if {[info exists options(javascript)]} {
+ append xinha_options $options(javascript) \n
+ }
+ set ::acs_blank_master(xinha.options) $xinha_options
+ lappend ::acs_blank_master__htmlareas $attributes(id)
+ }
- # What we are generating here is the call to write the richtext widget but we also
- # need to pass what to generate in for browsers for which the richtext widget
- # won't work but which do have js enabled should output since we need the
- # format widget (this for Safari among some others)
- set output ""
-
- }
- # Spell-checker
- array set spellcheck [template::util::spellcheck::spellcheck_properties -element_ref element]
- if { $spellcheck(render_p) } {
- append output " Spellcheck: [menu "$element(id).spellcheck" [nsv_get spellchecker lang_options] $spellcheck(selected_option) attributes]"
- }
} else {
# Display mode
if { [info exists element(value)] } {
@@ -342,8 +452,27 @@
} else {
append output ""
}
+ append output "
Format: $format_menu"
}
-
- return $output
+
+ # Spell-checker
+ array set spellcheck [template::util::spellcheck::spellcheck_properties \
+ -element_ref element]
+ if { $spellcheck(render_p) } {
+ append output " Spellcheck: " \
+ [menu "$element(id).spellcheck" [nsv_get spellchecker lang_options] \
+ $spellcheck(selected_option) attributes]
+ }
+ } else {
+ # Display mode
+ if { [info exists element(value)] } {
+ append output [template::util::richtext::get_property html_value $element(value)]
+ append output ""
+ append output ""
+ }
+ }
+
+ return $output
}
+