debian-mirror-gitlab/app/assets/javascripts/notebook/cells/code/index.vue

51 lines
922 B
Vue
Raw Normal View History

2017-08-17 22:00:37 +05:30
<script>
2018-12-13 13:39:08 +05:30
import Prism from '../../lib/highlight';
import Prompt from '../prompt.vue';
2017-08-17 22:00:37 +05:30
2018-12-13 13:39:08 +05:30
export default {
components: {
prompt: Prompt,
},
props: {
count: {
type: Number,
required: false,
default: 0,
2017-08-17 22:00:37 +05:30
},
2018-12-13 13:39:08 +05:30
codeCssClass: {
type: String,
required: false,
default: '',
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
},
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
},
2018-12-13 13:39:08 +05:30
},
mounted() {
Prism.highlightElement(this.$refs.code);
},
};
2017-08-17 22:00:37 +05:30
</script>
2018-03-17 18:26:18 +05:30
<template>
<div :class="type">
2019-02-13 22:33:31 +05:30
<prompt :type="promptType" :count="count" />
<pre ref="code" :class="codeCssClass" class="language-python" v-text="code"></pre>
2018-03-17 18:26:18 +05:30
</div>
</template>