Skip to content

Commit

Permalink
fix: import domStylesReader
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jan 12, 2021
1 parent 46974fe commit 10730c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
12 changes: 5 additions & 7 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const emitter = new Emitter()
/**
DOMStylesReader cache used for storing token colors
*/
let DOMStylesReaderInstance = null
export let domStylesReader = null

/**
* Activates the minimap package.
Expand All @@ -92,7 +92,7 @@ export function activate () {
})

editorsMinimaps = new Map()
DOMStylesReaderInstance = new DOMStylesReader()
domStylesReader = new DOMStylesReader()

subscriptions = new CompositeDisposable()
active = true
Expand All @@ -109,8 +109,6 @@ export function activate () {
export function minimapViewProvider (model) {
if (model instanceof Minimap) {
const element = new MinimapElement()
// add DOMStylesReaderInstance
element.DOMStylesReader = DOMStylesReaderInstance;
element.setModel(model)
return element
}
Expand All @@ -136,7 +134,7 @@ export function deactivate () {
subscriptionsOfCommands.dispose()
subscriptionsOfCommands = null
editorsMinimaps = undefined
DOMStylesReaderInstance.invalidateDOMStylesCache()
domStylesReader.invalidateDOMStylesCache()
toggled = false
active = false
}
Expand Down Expand Up @@ -165,7 +163,7 @@ export function toggle () {
toggled = true
initSubscriptions()
}
DOMStylesReaderInstance.invalidateDOMStylesCache()
domStylesReader.invalidateDOMStylesCache()
}

/**
Expand Down Expand Up @@ -373,7 +371,7 @@ function initSubscriptions () {
}),
// empty color cache if the theme changes
atom.themes.onDidChangeActiveThemes(() => {
DOMStylesReaderInstance.invalidateDOMStylesCache()
domStylesReader.invalidateDOMStylesCache()
editorsMinimaps.forEach((minimap) => { atom.views.getView(minimap).requestForcedUpdate() })
}),
treeSitterWarning()
Expand Down
7 changes: 4 additions & 3 deletions lib/mixins/canvas-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { escapeRegExp } from 'underscore-plus'
import Mixin from 'mixto'

import * as Main from '../main'
import { domStylesReader } from '../main'
import CanvasLayer from '../canvas-layer'

const SPEC_MODE = atom.inSpecMode()
Expand Down Expand Up @@ -303,7 +304,7 @@ export default class CanvasDrawer extends Mixin {
* @return {string} a CSS color
*/
getDefaultColor (editorElement) {
const color = this.DOMStylesReader.retrieveStyleFromDom(['.editor'], 'color', editorElement, true)
const color = domStylesReader.retrieveStyleFromDom(['.editor'], 'color', editorElement, true)
return transparentize(color, this.textOpacity)
}

Expand All @@ -318,7 +319,7 @@ export default class CanvasDrawer extends Mixin {
* @return {string} the CSS color for the provided token
*/
getTokenColor (scopes, editorElement) {
const color = this.DOMStylesReader.retrieveStyleFromDom(scopes, 'color', editorElement, true)
const color = domStylesReader.retrieveStyleFromDom(scopes, 'color', editorElement, true)

return transparentize(color, this.textOpacity)
}
Expand All @@ -340,7 +341,7 @@ export default class CanvasDrawer extends Mixin {

if (properties.scope) {
const scopeString = properties.scope.split(oneOrMoreWhiteSpaceRegexp)
return this.DOMStylesReader.retrieveStyleFromDom(scopeString, 'background-color', editorElement, true)
return domStylesReader.retrieveStyleFromDom(scopeString, 'background-color', editorElement, true)
} else {
return this.getDefaultColor(editorElement)
}
Expand Down

0 comments on commit 10730c9

Please sign in to comment.