Make each section of presenter state self-contained

This means we have some duplicated values in different parts of the
tree, but it’s cleaner in the view since each component only consumes
a single object. Seems like the presenter should convey the correct
data to the correct locations and minimize the logic in the view. A
few duplicated integers is a reasonable trade-off.
This commit is contained in:
Nathan Sobo
2015-01-29 14:27:53 -07:00
parent da4b3a47ef
commit bbc1a264b5
7 changed files with 238 additions and 110 deletions

View File

@@ -34,7 +34,6 @@ TextEditorComponent = React.createClass
scrollSensitivity: 0.4
heightAndWidthMeasurementRequested: false
inputEnabled: true
scopedCharacterWidthsChangeCount: null
domPollingInterval: 100
domPollingIntervalId: null
domPollingPaused: false
@@ -56,7 +55,7 @@ TextEditorComponent = React.createClass
hiddenInputStyle = @getHiddenInputPosition()
hiddenInputStyle.WebkitTransform = 'translateZ(0)' if @useHardwareAcceleration
style.height = @presenter.state.scrollHeight if @autoHeight
style.height = @presenter.state.content.scrollHeight if @autoHeight
if useShadowDOM
className = 'editor-contents--private'
@@ -233,7 +232,6 @@ TextEditorComponent = React.createClass
@subscribe editor.observeGrammar(@onGrammarChanged)
@subscribe editor.observeCursors(@onCursorAdded)
@subscribe editor.observeSelections(@onSelectionAdded)
@subscribe editor.onDidChangeCharacterWidths(@onCharacterWidthsChanged)
@subscribe editor.$scrollTop.changes, @onScrollTopChanged
@subscribe editor.$scrollLeft.changes, @onScrollLeftChanged
@subscribe editor.$verticalScrollbarWidth.changes, @requestUpdate
@@ -579,9 +577,6 @@ TextEditorComponent = React.createClass
@cursorMoved = true
@requestUpdate()
onCharacterWidthsChanged: (@scopedCharacterWidthsChangeCount) ->
@requestUpdate()
handleDragUntilMouseUp: (event, dragHandler) ->
{editor} = @props
dragging = false