Document application modes (development/debug/production) Add global file drop handler, order column normalization, SPA hash fix Serve CDN assets via /_vendor/ URLs instead of merging into bundles Add production minification with license preservation Improve JSON formatting for debugging and production optimization Add CDN asset caching with CSS URL inlining for production builds Add three-mode system (development, debug, production) Update Manifest CLAUDE.md to reflect helper class architecture Refactor Manifest.php into helper classes for better organization Pre-manifest-refactor checkpoint: Add app_mode documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
78 lines
2.1 KiB
JavaScript
Executable File
78 lines
2.1 KiB
JavaScript
Executable File
import { detachNodeFromParent } from '../lib/xast.js';
|
|
|
|
/**
|
|
* @typedef RemoveElementsByAttrParams
|
|
* @property {string | string[]=} id
|
|
* @property {string | string[]=} class
|
|
*/
|
|
|
|
export const name = 'removeElementsByAttr';
|
|
export const description =
|
|
'removes arbitrary elements by ID or className (disabled by default)';
|
|
|
|
/**
|
|
* Remove arbitrary SVG elements by ID or className.
|
|
*
|
|
* @example id
|
|
* > single: remove element with ID of `elementID`
|
|
* ---
|
|
* removeElementsByAttr:
|
|
* id: 'elementID'
|
|
*
|
|
* > list: remove multiple elements by ID
|
|
* ---
|
|
* removeElementsByAttr:
|
|
* id:
|
|
* - 'elementID'
|
|
* - 'anotherID'
|
|
*
|
|
* @example class
|
|
* > single: remove all elements with class of `elementClass`
|
|
* ---
|
|
* removeElementsByAttr:
|
|
* class: 'elementClass'
|
|
*
|
|
* > list: remove all elements with class of `elementClass` or `anotherClass`
|
|
* ---
|
|
* removeElementsByAttr:
|
|
* class:
|
|
* - 'elementClass'
|
|
* - 'anotherClass'
|
|
*
|
|
* @author Eli Dupuis (@elidupuis)
|
|
*
|
|
* @type {import('../lib/types.js').Plugin<RemoveElementsByAttrParams>}
|
|
*/
|
|
export const fn = (root, params) => {
|
|
const ids =
|
|
params.id == null ? [] : Array.isArray(params.id) ? params.id : [params.id];
|
|
const classes =
|
|
params.class == null
|
|
? []
|
|
: Array.isArray(params.class)
|
|
? params.class
|
|
: [params.class];
|
|
return {
|
|
element: {
|
|
enter: (node, parentNode) => {
|
|
// remove element if it's `id` matches configured `id` params
|
|
if (node.attributes.id != null && ids.length !== 0) {
|
|
if (ids.includes(node.attributes.id)) {
|
|
detachNodeFromParent(node, parentNode);
|
|
}
|
|
}
|
|
// remove element if it's `class` contains any of the configured `class` params
|
|
if (node.attributes.class && classes.length !== 0) {
|
|
const classList = node.attributes.class.split(' ');
|
|
for (const item of classes) {
|
|
if (classList.includes(item)) {
|
|
detachNodeFromParent(node, parentNode);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
};
|
|
};
|