【问题标题】:Tiny MCE how to get a tag properties?Tinymce如何获取标签属性?
【发布时间】:2023-03-30 21:00:01
【问题描述】:

我正在使用 TinyMCE 进行文本格式化。我有类似的 HTML 代码:

<span class="ps_bonus_text_wide_t" style="font-family: Michroma;">
my text
</span>

当我选择该文本和 class="ps_bonus_text_wide_t" 时,我需要将其更改为

<div class="effect">
<span class="ps_bonus_text_wide_t" style="font-family: Michroma;">
my text
</span>
</div>

如何验证class="ps_bonus_text_wide_t"?

我的插件代码是:

// Creates a new plugin class and a custom listbox
tinymce.create('tinymce.plugins.fonteffect', {
    createControl: function(n, cm) {
        switch (n) {
            case 'fonteffect':
                var mlb = cm.createListBox('fonteffect', {
                     title : 'Font effects',
                     onselect : function(v) {
                        // n.selection.setContent(v);                            
                         var ed=this.control_manager.editor;
                        ed.focus();
//to do something here

                     }
                });

                // Add some values to the list box
                mlb.add('anaglyph', 'anaglyph');
                mlb.add('brick-sign', 'brick-sign');
                mlb.add('canvas-print', 'canvas-print');
                mlb.add('crackle', 'crackle');
                mlb.add('decaying', 'decaying');
                mlb.add('destruction', 'destruction');                  
                // Return the new listbox instance
                return mlb;
        }

        return null;
    }
});

【问题讨论】:

  • 您的问题到底是什么?

标签: php editor tinymce


【解决方案1】:

您将能够使用此代码 sn-p 检查课程 ps_bonus_text_wide_t

var node = ed.selection.getNode();

if (node.nodeNAme == "SPAN" && node.className == "ps_bonus_text_wide_t"){
  //do whatever you like here
}

【讨论】:

    猜你喜欢
    • 2015-04-25
    • 2011-09-20
    • 2020-11-27
    • 2017-05-11
    • 1970-01-01
    • 2018-04-19
    • 2016-07-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多