3545d00d46
Replaces most editing components with CM components, enabling vim mode and completions everywhere Fixes #205 Fixes #221 Fixes #222 Fixes #223
26 lines
622 B
TypeScript
26 lines
622 B
TypeScript
import emojis from "./emoji.json" assert { type: "json" };
|
|
import type { CompleteEvent } from "../../plug-api/app_event.ts";
|
|
|
|
export function emojiCompleter({ linePrefix, pos }: CompleteEvent) {
|
|
const match = /:([\w]+)$/.exec(linePrefix);
|
|
if (!match) {
|
|
return null;
|
|
}
|
|
|
|
const [fullMatch, emojiName] = match;
|
|
|
|
const filteredEmoji = emojis.filter(([_, shortcode]) =>
|
|
shortcode.includes(emojiName)
|
|
);
|
|
|
|
return {
|
|
from: pos - fullMatch.length,
|
|
filter: false,
|
|
options: filteredEmoji.map(([emoji, shortcode]) => ({
|
|
detail: shortcode,
|
|
label: emoji,
|
|
type: "emoji",
|
|
})),
|
|
};
|
|
}
|