Insert Text at Cursor Postion in Wijmo Editor

Wijmo Editor provides lot of options for inserting various elements in its editor such as table, image, links etc. but there is no direct method to insert text at current cursor position. However, Wijmo Editor being a jQuery based control, we can easily achieve this by using its client side object model.

In this blog, we will create a custom method which implements the same.

In order to insert any element, the most important thing we need is to access the document object of the control. After retrieving the document object by traversing through the iFrame element of Wijmo Editor, we can insert the text using createRange and execCommand methods.

Here is the complete method which you can directly use in your application:

 function insetTextAtCursor(inputText) {
    //get the container
    var $designView = $("iframe", $(".wijmo-wijeditor-container")),
         win, doc, range;

    if ($designView && $designView.length > 0) {
        //retrieve the Window object generated by the iframe
        win = $designView[0].contentWindow;
     }

    if (win) {
         //access the document object
         doc = win.document;
     }

     if (doc) {
        try {
           //check if the browser is IE
           if ($.browser.msie) {
              //insert the given text
              doc.body.focus();
              range = doc.selection.createRange();
              range.pasteHTML(inputText);
              range.collapse(false);
              range.select();
           } else {
              doc.execCommand('insertText', false, inputText);
           }
        } catch (e) {
     }
   }
 }

You may also check out this sample implementing the same.The output will look like:

Wijmo v2 Beta has Landed


Over the horizon a new version approaches with fierce determination. The next generation of UI reveals itself to a anxiously awaiting world. Wijmo v2 is going to launch like a two-headed, fire-breathing, armor-plated dragon from the depths of Github.

As the shroud of fog parts, a Beta version appears… Behold Wijmo v2

Download Wijmo v2 Beta, explore the new widgets or learn more about v2.

Less Scripts, More Widgets!

We have bundled all of our scripts and dependencies together to make using Wijmo much easier. Wijmo Open now includes BGIframe, Mousewheel, and Globalize libraries. Wijmo Complete now includes Raphael and Cookie libraries. We also merged everything into a single CSS file for both Wijmo Open and Complete. Here is how easy it is to reference Wijmo now:

    <!--jQuery References-->
    <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.6.2.min.js" type="text/javascript"></script>
    <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.16/jquery-ui.min.js" type="text/javascript"></script>

    <!--Theme-->
    <link href="http://cdn.wijmo.com/themes/rocket/jquery-wijmo.css" rel="stylesheet" type="text/css" title="rocket-jqueryui" />

    <!--Wijmo Widgets CSS-->
    <link href="http://cdn.wijmo.com/jquery.wijmo-complete.all.2.0.0b1.min.css" rel="stylesheet" type="text/css" />

    <!--Wijmo Widgets JavaScript-->
    <script src="http://cdn.wijmo.com/jquery.wijmo-open.all.2.0.0b1.min.js" type="text/javascript"></script>
    <script src="http://cdn.wijmo.com/jquery.wijmo-complete.all.2.0.0b1.min.js" type="text/javascript"></script>

And of course we have added some epic new widgets to our arsenal.

New Gauge Widgets


Our new list of widgets includes many new and improved widgets for Data Visualization. We have added the much requested HTML5 Gauges. The Gauges are interactive and built on SVG just like our Charts. Check out the new Gauge Widgets:

New Chart Widgets


Wijmo v2 includes new chart types for creating rich data visualizations. We have even added a Composite Chart for building dashboards using a single widget. Check out the new Chart widgets:

New Editor Widget


The powerful new Editor widget allows even non-technical users to author and manage HTML content on any page. Replace any textarea with this intuitive Microsoft Word-like editor that allows you to edit your HTML content in your preferred style: design, source code, or split view. Check out the new Editor Widget.

New Events Calendar


We have built an entire app into a single widget with the new Events Calendar. It is very similar to the UI found in the iPad Calendar app and has similar features as Google Calendar. It is built work work with localStorage and can also be tied to server-side storage. Check out the new Events Calendar Widget.

New Multimedia Widgets


We’ve also added a new family of graphical widgets. These widgets are focused around modern web development and offer interactive ways of displaying media. Check out the new Multimedia Widgets:

Go Get It!

Download Wijmo v2 Beta, explore the new widgets or learn more about v2. If you have any feedback or questions about please post them in the v2 Beta forum. We have also published some documentation for the widgets to help you get started. The docs will be updated during the Beta process so please be patient if something is missing momentarily.