sourcedialog.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <!DOCTYPE html>
  2. <!--
  3. Copyright (c) 2003-2016, 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>Editing source code in a dialog &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="Editing source code in a dialog">
  13. <meta name="ckeditor-sample-group" content="Plugins">
  14. <meta name="ckeditor-sample-description" content="Editing HTML content of both inline and classic editor instances.">
  15. <meta name="ckeditor-sample-isnew" content="1">
  16. <style>
  17. #editable
  18. {
  19. padding: 10px;
  20. float: left;
  21. }
  22. </style>
  23. </head>
  24. <body>
  25. <h1 class="samples">
  26. <a href="../../../samples/old/index.html">CKEditor Samples</a> &raquo; Editing source code in a dialog
  27. </h1>
  28. <div class="warning deprecated">
  29. This sample is not maintained anymore. Check out its <a href="http://sdk.ckeditor.com/samples/sourcearea.html">brand new version in CKEditor SDK</a>.
  30. </div>
  31. <div class="description">
  32. <p>
  33. <strong>Sourcedialog</strong> plugin provides an easy way to edit raw HTML content
  34. of an editor, similarly to what is possible with <strong>Sourcearea</strong>
  35. plugin for classic (<code>iframe</code>-based) instances but using dialogs. Thanks to that, it's also possible
  36. to manipulate raw content of inline editor instances.
  37. </p>
  38. <p>
  39. This plugin extends the toolbar with a button,
  40. which opens a dialog window with a source code editor. It works with both classic
  41. and inline instances. To enable this
  42. plugin, basically add <code>extraPlugins: 'sourcedialog'</code> to editor's
  43. config:
  44. </p>
  45. <pre class="samples">
  46. // Inline editor.
  47. CKEDITOR.inline( 'editable', {
  48. <strong>extraPlugins: 'sourcedialog'</strong>
  49. });
  50. // Classic (iframe-based) editor.
  51. CKEDITOR.replace( 'textarea_id', {
  52. <strong>extraPlugins: 'sourcedialog'</strong>,
  53. removePlugins: 'sourcearea'
  54. });
  55. </pre>
  56. <p>
  57. Note that you may want to include <code>removePlugins: 'sourcearea'</code>
  58. in your config when using <strong>Sourcedialog</strong> in classic editor instances.
  59. This prevents feature redundancy.
  60. </p>
  61. <p>
  62. Note that <code>editable</code> in the code above is the <code>id</code>
  63. attribute of the <code>&lt;div&gt;</code> element to be converted into an inline instance.
  64. </p>
  65. <p>
  66. Note that <code><em>textarea_id</em></code> in the code above is the <code>id</code> attribute of
  67. the <code>&lt;textarea&gt;</code> element to be replaced with CKEditor.
  68. </p>
  69. </div>
  70. <div>
  71. <label for="editor1">
  72. Inline editor:
  73. </label>
  74. <div id="editor1" contenteditable="true" style="padding: 5px 20px;">
  75. <p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p>
  76. </div>
  77. </div>
  78. <br>
  79. <div>
  80. <label for="editor2">
  81. Classic editor:
  82. </label>
  83. <textarea cols="80" id="editor2" name="editor2" rows="10">
  84. 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;.
  85. </textarea>
  86. </div>
  87. <script>
  88. // We need to turn off the automatic editor creation first.
  89. CKEDITOR.disableAutoInline = true;
  90. var config = {
  91. toolbarGroups: [
  92. { name: 'mode' },
  93. { name: 'basicstyles' },
  94. { name: 'links' }
  95. ],
  96. extraPlugins: 'sourcedialog',
  97. removePlugins: 'sourcearea'
  98. }
  99. CKEDITOR.inline( 'editor1', config );
  100. CKEDITOR.replace( 'editor2', config );
  101. </script>
  102. <div id="footer">
  103. <hr>
  104. <p>
  105. CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">
  106. http://ckeditor.com</a>
  107. </p>
  108. <p id="copy">
  109. Copyright &copy; 2003-2016, <a class="samples" href="http://cksource.com/">CKSource</a>
  110. - Frederico Knabben. All rights reserved.
  111. </p>
  112. </div>
  113. </body>
  114. </html>