Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
6e89a481
Unverified
Commit
6e89a481
authored
May 25, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
May 25, 2024
Browse files
Merge pull request #2180 from austenadler/dev
Always open links in chat in a new tab
parents
27f034b2
c9799991
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
src/lib/components/chat/Messages/ResponseMessage.svelte
src/lib/components/chat/Messages/ResponseMessage.svelte
+7
-0
src/lib/utils/index.ts
src/lib/utils/index.ts
+4
-1
No files found.
src/lib/components/chat/Messages/ResponseMessage.svelte
View file @
6e89a481
...
@@ -80,6 +80,13 @@
...
@@ -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;
...
...
src/lib/utils/index.ts
View file @
6e89a481
...
@@ -12,11 +12,14 @@ export const sanitizeResponseContent = (content: string) => {
...
@@ -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
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment