如何将上传实用程序添加到wmd编辑器?
有人成功做到这一点吗?
Has anyone succeeded to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
有人成功做到这一点吗?
Has anyone succeeded to do this?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
我通过用我自己的 jquery.dialog 方法替换 Util.prompt 来完成此操作。提示函数将参数作为回调,从而可以轻松创建直接替换。
如果您有兴趣,我写了一篇 博客有关它的条目(带图片!),其中有更多示例代码以及我在实现此过程中遇到的一些问题/解决方案。
I accomplished this by replacing Util.prompt with my own jquery.dialog method. The prompt function takes a parameter as a callback, making it easy to create a drop-in replacement.
If you're interested, I wrote a blog entry about it (with pictures!) which has some more sample code as well as some of the problems/solutions I encountered in implementing this.
以下黑客需要使用 jQuery, jQuery UI 和 Mike Alsup 的 jQuery 表单插件,用于执行 AJAX 文件上传。该黑客适用于链接版本(jQ 1.7.2 和 jQUI 1.8.20)。我不能保证与其他版本的兼容性。
在您的
中,您需要包含依赖项:
我们实际上需要对
wmd.js
进行一次更改。继续在那里搜索 (ctrl+f)
var form = doc.createElement("form");
紧接着这一行,为表单分配一个 id,dialogform 即可:
form.id = "dialogform";
现在在前端运行:
记住,这篇文章是为 jQuery 1.7.2 编写的,
live()
已被弃用。如果您使用的是更新版本的 jQuery,请切换到on()
在后端的
submit_image.php
中:希望这能让您满意开始了。这是几年前写的,当时我的 JavaScript 技能还很差!哈哈。我之前在博客上有过这个(现在已经死了),其中有分步说明和解释;很多不必要的绒毛。感谢 @Kamiccolo 让我注意到此链接。我必须咨询返回机器才能恢复它。
The following hack requires use of jQuery, jQuery UI and Mike Alsup's jQuery Form Plugin for performing AJAX file uploads. The hack works with the linked versions (jQ 1.7.2 and jQUI 1.8.20). I can't guarantee compatibility with other versions.
In your
<head>
, you'll need to include the dependencies:We actually need to make a single change to
wmd.js
.Go on in there and search (ctrl+f) for
var form = doc.createElement("form");
Immediately following this line, assign the form an id, dialogform will do:
form.id = "dialogform";
Now on the front end, run:
Remember, the post was written for jQuery 1.7.2, and
live()
has since been deprecated. Please switch toon()
if you're using a more recent version of jQueryAnd on the backend, in
submit_image.php
:Hopefully that will get you started. This was written a couple of years ago, when my javascript skills were sub-par! Haha. I previously had this on a blog (which is now dead), with step-by-step instructions and explanations; lots of unnecessary fluff. Thanks @Kamiccolo for bringing this link to my attention. I had to consult the way-back-machine in order to revive it.
在WMD的控制面板上添加一个按钮。
搜索以下字符串以查找添加按钮的位置:
italicButton.XShift
在我的版本中,该函数位于类SpritedButtonRow中,称为build 。
忽略 setup 和 textOp 属性。 XShift 是 WMD 自带的 css sprite 中按钮图像的位置,取而代之的是给按钮一个类,并在类中指定背景图像。然后只需向按钮添加一个onclick事件
这将做你需要它做的事情。
但是,我认为上传按钮不应该位于文本编辑器内,没有意义。
Add a button to the control panel of WMD.
Search for the following string to find the place where buttons are being added:
italicButton.XShift
In my version, the function is in class SpritedButtonRow and is called build.
Ignore the setup and textOp attributes. XShift is the position of the button image in the css sprite that comes with WMD, Instead of that, give the button a class and in the class specify the background image. Then Just add an onclick event to the button
that will do what you need it to do.
But, I don't think an upload button should be inside a text editor, does not make sense.