-
-
Notifications
You must be signed in to change notification settings - Fork 247
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
Add inline edit dialog #1039
Add inline edit dialog #1039
Conversation
8a738b5
to
d7932bc
Compare
src/components/Chat.tsx
Outdated
if (replace) { | ||
editor.replaceRange(message, cursorFrom, cursorTo); | ||
} else { | ||
editor.replaceRange(message, cursorTo); |
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.
change to cursorTo for insertion so when user selects text before insertion, it will add the text to the end of the selection, which is more intuitive.
name: "Change tone of selection", | ||
}, | ||
}, | ||
enabledCommands: {}, |
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.
Change them to be true by default, so there is no need to list them explicitly. I kept the {enable: boolean} structure, so the current user settings will continue to work.
38620e3
to
a586c4b
Compare
this.registerEvent( | ||
this.app.workspace.on("editor-menu", (menu: Menu, editor: Editor) => { | ||
const selectedText = editor.getSelection().trim(); | ||
if (selectedText) { |
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.
This line keeps context menu clean when no text is selected
@@ -643,3 +533,31 @@ export function findCustomModel(modelKey: string, activeModels: CustomModel[]): | |||
} | |||
return model; | |||
} | |||
|
|||
export async function insertIntoEditor(message: string, replace: boolean = false) { |
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.
This function has no external dependency (can use global app
). I move it to here as a standalone function so all components and modals can use it easily.
a586c4b
to
e32fa6f
Compare
e32fa6f
to
6380d3b
Compare
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.
Awesome stuff!!! I created the ticket to revamp these hardcoded prompts #1043 but not super high priority. Look forward to the user feedback. Let me know if this is ready to merge!
#1038
New Feature: Inline edit dialog/context menu
Enhanced built-in-prompt command with a new dialog view. Previously, commands such as "fix grammar", "summarize selection" will add the result to the chat view. It was not ideal because they are often unrelated to the ongoing chat. This change separates them from the chat experience and allows users to insert into the editor, replace selected text, or copy the text.
In addition, this change surfaces common commands in the context menu. Users can access them easily without finding them from the command list with cmd + p. The context menu item syncs with the command enable settings.
Refactor: Commands
E2E Tests