Bespin 0.8 ("Cheviot") Release Notes

Up - Next Release - Previous Release

Important Changes

Note that there have been some significant changes to the embedded API between Bespin 0.7 and 0.8. See the "Upgrade Notes" section below.

Known Issues

Bespin 0.8 is alpha software. It is still under active development and APIs are subject to change.

For Bespin Embedded:

For Bespin Server:

Important note: The Bespin Server is going to undergo a complete rework. You can read more about this in the Bespin Server Roadmap that was posted to the mailing list.

Features

Fixes

Upgrade Notes

For Embedded builds, BespinEmbedded.js now refers to the compressed version. BespinEmbedded.uncompressed.js is the uncompressed version. Also noteworthy: the BespinEmbedded.css file is no longer required. Finally, builds now produce three .js files (BespinEmbedded.js, BespinMain.js, BespinWorker.js). You only need to refer to BespinEmbedded.js on your page.

Before Bespin 0.8, the booting code for the 'embedded' and the 'server' versions of Bespin was different. Because of this, a few plugins available to the 'server' version couldn't be used in the 'embedded' case and the API offered in the 'embedded' case was not available in the 'server' version of Bespin. Starting with Bespin 0.8, the 'embedded' and 'server' versions use the same codebase.

This together with a few other modifications and improvements requires that you change the way you create a new Bespin instance. Before, things looked like this:

// Get the embedded plugin.
var embedded = tiki.require("embedded");
// Create a new Bespin instance.
var bespin = embedded.useBespin("edit");
// Change the value.
bespin.value = 'Hello world!';

As with Bespin 0.8:

// Create a new Bespin instance.
// This returns a promise which is resolved when the Bespin is ready.
bespin.useBespin("edit").then(function(env) {
    // Get the editor.
    var editor = env.editor;
    // Change the value.
    editor.value = 'Hello world!';
}, function(error) {
    throw new Error("Launch failed: " + error);
});

Let's take a closer look:

How selected text replacement worked before:

// This holds the Bespin editor;
var editor;
// Make the current selected text upper case.
editor.replaceSelection(editor.getSelectedText().toUpperCase());

With the new Editor API this changed to:

// This holds the Bespin editor;
var editor;
// Make the current selected text upper case.
editor.selectedText = editor.selectedText.toUpperCase();

How to register a size change:

// Tell Bespin that the container size changed.
env.dimensionsChanged();

Example of using the "env" variable from the DOM node:

<div id='edit' class='bespin'>Bespin editor goes here!</div>

<script>
    // This function is called when all Bespin instances on the page were
    // initialized.
    //
    // Make sure you access the Bespin instance *AFTER* the window.onBespinLoad
    // function was called.
    window.onBespinLoad = function() {
        // Get the DOM node with the Bespin instance inside
        var edit = document.getElementById("edit");
        // Get the environment variable.
        var env = edit.bespin;
        // Get the editor.
        var editor = env.editor;
        // Change the value and move to the secound line.
        editor.value = "Initial Content\nWith 2 lines";
        editor.setLineNumber(2);
    };
</script>