我想在tinymce中添加一个谷歌字体。我根本无法工作。这是我目前的例子:
tinymce.init({
selector: "textarea",
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste"
],
toolbar: "styleselect fontselect fontsizeselect | forecolor backcolor",
font_formats: 'Libre Barcode 128=Libre Barcode 128, cursive',
content_css: [
'//fonts.googleapis.com/css?family=Libre+Barcode+128',
'//www.tinymce.com/css/codepen.min.css'
]
});
使用tinymce小提琴进行演示:http://fiddle.tinymce.com/iagaab
使用jsfiddle进行演示:https://jsfiddle.net/tx4Lc8a9/46/
这是我试图开始工作https://fonts.google.com/specimen/Libre+Barcode+128
的问题答案 0 :(得分:0)
如果您只是将TinyMCE的版本更新为最新版本,则您的代码就可以正常工作: https://cdn.tiny.cloud/1/no-api-key/tinymce/5/tinymce.min.js
工作小提琴:https://jsfiddle.net/x4puwmbc/
<form method="post" action="dump.php">
<textarea name="content"></textarea>
</form>
<script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script>
<script>
tinymce.init({
selector: "textarea",
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste"
],
toolbar: "styleselect fontselect fontsizeselect | forecolor backcolor",
font_formats: 'Libre Barcode 128=Libre Barcode 128, cursive',
content_css: [
'//fonts.googleapis.com/css?family=Libre+Barcode+128',
'//www.tinymce.com/css/codepen.min.css'
]
});
</script>