chore: update managed runtime pins (#3606)
Co-authored-by: kandev-runtime-updater[bot] <kandev-runtime-updater[bot]@users.noreply.github.com> Co-authored-by: Carlos Florencio <carlosmflorencio@gmail.com>
This commit is contained in:
committed by
GitHub
parent
49df3794bc
commit
ae3e359abc
@@ -7,7 +7,7 @@ import {
|
||||
handleEntityReferenceMenuKeyDown,
|
||||
isEntityReferenceQueryAllowed,
|
||||
} from "./tiptap-entity-reference-suggestion";
|
||||
import { createMentionSuggestion } from "./tiptap-suggestion";
|
||||
import { createMentionSuggestion, MentionSuggestionPluginKey } from "./tiptap-suggestion";
|
||||
import * as entityReferenceSuggestions from "./tiptap-entity-reference-suggestion";
|
||||
|
||||
function createSuggestionPositioningProps() {
|
||||
@@ -306,6 +306,29 @@ describe("entity reference suggestion lifecycle", () => {
|
||||
});
|
||||
|
||||
describe("createMentionSuggestion", () => {
|
||||
it("exits TipTap suggestion state when Escape closes the menu", () => {
|
||||
const suggestion = createMentionSuggestion(
|
||||
{ getItems: vi.fn().mockResolvedValue([]), onSelect: vi.fn() },
|
||||
vi.fn(),
|
||||
vi.fn(),
|
||||
);
|
||||
const lifecycle = suggestion.render?.();
|
||||
const transaction = { setMeta: vi.fn(() => ({ id: "exit" })) };
|
||||
const dispatch = vi.fn();
|
||||
|
||||
const handled = lifecycle?.onKeyDown?.({
|
||||
view: { state: { tr: transaction }, dispatch } as never,
|
||||
event: new KeyboardEvent("keydown", { key: "Escape" }),
|
||||
range: { from: 1, to: 2 },
|
||||
});
|
||||
|
||||
expect(handled).toBe(true);
|
||||
expect(transaction.setMeta).toHaveBeenCalledWith(MentionSuggestionPluginKey, {
|
||||
exit: true,
|
||||
});
|
||||
expect(dispatch).toHaveBeenCalledWith({ id: "exit" });
|
||||
});
|
||||
|
||||
it("keeps Kandev task discovery in the @ menu", async () => {
|
||||
const file: MentionItem = {
|
||||
id: "src/app.ts",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { PluginKey } from "@tiptap/pm/state";
|
||||
import { exitSuggestion } from "@tiptap/suggestion";
|
||||
import type {
|
||||
SuggestionOptions,
|
||||
SuggestionProps,
|
||||
@@ -122,6 +123,7 @@ export function createMentionSuggestion(
|
||||
// keypress.
|
||||
kd.event.stopPropagation();
|
||||
setMenuState(EMPTY_MENTION_STATE);
|
||||
exitSuggestion(kd.view, MentionSuggestionPluginKey);
|
||||
return true;
|
||||
}
|
||||
return onKeyDown(kd.event);
|
||||
|
||||
Reference in New Issue
Block a user