
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
inline-style-editor
Advanced tools
Lightweight (~42KB, ~16KB gzipped) tool to graphically change style and CSS (on classes or inline) using a graphical interface.
See demo.
npm install inline-style-editor
Then, to use it:
import InlineStyleEditor from "node_modules/inline-style-editor/dist/inline-style-editor.mjs";
const editor = new InlineStyleEditor();
Also don't forget to import the css in: node_modules/inline-style-editor/dist/inline-style-editor.css
.
<link rel="stylesheet" type="text/css" href="https://unpkg.com/inline-style-editor@1.0.0/dist/inline-style-editor.css" />
<script src="https://unpkg.com/inline-style-editor@1.0.0/dist/inline-style-editor.js"></script>
Manual opening of editor:
const editor = new InlineStyleEditor();
document.body.addEventListener('click', (e) => {
if (editor.isOpened()) return;
const target = e.target;
editor.open(target, e.pageX, e.pageY);
});
Or automatic (in which case it automatically listen to the <body>
element for clicks):
new InlineStyleEditor({
listenOnClick: true,
});
option | type | Description |
---|---|---|
listenOnClick | Boolean | Default to false. If true, click events will be listened on the <body> element, and the editor opened where clicked |
inlineDeletable | Function | Defaults to a function always returning true. The function takes the currently selected DOM node, and should return a boolean to determine whether the element can be deleted |
getElems | Function | A function called everytime the editor is opened. Should return a list of [HTMLElement, name], or HTMLElement (in which case the displayed name will be Elem i ). The returned elements will be editable as well. The first argument is the element on which the editor is about to be opened. |
onStyleChanged | Function | A function called everytime a style is modified. The first argument is the current target element, the second the edited CSS rule, or 'inline' if inline, the third the CSS prop name, the fourth the prop value |
cssSelector | Function | If defined, the CSS rules to edit can be filtered. The function takes an element and associated CSS selection text. If the function returns false, the current CSS rule will not appear in the popup. |
cssRuleFilter | Function | A function taking an DOM element and the css selector for the CSS rule that will be editable, that should return false if the rule should not display in the editor |
getCssRuleName | Function | A function taking a CSS text selector and the element on which the editor opened, returning a new string for this selector to display in the editor |
customProps | Object | An object defining custom properties to edit. See below. |
customProps
is an object on the form of propName
(as displayed in the editor) -> definition
.
definition
is an object defining the property to edit and the used widget:
type
: One of slider
, select
or color
.
slider
, min
, max
and step
must be defined (floats).select
, choices
must be defined. It is a function returning a list to select fromgetter
: A function to get the property value. Takes the edited HTMLElement as first argument. If null
is returned, the widget will not be awailable for the current element.setter
: A function to set the property value. Takes the edited HTMLElement as first argument, and the new value as second argument.Example, to edit the pathLength of an SVG element using a slider:
new InlineStyleEditor({
customProps: {
'pathLength': {
type: 'slider', min: 1, max: 500, step: 1,
getter: (el) => {
// disable when elem is not a SVG geometry
if (!el.getTotalLength) return null;
const pathLength = el.getAttribute('pathLength');
if (!pathLength) return Math.round(el.getTotalLength());
return parseInt(pathLength);
},
setter: (el, val) => {
el.setAttribute('pathLength', val);
}
},
}
});
FAQs
Update CSS rules or add inline style to elements visualy
The npm package inline-style-editor receives a total of 3 weekly downloads. As such, inline-style-editor popularity was classified as not popular.
We found that inline-style-editor demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.