generated at
moriyuya

ブログ

得意
特徴量が十分だけれども、まだ名前がつけられていない現象を認知し、適切な名前をつけること


自分用のセッティング
script.js
// 関連ページを吹き出し表示する // n: north, s: south $('body').attr('data-daiiz-rel-bubble', 'n') $('body').attr('data-daiiz-rel-bubble', 'off'); // 関連ページを吹き出し表示する $('body').attr('data-daiiz-text-bubble', 'on'); // リンク先ページのテキストを表示する

script.js
// ポップアップメニューから選択した文字列にマーカー scrapbox.PopupMenu.addButton({ title: 'マーカー', onClick: text => `[[${text}]]` })

script.js
scrapbox.PopupMenu.addButton({ title: 'quote', onClick: text => text.split(/\n/).map(line => ` > ${line}`).join('\n') })

見出し
script.js
scrapbox.PageMenu.addMenu({ title: '見出し', image: 'https://gyazo.com/da0408108eda84e56a587630be5e4524/raw', onClick: () => { scrapbox.PageMenu('見出し').removeAllItems() for (let line of scrapbox.Page.lines) { if (!line.section.start) continue if (!line.text.startsWith("[* ") && !line.text.startsWith("[** ") && !line.text.startsWith("[*** ")&& !line.text.startsWith("[**** ")) continue if (!line.nodes) continue const image = "" const noIcon = false // [* hoge]と[** hoge]は先頭をインデントする。 const marginLeft = line.text.startsWith("[* ") ? "  ・" : "" const marginLeft2 = line.text.startsWith("[** ") ? " ■" : "" const title = marginLeft + marginLeft2 + renderPlainText(line.nodes) const onClick = () => location.hash = line.id scrapbox.PageMenu('見出し').addItem({ title, image, onClick }) } } }) function renderPlainText(node) { if (node instanceof Array) return node.map(node => renderPlainText(node)).join('') if (typeof node === 'string') return node switch (node.type) { case 'icon': case 'strong-icon': return node.unit.page } return renderPlainText(node.children) } function getIconUrl(node) { if (/icon/.test(node.type)) { return `/api/pages/${node.unit.project||scrapbox.Project.name}/${node.unit.page}/icon` } if (node instanceof Array) { return node.map(getIconUrl).find(img => img) } return null }

テスト

A
B
C
D
E

空行がないと表示されない

参考
機能しない




非表示
不要なPopup Menuを消す
style.css
.popup-menu .strike-button, .popup-menu .italic-button, .popup-menu .copy-plain-button { display: none !important; }

ポップアップメニューのショートカットキー

新規作成ボタンを消す
style.css
.new-button { visibility: hidden; }

動かなかった