ck 编辑器 - 服务器预览?
我将如何让 ckeditor 的预览按钮将内容发送到服务器,以便在单击预览时可以在自定义页面中显示它?
How would I go about getting ckeditor's preview button to send the content to the server so I can show it in a custom page when preview is clicked?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们正在做类似的事情,只不过我们在加载编辑器的页面上有一个预览链接。该方法可用于编辑器中的按钮,但它需要额外的编码(我将在底部概述该方法)。
预览链接看起来像这样:
我们有 doPreview 函数:
}
最后,有一个带有隐藏字段的表单 (hiddenForm):
因此,单击该链接并调用 doPreview 函数。
该函数从 CKEditor 中获取内容并将其分配给隐藏表单中的隐藏字段。
然后该函数提交隐藏表单。
隐藏的表单已发布,预览模板已在新窗口中加载。
预览模板的内容区域由 $_POST['preview_content'](来自编辑器的内容数据)填充。
您可以修改以包含需要发布的任何变量。
要通过单击 CKEditor 中的按钮来执行此操作:
您可以创建一个自定义插件。这里有一个教程部分,其中包含创建插件的简单说明:
http://docs.cksource.com/CKEditor_3.x/Tutorials
该插件可以工作再次在主页上使用隐藏表单,您需要从插件函数中调用父窗口。
或者,您可以在插件中使用 JavaScript 编写表单并从那里提交。
注意:您可以使用此设置禁用默认预览功能:
Be Well,
乔
We're doing something like this except that we have a preview link on the page that loads the editor. The approach could be used for a button within the editor, but it requires additional coding (I'll outline that approach at the bottom).
The preview link looks something like this:
We have the doPreview function:
}
Finally, there's a form with hidden fields (hiddenForm):
So, the link is clicked and the doPreview function is called.
The function grabs the content from CKEditor and assigns it to a hidden field in the hidden form.
Then the function submits the hidden form.
The hidden form is posted and the preview template is loaded in a new window.
The content area of the preview template is populated with $_POST['preview_content'] (the content data from the editor).
You can modify to contain any variables you need to post.
To do this by clicking a button within CKEditor:
You could create a custom plugin. There's a tutorial section with easy instructions for creating a plugin here:
http://docs.cksource.com/CKEditor_3.x/Tutorials
The plugin could work with a hidden form on the main page again, you'll need to call the parent window from your plugin function.
Or, you could compose the form with JavaScript within your plugin and submit it from there.
Note: You can disable the default preview functionality using this setting:
Be Well,
Joe
您可以在这里准备一个插件: http://alfonsoml .blogspot.com/2011/08/serverpreview-plugin-for-ckeditor.html
您只需配置要用于预览的页面,它将替换默认的预览按钮。其他选项在随附的文档中进行了解释。
You can get a plugin ready to work here: http://alfonsoml.blogspot.com/2011/08/serverpreview-plugin-for-ckeditor.html
You just have to configure the page that you want to use for the preview and it will replace the default Preview button. Additional options are explained in the included documentation.