0

TL;博士

SCEditor[li]test[/li]用于列表项。为了使其与 VB 兼容,我想将其更改为[*]test. 但我的方法并没有完全奏效。我可以让编辑器插入[*]列表项。但是,它们总是在其内容之前包含不需要的换行符。

所以问题是:如何在当前解决方案之后更改[li]x[/li][*]x没有换行符[*](见上文)?

详细解释和我的方法

我希望 SCEditor 与 VBulletin 兼容。许多 BBCode 有效,但列表无效。在 SCEditor 中创建列表时,它会生成以下 BBCode:

[ul]
[li]x[/li]
[li]y[/li]
[/ul]

VBulletin 不解析它,因为它使用[list]而不是[ul]. 通过了解bbcode.js,我可以通过替换 BBCode 的格式来解决这个问题:

sceditor.formats.bbcode.set('ul', {
    tags: {
        ul: null
    },
    breakStart: true,
    isInline: false,
    skipLastLineBreak: true,
    format: '[list]{0}[/list]',
    html: '<ul>{0}</ul>'
})

但是当我改变 But the[li]x[/li]也不起作用,因为 VB 使用[*] x没有结束标记。也尝试修改此项目:

sceditor.formats.bbcode.remove('li')
sceditor.formats.bbcode.set('li', {
    tags: {
        li: null,
        '*': null
    },
    isInline: false,
    excludeClosing: true,
    isSelfClosing: true,
    skipLastLineBreak: true,
    closedBy: ['/ul', '/ol', '/list', '*', 'li'],
    format: '[*]{0}',
    html: '<li>{0}</li>'
})
sceditor.formats.bbcode.remove('*')
sceditor.formats.bbcode.set('*', {
    isInline: false,
    //excludeClosing: true,
    isSelfClosing: true,
    //skipLastLineBreak: true,
    html: '<li>{0}</li>'
})

现在,当按下列表按钮时,编辑器几乎在我需要的时候插入 BBCodes:

[list]
[*]
x[/list]

由于它在 和 内容之间创建了一个换行符[*],因此它看起来已损坏:

在此处输入图像描述

它似乎li用于编辑器控件(插入列表按钮),其中*(最后一个条目)处理从 BBCode 到编辑器 HTML 的解析(在源代码和所见即所得视图之间切换时)。

4

1 回答 1

1

发现我需要isSelfClosingfalseBBCode 中*设置。skipLastLineBreak不需要删除标签,sceditor.formats.bbcode.remove('*')因为set()会覆盖任何现有标签(在文档中描述)。

以下作品:

sceditor.formats.bbcode.set('*', {
    isInline: false,
    // Avoid automatically closing tag [/*]
    excludeClosing: true,
    // Avoids line break between [*] and list point content
    isSelfClosing: false,
    html: '<li>{0}</li>'
})

结果是

[list]
[*]x
[*]y
[/list]
于 2019-08-10T15:37:45.560 回答