@webjourney/vite-plugins 1.2.10-2 → 1.2.11-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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,wBAAgB,uBAAuB;;;oBAKnB,MAAM,MAAM,MAAM;;;;EA6OrC;AAED,wBAAgB,sBAAsB;;;6BAKT,MAAM;EAoBlC;AAED,wBAAgB,iBAAiB;;;oBA1Qb,MAAM,MAAM,MAAM;;;;;;;6BAoPT,MAAM;KA0BlC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,wBAAgB,uBAAuB;;;oBAKnB,MAAM,MAAM,MAAM;;;;EAkSrC;AAED,wBAAgB,sBAAsB;;;6BAKT,MAAM;EAoBlC;AAED,wBAAgB,iBAAiB;;;oBA/Tb,MAAM,MAAM,MAAM;;;;;;;6BAyST,MAAM;KA0BlC"}
package/dist/index.js CHANGED
@@ -116,6 +116,36 @@ export function webjourneyElementTagger() {
116
116
  modified = true;
117
117
  }
118
118
  }
119
+ // Handle elements with bg-[url(...)] className pattern
120
+ // Check for Tailwind CSS arbitrary value background images
121
+ const classNameAttr = openingElement.attributes.find((attr) => t.isJSXAttribute(attr) &&
122
+ t.isJSXIdentifier(attr.name) &&
123
+ attr.name.name === 'className');
124
+ if (classNameAttr && t.isJSXAttribute(classNameAttr)) {
125
+ let classNameValue = '';
126
+ // Extract className value (could be string literal or template literal)
127
+ if (t.isStringLiteral(classNameAttr.value)) {
128
+ classNameValue = classNameAttr.value.value;
129
+ }
130
+ else if (t.isJSXExpressionContainer(classNameAttr.value) &&
131
+ t.isTemplateLiteral(classNameAttr.value.expression)) {
132
+ // For template literals, concatenate all string parts
133
+ const templateLiteral = classNameAttr.value.expression;
134
+ classNameValue = templateLiteral.quasis.map(q => q.value.raw).join('');
135
+ }
136
+ else if (t.isJSXExpressionContainer(classNameAttr.value) &&
137
+ t.isStringLiteral(classNameAttr.value.expression)) {
138
+ classNameValue = classNameAttr.value.expression.value;
139
+ }
140
+ // Check if className contains bg-[url(...)] pattern
141
+ const bgUrlPattern = /bg-\[url\([^\)]+\)\]/;
142
+ if (bgUrlPattern.test(classNameValue)) {
143
+ // Generate unique ID: filename:line
144
+ const elementId = `${relativePath}:${lineNumber}`;
145
+ openingElement.attributes.push(t.jsxAttribute(t.jsxIdentifier('data-wj-file'), t.stringLiteral(relativePath)), t.jsxAttribute(t.jsxIdentifier('data-wj-line'), t.stringLiteral(String(lineNumber))), t.jsxAttribute(t.jsxIdentifier('data-wj-type'), t.stringLiteral('background-image')), t.jsxAttribute(t.jsxIdentifier('data-wj-id'), t.stringLiteral(elementId)));
146
+ modified = true;
147
+ }
148
+ }
119
149
  // Handle anchor elements and Link components
120
150
  if (tagName === 'a' || tagName === 'Link') {
121
151
  // Check if anchor has href attribute or Link has to attribute
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webjourney/vite-plugins",
3
- "version": "1.2.10-2",
3
+ "version": "1.2.11-0",
4
4
  "description": "Vite plugins for Webjourney WYSIWYG editing",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",