TinyMCE 自定义样式未应用(尽管技术上可行)

发布于 2024-12-08 17:00:13 字数 378 浏览 0 评论 0原文

我在为客户处理的一些自定义表单上安装了最新的 TinyMCE(jquery 版本)。我创建了一个自定义样式文件,并将 init 更改为指向正确的文件(以及在必要时加载它)。

自定义样式已正确加载我的样式,并且它们可以工作,除了一件事。当您选择未样式化的文本时,并选择一个样式,根本没有任何反应。没有为我选择的文本分配新类(所有自定义 css 都是自定义类(带有 @font-face)。

但是,如果我打开 TinyMCE 的 HTML 部分并手动添加class="garbage",然后尝试分配一个样式,它会用正确的类替换垃圾,并且

当没有分配类时它根本不会更新

。首先修改其他元素(使其成为 h1,h2,以不同方式对齐等),但它仍然不会更新类,除非我先手动将其设置为任何内容。

I have the latest TinyMCE installed (jquery version) on some custom forms I'm working on for a client. I created a custom styles file, and changed the init to point to the correct file (as well as load it where necessary.

The custom styles are correctly loaded with my styles, and they work, except for one thing. When you select unstylized text, and select a style nothing happens at all. No new class is assigned to the text that I've selected (all the custom css is custom classes (with @font-face).

However, if I open the HTML portion of TinyMCE and manually add class="garbage", then try to assign a style, it replaces garbage with the correct class. The text & font updates correctly as well.

It just will not update at all when there is no class already assigned.

Note: Also tried modifying other elements first (making it h1,h2, aligned differently etc..) but it still will not update the class unless I set it to anything manually first.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怎樣才叫好 2024-12-15 17:00:13

由于您使用的是 jQuery 版本,我相信如果您以 jQuery 方式初始化并使用tinyMCE,您的问题将会得到解决,如下所示:

// Initializes all textareas with the tinymce class
$().ready(function() {
   $('textarea.tinymce').tinymce({
      script_url : '../js/tinymce/jscripts/tiny_mce/tiny_mce.js',
      theme : "advanced",
      ...
   });
});

http://www.tinymce.com/wiki.php/jQuery_Plugin

而不是传统的 javascript 方式

<script type="text/javascript" >
tinyMCE.init({
        mode : "textareas",
        theme : "advanced",
        ...
});
</script >

As you are using the jQuery version, I believe your problem will be solved if you initialize and use tinyMCE the jQuery way, like so:

// Initializes all textareas with the tinymce class
$().ready(function() {
   $('textarea.tinymce').tinymce({
      script_url : '../js/tinymce/jscripts/tiny_mce/tiny_mce.js',
      theme : "advanced",
      ...
   });
});

http://www.tinymce.com/wiki.php/jQuery_Plugin

and not the traditional javascript way

<script type="text/javascript" >
tinyMCE.init({
        mode : "textareas",
        theme : "advanced",
        ...
});
</script >
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文