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

Internal links: use a Monaco link provider #2376

Merged
merged 12 commits into from
Oct 2, 2020

Conversation

codebykat
Copy link
Member

@codebykat codebykat commented Sep 30, 2020

This PR adds a custom LinkProvider that searches the note for simplenote:// links and linkifies them, then handles the click event by opening the linked note in the editor.

If the note ID does not refer to a note we can open, it will silently fail. I'm not sure what else it can or should do in that case.

Also adds a check to the preview component to skip links that can't be opened (i.e. the noteId isn't in our notes list), as otherwise it closes the selected note in favor of.. nothing.

Screen Shot 2020-09-30 at 12 46 06 AM

@codebykat codebykat requested a review from a team September 30, 2020 08:48
@codebykat codebykat self-assigned this Sep 30, 2020
@codebykat codebykat marked this pull request as ready for review September 30, 2020 09:22
@belcherj
Copy link
Contributor

Could you update the PR description with more detail for posterity? Great work!

@codebykat
Copy link
Member Author

Updated to address comments, and added a check in the preview component so that it also skips any links that can't be opened in the editor (rather than closing the selected note).

@codebykat codebykat requested a review from dmsnell October 1, 2020 00:25
Copy link
Contributor

@belcherj belcherj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, code looks good.

Copy link
Member

@dmsnell dmsnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work on this PR. I left a comment about making the types more convenient for you and feel free to do that and merge without a re-approval; feel free to ignore it since it's just a small convenience thing.

This was a good find allowing us to avoid the complexity of re-implementing the built-in link state machine. It's a straightforward solution.

@codebykat codebykat merged commit e805fd6 into develop Oct 2, 2020
@codebykat codebykat deleted the try/link-provider-for-internal-links branch October 2, 2020 00:59
@codebykat codebykat added this to the 2.0.0 milestone Oct 5, 2020
@souljedi
Copy link

Great work! I've been waiting for something like this for years.

Would it be possible to add anchor points to the link (to jump somewhere within a note)? For example the heading titles from markdown could be used?

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

Successfully merging this pull request may close these issues.

4 participants