From 83e9cd02d82fda8b4eed08322ecc3210bc800e0a Mon Sep 17 00:00:00 2001 From: josc146 Date: Thu, 16 Mar 2023 20:31:10 +0800 Subject: [PATCH] feat: code explain for selection tools --- src/content-script/selection-tools/index.mjs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/content-script/selection-tools/index.mjs b/src/content-script/selection-tools/index.mjs index 9dc900b..835cd06 100644 --- a/src/content-script/selection-tools/index.mjs +++ b/src/content-script/selection-tools/index.mjs @@ -5,6 +5,7 @@ import { Palette, QuestionCircle, Translate, + Braces, } from 'react-bootstrap-icons' import { getPreferredLanguage } from '../../config.mjs' @@ -49,6 +50,14 @@ export const config = { genPrompt: async (selection) => `Divide the following into paragraphs that are easy to read and understand:\n"${selection}"`, }, + code: { + icon: , + label: 'Code Explain', + genPrompt: async (selection) => { + const preferredLanguage = await getPreferredLanguage() + return `Reply in ${preferredLanguage}.Explain the following code:\n"${selection}"` + }, + }, ask: { icon: , label: 'Ask',