javascript - TintMCE - 单击按钮后更改文本字体大小
问题描述
单击字体按钮后,我想更改所选文本的大小Change Font
:但使用该行后它没有改变:
editor.execCommand("fontSize", false, e.data.source)
这是带有小提琴的代码:
<script type="text/javascript">
tinymce.init({
selector: "textarea",
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste"
],
toolbar: "wrapselection | code | insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
setup: function (editor) {
editor.addButton('wrapselection', {
text: 'Change Font',
icon: false,
onclick: function () {
editor.windowManager.open({
title: 'Enter Font Size',
body: [
{type: 'textbox', name: 'source', label: 'Font Size'}
],
onsubmit: function(e) {
alert(e.data.source);
editor.focus();
editor.execCommand("fontSize", false, e.data.source);
}
});
}
});
}
});
</script>
<form method="post" action="dump.php">
<textarea name="content">This is content in the editor</textarea>
</form>
http://fiddle.tinymce.com/a7gaab
用户单击其大小后如何更改字体大小?
解决方案
只需在警报消息后添加以下代码行
editor.getBody().style.fontSize = e.data.source + 'px';
更新代码
推荐阅读
- ios - 如何找出对象的方法何时被调用?
- sql - SQL 按聚合 varchar 列分组
- c - 从 C 中的函数返回二维数组
- elasticsearch - 如何在elasticsearch中按结果聚合分组
- json - play-json: JsNull 不等于 JsString(null),如何解决这个问题?
- css - mat-button-toggle 不换行
- java - 如何在 Java 9 的模块化项目中从资源文件夹中加载图像?
- parameters - 在google dataproc上执行pig作业时,如何使用params标志以逗号分隔的多个值?
- javascript - 如果我在一个页面上有两个 iframe,是否可以将源自一个的 MessageChannel 传输到另一个?
- r - 5 维数据的密度图