Base editor dimensions on the wrapper view

The goal is to make the editor behave like a standard block-level
element.

The horizontal behavior is simple: we stretch horizontally to fill our
container.

The vertical behavior is more nuanced. If an explicit height is assigned
on the wrapper view, we honor that height. But if no explicit height is
assigned, the editor stretches vertically so that its contents are
visible.

This prepares us to support mini editors, which need to be 1-line tall
without an explicit height assignment.
This commit is contained in:
Nathan Sobo
2014-07-13 11:56:14 -06:00
parent f16ea63a95
commit e999ef00e7
3 changed files with 212 additions and 206 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -759,21 +759,22 @@ EditorComponent = React.createClass
return if @scrollViewMeasurementPaused
return unless @isMounted()
{editor} = @props
editorNode = @getDOMNode()
{editor, parentView} = @props
parentNode = parentView.element
scrollViewNode = @refs.scrollView.getDOMNode()
{position} = getComputedStyle(editorNode)
{width, height} = editorNode.style
{position} = getComputedStyle(parentNode)
{height} = parentNode.style
if position is 'absolute' or height
clientHeight = scrollViewNode.clientHeight
editor.setHeight(clientHeight) if clientHeight > 0
else
editor.setHeight(null)
if position is 'absolute' or width
clientWidth = scrollViewNode.clientWidth
paddingLeft = parseInt(getComputedStyle(scrollViewNode).paddingLeft)
clientWidth -= paddingLeft
editor.setWidth(clientWidth) if clientWidth > 0
clientWidth = scrollViewNode.clientWidth
paddingLeft = parseInt(getComputedStyle(scrollViewNode).paddingLeft)
clientWidth -= paddingLeft
editor.setWidth(clientWidth) if clientWidth > 0
measureLineHeightAndCharWidthsIfNeeded: (prevState) ->
if not isEqualForProperties(prevState, @state, 'lineHeight', 'fontSize', 'fontFamily')

View File

@@ -3,6 +3,10 @@
@import "octicon-mixins";
.editor.react {
.editor-contents {
width: 100%;
}
.underlayer {
position: absolute;
top: 0;