indent.js 716 B

1234567891011121314151617181920212223242526272829303132
  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,
  19. value = me.queryCommandState("indent")
  20. ? "0em"
  21. : me.options.indentValue || "2em";
  22. me.execCommand("Paragraph", "p", { style: "text-indent:" + value });
  23. },
  24. queryCommandState: function() {
  25. var pN = domUtils.filterNodeList(
  26. this.selection.getStartElementPath(),
  27. "p h1 h2 h3 h4 h5 h6"
  28. );
  29. return pN && pN.style.textIndent && parseInt(pN.style.textIndent) ? 1 : 0;
  30. }
  31. };