バレットジャーナルのkeyを呼び出せるメニューを追加するコード
from バレットジャーナルkey
バレットジャーナルのkeyを呼び出せるメニューを追加するコード
カーソルがある位置に絵文字が挿入されます
https://gyazo.com/4acc936c7ccf1115296bdba93f20b323
作成例
本番運用中のものはプロフィールページまなてぃでみられます
たまに変更されることがあります
code:script.js
const STAMPS = [
{ title: '⬜ TODO', text: '⬜' },
{ title: '✅ タスク完了', text: '✅' },
{ title: '✨ TOBEリスト', text: '✨' },
{ title: '🔜 先送り', text: '🔜' },
{ title: '📅 リスケ済', text: '📅' },
null,
{ title: '💡 ひらめき', text: '💡' },
{ title: '🔍️ 疑問・調べること', text: '🔍️' },
{ title: '🚩 イベント', text: '🚩イベント ' },
{ title: '⭐ 重要', text: '⭐重要 ' },
null,
{ title: '💖 感謝', text: '💖感謝 ' },
{ title: '👍 good', text: '👍good ' },
{ title: '😞 bad', text: '😞bad ' },
{ title: '😋 美味しかった', text: '😋美味しかった ' },
];
function insertStamp(text) {
const lines = scrapbox.Page.lines;
if (!lines) return;
const lineIndex = scrapbox.Page.cursor?.line ?? lines.length - 1;
const charIndex = scrapbox.Page.cursor?.char ?? 0;
const currentText = lineslineIndex?.text ?? '';
// カーソル位置に絵文字を挿入
const newText = currentText.slice(0, charIndex) + text + currentText.slice(charIndex);
if (typeof cosense !== 'undefined') {
cosense.Page.updateLine(newText, lineIndex);
} else {
scrapbox.Page.updateLine(newText, lineIndex);
}
}
scrapbox.PageMenu.addMenu({
title: 'KEY',
image: 'https://i.gyazo.com/8149d2001d5eec0252fc4c85cf94f4dd.png',
});
for (const item of STAMPS) {
if (item === null) {
scrapbox.PageMenu('KEY').addSeparator();
} else {
scrapbox.PageMenu('KEY').addItem({
title: item.title,
onClick: () => insertStamp(item.text),
});
}
}