> wiki-plugin-useraccesstokens@0.1.0 npx > create-wiki-plugin Usage: npm create wiki-plugin <new-plugin-name> e.g. npm create wiki-plugin CoolThing and write requirements in README.
27 lines
602 B
JavaScript
27 lines
602 B
JavaScript
const expand = text => {
|
|
return text
|
|
.replace(/&/g, '&')
|
|
.replace(/</g, '<')
|
|
.replace(/>/g, '>')
|
|
.replace(/\*(.+?)\*/g, '<i>$1</i>')
|
|
}
|
|
|
|
const emit = ($item, item) => {
|
|
return $item.append(`
|
|
<p style="background-color:#eee;padding:15px;">
|
|
${expand(item.text)}
|
|
</p>`)
|
|
}
|
|
|
|
const bind = ($item, item) => {
|
|
return $item.dblclick(() => {
|
|
return wiki.textEditor($item, item)
|
|
})
|
|
}
|
|
|
|
if (typeof window !== 'undefined') {
|
|
window.plugins.useraccesstokens = { emit, bind }
|
|
}
|
|
|
|
export const useraccesstokens = typeof window == 'undefined' ? { expand } : undefined
|