input mode UserScript
Scrapbox
vimmodeUserScript使 (see also: /help-jp/UserScript)mode

readonly mode
input mode

UserScript
(readonly mode)
navbar i
(input mode)
readonly modenavbar Esc

:
let isInputMode = true;
const enterInputMode = (e) => {
if (!isInputMode) {
if (e) {
e.preventDefault();
}
$("#text-input").prop('disabled', false);
$("#text-input").focus();
$('.page').css('opacity', '1.0');
isInputMode = !isInputMode;
}
}
const exitInputMode = (e) => {
if (isInputMode) {
$("#text-input").prop('disabled', true);
$('.page').css('opacity', '0.6');
isInputMode = !isInputMode;
}
}
const modeSelectors = {
true: exitInputMode,
false: enterInputMode,
}
scrapbox.PageMenu.addMenu({
title: 'Input mode',
image: 'https://i.gyazo.com/5f2de2133ef5d9a35ac16b3b8aa1c6aa.png',
onClick: () => {
modeSelectors[isInputMode]();
},
});
$(window).keydown((e) => {
if (e.keyCode === 73) { // key code of "i"
enterInputMode(e);
}
if (e.keyCode === 27) { // key code of Esc
exitInputMode(e);
}
});
exitInputMode();

import '/api/code/moznion/input_mode_UserScript/script.js'