2017-08-17 22:00:37 +05:30
|
|
|
<script>
|
2018-12-13 13:39:08 +05:30
|
|
|
import { MarkdownCell, CodeCell } from './cells';
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
export default {
|
|
|
|
components: {
|
2019-03-02 22:35:43 +05:30
|
|
|
CodeCell,
|
|
|
|
MarkdownCell,
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
props: {
|
|
|
|
notebook: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
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
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
cells() {
|
|
|
|
if (this.notebook.worksheets) {
|
|
|
|
const data = {
|
|
|
|
cells: [],
|
|
|
|
};
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
return this.notebook.worksheets.reduce((cellData, sheet) => {
|
|
|
|
const cellDataCopy = cellData;
|
|
|
|
cellDataCopy.cells = cellDataCopy.cells.concat(sheet.cells);
|
|
|
|
return cellDataCopy;
|
|
|
|
}, data).cells;
|
|
|
|
}
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
return this.notebook.cells;
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
hasNotebook() {
|
|
|
|
return Object.keys(this.notebook).length;
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
cellType(type) {
|
2020-04-22 19:07:51 +05:30
|
|
|
return `${type}-cell`; // eslint-disable-line @gitlab/require-i18n-strings
|
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 v-if="hasNotebook">
|
|
|
|
<component
|
|
|
|
:is="cellType(cell.cell_type)"
|
2018-12-05 23:21:45 +05:30
|
|
|
v-for="(cell, index) in cells"
|
2018-03-17 18:26:18 +05:30
|
|
|
:key="index"
|
2018-12-05 23:21:45 +05:30
|
|
|
:cell="cell"
|
2019-02-15 15:39:39 +05:30
|
|
|
:code-css-class="codeCssClass"
|
|
|
|
/>
|
2018-03-17 18:26:18 +05:30
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
<style>
|
|
|
|
.cell,
|
|
|
|
.input,
|
|
|
|
.output {
|
|
|
|
display: flex;
|
|
|
|
width: 100%;
|
|
|
|
margin-bottom: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.cell pre {
|
|
|
|
margin: 0;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
</style>
|