国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sourcedialog.html 4.1KB

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