indent.js 764 B

12345678910111213141516171819202122
  1. ///import core
  2. ///import plugins\paragraph.js
  3. ///commands 首行缩进
  4. ///commandsName Outdent,Indent
  5. ///commandsTitle 取消缩进,首行缩进
  6. /**
  7. * 首行缩进
  8. * @function
  9. * @name baidu.editor.execCommand
  10. * @param {String} cmdName outdent取消缩进,indent缩进
  11. */
  12. UE.commands['indent'] = {
  13. execCommand : function() {
  14. var me = this,value = me.queryCommandState("indent") ? "0em" : (me.options.indentValue || '2em');
  15. me.execCommand('Paragraph','p',{style:'text-indent:'+ value});
  16. },
  17. queryCommandState : function() {
  18. var pN = domUtils.filterNodeList(this.selection.getStartElementPath(),'p h1 h2 h3 h4 h5 h6');
  19. return pN && pN.style.textIndent && parseInt(pN.style.textIndent) ? 1 : 0;
  20. }
  21. };