function insertCaretContainerOrExpandToBlock(target, before) {
			var caretContainer, rng;

			// Select block
			if (getContentEditable(target) === "false") {
				if (dom.isBlock(target)) {
					selection.select(target);
					return;
				}
			}

			rng = dom.createRng();

			if (getContentEditable(target) === "true") {
				if (!target.firstChild) {
					target.appendChild(ed.getDoc().createTextNode('\u00a0'));
				}

				target = target.firstChild;
				before = true;
			}

			//caretContainer = dom.create('span', {id: caretContainerId, 'data-mce-bogus': true, style:'border: 1px solid red'}, invisibleChar);
			caretContainer = dom.create('span', {id: caretContainerId, 'data-mce-bogus': true}, invisibleChar);

			if (before) {
				target.parentNode.insertBefore(caretContainer, target);
			} else {
				dom.insertAfter(caretContainer, target);
			}

			rng.setStart(caretContainer.firstChild, 1);
			rng.collapse(true);
			selection.setRng(rng);

			return caretContainer;
		}
function insertCaretContainerOrExpandToBlock(target, before) {
			var caretContainer, rng;

			
			if (getContentEditable(target) === "false") {
				if (dom.isBlock(target)) {
					selection.select(target);
					return;
				}
			}

			rng = dom.createRng();

			if (getContentEditable(target) === "true") {
				if (!target.firstChild) {
					target.appendChild(ed.getDoc().createTextNode('\u00a0'));
				}

				target = target.firstChild;
				before = true;
			}

			
			caretContainer = dom.create('span', {id: caretContainerId, 'data-mce-bogus': true}, invisibleChar);

			if (before) {
				target.parentNode.insertBefore(caretContainer, target);
			} else {
				dom.insertAfter(caretContainer, target);
			}

			rng.setStart(caretContainer.firstChild, 1);
			rng.collapse(true);
			selection.setRng(rng);

			return caretContainer;
		}
function insertCaretContainerOrExpandToBlock ( target , before ) { var caretContainer , rng ; // Select block
 if ( getContentEditable ( target ) === "false" ) { if ( dom . isBlock ( target ) ) { selection . select ( target ) ; return ; } } rng = dom . createRng ( ) ; if ( getContentEditable ( target ) === "true" ) { if ( ! target . firstChild ) { target . appendChild ( ed . getDoc ( ) . createTextNode ( '\u00a0' ) ) ; } target = target . firstChild ; before = true ; } //caretContainer = dom.create('span', {id: caretContainerId, 'data-mce-bogus': true, style:'border: 1px solid red'}, invisibleChar);
 caretContainer = dom . create ( 'span' , { id : caretContainerId , 'data-mce-bogus' : true } , invisibleChar ) ; if ( before ) { target . parentNode . insertBefore ( caretContainer , target ) ; } else { dom . insertAfter ( caretContainer , target ) ; } rng . setStart ( caretContainer . firstChild , 1 ) ; rng . collapse ( true ) ; selection . setRng ( rng ) ; return caretContainer ; }
Insert caret container before/after target or expand selection to include block
Insert caret container before / after target or expand selection to include block