Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(ckeditor5): gather editor messages from source instead of a list
Elian Doran4fcc5f1439b6
diff --git a/apps/client/src/services/i18n.spec.ts b/apps/client/src/services/i18n.spec.tsindex 2d498fe90e..ca7a4d628a 100644--- a/apps/client/src/services/i18n.spec.ts+++ b/apps/client/src/services/i18n.spec.ts@@ -1,5 +1,7 @@+import { MESSAGE_KEY_PREFIX, slugify } from "@triliumnext/ckeditor5";+import { ADMONITION_TYPES } from "@triliumnext/ckeditor5/src/plugins/admonition/admonition_ui.js";import { dayjs, findDuplicateJsonKeys, findPluralKeyConflicts, LOCALES } from "@triliumnext/commons";-import { readFileSync } from "fs";+import { readdirSync, readFileSync } from "fs";import { join } from "path";import { describe, expect, it, vi } from "vitest";@@ -23,6 +25,14 @@ vi.mock("i18next-http-backend", () => {const { getAvailableLocales, getCurrentLanguage, getLocaleById, initLocale, translationsInitializedPromise } = await import("./i18n");+/** Resolve a dotted i18next key against a parsed catalog. */+function resolveKey(translations: unknown, key: string): unknown {+ return key.split(".").reduce<unknown>(+ (node, segment) => (node && typeof node === "object" ? (node as Record<string, unknown>)[segment] : undefined),+ translations+ );+}+describe("i18n", () => {it("translations are valid JSON with no duplicate keys", () => {for (const locale of LOCALES) {@@ -54,6 +64,99 @@ describe("i18n", () => {}});+ // The text editor localizes by passing the English text itself to the editor's translation+ // function, and that text resolves to `text-editor.ck.<slug>`. A string with no entry there+ // silently renders its English id in every locale — it is invisible to Weblate, so no+ // translator can ever supply it.+ //+ // Nothing here is declared by hand: the messages are gathered from the editor package's own+ // source, so a translation call added anywhere in any plugin is covered the moment it is+ // written. The check runs in both directions, so a stale or misspelled entry fails too.+ describe("editor messages", () => {+ const translationPath = join(__dirname, "..", "translations", "en", "translation.json");+ const editorSourcePath = join(__dirname, "..", "..", "..", "..", "packages", "ckeditor5", "src");++ // Matches `t("…")` however it is reached — bare, `editor.t(…)`, `this.t(…)`. `\bt\(` only+ // fires where `t` starts a word, so `insert(`, `expect(` and `_t(` are not mistaken for+ // translation calls. The first group captures the opening quote for the backreference.+ const TRANSLATION_CALL = /\bt\(\s*(["'`])((?:\\.|(?!\1).)*)\1/g;++ // A dotted lowercase identifier is a key for the older host-translator bridge, which+ // resolves it against the app catalog directly rather than through a message dictionary.+ // Transitional: this can go once every plugin has moved over.+ const BRIDGE_KEY = /^[a-z0-9_-]+(\.[a-z0-9_-]+)+$/;++ /** Every message id the editor package asks its translation function for. */+ function gatherEditorMessages(): string[] {+ const messages = new Set<string>();++ for (const entry of readdirSync(editorSourcePath, { recursive: true, withFileTypes: true })) {+ if (!entry.isFile() || !entry.name.endsWith(".ts") || entry.name.endsWith(".spec.ts")) continue;++ const source = readFileSync(join(entry.parentPath, entry.name), { encoding: "utf-8" });+ for (const [ , , body ] of source.matchAll(TRANSLATION_CALL)) {+ // Un-escape what the source had to escape to sit inside its quotes, so the+ // result is the message id as the translation function receives it.+ const message = body.replace(/\\(.)/g, "$1");+ if (!BRIDGE_KEY.test(message)) {+ messages.add(message);+ }+ }+ }++ // The admonition type titles are passed as a variable rather than a literal, so they+ // are invisible to the scan and are read from their own declaration.+ for (const definition of Object.values(ADMONITION_TYPES)) {+ messages.add(definition.title);+ }++ return [ ...messages ];+ }++ /**+ * Message ids CKEditor already translates itself. Ours is merged after the core catalog, so+ * an entry for one of these would *override* the upstream translation in every locale —+ * which is a thing we do deliberately (`Bookmark` → `Anchor`), but never by accident. They+ * are recognized rather than listed: a message the German core catalog knows is upstream.+ */+ async function loadUpstreamMessages(): Promise<Set<string>> {+ const core = (await import("ckeditor5/translations/de.js")).default;+ return new Set(Object.keys(core.de.dictionary));+ }++ it("has an English entry for every message the plugins ask for", async () => {+ const translations = JSON.parse(readFileSync(translationPath, { encoding: "utf-8" }));+ const upstream = await loadUpstreamMessages();++ const missing = gatherEditorMessages()+ .filter((message) => !upstream.has(message))+ .map((message) => ({ message, key: MESSAGE_KEY_PREFIX + slugify(message) }))+ .filter(({ key }) => typeof resolveKey(translations, key) !== "string");++ expect(+ missing,+ `Editor messages with no entry in "${translationPath}":\n${+ missing.map(({ message, key }) => ` - "${message}" → add "${key}"`).join("\n")}`+ ).toEqual([]);+ });++ it("has no English entry that no plugin asks for", () => {+ const translations = JSON.parse(readFileSync(translationPath, { encoding: "utf-8" }));+ const declared = (resolveKey(translations, "text-editor.ck") ?? {}) as Record<string, string>;+ const asked = new Set(gatherEditorMessages());++ const orphaned = Object.entries(declared)+ .filter(([ , english ]) => !asked.has(english))+ .map(([ key, english ]) => ` - "${MESSAGE_KEY_PREFIX}${key}" ("${english}")`);++ expect(+ orphaned,+ `Entries under "${MESSAGE_KEY_PREFIX}" that no editor string uses — the message was renamed or removed:\n${+ orphaned.join("\n")}`+ ).toEqual([]);+ });+ });+describe("getAvailableLocales", () => {it("returns the full LOCALES list", () => {expect(getAvailableLocales()).toBe(LOCALES);diff --git a/apps/client/src/widgets/type_widgets/text/config.ts b/apps/client/src/widgets/type_widgets/text/config.tsindex b4b6e95697..79f0710604 100644--- a/apps/client/src/widgets/type_widgets/text/config.ts+++ b/apps/client/src/widgets/type_widgets/text/config.ts@@ -1,6 +1,7 @@import { buildExtraCommands, type EditorConfig, getCkLocale, SnippetDefinition } from "@triliumnext/ckeditor5";import emojiDefinitionsUrl from "@triliumnext/ckeditor5/src/emoji_definitions/en.json?url";import { ALLOWED_PROTOCOLS, DISPLAYABLE_LOCALE_IDS, KATEX_MACROS, MIME_TYPE_AUTO, normalizeMimeTypeForCKEditor } from "@triliumnext/commons";+import i18next from "i18next";import { copyTextWithToast } from "../../../services/clipboard_ext.js";import { t } from "../../../services/i18n.js";@@ -186,7 +187,7 @@ export async function buildConfig(opts: BuildEditorOptions): Promise<EditorConfiremovePlugins: getDisabledPlugins(),// The locale's CKEditor translations, plus the dictionary of Trilium-authored editor// strings resolved through the app's i18n (see `messages.ts` in the ckeditor5 package).- ...await getCkLocale(opts.uiLanguage, (key) => t(key))+ ...await getCkLocale(opts.uiLanguage, { englishMessages: getEnglishEditorMessages(), translate: (key) => t(key) })};// User-configurable todo task states (from the `_taskStates` hidden subtree).@@ -271,6 +272,24 @@ export async function buildConfig(opts: BuildEditorOptions): Promise<EditorConfi};}+/**+ * The English editor messages, i.e. the `text-editor.ck` section of the English catalog, mapping+ * each derived key to the English text that plugins pass to `editor.t()`. This section is the+ * registry of Trilium-authored editor strings — there is no list of them in code — so reading it+ * back is what lets the message dictionary be built.+ *+ * English is always loaded, being i18next's `fallbackLng`; an empty section only means every editor+ * string renders its English message id, which is what an unconfigured editor does anyway.+ *+ * `getResourceBundle` is bound onto the i18next instance by `init()`, so it is missing until+ * `initLocale()` has run — the case for a test that builds a config without booting i18n.+ */+function getEnglishEditorMessages(): Record<string, string> {+ const bundle = i18next.getResourceBundle?.("en", "translation") as+ { "text-editor"?: { ck?: Record<string, string> } } | undefined;+ return bundle?.["text-editor"]?.ck ?? {};+}+function buildListOfLanguages() {const userLanguages = mimeTypesService.getMimeTypes()diff --git a/packages/ckeditor5/src/i18n.spec.ts b/packages/ckeditor5/src/i18n.spec.tsindex 1cfcf1fe5e..c0fcd290f2 100644--- a/packages/ckeditor5/src/i18n.spec.ts+++ b/packages/ckeditor5/src/i18n.spec.ts@@ -8,13 +8,26 @@ import { MESSAGE_KEY_PREFIX } from "./messages.js";import Admonition from "./plugins/admonition/admonition.js";import AdmonitionUI from "./plugins/admonition/admonition_ui.js";+/** The `text-editor.ck` section of the English catalog, as the client reads it back at runtime. */+const ENGLISH_MESSAGES: Record<string, string> = {+ admonition: "Admonition",+ caution: "Caution",+ important: "Important",+ note: "Note",+ tip: "Tip",+ warning: "Warning"+};+/**- * A translator that resolves only the admonition button, echoing every other key back the way- * i18next does for a missing entry — so the assertions below pin one dictionary entry rather than- * tracking the whole message list.+ * Messages resolving only the admonition button, with every other key echoed back the way i18next+ * does for a missing entry — so the assertions below pin one dictionary entry rather than tracking+ * the whole catalog.*/-function translateAdmonitionOnly(translation: string) {- return (key: string) => (key === "text-editor.ck.admonition" ? translation : key);+function admonitionOnly(translation: string) {+ return {+ englishMessages: ENGLISH_MESSAGES,+ translate: (key: string) => (key === "text-editor.ck.admonition" ? translation : key)+ };}interface AdmonitionDropdown {@@ -62,7 +75,7 @@ describe("getCkLocale", () => {});it("appends the Trilium dictionary after the core translations", async () => {- const { language, translations } = await getCkLocale("de", translateAdmonitionOnly("Ermahnung"));+ const { language, translations } = await getCkLocale("de", admonitionOnly("Ermahnung"));expect(language).toBe("de");if (!Array.isArray(translations)) throw new Error("expected an array of translations");@@ -80,7 +93,7 @@ describe("getCkLocale", () => {if (!Array.isArray(before.translations)) throw new Error("expected an array of translations");const coreEntry = before.translations[1] as Record<string, { dictionary: Record<string, string> }>;- await getCkLocale("de", translateAdmonitionOnly("Ermahnung"));+ await getCkLocale("de", admonitionOnly("Ermahnung"));expect(coreEntry.de.dictionary).not.toHaveProperty("Admonition");});@@ -88,7 +101,7 @@ describe("getCkLocale", () => {// A locale with no CKEditor translation still needs the dictionary, since it also carries any// rewording of the editor's built-in English strings.it("supplies a dictionary keyed 'en' for locales with no core translation", async () => {- const { language, translations } = await getCkLocale("ga", translateAdmonitionOnly("Rabhadh"));+ const { language, translations } = await getCkLocale("ga", admonitionOnly("Rabhadh"));expect(language).toBeUndefined();expect(translations).toEqual([ {}, { en: { dictionary: { Admonition: "Rabhadh" } } } ]);@@ -97,7 +110,7 @@ describe("getCkLocale", () => {// An unresolved key yields an empty dictionary, which must not be pushed as a translations// entry — an empty dictionary for a locale would otherwise shadow nothing but still allocate.it("omits the dictionary when the translator resolves nothing", async () => {- expect(await getCkLocale("ga", (key) => key)).toEqual({});+ expect(await getCkLocale("ga", { englishMessages: ENGLISH_MESSAGES, translate: (key) => key })).toEqual({});});// End-to-end over a real editor: `AdmonitionUI` localizes with plain `editor.t("Admonition")`,@@ -120,7 +133,7 @@ describe("getCkLocale", () => {}it("translates the button and every type entry through the host translator", async () => {- const dropdown = await createAdmonitionDropdown(await getCkLocale("ro", translateToRomanian));+ const dropdown = await createAdmonitionDropdown(await getCkLocale("ro", { englishMessages: ENGLISH_MESSAGES, translate: translateToRomanian }));expect(dropdown.buttonView.label).toBe("Casetă de avertizare");expect(readTypeLabels(dropdown)).toEqual([ "Notă", "Sfat", "Important", "Atenție", "Avertisment" ]);@@ -133,7 +146,7 @@ describe("getCkLocale", () => {[ "no translator is configured", undefined ],[ "the translation is missing", (key: string) => key ]])("falls back to the English message ids when %s", async (_case, translate) => {- const dropdown = await createAdmonitionDropdown(await getCkLocale("ro", translate));+ const dropdown = await createAdmonitionDropdown(await getCkLocale("ro", translate && { englishMessages: ENGLISH_MESSAGES, translate }));expect(dropdown.buttonView.label).toBe("Admonition");expect(readTypeLabels(dropdown)).toEqual([ "Note", "Tip", "Important", "Caution", "Warning" ]);diff --git a/packages/ckeditor5/src/i18n.ts b/packages/ckeditor5/src/i18n.tsindex b9c245f98d..b56b391d49 100644--- a/packages/ckeditor5/src/i18n.ts+++ b/packages/ckeditor5/src/i18n.ts@@ -99,13 +99,13 @@ const LOCALE_MAPPINGS: Record<DISPLAYABLE_LOCALE_IDS, LocaleMapping | null> = {* locale.** @param locale the Trilium locale to configure the editor for.- * @param translate the host's translator, resolving an i18next key to the localized string. Omit it- * (a test, a standalone editor) and every Trilium string falls back to the English- * message id passed to `editor.t()`.+ * @param messages the host's English message catalog (the `text-editor.ck` section) paired with its+ * translator. Omit it — a test, a standalone editor — and every Trilium string+ * falls back to the English message id passed to `editor.t()`.*/export default async function getCkLocale(locale: DISPLAYABLE_LOCALE_IDS,- translate?: (key: string) => string+ messages?: { englishMessages: Record<string, string>; translate: (key: string) => string }): Promise<Pick<EditorConfig, "language" | "translations">> {const mapping = LOCALE_MAPPINGS[locale];const translations: Translations[] = [];@@ -116,8 +116,8 @@ export default async function getCkLocale(translations.push((await mapping.coreTranslation()).default);}- if (translate) {- const dictionary = buildMessageDictionary(translate);+ if (messages) {+ const dictionary = buildMessageDictionary(messages.englishMessages, messages.translate);if (Object.keys(dictionary).length > 0) {// Keyed by the language CKEditor will resolve messages under, which is the editor's// default (`en`) whenever we pass no `language` below.diff --git a/packages/ckeditor5/src/index.ts b/packages/ckeditor5/src/index.tsindex 340d075a33..929077178f 100644--- a/packages/ckeditor5/src/index.ts+++ b/packages/ckeditor5/src/index.ts@@ -17,6 +17,7 @@ export { default as TriliumSnippets } from "./plugins/snippets/snippets.js";export type { SnippetDefinition } from "./plugins/snippets/snippetsconfig.js";export { default as buildExtraCommands } from "./extra_slash_commands.js";export { default as getCkLocale } from "./i18n.js";+export { MESSAGE_KEY_PREFIX, slugify } from "./messages.js";export * from "./utils.js";// Import with sideffects to ensure that type augmentations are present.diff --git a/packages/ckeditor5/src/messages.spec.ts b/packages/ckeditor5/src/messages.spec.tsindex dd287fa431..f83555c729 100644--- a/packages/ckeditor5/src/messages.spec.ts+++ b/packages/ckeditor5/src/messages.spec.ts@@ -1,6 +1,6 @@import { describe, expect, it } from "vitest";-import { buildMessageDictionary, MESSAGE_KEY_PREFIX, MESSAGES, slugify, translateMessage } from "./messages.js";+import { buildMessageDictionary, MESSAGE_KEY_PREFIX, slugify, translateMessage } from "./messages.js";describe("slugify", () => {// The punctuation cases matter: `.` separates key paths in i18next, and `"`/`%0` would be@@ -17,33 +17,24 @@ describe("slugify", () => {});describe("buildMessageDictionary", () => {- it("maps each message id to its translation", () => {- const dictionary = buildMessageDictionary((key) => `translated:${key}`);+ const ENGLISH = { admonition: "Admonition", warning: "Warning" };- expect(dictionary.Admonition).toBe(`translated:${MESSAGE_KEY_PREFIX}admonition`);- expect(dictionary.Warning).toBe(`translated:${MESSAGE_KEY_PREFIX}warning`);- expect(Object.keys(dictionary)).toHaveLength(MESSAGES.length);+ it("maps each English message to its translation", () => {+ const dictionary = buildMessageDictionary(ENGLISH, (key) => `translated:${key}`);++ expect(dictionary).toEqual({+ Admonition: `translated:${MESSAGE_KEY_PREFIX}admonition`,+ Warning: `translated:${MESSAGE_KEY_PREFIX}warning`+ });});// i18next echoes the key back when an entry is missing. Putting that in the dictionary would// render `text-editor.ck.admonition` at the user; skipping it lets CKEditor fall back to the// English message id instead.it("omits messages whose key the translator does not resolve", () => {- expect(buildMessageDictionary((key) => key)).toEqual({});- expect(buildMessageDictionary(() => "")).toEqual({});- });-- it("has no duplicate message ids", () => {- expect(new Set(MESSAGES).size).toBe(MESSAGES.length);- });-- it("covers every message id, keyed by its slug", () => {- const dictionary = buildMessageDictionary((key) => key.slice(MESSAGE_KEY_PREFIX.length));-- expect(Object.keys(dictionary)).toEqual([ ...MESSAGES ]);- for (const message of MESSAGES) {- expect(dictionary[message]).toBe(slugify(message));- }+ expect(buildMessageDictionary(ENGLISH, (key) => key)).toEqual({});+ expect(buildMessageDictionary(ENGLISH, () => "")).toEqual({});+ expect(buildMessageDictionary({}, (key) => `translated:${key}`)).toEqual({});});});diff --git a/packages/ckeditor5/src/messages.ts b/packages/ckeditor5/src/messages.tsindex b49e6959cb..770fa8344c 100644--- a/packages/ckeditor5/src/messages.ts+++ b/packages/ckeditor5/src/messages.ts@@ -1,44 +1,28 @@/*** Trilium-authored editor strings, and the bridge that gets them translated.*- * Plugins localize with CKEditor's own `editor.t("English text")` — no host configuration, no- * translation keys in plugin code. When nothing supplies a dictionary (a test, a standalone- * editor), `t()` falls back to the message id itself, which *is* the English text, so the UI is- * always correct rather than showing a raw key.+ * Plugins localize with CKEditor's own `editor.t`, passing the English text itself as the message+ * id — no host configuration, no translation keys in plugin code. When nothing supplies a+ * dictionary (a test, a standalone editor), the message id is what gets rendered, so the UI is+ * always correct English rather than a raw key.*- * To actually translate those strings, the host hands {@link buildMessageDictionary} a translator- * (the client passes i18next's `t`) and the resulting dictionary is appended to the editor's- * `translations` config in `i18n.ts`. The i18next key is *derived* from the English text by- * {@link slugify}, so there is no message-id-to-key mapping to maintain: every string is written- * once, at the call site.+ * To actually translate those strings, the host builds a message dictionary and `i18n.ts` appends+ * it to the editor's `translations` config. The i18next key is *derived* from the English text by+ * {@link slugify}, so there is no message-id-to-key mapping to maintain, and there is no list of+ * messages either: the English catalog under `text-editor.ck` **is** the registry, and+ * {@link buildMessageDictionary} turns it into the dictionary CKEditor wants. Adding a string means+ * writing it at the call site and adding its English entry — nothing else, and the client's+ * `i18n.spec.ts` fails if the entry is missing, because it gathers the translation calls from this+ * package's source.*- * The same mechanism can reword CKEditor's own strings — listing an upstream message id here- * overrides the built-in translation for every locale, because our dictionary is merged after the- * core one.+ * The same mechanism can reword CKEditor's own strings: an entry whose English text matches an+ * upstream message id overrides the built-in translation for every locale, because our dictionary+ * is merged after the core one.*//** Prefix for the i18next keys this package's messages resolve to. */export const MESSAGE_KEY_PREFIX = "text-editor.ck.";-/**- * Every English message id the editor package owns, i.e. each distinct string passed to- * `editor.t()` by a Trilium plugin (plus any upstream string we deliberately reword).- *- * Current scope: the admonition feature. The remaining plugins still localize through the older- * `config.translate` bridge and are migrated separately.- */-export const MESSAGES = [- "Admonition",- // The admonition types, declared as titles in `ADMONITION_TYPES` and rendered by the toolbar- // dropdown, the type dropdown and the slash commands. `admonition_messages.spec.ts` keeps this- // list and that map in sync.- "Note",- "Tip",- "Important",- "Caution",- "Warning"-] as const;-/*** Derive the i18next key for a message id: lowercase, with every run of non-alphanumeric* characters collapsed into a single dash. Punctuation that would otherwise be significant in an@@ -55,33 +39,24 @@ export function slugify(message: string): string {}/**- * Translate a single message id outside an editor, for code that builds editor content before an- * editor exists — the slash-command definitions, for instance. Inside a plugin use `editor.t()`- * instead; this is the same lookup, minus the editor.- *- * Falls back to the message id, which is the English text, so a missing entry renders English- * rather than a raw key.- */-export function translateMessage(translate: (key: string) => string, message: string): string {- const key = MESSAGE_KEY_PREFIX + slugify(message);- const translated = translate(key);- return translated && translated !== key ? translated : message;-}--/**- * Build the CKEditor dictionary for {@link MESSAGES} using the host's translator.+ * Build the CKEditor dictionary from the host's English catalog and translator.*- * A message is only included when the translator actually resolves its key. i18next echoes the key- * back for a missing entry, so an unresolved message would otherwise put `text-editor.ck.…` in the- * dictionary and render that key at the user; skipping it instead lets CKEditor fall back to the- * English message id.+ * @param englishMessages the `text-editor.ck` section of the English catalog, mapping each derived+ * key to the English text — which is the message id plugins pass to the+ * editor's translation function.+ * @param translate resolves a full i18next key to the localized string.*/-export function buildMessageDictionary(translate: (key: string) => string): Record<string, string> {+export function buildMessageDictionary(+ englishMessages: Record<string, string>,+ translate: (key: string) => string+): Record<string, string> {const dictionary: Record<string, string> = {};- for (const message of MESSAGES) {- const key = MESSAGE_KEY_PREFIX + slugify(message);+ for (const [ derivedKey, message ] of Object.entries(englishMessages)) {+ const key = MESSAGE_KEY_PREFIX + derivedKey;const translated = translate(key);+ // i18next echoes the key back for a missing entry; that would render `text-editor.ck.…` at+ // the user, where falling back to the message id renders correct English.if (translated && translated !== key) {dictionary[message] = translated;}@@ -89,3 +64,17 @@ export function buildMessageDictionary(translate: (key: string) => string): Recoreturn dictionary;}++/**+ * Translate a single message id outside an editor, for code that builds editor content before an+ * editor exists — the slash-command definitions, for instance. Inside a plugin use the editor's own+ * translation function instead; this is the same lookup, minus the editor.+ *+ * Falls back to the message id, which is the English text, so a missing entry renders English+ * rather than a raw key.+ */+export function translateMessage(translate: (key: string) => string, message: string): string {+ const key = MESSAGE_KEY_PREFIX + slugify(message);+ const translated = translate(key);+ return translated && translated !== key ? translated : message;+}diff --git a/packages/ckeditor5/src/plugins/admonition/admonition_ui.spec.ts b/packages/ckeditor5/src/plugins/admonition/admonition_ui.spec.tsindex 961716ae87..514428af72 100644--- a/packages/ckeditor5/src/plugins/admonition/admonition_ui.spec.ts+++ b/packages/ckeditor5/src/plugins/admonition/admonition_ui.spec.ts@@ -2,7 +2,6 @@ import { _setModelData as setModelData, ClassicEditor, Essentials, Paragraph, Spimport { beforeEach, describe, expect, it, vi } from "vitest";import { createTestEditor } from "../../../test/editor-kit.js";-import { MESSAGES } from "../../messages.js";import Admonition from "./admonition.js";import type AdmonitionCommand from "./admonition_command.js";import AdmonitionUI, { ADMONITION_TYPES } from "./admonition_ui.js";@@ -121,17 +120,6 @@ describe("AdmonitionUI", () => {}});- // The titles are localized by passing them to `t()` as message ids, which only resolves if- // each is declared in `MESSAGES` — that list is what builds the dictionary. A type added to- // `ADMONITION_TYPES` alone would silently stay English in every locale.- it("declares every type title as a message id", () => {- const titles = Object.values(ADMONITION_TYPES).map((definition) => definition.title);-- expect(titles).not.toHaveLength(0);- for (const title of titles) {- expect(MESSAGES, `"${title}" is missing from MESSAGES`).toContain(title);- }- });it("applies the picked type when a dropdown item is executed", () => {setModelData(editor.model, "<paragraph>foo[]</paragraph>");