autogrow.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <!DOCTYPE html>
  2. <!--
  3. Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  4. For licensing, see LICENSE.md or http://ckeditor.com/license
  5. -->
  6. <html>
  7. <head>
  8. <meta charset="utf-8">
  9. <title>AutoGrow Plugin &mdash; CKEditor Sample</title>
  10. <script src="../../../ckeditor.js"></script>
  11. <link rel="stylesheet" href="../../../samples/sample.css">
  12. <meta name="ckeditor-sample-name" content="AutoGrow plugin">
  13. <meta name="ckeditor-sample-group" content="Plugins">
  14. <meta name="ckeditor-sample-description" content="Using the AutoGrow plugin in order to make the editor grow to fit the size of its content.">
  15. </head>
  16. <body>
  17. <h1 class="samples">
  18. <a href="../../../samples/index.html">CKEditor Samples</a> &raquo; Using AutoGrow Plugin
  19. </h1>
  20. <div class="description">
  21. <p>
  22. This sample shows how to configure CKEditor instances to use the
  23. <strong>AutoGrow</strong> (<code>autogrow</code>) plugin that lets the editor window expand
  24. and shrink depending on the amount and size of content entered in the editing area.
  25. </p>
  26. <p>
  27. In its default implementation the <strong>AutoGrow feature</strong> can expand the
  28. CKEditor window infinitely in order to avoid introducing scrollbars to the editing area.
  29. </p>
  30. <p>
  31. It is also possible to set a maximum height for the editor window. Once CKEditor
  32. editing area reaches the value in pixels specified in the
  33. <code><a class="samples" href="http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-autoGrow_maxHeight">autoGrow_maxHeight</a></code>
  34. configuration setting, scrollbars will be added and the editor window will no longer expand.
  35. </p>
  36. <p>
  37. To add a CKEditor instance using the <code>autogrow</code> plugin and its
  38. <code>autoGrow_maxHeight</code> attribute, insert the following JavaScript call to your code:
  39. </p>
  40. <pre class="samples">
  41. CKEDITOR.replace( '<em>textarea_id</em>', {
  42. <strong>extraPlugins: 'autogrow',</strong>
  43. autoGrow_maxHeight: 800,
  44. // Remove the Resize plugin as it does not make sense to use it in conjunction with the AutoGrow plugin.
  45. removePlugins: 'resize'
  46. });</pre>
  47. <p>
  48. Note that <code><em>textarea_id</em></code> in the code above is the <code>id</code> attribute of
  49. the <code>&lt;textarea&gt;</code> element to be replaced with CKEditor. The maximum height should
  50. be given in pixels.
  51. </p>
  52. </div>
  53. <form action="../../../samples/sample_posteddata.php" method="post">
  54. <p>
  55. <label for="editor1">
  56. CKEditor using the <code>autogrow</code> plugin with its default configuration:
  57. </label>
  58. <textarea cols="80" id="editor1" name="editor1" rows="10">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
  59. <script>
  60. CKEDITOR.replace( 'editor1', {
  61. extraPlugins: 'autogrow',
  62. removePlugins: 'resize'
  63. });
  64. </script>
  65. </p>
  66. <p>
  67. <label for="editor2">
  68. CKEditor using the <code>autogrow</code> plugin with maximum height set to 400 pixels:
  69. </label>
  70. <textarea cols="80" id="editor2" name="editor2" rows="10">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
  71. <script>
  72. CKEDITOR.replace( 'editor2', {
  73. extraPlugins: 'autogrow',
  74. autoGrow_maxHeight: 400,
  75. removePlugins: 'resize'
  76. });
  77. </script>
  78. </p>
  79. <p>
  80. <input type="submit" value="Submit">
  81. </p>
  82. </form>
  83. <div id="footer">
  84. <hr>
  85. <p>
  86. CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
  87. </p>
  88. <p id="copy">
  89. Copyright &copy; 2003-2015, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
  90. Knabben. All rights reserved.
  91. </p>
  92. </div>
  93. </body>
  94. </html>