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