openpencil/packages/docs/programmable/sdk/api/composables/provide-editor.md
2026-03-24 23:24:08 +03:00

980 B

title description
provideEditor Provide an OpenPencil editor instance to a Vue subtree using injection.

provideEditor

provideEditor(editor) makes an OpenPencil editor available to descendant composables and headless primitives through Vue injection.

This is the foundation for useEditor().

Usage

import { provideEditor } from '@open-pencil/vue'

provideEditor(editor)

Basic example

<script setup lang="ts">
import { provideEditor } from '@open-pencil/vue'

import type { Editor } from '@open-pencil/core/editor'

const props = defineProps<{
  editor: Editor
}>()

provideEditor(props.editor)
</script>

<template>
  <slot />
</template>

Notes

The current SDK uses provideEditor() and useEditor() directly. Some older examples and error messages still refer to an OpenPencilProvider component, but the injection model is the real API surface to prefer in docs and app code.