{"record":{"id":"ad79a32471f0cc6c","repo":"slidevjs/slidev","slug":"slidev-can-not-identify-the-source-position-of-t","errorCode":null,"errorMessage":"[Slidev] Can not identify the source position of the v-drag element, please provide an explicit `id` prop.","messagePattern":"\\[Slidev\\] Can not identify the source position of the v-drag element, please provide an explicit `id` prop\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/client/composables/useDragElements.ts","lineNumber":154,"sourceCode":"\n  let dataSource: DragElementDataSource = directive ? 'directive' : 'prop'\n  let dragId: string = makeId()\n  let pos: number[] | undefined\n  if (Array.isArray(posRaw)) {\n    pos = posRaw\n  }\n  else if (typeof posRaw === 'string' && posRaw.includes(',')) {\n    pos = posRaw.split(',').map(Number)\n  }\n  else if (posRaw != null) {\n    dataSource = 'frontmatter'\n    dragId = `${posRaw}`\n    posRaw = frontmatter?.dragPos?.[dragId]\n    pos = (posRaw as string)?.split(',').map(Number)\n  }\n\n  if (dataSource !== 'frontmatter' && !markdownSource)\n    throw new Error('[Slidev] Can not identify the source position of the v-drag element, please provide an explicit `id` prop.')\n\n  const watchStopHandles: WatchStopHandle[] = [stopWatchBounds]\n\n  const autoHeight = !isArrow && posRaw != null && !Number.isFinite(pos?.[3])\n  pos ??= [Number.NaN, Number.NaN, 0]\n  const width = ref(pos[2])\n  const x0 = ref(pos[0] + pos[2] / 2)\n\n  const rotate = ref(isArrow ? 0 : (pos[4] ?? 0))\n  const rotateRad = computed(() => rotate.value * Math.PI / 180)\n  const rotateSin = computed(() => Math.sin(rotateRad.value))\n  const rotateCos = computed(() => Math.cos(rotateRad.value))\n\n  const container = ref<HTMLElement>()\n  const bounds = ref({ left: 0, top: 0, width: 0, height: 0 })\n  const actualHeight = ref(0)\n  function updateBounds() {\n    if (!container.value)","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/slidevjs/slidev/blob/0d798ace5828966d9f77f62094d5f7a971ad98f7/packages/client/composables/useDragElements.ts#L136-L172","documentation":"Thrown by useDragElement when the data source is 'directive' or 'prop' (inline-positioned, not frontmatter) but no markdownSource was provided. Without either a markdown source range or a frontmatter id, the element has no place to read/write its position.","triggerScenarios":"Using the v-drag directive or pos=\"...\" prop without an id and outside the normal markdown capture path (e.g. inside a computed/dynamic component, or a custom integration that bypasses the source tracker).","commonSituations":"Programmatic v-drag usage, wrapping v-drag in a custom component without forwarding source info, or rendering v-drag from a non-markdown source.","solutions":["Add an explicit id=\"...\" prop so the element uses frontmatter dragPos","Pass the markdownSource tuple when invoking useDragElement directly","Author the element directly in slides.md so the source range is auto-captured"],"exampleFix":"// before\n<div v-drag />\n// after\n<div v-drag id=\"my-el\" />","handlingStrategy":"validation","validationCode":"// when wiring up a v-drag element programmatically\nif (!markdownSource && (dataSource === 'directive' || dataSource === 'prop')) {\n  // require an id so it becomes frontmatter-backed\n  if (!hasId) throw new Error('Provide an id or author the element in slides.md')\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always add an explicit id to v-drag elements used outside static markdown","Forward markdownSource when wrapping v-drag in custom components"],"tags":["v-drag","frontmatter","id"],"backgroundTag":null,"analyzedSha":"0d798ace5828966d9f77f62094d5f7a971ad98f7","analyzedAt":"2026-08-12T17:10:56.221Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}