Add image listing and asset management
Show images in asset directories with preview, rename, replacement, and trash recovery. Update local Markdown references when images move and restore original files if related metadata cannot be committed. Refresh image previews after replacement and compare actual contents when deduplicating subsequent uploads.
This commit is contained in:
1 parent
8b54ccba18
commit
d253536009
25 files changed
+801
-103
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { syntaxTree } from '@codemirror/language'
|
||||
import { Facet, type EditorState, type Range } from '@codemirror/state'
|
||||
import { StateEffect, Facet, type EditorState, type Range } from '@codemirror/state'
|
||||
import { Decoration, EditorView, ViewPlugin, type DecorationSet, type ViewUpdate } from '@codemirror/view'
|
||||
import type { SyntaxNode } from '@lezer/common'
|
||||
import { codeContentRange, fenceLanguage, fencedCodeAt } from './codeblocks'
|
||||
@@ -21,6 +21,9 @@ export const resolveImageUrl = Facet.define<(src: string) => string, (src: strin
|
||||
combine: (values) => values[0] ?? ((src) => src),
|
||||
})
|
||||
|
||||
// 图片文件原位替换时重建预览,不改变正文、选区或撤销历史。
|
||||
export const refreshImages = StateEffect.define<null>()
|
||||
|
||||
const hidden = Decoration.replace({})
|
||||
const inlineCode = Decoration.mark({ class: 'cm-rm-inline-code' })
|
||||
const linkText = Decoration.mark({ class: 'cm-rm-link' })
|
||||
@@ -328,6 +331,7 @@ const livePreviewPlugin = ViewPlugin.fromClass(
|
||||
}
|
||||
if (
|
||||
this.stale ||
|
||||
u.transactions.some((tr) => tr.effects.some((effect) => effect.is(refreshImages))) ||
|
||||
u.docChanged ||
|
||||
u.viewportChanged ||
|
||||
u.selectionSet ||
|
||||
|
||||
Reference in new issue
Block a user