Rich_Editor.html 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Rich Editor</title>
  6. </head>
  7. <body>
  8. <style>
  9. #container {
  10. width: 1000px;
  11. margin: 20px auto;
  12. }
  13. .ck-editor__editable[role="textbox"] {
  14. /* Editing area */
  15. min-height: 600px;
  16. }
  17. .ck-content .image {
  18. /* Block images */
  19. max-width: 80%;
  20. margin: 20px auto;
  21. }
  22. /* 居中编辑器标题 */
  23. h2 {
  24. text-align: center;
  25. }
  26. </style>
  27. <h2>Rich Editor</h2>
  28. <div id="container">
  29. <div id="editor"></div>
  30. </div>
  31. <!--
  32. The "superbuild" of CKEditor&nbsp;5 served via CDN contains a large set of plugins and multiple editor types.
  33. See https://ckeditor.com/docs/ckeditor5/latest/installation/getting-started/quick-start.html#running-a-full-featured-editor-from-cdn
  34. -->
  35. <script src="https://cdn.ckeditor.com/ckeditor5/41.1.0/super-build/ckeditor.js"></script>
  36. <script>
  37. ClassicEditor
  38. .create(document.getElementById('editor'))
  39. .then(editor => {
  40. const savedData = localStorage.getItem('editorData');
  41. if (savedData) {
  42. editor.setData(savedData);
  43. }
  44. editor.model.document.on('change:data', () => {
  45. const editorData = editor.getData();
  46. localStorage.setItem('editorData', editorData);
  47. });
  48. })
  49. .catch(error => {
  50. console.error(error);
  51. });
  52. </script>
  53. <!-- Uncomment to load the Spanish translation -->
  54. <!-- <script src="https://cdn.ckeditor.com/ckeditor5/41.1.0/super-build/translations/es.js"></script> -->
  55. <script>
  56. // This sample still does not showcase all CKEditor&nbsp;5 features (!)
  57. // Visit https://ckeditor.com/docs/ckeditor5/latest/features/index.html to browse all the features.
  58. CKEDITOR.ClassicEditor.create(document.getElementById("editor"), {
  59. // https://ckeditor.com/docs/ckeditor5/latest/features/toolbar/toolbar.html#extended-toolbar-configuration-format
  60. toolbar: {
  61. items: [
  62. 'exportPDF','exportWord', '|',
  63. 'findAndReplace', 'selectAll', '|',
  64. 'heading', '|',
  65. 'bold', 'italic', 'strikethrough', 'underline', 'code', 'subscript', 'superscript', 'removeFormat', '|',
  66. 'bulletedList', 'numberedList', 'todoList', '|',
  67. 'outdent', 'indent', '|',
  68. 'undo', 'redo',
  69. '-',
  70. 'fontSize', 'fontFamily', 'fontColor', 'fontBackgroundColor', 'highlight', '|',
  71. 'alignment', '|',
  72. 'link', 'uploadImage', 'blockQuote', 'insertTable', 'mediaEmbed', 'codeBlock', 'htmlEmbed', '|',
  73. 'specialCharacters', 'horizontalLine', 'pageBreak', '|',
  74. 'textPartLanguage', '|',
  75. 'sourceEditing'
  76. ],
  77. shouldNotGroupWhenFull: true
  78. },
  79. // Changing the language of the interface requires loading the language file using the <script> tag.
  80. // language: 'es',
  81. language: {
  82. textPartLanguage: [
  83. { title: 'Arabic', languageCode: 'ar' },
  84. { title: '中文', languageCode: 'zh' },
  85. { title: 'English', languageCode: 'en' },
  86. { title: 'French', languageCode: 'fr' },
  87. { title: 'Hebrew', languageCode: 'he' },
  88. { title: 'español', languageCode: 'es' }
  89. ]
  90. },
  91. list: {
  92. properties: {
  93. styles: true,
  94. startIndex: true,
  95. reversed: true
  96. }
  97. },
  98. // https://ckeditor.com/docs/ckeditor5/latest/features/headings.html#configuration
  99. heading: {
  100. options: [
  101. { model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
  102. { model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' },
  103. { model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' },
  104. { model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3' },
  105. { model: 'heading4', view: 'h4', title: 'Heading 4', class: 'ck-heading_heading4' },
  106. { model: 'heading5', view: 'h5', title: 'Heading 5', class: 'ck-heading_heading5' },
  107. { model: 'heading6', view: 'h6', title: 'Heading 6', class: 'ck-heading_heading6' }
  108. ]
  109. },
  110. // https://ckeditor.com/docs/ckeditor5/latest/features/editor-placeholder.html#using-the-editor-configuration
  111. placeholder: 'Welcome to CKEditor 5!',
  112. // https://ckeditor.com/docs/ckeditor5/latest/features/font.html#configuring-the-font-family-feature
  113. fontFamily: {
  114. options: [
  115. 'default',
  116. 'Ubuntu, Arial, sans-serif',
  117. 'Ubuntu Mono, Courier New, Courier, monospace',
  118. 'Arial, Helvetica, sans-serif',
  119. 'Courier New, Courier, monospace',
  120. 'Georgia, serif',
  121. 'Lucida Sans Unicode, Lucida Grande, sans-serif',
  122. 'Tahoma, Geneva, sans-serif',
  123. 'Times New Roman, Times, serif',
  124. 'Trebuchet MS, Helvetica, sans-serif',
  125. 'Verdana, Geneva, sans-serif'
  126. ],
  127. supportAllValues: true
  128. },
  129. // https://ckeditor.com/docs/ckeditor5/latest/features/font.html#configuring-the-font-size-feature
  130. fontSize: {
  131. options: [ 10, 12, 14, 'default', 18, 20, 22 ],
  132. supportAllValues: true
  133. },
  134. // Be careful with the setting below. It instructs CKEditor to accept ALL HTML markup.
  135. // https://ckeditor.com/docs/ckeditor5/latest/features/general-html-support.html#enabling-all-html-features
  136. htmlSupport: {
  137. allow: [
  138. {
  139. name: /.*/,
  140. attributes: true,
  141. classes: true,
  142. styles: true
  143. }
  144. ]
  145. },
  146. // Be careful with enabling previews
  147. // https://ckeditor.com/docs/ckeditor5/latest/features/html-embed.html#content-previews
  148. htmlEmbed: {
  149. showPreviews: true
  150. },
  151. // https://ckeditor.com/docs/ckeditor5/latest/features/link.html#custom-link-attributes-decorators
  152. link: {
  153. decorators: {
  154. addTargetToExternalLinks: true,
  155. defaultProtocol: 'https://',
  156. toggleDownloadable: {
  157. mode: 'manual',
  158. label: 'Downloadable',
  159. attributes: {
  160. download: 'file'
  161. }
  162. }
  163. }
  164. },
  165. // https://ckeditor.com/docs/ckeditor5/latest/features/mentions.html#configuration
  166. mention: {
  167. feeds: [
  168. {
  169. marker: '@',
  170. feed: [
  171. '@apple', '@bears', '@brownie', '@cake', '@cake', '@candy', '@canes', '@chocolate', '@cookie', '@cotton', '@cream',
  172. '@cupcake', '@danish', '@donut', '@dragée', '@fruitcake', '@gingerbread', '@gummi', '@ice', '@jelly-o',
  173. '@liquorice', '@macaroon', '@marzipan', '@oat', '@pie', '@plum', '@pudding', '@sesame', '@snaps', '@soufflé',
  174. '@sugar', '@sweet', '@topping', '@wafer'
  175. ],
  176. minimumCharacters: 1
  177. }
  178. ]
  179. },
  180. // The "superbuild" contains more premium features that require additional configuration, disable them below.
  181. // Do not turn them on unless you read the documentation and know how to configure them and setup the editor.
  182. removePlugins: [
  183. // These two are commercial, but you can try them out without registering to a trial.
  184. // 'ExportPdf',
  185. // 'ExportWord',
  186. 'AIAssistant',
  187. 'CKBox',
  188. 'CKFinder',
  189. 'EasyImage',
  190. // This sample uses the Base64UploadAdapter to handle image uploads as it requires no configuration.
  191. // https://ckeditor.com/docs/ckeditor5/latest/features/images/image-upload/base64-upload-adapter.html
  192. // Storing images as Base64 is usually a very bad idea.
  193. // Replace it on production website with other solutions:
  194. // https://ckeditor.com/docs/ckeditor5/latest/features/images/image-upload/image-upload.html
  195. // 'Base64UploadAdapter',
  196. 'RealTimeCollaborativeComments',
  197. 'RealTimeCollaborativeTrackChanges',
  198. 'RealTimeCollaborativeRevisionHistory',
  199. 'PresenceList',
  200. 'Comments',
  201. 'TrackChanges',
  202. 'TrackChangesData',
  203. 'RevisionHistory',
  204. 'Pagination',
  205. 'WProofreader',
  206. // Careful, with the Mathtype plugin CKEditor will not load when loading this sample
  207. // from a local file system (file://) - load this site via HTTP server if you enable MathType.
  208. 'MathType',
  209. // The following features are part of the Productivity Pack and require additional license.
  210. 'SlashCommand',
  211. 'Template',
  212. 'DocumentOutline',
  213. 'FormatPainter',
  214. 'TableOfContents',
  215. 'PasteFromOfficeEnhanced',
  216. 'CaseChange'
  217. ]
  218. });
  219. </script>
  220. </body>
  221. </html>