Skip to content

Commit

Permalink
fix image pasting
Browse files Browse the repository at this point in the history
  • Loading branch information
sestinj committed Aug 8, 2024
1 parent df9ccba commit 5d5d4eb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions gui/src/components/mainInput/TipTapEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ function TipTapEditor(props: TipTapEditorProps) {
);

const defaultModel = useSelector(defaultModelSelector);
const defaultModelRef = useUpdatingRef(defaultModel);

const getSubmenuContextItemsRef = useUpdatingRef(getSubmenuContextItems);
const availableContextProvidersRef = useUpdatingRef(
Expand Down Expand Up @@ -267,16 +268,16 @@ function TipTapEditor(props: TipTapEditorProps) {
props: {
handleDOMEvents: {
paste(view, event) {
console.log("Pasting image");
const model = defaultModelRef.current;
const items = event.clipboardData.items;
for (const item of items) {
const file = item.getAsFile();
file &&
modelSupportsImages(
defaultModel.provider,
defaultModel.model,
defaultModel.title,
defaultModel.capabilities,
model.provider,
model.model,
model.title,
model.capabilities,
) &&
handleImageFile(file).then((resp) => {
if (!resp) return;
Expand Down

0 comments on commit 5d5d4eb

Please sign in to comment.