Magic Line Documentation
Some document elements make placing the cursor in their vicinity problematic. This pertains to, for example, images, tables or <div>
elements that start or end a
document, lists, or even adjacent horizontal lines.
CKEditor 4 introduced the Magic Line plugin that helps overcome these limitations. By default, this plugin is included in the Standard and Full editor distributions. It causes a red line with a handle () to appear when you hover your mouse over any such otherwise inaccessible place in an active editor. When you click the magic line's handle (or use the default Shift+Ctrl+3 and Shift+Ctrl+4 keyboard shortcut), a new paragraph will be inserted into the document.
A few configuration options are available to fine-tune this feature, including adjusting the magic line color, setting custom keyboard shortcuts, or adjusting which elements should trigger the appearance of the magic line. Refer to the Magic Line article to learn more about this feature.
Get Sample Source Code
- Magic line
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="robots" content="noindex, nofollow"> <title>Magic line</title> <script src="https://cdn.ckeditor.com/4.25.0-lts/standard-all/ckeditor.js"></script> </head> <body> <textarea cols="80" id="editor1" name="editor1" rows="10"><table border="1" cellpadding="1" cellspacing="1" style="width: 100%; "> <tbody> <tr> <td>This table</td> <td>is the</td> <td>very first</td> <td>element of the document.</td> </tr> <tr> <td>You are still</td> <td>able to place</td> <td>the cursor before it.</td> <td> <table border="1" cellpadding="1" cellspacing="1" style="width: 100%; "> <tbody> <tr> <td>This table is inside a cell of another table.</td> </tr> <tr> <td>You can type&nbsp;either before or after it, though.</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <p>The following are two successive horizontal lines (<code>hr</code> elements). Thanks to Magic Line you can easily place the cursor in between them:</p> <hr /> <hr /> <ol> <li>This numbered list...</li> <li>...is a neighbor of the horizontal line above...</li> <li>...and also of another list.</li> </ol> <ul> <li>Nevertheless, you can type between the lists...</li> <li>...thanks to <strong>Magic Line</strong>!</li> </ul> <p>Lorem ipsum dolor sit amet dui. Morbi vel turpis. Nullam et leo. Etiam rutrum, urna tellus dui vel tincidunt mattis egestas, justo fringilla vel, massa.</p> <p>Ut pretium. Vestibulum rutrum in, adipiscing elit. Sed in quam in purus sem vitae pede. Pellentesque bibendum, urna sem vel risus. Vivamus posuere metus. Aliquam gravida iaculis nisl. Nam enim. Aliquam erat ac lacus tellus ac felis.</p> <div style="border: 2px dashed green; background: #ddd; text-align: center;"> <p>This text is wrapped in a&nbsp;<code>div</code>&nbsp;element. Thanks to Magic Line you can type after this element, too.</p> </div> </textarea> <script> CKEDITOR.replace('editor1', { height: '500', // Ensure that the Magic Line plugin, which is required for this sample, is loaded. extraPlugins: 'magicline', // Magic Line does not require any additional ACF settings. // We set config.extraAllowedContent because HTML code in this sample contains // a <div> element with custom styles that we would like to allow. extraAllowedContent: 'div{border,background,text-align}', removeButtons: 'PasteFromWord' }); </script> </body> </html>