vue tinymce 首行缩进

node modules 内

index.js文件

// Exports the "indent2em" plugin for usage with module loaders
// Usage:
//   CommonJS:
//     require('tinymce/plugins/indent2em')
//   ES2015:
//     import 'tinymce/plugins/indent2em'
require('./plugin.js');

看情况是否改造indent2em/plugin.js

(function () {
  var indent2em = (function () {
      'use strict';
  
      var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
      var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
      

      var doAct = function (editor) {
        var dom = editor.dom;
        var blocks = editor.selection.getSelectedBlocks();
        var act = '';
        var indent2em_val = editor.getParam('indent2em_val', '2em')
        global$1.each(blocks, function (block) {
            if(act==''){
                act = dom.getStyle(block,'text-indent')== indent2em_val ? 'remove' : 'add';
            }
            if( act=='add' ){
                dom.setStyle(block, 'text-indent', indent2em_val);
            }else{
                var style=dom.getAttrib(block,'style');
                style = style.replace(/text-indent:[\s]*2em;/ig,'');
                dom.setAttrib(block,'style',style);
            }

        });
      };

      var register = function (editor) {
        console.log(editor.ui.registry.getAll().icons)
        editor.ui.registry.getAll().icons.indent2em || editor.ui.registry.addIcon('indent2em','<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M170.666667 563.2v-102.4H887.466667v102.4zM170.666667 836.266667v-102.4H887.466667v102.4zM512 290.133333v-102.4H887.466667v102.4zM238.933333 341.333333V136.533333l204.8 102.4z" fill="#2c2c2c" p-id="5210"></path></svg>');
        editor.ui.registry.addButton('indent2em', {
          tooltip: '首行缩进',
          icon: 'indent2em',
          onAction: function () {
            doAct(editor);
          }
        });
        editor.ui.registry.addMenuItem('indent2em', {
          text: '首行缩进',
          icon: 'indent2em',
          onAction: function () {
            doAct(editor);
          }
        });
      };

      global.add('indent2em', function (editor) {
        register(editor)
      });

      function Plugin () {
      }
  
      return Plugin;
  
  }());
  })();

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值