Https://ckeditor.com/docs/ckeditor5/latest/features/html/html/general-html-support.html
我的CKeditor配置看起来像这样
ClassicEditor.create(
editorEl,
config,
{
plugins: [GeneralHtmlSupport, SourceEditing, Undo, Alignment, Image, ImageResizeEditing, ImageResizeHandles],
htmlSupport: {
allow: [
{
name: /.*/,
attributes: true,
classes: true,
styles: true
}
]
},
image: {
resizeUnit: "%",
styles: {
options: [
{ name: 'Resize', title: 'Resize', className: 'Resize' },
]
},
},
htmlSupport: true,
allowedContent: true
}
).then(editor => {
const textarea = document.querySelector(`#${editorEl.id}`);
editor.model.document.on('change:data', () => {
textarea.value = editor.getData();
});
if (editor.plugins.has('WordCount')) {
const wordCountPlugin = editor.plugins.get('WordCount');
const wordCountWrapper = element.querySelector(`#${script_id}-word-count`);
wordCountWrapper.innerHTML = '';
wordCountWrapper.appendChild(wordCountPlugin.wordCountContainer);
}
editors[editorEl.id] = editor;
if (callbacks[editorEl.id]) {
callbacks[editorEl.id](editor);
}
}).catch(error => {
console.error((error));
});
editorEl.setAttribute('data-processed', '1');
});
window.editors = editors;
did您在ckeditor_5_configs中尝试此尝试
...
"extends": {
...
"extraPlugins": ["GeneralHtmlSupport"],
"sourceEditing": {"allowedStyles": True}, # Allow editing inline styles
"htmlSupport": { # General HTML Support plugin
"allow": [
{
"name": ".*", # Allow all elements
"attributes": True, # Allow all attributes
"classes": True, # Allow all classes
"styles": True, # Allow all inline styles
}
]
},
...
}
...