selectall.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * 全选
  3. * @file
  4. * @since 1.2.6.1
  5. */
  6. /**
  7. * 选中所有内容
  8. * @command selectall
  9. * @method execCommand
  10. * @param { String } cmd 命令字符串
  11. * @example
  12. * ```javascript
  13. * editor.execCommand( 'selectall' );
  14. * ```
  15. */
  16. UE.plugins['selectall'] = function(){
  17. var me = this;
  18. me.commands['selectall'] = {
  19. execCommand : function(){
  20. //去掉了原生的selectAll,因为会出现报错和当内容为空时,不能出现闭合状态的光标
  21. var me = this,body = me.body,
  22. range = me.selection.getRange();
  23. range.selectNodeContents(body);
  24. if(domUtils.isEmptyBlock(body)){
  25. //opera不能自动合并到元素的里边,要手动处理一下
  26. if(browser.opera && body.firstChild && body.firstChild.nodeType == 1){
  27. range.setStartAtFirst(body.firstChild);
  28. }
  29. range.collapse(true);
  30. }
  31. range.select(true);
  32. },
  33. notNeedUndo : 1
  34. };
  35. //快捷键
  36. me.addshortcutkey({
  37. "selectAll" : "ctrl+65"
  38. });
  39. };