在 Ckeditor 中,删除文本前后的 br 标签


In Ckeditor, delete br tags before and after the text

例如,当用户在编辑器中粘贴文本时,他们不会删除文本前后的空格。

如何删除这些br标签?它的工作方式类似于 php 中的 trim() 函数。

我的代码是:

    CKEDITOR.replace('contenido',
    {
       language: 'es',
       resize_enabled: true,
       pasteFromWordRemoveFontStyles: true,
       pasteFromWordPromptCleanup: true,
       forcePasteAsPlainText: true,
       ignoreEmptyParagraph: true,
       removeFormatAttributes: true,
       autoParagraph: false,
       fillEmptyBlocks: false,
       enterMode: CKEDITOR.ENTER_BR,
       toolbar: [
         ['Bold', 'Italic', 'Underline', 'Strike'],
         ['Cut', 'Copy', 'PasteText', '-', 'Scayt'],
         ['Undo', 'Redo', '-', 'Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'], ['CreateDiv', '-', 'ShowBlocks'],
         ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'],
         ['Link', 'Unlink', 'Anchor'],
         ['Image', 'Table', 'HorizontalRule', 'SpecialChar'], ['Source'],['Maximize']
 ]
});

为了能够使用内置的PHP方法来为您执行此操作,请查看以下内容:

http://php.net/manual/en/function.strip-tags.php

您可以使用该方法的第二个 pram 列出您不想修剪掉的任何 html 类型标记。 因此,从理论上讲,如果您只想
删除",则可以为其提供除该标签之外的每个标签的列表。

希望这有帮助。