feat(tikz): implement undo functionality and clean up TikZ output generation

This commit is contained in:
JK 2026-06-14 09:18:41 +02:00
parent 416e4fa987
commit 1642b5cd76
2 changed files with 7 additions and 4 deletions

View file

@ -530,6 +530,12 @@ export class TikzEditorModal extends Modal implements TikzEditorContext {
return;
}
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'z') {
e.preventDefault();
this.handleUndo();
return;
}
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'c') {
e.preventDefault();
const uniqueIds = Array.from(new Set(this.selectedVertices.map(v => v.elementId)));

View file

@ -305,10 +305,7 @@ export class TikzCodec {
public generate(elements: EditorElement[], pictureOptions: string): string {
let output = '';
output += `\\begin{tikzpicture}${pictureOptions}\n`;
const stateObj = { elements, pictureOptions };
output += ` % [ObsiTeXState:${JSON.stringify(stateObj)}]\n\n`;
output += `\\begin{tikzpicture}${pictureOptions}\n\n`;
elements.forEach(elem => {
const xVal = this.fromCanvasX(elem.x).toFixed(2);