<template>
  <div class="edit-text">
    <el-form
      ref="modalFormComp"
      :key="modalForm.id"
      :model="modalForm"
      label-width="100px"
    >
      <el-form-item label="对齐：">
        <el-radio-group v-model="modalForm.textAlign">
          <el-radio-button label="left">左</el-radio-button>
          <el-radio-button label="center">居中</el-radio-button>
          <el-radio-button label="right">右</el-radio-button>
          <el-radio-button label="justify">两端</el-radio-button>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="缩进：">
        <el-input-number
          v-model="modalForm.paddingLeft"
          style="width: 125px"
          :min="0"
          :max="200"
          :step="1"
          step-strictly
          :controls="false"
        ></el-input-number>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
const initModalForm = {
  id: "",
  paddingLeft: 0,
  textAlign: "left",
};

export default {
  name: "EditText",

  props: {
    instance: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  data() {
    return {
      modalForm: { ...initModalForm },
    };
  },
  mounted() {
    this.initData(this.instance);
  },
  methods: {
    initData(val) {
      this.modalForm = { ...val };
    },
    submit() {
      this.$emit("modified", this.modalForm);
    },
  },
};
</script>
