standardnotes / iOS-classic

iOS client - (Deprecated) - New version: https://github.com/standardnotes/mobile
167 stars 21 forks source link

Markdown support #22

Closed moughxyz closed 7 years ago

moughxyz commented 7 years ago

Tap on title bar to toggle Markdown view?

Markdown view would ideally be a local webview, using some library to convert from Markdown to HTML.

jz709u commented 7 years ago

so I have the markdown view working and it toggles but should we add a feature which we save when a note has been toggled to markdown view so that when you navigate to a note it will default to whatever mode it was in before.
for instance if you go to a note you want to see it in markdown mode first instead of having to toggle everytime you choose that note.

I'm thinking of saving that in the UserDefaults? what do you think Mobitar?

moughxyz commented 7 years ago

Hey @jz709u, pull request looks awesome. I'm actually reconsidering how we would do Markdown in Standard Notes. Before, when I created this issue, Markdown was to be natively supported by all SN clients. However, since then, we have introduced the concept of Editors, which are custom HTML/JS that can be loaded into the app from a URL.

See here: https://standardnotes.org/extensions/simple-markdown

After this change, I removed native Markdown support from the web app.

Now I'm deciding how to go about Markdown in mobile apps. There are two options:

  1. Add Editor support to iOS apps using UIWebView.
  2. Keep mobile apps as "light" clients that do not do too much. This way we keep it simple and avoid complexity.

What are your thoughts on option 1?

jz709u commented 7 years ago

I like the idea of keeping things light but how many of your subscribers would want a markdown view supported natively? I think keeping things light is your niche I think it's common though once you start supporting a feature and people like it people will want it on all clients.

on option 1 do you mean use the extension loaded into the uiwebview within the app? or do it how I implemented it?

moughxyz commented 7 years ago

Well, editor extensions are made using JS/HTML and the postMessage API that web browsers support. Is it possible for a UIWebView to receive postMessage events? If so, we might be able to allow editors on iOS.

jz709u commented 7 years ago

with the WKWebView I think we can but let me try it.

I just loaded the url into the webview "https://extensions.standardnotes.org/editors/simple_markdown?name=Simple%20Markdown"

jz709u commented 7 years ago

can you explain to me what the flow is that you want? so load extensionurl and then what? call javascript code to set the text?

moughxyz commented 7 years ago

Yes we would need to use the postMessage API: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage

postMessage API allows one window to send messages to another window with Javascript.

If this can work in iOS, so that iOS can receive messages from Javascript, or may check ever 0.1s for content updates, then editors can work.