Apply stylesheets with atom-editor-context in text editor specs

This commit is contained in:
Nathan Sobo
2014-10-16 12:42:29 -06:00
parent 268fceb073
commit b2bc09c13d
3 changed files with 17 additions and 15 deletions

View File

@@ -175,14 +175,14 @@ TextEditorComponent = React.createClass
@setScrollSensitivity(atom.config.get('editor.scrollSensitivity'))
componentDidMount: ->
{editor} = @props
{editor, stylesElement} = @props
@observeEditor()
@listenForDOMEvents()
@subscribe atom.themes.onDidAddStylesheet @onStylesheetsChanged
@subscribe atom.themes.onDidUpdateStylesheet @onStylesheetsChanged
@subscribe atom.themes.onDidRemoveStylesheet @onStylesheetsChanged
@subscribe stylesElement.onDidAddStyleElement @onStylesheetsChanged
@subscribe stylesElement.onDidUpdateStyleElement @onStylesheetsChanged
@subscribe stylesElement.onDidRemoveStyleElement @onStylesheetsChanged
unless atom.themes.isInitialLoadComplete()
@subscribe atom.themes.onDidReloadAll @onStylesheetsChanged
@subscribe scrollbarStyle.changes, @refreshScrollbars
@@ -622,11 +622,11 @@ TextEditorComponent = React.createClass
else
editor.setSelectedScreenRange([tailPosition, [dragRow + 1, 0]], preserveFolds: true)
onStylesheetsChanged: (stylesheet) ->
onStylesheetsChanged: (styleElement) ->
return unless @performedInitialMeasurement
return unless atom.themes.isInitialLoadComplete()
@refreshScrollbars() if not stylesheet? or @containsScrollbarSelector(stylesheet)
@refreshScrollbars() if not styleElement? or @containsScrollbarSelector(styleElement.sheet)
@sampleFontStyling()
@sampleBackgroundColors()
@remeasureCharacterWidths()

View File

@@ -24,12 +24,12 @@ class TextEditorElement extends HTMLElement
initializeContent: (attributes) ->
@classList.add('editor')
@setAttribute('tabindex', -1)
@shadowRoot = @createShadowRoot()
@createShadowRoot()
stylesElement = document.createElement('atom-styles')
stylesElement.setAttribute('context', 'atom-text-editor')
stylesElement.initialize()
@shadowRoot.appendChild(stylesElement)
@stylesElement = document.createElement('atom-styles')
@stylesElement.setAttribute('context', 'atom-text-editor')
@stylesElement.initialize()
@shadowRoot.appendChild(@stylesElement)
@rootElement = document.createElement('div')
@rootElement.classList.add('editor', 'editor-colors')
@@ -76,6 +76,7 @@ class TextEditorElement extends HTMLElement
@componentDescriptor ?= TextEditorComponent(
hostElement: this
rootElement: @rootElement
stylesElement: @stylesElement
editor: @model
mini: @model.mini
lineOverdrawMargin: @lineOverdrawMargin