Update settings
parent
f262bbbe92
commit
85ba6a42cb
27
package.json
27
package.json
|
@ -71,19 +71,20 @@
|
||||||
"default": {},
|
"default": {},
|
||||||
"markdownDescription": "Enable features in languages that are not supported by default. Add a mapping here between the new language and an already supported language.\n E.g.: `{\"plaintext\": \"html\"}`"
|
"markdownDescription": "Enable features in languages that are not supported by default. Add a mapping here between the new language and an already supported language.\n E.g.: `{\"plaintext\": \"html\"}`"
|
||||||
},
|
},
|
||||||
"tailwindCSS.colorDecorators.enabled": {
|
"tailwindCSS.colorDecorators": {
|
||||||
"type": "boolean",
|
"type": "string",
|
||||||
"default": true,
|
"enum": [
|
||||||
"scope": "language-overridable"
|
"inherit",
|
||||||
},
|
"on",
|
||||||
"tailwindCSS.colorDecorators.classes": {
|
"off"
|
||||||
"type": "boolean",
|
],
|
||||||
"default": true,
|
"markdownEnumDescriptions": [
|
||||||
"scope": "language-overridable"
|
"Color decorators are rendered if `editor.colorDecorators` is `true`.",
|
||||||
},
|
"Color decorators are rendered.",
|
||||||
"tailwindCSS.colorDecorators.cssHelpers": {
|
"Color decorators are not rendered."
|
||||||
"type": "boolean",
|
],
|
||||||
"default": true,
|
"default": "inherit",
|
||||||
|
"markdownDescription": "Controls whether the editor should render inline color decorators for Tailwind CSS classes and helper functions.",
|
||||||
"scope": "language-overridable"
|
"scope": "language-overridable"
|
||||||
},
|
},
|
||||||
"tailwindCSS.validate": {
|
"tailwindCSS.validate": {
|
||||||
|
|
|
@ -47,20 +47,22 @@ export function registerColorDecorator(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let settings = workspace.getConfiguration(
|
let preference =
|
||||||
'tailwindCSS.colorDecorators',
|
workspace.getConfiguration('tailwindCSS', editor.document)
|
||||||
editor.document
|
.colorDecorators || 'inherit'
|
||||||
)
|
|
||||||
|
|
||||||
if (settings.enabled !== true) {
|
let enabled =
|
||||||
|
preference === 'inherit'
|
||||||
|
? workspace.getConfiguration('editor').colorDecorators
|
||||||
|
: preference === 'on'
|
||||||
|
|
||||||
|
if (enabled !== true) {
|
||||||
editor.setDecorations(colorDecorationType, [])
|
editor.setDecorations(colorDecorationType, [])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let { colors } = await emitter.emit('getDocumentColors', {
|
let { colors } = await emitter.emit('getDocumentColors', {
|
||||||
document: editor.document.uri.toString(),
|
document: editor.document.uri.toString(),
|
||||||
classes: settings.classes,
|
|
||||||
cssHelpers: settings.cssHelpers,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
editor.setDecorations(
|
editor.setDecorations(
|
||||||
|
|
|
@ -7,7 +7,6 @@ import {
|
||||||
} from '../util/find'
|
} from '../util/find'
|
||||||
import { getClassNameParts } from '../util/getClassNameAtPosition'
|
import { getClassNameParts } from '../util/getClassNameAtPosition'
|
||||||
import { getColor, getColorFromValue } from '../util/color'
|
import { getColor, getColorFromValue } from '../util/color'
|
||||||
import { logFull } from '../util/logFull'
|
|
||||||
import { stringToPath } from '../util/stringToPath'
|
import { stringToPath } from '../util/stringToPath'
|
||||||
const dlv = require('dlv')
|
const dlv = require('dlv')
|
||||||
|
|
||||||
|
@ -15,12 +14,11 @@ export function registerDocumentColorProvider(state: State) {
|
||||||
onMessage(
|
onMessage(
|
||||||
state.editor.connection,
|
state.editor.connection,
|
||||||
'getDocumentColors',
|
'getDocumentColors',
|
||||||
async ({ document, classes, cssHelpers }) => {
|
async ({ document }) => {
|
||||||
let colors = []
|
let colors = []
|
||||||
let doc = state.editor.documents.get(document)
|
let doc = state.editor.documents.get(document)
|
||||||
if (!doc) return { colors }
|
if (!doc) return { colors }
|
||||||
|
|
||||||
if (classes) {
|
|
||||||
let classLists = findClassListsInDocument(state, doc)
|
let classLists = findClassListsInDocument(state, doc)
|
||||||
classLists.forEach((classList) => {
|
classLists.forEach((classList) => {
|
||||||
let classNames = getClassNamesInClassList(classList)
|
let classNames = getClassNamesInClassList(classList)
|
||||||
|
@ -32,9 +30,7 @@ export function registerDocumentColorProvider(state: State) {
|
||||||
colors.push({ range: className.range, color: color.documentation })
|
colors.push({ range: className.range, color: color.documentation })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
if (cssHelpers) {
|
|
||||||
let helperFns = findHelperFunctionsInDocument(state, doc)
|
let helperFns = findHelperFunctionsInDocument(state, doc)
|
||||||
helperFns.forEach((fn) => {
|
helperFns.forEach((fn) => {
|
||||||
let keys = stringToPath(fn.value)
|
let keys = stringToPath(fn.value)
|
||||||
|
@ -55,7 +51,6 @@ export function registerDocumentColorProvider(state: State) {
|
||||||
colors.push({ range: fn.valueRange, color })
|
colors.push({ range: fn.valueRange, color })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
return { colors }
|
return { colors }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue