# Usage
Browser
<script src="./text-editor/index.min.js"></script>
<script src="./text-editor.rect/index.min.js"></script>
<script>
const editor = new TextEditor(document.querySelector('textarea'), {
with: [TextEditor.Rect]
});
</script>
CommonJS
const TextEditor = require('@taufik-nurrohman/text-editor').default;
const TextEditorRect = require('@taufik-nurrohman/text-editor.rect').default;
TextEditor.state.with.push(TextEditorRect); // Load as a core extension
const editor = new TextEditor(document.querySelector('textarea'), {
with: [TextEditorRect] // Load as an optional extension
});
ECMAScript
import TextEditor from '@taufik-nurrohman/text-editor';
import TextEditorRect from '@taufik-nurrohman/text-editor.rect';
TextEditor.state.with.push(TextEditorRect); // Load as a core extension
const editor = new TextEditor(document.querySelector('textarea'), {
with: [TextEditorRect] // Load as an optional extension
});
# Tweaks
# Methods
Instance Methods
editor.rect(key)
Gets current selection offset and dimension data.
console.log(editor.rect()); // [start, end, selection, editor]
# Properties
Instance Properties
editor.mirror
Returns the <div>
element that mirrors the <textarea>
element.