开发者

How do I insert text at the focus into a markitup editor with javascript?

开发者 https://www.devze.com 2022-12-22 12:30 出处:网络
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 ed

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 insertImag开发者_运维知识库e 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 = "!["+alttext+"]("+imageurl+")";
    // how do I insert imageurl into markitup??
}

I need help implementing addImage.


You just need to do this:

function addImage(imageurl,alttext)
{
    var imagetext = "!["+alttext+"]("+imageurl+")";
    $.markItUp({ replaceWith: imagetext });
}
0

精彩评论

暂无评论...
验证码 换一张
取 消