mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-18 19:29:11 -05:00
refac
This commit is contained in:
@@ -1443,7 +1443,35 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
|
||||
bind:show={showPanel}
|
||||
bind:selectedModelId
|
||||
bind:files
|
||||
onUpdate={() => {
|
||||
onUpdate={(updatedFiles) => {
|
||||
files = updatedFiles;
|
||||
note.data.files = files.length > 0 ? files : null;
|
||||
|
||||
if (editor) {
|
||||
editor.storage.files = files;
|
||||
const fileIds = new Set(files.map((file) => file.id));
|
||||
const ranges = [];
|
||||
|
||||
editor.state.doc.descendants((node, pos) => {
|
||||
const src = node.attrs.src;
|
||||
if (
|
||||
node.type.name === 'image' &&
|
||||
src?.startsWith('data://') &&
|
||||
!fileIds.has(src.slice('data://'.length))
|
||||
) {
|
||||
ranges.push([pos, pos + node.nodeSize]);
|
||||
}
|
||||
});
|
||||
|
||||
if (ranges.length > 0) {
|
||||
let transaction = editor.state.tr;
|
||||
ranges.reverse().forEach(([from, to]) => {
|
||||
transaction = transaction.delete(from, to);
|
||||
});
|
||||
editor.view.dispatch(transaction);
|
||||
}
|
||||
}
|
||||
|
||||
changeDebounceHandler();
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user