我在这个插件中做错了什么?
editor.model.schema.register('section', {
allowAttributes: ['class']
});
editor.model.schema.register('a', {
allowAttributes: ['class', 'href', 'target', 'download']
});
editor.model.change(writer => {
const section = writer.createElement('section', {
class: 'button'
});
const link = writer.createElement('a', {
href: 'https://dominio.com/file.pdf',
target: '_blank',
download: 'file.pdf'
});
writer.appendText('DOWNLOAD', link);
writer.insert(link, section);
editor.model.insertContent(section, editor.model.document.selection);
});结果是:
<p>DOWNLAOD</p>但它应该是:
<section class="button"><a href="https://dominio.com/file.pdf" download="file.pdf" targert="_blank">DOWNLOAD</a></section>有没有人知道我在ckeditor 5上创建这个插件的错误之处?
发布于 2021-02-20 20:13:32
我不能像我希望的那样解决它,但我是这样做的:
editor.model.change(writer => {
const link = writer.createText('DOWNLOAD', {
linkHref: 'https://file_link'
});
editor.model.insertContent(link, editor.model.document.selection);
});https://stackoverflow.com/questions/63779897
复制相似问题