@cocreate/plugins 1.0.3 → 1.1.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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/index.js +25 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.1.0](https://github.com/CoCreate-app/CoCreate-plugins/compare/v1.0.3...v1.1.0) (2026-01-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add marker to indicate where css files will be inserted ([6b4b030](https://github.com/CoCreate-app/CoCreate-plugins/commit/6b4b0301acdabff19b8cca5968cc67619e417c92))
|
|
7
|
+
|
|
1
8
|
## [1.0.3](https://github.com/CoCreate-app/CoCreate-plugins/compare/v1.0.2...v1.0.3) (2025-12-26)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -172,6 +172,8 @@ const plugins = {
|
|
|
172
172
|
|
|
173
173
|
// Global Cache for script promises to prevent race conditions and duplicate loads
|
|
174
174
|
const scriptCache = new Map();
|
|
175
|
+
// Cache the CSS marker once on load
|
|
176
|
+
const cssMarker = typeof document !== 'undefined' ? document.querySelector('link[plugins]') : null;
|
|
175
177
|
|
|
176
178
|
/**
|
|
177
179
|
* Global Initialization Function
|
|
@@ -211,7 +213,29 @@ async function processPlugin(el) {
|
|
|
211
213
|
if (pluginDef.css) pluginDef.css.forEach(href => {
|
|
212
214
|
if (!document.querySelector(`link[href="${href}"]`)) {
|
|
213
215
|
const link = document.createElement("link");
|
|
214
|
-
link.rel = "stylesheet";
|
|
216
|
+
link.rel = "stylesheet";
|
|
217
|
+
link.href = href;
|
|
218
|
+
|
|
219
|
+
// CSS INJECTION STRATEGY:
|
|
220
|
+
// 1. Priority: Check for a specific marker element <link plugin>
|
|
221
|
+
// (Cached globally in cssMarker)
|
|
222
|
+
|
|
223
|
+
if (cssMarker) {
|
|
224
|
+
// Insert before the marker
|
|
225
|
+
cssMarker.parentNode.insertBefore(link, cssMarker);
|
|
226
|
+
} else {
|
|
227
|
+
// 2. Fallback: Prepend before existing CSS
|
|
228
|
+
// To allow custom CSS to easily override plugin defaults, we must ensure
|
|
229
|
+
// plugin CSS loads BEFORE user CSS.
|
|
230
|
+
const firstStyle = document.head.querySelector('link[rel="stylesheet"], style');
|
|
231
|
+
|
|
232
|
+
if (firstStyle) {
|
|
233
|
+
document.head.insertBefore(link, firstStyle);
|
|
234
|
+
} else {
|
|
235
|
+
// If no CSS exists yet, appending is safe
|
|
236
|
+
document.head.appendChild(link);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
215
239
|
}
|
|
216
240
|
});
|
|
217
241
|
|