2017-04-11 13:50:21 -04:00
|
|
|
<script>
|
2018-10-10 02:27:42 -04:00
|
|
|
import { MarkdownCell, CodeCell } from './cells';
|
2017-04-11 13:50:21 -04:00
|
|
|
|
2018-10-10 02:27:42 -04:00
|
|
|
export default {
|
|
|
|
components: {
|
2019-01-11 05:14:51 -05:00
|
|
|
CodeCell,
|
|
|
|
MarkdownCell,
|
2018-10-10 02:27:42 -04:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
notebook: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
2017-04-11 13:50:21 -04:00
|
|
|
},
|
2018-10-10 02:27:42 -04:00
|
|
|
codeCssClass: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
2017-04-11 13:50:21 -04:00
|
|
|
},
|
2018-10-10 02:27:42 -04:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
cells() {
|
|
|
|
if (this.notebook.worksheets) {
|
|
|
|
const data = {
|
|
|
|
cells: [],
|
|
|
|
};
|
2017-04-11 13:50:21 -04:00
|
|
|
|
2018-10-10 02:27:42 -04:00
|
|
|
return this.notebook.worksheets.reduce((cellData, sheet) => {
|
|
|
|
const cellDataCopy = cellData;
|
|
|
|
cellDataCopy.cells = cellDataCopy.cells.concat(sheet.cells);
|
|
|
|
return cellDataCopy;
|
|
|
|
}, data).cells;
|
|
|
|
}
|
2017-04-11 13:50:21 -04:00
|
|
|
|
2018-10-10 02:27:42 -04:00
|
|
|
return this.notebook.cells;
|
2017-04-11 13:50:21 -04:00
|
|
|
},
|
2018-10-10 02:27:42 -04:00
|
|
|
hasNotebook() {
|
|
|
|
return Object.keys(this.notebook).length;
|
2018-01-04 19:18:35 -05:00
|
|
|
},
|
2018-10-10 02:27:42 -04:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
cellType(type) {
|
|
|
|
return `${type}-cell`;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2017-04-11 13:50:21 -04:00
|
|
|
</script>
|
|
|
|
|
2017-10-03 20:07:41 -04:00
|
|
|
<template>
|
|
|
|
<div v-if="hasNotebook">
|
|
|
|
<component
|
|
|
|
:is="cellType(cell.cell_type)"
|
2018-09-20 02:13:50 -04:00
|
|
|
v-for="(cell, index) in cells"
|
2017-10-03 20:07:41 -04:00
|
|
|
:key="index"
|
2018-09-20 02:13:50 -04:00
|
|
|
:cell="cell"
|
2018-11-16 15:07:38 -05:00
|
|
|
:code-css-class="codeCssClass"
|
|
|
|
/>
|
2017-10-03 20:07:41 -04:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2017-04-11 13:50:21 -04:00
|
|
|
<style>
|
|
|
|
.cell,
|
|
|
|
.input,
|
|
|
|
.output {
|
|
|
|
display: flex;
|
|
|
|
width: 100%;
|
|
|
|
margin-bottom: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.cell pre {
|
|
|
|
margin: 0;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
</style>
|