A rehype plugin to disable or enable specific input elements.
npm install rehype-input-disable
Optional:
-
type
: filer by input type, e.g. "checkbox" -
disabled
: set the property to eithertrue
orfalse
. Defaults totrue
.
import { rehype } from "rehype";
import rehypeInputDisable from "rehypeInputDisable";
rehype()
.use(rehypeInputDisable, { type: "checkbox" disabled: False })
.process('<input type="checkbox" id="key" value="1" disabled>', function (err, file) {
if (err) throw err;
console.log(String(file));
});
Expected output:
<html>
<head></head>
<body>
<input type="checkbox" id="key" value="1" />
</body>
</html>