拦截更改字体大小的事件。

huangapple go评论54阅读模式
英文:

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: &quot;textarea&quot;,
    	setup: function(editor) {
    		editor.on(&#39;FormatApply&#39;, function(element) {
    			console.log(element);
    		});
    	}
    	
    });

<!-- end snippet -->

I've also created a fiddle: https://fiddle.tiny.cloud/t8iaab.

huangapple
  • 本文由 发表于 2023年5月22日 03:05:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76301479.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定