views:

159

answers:

1

What I'm trying to create is a text editor backed by an XML document. This document will get read into a domain model I then want to allow editing. Some of the traits I'm looking for are:

  • Display only textual content and not require escapes to link text to domain model (want to avoid showing any kind of markup)
  • Types of sections can have varying formatting (font name, font size, etc.)
  • Usual editing abilities (navigation, cut/paste, highlight)
  • Be able to map changes in the editor back to the domain model.

This isn't the complete list, but of the options I've looked at these are the ones that eliminate third party controls.

I've looked at a number of text editors (Aspose.Editor, TX Text Control and some others.) They naturally support the editing abilities and formatting. I have yet to find one that gives you a way to create some kind of link between the text and a custom domain model to migrate the changes back. Being able access their DOM might make that possible, but I haven't seen any controls that support this.

I've looked at writing an editor. This would allow me to maintain a link from on screen text to our domain model. Unfortunately this comes with a big price of writing all the code for laying out the text and handling events for basic navigation and editing. It also feels a lot like reinventing the wheel.

As a starting point I've considered forking from the ShardDevelop editor. However, I'm worried about the potential complications for our commercial application and the LGPL license. Although this currently seems my best option but don't think business side would be ok with all the code being open source. As I understand it being LPGL we could extend the editor for our needs and only make that source available. Unfortunately, having to more explicitly decouple it from our domain model will complicate our efforts.

My question boils down to, does anyone know of any other options to consider?

Update 1: Doing some experimenting with the RichTextEditor in WPF. So far it seems pretty close to what I need. I've got got some prototype code that converts from my DOM to a FlowDocument. It allows me to subclass the content elements and when it splits them even uses my custom type. One downside so far is that it does not copy any of my class members over in my custom type. Currently looking at ways to define one that disallows direct editing.

+1  A: 

I have used Actipro Syntax Editor. It is quite powerful and customisable. You can define your own languages and it comes with quite a few main stream language packs already.

Chris Aitchison
This is one I looked at, however, it didn't really set well with me the idea of creating a language parser from an xml file. If I did that would it then be possible to prevent it from displaying the tags?
Jeremy Wilde