123456789101112131415161718192021222324252627282930313233343536 |
- ///import core
- ///commands 插入空行
- ///commandsName insertparagraph
- ///commandsTitle 插入空行
- /**
- * 插入空行
- * @function
- * @name baidu.editor.execCommand
- * @param {String} cmdName insertparagraph
- */
- UE.commands['insertparagraph'] = {
- execCommand : function( cmdName,front) {
- var me = this,
- range = me.selection.getRange(),
- start = range.startContainer,tmpNode;
- while(start ){
- if(domUtils.isBody(start)){
- break;
- }
- tmpNode = start;
- start = start.parentNode;
- }
- if(tmpNode){
- var p = me.document.createElement('p');
- if(front){
- tmpNode.parentNode.insertBefore(p,tmpNode)
- }else{
- tmpNode.parentNode.insertBefore(p,tmpNode.nextSibling)
- }
- domUtils.fillNode(me.document,p);
- range.setStart(p,0).setCursor(false,true);
- }
- }
- };
|