rowspacing.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * 段前段后间距插件
  3. * @file
  4. * @since 1.2.6.1
  5. */
  6. /**
  7. * 设置段间距
  8. * @command rowspacing
  9. * @method execCommand
  10. * @param { String } cmd 命令字符串
  11. * @param { String } value 段间距的值,以px为单位
  12. * @param { String } dir 间距位置,top或bottom,分别表示段前和段后
  13. * @example
  14. * ```javascript
  15. * editor.execCommand( 'rowspacing', '10', 'top' );
  16. * ```
  17. */
  18. UE.plugins['rowspacing'] = function(){
  19. var me = this;
  20. me.setOpt({
  21. 'rowspacingtop':['5', '10', '15', '20', '25'],
  22. 'rowspacingbottom':['5', '10', '15', '20', '25']
  23. });
  24. me.commands['rowspacing'] = {
  25. execCommand : function( cmdName,value,dir ) {
  26. this.execCommand('paragraph','p',{style:'margin-'+dir+':'+value + 'px'});
  27. return true;
  28. },
  29. queryCommandValue : function(cmdName,dir) {
  30. var pN = domUtils.filterNodeList(this.selection.getStartElementPath(),function(node){return domUtils.isBlockElm(node) }),
  31. value;
  32. //trace:1026
  33. if(pN){
  34. value = domUtils.getComputedStyle(pN,'margin-'+dir).replace(/[^\d]/g,'');
  35. return !value ? 0 : value;
  36. }
  37. return 0;
  38. }
  39. };
  40. };