« Text Editor Rect 4.0.5

This extension provides a feature to get cursor position and selection dimension in pixels.


      

# 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)

Get current selection offset and dimension data.

console.log(editor.rect()); // [start, end, selection, editor]

# Properties

Instance Properties

editor.mirror

Return a <div> element that mirrors the <textarea> element.