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

63 lines
1.1 KiB
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 {
2019-03-02 22:35:43 +05:30
name: 'CodeOutput',
2018-12-13 13:39:08 +05:30
components: {
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
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
},
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
},
2019-12-21 20:55:43 +05:30
cellCssClass() {
return {
[this.codeCssClass]: true,
'jupyter-notebook-scrolled': this.metadata.scrolled,
};
},
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-15 15:39:39 +05:30
<prompt :type="promptType" :count="count" />
2019-12-21 20:55:43 +05:30
<pre ref="code" :class="cellCssClass" class="language-python" v-text="code"></pre>
2018-03-17 18:26:18 +05:30
</div>
</template>