rowspacing.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ///import core
  2. ///import plugins\paragraph.js
  3. ///commands 段间距
  4. ///commandsName RowSpacingBottom,RowSpacingTop
  5. ///commandsTitle 段间距
  6. /**
  7. * @description 设置段前距,段后距
  8. * @name baidu.editor.execCommand
  9. * @param {String} cmdName rowspacing设置段间距
  10. * @param {String} value 值,以px为单位
  11. * @param {String} dir top或bottom段前后段后
  12. * @author zhanyi
  13. */
  14. UE.plugins['rowspacing'] = function(){
  15. var me = this;
  16. me.setOpt({
  17. 'rowspacingtop':['5', '10', '15', '20', '25'],
  18. 'rowspacingbottom':['5', '10', '15', '20', '25']
  19. });
  20. me.commands['rowspacing'] = {
  21. execCommand : function( cmdName,value,dir ) {
  22. this.execCommand('paragraph','p',{style:'margin-'+dir+':'+value + 'px'});
  23. return true;
  24. },
  25. queryCommandValue : function(cmdName,dir) {
  26. var pN = domUtils.filterNodeList(this.selection.getStartElementPath(),function(node){return domUtils.isBlockElm(node) }),
  27. value;
  28. //trace:1026
  29. if(pN){
  30. value = domUtils.getComputedStyle(pN,'margin-'+dir).replace(/[^\d]/g,'');
  31. return !value ? 0 : value;
  32. }
  33. return 0;
  34. }
  35. };
  36. };