summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components/page/page.textarea-input.vue
blob: 507e1bd97be4f28a0c9c65aa8fad1c9e14234bbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<template>
<div>
	<MkTextarea :model-value="value" @update:model-value="updateValue($event)">
		<template #label>{{ hpml.interpolate(block.text) }}</template>
	</MkTextarea>
</div>
</template>

<script lang="ts">
import { computed, defineComponent, PropType } from 'vue';
import MkTextarea from '../form/textarea.vue';
import * as os from '@/os';
import { Hpml } from '@/scripts/hpml/evaluator';
import { HpmlTextInput } from '@/scripts/hpml';
import { TextInputVarBlock } from '@/scripts/hpml/block';

export default defineComponent({
	components: {
		MkTextarea,
	},
	props: {
		block: {
			type: Object as PropType<TextInputVarBlock>,
			required: true,
		},
		hpml: {
			type: Object as PropType<Hpml>,
			required: true,
		},
	},
	setup(props, ctx) {
		const value = computed(() => {
			return props.hpml.vars.value[props.block.name];
		});

		function updateValue(newValue) {
			props.hpml.updatePageVar(props.block.name, newValue);
			props.hpml.eval();
		}

		return {
			value,
			updateValue,
		};
	},
});
</script>