Javascript TintMCE-单击按钮后更改文本字体大小
单击Javascript TintMCE-单击按钮后更改文本字体大小,javascript,jquery,tinymce,tinymce-4,Javascript,Jquery,Tinymce,Tinymce 4,单击change font中的字体按钮后,我想更改所选文本的大小: 但我认为在使用该行后不会发生变化: editor.execCommand(“fontSize”,false,e.data.source) 下面是代码及其小提琴: <script type="text/javascript"> tinymce.init({ selector: "textarea", plugins: [ "advlist autolink lists link imag
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>
tinymce.init({
选择器:“文本区域”,
插件:[
“advlist autolink列出链接图像charmap打印预览锚”,
“searchreplace visualblocks代码全屏显示”,
“insertdatetime媒体表上下文菜单粘贴”
],
工具栏:“wrapselection | code | insertfile undo redo | styleselect |粗体斜体| alignleft aligncenter alignright alignjustify | bullist numlist outdent indent |链接图像”,
设置:函数(编辑器){
editor.addButton('wrapselection'{
文本:“更改字体”,
图标:false,
onclick:function(){
editor.windowManager.open({
标题:“输入字体大小”,
正文:[
{类型:'textbox',名称:'source',标签:'Font Size'}
],
提交人:函数(e){
警报(如数据源);
editor.focus();
editor.execCommand(“fontSize”,false,e.data.source);
}
});
}
});
}
});
这是编辑器中的内容
在用户单击字体大小后,如何更改字体大小?只需在警告消息后添加下面的代码行即可
editor.getBody().style.fontSize = e.data.source + 'px';
更新代码