selectall.js 980 B

1234567891011121314151617181920212223242526272829303132333435
  1. ///import core
  2. ///commands 全选
  3. ///commandsName SelectAll
  4. ///commandsTitle 全选
  5. /**
  6. * 选中所有
  7. * @function
  8. * @name baidu.editor.execCommand
  9. * @param {String} cmdName selectall选中编辑器里的所有内容
  10. * @author zhanyi
  11. */
  12. UE.plugins['selectall'] = function(){
  13. var me = this;
  14. me.commands['selectall'] = {
  15. execCommand : function(){
  16. //去掉了原生的selectAll,因为会出现报错和当内容为空时,不能出现闭合状态的光标
  17. var range = this.selection.getRange();
  18. range.selectNodeContents(this.body);
  19. if(domUtils.isEmptyBlock(this.body))
  20. range.collapse(true);
  21. range.select(true);
  22. this.selectAll = true;
  23. },
  24. notNeedUndo : 1
  25. };
  26. me.addListener('ready',function(){
  27. domUtils.on(me.document,'click',function(evt){
  28. me.selectAll = false;
  29. })
  30. })
  31. };