Fixes #394 and upgrade to emoji 15.1, optimizes size
parent
bdb4159f5b
commit
db607f1661
|
@ -1,4 +1,4 @@
|
||||||
build:
|
build:
|
||||||
curl https://unicode.org/Public/emoji/14.0/emoji-test.txt > emoji-data.txt
|
curl https://unicode.org/Public/emoji/15.1/emoji-test.txt > emoji-data.txt
|
||||||
node build.js
|
deno run -A build.ts
|
||||||
rm emoji-data.txt
|
rm emoji-data.txt
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
// Generates emoji.json from emoji-data.txt
|
|
||||||
const { readFileSync, writeFileSync } = require("fs");
|
|
||||||
|
|
||||||
const emojiRe = /#\s([^\s]+)\s+E[^\s]+\s+(.+)$/;
|
|
||||||
|
|
||||||
let text = readFileSync("emoji-data.txt", "utf-8");
|
|
||||||
const lines = text.split("\n").filter((line) => !line.startsWith("#"));
|
|
||||||
|
|
||||||
let emoji = [];
|
|
||||||
for (const line of lines) {
|
|
||||||
let match = emojiRe.exec(line);
|
|
||||||
if (match) {
|
|
||||||
emoji.push([match[1], match[2].toLowerCase().replaceAll(/\W+/g, "_")]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
writeFileSync("emoji.json", JSON.stringify(emoji));
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
// Generates emoji.json from emoji-data.txt
|
||||||
|
const emojiRe = /#\s([^\s]+)\s+E[^\s]+\s+(.+)$/;
|
||||||
|
|
||||||
|
let text = Deno.readTextFileSync("emoji-data.txt");
|
||||||
|
const lines = text.split("\n").filter((line) => !line.startsWith("#"));
|
||||||
|
|
||||||
|
const emojis: string[] = [];
|
||||||
|
for (const line of lines) {
|
||||||
|
let match = emojiRe.exec(line);
|
||||||
|
if (match) {
|
||||||
|
const emoji = match[1];
|
||||||
|
const name = match[2].toLowerCase().replaceAll(/\W+/g, "_");
|
||||||
|
emojis.push(`${name} ${emoji}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Deno.writeFileSync(
|
||||||
|
"emoji.json",
|
||||||
|
new TextEncoder().encode(JSON.stringify(emojis.join("|"))),
|
||||||
|
);
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,8 @@
|
||||||
import emojis from "./emoji.json" assert { type: "json" };
|
import emojiBlob from "./emoji.json" assert { type: "json" };
|
||||||
import type { CompleteEvent } from "$sb/app_event.ts";
|
import type { CompleteEvent } from "$sb/app_event.ts";
|
||||||
|
|
||||||
|
const emojis = emojiBlob.split("|").map((line) => line.split(" "));
|
||||||
|
|
||||||
export function emojiCompleter({ linePrefix, pos }: CompleteEvent) {
|
export function emojiCompleter({ linePrefix, pos }: CompleteEvent) {
|
||||||
const match = /:([\w]+)$/.exec(linePrefix);
|
const match = /:([\w]+)$/.exec(linePrefix);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
|
@ -9,14 +11,14 @@ export function emojiCompleter({ linePrefix, pos }: CompleteEvent) {
|
||||||
|
|
||||||
const [fullMatch, emojiName] = match;
|
const [fullMatch, emojiName] = match;
|
||||||
|
|
||||||
const filteredEmoji = emojis.filter(([_, shortcode]) =>
|
const filteredEmoji = emojis.filter(([shortcode]) =>
|
||||||
shortcode.includes(emojiName)
|
shortcode.includes(emojiName)
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
from: pos - fullMatch.length,
|
from: pos - fullMatch.length,
|
||||||
filter: false,
|
filter: false,
|
||||||
options: filteredEmoji.map(([emoji, shortcode]) => ({
|
options: filteredEmoji.map(([shortcode, emoji]) => ({
|
||||||
detail: shortcode,
|
detail: shortcode,
|
||||||
label: emoji,
|
label: emoji,
|
||||||
type: "emoji",
|
type: "emoji",
|
||||||
|
|
Loading…
Reference in New Issue