- 移除了vue-draggable-plus依赖,改用原生HTML5拖拽API

- 增强了图片拖拽功能的调试信息,便于问题排查
  - 优化了图片插入和拖拽处理逻辑
  - 修复了拖拽过程中图片和拖拽手柄的同步问题
This commit is contained in:
yuantao
2025-10-15 18:35:38 +08:00
parent 51014991cf
commit b139d64363
5 changed files with 260 additions and 85 deletions

View File

@@ -47,35 +47,27 @@ const setNoteContent = async noteId => {
// 确保store数据已加载如果便签列表为空则先加载数据
if (store.notes.length === 0) {
await store.loadData()
console.log('Store loaded, notes count:', store.notes.length)
}
// 从store中查找指定ID的便签
const note = store.notes.find(n => n.id === noteId)
console.log('Found note:', note)
// 确保编辑器已经初始化完成
await nextTick()
console.log('Editor ref:', editorRef.value)
if (note) {
console.log('Setting content:', note.content)
// 无论editorRef是否可用都先设置content的值作为备份
content.value = note.content || ''
// 如果editorRef可用直接设置编辑器内容
if (editorRef.value) {
editorRef.value.setContent(note.content || '')
}
} else {
console.log('Note not available')
}
}
// 加载初始数据
onMounted(async () => {
console.log('NoteEditorPage mounted')
await store.loadData()
console.log('Store loaded, notes count:', store.notes.length)
// 如果是编辑现有便签,在组件挂载后设置内容
if (noteId.value) {
@@ -87,7 +79,6 @@ onMounted(async () => {
watch(
noteId,
async newNoteId => {
console.log('Note ID changed:', newNoteId)
if (newNoteId) {
await setNoteContent(newNoteId)
}
@@ -148,13 +139,11 @@ const debounce = (func, delay) => {
// 延迟300ms更新内容避免用户输入时频繁触发更新
const debouncedHandleContentChange = debounce(newContent => {
content.value = newContent
console.log('Content updated:', newContent)
}, 300)
// 监听编辑器内容变化
// 当编辑器内容发生变化时调用此函数
const handleContentChange = newContent => {
console.log('Editor content changed:', newContent)
debouncedHandleContentChange(newContent)
}