如何使用 javascript 将焦点处的文本插入到标记编辑器中?
我已经实现了 markitup 来处理用户输入 Markdown 文本。我想用一个漂亮的 jquery 例程替换默认的图像插入命令,让用户浏览图像。我可以编辑 set.js
文件来调用打开文件浏览器的 javascript 例程:
{name: 'Picture', key: 'P', call: 'insertImage'},
我的 insertImage
函数如下所示:
function insertImage()
{
// launch Image Browser
}
当用户选择图像时在图像浏览器中,调用另一个 javascript 函数:
function addImage(imageurl,alttext)
{
var imagetext = "";
// how do I insert imageurl into markitup??
}
我需要帮助实现 addImage
。
I've implemented markitup to handle users entering markdown text. I want to replace the default image insert command with a nice jquery routine that lets the user browse for an image. I'm able to edit the set.js
file to call my javascript routine that brings up the file browser:
{name: 'Picture', key: 'P', call: 'insertImage'},
My insertImage
function looks like this:
function insertImage()
{
// launch Image Browser
}
When the user selects an image in the image browser, another javascript function is called:
function addImage(imageurl,alttext)
{
var imagetext = "";
// how do I insert imageurl into markitup??
}
I need help implementing addImage
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你只需要这样做:
You just need to do this: