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