cleardoc.js 736 B

12345678910111213141516171819202122232425262728
  1. ///import core
  2. ///commands 清空文档
  3. ///commandsName ClearDoc
  4. ///commandsTitle 清空文档
  5. /**
  6. *
  7. * 清空文档
  8. * @function
  9. * @name baidu.editor.execCommand
  10. * @param {String} cmdName cleardoc清空文档
  11. */
  12. UE.commands['cleardoc'] = {
  13. execCommand : function( cmdName) {
  14. var me = this,
  15. enterTag = me.options.enterTag,
  16. range = me.selection.getRange();
  17. if(enterTag == "br"){
  18. me.body.innerHTML = "<br/>";
  19. range.setStart(me.body,0).setCursor();
  20. }else{
  21. me.body.innerHTML = "<p>"+(ie ? "" : "<br/>")+"</p>";
  22. range.setStart(me.body.firstChild,0).setCursor(false,true);
  23. }
  24. me.fireEvent("clearDoc");
  25. }
  26. };