@@ -57,6 +57,26 @@ describe "TextEditorElement", ->
|
|||||||
document.body.focus()
|
document.body.focus()
|
||||||
expect(blurCalled).toBe true
|
expect(blurCalled).toBe true
|
||||||
|
|
||||||
|
describe "style transfer", ->
|
||||||
|
beforeEach ->
|
||||||
|
waitsForPromise -> atom.themes.activateThemes()
|
||||||
|
|
||||||
|
afterEach ->
|
||||||
|
atom.themes.deactivateThemes()
|
||||||
|
|
||||||
|
ffit "transfers the foreground and background colors into the shadow DOM", ->
|
||||||
|
runs ->
|
||||||
|
element = new TextEditorElement()
|
||||||
|
jasmineContent.appendChild(element)
|
||||||
|
initialBackgroundColor = getComputedStyle(element.shadowRoot.querySelector('.editor')).backgroundColor
|
||||||
|
|
||||||
|
atom.styles.addStyleSheet """
|
||||||
|
atom-text-editor { background: red; }
|
||||||
|
"""
|
||||||
|
|
||||||
|
newBackgroundColor = getComputedStyle(element.shadowRoot.querySelector('.editor')).backgroundColor
|
||||||
|
expect(newBackgroundColor).not.toBe initialBackgroundColor
|
||||||
|
|
||||||
describe "when the themes finish loading with the shadow DOM disabled (regressios)", ->
|
describe "when the themes finish loading with the shadow DOM disabled (regressios)", ->
|
||||||
[themeReloadCallback, initialThemeLoadComplete, element] = []
|
[themeReloadCallback, initialThemeLoadComplete, element] = []
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ class TextEditorElement extends HTMLElement
|
|||||||
focusOnAttach: false
|
focusOnAttach: false
|
||||||
|
|
||||||
createdCallback: ->
|
createdCallback: ->
|
||||||
@subscriptions =
|
|
||||||
@initializeContent()
|
@initializeContent()
|
||||||
@createSpacePenShim()
|
@createSpacePenShim()
|
||||||
@addEventListener 'focus', @focused.bind(this)
|
@addEventListener 'focus', @focused.bind(this)
|
||||||
@@ -36,13 +35,18 @@ class TextEditorElement extends HTMLElement
|
|||||||
|
|
||||||
@shadowRoot.appendChild(@stylesElement)
|
@shadowRoot.appendChild(@stylesElement)
|
||||||
@shadowRoot.appendChild(@rootElement)
|
@shadowRoot.appendChild(@rootElement)
|
||||||
|
|
||||||
|
if atom.themes.isInitialLoadComplete()
|
||||||
|
@observeGlobalStyles()
|
||||||
|
else
|
||||||
|
loadSubscription = atom.themes.onDidReloadAll(@observeGlobalStyles.bind(this))
|
||||||
|
|
||||||
else
|
else
|
||||||
@stylesElement = document.head.querySelector('atom-styles')
|
@stylesElement = document.head.querySelector('atom-styles')
|
||||||
@rootElement = this
|
@rootElement = this
|
||||||
|
|
||||||
@rootElement.classList.add('editor', 'editor-colors')
|
@rootElement.classList.add('editor', 'editor-colors')
|
||||||
|
|
||||||
|
|
||||||
createSpacePenShim: ->
|
createSpacePenShim: ->
|
||||||
TextEditorView ?= require './text-editor-view'
|
TextEditorView ?= require './text-editor-view'
|
||||||
@__spacePenView = new TextEditorView(this)
|
@__spacePenView = new TextEditorView(this)
|
||||||
@@ -53,6 +57,29 @@ class TextEditorElement extends HTMLElement
|
|||||||
@component.checkForVisibilityChange()
|
@component.checkForVisibilityChange()
|
||||||
@focus() if @focusOnAttach
|
@focus() if @focusOnAttach
|
||||||
|
|
||||||
|
observeGlobalStyles: ->
|
||||||
|
globalStyles = document.head.querySelector('atom-styles')
|
||||||
|
globalStyles.onDidAddStyleElement(@transferComputedStyles.bind(this))
|
||||||
|
@transferComputedStyles()
|
||||||
|
|
||||||
|
transferComputedStyles: ->
|
||||||
|
unless @hostOverrideStyleElement?
|
||||||
|
@hostOverrideStyleElement = document.createElement('style')
|
||||||
|
@shadowRoot.insertBefore(@hostOverrideStyleElement, @stylesElement.nextSibling)
|
||||||
|
|
||||||
|
{color, backgroundColor} = getComputedStyle(this)
|
||||||
|
|
||||||
|
@hostOverrideStyleElement.textContent = """
|
||||||
|
.editor-colors {
|
||||||
|
background-color: #{backgroundColor};
|
||||||
|
color: #{color};
|
||||||
|
}
|
||||||
|
|
||||||
|
.cursor {
|
||||||
|
border-color: #{color};
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
setModel: (model) ->
|
setModel: (model) ->
|
||||||
throw new Error("Model already assigned on TextEditorElement") if @model?
|
throw new Error("Model already assigned on TextEditorElement") if @model?
|
||||||
return if model.isDestroyed()
|
return if model.isDestroyed()
|
||||||
|
|||||||
Referência em uma Nova Issue
Bloquear um usuário