
- #Wysiwyg web editor for ipad how to
- #Wysiwyg web editor for ipad install
- #Wysiwyg web editor for ipad full
#Wysiwyg web editor for ipad full
See MarkupDelegate.swift for the full protocol and default implementations. The MarkupCoordinator in turn notifies your MarkupDelegate of changes. The MarkupCoordinator is the WKScriptMessageHandler for a single MarkupWKWebView and receives all the JavaScript callbacks in userContentController(_:didReceive:). The callbacks on the Swift side are handled by the MarkupCoordinator. In turn, the JavaScript calls back into Swift to let the Swift side know that changes occurred. It uses a subclass of WKWebView - the MarkupWKWebView - to make calls to the JavaScript in markup.js. Using the MarkupEditorīehind the scenes, the MarkupEditor interacts with an HTML document (created in markup.html) that uses a single contentEditable DIV element to modify the DOM of the document you are editing. Add the amework as a dependency to your project. FrameworkĬlone this repository and build the MarkupFramework target in Xcode. Swift PackageĪdd the MarkupEditor package to your Xcode project using File -> Swift Packages -> Add Package Dependency.
#Wysiwyg web editor for ipad install
You can install the Swift package into your project, or you can build the MarkupEditor framework yourself and make that a dependency. Otherwise, you are using a "What You See Is Not What You Get" editor, which is both less pronounceable and much less useful to your end users. If you're going to do that, then you should make sure that round-tripping back into HTML also works flawlessly. The MarkupEditor will let your MarkupDelegate know as the underlying document changes state, and you can take advantage of those notifications to save and potentially transform the HTML into another form. This is something your application that consumes the MarkupEditor will need to do.
#Wysiwyg web editor for ipad how to
The MarkupEditor does not know how to save your document or transform it to some other format.


It uses JavaScript to change the underlying DOM and calls back into Swift as you interact with the document. The MarkupEditor is presenting an HTML document to you as you edit. It's my intent to keep the core MarkupEditor feature set to be similar to what you will see in GitHub Markdown. The demos include examples of how to extend the MarkupEditor's core features and how to interact with the file system for selecting what to edit. If you want a richer feature set, you can extend the MarkupEditor yourself. Font size changes (except as implied by identifying something as a paragraph or header).The feature list doesn't include some things you might expect from your favorite word processor: And as soon as you do WYSIWYG editing, you must support undo/redo properly. Bold, italic, underline, code, strikethrough, sub- and super-scriptingĪs you might expect, then, this feature set is pretty darned close to Markdown - or at least a GitHub flavor of Markdown.Present a paragraph or header with a predefined font size.I wanted something with the feature-simplicity of Markdown, but presented in a clean, what-you-see-is-what-you-get manner that supported the basics people expect: Still, I wanted an editing experience that didn't get in the way. Having to deal with an editing experience where you use some kind of "preview mode" to make sure that what you are writing will be presented like you expect feels like CI/CD for writing. Who wants to have to mentally filter all that cruft on the screen? Sure, it's a lot better than editing raw HTML but come on, this is the 21st century. I could have forced my developer-users to use Markdown, but I find it to be annoying both to write and to look at while writing.

WYSIWYG editing is a must-have requirement for me. I am working on a larger project that requires embedded support for "rich text" editing. So when I was forced to do it, I thought I'd share what I did as a way to help others avoid it. Jealous of those JavaScript coders with their WYSIWYG text editors, but just can't stomach the idea of immersing yourself in JavaScript when you're enjoying the comfort and joy of Swift? Yeah, me too. WYSIWYG editing for SwiftUI and UIKit apps.
