英文:
Intercept event on changing font size
问题
当使用TinyMCE更改字体大小时,它会添加一个带有属性样式的,例如'font-size: 12pt'。
我想拦截这种行为并执行完全不同的操作。我需要所选的值,但我不希望文本在文本字段中更改,只希望在页面的另一部分中更改可视化效果。
有人知道是否可能实现这一点吗?
英文:
When changing fontsize with tinymce it adds a span with attribute style set to eg. 'font-size: 12pt'.
I would like to intercept that behaviour and do something totally different. I would need the chosen value but I don't want the text to change in the text field only in my visualisation on another part of the page.
Does anyone know if this is possible?
答案1
得分: 1
你可以使用FormatApply
事件来跟踪是否应用了任何格式。
以下是一个示例,它将通过浏览器控制台记录每个FormatApply
事件:
tinymce.init({
selector: "textarea",
setup: function(editor) {
editor.on('FormatApply', function(element) {
console.log(element);
});
}
});
我还创建了一个示例:https://fiddle.tiny.cloud/t8iaab。
英文:
You can utilize the FormatApply
event to track if any format was applied.
Here is an example that will log every FormatApply
event via the browser console:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
tinymce.init({
selector: "textarea",
setup: function(editor) {
editor.on('FormatApply', function(element) {
console.log(element);
});
}
});
<!-- end snippet -->
I've also created a fiddle: https://fiddle.tiny.cloud/t8iaab.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论