indent.js 700 B

123456789101112131415161718192021222324252627
  1. /**
  2. * 首行缩进
  3. * @file
  4. * @since 1.2.6.1
  5. */
  6. /**
  7. * 缩进
  8. * @command indent
  9. * @method execCommand
  10. * @param { String } cmd 命令字符串
  11. * @example
  12. * ```javascript
  13. * editor.execCommand( 'indent' );
  14. * ```
  15. */
  16. UE.commands['indent'] = {
  17. execCommand : function() {
  18. var me = this,value = me.queryCommandState("indent") ? "0em" : (me.options.indentValue || '2em');
  19. me.execCommand('Paragraph','p',{style:'text-indent:'+ value});
  20. },
  21. queryCommandState : function() {
  22. var pN = domUtils.filterNodeList(this.selection.getStartElementPath(),'p h1 h2 h3 h4 h5 h6');
  23. return pN && pN.style.textIndent && parseInt(pN.style.textIndent) ? 1 : 0;
  24. }
  25. };