mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Apply stylesheets with atom-editor-context in text editor specs
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user