Sto usando questo codice nel mio plugin:
helper.allowList(['span.dpg-balloon-text'])
helper.registerPlugin(md => {
md.inline.bbcode.ruler.push('dpgb', {
tag: 'dpgb',
wrap: function (startToken, endToken, tagInfo) {
startToken.tag = endToken.tag = 'span'
startToken.content = endToken.content = ''
startToken.type = "span_open";
endToken.type = "span_close";
startToken.nesting = 1;
endToken.nesting = -1;
startToken.attrs = [['class', 'dpg-balloon-text']].concat(
Object.keys(tagInfo.attrs).map(key => [
`data-dpg-${key}`,
tagInfo.attrs[key]
])
)
}
})
})
Quanto sopra funzionava sia con i tag BBCode vuoti che non vuoti. Ma ho scoperto oggi che ora si attiva solo quando il tag BBCode ha contenuto (come [dpgb]Alcuni contenuti[/dpgb]) e non si attiva quando il tag BBCode non ha contenuto (come [dpgb][/dpgb]). È una nuova scelta di progettazione?