 
     @_html = newHtml
 
-    if @props.storageKey?
-      if newHtml
-        safeLocalStorage.setItem(@props.storageKey, newHtml)
-      else
-        safeLocalStorage.removeItem(@props.storageKey)
+    @_setLocalStorageBackup()
     @props.onChange?(newHtml)
 
   updateHtml: (html) ->

  componentDidMount: ->
    @_editor = CKEDITOR.inline(@getDOMNode(), Factlink.Global.ckeditor_config);
    @_editor.on 'change', @_onChange
    initialHtml = @_getLocalStorageBackup() || @props.defaultValue
    @updateHtml initialHtml

  render: ->
    _div


  shouldComponentUpdate: -> false

  _getLocalStorageBackup: ->
    if @props.defaultValue?
      @props.defaultValue
    else if @props.storageKey?
      safeLocalStorage.getItem(@props.storageKey)

  _setLocalStorageBackup: ->
    return unless @props.storageKey?

    if @_html
      safeLocalStorage.setItem(@props.storageKey, @_html)
    else
      safeLocalStorage.removeItem(@props.storageKey)

  _onChange: ->
    newHtml = @_editor.getData()
