Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[mylyn-integrators] Re: Building a book editor with WikiText

Am 04.12.2009 18:56, schrieb David Green:

> Thanks for the email.  What a great idea!!
> 
> Just FYI, for future if you can please ask these questions on
> mylyn-integrators@xxxxxxxxxxx so that others can benefit too.

Ok, I'll continue the discussion here :)

>> I'm in the process of building a story/novel/book editor based on WikiText.
>> There are a couple of questions and I was wondering whether I could bother
>> you with them.
>>
>> The general design will split the book and all additional infos (like
>> characters, places, external documents, etc) into small wiki pages. The
>> editor can search them, index them, and build the book (either as HTML
>> pages, as a PDF, etc).
>>
>> Right now, I'm toying with ideas how to implement the preview and how to
>> show links to additional information.
>>
>> First, the preview. Unlike WikiText, I'd like to show the preview next to
>> the text editor. If possible, I'd like to show the preview as a single, huge
>> document. To make this happen, I wanted to chop the wiki pages at the block
>> level and do the scrolling by adding/removing blocks in the viewer. For
>> this, I need to keep a couple of document ASTs in memory. This shouldn't be
>> a big deal but I need an API to build the AST. I could roll my own or use
>> the one you already have.
> 
> In practice WikiText is very fast at rendering HTML from wiki markup.  I
> recommend that you have a go without the AST initially, since it may save
> you lots of work.

I guess I could to the chopping the the XHTML level :/

>> Next, I need a way to convert the current cursor position back and forth
>> between the two views. It's easy for editor->preview since I can insert a
>> special SPAN at the current cursor position and then look for it in the AST.
>>
>> Things are a bit harder for the other way around. So far, my only idea is
>> to scroll to the selected block in the editor. But it would be nice to be
>> able to map the cursor position more fine grained. Maybe I'll search for the
>> word under the cursor or something. But to make this work in all cases, I
>> need an extension of the AST: it must save the source code position in the
>> elements.
> 
> You can get the current position when parsing in a DocumentBuilder via
> getLocator()

OK. That would mean I need to extend the HTML builder to insert position
information which shouldn't be too hard. I've found that your builder
are really easy to reuse.

At first, I was a bit afraid that you're like the other Eclipse guys who
try to close every pore of the code (everything is either private,
final, or protected with a
getClass().getName().startsWith("org.eclipse.") ... or all three)

>> Secondly, I need to extend the editor. I plan to implement automatic
>> linking. If you enter a keyword like the name of a character in the text,
>> then the editor should display a link to the description. Moreover, it
>> should show the character name in the outline. The same applies for items,
>> places, events.
> 
> Take a look at new 1.3 APIs, specifically
> org.eclipse.mylyn.wikitext.ui.editor.WikiTextSourceEditor
> If it doesn't meet your needs feel free to post an enhancement request.

Thanks, I will. I hope I can easily create this class in unit tests
(i.e. without having to start OSGi). Nope ... *sigh* I just wished there
was something like StyledText which I could just invoke. Having to deal
with the whole of Eclipse just to add a feature to the editor is
intimidating.

Since the core of Eclipse are the editors, I'd expect that there are
some excellent books or articles which explain in detail how they work
and how you extend them. Any pointers? My last explorations in
StyledText weren't very successful or welcome :(

>> For this, I need a way to extend the existing editor. While I like Eclipse,
>> I hate the startup times. Is there an editor API which I can use without
>> having to pull in the whole of Eclipse? Something that works without the
>> whole infrastructure?
> 
> WikiText makes use of Eclipse platform APIs for its editing framework.  If
> startup times are a problem consider filing a bug against platform.  If you
> wish to use WikiText outside of Eclipse you certainly can -- there are
> stand-alone packages available.  See 14.7 Can I use WikiText without
> Eclipse?<http://wiki.eclipse.org/index.php/Mylyn/FAQ#Can_I_use_WikiText_without_Eclipse.3F>
> for details.

Well, that's only to write command line tools, not UIs.

Regards,

-- 
Aaron "Optimizer" Digulla a.k.a. Philmann Dark
"It's not the universe that's limited, it's our imagination.
Follow me and I'll show you something beyond the limits."
http://blog.pdark.de/


Back to the top