2017-08-17 22:00:37 +05:30
|
|
|
<script>
|
2022-10-11 01:57:18 +05:30
|
|
|
import CodeBlockHighlighted from '~/vue_shared/components/code_block_highlighted.vue';
|
2018-12-13 13:39:08 +05:30
|
|
|
import Prompt from '../prompt.vue';
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
export default {
|
2019-03-02 22:35:43 +05:30
|
|
|
name: 'CodeOutput',
|
2018-12-13 13:39:08 +05:30
|
|
|
components: {
|
2022-10-11 01:57:18 +05:30
|
|
|
CodeBlockHighlighted,
|
2019-03-02 22:35:43 +05:30
|
|
|
Prompt,
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
props: {
|
|
|
|
count: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
|
|
|
default: 0,
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
rawCode: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
2019-12-21 20:55:43 +05:30
|
|
|
metadata: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
2020-04-22 19:07:51 +05:30
|
|
|
required: false,
|
2019-12-21 20:55:43 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
code() {
|
|
|
|
return this.rawCode;
|
|
|
|
},
|
|
|
|
promptType() {
|
|
|
|
const type = this.type.split('put')[0];
|
|
|
|
|
|
|
|
return type.charAt(0).toUpperCase() + type.slice(1);
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
2022-10-11 01:57:18 +05:30
|
|
|
maxHeight() {
|
|
|
|
return this.metadata.scrolled ? '20rem' : 'initial';
|
2019-12-21 20:55:43 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
};
|
2017-08-17 22:00:37 +05:30
|
|
|
</script>
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
<template>
|
|
|
|
<div :class="type">
|
2019-02-15 15:39:39 +05:30
|
|
|
<prompt :type="promptType" :count="count" />
|
2022-10-11 01:57:18 +05:30
|
|
|
<code-block-highlighted
|
|
|
|
language="python"
|
|
|
|
:code="code"
|
|
|
|
:max-height="maxHeight"
|
2023-06-20 00:43:36 +05:30
|
|
|
class="gl-border gl-p-4!"
|
2022-10-11 01:57:18 +05:30
|
|
|
/>
|
2018-03-17 18:26:18 +05:30
|
|
|
</div>
|
|
|
|
</template>
|