ckeditor5加字数_CKEditor5富文本编辑器如何取值

本文介绍了如何在CKEditor5富文本编辑器中创建编辑器实例,并展示了如何通过JavaScript获取编辑器中的纯文本内容。通过示例代码,展示了利用`innerHTML`和`textContent`属性获取编辑器内的文本,对于需要限制字数的场景非常实用。
摘要由CSDN通过智能技术生成

ClassicEditor

.create( document.querySelector( '#editor' ), {

//工具栏,可选择添加或去除

toolbar: ['headings', 'bold', 'italic', 'blockQuote', 'bulletedList', 'numberedList', 'link', 'cut','undo','redo'],

//toolbar: ['headings', 'bold', 'italic', 'blockQuote', 'bulletedList', 'numberedList', 'link', 'ImageUpload', 'cut','undo','redo'],

//editor加载中文简体,默认是英文

language: 'zh-cn'

//,ckfinder: {

// uploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files&responseType=json'

//}

//image: {

// // You need to configure the image toolbar, too, so it uses the new style buttons.

// toolbar: [ 'imageTextAlternative', '|', 'imageStyle:alignLeft', 'imageStyle:full', 'imageStyle:alignRight' ],

// styles: [

// // This option is equal to a situation where no style is applied.

// 'full',

// // This represents an image aligned to the left.

// 'alignLeft',

// // This represents an image aligned to the right.

// 'alignRight' ,

// 'side'

// ]

//},

} )

.then( editor => {

window.editor = editor;

} )

.catch( err => {

console.error( err.stack );

} );

var a = document.getElementById("editor"); //取得纯文本

alert(a.innerHTML);

alert(a.textContent);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值