gpt4 book ai didi

javascript - Froala 在使用 html.insert 时去除内联样式

转载 作者:行者123 更新时间:2023-11-29 23:17:18 25 4
gpt4 key购买 nike

当我在 Froala 中使用 html.insert 函数时,它会去除内联样式。

编辑器集成看起来像

        $('.fr-view').froalaEditor({
// Set custom buttons with separator between them.
toolbarButtons: ['paragraphFormat', 'bold', 'italic', 'strikeThrough', 'formatOL', 'formatUL', 'clearFormatting', 'link', 'unlink', 'myButton', 'image', 'blockquote', 'html'],
paragraphFormatSelection: true,
refreshAfterCallback: true,
imageEditButtons: ['replaceImage', 'imageDisplay', 'imageAlign', 'imageRemove'],
linkEditButtons: ['linkOpen', 'linkRemove'],
linkNoReferrer: false,
htmlAllowedTags: ['.*'],
htmlRemoveTags: ['']

});

Html 插入函数如下所示:

$('.fr-view').froalaEditor('html.insert', '<a href="' + imgLink + '" target="_self" ><img src="' + finalImgSrc + '" style="' + imgStyle + '" alt="' + altTitle + '" title="' + altTitle + '" /></a>', true);

有人知道为什么内联样式会被删除吗?

最佳答案

为其他有类似问题的人找到了解决方案。初始化编辑器时,它归结为几个选项。这是现在的样子:

        $('.fr-view').froalaEditor({
// Set custom buttons with separator between them.
toolbarButtons: ['paragraphFormat', 'bold', 'italic', 'strikeThrough', 'formatOL', 'formatUL', 'clearFormatting', 'link', 'unlink', 'myButton', 'image', 'blockquote', 'html'],
htmlAllowedStyleProps: ['font-family', 'font-size', 'background', 'color', 'width', 'text-align', 'vertical-align', 'background-color', 'float'],
paragraphFormatSelection: true,
refreshAfterCallback: true,
htmlUntouched: true,
imageEditButtons: ['replaceImage', 'imageDisplay', 'imageAlign', 'imageRemove'],
linkEditButtons: ['linkOpen', 'linkRemove'],
linkNoReferrer: false,
htmlAllowedTags: ['.*'],
htmlRemoveTags: ['']

});

htmlUntouched 和 htmlAllowedStyleProps

关于javascript - Froala 在使用 html.insert 时去除内联样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52303351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com