@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.
- package/README.md +11 -11
- package/dist/editor.js +7497 -7188
- package/package.json +1 -1
- package/src/build-processor.ts +44 -1
- package/src/dev-middleware.ts +47 -2
- package/src/editor/components/collections-browser.tsx +10 -6
- package/src/editor/components/fields.tsx +7 -7
- package/src/editor/components/frontmatter-fields.tsx +163 -2
- package/src/editor/components/outline.tsx +165 -6
- package/src/editor/components/seo-editor.tsx +2 -1
- package/src/editor/components/text-style-toolbar.tsx +1 -1
- package/src/editor/components/toast/toast.tsx +19 -2
- package/src/editor/editor.ts +24 -25
- package/src/editor/index.tsx +100 -5
- package/src/editor/types.ts +4 -2
- package/src/handlers/array-ops.ts +102 -0
- package/src/handlers/source-writer.ts +6 -2
- package/src/html-processor.ts +8 -4
- package/src/index.ts +1 -1
- package/src/source-finder/cross-file-tracker.ts +42 -0
- package/src/source-finder/element-finder.ts +18 -4
- package/src/source-finder/snippet-utils.ts +3 -0
- package/src/source-finder/types.ts +3 -0
- package/src/source-finder/variable-extraction.ts +2 -2
- package/src/tailwind-colors.ts +33 -0
- package/src/types.ts +3 -0
|
@@ -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.
|
|
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
|
}
|
package/src/tailwind-colors.ts
CHANGED
|
@@ -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 {
|