Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zbeyens committed Oct 23, 2024
1 parent d19d103 commit b5dfdc1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/stale-mails-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@udecode/plate-ai': patch
---

fix accept + undo
12 changes: 10 additions & 2 deletions packages/ai/src/lib/transforms/undoAI.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import type { SlateEditor } from '@udecode/plate-common';
import { type SlateEditor, someNode } from '@udecode/plate-common';

import { AIPlugin } from '../../react';

export const undoAI = (editor: SlateEditor) => {
if ((editor.history.undos.at(-1) as any)?.ai) {
if (
(editor.history.undos.at(-1) as any)?.ai &&
someNode(editor, {
at: [],
match: (n) => !!n[AIPlugin.key],
})
) {
editor.undo();
editor.history.redos.pop();
}
Expand Down

0 comments on commit b5dfdc1

Please sign in to comment.