@nuasite/cms-marker 0.0.73 → 0.0.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/html-processor.d.ts.map +1 -1
- package/dist/types/tailwind-colors.d.ts +4 -3
- package/dist/types/tailwind-colors.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/types.d.ts +28 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/html-processor.ts +117 -21
- package/src/tailwind-colors.ts +129 -15
- package/src/types.ts +30 -0
package/dist/types/types.d.ts
CHANGED
|
@@ -75,6 +75,30 @@ export interface TailwindColor {
|
|
|
75
75
|
/** Whether this is a custom/theme color vs default Tailwind */
|
|
76
76
|
isCustom?: boolean;
|
|
77
77
|
}
|
|
78
|
+
/** Opacity classes currently applied to an element */
|
|
79
|
+
export interface OpacityClasses {
|
|
80
|
+
/** Background opacity class (e.g., 'bg-opacity-90') */
|
|
81
|
+
bgOpacity?: string;
|
|
82
|
+
/** Text opacity class (e.g., 'text-opacity-50') */
|
|
83
|
+
textOpacity?: string;
|
|
84
|
+
/** Border opacity class (e.g., 'border-opacity-75') */
|
|
85
|
+
borderOpacity?: string;
|
|
86
|
+
}
|
|
87
|
+
/** Gradient color classes currently applied to an element */
|
|
88
|
+
export interface GradientClasses {
|
|
89
|
+
/** Gradient start color (e.g., 'from-blue-500') */
|
|
90
|
+
from?: string;
|
|
91
|
+
/** Gradient middle color (e.g., 'via-purple-500') */
|
|
92
|
+
via?: string;
|
|
93
|
+
/** Gradient end color (e.g., 'to-pink-500') */
|
|
94
|
+
to?: string;
|
|
95
|
+
/** Hover gradient start color (e.g., 'hover:from-blue-600') */
|
|
96
|
+
hoverFrom?: string;
|
|
97
|
+
/** Hover gradient middle color (e.g., 'hover:via-purple-600') */
|
|
98
|
+
hoverVia?: string;
|
|
99
|
+
/** Hover gradient end color (e.g., 'hover:to-pink-600') */
|
|
100
|
+
hoverTo?: string;
|
|
101
|
+
}
|
|
78
102
|
/** Color classes currently applied to an element */
|
|
79
103
|
export interface ColorClasses {
|
|
80
104
|
/** Background color class (e.g., 'bg-blue-500') */
|
|
@@ -89,6 +113,10 @@ export interface ColorClasses {
|
|
|
89
113
|
hoverText?: string;
|
|
90
114
|
/** Hover border color class (e.g., 'hover:border-blue-700') */
|
|
91
115
|
hoverBorder?: string;
|
|
116
|
+
/** Gradient color classes */
|
|
117
|
+
gradient?: GradientClasses;
|
|
118
|
+
/** Opacity classes */
|
|
119
|
+
opacity?: OpacityClasses;
|
|
92
120
|
/** All color-related classes as found in the element */
|
|
93
121
|
allColorClasses?: string[];
|
|
94
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAChC,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IAC7B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,OAAO,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EA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package/package.json
CHANGED
package/src/html-processor.ts
CHANGED
|
@@ -126,6 +126,33 @@ const TEXT_STYLE_PATTERNS = [
|
|
|
126
126
|
/^leading-/,
|
|
127
127
|
]
|
|
128
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Get text content from an HTML node, treating <br> elements as whitespace.
|
|
131
|
+
* This matches the rendered HTML behavior where <br> creates line breaks.
|
|
132
|
+
*/
|
|
133
|
+
function getTextContent(node: HTMLNode): string {
|
|
134
|
+
const result: string[] = []
|
|
135
|
+
|
|
136
|
+
for (const child of node.childNodes) {
|
|
137
|
+
if (child.nodeType === 3) {
|
|
138
|
+
// Text node
|
|
139
|
+
result.push(child.text || '')
|
|
140
|
+
} else if (child.nodeType === 1) {
|
|
141
|
+
// Element node
|
|
142
|
+
const tagName = (child as HTMLNode).tagName?.toLowerCase?.()
|
|
143
|
+
if (tagName === 'br') {
|
|
144
|
+
// Treat <br> as whitespace
|
|
145
|
+
result.push(' ')
|
|
146
|
+
} else {
|
|
147
|
+
// Recursively get text from child elements
|
|
148
|
+
result.push(getTextContent(child as HTMLNode))
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return result.join('')
|
|
154
|
+
}
|
|
155
|
+
|
|
129
156
|
/**
|
|
130
157
|
* Check if a class is a text styling class
|
|
131
158
|
*/
|
|
@@ -360,7 +387,7 @@ export async function processHtml(
|
|
|
360
387
|
)
|
|
361
388
|
|
|
362
389
|
if (firstChild) {
|
|
363
|
-
const firstChildText = (firstChild
|
|
390
|
+
const firstChildText = getTextContent(firstChild).trim().substring(0, 80)
|
|
364
391
|
if (firstChildText.includes(bodyStart)) {
|
|
365
392
|
// Count block-level child elements
|
|
366
393
|
// Markdown typically renders to multiple block elements (p, h2, h3, ul, ol, etc.)
|
|
@@ -424,6 +451,22 @@ export async function processHtml(
|
|
|
424
451
|
const src = node.getAttribute('src')
|
|
425
452
|
if (!src) return // Skip images without src
|
|
426
453
|
|
|
454
|
+
// When skipMarkdownContent is true (collection pages), only mark images
|
|
455
|
+
// that have source file attributes (from Astro templates, not markdown)
|
|
456
|
+
if (skipMarkdownContent) {
|
|
457
|
+
// Check if the image or any ancestor has source file attribute
|
|
458
|
+
let hasSourceAttr = false
|
|
459
|
+
let current: HTMLNode | null = node
|
|
460
|
+
while (current) {
|
|
461
|
+
if (current.getAttribute?.('data-astro-source-file')) {
|
|
462
|
+
hasSourceAttr = true
|
|
463
|
+
break
|
|
464
|
+
}
|
|
465
|
+
current = current.parentNode as HTMLNode | null
|
|
466
|
+
}
|
|
467
|
+
if (!hasSourceAttr) return
|
|
468
|
+
}
|
|
469
|
+
|
|
427
470
|
const id = getNextId()
|
|
428
471
|
node.setAttribute(attributeName, id)
|
|
429
472
|
node.setAttribute('data-cms-img', 'true')
|
|
@@ -463,13 +506,23 @@ export async function processHtml(
|
|
|
463
506
|
})
|
|
464
507
|
})
|
|
465
508
|
|
|
466
|
-
// Third pass:
|
|
509
|
+
// Third pass: collect candidate text elements (don't mark yet)
|
|
510
|
+
// We collect candidates first to filter out pure containers before marking
|
|
511
|
+
interface TextCandidate {
|
|
512
|
+
node: HTMLNode
|
|
513
|
+
tag: string
|
|
514
|
+
sourceFile: string | undefined
|
|
515
|
+
sourceLine: string | undefined
|
|
516
|
+
}
|
|
517
|
+
const textCandidates: TextCandidate[] = []
|
|
518
|
+
const candidateNodes = new Set<HTMLNode>()
|
|
519
|
+
|
|
467
520
|
root.querySelectorAll('*').forEach((node) => {
|
|
468
521
|
const tag = node.tagName?.toLowerCase?.() ?? ''
|
|
469
522
|
|
|
470
523
|
if (excludeTags.includes(tag)) return
|
|
471
524
|
if (includeTags && !includeTags.includes(tag)) return
|
|
472
|
-
if (node.getAttribute(attributeName)) return // Already marked
|
|
525
|
+
if (node.getAttribute(attributeName)) return // Already marked (images, collection wrapper)
|
|
473
526
|
|
|
474
527
|
// Skip elements inside markdown wrapper - they are edited via the markdown editor
|
|
475
528
|
if (isInsideMarkdownWrapper(node)) return
|
|
@@ -491,11 +544,10 @@ export async function processHtml(
|
|
|
491
544
|
}
|
|
492
545
|
}
|
|
493
546
|
|
|
494
|
-
const textContent = (node
|
|
547
|
+
const textContent = getTextContent(node).trim()
|
|
495
548
|
if (!includeEmptyText && !textContent) return
|
|
496
549
|
|
|
497
550
|
// Extract source location from Astro compiler attributes
|
|
498
|
-
// Support both Astro's native attribute (data-astro-source-loc) and our custom one (data-astro-source-line)
|
|
499
551
|
const sourceFile = node.getAttribute('data-astro-source-file')
|
|
500
552
|
const sourceLine = node.getAttribute('data-astro-source-loc')
|
|
501
553
|
|| node.getAttribute('data-astro-source-line')
|
|
@@ -506,6 +558,59 @@ export async function processHtml(
|
|
|
506
558
|
return
|
|
507
559
|
}
|
|
508
560
|
|
|
561
|
+
textCandidates.push({ node, tag, sourceFile: sourceFile || undefined, sourceLine: sourceLine || undefined })
|
|
562
|
+
candidateNodes.add(node)
|
|
563
|
+
})
|
|
564
|
+
|
|
565
|
+
// Helper to check if a node has direct text (text not inside candidate descendants)
|
|
566
|
+
const hasDirectText = (node: HTMLNode): boolean => {
|
|
567
|
+
// Check for text nodes directly under this element (not inside candidate children)
|
|
568
|
+
for (const child of node.childNodes) {
|
|
569
|
+
if (child.nodeType === 3) {
|
|
570
|
+
// Text node
|
|
571
|
+
const text = (child.text || '').trim()
|
|
572
|
+
if (text) return true
|
|
573
|
+
} else if (child.nodeType === 1) {
|
|
574
|
+
// Element node - only recurse if it's not a candidate
|
|
575
|
+
const childEl = child as HTMLNode
|
|
576
|
+
if (!candidateNodes.has(childEl) && !childEl.getAttribute?.(attributeName)) {
|
|
577
|
+
if (hasDirectText(childEl)) return true
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
return false
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
// Helper to check if a node has any candidate or already-marked descendants
|
|
585
|
+
const hasCandidateDescendants = (node: HTMLNode): boolean => {
|
|
586
|
+
for (const child of node.childNodes) {
|
|
587
|
+
if (child.nodeType === 1) {
|
|
588
|
+
const childEl = child as HTMLNode
|
|
589
|
+
if (candidateNodes.has(childEl) || childEl.getAttribute?.(attributeName)) {
|
|
590
|
+
return true
|
|
591
|
+
}
|
|
592
|
+
if (hasCandidateDescendants(childEl)) return true
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
return false
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// Filter out pure containers (no direct text, only candidate/marked children)
|
|
599
|
+
// and mark remaining candidates
|
|
600
|
+
for (const candidate of textCandidates) {
|
|
601
|
+
const { node, sourceFile, sourceLine } = candidate
|
|
602
|
+
|
|
603
|
+
// Check if this is a pure container (no direct text, only has candidate descendants)
|
|
604
|
+
const directText = hasDirectText(node)
|
|
605
|
+
const hasDescendants = hasCandidateDescendants(node)
|
|
606
|
+
|
|
607
|
+
// Skip pure containers - they have no direct text and all content comes from children
|
|
608
|
+
if (!directText && hasDescendants) {
|
|
609
|
+
candidateNodes.delete(node) // Remove from candidates so nested checks stay accurate
|
|
610
|
+
continue
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
// Mark this element
|
|
509
614
|
const id = getNextId()
|
|
510
615
|
node.setAttribute(attributeName, id)
|
|
511
616
|
|
|
@@ -522,9 +627,9 @@ export async function processHtml(
|
|
|
522
627
|
node.removeAttribute('data-astro-source-line')
|
|
523
628
|
}
|
|
524
629
|
}
|
|
525
|
-
}
|
|
630
|
+
}
|
|
526
631
|
|
|
527
|
-
// Fourth pass: build manifest entries
|
|
632
|
+
// Fourth pass: build manifest entries for all marked elements
|
|
528
633
|
if (generateManifest) {
|
|
529
634
|
root.querySelectorAll(`[${attributeName}]`).forEach((node) => {
|
|
530
635
|
const id = node.getAttribute(attributeName)
|
|
@@ -565,18 +670,6 @@ export async function processHtml(
|
|
|
565
670
|
|
|
566
671
|
const textWithPlaceholders = buildTextWithPlaceholders((node.childNodes || []) as ChildNode[])
|
|
567
672
|
|
|
568
|
-
// Get direct text content (without placeholders)
|
|
569
|
-
const directText = textWithPlaceholders.replace(/\{\{cms:[^}]+\}\}/g, '').trim()
|
|
570
|
-
|
|
571
|
-
// Check if this is the collection wrapper
|
|
572
|
-
const isCollectionWrapper = id === collectionWrapperId
|
|
573
|
-
|
|
574
|
-
// Skip pure container elements (no direct text, only child CMS elements)
|
|
575
|
-
// BUT always include the collection wrapper
|
|
576
|
-
if (!directText && childCmsIds.length > 0 && !isCollectionWrapper) {
|
|
577
|
-
return
|
|
578
|
-
}
|
|
579
|
-
|
|
580
673
|
// Get source location from map (injected by Astro compiler)
|
|
581
674
|
const sourceLocation = sourceLocationMap.get(id)
|
|
582
675
|
|
|
@@ -606,6 +699,9 @@ export async function processHtml(
|
|
|
606
699
|
const imageInfo = imageEntries.get(id)
|
|
607
700
|
const isImage = !!imageInfo
|
|
608
701
|
|
|
702
|
+
// Check if this is the collection wrapper
|
|
703
|
+
const isCollectionWrapper = id === collectionWrapperId
|
|
704
|
+
|
|
609
705
|
const entryText = isImage ? (imageInfo.metadata.alt || imageInfo.metadata.src) : textWithPlaceholders.trim()
|
|
610
706
|
// For images, use the source file we captured from ancestors if not in sourceLocationMap
|
|
611
707
|
const entrySourcePath = sourceLocation?.file || imageInfo?.sourceFile || sourcePath
|
|
@@ -701,7 +797,7 @@ function extractSourceContext(node: HTMLNode, attributeName: string): SourceCont
|
|
|
701
797
|
let precedingText: string | undefined
|
|
702
798
|
if (siblingIndex > 0) {
|
|
703
799
|
const prevSibling = siblings[siblingIndex - 1]
|
|
704
|
-
const prevText =
|
|
800
|
+
const prevText = prevSibling ? getTextContent(prevSibling).trim() : ''
|
|
705
801
|
if (prevText) {
|
|
706
802
|
precedingText = prevText.substring(0, 30)
|
|
707
803
|
}
|
|
@@ -711,7 +807,7 @@ function extractSourceContext(node: HTMLNode, attributeName: string): SourceCont
|
|
|
711
807
|
let followingText: string | undefined
|
|
712
808
|
if (siblingIndex < siblings.length - 1) {
|
|
713
809
|
const nextSibling = siblings[siblingIndex + 1]
|
|
714
|
-
const nextText =
|
|
810
|
+
const nextText = nextSibling ? getTextContent(nextSibling).trim() : ''
|
|
715
811
|
if (nextText) {
|
|
716
812
|
followingText = nextText.substring(0, 30)
|
|
717
813
|
}
|
package/src/tailwind-colors.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs/promises'
|
|
2
2
|
import path from 'node:path'
|
|
3
3
|
import { getProjectRoot } from './config'
|
|
4
|
-
import type { AvailableColors, AvailableTextStyles, ColorClasses, TailwindColor, TextStyleValue } from './types'
|
|
4
|
+
import type { AvailableColors, AvailableTextStyles, ColorClasses, GradientClasses, OpacityClasses, TailwindColor, TextStyleValue } from './types'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Default Tailwind CSS v4 color names.
|
|
@@ -396,12 +396,36 @@ const DEFAULT_FONT_STYLES: TextStyleValue[] = [
|
|
|
396
396
|
{ class: 'italic', label: 'Italic', css: { fontStyle: 'italic' } },
|
|
397
397
|
]
|
|
398
398
|
|
|
399
|
+
/**
|
|
400
|
+
* Non-color utility suffixes that should not be matched as custom colors.
|
|
401
|
+
* These follow the pattern `prefix-word-number` but are not colors.
|
|
402
|
+
*/
|
|
403
|
+
const NON_COLOR_SUFFIXES = ['opacity'] as const
|
|
404
|
+
|
|
399
405
|
/**
|
|
400
406
|
* Build a regex pattern for matching color classes.
|
|
407
|
+
* Matches:
|
|
408
|
+
* - Default colors with optional shades: bg-blue-500, bg-white
|
|
409
|
+
* - Custom theme colors with shades: bg-primary-500
|
|
410
|
+
* - Arbitrary hex values: bg-[#41b883], bg-[#fff]
|
|
411
|
+
* - Arbitrary rgb/hsl values: bg-[rgb(255,0,0)], bg-[hsl(0,100%,50%)]
|
|
412
|
+
* Excludes non-color utilities like opacity.
|
|
401
413
|
*/
|
|
402
414
|
function buildColorPattern(prefix: string): RegExp {
|
|
403
415
|
const colorNames = [...DEFAULT_TAILWIND_COLORS, ...SPECIAL_COLORS].join('|')
|
|
404
|
-
|
|
416
|
+
const excluded = NON_COLOR_SUFFIXES.join('|')
|
|
417
|
+
// Arbitrary value patterns for colors
|
|
418
|
+
const arbitraryHex = '\\[#[0-9a-fA-F]{3,8}\\]'
|
|
419
|
+
const arbitraryFunc = '\\[(?:rgba?|hsla?)\\([^\\]]+\\)\\]'
|
|
420
|
+
// Match: prefix-(colorName[-shade]?) OR prefix-(customColor-shade) OR prefix-[arbitrary] but NOT prefix-(excluded-number)
|
|
421
|
+
return new RegExp(`^${prefix}-((?:${colorNames})(?:-(\\d+))?|(?!(?:${excluded})-)(\\w+)-(\\d+)|${arbitraryHex}|${arbitraryFunc})$`)
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Build a regex pattern for matching opacity classes.
|
|
426
|
+
*/
|
|
427
|
+
function buildOpacityPattern(prefix: string): RegExp {
|
|
428
|
+
return new RegExp(`^${prefix}-opacity-(\\d+)$`)
|
|
405
429
|
}
|
|
406
430
|
|
|
407
431
|
/**
|
|
@@ -416,6 +440,27 @@ const COLOR_CLASS_PATTERNS = {
|
|
|
416
440
|
hoverBorder: buildColorPattern('hover:border'),
|
|
417
441
|
}
|
|
418
442
|
|
|
443
|
+
/**
|
|
444
|
+
* Regex patterns to match Tailwind opacity classes.
|
|
445
|
+
*/
|
|
446
|
+
const OPACITY_CLASS_PATTERNS = {
|
|
447
|
+
bgOpacity: buildOpacityPattern('bg'),
|
|
448
|
+
textOpacity: buildOpacityPattern('text'),
|
|
449
|
+
borderOpacity: buildOpacityPattern('border'),
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Regex patterns to match Tailwind gradient color classes.
|
|
454
|
+
*/
|
|
455
|
+
const GRADIENT_CLASS_PATTERNS = {
|
|
456
|
+
from: buildColorPattern('from'),
|
|
457
|
+
via: buildColorPattern('via'),
|
|
458
|
+
to: buildColorPattern('to'),
|
|
459
|
+
hoverFrom: buildColorPattern('hover:from'),
|
|
460
|
+
hoverVia: buildColorPattern('hover:via'),
|
|
461
|
+
hoverTo: buildColorPattern('hover:to'),
|
|
462
|
+
}
|
|
463
|
+
|
|
419
464
|
/**
|
|
420
465
|
* Parse Tailwind v4 CSS config to extract available colors with their values.
|
|
421
466
|
*/
|
|
@@ -664,35 +709,84 @@ export function extractColorClasses(classAttr: string | null | undefined): Color
|
|
|
664
709
|
|
|
665
710
|
const classes = classAttr.split(/\s+/).filter(Boolean)
|
|
666
711
|
const colorClasses: ColorClasses = {}
|
|
712
|
+
const opacityClasses: OpacityClasses = {}
|
|
713
|
+
const gradientClasses: GradientClasses = {}
|
|
667
714
|
const allColorClasses: string[] = []
|
|
668
715
|
|
|
669
716
|
for (const cls of classes) {
|
|
717
|
+
// Check color patterns
|
|
718
|
+
let matched = false
|
|
670
719
|
for (const [key, pattern] of Object.entries(COLOR_CLASS_PATTERNS)) {
|
|
671
720
|
const match = cls.match(pattern)
|
|
672
721
|
if (match) {
|
|
673
722
|
allColorClasses.push(cls)
|
|
674
|
-
const colorKey = key as keyof Omit<ColorClasses, 'allColorClasses'>
|
|
723
|
+
const colorKey = key as keyof Omit<ColorClasses, 'allColorClasses' | 'opacity' | 'gradient'>
|
|
675
724
|
if (!(colorKey in colorClasses)) {
|
|
676
725
|
colorClasses[colorKey] = cls
|
|
677
726
|
}
|
|
727
|
+
matched = true
|
|
678
728
|
break
|
|
679
729
|
}
|
|
680
730
|
}
|
|
731
|
+
|
|
732
|
+
// Check gradient patterns if not already matched
|
|
733
|
+
if (!matched) {
|
|
734
|
+
for (const [key, pattern] of Object.entries(GRADIENT_CLASS_PATTERNS)) {
|
|
735
|
+
const match = cls.match(pattern)
|
|
736
|
+
if (match) {
|
|
737
|
+
allColorClasses.push(cls)
|
|
738
|
+
const gradientKey = key as keyof GradientClasses
|
|
739
|
+
if (!(gradientKey in gradientClasses)) {
|
|
740
|
+
gradientClasses[gradientKey] = cls
|
|
741
|
+
}
|
|
742
|
+
matched = true
|
|
743
|
+
break
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
// Check opacity patterns if not already matched
|
|
749
|
+
if (!matched) {
|
|
750
|
+
for (const [key, pattern] of Object.entries(OPACITY_CLASS_PATTERNS)) {
|
|
751
|
+
const match = cls.match(pattern)
|
|
752
|
+
if (match) {
|
|
753
|
+
const opacityKey = key as keyof OpacityClasses
|
|
754
|
+
if (!(opacityKey in opacityClasses)) {
|
|
755
|
+
opacityClasses[opacityKey] = cls
|
|
756
|
+
}
|
|
757
|
+
break
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// Add gradient if any found
|
|
764
|
+
if (Object.keys(gradientClasses).length > 0) {
|
|
765
|
+
colorClasses.gradient = gradientClasses
|
|
681
766
|
}
|
|
682
767
|
|
|
683
|
-
|
|
768
|
+
// Add opacity if any found
|
|
769
|
+
if (Object.keys(opacityClasses).length > 0) {
|
|
770
|
+
colorClasses.opacity = opacityClasses
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
if (allColorClasses.length === 0 && !colorClasses.opacity) {
|
|
684
774
|
return undefined
|
|
685
775
|
}
|
|
686
776
|
|
|
687
|
-
|
|
777
|
+
if (allColorClasses.length > 0) {
|
|
778
|
+
colorClasses.allColorClasses = allColorClasses
|
|
779
|
+
}
|
|
780
|
+
|
|
688
781
|
return colorClasses
|
|
689
782
|
}
|
|
690
783
|
|
|
691
784
|
/**
|
|
692
|
-
* Check if a class is a color class.
|
|
785
|
+
* Check if a class is a color class (including gradient colors).
|
|
693
786
|
*/
|
|
694
787
|
export function isColorClass(className: string): boolean {
|
|
695
788
|
return Object.values(COLOR_CLASS_PATTERNS).some(pattern => pattern.test(className))
|
|
789
|
+
|| Object.values(GRADIENT_CLASS_PATTERNS).some(pattern => pattern.test(className))
|
|
696
790
|
}
|
|
697
791
|
|
|
698
792
|
/**
|
|
@@ -711,12 +805,17 @@ export function replaceColorClass(
|
|
|
711
805
|
/**
|
|
712
806
|
* Get the color type from a color class.
|
|
713
807
|
*/
|
|
714
|
-
export function getColorType(colorClass: string): keyof ColorClasses | undefined {
|
|
808
|
+
export function getColorType(colorClass: string): keyof ColorClasses | keyof GradientClasses | undefined {
|
|
715
809
|
for (const [key, pattern] of Object.entries(COLOR_CLASS_PATTERNS)) {
|
|
716
810
|
if (pattern.test(colorClass)) {
|
|
717
811
|
return key as keyof ColorClasses
|
|
718
812
|
}
|
|
719
813
|
}
|
|
814
|
+
for (const [key, pattern] of Object.entries(GRADIENT_CLASS_PATTERNS)) {
|
|
815
|
+
if (pattern.test(colorClass)) {
|
|
816
|
+
return key as keyof GradientClasses
|
|
817
|
+
}
|
|
818
|
+
}
|
|
720
819
|
return undefined
|
|
721
820
|
}
|
|
722
821
|
|
|
@@ -728,20 +827,35 @@ export function parseColorClass(colorClass: string): {
|
|
|
728
827
|
colorName: string
|
|
729
828
|
shade?: string
|
|
730
829
|
isHover: boolean
|
|
830
|
+
isArbitrary?: boolean
|
|
731
831
|
} | undefined {
|
|
732
832
|
const isHover = colorClass.startsWith('hover:')
|
|
733
833
|
const classWithoutHover = isHover ? colorClass.slice(6) : colorClass
|
|
734
834
|
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
if (
|
|
835
|
+
// Try matching standard color classes (default colors, custom theme colors, and gradients)
|
|
836
|
+
const standardMatch = classWithoutHover.match(/^(bg|text|border|from|via|to)-([a-z]+)(?:-(\d+))?$/)
|
|
837
|
+
if (standardMatch) {
|
|
838
|
+
return {
|
|
839
|
+
prefix: isHover ? `hover:${standardMatch[1]}` : standardMatch[1]!,
|
|
840
|
+
colorName: standardMatch[2]!,
|
|
841
|
+
shade: standardMatch[3],
|
|
842
|
+
isHover,
|
|
843
|
+
}
|
|
844
|
+
}
|
|
738
845
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
846
|
+
// Try matching arbitrary value classes like bg-[#41b883] or from-[#41b883]
|
|
847
|
+
const arbitraryMatch = classWithoutHover.match(/^(bg|text|border|from|via|to)-(\[.+\])$/)
|
|
848
|
+
if (arbitraryMatch) {
|
|
849
|
+
return {
|
|
850
|
+
prefix: isHover ? `hover:${arbitraryMatch[1]}` : arbitraryMatch[1]!,
|
|
851
|
+
colorName: arbitraryMatch[2]!,
|
|
852
|
+
shade: undefined,
|
|
853
|
+
isHover,
|
|
854
|
+
isArbitrary: true,
|
|
855
|
+
}
|
|
744
856
|
}
|
|
857
|
+
|
|
858
|
+
return undefined
|
|
745
859
|
}
|
|
746
860
|
|
|
747
861
|
/**
|
package/src/types.ts
CHANGED
|
@@ -79,6 +79,32 @@ export interface TailwindColor {
|
|
|
79
79
|
isCustom?: boolean
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/** Opacity classes currently applied to an element */
|
|
83
|
+
export interface OpacityClasses {
|
|
84
|
+
/** Background opacity class (e.g., 'bg-opacity-90') */
|
|
85
|
+
bgOpacity?: string
|
|
86
|
+
/** Text opacity class (e.g., 'text-opacity-50') */
|
|
87
|
+
textOpacity?: string
|
|
88
|
+
/** Border opacity class (e.g., 'border-opacity-75') */
|
|
89
|
+
borderOpacity?: string
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Gradient color classes currently applied to an element */
|
|
93
|
+
export interface GradientClasses {
|
|
94
|
+
/** Gradient start color (e.g., 'from-blue-500') */
|
|
95
|
+
from?: string
|
|
96
|
+
/** Gradient middle color (e.g., 'via-purple-500') */
|
|
97
|
+
via?: string
|
|
98
|
+
/** Gradient end color (e.g., 'to-pink-500') */
|
|
99
|
+
to?: string
|
|
100
|
+
/** Hover gradient start color (e.g., 'hover:from-blue-600') */
|
|
101
|
+
hoverFrom?: string
|
|
102
|
+
/** Hover gradient middle color (e.g., 'hover:via-purple-600') */
|
|
103
|
+
hoverVia?: string
|
|
104
|
+
/** Hover gradient end color (e.g., 'hover:to-pink-600') */
|
|
105
|
+
hoverTo?: string
|
|
106
|
+
}
|
|
107
|
+
|
|
82
108
|
/** Color classes currently applied to an element */
|
|
83
109
|
export interface ColorClasses {
|
|
84
110
|
/** Background color class (e.g., 'bg-blue-500') */
|
|
@@ -93,6 +119,10 @@ export interface ColorClasses {
|
|
|
93
119
|
hoverText?: string
|
|
94
120
|
/** Hover border color class (e.g., 'hover:border-blue-700') */
|
|
95
121
|
hoverBorder?: string
|
|
122
|
+
/** Gradient color classes */
|
|
123
|
+
gradient?: GradientClasses
|
|
124
|
+
/** Opacity classes */
|
|
125
|
+
opacity?: OpacityClasses
|
|
96
126
|
/** All color-related classes as found in the element */
|
|
97
127
|
allColorClasses?: string[]
|
|
98
128
|
}
|