script.jsimport {
indentLines, outdentLines, upLines, downLines,
indentBlocks, outdentBlocks, upBlocks, downBlocks,
insertText, caret, takeCursor,
} from "../scrapbox-userscript-std/dom.ts";
export const mobile = !/mobile/i.test(navigator.userAgent) ? [] : [
// アウトライン編集
{key: 'ctrl+h', command: () => {outdentLines();return false;},},
{key: 'ctrl+j', command: () => {downLines();return false;},},
{key: 'ctrl+k', command: () => {upLines();return false;},},
{key: 'ctrl+l', command: () => {indentLines();return false;},},
{key: 'alt+h', command: () => {outdentBlocks();return false;},},
{key: 'alt+j', command: () => {downBlocks();return false;},},
{key: 'alt+k', command: () => {upBlocks();return false;},},
{key: 'alt+l', command: () => {indentBlocks();return false;},},
/*
// コピーペースト
{key: 'ctrl+c', command: async () => {
try {
const text = caret().selectedText;
if (text === "") return false;
await navigator.clipboard.writeText(text);
return false;
} catch(e) {
console.error(e);
alert(`Failed to copy: ${e.message}`);
};
},},
{key: 'ctrl+x', command: async () => {
try {
const text = caret().selectedText;
if (text === "") return false;
await navigator.clipboard.writeText(text);
return true;
} catch(e) {
console.error(e);
alert(`Failed to copy: ${e.message}`);
};
},},
{key: 'ctrl+v', command: async () => {
try {
const text = await navigator.clipboard.readText();
await insertText(text);
return false;
} catch(e) {
console.error(e);
alert(`Failed to paste: ${e.message}`);
};
},},
*/
// 文字入力できる状態にする
{key: 'i', command: () => {
const cursor = takeCursor();
cursor.focus();
cursor.showEditPopupMenu();
return false;
}, type: 'browser',},
];