| 195 | | editor.formatter.toggle('code'); |
| | 195 | var range = editor.selection.getRng(); |
| | 196 | var startContainerFirstBlockParent = editor.dom.getParent(range.startContainer, function(node) { |
| | 197 | return editor.dom.isBlock(node); |
| | 198 | }); |
| | 199 | var endContainerFirstBlockParent = editor.dom.getParent(range.endContainer, function(node) { |
| | 200 | return editor.dom.isBlock(node); |
| | 201 | }); |
| | 202 | var selectionSpansOverBlocks = startContainerFirstBlockParent !== endContainerFirstBlockParent; |
| | 203 | var selectionSpansEntireBlock = startContainerFirstBlockParent.textContent === editor.selection.getContent({format: 'text'}); |
| | 204 | if ( selectionSpansOverBlocks || selectionSpansEntireBlock ) { |
| | 205 | editor.formatter.toggle('pre'); |
| | 206 | } else { |
| | 207 | editor.formatter.toggle('code'); |
| | 208 | } |