CKEditor 5 不重新构建移除某个plugin控件组件

位置:首页>博客>详情   分类:WEB基础   阅读(250)   2023-03-28 11:29:14
CKEditor 5 不重新构建移除某个plugin控件组件


参考代码:
ClassicEditor
                .create( document.querySelector( '#contentHtml' ), {
                    removePlugins:['Title','Style','Code','MediaEmbed','CodeBlocks'],//移除控件
                    licenseKey: '',
                    placeholder: '输入正文',
                    // autosave: {
                    //     waitingTime: 8000, // in ms
                    //     save( editor ) {
                    //         // editor.getData();
                    //         return autoSave();
                    //     }
                    // },
                    ckfinder: {
                        uploadUrl: "/ajax/form/admin/goodsCkUpload?type=Image"//图片上传路径
                    },
                    // code Block
                    codeBlock:{
                        languages: [
                            { language: 'plaintext', label: 'Plain text' }, // The default language.
                            { language: 'c', label: 'C' },
                            { language: 'cs', label: 'C#' },
                            { language: 'cpp', label: 'C++' },
                            { language: 'css', label: 'CSS' },
                            { language: 'diff', label: 'Diff' },
                            { language: 'dockerfile', label: 'Dockerfile' },
                            { language: 'html', label: 'HTML' },
                            { language: 'java', label: 'Java' },
                            { language: 'javascript', label: 'JavaScript' },
                            { language: 'json', label: 'JSON' },
                            { language: 'php', label: 'PHP' },
                            { language: 'python', label: 'Python' },
                            { language: 'ruby', label: 'Ruby' },
                            { language: 'typescript', label: 'TypeScript' },
                            { language: 'xml', label: 'XML' }
                        ],
                    },
                    //heading
                    heading: {
                        options: [
                            { model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
                            { 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' }
                        ]
                    },
                    //link
                    link: {
                        decorators: {
                            addTargetToExternalLinks: {
                                mode: 'automatic',
                                callback: url => /^(https?:)?\/\//.test( url ),
                                attributes: {
                                    rel: 'noopener noreferrer nofollow'
                                }
                            },
                            openInNewTab: {
                                mode: 'manual',
                                label: 'Open in a new tab',
                                attributes: {
                                    target: '_blank',
                                }
                            }
                        }
                    },
                    //font-size
                    fontSize: {
                        options: [
                            12,
                            14,
                            'default',
                            18,
                            25,
                            30
                        ]
                    },
                    //设置字体
                    fontFamily: {
                        options: [
                            'default',
                            'Blackoak Std',
                            '宋体,SimSun',
                            '新宋体,NSimSun',
                            '微软雅黑,Microsoft YaHei',
                            '楷体_GB2312,KaiTi_GB2312',
                            '隶书,LiSu',
                            '幼园,YouYuan',
                            '华文细黑,STXihei',
                        ]
                    },
                } )
                .then( editor => {
                    let html=$('#cocntentScript').html();
                    editor.setData(html);
                    window.editor = editor;
                } )
                .catch( error => {
                    console.error( 'Oops, something went wrong!' );
                    console.error( 'Please, report the following error on https://github.com/ckeditor/ckeditor5/issues with the build id and the error stack trace:' );
                    console.warn( 'Build id: ckeditor5-35.4.0-shnfkcb21gfz' );
                    console.error( error );
                } );

画重点

 removePlugins:['Title','Style','Code','MediaEmbed','CodeBlocks'],//移除控件


 
地址:https://www.leftso.com/article/1137.html