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

Export default toggleLink behavior? #485

Closed
joshfrench opened this issue Sep 3, 2016 · 3 comments
Closed

Export default toggleLink behavior? #485

joshfrench opened this issue Sep 3, 2016 · 3 comments

Comments

@joshfrench
Copy link
Contributor

What do you think about exposing the default toggleLink handler for use in editor toolkits? I'm prepping the React editor for release and realizing I'd rather just use the core META+K dialog on the Link button instead of supplying our own form there.

Happy to submit a pull if you're up for it, although I'm not sure where the right place to export it would be. Thoughts on where best to expose it?

@bantic
Copy link
Collaborator

bantic commented Sep 6, 2016

@joshfrench Yeah, that certainly seems fine. +1 to code reuse.
Exporting a top-level "UI" might make sense for this. It would be good use this opportunity to change toggleLink to accept a configurable method for showing the prompt, i.e. pass it a callback-accepting function to use to show the prompt:

function toggleLink(editor, showPrompt=defaultShowPrompt) {
  ...
  let myPromptCallback = (url) => /* ... toggleMarkupWithUrl... */;
  showPrompt(message, defaultValue, myPromptCallback);
}

let defaultShowPrompt = (defaultValue, callback) => callback(window.prompt(message, defaultValue));

Exporting it as Mobiledoc.UI.toggleLink seems ok — what do you think?
If we do this we can also remove Editor#showPrompt as it is not used anywhere else.

@joshfrench
Copy link
Contributor Author

Looks good to me, I'll put together a patch this week. Thanks!

@bantic
Copy link
Collaborator

bantic commented Sep 9, 2016

closed by #491. thanks @joshfrench !

@bantic bantic closed this as completed Sep 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants