From f49adaccc8f9c22e3d84d7dcfa7448ca70e4ec73 Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Thu, 20 Feb 2025 19:05:18 +0100 Subject: [PATCH] Remove commented out code --- src/views/conflicts-resolution/component.tsx | 247 ------------------- 1 file changed, 247 deletions(-) diff --git a/src/views/conflicts-resolution/component.tsx b/src/views/conflicts-resolution/component.tsx index 0700545..91281f2 100644 --- a/src/views/conflicts-resolution/component.tsx +++ b/src/views/conflicts-resolution/component.tsx @@ -147,251 +147,4 @@ const DiffView: React.FC = ({ ); }; -// const DiffView: React.FC = ({ oldText, newText, onResolve }) => { -// const [originalEditorView, setOriginalEditorView] = -// useState(null); -// const [modifiedEditorView, setModifiedEditorView] = -// useState(null); - -// const containerRef = useRef(null); -// const editorViewsRef = useRef([]); - -// useEffect(() => { -// if (!containerRef.current) return; - -// const createEditor = ( -// container: HTMLElement, -// content: string, -// readOnly: boolean = false, -// isOriginal: boolean = false, -// ) => { -// const differences = diff(oldText || "", newText || ""); - -// const highlightPlugin = createDiffHighlightPlugin({ -// diff: differences, -// isOriginal, -// }); - -// const changeListener = !readOnly -// ? [ -// EditorView.updateListener.of((update) => { -// if (update.docChanged) { -// onResolve(update.state.doc.toString()); -// } -// }), -// ] -// : []; - -// const editorState = EditorState.create({ -// doc: content, -// extensions: [ -// // basicSetup minus line numbers -// EditorView.lineWrapping, -// EditorView.editable.of(!readOnly), -// highlightPlugin, -// EditorView.theme({ -// "&": { -// backgroundColor: "var(--background-primary)", -// color: "var(--text-normal)", -// }, -// ".cm-line": { -// padding: "0 4px", -// }, -// "&.cm-focused .cm-selectionBackground, .cm-selectionBackground": { -// background: "var(--text-selection)", -// }, -// "&.cm-focused .cm-cursor": { -// borderLeftColor: "var(--text-normal)", -// }, -// }), -// markdown(), -// ...changeListener, -// ], -// }); - -// const view = new EditorView({ -// state: editorState, -// parent: container, -// }); - -// if (isOriginal) { -// setOriginalEditorView(view); -// } else if (readOnly) { -// setModifiedEditorView(view); -// } - -// editorViewsRef.current.push(view); -// return view; -// }; - -// // Create the three editors -// const originalView = createEditor( -// containerRef.current.querySelector(".original-editor")!, -// oldText, -// true, -// true, -// ); - -// const modifiedView = createEditor( -// containerRef.current.querySelector(".modified-editor")!, -// newText, -// true, -// false, -// ); - -// const resultView = createEditor( -// containerRef.current.querySelector(".result-editor")!, -// newText, -// false, -// ); - -// return () => { -// editorViewsRef.current.forEach((view) => view.destroy()); -// editorViewsRef.current = []; -// }; -// }, [oldText, newText]); - -// const handleMerge = (direction: "left" | "right", chunk: ConnectionChunk) => { -// if (!originalEditorView || !modifiedEditorView) { -// return; -// } - -// const sourceEditor = -// direction === "left" ? modifiedEditorView : originalEditorView; -// const targetEditor = -// direction === "left" ? originalEditorView : modifiedEditorView; - -// const sourceLine = -// direction === "left" ? chunk.targetStartLine : chunk.startLine; -// const sourceEndLine = -// direction === "left" ? chunk.targetEndLine : chunk.endLine; -// const targetLine = -// direction === "left" ? chunk.startLine : chunk.targetStartLine; -// const targetEndLine = -// direction === "left" ? chunk.endLine : chunk.targetEndLine; - -// const sourceDoc = sourceEditor.state.doc; -// const targetDoc = targetEditor.state.doc; - -// // Handle source content -// let contentToInsert = ""; -// if (sourceLine > sourceDoc.lines) { -// // Adding new lines at the end -// contentToInsert = "\n" + chunk.content.join("\n"); -// } else { -// const sourceFrom = sourceDoc.line(sourceLine).from; -// const sourceTo = -// sourceEndLine <= sourceDoc.lines -// ? sourceDoc.line(sourceEndLine).to -// : sourceDoc.length; -// contentToInsert = sourceEditor.state.sliceDoc(sourceFrom, sourceTo); -// } - -// // Handle target position -// let targetFrom = 0; -// let targetTo = 0; - -// if (targetLine > targetDoc.lines) { -// // Appending to end of file -// targetFrom = targetTo = targetDoc.length; -// if (!contentToInsert.startsWith("\n") && targetDoc.length > 0) { -// contentToInsert = "\n" + contentToInsert; -// } -// } else { -// targetFrom = targetDoc.line(targetLine).from; -// targetTo = -// targetEndLine <= targetDoc.lines -// ? targetDoc.line(targetEndLine).to -// : targetDoc.length; -// } - -// // Apply the change -// const change = { -// from: targetFrom, -// to: targetTo, -// insert: contentToInsert, -// }; - -// targetEditor.dispatch({ changes: change }); - -// // Update result editor if it exists -// // if (resultEditor) { -// // const resultDoc = resultEditor.state.doc; -// // let resultFrom = targetFrom; -// // let resultTo = targetTo; - -// // // Handle case where result editor might have different content length -// // if (resultFrom > resultDoc.length) { -// // resultFrom = resultTo = resultDoc.length; -// // if (!contentToInsert.startsWith("\n") && resultDoc.length > 0) { -// // contentToInsert = "\n" + contentToInsert; -// // } -// // } - -// // resultEditor.dispatch({ -// // changes: { -// // from: resultFrom, -// // to: resultTo, -// // insert: contentToInsert, -// // }, -// // }); -// // } - -// // Notify parent -// onResolve(targetEditor.state.doc.toString()); -// }; - -// return ( -//
-//
-//
-// -//
-//
-//
-//
-// ); -// }; - export default DiffView;