By Bob Potter
Displaying and editing text can be accomplished with several tools in Open Wonderland. These include Sticky Notes, the PDF Viewer and via the Shared Applications server using Open Office or web-based editors such as Google Docs. Each of these, however, comes with significant limitations. Sticky Notes are best used for short pieces of text. The PDF Viewer will show text documents but not permit them to be edited. Open Office editing is limited to documents managed on the application server, and due to the nature of shared applications, does not support cut and paste from the user’s computer. The cut and paste limitation also applies to web-based apps. In addition to the cut and paste limitation, the usability of the web-based editors is not optimal because of the large overhead of editing text in a web browser on the application server. Additionally, given the nature of shared apps, there can be lags in viewing text updates in Open Office or other Xll apps. Finally, shared applications place a significant overhead on the application server, especially when the user is navigating and editing text.
Frequently in our Wonderland community meetings, we have experienced the need for a text editor that can:
- Display a large amount of text,
- Be edited concurrently by multiple users,
- Support cut and paste from the user’s system,
- Import selected file types using drag-and-drop; and
- Export the edited text back to the user’s computer.
The new Collaborative Text Editor module recently uploaded to the Module Warehouse meets these needs for routine text editing.
Once the module has been installed, a text editor can been inserted into the world using the Insert –> Object dialog. To edit text, one or more users can take control of the editor, move the cursor to the desired location, and start typing. The editor is limited to plain text and does not yet support any formatting such as bold and italic. There are two buttons in the lower right of the frame. The “Sync” button can be used to refresh the display with the master copy of the document stored on the server. This function is only required if the text appears to get out of sync when multiple people are typing or editing at the same time. The second button, labelled “Export,” will bring up the Save File dialog, permitting the user to save a copy of the file to their own computer.
The Collaborative Text Editor supports drag and drop of text files. If a user drops in a file with the .txt, .log, .html, .java or .xml extension, the editor will automatically open and display the document. Note that since this is a text editor, it will display the Java, html, or xml source, complete with all the code and markup information. Files dropped into the world can be edited and saved back to the user’s system via the export capability.
This editor is based on the work Jonathan Kaplan (Chief Architect of the Open Wonderland Foundation) had done for the programming demo module called “Sorting Algorithms.” Within that module, Jon had developed a code editor that permitted concurrent editing by users. This current collaborative editor was developed by extracting and enhancing this code to create a generic text editor application.
The module contains both client and server code to manage the concurrent insertion and deletion of text. Since users are actually editing slightly different copies of the same document, both the clients and the server need to adjust the position of each insertion (or deletion) based on the current state of the document in their space. The server’s responsibility is more complex. It is receiving messages from multiple clients, each possibly being a different version from what is in the server’s master copy. The server transforms each of these changes into the most recent version and forwards these on to the clients. The clients have to ensure that any local modifications that have occurred since their last update has been applied are considered when determining the target position of the changes received from the server.
The code for this module is presently hosted on GitHub. (https://github.com/bpotter/textEditor.git) The standard Open Wonderland license applies to this module. This is still a work in progress. I would appreciate your feedback.