<!doctype html>
<html>
<head>
<!--Define the character set for the HTML element -->
<meta charset="utf-8">
<!--Call the external script to use the CDN CKEditor in your page-->
<script src="//cdn.ckeditor.com/4.6.2/standard/ckeditor.js"></script>
<script type="text/javascript">
//Define an init function that sends the rich text editor contents to the page code
function init() {
//onMessage runs when the HTML element receives a message from the page code
window.onmessage = (event) => {
if (event.data == "x") {
CKEDITOR.instances.CK1.setData( '<p></p>' );
console.log(event.data,"ok");
} else {
//postMessage sends the contents of the CKEDITOR back to the page code
window.parent.postMessage(CKEDITOR.instances.CK1.getData(),"*");
console.log(event.data,"okd");
}
}
}
</script>
</head>
<body onload="init();">
<!--Define the HTML element as a textarea-->
<textarea name="editor1" id="CK1"></textarea>
<script>
//Use the CKEditor replace() function to turn our textarea into a CKEditor rich text editor
CKEDITOR.replace("editor1");
</script>
</body>
</html>
它工作得很好,但我有一个行间距问题,看起来段落之间有一条线,但是当它稍后显示时,它在彼此之上。无论如何要减少间距,以便用户意识到他们需要再次按回车吗?
附图像,第一次测试是在文本之后按1键(看起来它之间有一条线但是没有),第二次是2进入。
我的问题还在于我正在使用Wix,因此我无法托管配置或要更改的任何文件。所以这一切都需要来自html链接.....
谢谢!
答案 0 :(得分:1)
您是否需要强制用户按两次Enter键以获取新段落?如果是这样,试试这个:
CKEDITOR.addCss('.cke_editable p { margin: 0 !important; }');
CKEDITOR.replace('editor1');
答案 1 :(得分:0)
这些代码行将删除多余的空间
:host ::ng-deep .ck-editor__editable_inline p {
margin: 0;
}