refac
This commit is contained in:
1 parent
7ed7e81e84
commit
5055fb85aa
1 file changed
+29
-1
@@ -1443,7 +1443,35 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
|
|||||||
bind:show={showPanel}
|
bind:show={showPanel}
|
||||||
bind:selectedModelId
|
bind:selectedModelId
|
||||||
bind:files
|
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();
|
changeDebounceHandler();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in new issue
Block a user