Skip to content

Commit

Permalink
add ability to delete annotation via annotation card
Browse files Browse the repository at this point in the history
  • Loading branch information
blackforestboi committed May 31, 2024
1 parent f1e9fe7 commit c3b0f53
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion external/@worldbrain/memex-common
22 changes: 22 additions & 0 deletions src/content-scripts/content_script/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,22 @@ export async function main(
}
}

const deleteAnnotation = async (annotationId: string) => {
const annotation = annotationsCache.annotations.byId[annotationId]
const { localId } = annotation

highlightRenderer.removeAnnotationHighlight({
id: annotationId,
})

annotationsCache.removeAnnotation({
unifiedId: annotation.unifiedId,
})
if (localId != null) {
await annotationsBG.deleteAnnotation(localId)
}
}

const pageInfo = new PageInfo(params)

// 1. Create a local object with promises to track each content script
Expand Down Expand Up @@ -913,6 +929,9 @@ export async function main(
instaExecutePrompt: instaExecutePrompt ?? false,
})
},
deleteAnnotation: async (annotationId: string) => {
await deleteAnnotation(annotationId)
},
createYoutubeTimestamp: async (commentText: string) => {
await inPageUI.showSidebar({
action: 'youtube_timestamp',
Expand Down Expand Up @@ -1136,6 +1155,9 @@ export async function main(
fullPageUrl: originalPageURL,
})
},
deleteAnnotation: async (annotationId) => {
await annotationsFunctions.deleteAnnotation(annotationId)
},
annotationsBG,
annotationsCache,
contentSharingBG,
Expand Down
3 changes: 3 additions & 0 deletions src/in-page-ui/tooltip/content_script/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ export const insertTooltip = async (params: TooltipInsertDependencies) => {
createHighlight: async (...args) => {
return await params.createHighlight(...args)
},
deleteAnnotation: async (annotationId: string) => {
return await params.deleteAnnotation(annotationId)
},
askAI: params.askAI,
getKBShortcuts: async () => {
const state = await getKeyboardShortcutsState()
Expand Down

0 comments on commit c3b0f53

Please sign in to comment.