Class ::xowiki::formfield::textarea

::xowiki::formfield::textarea[i] create ... \
           [ -autosave:boolean (default "false") ] \
           [ -cols (default "80") ] \
           [ -paste:boolean (default "true") ] \
           [ -rows (default "2") ] \
           [ -spell (default "false") ] \
           [ -spellcheck:boolean (default "true") ]

Class Relations

  • class: ::xotcl::Class[i]
  • superclass: ::xowiki::formfield::FormField[i]
  • subclass: ::xowiki::formfield::workflow_definition[i], ::xowiki::formfield::code_listing[i], ::xowiki::formfield::richtext[i], ::xowiki::formfield::menuentries[i], ::xowiki::formfield::form_constraints[i]
::xotcl::Class create ::xowiki::formfield::textarea \
     -superclass ::xowiki::formfield::FormField

Methods (to be applied on instances)

  • add_statistics (scripted)

    #:log "add_statistics $options"
    next
    if {[dict exists $options word_statistics]} {
      #:log "add_statistics call :word_statistics"
      :word_statistics [dict get $options word_statistics]
    }
  • autosave (setter)

  • clear_editor_mixins (scripted)

    foreach m [:info mixin] {
      if {[$m exists editor_mixin]} {
        :mixin delete $m
      }
    }
  • cols (setter)

  • initialize (scripted)

    set :widget_type text(textarea)
    set :booleanHTMLAttributes {required readonly disabled formnovalidate}
    foreach p [list rows cols style] {
      if {[info exists :$p]} {set :html($p) [:$p]}
    }
    if {![:istype ::xowiki::formfield::richtext] && [info exists :editor]} {
      # downgrading
      #:msg "downgrading [:info class]"
      :clear_editor_mixins
      foreach v {editor options} {
        if {[info exists :$v]} {
          unset :$v
        }
      }
    }
    if {${:autosave}} {
      ::xo::Page requireJS  "/resources/xowiki/autosave-text.js"
    }
    next
  • paste (setter)

  • render_as_div (scripted)

    #
    # Rendering a textarea as a div is needed in particular for
    # richtext editors, where some may not expect to enhance a
    # textarea as usual, but a div.
    #
    #:msg "[:get_attributes id style {CSSclass class}]"
    ::html::div [:get_attributes id style {CSSclass class} data-repeat-template-id] {
      if {[:wiki]} {
        ${:object} references clear
        ::html::t -disableOutputEscaping [${:object} substitute_markup [:value]]
      } else {
        ::html::t -disableOutputEscaping [:value]
      }
    }
    ::html::div
  • render_input (scripted)

    if {[info exists :render_as_div_p] && ${:render_as_div_p}} {
      #
      # A subclass set :render_as_div_p to indicate they want the
      # field to be rendered as a div, but did not want to interrupt
      # inheritance.
      #
      # When superclass behavior is not needed, one may simply call
      # :render_as_div directly in the subclass methods.
      #
      :render_as_div
    } elseif {[:is_disabled] && [info exists :disabled_as_div]} {
      :render_disabled_as_div textarea
    } else {
      set booleanAtts [:booleanAttributes {*}${:booleanHTMLAttributes}]
      if {!${:spellcheck}} {
        set :data-gramm false
        set :data-lt-active false
      }
      if {${:autosave}} {
        ::html::div -class "autosave" {
          ::html::div -id ${:id}-status  -class "nochange"  -data-saved #xowiki.autosave_saved#  -data-rejected #xowiki.autosave_rejected#  -data-pending #xowiki.autosave_pending# {
                ::html::t "" ;#"no change"
              }
          ::html::textarea [:get_attributes id name cols rows style wrap placeholder  data-repeat-template-id {CSSclass class} spellcheck  data-gramm data-lt-active {*}$booleanAtts] {
                                  ::html::t [:value]
                                }
        }
        template::add_event_listener  -id ${:id}  -event keyup  -preventdefault=false  -script "autosave_handler('${:id}');"
    
      } else {
        ::html::textarea [:get_attributes id name cols rows style wrap placeholder  data-repeat-template-id {CSSclass class}  {*}$booleanAtts] {
                                ::html::t [:value]
                              }
      }
      #
      # For emergency situations, one might allow swa always pasting
      # if {!${:paste} && ![acs_user::site_wide_admin_p -user_id [::xo::cc user_id]]} { ... }
      #
      if {!${:paste}} {
        #
        # When "paste" is deactivated, the cut&paste and drag&drop
        # handlers are deactivated for this field. "copy" is
        # deactivated for the full page, since otherwise, one could
        # cut the field with the surrounding text.
        #
        foreach event_type {paste drag drop} {
          template::add_event_listener -id ${:id} -event $event_type  -preventdefault=true -script ""
        }
        template::add_script -section body -script {
          window.addEventListener('copy', function (event) {event.preventDefault();}, false);
        }
      }
    
      :resetBooleanAttributes $booleanAtts
    }
    :render_result_statistics
  • rows (setter)

  • set_feedback (scripted)

    set :correction [next]
    return ${:correction}
  • spell (setter)

  • spellcheck (setter)