MobileEditMenu
モバイル版Scrapbox改善活動の一環
全て作りかけ
code:mobile_edit_menu.js
const {
cursor,
selection,
mobileSelection,
} = getCursor();
window.cursor = cursor;
window.selection = selection;
window.mobileSelection = mobileSelection;
window.cursor = getCursor();
function mobileEditMenu() {
window.kuuote ??= {};
if (window.kuuote.mobileEditMenu != null) {
return;
}
const data = window.kuuote.mobileEditMenu = {};
const bar = statusBar();
data.start = document.createElement("div");
data.start.innerHTML = "始点";
data.start.onclick = (e) => {
e.preventDefault();
e.stopPropagation();
data.line = cursor.data.line;
data.char = cursor.data.char;
data.start.innerHTML = "拝承";
setTimeout(() => {
data.start.innerHTML = "始点";
}, 1000);
};
bar.append(data.start);
data.end = document.createElement("div");
data.end.innerHTML = "終点";
data.end.onclick = (e) => {
e.preventDefault();
e.stopPropagation();
if (!data.line) {
return;
}
selection.setRange({
start: {
line: data.line,
char: data.char,
},
end: cursor.data,
})
}
bar.append(data.end);
}
useKuuoteMenu().addItem({
title: () => "Mobile Edit Menu",
onClick: mobileEditMenu,
});