mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-15 04:18:18 +00:00
refac
This commit is contained in:
parent
f9c524d31d
commit
ba3e227358
3 changed files with 21 additions and 9 deletions
|
|
@ -18,7 +18,11 @@
|
|||
user
|
||||
} from '$lib/stores';
|
||||
import { processingQueueChannels, processNextInQueue } from '$lib/utils/channelQueue';
|
||||
import { getMentionUserQueries, resolveMentions, getChannelMentionCandidates } from '$lib/utils/channelMentions';
|
||||
import {
|
||||
getMentionUserQueries,
|
||||
resolveMentions,
|
||||
getChannelMentionCandidates
|
||||
} from '$lib/utils/channelMentions';
|
||||
import type { Editor } from '@tiptap/core';
|
||||
import QueuedMessageItem from '../chat/MessageInput/QueuedMessageItem.svelte';
|
||||
import {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import type { Token } from 'marked';
|
||||
import type { Tokens } from 'marked';
|
||||
import { LinkPreview } from 'bits-ui';
|
||||
|
||||
import { getContext } from 'svelte';
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
const i18n = getContext<typeof import('$lib/i18n').default>('i18n');
|
||||
|
||||
export let token: Token;
|
||||
export let token: Tokens.Generic;
|
||||
|
||||
let triggerChar = '';
|
||||
let label = '';
|
||||
|
|
|
|||
|
|
@ -1042,9 +1042,15 @@
|
|||
const stripMentionLinks = (fragment: Fragment): Fragment => {
|
||||
const nodes: Node[] = [];
|
||||
fragment.forEach((node) => {
|
||||
nodes.push(node.type.name === 'mention'
|
||||
? node.mark(node.marks.filter((mark) => mark.type.name !== 'link'))
|
||||
: node.isLeaf ? node : node.copy(stripMentionLinks(node.content)));
|
||||
nodes.push(
|
||||
node.type.name === 'mention'
|
||||
? node.mark(
|
||||
node.marks.filter((mark) => !['link', 'underline'].includes(mark.type.name))
|
||||
)
|
||||
: node.isLeaf
|
||||
? node
|
||||
: node.copy(stripMentionLinks(node.content))
|
||||
);
|
||||
});
|
||||
return Fragment.fromArray(nodes);
|
||||
};
|
||||
|
|
@ -1071,7 +1077,7 @@
|
|||
handlePaste: (view, event, slice) => {
|
||||
// Paste literal text when automatic formatting is disabled.
|
||||
if (!richText || !autoFormat) {
|
||||
// swallow HTML completely
|
||||
// Discard formatting while retaining explicit mention identities.
|
||||
event.preventDefault();
|
||||
const { state, dispatch } = view;
|
||||
|
||||
|
|
@ -1088,8 +1094,10 @@
|
|||
const mentions = plainMentionPaste(slice, state.schema);
|
||||
if (mentions) {
|
||||
dispatch(
|
||||
state.tr.replaceWith(state.selection.from, state.selection.to, mentions)
|
||||
.setMeta('paste', true).scrollIntoView()
|
||||
state.tr
|
||||
.replaceWith(state.selection.from, state.selection.to, mentions)
|
||||
.setMeta('paste', true)
|
||||
.scrollIntoView()
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue