lineheight.js 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. ///import core
  2. ///import plugins\paragraph.js
  3. ///commands 行间距
  4. ///commandsName LineHeight
  5. ///commandsTitle 行间距
  6. /**
  7. * @description 设置行内间距
  8. * @name baidu.editor.execCommand
  9. * @param {String} cmdName lineheight设置行内间距
  10. * @param {String} value 值
  11. * @author zhuwenxuan
  12. */
  13. UE.plugins['lineheight'] = function(){
  14. var me = this;
  15. me.setOpt({'lineheight':['1', '1.5','1.75','2', '3', '4', '5']});
  16. me.commands['lineheight'] = {
  17. execCommand : function( cmdName,value ) {
  18. this.execCommand('paragraph','p',{style:'line-height:'+ (value == "1" ? "normal" : value + 'em') });
  19. return true;
  20. },
  21. queryCommandValue : function() {
  22. var pN = domUtils.filterNodeList(this.selection.getStartElementPath(),function(node){return domUtils.isBlockElm(node)});
  23. if(pN){
  24. var value = domUtils.getComputedStyle(pN,'line-height');
  25. return value == 'normal' ? 1 : value.replace(/[^\d.]*/ig,"");
  26. }
  27. }
  28. };
  29. };