<script setup="setup">

import { ref } from 'vue'

const { etherpadUrl, etherpadPrefix } = useRuntimeConfig().public

const props = defineProps({
  revisionId: String,
  onLoad: Function
})

const embed = ref(null)

onMounted(() => {
  // Ce ni revisionId propertyja, se random generira.
  const uuid = props.revisionId ? props.revisionId : crypto.randomUUID()
  const padUrl = `${etherpadUrl}/p/${etherpadPrefix}${uuid}?showChat=false&showLineNumbers=false&toc=false`
  embed.value.src = padUrl
})

</script>

<template>
  <iframe ref="embed" class="etherpad-textarea" @load="props.onLoad" />
</template>
