
Product
A New Overview in our Dashboard
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
tiny-editor
Advanced tools
A tiny HTML rich text editor written in vanilla JavaScript
Create a less than 5 Kb (compressed) library that enables a HTML element to be used as a rich text editor in plain old vanilla JavaScript.
If you use and like this library, feel free to support my Open Source projects.
npm install tiny-editor
or load the bundle file directly at the end of your HTML document.
<script src="https://unpkg.com/tiny-editor/dist/bundle.js"></script>
data-tiny-editor
attribute to the HTML element you want to transform into an editorUse the exported function window.__tinyEditor.transformToEditor()
which take as the first argument the DOM element (usually a <div>
) that you want to transform to an editor. Refer to the /public/index.html
for an example.
Listen for the input
event on the editor HTML element.
document
.querySelectorAll('[data-tiny-editor]')
.forEach(editor =>
editor.addEventListener('input', e => console.log(e.target.innerHTML)
)
);
There are various options that can be used to customize how the Tiny Editor will be rendered. By default, every options are enabled. You can disable an option using data attributes.
For example, you can remove the bold format button using the following attribute:
<div data-tiny-editor data-bold="no"></div>
data-formatblock="no"
: remove the styles drop down listdata-bold="no"
: remove the bold buttondata-italic="no"
: : remove the italic buttondata-underline="no"
: remove the underline buttondata-fontname="no"
: remove the font drop down listdata-forecolor="no"
: : remove the text color buttondata-justifyleft="no"
: remove the left align buttondata-justifycenter="no"
: remove the center align buttondata-justifyright="no"
: remove the right align buttondata-insertorderedlist="no"
: remove the numbered list buttondata-insertunorderedlist="no"
: remove the bulleted list buttondata-outdent="no"
: remove the decrease indent buttondata-indent="no"
: remove the increase indent buttondata-remove-format="no"
: remove the clear formatting buttondata-autofocus="no"
: remove autofocus from the editorModern browser (Chrome, Firefox, Edge,...) are supported. Tiny Editor doesn't work on Internet Explorer.
FAQs
A tiny HTML rich text editor written in vanilla JavaScript
The npm package tiny-editor receives a total of 220 weekly downloads. As such, tiny-editor popularity was classified as not popular.
We found that tiny-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.
Product
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.