sourcedialog.html 3.6 KB

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