Load editor stylesheet in shadow root with style manager context param

This commit is contained in:
Nathan Sobo
2014-10-14 17:05:37 -06:00
parent 2affff30ff
commit c2d0b6d4f5
4 changed files with 116 additions and 113 deletions

View File

@@ -26,6 +26,10 @@ class TextEditorElement extends HTMLElement
@setAttribute('tabindex', -1)
@shadowRoot = @createShadowRoot()
stylesElement = document.createElement('atom-styles')
stylesElement.setAttribute('context', 'atom-text-editor')
@shadowRoot.appendChild(stylesElement)
for styleElement in document.querySelectorAll('head style.syntax-theme')
@shadowRoot.appendChild(styleElement.cloneNode(true))

View File

@@ -249,6 +249,9 @@ class ThemeManager
if nativeStylesheetPath = fs.resolveOnLoadPath(process.platform, ['css', 'less'])
@requireStylesheet(nativeStylesheetPath)
textEditorStylesPath = path.join(@resourcePath, 'static', 'editor.less')
atom.styles.addStyleSheet(@loadLessStylesheet(textEditorStylesPath), sourcePath: 'textEditorStylesPath', context: 'atom-text-editor')
stylesheetElementForId: (id) ->
document.head.querySelector("atom-styles style[source-path=\"#{id}\"]")