-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(notetaker): accept decline notetaker ai generation (#3389)
# Description - Ability to accept or decline the ai generated content in the notetaker. - Notetaker Search bar is now visible by default and can be toggled via `Ctrl+F` or the `Ask Brain` Button. - Ability to select content and ask questions with respect to the selection. ## Checklist before requesting a review Please delete options that are not relevant. - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate): ![image](https://github.com/user-attachments/assets/7353f27f-52ed-45f8-95e3-db628f7627c5) ![image](https://github.com/user-attachments/assets/49e6ecf0-a2f8-4614-98ad-e6960d2fc391) --------- Co-authored-by: Antoine Dewez <[email protected]> Co-authored-by: Stan Girard <[email protected]> Co-authored-by: chloedia <[email protected]> Co-authored-by: aminediro <[email protected]> Co-authored-by: Chloé Daems <[email protected]> Co-authored-by: Zewed <[email protected]> Co-authored-by: Stan Girard <[email protected]> Co-authored-by: aminediro <[email protected]> Co-authored-by: porter-deployment-app[bot] <87230664+porter-deployment-app[bot]@users.noreply.github.com> Co-authored-by: Jacopo Chevallard <[email protected]>
- Loading branch information
1 parent
cec7a0d
commit 08b6bcf
Showing
8 changed files
with
215 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
frontend/lib/components/TextEditor/extensions/AIHighlight.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Command } from "@tiptap/core"; | ||
import { Highlight } from "@tiptap/extension-highlight"; | ||
|
||
import { AIHighlightOptions } from "./types"; | ||
|
||
const unsetSelectionsInDocument: Command = ({ dispatch, state }) => { | ||
const { tr } = state; | ||
if (!dispatch) { | ||
return false; | ||
} | ||
|
||
state.doc.descendants((node, pos) => { | ||
if (node.isText) { | ||
node.marks.map((mark) => { | ||
if ( | ||
mark.type.name === AIHighlight.name && | ||
mark.attrs["type"] === "selection" | ||
) { | ||
tr.removeMark(pos, pos + node.nodeSize, mark.type); | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
dispatch(tr); | ||
|
||
return true; | ||
}; | ||
|
||
export const AIHighlight = Highlight.extend<AIHighlightOptions>({ | ||
name: "aiHighlight", | ||
addAttributes() { | ||
return { | ||
...this.parent?.(), | ||
type: "selection", | ||
}; | ||
}, | ||
addCommands() { | ||
return { | ||
...this.parent?.(), | ||
unsetSelectionsInDocument: () => unsetSelectionsInDocument, | ||
setSelectionHighlight: () => { | ||
return ({ commands }) => { | ||
return commands.setHighlight({ type: "selection" }); | ||
}; | ||
}, | ||
setAiHighlight: () => { | ||
return ({ commands }) => { | ||
return commands.setHighlight({ type: "ai" }); | ||
}; | ||
}, | ||
}; | ||
}, | ||
onSelectionUpdate() { | ||
this.editor.commands.unsetSelectionsInDocument(); | ||
}, | ||
}).configure({ | ||
multicolor: true, | ||
type: "selection", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { HighlightOptions } from "@tiptap/extension-highlight"; | ||
|
||
export type AIHighlightType = "ai" | "selection"; | ||
|
||
export type AIHighlightOptions = HighlightOptions & { | ||
type: AIHighlightType; | ||
}; | ||
|
||
declare module "@tiptap/core" { | ||
interface Commands<ReturnType> { | ||
aiHighlight: { | ||
/** | ||
* Highlights selected text to be sent to context of ai | ||
*/ | ||
setSelectionHighlight: () => ReturnType; | ||
/** | ||
* Highlights newly generated text by ai | ||
*/ | ||
setAiHighlight: () => ReturnType; | ||
/** | ||
* Remove highlights in selection | ||
*/ | ||
unsetSelectionsInDocument: () => ReturnType; | ||
/** | ||
* Set a highlight mark | ||
* @param attributes The highlight attributes | ||
* @example editor.commands.setHighlight({ color: 'red' }) | ||
*/ | ||
setHighlight: (attributes?: { | ||
color?: string; | ||
type?: AIHighlightType; | ||
}) => ReturnType; | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters