diff --git a/.gitignore b/.gitignore index 61880e3..0c7b40f 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,6 @@ logs .env .env.* !.env.example -config \ No newline at end of file +config + +public/emojis \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index cb7bb48..a0666e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,7 @@ FROM base AS builder COPY . /app COPY --from=install /temp/dev/node_modules /app/node_modules +RUN cd /app && bun run emojis:generate RUN cd /app && bun run build --preset node-server FROM oven/bun:1.1.34-alpine AS final diff --git a/README.md b/README.md index 908437a..f800c96 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,10 @@ services: Then, the frontend will be available at `http://localhost:3000` inside the container. To link it to a Versia Server, set the `NUXT_PUBLIC_API_HOST` environment variable to the server's URL. +## Development + +Make sure to run `bun run emojis:generate` to generate the emoji list before building or running the project. + ## License This project is licensed under the AGPL 3.0 - see the [LICENSE](LICENSE) file for details. diff --git a/bun.lockb b/bun.lockb index 30ba19a..00c7cd9 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/settings/types/Code.vue b/components/settings/types/Code.vue index 2631119..f3868f3 100644 --- a/components/settings/types/Code.vue +++ b/components/settings/types/Code.vue @@ -6,6 +6,7 @@ +

{{ setting.description }}

diff --git a/components/settings/types/Enum.vue b/components/settings/types/Enum.vue index 38be709..7126ff4 100644 --- a/components/settings/types/Enum.vue +++ b/components/settings/types/Enum.vue @@ -9,9 +9,10 @@ -

Not +

Not implemented

+

{{ setting.description }}

- + {{ page }} diff --git a/composables/ParsedContent.ts b/composables/ParsedContent.ts index 88d5d24..233879d 100644 --- a/composables/ParsedContent.ts +++ b/composables/ParsedContent.ts @@ -3,6 +3,10 @@ import { renderToString } from "vue/server-renderer"; import { SettingIds, type Settings } from "~/settings"; import MentionComponent from "../components/social-elements/notes/mention.vue"; +const emojisRegex = + /\p{RI}\p{RI}|\p{Emoji}(\p{EMod}|\uFE0F\u20E3?|[\u{E0020}-\u{E007E}]+\u{E007F})?(\u200D(\p{RI}\p{RI}|\p{Emoji}(\p{EMod}|\uFE0F\u20E3?|[\u{E0020}-\u{E007E}]+\u{E007F})?))*/gu; +const incorrectEmojisRegex = /^[#*0-9©®]$/; + /** * Takes in an HTML string, parses emojis and returns a reactive object with the parsed content. * @param content String of HTML content to parse @@ -29,6 +33,7 @@ export const useParsedContent = ( const shouldRenderEmoji = toValue(settings)?.[SettingIds.CustomEmojis].value; + const emojiFont = toValue(settings)?.[SettingIds.EmojiTheme].value; // Replace emoji shortcodes with images if (shouldRenderEmoji) { @@ -52,6 +57,19 @@ export const useParsedContent = ( ); } + if (emojiFont !== "native") { + contentHtml.innerHTML = contentHtml.innerHTML.replace( + emojisRegex, + (match) => { + if (incorrectEmojisRegex.test(match)) { + return match; + } + + return `${match}`; + }, + ); + } + // Replace links containing mentions with interactive mentions const links = contentHtml.querySelectorAll("a"); diff --git a/nuxt.config.ts b/nuxt.config.ts index 5bdbaa4..a8a74cd 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -247,6 +247,13 @@ export default defineNuxtConfig({ brotli: false, gzip: false, }, + routeRules: { + "/emojis/**": { + headers: { + "Cache-Control": "public, max-age=31536000, immutable", + }, + }, + }, }, schemaOrg: { enabled: false, diff --git a/package.json b/package.json index 350215b..7e08290 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "build": "nuxt build", "dev": "NODE_TLS_REJECT_UNAUTHORIZED=0 bun --bun nuxt dev --https --https.cert config/versia-fe.localhost.pem --https.key config/versia-fe.localhost-key.pem --host versia-fe.localhost", "generate": "nuxt generate", - "preview": "nuxt preview", + "emojis:generate": "bun run utils/emojis.ts", "postinstall": "nuxt prepare", "lint": "bunx @biomejs/biome check .", "check": "bunx tsc -p ." @@ -64,7 +64,12 @@ "@types/html-to-text": "^9.0.4", "@vue-email/nuxt": "^0.8.19", "typescript": "^5.6.3", - "vue-tsc": "^2.1.10" + "vue-tsc": "^2.1.10", + "@iconify-json/fluent-emoji": "^1.2.1", + "@iconify-json/fluent-emoji-flat": "^1.2.1", + "@iconify-json/noto": "^1.2.1", + "@iconify-json/twemoji": "^1.2.1", + "@iconify/utils": "^2.1.33" }, "trustedDependencies": [ "@biomejs/biome", diff --git a/pages/settings/index.vue b/pages/settings/index.vue index 3ba6ae8..b7b2ab5 100644 --- a/pages/settings/index.vue +++ b/pages/settings/index.vue @@ -10,11 +10,11 @@ SettingPages.Appearance, )) as SettingIds[])" :key="id" /> -