<template>
  <div class="question">
    <div class="question-container">
      <div class="question-content">
        <slot name="content"></slot>
      </div>
      <div v-if="isSetting" class="property">
        <slot name="property"></slot>
      </div>
    </div>
    <slot name="question-footer">
      <slot name="footer"></slot>
    </slot>
  </div>
</template>

<script>
export default {
  name: 'QuestionBase',
  inject: ['isSetUp'],
  data() {
    return {};
  },
  computed: {
    isSetting() {
      return this.isSetUp();
    },
  },
  methods: {},
};
</script>

<style lang="scss" scoped>
.question {
  width: 100%;

  &-container {
    display: flex;
    width: 100%;
    padding: 24px;
    background-color: #fff;
    border: $border;
    border-radius: 0 0 8px 8px;

    .question-content {
      flex: 1;

      .stem {
        padding-bottom: 8px;
        margin-bottom: 8px;
        border-bottom: 1px solid $border-color;

        .el-textarea {
          margin-top: 8px;
        }
      }

      .content {
        > ul {
          display: flex;
          flex-direction: column;
          row-gap: 8px;
          width: 100%;

          .content-item {
            display: flex;
            column-gap: 4px;
            align-items: center;

            .question-number {
              min-width: 40px;
              height: 32px;
              padding: 4px 8px;
              color: $text-color;
              cursor: default;
              background-color: $fill-color;
              border-radius: 2px;
            }

            .option-content {
              display: flex;
              flex: 1;
              align-items: center;
              padding-left: 16px;
              background-color: $fill-color;

              .rich-text {
                flex: 1;
                min-height: 32px;

                :deep &.mce-content-body {
                  padding-top: 4px;
                }

                :deep &:not(.mce-edit-focus) {
                  p {
                    margin: 0;
                  }
                }

                :deep &.mce-content-body[data-mce-placeholder]:not(.mce-visualblocks)::before {
                  top: 6px;
                }
              }
            }

            .delete {
              margin-left: 12px;
            }
          }
        }
      }

      .footer {
        display: flex;
        justify-content: center;
        margin-top: 14px;
        color: $main-color;

        .add-option {
          display: flex;
          column-gap: 8px;
          align-items: center;
          font-size: 14px;
          cursor: pointer;
        }
      }
    }

    .property {
      display: flex;

      &::before {
        display: inline-block;
        width: 2px;
        height: 100%;
        margin: 0 24px;
        content: '';
        background-color: $border-color;
      }

      .el-form {
        .el-input {
          width: 250px;
        }
      }

      :deep .el-form-item.el-form-item--small {
        display: flex;
      }
    }
  }
}
</style>
