Pass onNavigateNote to RichNoteEditor and handle attachment document links on click
This commit is contained in:
1 parent
069a210bee
commit
781b64ee3b
2 files changed
+16
-5
No files matched your search
@@ -3462,6 +3462,7 @@ export default function EvercloneWorkspace() {
|
|||||||
noteId={activeNote.id}
|
noteId={activeNote.id}
|
||||||
contentHtml={activeNote.contentHtml}
|
contentHtml={activeNote.contentHtml}
|
||||||
readOnly={activeNote.isTrashed || activeNote.canEdit === false}
|
readOnly={activeNote.isTrashed || activeNote.canEdit === false}
|
||||||
|
onNavigateNote={handleNavigateToNote}
|
||||||
onChange={(newHtml) => {
|
onChange={(newHtml) => {
|
||||||
setActiveNote((prev) =>
|
setActiveNote((prev) =>
|
||||||
prev ? { ...prev, contentHtml: newHtml } : prev
|
prev ? { ...prev, contentHtml: newHtml } : prev
|
||||||
|
|||||||
@@ -261,19 +261,29 @@ export default function RichNoteEditor({
|
|||||||
|
|
||||||
// 1. Internal Everclone note link
|
// 1. Internal Everclone note link
|
||||||
const internalId = extractInternalNoteId(href);
|
const internalId = extractInternalNoteId(href);
|
||||||
if (internalId && onNavigateNote) {
|
if (internalId) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
if (onNavigateNote) {
|
||||||
onNavigateNote(internalId);
|
onNavigateNote(internalId);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Legacy Evernote ENEX internal links (evernote:///view/...)
|
// 2. Attachment / Document links (/api/attachments/...)
|
||||||
if (href.startsWith('evernote:///view') && onNavigateNote) {
|
if (href.startsWith('/api/attachments') || href.includes('/api/attachments')) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
window.open(href, '_blank', 'noopener,noreferrer');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Legacy Evernote ENEX internal links (evernote:///view/...)
|
||||||
|
if (href.startsWith('evernote:///view')) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
const title = link.textContent?.trim();
|
const title = link.textContent?.trim();
|
||||||
if (title) {
|
if (title && onNavigateNote) {
|
||||||
fetch(`/api/notes?q=${encodeURIComponent(title)}&limit=1`)
|
fetch(`/api/notes?q=${encodeURIComponent(title)}&limit=1`)
|
||||||
.then((r) => r.json())
|
.then((r) => r.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
@@ -287,7 +297,7 @@ export default function RichNoteEditor({
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Web URL: If Ctrl/Cmd is pressed or readOnly, open in new window
|
// 4. Web URL: If Ctrl/Cmd is pressed or readOnly, open in new window
|
||||||
if (event.ctrlKey || event.metaKey || readOnly) {
|
if (event.ctrlKey || event.metaKey || readOnly) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
window.open(href, '_blank', 'noopener,noreferrer');
|
window.open(href, '_blank', 'noopener,noreferrer');
|
||||||
|
|||||||
Reference in new issue
Block a user