Size TextEditorElement according to the autoWidth property

This commit is contained in:
Antonio Scandurra
2016-08-17 16:16:16 +02:00
parent 2e37d7f0cf
commit e8f2e3a608
3 changed files with 39 additions and 2 deletions

View File

@@ -129,7 +129,7 @@ class TextEditorComponent
updateSync: ->
@updateSyncPreMeasurement()
@oldState ?= {}
@oldState ?= {content: {}}
@newState = @presenter.getPostMeasurementState()
if @editor.getLastSelection()? and not @editor.getLastSelection().isEmpty()
@@ -149,6 +149,15 @@ class TextEditorComponent
else
@domNode.style.height = ''
if (@newState.content.autoWidth isnt @oldState.content.autoWidth) or (@newState.content.width isnt @oldState.content.width)
if @newState.content.autoWidth
@hostElement.style.width = @newState.content.width + 'px'
else
@hostElement.style.width = ''
@oldState.content.width = @newState.content.width
@oldState.content.autoWidth = @newState.content.autoWidth
if @newState.gutters.length
@mountGutterContainerComponent() unless @gutterContainerComponent?
@gutterContainerComponent.updateSync(@newState)