Update `context.getClassList` usage (#707)
* Update `context.getClassList` usage * fix default metadatamaster
parent
637f838725
commit
0fab387f77
|
@ -1003,15 +1003,19 @@ async function createProjectService(
|
|||
state.jitContext = state.modules.jit.createContext.module(state)
|
||||
state.jitContext.tailwindConfig.separator = state.config.separator
|
||||
if (state.jitContext.getClassList) {
|
||||
state.classList = state.jitContext
|
||||
.getClassList()
|
||||
let classList = state.jitContext
|
||||
.getClassList({ includeMetadata: true })
|
||||
.filter((className) => className !== '*')
|
||||
.map((className) => {
|
||||
if (Array.isArray(className)) {
|
||||
return [className[0], { color: getColor(state, className[0]), ...className[1] }]
|
||||
}
|
||||
return [className, { color: getColor(state, className) }]
|
||||
})
|
||||
state.classListContainsMetadata = classList.some((cls) => Array.isArray(cls))
|
||||
state.classList = classList.map((className) => {
|
||||
if (Array.isArray(className)) {
|
||||
return [
|
||||
className[0],
|
||||
{ color: getColor(state, className[0]), ...(className[1] ?? {}) },
|
||||
]
|
||||
}
|
||||
return [className, { color: getColor(state, className) }]
|
||||
})
|
||||
}
|
||||
} else {
|
||||
delete state.jitContext
|
||||
|
|
|
@ -75,15 +75,12 @@ export function completionsFromClassList(
|
|||
// modifiers
|
||||
let modifiers: string[]
|
||||
let beforeSlash = partialClassName.split('/').slice(0, -1).join('/')
|
||||
let classListContainsModifiers = state.classList.some(
|
||||
(cls) => Array.isArray(cls) && cls[1].modifiers
|
||||
)
|
||||
|
||||
if (classListContainsModifiers) {
|
||||
if (state.classListContainsMetadata) {
|
||||
let baseClassName = beforeSlash.slice(offset)
|
||||
modifiers = state.classList.find(
|
||||
(cls) => Array.isArray(cls) && cls[0] === baseClassName
|
||||
)?.[1].modifiers
|
||||
)?.[1]?.modifiers
|
||||
} else {
|
||||
let testClass = beforeSlash + '/[0]'
|
||||
let { rules } = jit.generateRules(state, [testClass])
|
||||
|
|
|
@ -118,6 +118,7 @@ export interface State {
|
|||
jit?: boolean
|
||||
jitContext?: any
|
||||
classList?: Array<[string, { color: culori.Color | KeywordColor | null; modifiers?: string[] }]>
|
||||
classListContainsMetadata?: boolean
|
||||
pluginVersions?: string
|
||||
completionItemData?: Record<string, any>
|
||||
// postcssPlugins?: { before: any[]; after: any[] }
|
||||
|
|
Loading…
Reference in New Issue