current position:Home>Configuration and use of rich text editor ckeditor4 in Vue
Configuration and use of rich text editor ckeditor4 in Vue
2022-04-29 04:29:59【Guo_ 10_ Jun】
Catalog
add to / Delete editor function
One . Download and install
First time to do rich text editor , After two days of information and reference Official documents Finally complete the required function with the help of colleagues , Here are some ways to use .
Our needs are like this : The required editor functions are shown in the figure below , Need to add Fonts , Set the default font size , It's also the place that bothers me most !
Through the survey data ,vue Project use ckeditor4 There are two ways , One is to go to the official website to download ckeditor4 My bag , Decompress and put it in
In the project , Then according to their own needs , By modifying the editor's configuration file config.js File to add / Delete function , The other is to use packaged ckeditor4-vue package , I downloaded and installed by command :
npm install --save ckeditor4-vue
<ckeditor
ref="editor"
:config="editorConfig"
v-model="editorData"
@blur="onBlur"
@input="onTextChange">
</ckeditor>
export default {
name: 'CkEditor4',
components: {
ckeditor: CKEditor.component
},
data () {
return {
editorData: '',
editorConfig: {},
such , A basic editor is built
Then it mainly explains how to add font size , And set the default font size !
Not a professional front end , Some places don't understand , But if you don't write it like this, it won't work
data () {
return {
editorConfig: {
toolbar: [
{ name: 'clipboard', items: [ 'Undo', 'Redo' ] },
{ name: 'links', items: [ 'Link', 'Unlink' ] },
{ name: 'align', items: ['JustifyLeft', 'JustifyCenter', 'JustifyRight'] },
{ name: 'basicstyles', items: [ 'Bold', 'Italic', 'Underline' ] },
{ name: 'styles', items: ['Font', 'FontSize'] }, // Format typeface size
{ name: 'colors', items: ['TextColor', 'BGColor'] }, '/' ],
font_names: 'メイリオ;ヒラギノ horn ゴPro W3;Hiragino Kaku Gothic Pro;MS Pゴシック;MS P The Ming dynasty ;MS ゴシック;MS The Ming dynasty ;' +
'Arial/Arial,Helvetica,sans-serif;' +
'Comic Sans MS/Comic Sans MS,cursive;' +
'Courier New/Courier New,Courier,monospace;' +
'Georgia/Georgia,serif;' +
'Lucida Sans Unicode/Lucida Sans Unicode,Lucida Grande,sans-serif;' +
'Tahoma/Tahoma,Geneva,sans-serif;' +
'Times New Roman/Times New Roman,Times,serif;' +
'Trebuchet MS/Trebuchet MS,Helvetica,sans-serif;' +
'Verdana/Verdana,Geneva,sans-serif',
// fontSize_sizes: '8/8px;9/9px;10/10px;11/11px;12/12px;14/14px;16/16px;18/18px;20/20px;22/22px;24/24px;26/26px;28/28px;36/36px;48/48px;72/72px',
font_defaultLabel: 'メイリオ',
fontSize_defaultLabel: '16',
contentsCss: './contents.css',
extraPlugins: 'justify,font,colorbutton',
resize_enabled: false
},
add to / Delete editor function , And setting fonts and adding Fonts , They all need to be modified config, Above .
add to / Delete editor function
Add and modify editor functions in toolbar[ ] Set in , And add to extraPlugins: 'justify,font,colorbutton......', This should be a registered plug-in , Anyway, if you don't add it, you can't add functions , Refer to the first picture
Add font size
Refer to official documentation , The added font needs to be written in font_names, Pay attention to is , Once customized , Will overwrite all the original Fonts , You need to define all fonts according to your needs , Use... Between entries " ; " Separate , Each entry can have multiple Fonts , With " , " Separate , And write the name of the font to be displayed in " / " front .
for example :'Arial/Arial, Helvetica, sans-serif', Only... Will be displayed in the font list
'Arial'
, But the output font is 'Arial, Helvetica, sans-serif'.
Adding font size is the same , Refer to official documentation , I don't need to add font size for my needs , So note
Set the default font size
Or refer to the official documents , At first I thought it was to set up these two ,
Found after setting , Just the default display , No effect , Need to introduce contents.css Document and modify , This file can be downloaded from the official website ckeditor package , After decompression, it is under the root directory , take contents.css Put it in the project , and contentsCss: './contents.css' introduce , Then modify the following piece :
.cke_editable
{
font-size: 16px;
font-family: メイリオ;
line-height: 1.6;
/* Fix for missing scrollbars with RTL texts. (#10488) */
word-wrap: break-word;
}
At this point, the function is almost complete , Another part is inconvenient to show .
Not a professional front end , There are many details I don't quite understand , If there is a mistake , Please correct me. !!!
copyright notice
author[Guo_ 10_ Jun],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/117/202204270550501656.html
The sidebar is recommended
- vue2. How to register and login with 0 + koa2 + mongodb
- How to set the background color for individual pages in Vue cli
- Vue2 how to load more data on the scroll bar
- How to use margin and padding in CSS
- How does vue2x implement the vueslidershow function of the responsive adaptive rotation component plug-in
- How does vue2 recursive component implement tree menu
- How to use the three selectors of CSS
- Same blog, different styles -- hexo alternative construction
- Optimize nginx HTTPS latency - see how I can speed up nginx by 30%?
- The development model in the era of consumer Internet only transfers industrial elements from offline to online
guess what you like
Advanced features of Vue
CSS shadow advanced, to achieve a more three-dimensional shadow effect!
Introduction to the number type method in JavaScript
Differences between nginx forward and reverse proxy
Front end schema form configuration generation scheme
Units that can be used by the rotate method of transform in CSS
Why CSS3 sticky doesn't work?
[bug resolution] webpack error: module not found Did you mean xxx
[bug resolution] can't perform a react state update on an unmounted component This is > a no-op, but it...
Remember to speed up the construction of a webpack
Random recommended
- Browser review hover element
- Vue insert iframe
- Vue realizes downloading pictures
- Some common problem-solving methods in Vue (sort out some truly effective methods that can be used in the project) (wait for continuous update and accumulation)
- About database data response to HTML page, Chinese appears? Solution to garbled code (multiple question marks)
- Ask a question about CSS selector
- When Vue jumps the route, the timer cannot be cleared in time
- Document is not defined
- Vuepress packaging deployment stepping on the road of the pit
- Vue quill editor stepping on pit record -- the echo style of rich text content is wrong
- The multi selection box of table in element is combined with paging to echo the bug step hole
- Vue project optimizes the loading speed of the first screen
- Use / deep / to report an error CSS (CSS selected expected)
- Nginx configuration
- Vue cli reverse proxy
- Vuex persistedstate plug-in - vuex persistent storage
- Automatic import of less
- Understanding and summary of CSS
- vue2. Implementation of X data response
- JavaScript content understanding
- Props in react
- JavaScript stack“
- Bootstrap blazor table component (III) intelligent generation
- Based on centos7 + nginx + Daphne + uwsgi + django3 2 + supervisor + mysql8 single architecture server production environment deployment (I)
- Differences between vue2 and vue3 named slots
- Vue3: Axios cross domain request problem
- The difference between vue2 and vue3: keep alive
- Configure nginx and SSL certificate for Django project under Windows Environment
- Ant Design Vue: a-table custom column
- Using jQuery in Vue
- Vue dynamic loading picture problem
- Icons using Alibaba vector icon library in Vue
- Java Android mobile phone automatic basic learning element positioning
- Rancher configuring HTTPS domain name to access graphic tutorial
- Building a blog with GitHub pages + hexo (7) how to delete a published article successfully solved: delete it at the same time deploy_ Git folder
- Eight blog views / hexubs
- Build a blog with GitHub pages + hexo (9) set the next theme of hexo blog, and only part of the home page is displayed (not the full text)
- Building a blog with GitHub pages + hexo (10) the next theme of hexo blog mathjax mathematical formula rendering problem
- Hexo/Github. IO configure Tencent cloud CDN
- Details of Vue to react useeffect