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

Add initial open note-link functionality (#313) #691

Closed

Conversation

Komediruzecki
Copy link
Contributor

@Komediruzecki Komediruzecki commented Nov 18, 2020

Add note-link functionality (#313)

Add copy note link menu option (NoteItem.tsx)
Update db API for creating a note link (createstore, FSNoteDb, PouchNoteDb)
Add codemirror hyperlink addon
Add codemirror hyperlink addon css style (CodeEditor.tsx)
Initialize hyperlink addon (CodeMirror.ts)
Add event handling of editor ctrl+click link with ipc (App.tsx)
Add regexes for note link shortId (MarkdownPreviewer.tsx)
Add handling of rendering and clicking of note link in md preview
Fix invalid logic in prependNoteIdPrefix (should return prefixed noteId when no prefix is found)

Fix electron only API
Fix getWebContentsById to be initialized
Fix hyperlink to use electron only API
Fix macos binding in hyperlink

Copy link option:
CopyNoteLink

Hovering over note link inside editor:
EditorNoteLinkPopup

Hovering on note link in markdown preview:
HoverOnLinkMd

Test:
In electron Linux App (dev)
In electron Linux App production version (appImage)

Improvements:

  • See if we can use similar logic as linkify-remark to get links and then remove our prefixes (:note: etc) instead of directly removing note content for md preview to be able to consider it a link
  • Style the md preview link better
  • Add note link copied message
  • Add status in status bar (when comes) that something is in clipboard
  • Add better export (how to handle?) of links to another note

@Komediruzecki Komediruzecki force-pushed the feature/link-to-another-note branch 3 times, most recently from 8439c97 to 0b40fa5 Compare November 19, 2020 16:39
src/lib/addons/hyperlink.js Outdated Show resolved Hide resolved
@@ -0,0 +1,183 @@
export function initHyperlink(CodeMirror) {
'use strict'
const shell = window.require('electron').shell
Copy link
Member

Choose a reason for hiding this comment

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

Don't use electron directly. It could cause lots of problems. I thought I disabled it but apparently, I didn't do it yet. Please use main-preload.js and lib/electronOnly.ts module to expose electron and native nodejs apis.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh sure, still learning the API.

Updated the needed changes, it seems to work nicely now (also fixed macOS binding, and non-initialized getWebContentsById)

Is there a way to know the ID rather than guessing it's id=1 (since we have one window?)
Should we maybe have getCurrentWindow (or getCurrentWindowWebContents), or set id explicitly to be sure (for further changes)?

Also, should I check if we are in electron when using electorn only API?

@Rokt33r Rokt33r added the awaiting changes 🖊️ Pull request has been reviewed, but contributor needs to make changes. label Nov 21, 2020
@Komediruzecki Komediruzecki self-assigned this Nov 28, 2020
@Komediruzecki Komediruzecki added the awaiting review ❇️ Pull request is awaiting a review. label Dec 1, 2020
@Komediruzecki Komediruzecki force-pushed the feature/link-to-another-note branch 2 times, most recently from dc062f6 to c23e377 Compare December 9, 2020 16:41
@Komediruzecki Komediruzecki removed the awaiting changes 🖊️ Pull request has been reviewed, but contributor needs to make changes. label Dec 10, 2020
@Komediruzecki Komediruzecki force-pushed the feature/link-to-another-note branch 2 times, most recently from 11bfcf3 to ad59f9b Compare December 30, 2020 17:11
Add copy note link menu option (NoteItem.tsx)
Update db API for creating a note link (createstore, FSNoteDb, PouchNoteDb)
Add codemirror hyperlink addon
Add codemirror hyperlink addon css style (CodeEditor.tsx)
Initialize hyperlink addon (CodeMirror.ts)
Add event handling of editor ctrl+click link with ipc (App.tsx)
Add regexes for note link shortId (MarkdownPreviewer.tsx)
Add handling of rendering and clicking of note link in md preview
Fix electron only API
Fix getWebContentsById to be initialized
Fix hyperlink to use electron only API
Fix macos binding in hyperlink
Refactor utility functions and put regexes in constants
Fix note linking when title contains characters that should be escaped
Add note link copied push message
Add push message when note link is successfully copied

Update note link after rebase v0.14.3

Add copy note link in NoteNavigatorItem
Fix issues with event default propagation on context menu
@Komediruzecki
Copy link
Contributor Author

@Rokt33r can cloud internal note linking be used instead of this, is it shared component, can we make it so?

@Komediruzecki
Copy link
Contributor Author

Closing in favor of new local space only repository, it will be rebased and opened there.

bitoffdev added a commit to bitoffdev/BoostNote.next-local that referenced this pull request Feb 26, 2022
Based on BoostIO/BoostNote-App#691

Changes pulled in from original patch:

- Update db API for creating a note link (createstore, FSNoteDb)
- Add codemirror hyperlink addon
- Initialize hyperlink addon (CodeMirror.ts)
- Add event handling of editor ctrl+click link with ipc (App.tsx)
- Add regexes for note link shortId (MarkdownPreviewer.tsx)
- Add handling of rendering and clicking of note link in md preview
- Fix electron only API
- Fix getWebContentsById to be initialized
- Fix hyperlink to use electron only API
- Fix macos binding in hyperlink
- Refactor utility functions and put regexes in constants
- Fix note linking when title contains characters that should be escaped
- Add note link copied push message
- Add push message when note link is successfully copied
- Fix issues with event default propagation on context menu

Differences from original patch:

- Removed PouchNoteDb support
- Migrated to V2 API for context menu in sidebar
- Removed codemirror hyperlink addon css style (CodeEditor.tsx)

Co-authored-by: Elliot Miller <elliot@bitoffdev.com>
Co-authored-by: Komediruzecki <komediruzecki.2015@gmail.com>
Komediruzecki added a commit to BoostIO/BoostNote.next-local that referenced this pull request Feb 27, 2022
Based on BoostIO/BoostNote-App#691

Changes pulled in from original patch:

- Update db API for creating a note link (createstore, FSNoteDb)
- Add codemirror hyperlink addon
- Initialize hyperlink addon (CodeMirror.ts)
- Add event handling of editor ctrl+click link with ipc (App.tsx)
- Add regexes for note link shortId (MarkdownPreviewer.tsx)
- Add handling of rendering and clicking of note link in md preview
- Fix electron only API
- Fix getWebContentsById to be initialized
- Fix hyperlink to use electron only API
- Fix macos binding in hyperlink
- Refactor utility functions and put regexes in constants
- Fix note linking when title contains characters that should be escaped
- Add note link copied push message
- Add push message when note link is successfully copied
- Fix issues with event default propagation on context menu

Differences from original patch:

- Removed PouchNoteDb support
- Migrated to V2 API for context menu in sidebar
- Removed codemirror hyperlink addon css style (CodeEditor.tsx)

Co-authored-by: Elliot Miller <elliot@bitoffdev.com>
Co-authored-by: Komediruzecki <komediruzecki.2015@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review ❇️ Pull request is awaiting a review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants