autogrow.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <!DOCTYPE html>
  2. <!--
  3. Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  4. For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-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/old/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/old/index.html">CKEditor Samples</a> &raquo; Using AutoGrow Plugin
  19. </h1>
  20. <div class="warning deprecated">
  21. This sample is not maintained anymore. Check out its <a href="https://ckeditor.com/docs/ckeditor4/latest/examples/autogrow.html">brand new version in CKEditor Examples</a>.
  22. </div>
  23. <div class="description">
  24. <p>
  25. This sample shows how to configure CKEditor instances to use the
  26. <strong>AutoGrow</strong> (<code>autogrow</code>) plugin that lets the editor window expand
  27. and shrink depending on the amount and size of content entered in the editing area.
  28. </p>
  29. <p>
  30. In its default implementation the <strong>AutoGrow feature</strong> can expand the
  31. CKEditor window infinitely in order to avoid introducing scrollbars to the editing area.
  32. </p>
  33. <p>
  34. It is also possible to set a maximum height for the editor window. Once CKEditor
  35. editing area reaches the value in pixels specified in the
  36. <code><a class="samples" href="https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-autoGrow_maxHeight">autoGrow_maxHeight</a></code>
  37. configuration setting, scrollbars will be added and the editor window will no longer expand.
  38. </p>
  39. <p>
  40. To add a CKEditor instance using the <code>autogrow</code> plugin and its
  41. <code>autoGrow_maxHeight</code> attribute, insert the following JavaScript call to your code:
  42. </p>
  43. <pre class="samples">
  44. CKEDITOR.replace( '<em>textarea_id</em>', {
  45. <strong>extraPlugins: 'autogrow',</strong>
  46. autoGrow_maxHeight: 800,
  47. // Remove the Resize plugin as it does not make sense to use it in conjunction with the AutoGrow plugin.
  48. removePlugins: 'resize'
  49. });</pre>
  50. <p>
  51. Note that <code><em>textarea_id</em></code> in the code above is the <code>id</code> attribute of
  52. the <code>&lt;textarea&gt;</code> element to be replaced with CKEditor. The maximum height should
  53. be given in pixels.
  54. </p>
  55. </div>
  56. <form action="../../../samples/sample_posteddata.php" method="post">
  57. <p>
  58. <label for="editor1">
  59. CKEditor using the <code>autogrow</code> plugin with its default configuration:
  60. </label>
  61. <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="https://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
  62. <script>
  63. CKEDITOR.replace( 'editor1', {
  64. extraPlugins: 'autogrow',
  65. removePlugins: 'resize'
  66. });
  67. </script>
  68. </p>
  69. <p>
  70. <label for="editor2">
  71. CKEditor using the <code>autogrow</code> plugin with maximum height set to 400 pixels:
  72. </label>
  73. <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="https://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
  74. <script>
  75. CKEDITOR.replace( 'editor2', {
  76. extraPlugins: 'autogrow',
  77. autoGrow_maxHeight: 400,
  78. removePlugins: 'resize'
  79. });
  80. </script>
  81. </p>
  82. <p>
  83. <input type="submit" value="Submit">
  84. </p>
  85. </form>
  86. <div id="footer">
  87. <hr>
  88. <p>
  89. CKEditor - The text editor for the Internet - <a class="samples" href="https://ckeditor.com/">https://ckeditor.com</a>
  90. </p>
  91. <p id="copy">
  92. Copyright &copy; 2003-2019, <a class="samples" href="https://cksource.com/">CKSource</a> - Frederico
  93. Knabben. All rights reserved.
  94. </p>
  95. </div>
  96. </body>
  97. </html>