mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
2.5 KiB
108 lines
2.5 KiB
4 years ago
|
<template>
|
||
|
<div>
|
||
|
<v-toolbar dense>
|
||
3 years ago
|
<v-spacer />
|
||
|
<v-btn outlined x-small :disabled="!index" @click="prev">
|
||
|
Prev
|
||
|
</v-btn>
|
||
|
<v-btn outlined x-small :disabled="index===history.length -1" @click="next">
|
||
|
Next
|
||
|
</v-btn>
|
||
4 years ago
|
</v-toolbar>
|
||
3 years ago
|
<div id="editor" style="height:500px; width:100%;position: relative">
|
||
|
<div ref="diff" />
|
||
4 years ago
|
</div>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
|
||
3 years ago
|
// import ace from 'ace-builds'
|
||
4 years ago
|
//
|
||
3 years ago
|
import AceDiff from 'ace-diff'
|
||
|
/// / optionally, include CSS, or use your own
|
||
|
import 'ace-diff/dist/ace-diff.min.css'
|
||
4 years ago
|
// Or use the dark mode
|
||
|
// import 'ace-diff/dist/ace-diff-dark.min.css';
|
||
|
|
||
|
export default {
|
||
3 years ago
|
name: 'XcDiff',
|
||
|
props: {
|
||
|
value: String,
|
||
|
history: Array
|
||
|
},
|
||
4 years ago
|
data: () => ({
|
||
|
differ: null,
|
||
|
index: 0,
|
||
|
editors: null
|
||
|
}),
|
||
3 years ago
|
watch: {
|
||
3 years ago
|
index(i) {
|
||
3 years ago
|
if (this.editors) {
|
||
|
this.editors.right.setValue(this.history[i])
|
||
|
}
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
mounted() {
|
||
4 years ago
|
this.differ = new AceDiff({
|
||
|
element: this.$refs.diff,
|
||
|
left: {
|
||
|
content: this.value,
|
||
|
copyLinkEnabled: false
|
||
|
},
|
||
|
right: {
|
||
|
content: this.history[this.index],
|
||
|
editable: false
|
||
|
},
|
||
3 years ago
|
diffGranularity: 'specific'
|
||
4 years ago
|
|
||
3 years ago
|
})
|
||
4 years ago
|
|
||
3 years ago
|
this.editors = this.differ.getEditors()
|
||
|
this.editors.left.on('change', () => {
|
||
4 years ago
|
this.$emit('input', this.editors.left.getValue())
|
||
|
})
|
||
3 years ago
|
},
|
||
|
methods: {
|
||
3 years ago
|
prev() {
|
||
3 years ago
|
this.index && --this.index
|
||
|
},
|
||
3 years ago
|
next() {
|
||
3 years ago
|
if (this.index < this.history.length - 1) { ++this.index }
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
/deep/ *, /deep/ div {
|
||
|
font-size: 12px !important;
|
||
|
font-family: monospace !important;
|
||
|
word-spacing: 0;
|
||
|
}
|
||
|
</style>
|
||
|
<!--
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Affero General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of the
|
||
|
* License, or (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Affero General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|