gpt4 book ai didi

javascript - Cckeditor 从数据库加载模板

转载 作者:行者123 更新时间:2023-11-29 23:27:19 24 4
gpt4 key购买 nike

我想让用户能够设置自己的模板以在编辑器中使用,但问题是我并不完全知道如何操作。

我为模板创建了表,并使用 php 函数从数据库检索数据,但无法在门户中显示它。

我在其他问题中看到了这个:

CKEDITOR.editorConfig = function (config) {
config.templates_files = ['js/editor/plugins/templates/templates/custom.js'];
};

CKEDITOR.replace( 'editor1', {
templates: 'my',
on: {
instanceReady: function( argument ) {
var httpRequest = new XMLHttpRequest();

httpRequest.onreadystatechange = function() {
CKEDITOR.addTemplates( 'my', {
templates: [
{
title: 'My Templates',
html: this.responseText
}
]
});
};
httpRequest.open( 'GET', 'in/ver.php?cons=8' );
httpRequest.send();
}
}
});

但它似乎没有任何作用,而且我找不到任何有关它的文档

最佳答案

最后我通过覆盖模板按钮的操作解决了:

CKEDITOR.on('instanceReady', function (ev) {


var editor = ev.editor;

var cargaPlantilla = new CKEDITOR.command(editor, {
exec: function(editor){
$( '#modal' ).fadeIn();
$.post("in/ver.php?cons=8",{algo: "algo"},function(exito){
$("#modal").html(exito);
});
$( '#modal-background' ).fadeTo( 500, .5 );
}
});
ev.editor.commands.templates.exec = cargaPlantilla.exec;
});
CKEDITOR.replace('editor1');

关于javascript - Cckeditor 从数据库加载模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26854333/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com