import { Autocomplete, openAutocomplete, } from "../../../behavior/Autocomplete/index.js";
import { EmojiHandler } from "./EmojiHandler.js";
import { DecoClassName } from "./const.js";
const emojiSuggestActionName = 'openEmojiSuggest';
export const EmojiSuggest = (builder, { defs, shortcuts }) => {
    if (!defs)
        return;
    if (!builder.context.has('autocomplete')) {
        builder.use(Autocomplete);
    }
    const item = {
        trigger: {
            name: 'emoji',
            trigger: /(?:^|\s)(:)$/,
            allArrowKeys: false,
            cancelOnFirstSpace: true,
            decorationAttrs: { class: DecoClassName },
        },
        handler: new EmojiHandler({ defs, shortcuts }),
    };
    builder.context.get('autocomplete').add(item);
    builder.addAction(emojiSuggestActionName, () => {
        return {
            isEnable: (state) => {
                return state.selection.empty;
            },
            run: (_s, _d, view, attrs) => {
                return openAutocomplete(view, ':', attrs?.text);
            },
        };
    });
};
//# sourceMappingURL=EmojiSuggest.js.map
