settings
等幅フォントテスト
code:style.css
.deco-\# {
font-family: Cica,Menlo,Monaco,Consolas,"Courier New",monospace;
}
空リンクの文字色をひかえめにする。
code:style.css
atype="link".empty-page-link,
atype="hashTag".empty-page-link {
color: rgb(57, 172, 134) !important;
}
リンクの色をひかえめにする
code:style.css
.line a.link, .line a.page-link {
color: #4682b4;
}
ピン留めしたときのカードの折り返した部分の色を変える
code:style.css
.grid li.page-list-item ahref^="/pokari/active" .header {
border-top-color: rgb(57, 172, 134);
}
箇条書きを控えめにする
code:style.css
.app .line .indent-mark .dot {
height: .15em; width: .4em; border-radius: 25%;
background-color: rgba(173,173,173,.55) }
.app:not(.presentation) .line .indent-mark .dot { top: auto; bottom: 0 }
.page-list-item.pin + .page-list-item:not(.pin) {clear: both;}
画像サイズを変更できるようにする
code:style.css
.level-1 img { width: 10%; max-height: none; }
.level-2 img { width: 20%; max-height: none; }
.level-3 img { width: 30%; max-height: none; }
.level-4 img { width: 40%; max-height: none; }
.level-5 img { width: 50%; max-height: none; }
.level-6 img { width: 60%; max-height: none; }
編集中カーソルがダークリーダーで埋もれるのでカーソルの色を替える。
code:style.css
/* カーソルの幅と width で、色を background-color で替えられます */
.cursor {
width: 3px !important;
background-color: rgb(57, 172, 134);
}
/* 元の黒い線が気になるのでカーソルと同じ色にする */
.cursor {f
color: rgb(57, 172, 134);
border-color: rgb(57, 172, 134);
}
.cursor svg {
display: none;
control+t の日付のフォーマットを追加する
code:script.js
(() => {
let getMonth = t => {
var yyyy = t.getFullYear();
var mm = ("00" + (t.getMonth() + 1)).slice(-2);
return ${yyyy}-${mm};
};
let getDay = t => {
var dd = ("00" + t.getDate()).slice(-2)
var wday = '日月火水木金土't.getDay()
return ${dd}] (${wday})
};
let getTime = t => {
let hh = ('00' + t.getHours()).slice(-2);
let mm = ('00' + t.getMinutes()).slice(-2);
let ss = ('00' + t.getSeconds()).slice(-2);
return ${[hh, mm, ss].join(':')};
};
scrapbox.TimeStamp.addFormat(() => {
let date = new Date();
return [${getMonth(date)}-${getDay(date)};
});
})();
✅と⬜ をクリックで切り替えるためのスクリプト
code:script.js
setTimeout(() => {
// チェックボックスとして使用する文字セットのリスト
const checkboxSetList = [
'⬜', '✅',
];
/*
'⬜', '✅'
'🔲', '☑️'
*/
const allBoxes = checkboxSetList.reduce((accu, current) => accu.concat(current), []);
const startsWithBoxReg = new RegExp('^\\s*(' + allBoxes.join('|') + ')');
const targetProject = scrapbox.Project.name;
class KeydownEvent {
constructor() {
this.textArea = document.getElementById('text-input');
this.event = document.createEvent('UIEvent');
this.event.initEvent('keydown', true, true);
}
dispatch(keyCode, withShift = false, withCtrl = false, withAlt = false, withCommand = false) {
this.event.keyCode = keyCode;
this.event.shiftKey = withShift;
this.event.ctrlKey = withCtrl;
this.event.altKey = withAlt;
this.event.metaKey = withCommand;
this.textArea.dispatchEvent(this.event);
}
}
// ボックスクリックでオンオフする
$('#app-container').off(click.toggleCheckBox_${targetProject}, '.lines');
$('#app-container').on(click.toggleCheckBox_${targetProject}, '.lines', async event => {
if (scrapbox.Project.name !== targetProject) {
$('#app-container').off(click.toggleCheckBox_${targetProject}, '.lines');
return;
}
const target = event.target;
if (!isFirstElementChild(target)||!isCharSpan(target, allBoxes)) return;
await new Promise(resolve => setTimeout(resolve, 30));
let lineString;
try {
lineString = getCursorLineString();
} catch (err) {
console.log(err);
return;
}
if (!startsWithBoxReg.test(lineString)) return;
const targetX = target.getBoundingClientRect().left;
const cursorX = document.getElementsByClassName('cursor')0.getBoundingClientRect().left;
const keydownEvent = new KeydownEvent();
if (cursorX <= targetX) {
keydownEvent.dispatch(39); // →
}
keydownEvent.dispatch(8); // Backspace
const newBox = (() => {
const trimmedLineString = lineString.trim();
for (const checkboxSet of checkboxSetList) {
for (let i = 0; i < checkboxSet.length; i++) {
if (trimmedLineString.startsWith(checkboxSeti)) {
return checkboxSeti + 1 < checkboxSet.length ? i + 1 : 0;
}
}
}
return target.textContent;
})();
writeText(newBox);
});
// ボックス行で改行すると次行にボックス自動挿入
$('#text-input').off(keydown.autoInsertCheckBox_${targetProject});
$('#text-input').on(keydown.autoInsertCheckBox_${targetProject}, async event => {
if (scrapbox.Project.name !== targetProject) {
$('#text-input').off(keydown.autoInsertCheckBox_${targetProject});
return;
}
switch (event.key) {
case 'Enter': {
let currentLineString;
try {
currentLineString = getCursorLineString();
} catch (err) {
console.log(err);
return;
}
if (!startsWithBoxReg.test(currentLineString)) return;
await new Promise(resolve => setTimeout(resolve, 30));
let nextLineString;
try {
nextLineString = getCursorLineString();
} catch (err) {
console.log(err);
return;
}
if (!startsWithBoxReg.test(nextLineString)) {
const trimmedLineString = currentLineString.trim();
const targetBoxSet = checkboxSetList.find(boxSet => {
return boxSet.some(box => trimmedLineString.startsWith(box));
});
writeText(targetBoxSet0);
}
return;
}
default: {
return;
}
}
});
function isFirstElementChild(element) {
return element.parentNode.firstElementChild === element;
}
function getCursorLineString() {
return document.querySelector('.lines div.line.cursor-line').textContent;
}
function isCharSpan(element, targetCharList) {
return element.tagName === 'SPAN'
&& targetCharList.includes(element.textContent)
&& element.classList.value.split(' ').some(value => /^c\-\d+$/.test(value));
}
function writeText(text) {
const textArea = document.getElementById('text-input');
textArea.value = text;
textArea.dispatchEvent(new InputEvent('input', {bubbles: true, cancelable: true}));
}
}, 1500);