tinymce.full.js
function wrapSelfAndSiblingsInDefaultBlock(container, offset) {
          var newBlock, parentBlock, startNode, node, next, rootBlockName, blockName = newBlockName || 'P';

          // Not in a block element or in a table cell or caption
          parentBlock = dom.getParent(container, dom.isBlock);
          if (!parentBlock || !canSplitBlock(parentBlock)) {
            parentBlock = parentBlock || editableRoot;

            if (parentBlock == editor.getBody() || isTableCell(parentBlock)) {
              rootBlockName = parentBlock.nodeName.toLowerCase();
            } else {
              rootBlockName = parentBlock.parentNode.nodeName.toLowerCase();
            }

            if (!parentBlock.hasChildNodes()) {
              newBlock = dom.create(blockName);
              setForcedBlockAttrs(newBlock);
              parentBlock.appendChild(newBlock);
              rng.setStart(newBlock, 0);
              rng.setEnd(newBlock, 0);
              return newBlock;
            }

            // Find parent that is the first child of parentBlock
            node = container;
            while (node.parentNode != parentBlock) {
              node = node.parentNode;
            }

            // Loop left to find start node start wrapping at
            while (node && !dom.isBlock(node)) {
              startNode = node;
              node = node.previousSibling;
            }

            if (startNode && schema.isValidChild(rootBlockName, blockName.toLowerCase())) {
              newBlock = dom.create(blockName);
              setForcedBlockAttrs(newBlock);
              startNode.parentNode.insertBefore(newBlock, startNode);

              // Start wrapping until we hit a block
              node = startNode;
              while (node && !dom.isBlock(node)) {
                next = node.nextSibling;
                newBlock.appendChild(node);
                node = next;
              }

              // Restore range to it's past location
              rng.setStart(container, offset);
              rng.setEnd(container, offset);
            }
          }

          return container;
        }
function wrapSelfAndSiblingsInDefaultBlock(container, offset) {
          var newBlock, parentBlock, startNode, node, next, rootBlockName, blockName = newBlockName || 'P';

          // Not in a block element or in a table cell or caption
          parentBlock = dom.getParent(container, dom.isBlock);
          if (!parentBlock || !canSplitBlock(parentBlock)) {
            parentBlock = parentBlock || editableRoot;

            if (parentBlock == editor.getBody() || isTableCell(parentBlock)) {
              rootBlockName = parentBlock.nodeName.toLowerCase();
            } else {
              rootBlockName = parentBlock.parentNode.nodeName.toLowerCase();
            }

            if (!parentBlock.hasChildNodes()) {
              newBlock = dom.create(blockName);
              setForcedBlockAttrs(newBlock);
              parentBlock.appendChild(newBlock);
              rng.setStart(newBlock, 0);
              rng.setEnd(newBlock, 0);
              return newBlock;
            }

            // Find parent that is the first child of parentBlock
            node = container;
            while (node.parentNode != parentBlock) {
              node = node.parentNode;
            }

            // Loop left to find start node start wrapping at
            while (node && !dom.isBlock(node)) {
              startNode = node;
              node = node.previousSibling;
            }

            if (startNode && schema.isValidChild(rootBlockName, blockName.toLowerCase())) {
              newBlock = dom.create(blockName);
              setForcedBlockAttrs(newBlock);
              startNode.parentNode.insertBefore(newBlock, startNode);

              // Start wrapping until we hit a block
              node = startNode;
              while (node && !dom.isBlock(node)) {
                next = node.nextSibling;
                newBlock.appendChild(node);
                node = next;
              }

              // Restore range to it's past location
              rng.setStart(container, offset);
              rng.setEnd(container, offset);
            }
          }

          return container;
        }
function wrapSelfAndSiblingsInDefaultBlock ( container , offset ) { var newBlock , parentBlock , startNode , node , next , rootBlockName , blockName = newBlockName || 'P' ; // Not in a block element or in a table cell or caption parentBlock = dom . getParent ( container , dom . isBlock ) ; if ( ! parentBlock || ! canSplitBlock ( parentBlock ) ) { parentBlock = parentBlock || editableRoot ; if ( parentBlock == editor . getBody ( ) || isTableCell ( parentBlock ) ) { rootBlockName = parentBlock . nodeName . toLowerCase ( ) ; } else { rootBlockName = parentBlock . parentNode . nodeName . toLowerCase ( ) ; } if ( ! parentBlock . hasChildNodes ( ) ) { newBlock = dom . create ( blockName ) ; setForcedBlockAttrs ( newBlock ) ; parentBlock . appendChild ( newBlock ) ; rng . setStart ( newBlock , 0 ) ; rng . setEnd ( newBlock , 0 ) ; return newBlock ; } // Find parent that is the first child of parentBlock node = container ; while ( node . parentNode != parentBlock ) { node = node . parentNode ; } // Loop left to find start node start wrapping at while ( node && ! dom . isBlock ( node ) ) { startNode = node ; node = node . previousSibling ; } if ( startNode && schema . isValidChild ( rootBlockName , blockName . toLowerCase ( ) ) ) { newBlock = dom . create ( blockName ) ; setForcedBlockAttrs ( newBlock ) ; startNode . parentNode . insertBefore ( newBlock , startNode ) ; // Start wrapping until we hit a block node = startNode ; while ( node && ! dom . isBlock ( node ) ) { next = node . nextSibling ; newBlock . appendChild ( node ) ; node = next ; } // Restore range to it's past location rng . setStart ( container , offset ) ; rng . setEnd ( container , offset ) ; } } return container ; }
Wraps any text nodes or inline elements in the specified forced root block name
Wraps any text nodes or inline elements in the specified forced root block name