我们在CMS中使用redactor作为编辑器,用户对其中的图像选择/上传功能非常满意。
通常是通过在需要的文本字段上调用redactor方法来激活redactor,这很棒。我想要做的是使用图像拖放上传/选择外部的一个重新压缩的文本字段以及。我想使用它在这个网站上的所有地方,用户正在选择一个图像。
有没有人成功地直接连接到了这个功能?
谢谢,
发布于 2014-01-19 11:02:23
好的,我想这就是你想要做的:
$('image-upload-tag').redactor({
allowedTags: ['img'], // We only want images
buttons: ['image'], // Only display the image button in the toolbar
placeholder: "Drop images here…", // Just to give some user info
focusCallback: function() {
// This stops the caret from being visable, it’s not necessary
// but stops it looking like the user should be able to type.
this.getEditor().css('color', 'transparent');
},
keydownCallback: function(e) {
// Loose focus everytime a key is pressed.
this.getEditor().blur();
}
});基本上,像往常一样设置编写器区域。我对工具栏中允许显示的标记和按钮设置了一些限制。为了不让最终用户感到困惑,我添加了占位符&使闪烁的插入符号变得透明。您可能应该在css中做透明部分,而不是在这里。
keydownCallback是一个实际阻止添加任何文本的函数。这真的很简单;只要按下一个键,就会把焦点从元素上移开。this.getEditor返回可编辑的Redactor区域&因此可以应用blur()。这仍然允许其他操作(按键绑定、图像丢弃等)正常工作。
如果那不是你要找的,请告诉我。
https://stackoverflow.com/questions/20811954
复制相似问题