Folks,
I’ve started work on a TiddlyWiki native wysiwyg editor. Although I still have a long way to go before I’ll have anything stable enough to unleash on the general public, I thought it might worthwhile to solicit input from the group as a whole. What do you think a wysiwyg editor for Tiddlywiki ought to look like? How should it act? That sort of thing. And I’ve hit a roadblock that may make the entire exercise academic. Perhaps someone in the group has an insight that could help me get around this difficulty.
First though, allow me to describe how I see the project and where I stand. I see this project as a plugin rather than something that displaces a major portion of the program. One result of that is the idea that I will disrupt the normal operation of the program as little as possible. At the moment, my prototype has the ordinary text editor panel on the left and makes the preview panel on the right an editable panel. Like the standard Tiddlywiki, this is a two state arrangement with either the text editor alone or the dual panel arrangement. I see the end product having a three state arrangement; text editor alone, wysiwyg editor alone or side by side.
As I understand how Tiddlywiki works, the text editor modifies the raw wikitext which is rendered into html with each change for display in the preview window by the browser. The displayed version is strictly temporary until the tiddler behind the display is saved. The actual displayed html is not saved. Editing in the preview window like I’m currently doing means I’m editing the displayed html. To make the changes permanent, I have to convert the displayed html into wikitext. I’ve taken to referring to this process as derendering. (I know. It’s an ugly excuse for a word but I’ve grown to like it.)
As the project stands now, I can make most of the standard text editing functions (bold, underline, italics, highlighting, lists and such) work in the preview window and derender them back into wikitext. The routine is glitchy and there are some aspects like images that do not act the way I want them to work.
And now the roadblock. Wikitext is not just the contents but also a set of assembly instructions. A good example, and the heart of my problem, is transclusion. When one tiddler is transcluded into another for the display, its contents are merged into the tiddler being displayed without any indication of its origin. In the displayed html, it is simply more text. When the program derenders that the result is the wikitext for the original tiddler and the transcluded one without any hint of the transclusion and so the transclude command is lost. This sort of thing happens with several of the twiddlywiki features like automatic lists, etc. This effect is unacceptable as it does massive damage to the core concept of Tiddlywiki.
My best idea on how to fix the problem requires Tiddlywiki to handle transclusions slightly differently and as a result requires modifications deeper and more fundamental to the code than I’m comfortable making. Specifically, my idea is to make the html that results from the transclusion look something like this:
Here is some text from the “outside” tiddler
<!—{{transcludedTiddler}} -->
This is the transcluded tiddler inside the other tiddler
<!—end transclusion -->
Here is some more text from the “outside” tiddler
By using comments I don’t introduce any new HTML elements to confuse the system but I do have the information I need to reconstruct the transclusion command correctly in wikitext. To make Tiddlywiki do something like this is beyond my comfort level so I can’t say I’m very happy with this answer.
Does someone have a better idea?