Cross-Platform Writer Progress

Earlier this year, I mentioned I was doing a rewrite/port of my custom writing software in order to support it on Linux. If you haven’t read about that, I recommend doing that first.

Anyway, my Avalonia UI port is going very well, and it’s now mostly usable on both Windows and Linux Mint. Its source is available on GitHub at https://github.com/TjMott/TjMott.Writer/tree/avalonia.

You may recall I wasn’t sure what to do about my document format and rich text editor. Previously, it was based on Microsoft’s FlowDocument, and nothing outside of .NET on Windows supported that. My choices were to wait for the Avalonia team to come around to supporting FlowDocument, or migrate to another document format, one that was not limited to Windows.

So I migrated to another document format. For the rich text editor, I selected Quill, which is a browser-based JavaScript editor. To me, this was a very weird choice, especially since my application is not web-based and I generally hate web-based software. So I needed to embed a web browser. I used the Chromium Embedded Framework (CEF) along with an Avalonia-compatible .NET binding for it called CefNet, and as weird as this is, it works well and its cross-platform. It’s also pretty seamless. You’d have no idea you’re interacting with a web browser!

Quill uses its own document format called Delta, which is really just JSON. JSON is text-based so it stores just as well as the old XML-based FlowDocument in my editor’s SQLite save file. I have a barebones custom converter that converts FlowDocument to Delta. Right now it handles about 95% of my data, and I’ll fix the remaining when I find it. If there are other users of this software, there’s a good chance the importer will miss stuff when you run it, because you are probably using document features I’m not using (lists, certain types of formatting, etc.) I’ll handle these as I become aware of them, but it’s a good idea to keep a backup of your old WPF-based works database so that data is not lost.

I am a big advocate of digital privacy. This new version of the app will NOT load Quill or its resources from the Internet. They will be loaded from offline HTML/JS files packaged with the application. I also cut out as much tracking/telemetry as possible from CEF. Originally, the embedded web browser submitted all kinds of stuff to Google which was ridiculous for a private offline application. I think I got 99.9% of all that shut off or blocked. There may be a couple minor cases left but I haven’t run into them yet. Ultimately, this means the app does not require an Internet connection and nothing within my app is scanning/tracking your data or providing it to outsiders.

No Official Mac Support, Sorry!

I mentioned before that this app would run on Mac once I finish porting to the new toolkit. Unfortunately, now that I’ve done most of the work this will not quite be true. The problem is cost/resources. It is free to develop for Windows and Linux, but Apple expects you to have Apple hardware (which I don’t have), a paid Apple developer account (which I don’t have), and a code-signing certificate (which I don’t have, because they are quite expensive and difficult to get as an individual and not a company).

That said, my codebase should be very, very close to working on Mac. I just can’t test it or officially support/release it. It’s very likely the branch will work if you were to compile it yourself and make a few tweaks to the CefNet startup code. I somewhat dislike the open source mentality of “It’s open source, so just fix the code yourself!” but I have to take that position on this issue. But I will gladly accept pull requests if someone wants to finish Mac support and figure out how to properly distribute it.

You Can Now Print!

I never even considered printing support in the old WPF-based app. But using CefNet, I almost got printing for free. I just call a Print() function on the embedded webview, and the built-in browser prints for me! All I had to do was write up some print CSS for the Quill editor page to clean it up a bit.

Combining Document Formats

The old WPF-based version had two document formats: FlowDocument which was used for manuscript text, and MarkdownDocument which was used for notes and tickets. I was never quite comfortable with that, but FlowDocument was missing features I found useful for notes, and Markdown was very inadequate for a rich text document.

The new Avalonia-based version, however, only uses one document format based on Quill delta. This simplifies things, and avoids mental context-switching when a different document has a totally different UI and set of features. Now, it’s all the same!

Losing Some Features

I am trimming the fat, so to speak, as part of this port. A couple features I never really used are going away.

File Browser

The old File Browser feature allowed you to embed entire files within the works database. I intended this to store cover art, completed manuscripts, and so on, so it’s all packaged up in the works database and you only have to backup/store one file to have everything. However, I never used this feature for anything except storing one Word template file, so I simply canned this feature. So when you update, make sure to pull any important files out of the File Browser first, because they will be nuked as part of the database upgrade.

Ticket Tracker

As a software engineer, my concept of ticket tracking is heavily influenced by Redmine/Trac/Jira/Bugzilla/etc, and my ticket tracker reflected that. But it was actually way too heavyweight, and so I am removing it. All tickets and ticket history will be lost as part of the database upgrade to the new version.

What’s Left?

I have a ton of small tweaks and fixes to work on, but it’s mostly usable at this point. (Export to Word is very much still a work in progress.) I have not created a release yet, but that should happen in the upcoming weeks. In the meantime, the avalonia branch is buildable and usable to anyone who wants to build it in Visual Studio. Check it out here: https://github.com/TjMott/TjMott.Writer/tree/avalonia

Well, that’s all I have for now. Thanks for reading!

Leave a Reply

Your email address will not be published. Required fields are marked *