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.200 -r1.284.2.201 --- openacs-4/packages/xowiki/tcl/form-field-procs.tcl 3 Mar 2022 19:00:11 -0000 1.284.2.200 +++ openacs-4/packages/xowiki/tcl/form-field-procs.tcl 3 Mar 2022 19:37:39 -0000 1.284.2.201 @@ -3488,193 +3488,6 @@ ########################################################### # - # ::xowiki::formfield::richtext::ckeditor - # - # mode: wysiwyg, source - # skin: kama, v2, office2003 - # extraPlugins: tcl-list, is converted to comma list for js - # - # This formfield class being based on ckeditor3 is deprecated, - # use richtext::ckeditor4 instead. - # - ########################################################### - Class create richtext::ckeditor -superclass richtext -parameter { - {mode wysiwyg} - {skin kama} - {toolbar Full} - {CSSclass xowiki-ckeditor} - {uiColor ""} - {CSSclass xowiki-ckeditor} - {customConfig "../ck_config.js"} - {callback "/* callback code */"} - {destroy_callback "/* callback code */"} - {extraPlugins "xowikiimage"} - {templatesFiles ""} - {templates ""} - {contentsCss /resources/xowiki/ck_contents.css} - {imageSelectorDialog /xowiki/ckeditor-images/} - } - richtext::ckeditor set editor_mixin 1 - richtext::ckeditor ad_instproc -deprecated initialize {} { - } { - switch -- ${:displayMode} { - inplace { append :help_text " #xowiki.ckeip_help#" } - inline { error "inline is not supported for ckeditor v3"} - } - next - set :widget_type richtext - # Mangle the id to make it compatible with jquery; most probably - # not optimal and just a temporary solution - regsub -all -- {[.:]} ${:id} "" id - :id $id - } - - richtext::ckeditor instproc js_image_helper {} { - set path [${:object} pretty_link] - append js \ - [subst -novariables { - function xowiki_image_callback(editor) { - if (typeof editor != "undefined") { - $(editor.element.$.form).submit(function(e) { - calc_image_tags_to_wiki_image_links(this); - }); - editor.setData(calc_wiki_image_links_to_image_tags('[set path]',editor.getData())); - } - } - }] { - function calc_image_tags_to_wiki_image_links(form) { - var calc = function() { - var wiki_link = $(this).attr('alt'); - $(this).replaceWith('[['+wiki_link+']]'); - } - $(form).find('iframe').each(function() { - $(this).contents().find('img[type="wikilink"]').each(calc); - }); - - $(form).find('textarea.ckeip').each(function() { - var contents = $('
'+this.value+'
'); - contents.find('img[type="wikilink"]').each(calc); - this.value = contents.html(); - }); - return true; - } - - function calc_wiki_image_links_to_image_tags(path, data) { - var regex_wikilink = new RegExp('(\\[\\[.SELF./image:)(.*?)(\\]\\])', 'g'); - data = data.replace(regex_wikilink,'.SELF./image:$2'); - return data - } - } - ::xo::Page requireJS $js - } - - richtext::ckeditor instproc pathNames {fileNames} { - set result [list] - foreach fn $fileNames { - if {[regexp {^[./]} $fn]} { - append result $fn - } else { - append result "/resources/xowiki/$fn" - } - } - return $result - } - - richtext::ckeditor instproc render_input {} { - set disabled [:is_disabled] - if {![:istype ::xowiki::formfield::richtext] || $disabled } { - :render_richtext_as_div - } else { - ::xo::Page requireJS urn:ad:js:jquery - ::xo::Page requireJS "/resources/xowiki/ckeditor/ckeditor_source.js" - #::xo::Page requireJS "/resources/xowiki/ckeditor/ckeditor.js" - ::xo::Page requireJS "/resources/xowiki/ckeditor/adapters/jquery.js" - ::xo::Page requireJS urn:ad:js:jquery-ui - ::xo::Page requireCSS urn:ad:css:jquery-ui - - # In contrary to the doc, ckeditor names instances after the id, - # not the name. - set id ${:id} - set name ${:name} - set package_id [${:object} package_id] - #set :extraPlugins {timestamp xowikiimage} - - if {"xowikiimage" in [:extraPlugins]} { - :js_image_helper - set ready_callback {xowiki_image_callback(e.editor);} - } else { - set ready_callback "/*none*/;" - } - - set options [subst { - toolbar : '[:toolbar]', - uiColor: '[:uiColor]', - language: '[::xo::cc lang]', - skin: '[:skin]', - startupMode: '${:mode}', - parent_id: '[${:object} item_id]', - package_url: '[::$package_id package_url]', - extraPlugins: '[join [:extraPlugins] ,]', - contentsCss: '[:contentsCss]', - imageSelectorDialog: '[:imageSelectorDialog]', - ready_callback: '$ready_callback', - customConfig: '[:customConfig]' - }] - if {[:templatesFiles] ne ""} { - append options " , templates_files: \['[join [:pathNames [:templatesFiles]] ',' ]' \]\n" - } - if {[:templates] ne ""} { - append options " , templates: '[:templates]'\n" - } - - #set parent [[${:object} package_id] get_page_from_item_or_revision_id [${:object} parent_id]];# ??? - - if {${:displayMode} eq "inplace"} { - if {[:value] eq ""} { - :value " " - } - :render_richtext_as_div - if {${:inline}} { - set wrapper_class "" - } else { - set wrapper_class "form-item-wrapper" - :callback {$(this.element.$).closest('.form-widget').css('clear','both').css('display', 'block');} - :destroy_callback {$(this).closest('.form-widget').css('clear','none');} - } - set callback [:callback] - set destroy_callback [:destroy_callback] - - ::xo::Page requireJS "/resources/xowiki/ckeip.js" - ::xo::Page requireJS [subst -nocommands { - \$(document).ready(function() { - \$( '\#$id' ).ckeip(function() { $callback }, { - name: '$name', - ckeditor_config: { - $options, - destroy_callback: function() { $destroy_callback } - }, - wrapper_class: '$wrapper_class' - }); - }); - }] - } else { - set callback [:callback] - ::xo::Page requireJS [subst -nocommands { - \$(document).ready(function() { - \$( '#$id' ).ckeditor(function() { $callback }, { - $options - }); - CKEDITOR.instances['$id'].on('instanceReady',function(e) {$ready_callback}); - }); - }] - next - } - } - } - - - ########################################################### - # # ::xowiki::formfield::richtext::ckeditor4 # # mode: wysiwyg, source