Refactor components/page/page.textarea.vue to composition API

FoundKeyGang/FoundKey#26
This commit is contained in:
Johann150 2022-07-25 07:51:31 +02:00 committed by ThatOneCalculator
parent ff46da778a
commit f256e8b578

View file

@ -2,38 +2,23 @@
<MkTextarea :model-value="text" readonly></MkTextarea> <MkTextarea :model-value="text" readonly></MkTextarea>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { watch } from 'vue';
import MkTextarea from '../form/textarea.vue';
import { TextBlock } from '@/scripts/hpml/block'; import { TextBlock } from '@/scripts/hpml/block';
import { Hpml } from '@/scripts/hpml/evaluator'; import { Hpml } from '@/scripts/hpml/evaluator';
import { defineComponent, PropType } from 'vue';
import MkTextarea from '../form/textarea.vue';
export default defineComponent({ const props = defineProps<{
components: { block: TextBlock;
MkTextarea hpml: Hpml;
}, }>();
props: {
block: { let text = $ref('');
type: Object as PropType<TextBlock>,
required: true watch(props.hpml.vars, () => {
}, text = props.hpml.interpolate(props.block.text) as string;
hpml: { }, {
type: Object as PropType<Hpml>, deep: true,
required: true immediate: true,
}
},
data() {
return {
text: this.hpml.interpolate(this.block.text),
};
},
watch: {
'hpml.vars': {
handler() {
this.text = this.hpml.interpolate(this.block.text);
},
deep: true
}
}
}); });
</script> </script>