scrapbox-insert-text
引数
text: 入力したいテキスト
cursor: テキストを入力する<textarea>
scrapboxなら#text-input
2021-01-05 09:57:17 なくても使えるようにした
code:script.js
export function insertText({text}) {
const cursor = document.getElementById('text-input');
cursor.focus();
const start = cursor.selectionStart; // in this case maybe 0
cursor.setRangeText(text);
cursor.selectionStart = cursor.selectionEnd = start + text.length;
const uiEvent = document.createEvent('UIEvent');
uiEvent.initEvent('input', true, false);
cursor.dispatchEvent(uiEvent);
}
UserScript.icon