启动 ckeditor 嵌入插件并传递 url 和所需参数
Fire ckeditor embed plugin and pass url and required parameter
我想在执行某些操作时手动启动 ckeditor 嵌入插件 (https://ckeditor.com/cke4/addon/embed)。例如,来自用户使用输入按钮的 URL,然后将此 URL 传递给嵌入插件,以便它可以将其嵌入到我的 ckeditor 实例中。
我从这个 link CKEditor: call a plugin function without toolbar button 得到一些帮助并使用 CKEDITOR.instances['editable'].execCommand('YOUR_PLUGIN_NAME_HERE');这将打开嵌入对话框,但我需要启动这个插件。所以用户输入 url 将嵌入到我的 ckeditor 中。
我也用editor.fire('YOUR_PLUGIN_NAME_HERE',data)方法,但不知道要传入什么数据。
为什么不直接将适当的小部件 HTML 插入 CKEditor?当您插入 HTML 时,会出现 checkWidgets method which reinitializes widgets gets fired automatically。如果由于某种原因它对您不起作用,您可以手动触发该方法。
您输入的示例代码(取决于您使用的插件)可能如下所示:
var editor = CKEDITOR.instances.editor1;
editor.focus();
// Embed Semantic
// editor.insertHtml('<oembed>https://www.youtube.com/watch?v=Ue6KrclRvY8</oembed>');
// Embed
CKEDITOR.instances.editor1.insertHtml('<div data-oembed-url="https://www.youtube.com/watch?v=lMNRQix_QzQ"><div style="height:0; left:0; padding-bottom:56.2493%; position:relative; width:100%"><iframe allowfullscreen="" scrolling="no" src="https://www.youtube.com/embed/lMNRQix_QzQ?rel=0&showinfo=0" style="border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;" tabindex="-1"></iframe></div>');
// This code should only be fired in cases where inserting HTML doesn't work fire
// checkWidgets method however it should not really happen
/*setTimeout( function(){
editor.widgets.checkWidgets();
} ,0 );*/
我想在执行某些操作时手动启动 ckeditor 嵌入插件 (https://ckeditor.com/cke4/addon/embed)。例如,来自用户使用输入按钮的 URL,然后将此 URL 传递给嵌入插件,以便它可以将其嵌入到我的 ckeditor 实例中。
我从这个 link CKEditor: call a plugin function without toolbar button 得到一些帮助并使用 CKEDITOR.instances['editable'].execCommand('YOUR_PLUGIN_NAME_HERE');这将打开嵌入对话框,但我需要启动这个插件。所以用户输入 url 将嵌入到我的 ckeditor 中。
我也用editor.fire('YOUR_PLUGIN_NAME_HERE',data)方法,但不知道要传入什么数据。
为什么不直接将适当的小部件 HTML 插入 CKEditor?当您插入 HTML 时,会出现 checkWidgets method which reinitializes widgets gets fired automatically。如果由于某种原因它对您不起作用,您可以手动触发该方法。
您输入的示例代码(取决于您使用的插件)可能如下所示:
var editor = CKEDITOR.instances.editor1;
editor.focus();
// Embed Semantic
// editor.insertHtml('<oembed>https://www.youtube.com/watch?v=Ue6KrclRvY8</oembed>');
// Embed
CKEDITOR.instances.editor1.insertHtml('<div data-oembed-url="https://www.youtube.com/watch?v=lMNRQix_QzQ"><div style="height:0; left:0; padding-bottom:56.2493%; position:relative; width:100%"><iframe allowfullscreen="" scrolling="no" src="https://www.youtube.com/embed/lMNRQix_QzQ?rel=0&showinfo=0" style="border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;" tabindex="-1"></iframe></div>');
// This code should only be fired in cases where inserting HTML doesn't work fire
// checkWidgets method however it should not really happen
/*setTimeout( function(){
editor.widgets.checkWidgets();
} ,0 );*/