CKEditor5 完整使用配置参考

教程分享 > WEB技术 > Web Editor (630) 2024-08-07 11:24:34

start

<!DOCTYPE html>
<html lang="en">
   <head>
       <meta charset="UTF-8">
       <title>CKEditor 5 - 完整示例代码</title>
   </head>
   <body>
       <style>
           #container {
               width: 1000px;
               margin: 20px auto;
           }
           .ck-editor__editable[role="textbox"] {
               /* editing area */
               min-height: 200px;
           }
           .ck-content .image {
               /* block images */
               max-width: 80%;
               margin: 20px auto;
           }
       </style>
       <div id="container">
           <div id="editor">
           </div>
       </div>
       <!--
           通过CDN服务的CKEditor 5的“超级构建”包含大量插件和多种编辑器类型。
           更多参考 https://ckeditor.com/docs/ckeditor5/latest/installation/getting-started/quick-start.html#running-a-full-featured-editor-from-cdn
       -->
       <script src="https://cdn.ckeditor.com/ckeditor5/35.3.2/super-build/ckeditor.js"></script>
       <!--
           取消注释以加载西班牙语
           <script src="https://cdn.ckeditor.com/ckeditor5/35.3.2/super-build/translations/es.js"></script>
       -->
       <script>
           // 注意:这个示例仍然没有展示CKEditor 5的所有功能 
           // 参考 https://ckeditor.com/docs/ckeditor5/latest/features/index.html to browse all the features.
           CKEDITOR.ClassicEditor.create(document.getElementById("editor"), {
               // https://ckeditor.com/docs/ckeditor5/latest/features/toolbar/toolbar.html#extended-toolbar-configuration-format
               toolbar: {
                   items: [
                       'exportPDF','exportWord', '|',
                       'findAndReplace', 'selectAll', '|',
                       'heading', '|',
                       'bold', 'italic', 'strikethrough', 'underline', 'code', 'subscript', 'superscript', 'removeFormat', '|',
                       'bulletedList', 'numberedList', 'todoList', '|',
                       'outdent', 'indent', '|',
                       'undo', 'redo',
                       '-',
                       'fontSize', 'fontFamily', 'fontColor', 'fontBackgroundColor', 'highlight', '|',
                       'alignment', '|',
                       'link', 'insertImage', 'blockQuote', 'insertTable', 'mediaEmbed', 'codeBlock', 'htmlEmbed', '|',
                       'specialCharacters', 'horizontalLine', 'pageBreak', '|',
                       'textPartLanguage', '|',
                       'sourceEditing'
                   ],
                   shouldNotGroupWhenFull: true
               },
               // 更改编辑器的语言需要使用<script>脚本加载语言配置文件。
               // language: 'es',
               list: {
                   properties: {
                       styles: true,
                       startIndex: true,
                       reversed: true
                   }
               },
               // https://ckeditor.com/docs/ckeditor5/latest/features/headings.html#configuration
               heading: {
                   options: [
                       { model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
                       { model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' },
                       { model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' },
                       { model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3' },
                       { model: 'heading4', view: 'h4', title: 'Heading 4', class: 'ck-heading_heading4' },
                       { model: 'heading5', view: 'h5', title: 'Heading 5', class: 'ck-heading_heading5' },
                       { model: 'heading6', view: 'h6', title: 'Heading 6', class: 'ck-heading_heading6' }
                   ]
               },
               // https://ckeditor.com/docs/ckeditor5/latest/features/editor-placeholder.html#using-the-editor-configuration
               placeholder: 'Welcome to CKEditor 5!',
               // https://ckeditor.com/docs/ckeditor5/latest/features/font.html#configuring-the-font-family-feature
               fontFamily: {
                   options: [
                       'default',
                       'Arial, Helvetica, sans-serif',
                       'Courier New, Courier, monospace',
                       'Georgia, serif',
                       'Lucida Sans Unicode, Lucida Grande, sans-serif',
                       'Tahoma, Geneva, sans-serif',
                       'Times New Roman, Times, serif',
                       'Trebuchet MS, Helvetica, sans-serif',
                       'Verdana, Geneva, sans-serif'
                   ],
                   supportAllValues: true
               },
               // https://ckeditor.com/docs/ckeditor5/latest/features/font.html#configuring-the-font-size-feature
               fontSize: {
                   options: [ 10, 12, 14, 'default', 18, 20, 22 ],
                   supportAllValues: true
               },
               // 注意下面的设置。它表示CKEditor接受所有HTML标记。
               // https://ckeditor.com/docs/ckeditor5/latest/features/general-html-support.html#enabling-all-html-features
               htmlSupport: {
                   allow: [
                       {
                           name: /.*/,
                           attributes: true,
                           classes: true,
                           styles: true
                       }
                   ]
               },
               // 启用预览时要注意
               // https://ckeditor.com/docs/ckeditor5/latest/features/html-embed.html#content-previews
               htmlEmbed: {
                   showPreviews: true
               },
               // https://ckeditor.com/docs/ckeditor5/latest/features/link.html#custom-link-attributes-decorators
               link: {
                   decorators: {
                       addTargetToExternalLinks: true,
                       defaultProtocol: 'https://',
                       toggleDownloadable: {
                           mode: 'manual',
                           label: 'Downloadable',
                           attributes: {
                               download: 'file'
                           }
                       }
                   }
               },
               // https://ckeditor.com/docs/ckeditor5/latest/features/mentions.html#configuration
               mention: {
                   feeds: [
                       {
                           marker: '@',
                           feed: [
                               '@apple', '@bears', '@brownie', '@cake', '@cake', '@candy', '@canes', '@chocolate', '@cookie', '@cotton', '@cream',
                               '@cupcake', '@danish', '@donut', '@dragée', '@fruitcake', '@gingerbread', '@gummi', '@ice', '@jelly-o',
                               '@liquorice', '@macaroon', '@marzipan', '@oat', '@pie', '@plum', '@pudding', '@sesame', '@snaps', '@soufflé',
                               '@sugar', '@sweet', '@topping', '@wafer'
                           ],
                           minimumCharacters: 1
                       }
                   ]
               },
               // The "super-build" contains more premium features that require additional configuration, disable them below.
               // Do not turn them on unless you read the documentation and know how to configure them and setup the editor.
               removePlugins: [
                   // These two are commercial, but you can try them out without registering to a trial.
                   // 'ExportPdf',
                   // 'ExportWord',
                   'CKBox',
                   'CKFinder',
                   'EasyImage',
                   // 这个示例使用Base64UploadAdapter来处理图像上传,因为它不需要配置。
                   // https://ckeditor.com/docs/ckeditor5/latest/features/images/image-upload/base64-upload-adapter.html
                   // 将图像存储为Base64通常是一个非常糟糕的办法并不推荐。
                   // 在生产环境上替换为其他解决方案:
                   // 参考:https://ckeditor.com/docs/ckeditor5/latest/features/images/image-upload/image-upload.html
                   // 'Base64UploadAdapter',
                   'RealTimeCollaborativeComments',
                   'RealTimeCollaborativeTrackChanges',
                   'RealTimeCollaborativeRevisionHistory',
                   'PresenceList',
                   'Comments',
                   'TrackChanges',
                   'TrackChangesData',
                   'RevisionHistory',
                   'Pagination',
                   'WProofreader',
                   //注意,使用Mathtype插件时,CKEditor将不会从本地文件系统(file://)加载此示例-如果启用Mathtype,则通过HTTP服务器加载此站点
                   'MathType'
               ]
           });
       </script>
   </body>
</html>

 

over

 

https://www.leftso.com/article/240725144312246.html

相关文章
1.引入依赖js文件&lt;script type="text/javascript" src="/plugin/ckeditor5/ckeditor.js"&gtl;&lt;/s
ckeditor5使用demo,配置详情参考。官网相关资源查阅,组件配置
ckeditor5 图片上传地址配置,ckeditor5和4的图片上传配置有点不一样。首先是确定你选的上传支持插件是什么,我这里是下面这个插件ckfinder
在CKEditor4版本中,对于编辑器高度设置是通过config配置里面的属性height来实现的,如下方所示CKEditor5 版本查文档发现已经没有这个配置了,通过网络资料查询得知,CKEd...
CKeditor无论那个版本,在我主要以文章编辑的时候,需要去掉默认的H1标签,所以需要自定义配置heading标签。同样CKeditor5 与之前的4版本有所不同。CKeditor5自定义配置...
在ckeditor4的时候绑定blur事件代码如下:window.editor.on('blur',function(){//这里写你想做的事儿})同样的代码搬到ckeditor5不仅不能用,还...
针对CKEditor5是否开源免费,我们阅读官方响应文档得到下面的结果:所有下载均受相关开源许可协议或商业许可协议(以适用者为准)的约束。 再查阅更详细的文档,
ckeditor 5 自定义插件实现,自定义一个插件并在toolbar上。点击自定义插件图标响应对应事件。环境ckeditor 5.42.1(github稳定版
CKeditor5代码片段是官方自己集成的。可以通过在线构建的时候选择Code blocks 组件。选择后默认支持一下代码语言,是通过pre标签+code标签实现的。[ { langu...
CKeditor 5.0 如何获取纯文本数据,ckeditor官方其实提供了获取带html脚本的内容方法,只需要配合jQuery简单就获取到了文本内容,详细操作如下
CKEditor 5 不重新构建移除某个plugin控件组件参考代码:ClassicEditor .create( document.querySelector...
CKeditor5 默认情况下的fontsize组件是小号默认大号特大号这种,没有具体的字体大小px单位选择,有些时候需要配置。故而对默认配置进行了修改。配置方式如下: C...
ckeditor绑定keyup/keydown等事件实现一些功能,比如实时保存$(function(){//1编辑器初始化$('textarea#blog_content').ckeditor();
ckeditor4的早期版本,图片上传组件。默认情况会有以下图片预览描述文字,如下图所示:上图红色圈出部分即为图片预览的描述。这个放到应用中会感觉很奇怪。所以多
CKEditor4.4整合SprngMVC实现上传图片