richtext::ckeditor5::initialize_widget (public)
richtext::ckeditor5::initialize_widget [ -form_id form_id ] \ [ -text_id text_id ] [ -options options ]
Defined in packages/richtext-ckeditor5/tcl/richtext-procs.tcl
Initialize an CKEditor richtext editor widget.
- Switches:
- -form_id (optional)
- -text_id (optional)
- -options (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: ns_log notice "initialize CKEditor 5 instance with <$options>" # Allow per default all CSS-classes, unless the user has specified # it differently if {![dict exists $options extraAllowedContent]} { dict set options extraAllowedContent {*(*)} } # # The richtext widget might be specified by "options {editor # ckeditor5}" or via the package parameter "RichTextEditor" of # acs-templating. # # The following options handled by the CKEditor integration # can be specified in the widget spec of the richtext widget: # # plugins skin customConfig spellcheck # set ckOptionsList {} if {![dict exists $options spellcheck]} { set package_id [apm_package_id_from_key "richtext-ckeditor5"] dict set options spellcheck [parameter::get -package_id $package_id -parameter "SCAYT" -default "false"] } # For the native spellchecker, one has to hold "ctrl" or "cmd" # with the right click. lappend ckOptionsList "language: '[lang::conn::language]'" "disableNativeSpellChecker: false" "scayt_autoStartup: [dict get $options spellcheck]" # # Get the property "displayed_object_id" from the call-stack # for {set l 0} {$l < [info level]} {incr l} { set propVar __adp_properties(displayed_object_id) if {[uplevel #$l [list info exists $propVar]]} { set displayed_object_id [uplevel #$l [list set $propVar]] break } } if {[info exists displayed_object_id]} { # # If we have a displayed_object_id, configure it for the # plugins "filebrowser" and "uploadimage". # set image_upload_url [export_vars -base $::richtext::ckeditor5::ckfinder_url/uploadimage { {object_id $displayed_object_id} {type Images} }] set file_upload_url [export_vars -base $::richtext::ckeditor5::ckfinder_url/upload { {object_id $displayed_object_id} {type Files} {command QuickUpload} }] set file_browse_url [export_vars -base $::richtext::ckeditor5::ckfinder_url/browse { {object_id $displayed_object_id} {type Files} }] lappend ckOptionsList "imageUploadUrl: '$image_upload_url'" "filebrowserBrowseUrl: '$file_browse_url'" "filebrowserUploadUrl: '$file_upload_url'" "filebrowserWindowWidth: '800'" "filebrowserWindowHeight: '600'" } set plugins [split $::richtext::ckeditor5::standard_plugins ,] if {[dict exists $options plugins]} { lappend plugins {*}[split [dict get $options plugins] ,] } if {[llength $plugins] > 0} { lappend ckOptionsList "plugins: \[ [join $plugins ,] \]" } if {[dict exists $options skin]} { lappend ckOptionsList "skin: '[dict get $options skin]'" } if {[dict exists $options customConfig]} { lappend ckOptionsList "customConfig: '[dict get $options customConfig]'" } if {[dict exists $options extraAllowedContent]} { lappend ckOptionsList "extraAllowedContent: '[dict get $options extraAllowedContent]'" } # # For the time being, set the global variable # ::richtext::ckeditor5::JSEditorClass of the JavaScript # editor class to the provided value, since we need this value # for computing the richt CDN url. # if {[dict exists $options JSEditorClass]} { set ::richtext::ckeditor5::JSEditorClass [dict get $options JSEditorClass] } set JSEditorClass $::richtext::ckeditor5::JSEditorClass set ckOptions [join $ckOptionsList ", "] # # Add the configuration via body script # ns_log notice "initialize_widget: $JSEditorClass.create(document.querySelector( '#$text_id', {$ckOptions} )" template::add_script -section body -script [subst { $JSEditorClass .create( document.querySelector( '#$text_id', {$ckOptions} )) .catch( error => { console.error( error ); } ); }] # # Load the editor and everything necessary to the current page. # ::richtext::ckeditor5::add_editor # # do we need render_widgets? # return ""XQL Not present: Generic, PostgreSQL, Oracle