Index: openacs-4/packages/xowiki/tcl/form-field-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/form-field-procs.tcl,v diff -u -r1.284.2.246 -r1.284.2.247 --- openacs-4/packages/xowiki/tcl/form-field-procs.tcl 2 May 2024 14:06:48 -0000 1.284.2.246 +++ openacs-4/packages/xowiki/tcl/form-field-procs.tcl 6 May 2024 14:47:07 -0000 1.284.2.247 @@ -3404,6 +3404,7 @@ width height {wiki false} + preset } richtext instproc editor {args} { @@ -3459,6 +3460,26 @@ set :editor $editor } + richtext instproc preset_conf {} { + # + # The actual richtext-editor implementation may provide some + # use-case based presets. Examples may be a "minimal", "standard" + # and "advanced" configuration that are reused in various forms. + # + # Here, we check and eventually return such conf, which will be + # applied to the loading formfield. + # + # The purpose of this feature is to have a set of logical + # configurations that do not depend on the specific editor and can + # be extended downstream. + # + if {[info exists :preset] && + [info exists :editor] && + [info commands ::richtext::${:editor}::preset::${:preset}] ne ""} { + return [::richtext::${:editor}::preset::${:preset}] + } + } + richtext instproc initialize {} { #set :display_field false switch -- ${:displayMode} { @@ -3745,6 +3766,16 @@ set name ${:name} set package_id [${:object} package_id] + # + # Apply configuration from presets, if any. + # + foreach {key value} [:preset_conf] { + # We do not set variables that do not exist. + if {[info exists :${key}]} { + set :${key} $value + } + } + # Earlier versions required the plugin "sourcedialog" in # "inline" mode. Not sure why. This plugin was removed from # CKEditor. @@ -4130,7 +4161,7 @@ richtext::tinymce instproc compute_config {} { # # Here we compute the editor config, mergin explicit one with - # systems configurations. + # systems configurations and presets. # # @return a dict # @@ -4163,6 +4194,7 @@ set config [dict merge \ [list language [ad_conn language]] \ $default_config \ + [:preset_conf] \ ${:additionalConfig} \ $config] }