daiiz
https://scrapbox.io/files/5fb7932f391e4700221222ad.png
https://gyazo.com/beda009ff89a86330a934e359362607a/thumb/140.pnghttps://svgscreenshot.appspot.com/c/x/d22d3168e3b6a66087876b2bedb72cf1.140.png
daiiz.icon
code:script1.js
(function (helpfeelUrl) {
const img = document.createElement('img')
img.style.height = '40px'
const a = document.createElement('a')
a.href = ''
a.addEventListener('click', function (event) {
event.preventDefault()
const q = document.querySelector('.search-form input').value.trim().slice(0, 50)
if (q && helpfeelUrl) window.open(${helpfeelUrl}?q=${encodeURIComponent(q)})
})
a.appendChild(img)
document.querySelector('div.navbar-form').appendChild(a)
2019/2/19
code:script.js
const indexes = function () {
scrapbox.PageMenu('見出し').removeAllItems()
for (let line of scrapbox.Page.lines) {
if (!line.section.start || line.title) continue
const image = line.nodes && getIconUrl(line.nodes)
const noIcon = !!image
const title = line.nodes ? renderPlainText(line.nodes, {noIcon}) : line.text
const onClick = () => location.hash = line.id
scrapbox.PageMenu('見出し').addItem({title, image, onClick})
}
}
function renderPlainText (node, options) {
if (node instanceof Array) return node.map(node => renderPlainText(node, options)).join('')
if (typeof node === 'string') return node
switch (node.type) {
case 'icon':
case 'strong-icon':
return options.noIcon ? ' ' : node.unit.page
case 'hashTag':
return ''
}
return renderPlainText(node.children, options)
}
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
}
scrapbox.PageMenu.addMenu({
title: '見出し',
onClick: indexes
})
code:script.js
$('body').attr('data-daiiz-icon-button', 'on');
$('body').attr('data-daiiz-rel-bubble', 'off');
$('body').attr('data-daiiz-text-bubble', 'off');
$('body').attr('data-daiiz-paste-url-title', 'ctrl');
code:script.js