-
Notifications
You must be signed in to change notification settings - Fork 0
add interop between extensions #20
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
base: main
Are you sure you want to change the base?
Changes from all commits
63151b4
4940cdf
2b54de9
b5e574d
8536f83
ef23560
d1e76d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,5 @@ dist/ | |
| .DS_Store | ||
|
|
||
| extension/dist | ||
|
|
||
| .tmp/ | ||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
|
|
||
| {} (:calcit-version |0.10.4) | ||
| :dependencies $ {} (|Respo/alerts.calcit |0.10.2) | ||
| {} (:calcit-version |0.10.9) | ||
| :dependencies $ {} (|Respo/alerts.calcit |0.10.4) | ||
| |Respo/reel.calcit |main | ||
| |Respo/respo-markdown.calcit |0.4.11 | ||
| |Respo/respo-ui.calcit |0.6.3 | ||
| |Respo/respo.calcit |0.16.22 | ||
| |Respo/respo.calcit |0.16.24 | ||
| |calcit-lang/lilac |main | ||
| |calcit-lang/memof |main | ||
| |calcit-lang/memof |0.0.17 | ||
| |Respo/respo-feather.calcit |main |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,26 +6,73 @@ chrome.runtime.onInstalled.addListener(() => { | |||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| chrome.runtime.onInstalled.addListener(async () => { | ||||||||||||||||||||||||||||||||||||||||||
| chrome.contextMenus.create({ | ||||||||||||||||||||||||||||||||||||||||||
| id: "msg-gemeni-selection", | ||||||||||||||||||||||||||||||||||||||||||
| id: "msg-gemini-root", | ||||||||||||||||||||||||||||||||||||||||||
| title: "Msg Gemini", | ||||||||||||||||||||||||||||||||||||||||||
| type: "normal", | ||||||||||||||||||||||||||||||||||||||||||
| contexts: ["selection"], | ||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||
| chrome.contextMenus.create({ | ||||||||||||||||||||||||||||||||||||||||||
| id: "msg-gemini-summary", | ||||||||||||||||||||||||||||||||||||||||||
| title: "Summary", | ||||||||||||||||||||||||||||||||||||||||||
| type: "normal", | ||||||||||||||||||||||||||||||||||||||||||
| contexts: ["selection"], | ||||||||||||||||||||||||||||||||||||||||||
| parentId: "msg-gemini-root", | ||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||
| chrome.contextMenus.create({ | ||||||||||||||||||||||||||||||||||||||||||
| id: "msg-gemini-translate", | ||||||||||||||||||||||||||||||||||||||||||
| title: "Translate", | ||||||||||||||||||||||||||||||||||||||||||
| type: "normal", | ||||||||||||||||||||||||||||||||||||||||||
| contexts: ["selection"], | ||||||||||||||||||||||||||||||||||||||||||
| parentId: "msg-gemini-root", | ||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||
| chrome.contextMenus.create({ | ||||||||||||||||||||||||||||||||||||||||||
| id: "msg-gemini-custom", | ||||||||||||||||||||||||||||||||||||||||||
| title: "Custom...", | ||||||||||||||||||||||||||||||||||||||||||
| type: "normal", | ||||||||||||||||||||||||||||||||||||||||||
| contexts: ["selection"], | ||||||||||||||||||||||||||||||||||||||||||
| parentId: "msg-gemini-root", | ||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| chrome.contextMenus.onClicked.addListener((item, tab) => { | ||||||||||||||||||||||||||||||||||||||||||
| let content = item.selectionText; | ||||||||||||||||||||||||||||||||||||||||||
| chrome.runtime.sendMessage({ action: "menu-trigger", content }); | ||||||||||||||||||||||||||||||||||||||||||
| if (item.menuItemId === "msg-gemini-translate") { | ||||||||||||||||||||||||||||||||||||||||||
| chrome.runtime.sendMessage({ action: "menu-translate", content }); | ||||||||||||||||||||||||||||||||||||||||||
| } else if (item.menuItemId === "msg-gemini-custom") { | ||||||||||||||||||||||||||||||||||||||||||
| chrome.runtime.sendMessage({ action: "menu-custom", content }); | ||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||
| chrome.runtime.sendMessage({ action: "menu-summary", content }); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| chrome.sidePanel.open({ tabId: tab.id }, () => { | ||||||||||||||||||||||||||||||||||||||||||
| // also try to open | ||||||||||||||||||||||||||||||||||||||||||
| if (!sidepanelOpen) { | ||||||||||||||||||||||||||||||||||||||||||
| setTimeout(() => { | ||||||||||||||||||||||||||||||||||||||||||
| chrome.runtime.sendMessage({ action: "menu-trigger", content }); | ||||||||||||||||||||||||||||||||||||||||||
| if (item.menuItemId === "msg-gemini-translate") { | ||||||||||||||||||||||||||||||||||||||||||
| chrome.runtime.sendMessage({ action: "menu-translate", content }); | ||||||||||||||||||||||||||||||||||||||||||
| } else if (item.menuItemId === "msg-gemini-custom") { | ||||||||||||||||||||||||||||||||||||||||||
| chrome.runtime.sendMessage({ action: "menu-custom", content }); | ||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||
| chrome.runtime.sendMessage({ action: "menu-summary", content }); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| }, 1000); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||
tiye marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { | ||||||||||||||||||||||||||||||||||||||||||
| if (message && message.action === "fill-text") { | ||||||||||||||||||||||||||||||||||||||||||
| chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { | ||||||||||||||||||||||||||||||||||||||||||
| const tab = tabs && tabs[0]; | ||||||||||||||||||||||||||||||||||||||||||
| if (tab && tab.id != null) { | ||||||||||||||||||||||||||||||||||||||||||
| chrome.tabs.sendMessage(tab.id, { | ||||||||||||||||||||||||||||||||||||||||||
| action: "fill-text", | ||||||||||||||||||||||||||||||||||||||||||
| text: message.text || "", | ||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+67
to
+70
|
||||||||||||||||||||||||||||||||||||||||||
| chrome.tabs.sendMessage(tab.id, { | |
| action: "fill-text", | |
| text: message.text || "", | |
| }); | |
| chrome.tabs.sendMessage( | |
| tab.id, | |
| { | |
| action: "fill-text", | |
| text: message.text || "", | |
| }, | |
| (response) => { | |
| if (chrome.runtime.lastError) { | |
| console.error( | |
| "Failed to send 'fill-text' message to tab", | |
| tab.id, | |
| chrome.runtime.lastError.message | |
| ); | |
| } | |
| } | |
| ); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing return statement after handling the 'fill-text' action. While JavaScript will implicitly return undefined, this is inconsistent with the explicit return statement at line 9 for the 'selected' action. For consistency and clarity, add an explicit return statement after calling insertTextAtCursor.