{"record":{"id":"95933e2b73a35617","repo":"slidevjs/slidev","slug":"slidev-vdrag-element-id-is-not-found-in-the-m","errorCode":null,"errorMessage":"[Slidev] VDrag Element ${id} is not found in the markdown source","messagePattern":"\\[Slidev\\] VDrag Element (.+?) is not found in the markdown source","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/client/composables/useDragElements.ts","lineNumber":97,"sourceCode":"              const posMatch = attrs.match(RE_POS_ATTR)\n              if (!posMatch)\n                return `<${tag}${ensureSuffix(' ', attrs)}pos=\"${posStr}\"${selfClose}>`\n              const start = posMatch.index\n              const end = start + posMatch[0].length\n              return `<${tag}${attrs.slice(0, start)}pos=\"${posStr}\"${attrs.slice(end)}${selfClose}>`\n            }\n            return full\n          })\n        : section.replace(/(?<![</\\w])v-drag(?:=\".*?\")?/gi, (full, index) => {\n            if (index === idx) {\n              replaced = true\n              return `v-drag=\"${posStr}\"`\n            }\n            return full\n          })\n\n      if (!replaced)\n        throw new Error(`[Slidev] VDrag Element ${id} is not found in the markdown source`)\n\n      lines.splice(\n        startLine,\n        endLine - startLine,\n        section,\n      )\n\n      const newContent = lines.join('\\n')\n      if (info.value.content === newContent)\n        return\n      newPatch = {\n        content: newContent,\n      }\n      info.value = {\n        ...info.value,\n        content: newContent,\n      }\n    }","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/slidevjs/slidev/blob/0d798ace5828966d9f77f62094d5f7a971ad98f7/packages/client/composables/useDragElements.ts#L79-L115","documentation":"Thrown after Slidev attempted to substitute a v-drag element's position in the markdown but the regex found no matching <v-drag...> tag or v-drag attribute at the expected [startLine, endLine, idx] location. The stored source indices no longer align with the actual file content.","triggerScenarios":"The markdown was edited (line shifts, element removed/renamed) while the presenter is open; HMR left stale source indices; the v-drag was moved into a different line range; or the element idx exceeds the number of v-drag occurrences in the section.","commonSituations":"Manually editing slides.md during a live session, copy-pasting v-drag blocks, or stale state after failed HMR.","solutions":["Restart the dev server so source ranges are recomputed","Switch the element to frontmatter storage with an id prop to avoid markdown rewriting","Avoid editing the slide's v-drag block in your editor while dragging in the presenter"],"exampleFix":"// before\n<v-drag pos=\"0,0,100,50\" />\n// after\n<v-drag id=\"stable\" />","handlingStrategy":"try-catch","validationCode":"// before calling the updater, sanity-check that the source range still contains a v-drag occurrence\nconst [s, e, idx] = markdownSource\nconst section = info.value.content.split('\\n').slice(s, e).join('\\n')\nconst occurrences = section.match(/<v-?[a-z-]*drag\\w*|[?'']?v-drag/gi) ?? []\nif (occurrences.length <= idx) throw new Error('stale source range; restart dev server')","typeGuard":null,"tryCatchPattern":"try {\n  updater(id, posStr, type, markdownSource)\n} catch (e) {\n  if (/not found in the markdown source/.test(String(e))) {\n    // switch this element to frontmatter storage to avoid stale-index failures\n    console.warn('Falling back to frontmatter drag storage for', id)\n  } else throw e\n}","preventionTips":["Restart the dev server after structural edits to slides.md","Use stable id props so positions don't depend on line indices"],"tags":["v-drag","markdown","hmr","stale-state"],"backgroundTag":null,"analyzedSha":"0d798ace5828966d9f77f62094d5f7a971ad98f7","analyzedAt":"2026-08-12T17:10:56.221Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}