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.
105 lines
2.5 KiB
105 lines
2.5 KiB
4 years ago
|
<template>
|
||
|
<div>
|
||
|
<v-toolbar dense>
|
||
3 years ago
|
<v-spacer />
|
||
3 years ago
|
<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">
|
||
3 years ago
|
<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';
|
||
3 years ago
|
/// / optionally, include CSS, or use your own
|
||
3 years ago
|
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,
|
||
3 years ago
|
history: Array,
|
||
3 years ago
|
},
|
||
4 years ago
|
data: () => ({
|
||
|
differ: null,
|
||
|
index: 0,
|
||
3 years ago
|
editors: null,
|
||
4 years ago
|
}),
|
||
3 years ago
|
watch: {
|
||
3 years ago
|
index(i) {
|
||
3 years ago
|
if (this.editors) {
|
||
3 years ago
|
this.editors.right.setValue(this.history[i]);
|
||
3 years ago
|
}
|
||
3 years ago
|
},
|
||
4 years ago
|
},
|
||
3 years ago
|
mounted() {
|
||
4 years ago
|
this.differ = new AceDiff({
|
||
|
element: this.$refs.diff,
|
||
|
left: {
|
||
|
content: this.value,
|
||
3 years ago
|
copyLinkEnabled: false,
|
||
4 years ago
|
},
|
||
|
right: {
|
||
|
content: this.history[this.index],
|
||
3 years ago
|
editable: false,
|
||
4 years ago
|
},
|
||
3 years ago
|
diffGranularity: 'specific',
|
||
|
});
|
||
4 years ago
|
|
||
3 years ago
|
this.editors = this.differ.getEditors();
|
||
3 years ago
|
this.editors.left.on('change', () => {
|
||
3 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
|
},
|
||
3 years ago
|
next() {
|
||
3 years ago
|
if (this.index < this.history.length - 1) {
|
||
|
++this.index;
|
||
|
}
|
||
|
},
|
||
|
},
|
||
|
};
|
||
4 years ago
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
3 years ago
|
/deep/ *,
|
||
|
/deep/ div {
|
||
4 years ago
|
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/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|