code: function applyBlockFormat() {
          var selection, dom, container, firstTextNode, node, format, textBlockElm, pattern, walker, rng, offset;
  
          selection = editor.selection;
          dom = editor.dom;
  
          if (!selection.isCollapsed()) {
            return;
          }
  
          textBlockElm = dom.getParent(selection.getStart(), 'p');
          if (textBlockElm) {
            walker = new TreeWalker(textBlockElm, textBlockElm);
            while ((node = walker.next())) {
              if (node.nodeType == 3) {
                firstTextNode = node;
                break;
              }
            }
  
            if (firstTextNode) {
              pattern = findPattern(firstTextNode.data);
              if (!pattern) {
                return;
              }
  
              rng = selection.getRng(true);
              container = rng.startContainer;
              offset = rng.startOffset;
  
              if (firstTextNode == container) {
                offset = Math.max(0, offset - pattern.start.length);
              }
  
              if (Tools.trim(firstTextNode.data).length == pattern.start.length) {
                return;
              }
  
              if (pattern.format) {
                format = editor.formatter.get(pattern.format);
                if (format && format[0].block) {
                  firstTextNode.deleteData(0, pattern.start.length);
                  editor.formatter.apply(pattern.format, {}, firstTextNode);
  
                  rng.setStart(container, offset);
                  rng.collapse(true);
                  selection.setRng(rng);
                }
              }
  
              if (pattern.cmd) {
                editor.undoManager.transact(function () {
                  firstTextNode.deleteData(0, pattern.start.length);
                  editor.execCommand(pattern.cmd);
                });
              }
            }
          }
        }
docs: Handles block formats like ##abc or 1. abc