# ----------------------------------------------------------------------------- # Author: Alexander Kravets , # Slate Studio (http://www.slatestudio.com) # # Coding Guide: # https://github.com/thoughtbot/guides/tree/master/style/coffeescript # ----------------------------------------------------------------------------- # ----------------------------------------------------------------------------- # INPUT HTML # ----------------------------------------------------------------------------- # # Config options: # label - Input label # aceOptions - Custom options for overriding default ones # # Input config example: # body_html: { type: 'html', label: 'Article' } # # Dependencies: #= require vendor/ace #= require vendor/mode-html # # ----------------------------------------------------------------------------- class @InputHtml extends InputString # PRIVATE =============================================== _add_input: -> @$input =$ "" @$el.append @$input @$editor =$ "
" @$el.append @$editor _update_inputs: -> @value = @editor.getSession().getValue() @$input.val(@value) @$input.trigger('change') # PUBLIC ================================================ initialize: -> @config.beforeInitialize?(this) @editor = ace.edit(@$editor.get(0)) @editor.$blockScrolling = Infinity @session = @editor.getSession() @session.setValue(@$input.val()) @session.setUseWrapMode(true) @session.setMode("ace/mode/html") # ace options: https://github.com/ajaxorg/ace/wiki/Configuring-Ace @editor.setOptions autoScrollEditorIntoView: true minLines: 5 maxLines: Infinity showLineNumbers: false showGutter: false highlightActiveLine: false showPrintMargin: false @session.on 'change', (e) => @_update_inputs() @config.onInitialize?(this) updateValue: (@value) -> @editor.getSession().setValue(@value) @$input.val(@value) chr.formInputs['html'] = InputHtml