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

58 lines
963 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">
<prompt
:type="promptType"
:count="count" />
<pre
ref="code"
2018-11-08 19:23:39 +05:30
:class="codeCssClass"
class="language-python"
2018-03-17 18:26:18 +05:30
v-text="code">
</pre>
</div>
</template>