mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-25 01:06:15 -04:00
feat(new tool): text diff and comparator (#588)
* feat(new tool): text diff and comparator * chore(ci): increased memory in CI
This commit is contained in:
parent
a9cd91ca9c
commit
81bfe57cb8
8 changed files with 127 additions and 37 deletions
68
src/ui/c-diff-editor/c-diff-editor.vue
Normal file
68
src/ui/c-diff-editor/c-diff-editor.vue
Normal file
|
@ -0,0 +1,68 @@
|
|||
<script setup lang="ts">
|
||||
import * as monaco from 'monaco-editor';
|
||||
import { useStyleStore } from '@/stores/style.store';
|
||||
|
||||
const props = withDefaults(defineProps<{ options?: monaco.editor.IDiffEditorOptions }>(), { options: () => ({}) });
|
||||
const { options } = toRefs(props);
|
||||
|
||||
const editorContainer = ref<HTMLElement | null>(null);
|
||||
let editor: monaco.editor.IStandaloneDiffEditor | null = null;
|
||||
|
||||
monaco.editor.defineTheme('it-tools-dark', {
|
||||
base: 'vs-dark',
|
||||
inherit: true,
|
||||
rules: [],
|
||||
colors: {
|
||||
'editor.background': '#00000000',
|
||||
},
|
||||
});
|
||||
|
||||
monaco.editor.defineTheme('it-tools-light', {
|
||||
base: 'vs',
|
||||
inherit: true,
|
||||
rules: [],
|
||||
colors: {
|
||||
'editor.background': '#00000000',
|
||||
},
|
||||
});
|
||||
|
||||
const styleStore = useStyleStore();
|
||||
|
||||
watch(
|
||||
() => styleStore.isDarkTheme,
|
||||
isDarkTheme => monaco.editor.setTheme(isDarkTheme ? 'it-tools-dark' : 'it-tools-light'),
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
() => options.value,
|
||||
options => editor?.updateOptions(options),
|
||||
{ immediate: true, deep: true },
|
||||
);
|
||||
|
||||
useResizeObserver(editorContainer, () => {
|
||||
editor?.layout();
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
if (!editorContainer.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
editor = monaco.editor.createDiffEditor(editorContainer.value, {
|
||||
originalEditable: true,
|
||||
minimap: {
|
||||
enabled: false,
|
||||
},
|
||||
});
|
||||
|
||||
editor.setModel({
|
||||
original: monaco.editor.createModel('original text', 'txt'),
|
||||
modified: monaco.editor.createModel('modified text', 'txt'),
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div ref="editorContainer" h-600px />
|
||||
</template>
|
Loading…
Add table
Add a link
Reference in a new issue