Custmisabl Headless component and React component for js, css and html compiler.
npm install html-css-js-editor
This npm library provides headless React hooks and self-suffiecient react components for building a powerful front-end editor. Developers can leverage these hooks to create custom editors for CSS, HTML, JavaScript, and even display console output.
You can install this library using npm:
```bash
npm install html-css-js-editor
or
yarn add html-css-js-editor
Usage
This hook allows you to manage HTML content within your editor. It accepts a state variable containing HTML code and an iframe reference.
Example usage:
'''
import { useHTMLEditor } from 'html-css-js-editor';
const MyHtmlEditor = () => {
const ref = useRef();
const [ value, setValue ] = useState('');
useHTMLEditor(value, ref);
return (
// Output will be shown here in iframe
);
};
'''
Similar to useHTMLEditor, this hook handles CSS code. It also takes a state variable with CSS code and an iframe reference.
'''
Example usage:
import { useCSSEditor } from 'html-css-js-editor';
const MyCssEditor = () => {
const ref = useRef();
const [ value, setValue ] = useState('');
useCSSEditor(value, ref);
return (
// Output will be shown here in iframe
);
};
'''
Similar to useHTMLEditor, this hook handles CSS code. It also takes a state variable with CSS code and an iframe reference.
Example usage:
'''
import { useCSSEditor } from 'html-css-js-editor';
import { useConsole } from 'html-css-js-editor';
const MyCssEditor = () => {
const ref = useRef();
const [ value, setValue ] = useState('');
useJSEditor(value, ref);
// useConsole return the console logs in logs
const {logs} = useConsole(value, ref);
return (
// Output will be shown here in iframe
);
};
'''
Example usage:
'''
import { useCSSEditor } from 'html-css-js-editor';
import { useConsole } from 'html-css-js-editor';
import { useHTMLEditor } from 'html-css-js-editor';
import { useCSSEditor } from 'html-css-js-editor';
const MyCssEditor = () => {
const ref = useRef();
const [ js, setJs ] = useState('');
const [ css, setCss ] = useState('');
const [ html, setJs ] = useState('');
useJSEditor(value, ref);
// useConsole return the console logs in logs
const {logs} = useConsole(value, ref);
return (
// write js code here
// write html code here
// write css code here
// Output will be shown here in iframe
);
};
'''
'''
-
-
-
-
'''
Contributing
Contributions are welcome! Feel free to open issues or submit pull requests on our GitHub repository.
Run 'npm run build or yarn build' command to build and use the build ( bundle.esm.js ) inside dist folder for testing in your local project.
License
This library is released under the MIT License. See the LICENSE file for details.
Remember to customize the content according to your library's specifics. Happy coding! 🚀