如何将默认字体系列添加到 Tinymce 输出 html
How to add default font-family to Tinymce output html
我们正在使用 Tinymce 4.x 文本 formatting.The 输出 HTML 生成的字符串不包含默认 text.The 输出 HTML 的字体系列,在这种情况下,是
This is a text string
但是,如果我们 select 来自下拉菜单的不同字体系列,它确实会在 html 范围内加起来 element.The 输出字符串看起来像
这是一个文本字符串
我们需要输出中输入文本的默认字体系列 HTML string.We 已经做了很多研究,但无法找到可行的解决方案 help.Appreciate 如果任何人都可以提供帮助。
当前代码为
tinyMCE.init({
// General options
mode: "textareas",
height: "167",
directionality: 'rtl',
selector: '#mytextarea',
convert_fonts_to_spans : false,
body_class: 'arn_richclass',
statusbar: false,
theme: "modern",
plugins: "link textcolor lists directionality",
removed_menuitems: "newdocument visualaid",
toolbar: "bold italic underline forecolor bullist link",
menu: {
edit: { title: 'Edit', items: 'undo redo | cut copy paste pastetext | selectall' },
format: { title: 'Format', items: 'bold italic underline | formats' }
}
});
默认情况下,TinyMCE 将使用提供给编辑器的 CSS 来控制内容的外观——这将包括默认字体、大小、颜色等。
如果你想在内容中的根块上使用某种内联样式,你需要自己添加它们 - 我不知道有哪个 HTML 编辑器会默认添加它们,因为它失败了通过 CSS.
控制内容外观的全部能力
也许您可以使用 forced_root_block
和 forced_root_block_attrs
在根块上设置某种样式属性?
https://www.tinymce.com/docs/configure/content-filtering/#forced_root_block
https://www.tinymce.com/docs/configure/content-filtering/#forced_root_block_attrs
你的配置中有这样的东西:
forced_root_block : 'p',
forced_root_block_attrs: {
'class': 'myclass',
'style': 'font-family: arial times sans-serif; font-weight: bold;'
}
每当编辑器插入一个新的根块时,它都会得到一个 class 和内联样式。
我们正在使用 Tinymce 4.x 文本 formatting.The 输出 HTML 生成的字符串不包含默认 text.The 输出 HTML 的字体系列,在这种情况下,是
This is a text string
但是,如果我们 select 来自下拉菜单的不同字体系列,它确实会在 html 范围内加起来 element.The 输出字符串看起来像
这是一个文本字符串
我们需要输出中输入文本的默认字体系列 HTML string.We 已经做了很多研究,但无法找到可行的解决方案 help.Appreciate 如果任何人都可以提供帮助。
当前代码为
tinyMCE.init({
// General options
mode: "textareas",
height: "167",
directionality: 'rtl',
selector: '#mytextarea',
convert_fonts_to_spans : false,
body_class: 'arn_richclass',
statusbar: false,
theme: "modern",
plugins: "link textcolor lists directionality",
removed_menuitems: "newdocument visualaid",
toolbar: "bold italic underline forecolor bullist link",
menu: {
edit: { title: 'Edit', items: 'undo redo | cut copy paste pastetext | selectall' },
format: { title: 'Format', items: 'bold italic underline | formats' }
}
});
默认情况下,TinyMCE 将使用提供给编辑器的 CSS 来控制内容的外观——这将包括默认字体、大小、颜色等。
如果你想在内容中的根块上使用某种内联样式,你需要自己添加它们 - 我不知道有哪个 HTML 编辑器会默认添加它们,因为它失败了通过 CSS.
控制内容外观的全部能力也许您可以使用 forced_root_block
和 forced_root_block_attrs
在根块上设置某种样式属性?
https://www.tinymce.com/docs/configure/content-filtering/#forced_root_block https://www.tinymce.com/docs/configure/content-filtering/#forced_root_block_attrs
你的配置中有这样的东西:
forced_root_block : 'p',
forced_root_block_attrs: {
'class': 'myclass',
'style': 'font-family: arial times sans-serif; font-weight: bold;'
}
每当编辑器插入一个新的根块时,它都会得到一个 class 和内联样式。