Node.js(sails.js)所见即所得编辑器-图像
有没有办法在sails应用程序中使用任何WYSIWYG/html编辑器?我 找不到这样做的手册。看起来水星是 在Node中得到了很好的支持,但我找不到一种方法来调整sails 要么(请引导我 现在,连接TinyMCE很容易(就像上面描述的一样容易)。所以现在又出现了另一个主要问题:是否有任何Node.js连接器连接到任何编辑器以上传图像和内容 或者我怎样才能允许用户上传图片并将其插入帖子正文 谢谢耶!终于做到了 最后,我使用了CKEditor,它成功了!请查看:Node.js(sails.js)所见即所得编辑器-图像,node.js,editor,wysiwyg,sails.js,Node.js,Editor,Wysiwyg,Sails.js,有没有办法在sails应用程序中使用任何WYSIWYG/html编辑器?我 找不到这样做的手册。看起来水星是 在Node中得到了很好的支持,但我找不到一种方法来调整sails 要么(请引导我 现在,连接TinyMCE很容易(就像上面描述的一样容易)。所以现在又出现了另一个主要问题:是否有任何Node.js连接器连接到任何编辑器以上传图像和内容 或者我怎样才能允许用户上传图片并将其插入帖子正文 谢谢耶!终于做到了 最后,我使用了CKEditor,它成功了!请查看: 下载编辑器,网址为 将其放入项
- 下载编辑器,网址为
- 将其放入项目的
文件夹中资产
- 将
添加到config.filebrowserUploadUrl='/uploader';
文件中ckeditor/config.js
- 在控制器中添加上载操作:
- 为我制作一个文件夹(
)以供上传assets/files
- 最后,更改将ckeditor放入的表单:
仅此而已!享受所见即所得:)以上答案将有效(我放弃了投票),但如果您在网站上启用了csrf令牌,您需要做一些额外的事情(我会留下评论,但我的代表还不够高): 在使用ckeditor的表单上添加标准csrf隐藏输入:
<input type="hidden" name="_csrf" value="<%= _csrf %>" id="csrf" />
然后需要在上传程序在ckeditor.js的第499行使用的表单上添加隐藏输入
<input type="hidden" name="_csrf" value="' + token + '" id="csrf" />
以下是完整的第499行,仅在上下文中查看:
var csrf = document.getElementsByName("_csrf");var token = csrfitems[0].defaultValue;
d.$.write(['<html dir="'+g+'" lang="'+i+'"><head><title></title></head><body style="margin: 0; overflow: hidden; background: transparent;">','<form enctype="multipart/form-data" method="POST" dir="'+g+'" lang="'+i+'" action="',CKEDITOR.tools.htmlEncode(f.action),
'"><label id="',a.labelId,'" for="',h,'" style="display:none">',
CKEDITOR.tools.htmlEncode(f.label),
'</label>
<input type="hidden" name="_csrf" value="' + token + '" id="csrf" /><input style="width:100%" id="',h,'" aria-labelledby="',a.labelId,'" type="file" name="',CKEDITOR.tools.htmlEncode(f.id||"cke_upload"),
var-csrf=document.getElementsByName(“\u-csrf”);var-token=csrfitems[0]。defaultValue;
d、 $。写入(['',
CKEDITOR.tools.htmlEncode(f.label),
'
非常感谢您提供这篇完整的文章,甚至花时间用您找到的答案回答您自己的问题:-)在Github或a上,您的最新和完整的工作代码在哪里?我和其他人当然希望有这个示例可以下载、使用和扩展。谢谢!当然,这里是:正在进行文件上载。但是如何从服务器浏览图像。它不起作用。
<input type="hidden" name="_csrf" value="<%= _csrf %>" id="csrf" />
var csrf = document.getElementsByName("_csrf");
var token = csrfitems[0].defaultValue;
<input type="hidden" name="_csrf" value="' + token + '" id="csrf" />
var csrf = document.getElementsByName("_csrf");var token = csrfitems[0].defaultValue;
d.$.write(['<html dir="'+g+'" lang="'+i+'"><head><title></title></head><body style="margin: 0; overflow: hidden; background: transparent;">','<form enctype="multipart/form-data" method="POST" dir="'+g+'" lang="'+i+'" action="',CKEDITOR.tools.htmlEncode(f.action),
'"><label id="',a.labelId,'" for="',h,'" style="display:none">',
CKEDITOR.tools.htmlEncode(f.label),
'</label>
<input type="hidden" name="_csrf" value="' + token + '" id="csrf" /><input style="width:100%" id="',h,'" aria-labelledby="',a.labelId,'" type="file" name="',CKEDITOR.tools.htmlEncode(f.id||"cke_upload"),