mirror of
https://github.com/open-webui/open-webui
synced 2025-05-17 12:03:41 +00:00
Merge pull request #2180 from austenadler/dev
Always open links in chat in a new tab
This commit is contained in:
commit
6e89a481be
@ -80,6 +80,13 @@
|
|||||||
return `<code>${code.replaceAll('&', '&')}</code>`;
|
return `<code>${code.replaceAll('&', '&')}</code>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Open all links in a new tab/window (from https://github.com/markedjs/marked/issues/655#issuecomment-383226346)
|
||||||
|
const origLinkRenderer = renderer.link;
|
||||||
|
renderer.link = (href, title, text) => {
|
||||||
|
const html = origLinkRenderer.call(renderer, href, title, text);
|
||||||
|
return html.replace(/^<a /, '<a target="_blank" rel="nofollow" ');
|
||||||
|
};
|
||||||
|
|
||||||
const { extensions, ...defaults } = marked.getDefaults() as marked.MarkedOptions & {
|
const { extensions, ...defaults } = marked.getDefaults() as marked.MarkedOptions & {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
extensions: any;
|
extensions: any;
|
||||||
|
@ -12,11 +12,14 @@ export const sanitizeResponseContent = (content: string) => {
|
|||||||
.replace(/<$/, '')
|
.replace(/<$/, '')
|
||||||
.replaceAll(/<\|[a-z]+\|>/g, ' ')
|
.replaceAll(/<\|[a-z]+\|>/g, ' ')
|
||||||
.replaceAll('<', '<')
|
.replaceAll('<', '<')
|
||||||
|
.replaceAll('>', '>')
|
||||||
.trim();
|
.trim();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const revertSanitizedResponseContent = (content: string) => {
|
export const revertSanitizedResponseContent = (content: string) => {
|
||||||
return content.replaceAll('<', '<');
|
return content
|
||||||
|
.replaceAll('<', '<')
|
||||||
|
.replaceAll('>', '>');
|
||||||
};
|
};
|
||||||
|
|
||||||
export const capitalizeFirstLetter = (string) => {
|
export const capitalizeFirstLetter = (string) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user