Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom/external formatting toolbar? #67

Open
tconroy opened this issue Jul 11, 2023 · 3 comments
Open

custom/external formatting toolbar? #67

tconroy opened this issue Jul 11, 2023 · 3 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@tconroy
Copy link

tconroy commented Jul 11, 2023

Hello!
Great work on ink-mde!

I'm currently integrating it into a React Native project, which loads ink-mde inside of a webview.

Since this will be used on mobile devices, I'd like to create a custom formatting toolbar as an InputAccessoryView on the keyboard.

This makes me wonder: how can/could I externally control formatting options in ink-mde? Is it currently possible to do that?

@davidmyersdev
Copy link
Owner

Hey @tconroy! Thanks so much. I can always export the toolbar as a separate component, but you might need something a bit more custom in the InputAccessoryView doesn't run in the same JS context as the editor itself. Do you know if that's the case?

@davidmyersdev davidmyersdev added enhancement New feature or request question Further information is requested labels Jul 18, 2023
@tconroy
Copy link
Author

tconroy commented Jul 18, 2023

Hey @davidmyersdev! Yes I believe that is the case.

React native let's you pass messages from the host app to web views via the postMessage API. So I can serialize commands back and forth between the two, as long as they're serializable to strings.

I think what would be most useful for my use case is for the editor to expose callbacks to perform the various editor actions (ie bold, italic, insert list, etc). Then I can just associate each callback to an "event" that my host RN app is sending through postMessage.

I don't mind implementing the UI myself, just need a way to trigger the behaviors 😊

@davidmyersdev
Copy link
Owner

In that case, I think you can already do what you are looking to do. The returned instance has a format method on it that formats the current (or given) selection. Hopefully this demo helps. 😄

https://stackblitz.com/edit/davidmyersdev-ink-mde-uyu9gq?file=src%2Fmain.ts,index.html,tsconfig.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants