You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for raising this. mobiledoc-kit aims to prescribe as little extra-curricular functionality like this as possible, and instead provide a good SDK that allows editor creators to modify it to suit their needs.
In this case, the onTextInput hook could be used to do this auto-formatting. There's an example in the initial PR (here) that describes how this might look:
let urlRegex = /(https?:\/\/[^ ]+) $/; // match a url-like string AND the space after it
editor.onTextInput({
match: urlRegex,
run(editor, matches) {
let url = matches[1];
let range = editor.range;
editor.selectRange(range.move(-1).extend(-1 * url.length)); // select the URL
editor.run(postEditor => {
let link = postEditor.builder.createMarkup('a', {href: url});
postEditor.toggleMarkup(link);
});
editor.selectRange(range); // restore original cursor position
}
});
I'd be happy to take a PR that adds this to the README (perhaps in a FAQ or how-to/cookbook section) so that others can see how it could be done. We're not going to bake this functionality into the editor just yet. In the future I could see it being either a default or a plugin that could be added to mobiledoc-kit, though, for those that expect/need this functionality.
If I hit enter key or spacebar after pasting a plain text URL, I'd expect that it to turn into a hyperlinked URL. Evernote and Word behave like this.
The text was updated successfully, but these errors were encountered: