UNPKG

prism-code-editor

Version:

Lightweight, extensible code editor component for the web using Prism

28 lines (27 loc) 949 B
import { c } from "../../position-VAfpj0jh.js"; import { c as createTemplate } from "../../index-q0zRzWVD.js"; import { a as addTextareaListener, b as addOverlay } from "../../index-CxiLA9IO.js"; const template = createTemplate("<div class=pce-cursor>"); const customCursor = () => { return (editor) => { let cursor = template(); let textareaStyle = editor.textarea.style; let toggle; editor.on("selectionChange", () => { const pos = editor.extensions.cursor?.getPosition(); if (pos) { textareaStyle.zIndex = textareaStyle.caretColor = "auto"; cursor.style = `left:${pos.left}px;top:${pos.top}px;height:${pos.height}px;animation-name:pce-blink${toggle = +!toggle}`; } }); addTextareaListener(editor, "dragover", () => { textareaStyle.caretColor = ""; }); addOverlay(editor, cursor); }; }; export { c as cursorPosition, customCursor }; //# sourceMappingURL=index.js.map