diff --git a/component/src/types/remarkable.ts b/component/src/types/remarkable.ts index 14028c014..3f385852f 100644 --- a/component/src/types/remarkable.ts +++ b/component/src/types/remarkable.ts @@ -6,7 +6,7 @@ export interface RemarkableOptions { html?: boolean; breaks?: boolean; linkify?: boolean; - langPrefix?: string; + langPrefix?: `language-${string}`; linkTarget?: string; typographer?: boolean; quotes?: string; diff --git a/component/src/views/chat/messages/remarkable/remarkable.d.ts b/component/src/views/chat/messages/remarkable/remarkable.d.ts index c79607147..56edb4f6d 100644 --- a/component/src/views/chat/messages/remarkable/remarkable.d.ts +++ b/component/src/views/chat/messages/remarkable/remarkable.d.ts @@ -12,7 +12,7 @@ declare module 'remarkable' { html?: boolean; breaks?: boolean; linkify?: boolean; - langPrefix?: string; + langPrefix?: `language-${string}`; linkTarget?: string; typographer?: boolean; quotes?: string; diff --git a/component/src/views/chat/messages/remarkable/remarkableConfig.ts b/component/src/views/chat/messages/remarkable/remarkableConfig.ts index 6aa9d8983..3ce202f31 100644 --- a/component/src/views/chat/messages/remarkable/remarkableConfig.ts +++ b/component/src/views/chat/messages/remarkable/remarkableConfig.ts @@ -9,9 +9,14 @@ declare global { } export class RemarkableConfig { + private static readonly DEFAULT_PROPERTIES = { + breaks: true, + linkTarget: '_blank', // set target to open in a new tab + }; + private static instantiate(customConfig?: RemarkableOptions) { if (customConfig) { - return new Remarkable(customConfig); + return new Remarkable({...RemarkableConfig.DEFAULT_PROPERTIES, ...customConfig}); } else if (window.hljs) { const hljsModule = window.hljs; return new Remarkable({ @@ -38,10 +43,7 @@ export class RemarkableConfig { typographer: true, // Enable smartypants and other sweet transforms }); } else { - return new Remarkable({ - breaks: true, - linkTarget: '_blank', // set target to open in a new tab - }); + return new Remarkable(RemarkableConfig.DEFAULT_PROPERTIES); } }