indent.js 837 B

1234567891011121314151617181920212223
  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. if(this.highlight){return -1;}
  19. var pN = utils.findNode(this.selection.getStartElementPath(),['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6']);
  20. return pN && pN.style.textIndent && parseInt(pN.style.textIndent) ? 1 : 0;
  21. }
  22. };