<template>
  <div>
    <div v-if="mypathin && !!rec">
      <q-drawer
        v-model="visuEditor"
        v-if="selElem && editOn"
        side="right"
        :width="tools.isMobile() ? 350 : 400"
        :breakpoint="800"
        elevated
        style="position: absolute; top: 0; left: 0"
      >
        <q-bar dense class="q-ma-xs bg-primary text-white">
          <q-toolbar-title> Editor </q-toolbar-title>
          <q-btn
            flat
            round
            color="white"
            icon="close"
            @click="
              visuEditor = false;
              selElem = {};
            "
          ></q-btn>
        </q-bar>
        <CMyEditElem :myelem="selElem" :editOn="editOn" :path="rec.path" :idPage="rec._id">
        </CMyEditElem>
      </q-drawer>

      <div class="q-ma-xs q-gutter-xs q-pa-xs">
        <div v-if="!!rec.img1" class="text-center">
          <q-img :src="`` + rec.img1" class="img"></q-img>
        </div>

        <div v-if="!!rec.content" v-html="rec.content"></div>
        <q-video v-if="!!rec.video1" :src="rec.video1" :ratio="rec.ratio1">
        </q-video>

        <div v-if="!!rec.img2" class="text-center">
          <q-img :src="`` + rec.img2" class="img"></q-img>
        </div>

        <div v-if="!!rec.content2" v-html="rec.content2"></div>
        <q-video
          v-if="!!rec.video2"
          :src="rec.video2"
          :ratio="rec.ratio2"
        ></q-video>

        <div v-if="!!rec.img3" class="text-center">
          <q-img :src="`` + rec.img2" class="img"></q-img>
        </div>

        <div v-if="!!rec.content3" v-html="rec.content3"></div>
        <q-video
          v-if="!!rec.video3"
          :src="rec.video3"
          :ratio="rec.ratio3"
        ></q-video>
        <div v-if="!!rec.content4" v-html="rec.content4"></div>

        <div v-for="myelem in myelems" :key="myelem._id">
          <CMyElem
            v-if="myelem.active || editOn"
            :myelem="myelem"
            :editOn="editOn"
            :addOn="addOn"
            :idPage="rec._id"
            :path="rec.path"
            :selElem="selElem"
            @selElemClick="selElemClick"
          >
          </CMyElem>
        </div>
        <div v-if="myelems.length === 0">
          <CMyElem
            v-if="editOn"
            :myelem="myelemVoid"
            :editOn="editOn"
            :addOn="addOn"
            :idPage="rec._id"
            :selElem="selElem"
            :path="rec.path"
            @selElemClick="selElemClick"
          >
          </CMyElem>
        </div>
      </div>
    </div>
    <div v-else>
      <div v-if="!!title">
        <CTitle
          v-if="imgbackground"
          :imgbackground="imgbackground"
          :headtitle="title"
          :sizes="sizes"
          :styleadd="styleadd"
        ></CTitle>
        <div v-if="!imgbackground">
          <CImgTitle v-if="img" :src="img" :title="title"> </CImgTitle>
        </div>
        <slot></slot>
      </div>
    </div>
  </div>
</template>

<script lang="ts" src="./CMyPageElem2.ts">
</script>
<style lang="scss" scoped>
@import './CMyPageElem2.scss';
</style>
