Skip to content

AI-native design editor. Open-source Figma alternative.

1.0 KB
Raw Blame
import {
  EXPORT_FORMATS,
  EXPORT_FORMAT_OPTIONS,
  EXPORT_SCALES,
  MAX_EXPORT_SCALE,
  MIN_EXPORT_SCALE,
  clampExportScale,
  createExportSettingActions,
  createExportTargetState,
  formatSupportsScale
} from '#vue/document/export/helpers'
import { useEditor } from '#vue/editor/context'
import { useSceneComputed } from '#vue/internal/scene-computed/use'

export type { ExportFormatOption, ExportPanelTarget } from '#vue/document/export/helpers'

export function useExport() {
  const editor = useEditor()

  const selectedIds = useSceneComputed(() => [...editor.state.selectedIds])

  const targetState = createExportTargetState(editor, selectedIds)
  const settingActions = createExportSettingActions(editor, targetState.targetIds)

  return {
    editor,
    selectedIds,
    scales: EXPORT_SCALES,
    maxScale: MAX_EXPORT_SCALE,
    minScale: MIN_EXPORT_SCALE,
    clampExportScale,
    formats: EXPORT_FORMATS,
    formatOptions: EXPORT_FORMAT_OPTIONS,
    formatSupportsScale,
    ...targetState,
    ...settingActions
  }
}