readonly.html 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <!DOCTYPE html>
  2. <!--
  3. Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
  4. For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  5. -->
  6. <html lang="en">
  7. <head>
  8. <meta charset="utf-8">
  9. <title>Using the CKEditor Read-Only API &mdash; CKEditor Sample</title>
  10. <script src="../../ckeditor.js"></script>
  11. <link rel="stylesheet" href="sample.css">
  12. <meta name="description" content="Try the latest sample of CKEditor 4 and learn more about customizing your WYSIWYG editor with endless possibilities.">
  13. <script>
  14. var editor;
  15. // The instanceReady event is fired, when an instance of CKEditor has finished
  16. // its initialization.
  17. CKEDITOR.on( 'instanceReady', function( ev ) {
  18. editor = ev.editor;
  19. // Show this "on" button.
  20. document.getElementById( 'readOnlyOn' ).style.display = '';
  21. // Event fired when the readOnly property changes.
  22. editor.on( 'readOnly', function() {
  23. document.getElementById( 'readOnlyOn' ).style.display = this.readOnly ? 'none' : '';
  24. document.getElementById( 'readOnlyOff' ).style.display = this.readOnly ? '' : 'none';
  25. });
  26. });
  27. function toggleReadOnly( isReadOnly ) {
  28. // Change the read-only state of the editor.
  29. // https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#method-setReadOnly
  30. editor.setReadOnly( isReadOnly );
  31. }
  32. </script>
  33. </head>
  34. <body>
  35. <h1 class="samples">
  36. <a href="index.html">CKEditor Samples</a> &raquo; Using the CKEditor Read-Only API
  37. </h1>
  38. <div class="warning deprecated">
  39. This sample is not maintained anymore. Check out its <a href="https://ckeditor.com/docs/ckeditor4/latest/examples/readonly.html">brand new version in CKEditor Examples</a>.
  40. </div>
  41. <div class="description">
  42. <p>
  43. This sample shows how to use the
  44. <code><a class="samples" href="https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#method-setReadOnly">setReadOnly</a></code>
  45. API to put editor into the read-only state that makes it impossible for users to change the editor contents.
  46. </p>
  47. <p>
  48. For details on how to create this setup check the source code of this sample page.
  49. </p>
  50. </div>
  51. <form action="sample_posteddata.php" method="post">
  52. <p>
  53. <textarea class="ckeditor" id="editor1" name="editor1" cols="100" 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>
  54. </p>
  55. <p>
  56. <input id="readOnlyOn" onclick="toggleReadOnly();" type="button" value="Make it read-only" style="display:none">
  57. <input id="readOnlyOff" onclick="toggleReadOnly( false );" type="button" value="Make it editable again" style="display:none">
  58. </p>
  59. </form>
  60. <div id="footer">
  61. <hr>
  62. <p>
  63. CKEditor - The text editor for the Internet - <a class="samples" href="https://ckeditor.com/">https://ckeditor.com</a>
  64. </p>
  65. <p id="copy">
  66. Copyright &copy; 2003-2023, <a class="samples" href="https://cksource.com/">CKSource</a> Holding sp. z o.o. All rights reserved.
  67. </p>
  68. </div>
  69. </body>
  70. </html>