Skip to content

Commit

Permalink
remarkable updates
Browse files Browse the repository at this point in the history
  • Loading branch information
OvidijusParsiunas committed Dec 18, 2024
1 parent f9ca0ec commit debc844
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion component/src/types/remarkable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface RemarkableOptions {
html?: boolean;
breaks?: boolean;
linkify?: boolean;
langPrefix?: string;
langPrefix?: `language-${string}`;
linkTarget?: string;
typographer?: boolean;
quotes?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ declare module 'remarkable' {
html?: boolean;
breaks?: boolean;
linkify?: boolean;
langPrefix?: string;
langPrefix?: `language-${string}`;
linkTarget?: string;
typographer?: boolean;
quotes?: string;
Expand Down
12 changes: 7 additions & 5 deletions component/src/views/chat/messages/remarkable/remarkableConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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);
}
}

Expand Down

0 comments on commit debc844

Please sign in to comment.