@nuasite/cms 0.5.1 → 0.7.0

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.
@@ -300,8 +300,8 @@ export async function resolveImportPath(source: string, fromFile: string): Promi
300
300
  for (const ext of extensions) {
301
301
  const fullPath = basePath + ext
302
302
  try {
303
- await fs.access(fullPath)
304
- return fullPath
303
+ const stat = await fs.stat(fullPath)
304
+ if (stat.isFile()) return fullPath
305
305
  } catch {
306
306
  // File doesn't exist with this extension
307
307
  }
@@ -776,6 +776,39 @@ export function extractColorClasses(classAttr: string | null | undefined): Recor
776
776
  return Object.keys(result).length > 0 ? result : undefined
777
777
  }
778
778
 
779
+ /**
780
+ * Regex patterns for matching text style classes on elements.
781
+ */
782
+ const TEXT_STYLE_CLASS_PATTERNS: Record<string, RegExp> = {
783
+ fontWeight: /^font-(thin|extralight|light|normal|medium|semibold|bold|extrabold|black)$/,
784
+ fontStyle: /^(italic|not-italic)$/,
785
+ textDecoration: /^(underline|overline|line-through|no-underline)$/,
786
+ fontSize: /^text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/,
787
+ }
788
+
789
+ /**
790
+ * Extract text style classes from an element's class attribute.
791
+ * Returns a Record<string, Attribute> with keys: fontWeight, fontStyle, textDecoration, fontSize.
792
+ * Pattern: same as extractColorClasses — scan classes, match patterns, return first match per category.
793
+ */
794
+ export function extractTextStyleClasses(classAttr: string | null | undefined): Record<string, Attribute> | undefined {
795
+ if (!classAttr) return undefined
796
+
797
+ const classes = classAttr.split(/\s+/).filter(Boolean)
798
+ const result: Record<string, Attribute> = {}
799
+
800
+ for (const cls of classes) {
801
+ for (const [key, pattern] of Object.entries(TEXT_STYLE_CLASS_PATTERNS)) {
802
+ if (pattern.test(cls) && !(key in result)) {
803
+ result[key] = { value: cls }
804
+ break
805
+ }
806
+ }
807
+ }
808
+
809
+ return Object.keys(result).length > 0 ? result : undefined
810
+ }
811
+
779
812
  /**
780
813
  * Check if a class is a color class (including gradient colors).
781
814
  */
package/src/types.ts CHANGED
@@ -161,6 +161,9 @@ export interface ManifestEntry {
161
161
  colorClasses?: Record<string, Attribute>
162
162
  /** All HTML attributes with source information */
163
163
  attributes?: Record<string, Attribute>
164
+ /** Whether inline text styling (bold, italic, etc.) can be applied.
165
+ * False when text comes from a string variable/prop that cannot contain HTML markup. */
166
+ allowStyling?: boolean
164
167
  }
165
168
 
166
169
  export interface ComponentInstance {