Installation
Feature origin: Tint
Tint is one ES module, with its styles and markdown-actions built in. Load it with a script tag, an import map, or npm.
Files
| File | Size (gzip) | What |
|---|---|---|
tint-editor.js | ~12 kB | ES module with the element, CSS, and editing engine. |
Loading the module registers <tint-editor>. There is no separate stylesheet.
Script tag
Add a module script to your page:
<script type="module" src="https://cdn.jsdelivr.net/npm/tint-editor@0.1.0/tint-editor.js"></script>Then add the element in the body:
<label for="notes">Notes</label>
<tint-editor id="notes" name="body"></tint-editor>Using the API
Wait for the element to be registered before reading its value or calling its methods.
<script type="module">
await customElements.whenDefined("tint-editor");
const editor = document.querySelector("tint-editor");
editor.addEventListener("input", () => console.log(editor.value));
</script>Versions and unpkg
Pin the version to keep the same build. The module is also available on unpkg:
<script type="module" src="https://unpkg.com/tint-editor@0.1.0/tint-editor.js"></script>ES module with an import map
<script type="importmap">
{
"imports": {
"tint-editor": "https://cdn.jsdelivr.net/npm/tint-editor@0.1.0/tint-editor.js"
}
}
</script>
<script type="module">
import "tint-editor";
</script>Place the import map before any module that imports Tint.
Self-hosting the file
curl -LO https://cdn.jsdelivr.net/npm/tint-editor@0.1.0/tint-editor.jsServe the file with your site and use its URL in the script tag or import map.
npm and bundlers
From npm
npm install tint-editorimport "tint-editor";
const editor = document.querySelector("tint-editor");