ide-assi 0.436.0 → 0.438.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.cjs.js +175 -141
- package/dist/bundle.esm.js +175 -141
- package/dist/components/ideDiff.js +168 -146
- package/package.json +1 -1
- package/src/components/ideDiff.js +168 -146
package/dist/bundle.esm.js
CHANGED
|
@@ -223557,6 +223557,13 @@ const defaultKeymap = /*@__PURE__*/[
|
|
|
223557
223557
|
{ key: "Alt-A", run: toggleBlockComment },
|
|
223558
223558
|
{ key: "Ctrl-m", mac: "Shift-Alt-m", run: toggleTabFocusMode },
|
|
223559
223559
|
].concat(standardKeymap);
|
|
223560
|
+
/**
|
|
223561
|
+
A binding that binds Tab to [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) and
|
|
223562
|
+
Shift-Tab to [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess).
|
|
223563
|
+
Please see the [Tab example](../../examples/tab/) before using
|
|
223564
|
+
this.
|
|
223565
|
+
*/
|
|
223566
|
+
const indentWithTab = { key: "Tab", run: indentMore, shift: indentLess };
|
|
223560
223567
|
|
|
223561
223568
|
const basicNormalize = typeof String.prototype.normalize == "function"
|
|
223562
223569
|
? x => x.normalize("NFKD") : x => x;
|
|
@@ -234851,8 +234858,71 @@ const tobeDiffDecorations = StateField.define({
|
|
|
234851
234858
|
});
|
|
234852
234859
|
|
|
234853
234860
|
|
|
234854
|
-
|
|
234861
|
+
// IdeDiff 클래스 외부 (파일 상단 or 하단)에 추가
|
|
234862
|
+
class MergeButtonWidget extends WidgetType {
|
|
234863
|
+
// ⭐️ diffRange는 변경이 발생할 대상 에디터의 범위입니다.
|
|
234864
|
+
// ⭐️ isAsisButton: ASIS 에디터 쪽에 붙는 버튼인가? (true면 ASIS -> TOBE 적용)
|
|
234865
|
+
// ⭐️ isAsisButton이 false면 TOBE 에디터 쪽에 붙는 버튼 (TOBE -> ASIS 되돌리기)
|
|
234866
|
+
constructor(isAsisButton, textToApply, targetEditorView, diffRange, hostComponent) {
|
|
234867
|
+
super();
|
|
234868
|
+
this.isAsisButton = isAsisButton; // 이 버튼이 ASIS 에디터에 붙는 버튼인가 (true) TOBE 에디터에 붙는 버튼인가 (false)
|
|
234869
|
+
this.textToApply = textToApply; // 적용할 텍스트
|
|
234870
|
+
this.targetEditorView = targetEditorView; // 텍스트를 적용할 에디터 뷰 (상대편 에디터)
|
|
234871
|
+
this.diffRange = diffRange; // 대상 에디터에서 변경이 일어날 정확한 from/to 오프셋
|
|
234872
|
+
this.hostComponent = hostComponent; // IdeDiff 인스턴스 참조
|
|
234873
|
+
}
|
|
234874
|
+
|
|
234875
|
+
// 위젯이 차지할 공간을 텍스트 줄에 할당할지 여부. false로 설정하여 버튼이 줄 사이에 끼어들지 않도록 함.
|
|
234876
|
+
eq(other) { return false; }
|
|
234877
|
+
|
|
234878
|
+
// 위젯의 DOM 요소를 생성합니다.
|
|
234879
|
+
toDOM(view) {
|
|
234880
|
+
const button = document.createElement("button");
|
|
234881
|
+
// 버튼 클래스 및 텍스트는 버튼의 위치(ASIS/TOBE)에 따라 결정됩니다.
|
|
234882
|
+
button.className = `cm-merge-button ${this.isAsisButton ? 'accept' : 'revert'}`;
|
|
234883
|
+
button.textContent = this.isAsisButton ? "→ 적용" : "← 되돌리기"; // ASIS 버튼: TOBE로 적용, TOBE 버튼: ASIS로 되돌리기
|
|
234884
|
+
|
|
234885
|
+
// 클릭 이벤트 핸들러
|
|
234886
|
+
button.addEventListener("click", () => {
|
|
234887
|
+
console.log(`버튼 클릭: ${this.isAsisButton ? 'ASIS -> TOBE' : 'TOBE -> ASIS'}`, this.textToApply);
|
|
234888
|
+
console.log("대상 에디터:", this.targetEditorView === this.hostComponent.asisEditorView ? "ASIS" : "TOBE");
|
|
234889
|
+
console.log("대상 범위:", this.diffRange);
|
|
234890
|
+
|
|
234891
|
+
this.applyChanges(this.textToApply, this.targetEditorView, this.diffRange);
|
|
234892
|
+
});
|
|
234893
|
+
|
|
234894
|
+
const container = document.createElement("div");
|
|
234895
|
+
container.className = "cm-merge-button-container";
|
|
234896
|
+
container.appendChild(button);
|
|
234897
|
+
return container;
|
|
234898
|
+
}
|
|
234899
|
+
|
|
234900
|
+
// 실제 변경 적용 로직
|
|
234901
|
+
applyChanges(text, editorView, range) {
|
|
234902
|
+
if (!editorView || !range) {
|
|
234903
|
+
console.error("Target editor view or range is undefined.", editorView, range);
|
|
234904
|
+
return;
|
|
234905
|
+
}
|
|
234906
|
+
|
|
234907
|
+
editorView.dispatch({
|
|
234908
|
+
changes: {
|
|
234909
|
+
from: range.from,
|
|
234910
|
+
to: range.to,
|
|
234911
|
+
insert: text
|
|
234912
|
+
}
|
|
234913
|
+
});
|
|
234914
|
+
|
|
234915
|
+
// 변경 후 Diff를 다시 계산하고 데코레이션을 업데이트합니다.
|
|
234916
|
+
// requestAnimationFrame으로 감싸서 다음 렌더링 사이클에서 Diff 계산이 이루어지도록 합니다.
|
|
234917
|
+
// 이렇게 하면 UI 블로킹을 줄일 수 있습니다.
|
|
234918
|
+
requestAnimationFrame(() => {
|
|
234919
|
+
this.hostComponent.recalculateDiff();
|
|
234920
|
+
});
|
|
234921
|
+
}
|
|
234922
|
+
}
|
|
234855
234923
|
|
|
234924
|
+
|
|
234925
|
+
class IdeDiff extends HTMLElement {
|
|
234856
234926
|
#asisEditorView;
|
|
234857
234927
|
#tobeEditorView;
|
|
234858
234928
|
#asisEditorEl;
|
|
@@ -234865,17 +234935,79 @@ class IdeDiff extends HTMLElement {
|
|
|
234865
234935
|
_tobeScrollHandler = null;
|
|
234866
234936
|
|
|
234867
234937
|
|
|
234938
|
+
get asisEditorView() {
|
|
234939
|
+
return this.#asisEditorView;
|
|
234940
|
+
};
|
|
234941
|
+
|
|
234868
234942
|
constructor() {
|
|
234869
234943
|
super();
|
|
234870
234944
|
this.attachShadow({ mode: 'open' });
|
|
234871
234945
|
}
|
|
234872
234946
|
|
|
234947
|
+
|
|
234948
|
+
|
|
234873
234949
|
connectedCallback() {
|
|
234874
234950
|
this.shadowRoot.innerHTML = `
|
|
234875
234951
|
<style>
|
|
234876
234952
|
/* ninegrid CSS 및 필요한 기본 스타일 */
|
|
234877
234953
|
@import "https://cdn.jsdelivr.net/npm/ninegrid@${ninegrid.version}/dist/css/ideDiff.css";
|
|
234878
234954
|
${ninegrid.getCustomPath(this, "ideDiff.css")}
|
|
234955
|
+
|
|
234956
|
+
/* --- 추가된 CSS 규칙 (버튼 및 선택 관련) --- */
|
|
234957
|
+
.cm-line {
|
|
234958
|
+
position: relative;
|
|
234959
|
+
}
|
|
234960
|
+
.cm-merge-button-container {
|
|
234961
|
+
position: absolute;
|
|
234962
|
+
right: 5px;
|
|
234963
|
+
top: 50%;
|
|
234964
|
+
transform: translateY(-50%);
|
|
234965
|
+
z-index: 10;
|
|
234966
|
+
display: flex;
|
|
234967
|
+
gap: 5px;
|
|
234968
|
+
}
|
|
234969
|
+
.cm-merge-button {
|
|
234970
|
+
background-color: #f0f0f0;
|
|
234971
|
+
border: 1px solid #ccc;
|
|
234972
|
+
border-radius: 3px;
|
|
234973
|
+
padding: 2px 6px;
|
|
234974
|
+
cursor: pointer;
|
|
234975
|
+
font-size: 0.8em;
|
|
234976
|
+
line-height: 1;
|
|
234977
|
+
white-space: nowrap;
|
|
234978
|
+
opacity: 0.7;
|
|
234979
|
+
transition: opacity 0.2s ease-in-out;
|
|
234980
|
+
}
|
|
234981
|
+
.cm-merge-button:hover {
|
|
234982
|
+
opacity: 1;
|
|
234983
|
+
background-color: #e0e0e0;
|
|
234984
|
+
}
|
|
234985
|
+
.cm-merge-button.accept {
|
|
234986
|
+
background-color: #4CAF50;
|
|
234987
|
+
color: white;
|
|
234988
|
+
border-color: #4CAF50;
|
|
234989
|
+
}
|
|
234990
|
+
.cm-merge-button.revert {
|
|
234991
|
+
background-color: #f44336;
|
|
234992
|
+
color: white;
|
|
234993
|
+
border-color: #f44336;
|
|
234994
|
+
}
|
|
234995
|
+
/* Diff 데코레이션 CSS (ideDiff.css에 없으면 여기에 추가) */
|
|
234996
|
+
.cm-inserted-line-bg { background-color: #e6ffed; border-left: 3px solid #66bb6a; }
|
|
234997
|
+
.cm-deleted-line-bg { background-color: #ffebe9; border-left: 3px solid #ef5350; }
|
|
234998
|
+
|
|
234999
|
+
/* CodeMirror 선택 스타일 (ideDiff.css에 없으면 여기에 추가) */
|
|
235000
|
+
.cm-selectionBackground {
|
|
235001
|
+
background-color: #d7d4f9 !important;
|
|
235002
|
+
}
|
|
235003
|
+
.cm-editor ::selection {
|
|
235004
|
+
background-color: #d7d4f9 !important;
|
|
235005
|
+
color: inherit !important;
|
|
235006
|
+
}
|
|
235007
|
+
.cm-editor::-moz-selection {
|
|
235008
|
+
background-color: #d7d4f9 !important;
|
|
235009
|
+
color: inherit !important;
|
|
235010
|
+
}
|
|
234879
235011
|
</style>
|
|
234880
235012
|
|
|
234881
235013
|
<div class="wrapper">
|
|
@@ -234921,7 +235053,7 @@ class IdeDiff extends HTMLElement {
|
|
|
234921
235053
|
drawSelection(),
|
|
234922
235054
|
dropCursor(),
|
|
234923
235055
|
EditorState.allowMultipleSelections.of(true),
|
|
234924
|
-
indentOnInput(),
|
|
235056
|
+
indentOnInput(),
|
|
234925
235057
|
bracketMatching(),
|
|
234926
235058
|
highlightActiveLine(),
|
|
234927
235059
|
highlightActiveLineGutter(),
|
|
@@ -234932,11 +235064,11 @@ class IdeDiff extends HTMLElement {
|
|
|
234932
235064
|
...historyKeymap,
|
|
234933
235065
|
...lintKeymap,
|
|
234934
235066
|
...completionKeymap,
|
|
234935
|
-
|
|
234936
|
-
|
|
235067
|
+
indentWithTab, // ⭐️ 함수가 아닌 확장 자체를 전달
|
|
235068
|
+
selectAll // ⭐️ 함수가 아닌 확장 자체를 전달
|
|
234937
235069
|
]),
|
|
234938
|
-
syntaxHighlighting(defaultHighlightStyle),
|
|
234939
|
-
autocompletion(),
|
|
235070
|
+
syntaxHighlighting(defaultHighlightStyle),
|
|
235071
|
+
autocompletion(),
|
|
234940
235072
|
];
|
|
234941
235073
|
|
|
234942
235074
|
// ASIS 에디터 뷰 초기화
|
|
@@ -234945,9 +235077,9 @@ class IdeDiff extends HTMLElement {
|
|
|
234945
235077
|
doc: '',
|
|
234946
235078
|
extensions: [
|
|
234947
235079
|
basicExtensions,
|
|
234948
|
-
this.#languageCompartment.of(javascript()),
|
|
234949
|
-
EditorState.readOnly.of(true),
|
|
234950
|
-
asisDiffDecorations,
|
|
235080
|
+
this.#languageCompartment.of(javascript()),
|
|
235081
|
+
EditorState.readOnly.of(true), // ASIS는 읽기 전용 유지
|
|
235082
|
+
asisDiffDecorations,
|
|
234951
235083
|
EditorView.updateListener.of((update) => {
|
|
234952
235084
|
if (update.view.contentDOM.firstChild && !update.view._initialAsisContentLoaded) {
|
|
234953
235085
|
update.view._initialAsisContentLoaded = true;
|
|
@@ -234965,9 +235097,9 @@ class IdeDiff extends HTMLElement {
|
|
|
234965
235097
|
doc: '',
|
|
234966
235098
|
extensions: [
|
|
234967
235099
|
basicExtensions,
|
|
234968
|
-
this.#languageCompartment.of(javascript()),
|
|
234969
|
-
//EditorState.readOnly.of(true),
|
|
234970
|
-
tobeDiffDecorations,
|
|
235100
|
+
this.#languageCompartment.of(javascript()),
|
|
235101
|
+
// EditorState.readOnly.of(true), // TOBE는 편집 가능하도록 주석 처리 유지
|
|
235102
|
+
tobeDiffDecorations,
|
|
234971
235103
|
EditorView.updateListener.of((update) => {
|
|
234972
235104
|
if (update.view.contentDOM.firstChild && !update.view._initialTobeContentLoaded) {
|
|
234973
235105
|
update.view._initialTobeContentLoaded = true;
|
|
@@ -235020,96 +235152,66 @@ class IdeDiff extends HTMLElement {
|
|
|
235020
235152
|
#applyDiffDecorations = (asisSrc, tobeSrc) => {
|
|
235021
235153
|
const dmp = new diffMatchPatchExports.diff_match_patch();
|
|
235022
235154
|
|
|
235023
|
-
// dmp의 기본 cleanupThreshold를 줄여서 더 세밀한 차이를 감지하도록 시도
|
|
235024
|
-
// 기본값은 0.5인데, 0으로 하면 더 많은 변화를 감지할 수 있습니다.
|
|
235025
|
-
// 하지만 너무 낮추면 노이즈가 많아질 수 있습니다.
|
|
235026
|
-
// dmp.Diff_EditCost = 4; // 편집 비용 조정, 기본 4
|
|
235027
|
-
// dmp.Diff_DualThreshold = 0.5; // 불명확한 Diff에 대한 임계값. 기본 0.5
|
|
235028
|
-
// dmp.Diff_Timeout = 1.0; // 타임아웃, 기본 1.0
|
|
235029
|
-
|
|
235030
|
-
// 텍스트를 줄 단위로 변환하여 Diff 수행
|
|
235031
235155
|
const a = dmp.diff_linesToChars_(asisSrc, tobeSrc);
|
|
235032
235156
|
const lineText1 = a.chars1;
|
|
235033
235157
|
const lineText2 = a.chars2;
|
|
235034
235158
|
const lineArray = a.lineArray;
|
|
235035
235159
|
|
|
235036
|
-
// dmp.diff_main(text1, text2, checklines, deadline)
|
|
235037
|
-
// checklines: true (기본값)는 줄 단위 최적화, false는 문자 단위로.
|
|
235038
|
-
// 여기서는 diff_linesToChars_를 사용했으므로 true가 적절.
|
|
235039
235160
|
const diffs = dmp.diff_main(lineText1, lineText2, true);
|
|
235040
|
-
|
|
235041
|
-
// cleanupEfficiency를 먼저 적용하여 효율적인 Diff를 만듭니다.
|
|
235042
|
-
// 이는 작은 변경사항이 인접해 있을 때 하나의 큰 변경으로 합치는 경향이 있습니다.
|
|
235043
|
-
// dmp.diff_cleanupEfficiency(diffs); // 오히려 이동을 놓칠 수 있음
|
|
235044
|
-
|
|
235045
|
-
// 그 다음 의미론적 정리를 적용합니다.
|
|
235046
235161
|
dmp.diff_cleanupSemantic(diffs);
|
|
235047
|
-
|
|
235048
|
-
// 다시 문자열로 변환
|
|
235049
235162
|
dmp.diff_charsToLines_(diffs, lineArray);
|
|
235050
235163
|
|
|
235051
|
-
console.log(diffs);
|
|
235164
|
+
console.log("Calculated Diffs:", diffs); // Diff 결과 확인용
|
|
235052
235165
|
|
|
235053
235166
|
const asisLineBuilder = new RangeSetBuilder();
|
|
235054
235167
|
const tobeLineBuilder = new RangeSetBuilder();
|
|
235055
235168
|
|
|
235056
|
-
let asisCursor = 0;
|
|
235057
|
-
let tobeCursor = 0;
|
|
235169
|
+
let asisCursor = 0; // ASIS 텍스트에서의 현재 오프셋
|
|
235170
|
+
let tobeCursor = 0; // TOBE 텍스트에서의 현재 오프셋
|
|
235058
235171
|
|
|
235059
|
-
// 변경된 줄에 대한 새로운 데코레이션 클래스를 추가할 수 있습니다.
|
|
235060
235172
|
const insertedLineDeco = Decoration.line({ class: "cm-inserted-line-bg" });
|
|
235061
235173
|
const deletedLineDeco = Decoration.line({ class: "cm-deleted-line-bg" });
|
|
235062
|
-
// const changedLineDeco = Decoration.line({ class: "cm-changed-line-bg" }); // 필요하다면
|
|
235063
235174
|
|
|
235064
|
-
// ⭐️ IdeDiff 인스턴스에 대한 참조를 위젯에 넘겨주기 위해 임시 변수 사용
|
|
235065
|
-
// 실제로는 Closure나 Bound method로 넘겨줄 수 있음
|
|
235066
235175
|
const currentInstance = this;
|
|
235067
235176
|
|
|
235068
235177
|
for (const [op, text] of diffs) {
|
|
235069
235178
|
const len = text.length;
|
|
235070
235179
|
|
|
235071
|
-
//
|
|
235072
|
-
const
|
|
235073
|
-
const
|
|
235180
|
+
// 각 diff op 이전에 현재 커서 위치를 저장
|
|
235181
|
+
const asisRangeStart = asisCursor;
|
|
235182
|
+
const tobeRangeStart = tobeCursor;
|
|
235074
235183
|
|
|
235075
235184
|
switch (op) {
|
|
235076
|
-
case diffMatchPatchExports.diff_match_patch.DIFF_INSERT:
|
|
235077
|
-
console.log(
|
|
235185
|
+
case diffMatchPatchExports.diff_match_patch.DIFF_INSERT: // TOBE에 추가된 내용 (ASIS에는 없음)
|
|
235186
|
+
console.log("DIFF_INSERT (TOBE added):", JSON.stringify(text));
|
|
235078
235187
|
const tobeLines = text.split('\n');
|
|
235079
|
-
|
|
235080
235188
|
for (let i = 0; i < tobeLines.length; i++) {
|
|
235081
|
-
// 빈 줄이 아니고, 마지막 줄이면서 줄바꿈이 없는 경우가 아니면 데코레이션
|
|
235082
|
-
/**
|
|
235083
|
-
if (!(i === tobeLines.length - 1 && tobeLines[i] === '' && !text.endsWith('\n'))) {
|
|
235084
|
-
tobeLineBuilder.add(tobeCursor, tobeCursor, insertedLineDeco);
|
|
235085
|
-
}
|
|
235086
|
-
tobeCursor += tobeLines[i].length + (i < tobeLines.length - 1 ? 1 : 0);
|
|
235087
|
-
*/
|
|
235088
235189
|
if (!(i === tobeLines.length - 1 && tobeLines[i] === '' && text.endsWith('\n'))) {
|
|
235089
235190
|
tobeLineBuilder.add(tobeCursor, tobeCursor, insertedLineDeco);
|
|
235090
235191
|
}
|
|
235091
235192
|
tobeCursor += tobeLines[i].length + (i < tobeLines.length - 1 ? 1 : 0);
|
|
235092
235193
|
}
|
|
235093
235194
|
|
|
235195
|
+
// ⭐️ TOBE 에디터에 버튼 추가: TOBE의 추가 내용을 ASIS로 '되돌리기' (ASIS에서 삭제)
|
|
235196
|
+
// 즉, TOBE에서 삽입된 내용을 ASIS에서 '없애는' 작업
|
|
235094
235197
|
tobeLineBuilder.add(
|
|
235095
|
-
|
|
235096
|
-
|
|
235198
|
+
tobeRangeStart, // TOBE에서의 해당 Diff 청크 시작 오프셋
|
|
235199
|
+
tobeRangeStart,
|
|
235097
235200
|
Decoration.widget({
|
|
235098
|
-
widget:
|
|
235099
|
-
|
|
235100
|
-
|
|
235101
|
-
|
|
235102
|
-
|
|
235103
|
-
|
|
235104
|
-
|
|
235105
|
-
),
|
|
235201
|
+
widget: new MergeButtonWidget(
|
|
235202
|
+
false, // 이 버튼은 TOBE 에디터에 붙는 버튼 (되돌리기)
|
|
235203
|
+
"", // 텍스트를 ""로 삽입하면 삭제 효과 (ASIS에서 없앨 내용)
|
|
235204
|
+
currentInstance.#asisEditorView, // 대상 에디터는 ASIS
|
|
235205
|
+
{ from: asisRangeStart, to: asisRangeStart + 0 }, // ASIS에서의 대상 범위 (삽입 지점)
|
|
235206
|
+
currentInstance
|
|
235207
|
+
),
|
|
235106
235208
|
side: 1 // 텍스트 뒤에 삽입
|
|
235107
235209
|
})
|
|
235108
235210
|
);
|
|
235109
235211
|
break;
|
|
235110
235212
|
|
|
235111
|
-
case diffMatchPatchExports.diff_match_patch.DIFF_DELETE:
|
|
235112
|
-
console.log(
|
|
235213
|
+
case diffMatchPatchExports.diff_match_patch.DIFF_DELETE: // ASIS에서 삭제된 내용 (TOBE에는 없음)
|
|
235214
|
+
console.log("DIFF_DELETE (ASIS deleted):", JSON.stringify(text));
|
|
235113
235215
|
const asisLines = text.split('\n');
|
|
235114
235216
|
for (let i = 0; i < asisLines.length; i++) {
|
|
235115
235217
|
if (!(i === asisLines.length - 1 && asisLines[i] === '' && text.endsWith('\n'))) {
|
|
@@ -235118,30 +235220,28 @@ class IdeDiff extends HTMLElement {
|
|
|
235118
235220
|
asisCursor += asisLines[i].length + (i < asisLines.length - 1 ? 1 : 0);
|
|
235119
235221
|
}
|
|
235120
235222
|
|
|
235121
|
-
// ⭐️ ASIS
|
|
235223
|
+
// ⭐️ ASIS 에디터에 버튼 추가: ASIS의 삭제 내용을 TOBE로 '적용' (TOBE에 삽입)
|
|
235224
|
+
// 즉, ASIS에서 삭제된 내용을 TOBE에 '넣는' 작업
|
|
235122
235225
|
asisLineBuilder.add(
|
|
235123
|
-
|
|
235124
|
-
|
|
235226
|
+
asisRangeStart, // ASIS에서의 해당 Diff 청크 시작 오프셋
|
|
235227
|
+
asisRangeStart,
|
|
235125
235228
|
Decoration.widget({
|
|
235126
235229
|
widget: new MergeButtonWidget(
|
|
235127
|
-
true, // ASIS
|
|
235128
|
-
text,
|
|
235129
|
-
currentInstance.#tobeEditorView //
|
|
235230
|
+
true, // 이 버튼은 ASIS 에디터에 붙는 버튼 (적용)
|
|
235231
|
+
text, // ASIS에서 삭제된 내용을 TOBE에 삽입
|
|
235232
|
+
currentInstance.#tobeEditorView, // 대상 에디터는 TOBE
|
|
235233
|
+
{ from: tobeRangeStart, to: tobeRangeStart + 0 }, // TOBE에서의 대상 범위 (삽입 지점)
|
|
235234
|
+
currentInstance
|
|
235130
235235
|
),
|
|
235131
235236
|
side: 1 // 텍스트 뒤에 삽입
|
|
235132
235237
|
})
|
|
235133
235238
|
);
|
|
235134
|
-
|
|
235135
235239
|
break;
|
|
235136
235240
|
|
|
235137
|
-
case diffMatchPatchExports.diff_match_patch.DIFF_EQUAL:
|
|
235241
|
+
case diffMatchPatchExports.diff_match_patch.DIFF_EQUAL: // 동일한 내용
|
|
235138
235242
|
asisCursor += len;
|
|
235139
235243
|
tobeCursor += len;
|
|
235140
235244
|
break;
|
|
235141
|
-
|
|
235142
|
-
default:
|
|
235143
|
-
console.log(op);
|
|
235144
|
-
break;
|
|
235145
235245
|
}
|
|
235146
235246
|
}
|
|
235147
235247
|
|
|
@@ -235151,7 +235251,6 @@ class IdeDiff extends HTMLElement {
|
|
|
235151
235251
|
};
|
|
235152
235252
|
};
|
|
235153
235253
|
|
|
235154
|
-
// IdeDiff 클래스 내부에 변경 후 Diff를 다시 계산하는 메서드 추가
|
|
235155
235254
|
recalculateDiff = () => {
|
|
235156
235255
|
const asisDoc = this.#asisEditorView.state.doc.toString();
|
|
235157
235256
|
const tobeDoc = this.#tobeEditorView.state.doc.toString();
|
|
@@ -235214,71 +235313,6 @@ class IdeDiff extends HTMLElement {
|
|
|
235214
235313
|
};
|
|
235215
235314
|
}
|
|
235216
235315
|
|
|
235217
|
-
// IdeDiff 클래스 외부 (파일 상단 or 하단)에 추가
|
|
235218
|
-
class MergeButtonWidget extends WidgetType {
|
|
235219
|
-
constructor(isAsis, textToApply, targetEditorView, diffRange, hostComponent) {
|
|
235220
|
-
super();
|
|
235221
|
-
this.isAsis = isAsis; // ASIS 쪽 버튼인지 (true) TOBE 쪽 버튼인지 (false)
|
|
235222
|
-
this.textToApply = textToApply; // 적용할 텍스트
|
|
235223
|
-
this.targetEditorView = targetEditorView; // 텍스트를 적용할 에디터 뷰
|
|
235224
|
-
this.diffRange = diffRange; // ⭐️ 추가된 속성
|
|
235225
|
-
this.hostComponent = hostComponent; // ⭐️ IdeDiff 인스턴스 참조
|
|
235226
|
-
}
|
|
235227
|
-
|
|
235228
|
-
// 위젯이 차지할 공간을 텍스트 줄에 할당할지 여부. false로 설정하여 버튼이 줄 사이에 끼어들지 않도록 함.
|
|
235229
|
-
eq(other) { return false; }
|
|
235230
|
-
|
|
235231
|
-
// 위젯의 DOM 요소를 생성합니다.
|
|
235232
|
-
toDOM(view) {
|
|
235233
|
-
const button = document.createElement("button");
|
|
235234
|
-
button.className = `cm-merge-button ${this.isAsis ? 'accept' : 'revert'}`;
|
|
235235
|
-
button.textContent = this.isAsis ? "→ 적용" : "← 되돌리기"; // 버튼 텍스트
|
|
235236
|
-
|
|
235237
|
-
// 클릭 이벤트 핸들러
|
|
235238
|
-
button.addEventListener("click", () => {
|
|
235239
|
-
// 이 로직은 나중에 구현할 `applyChanges` 메서드를 호출할 것입니다.
|
|
235240
|
-
// 지금은 콘솔에 로그만 남깁니다.
|
|
235241
|
-
console.log(`버튼 클릭: ${this.isAsis ? 'ASIS -> TOBE' : 'TOBE -> ASIS'}`, this.textToApply);
|
|
235242
|
-
|
|
235243
|
-
// 실제 변경 로직 (아래 applyChanges 메서드 구현 후 주석 해제)
|
|
235244
|
-
this.applyChanges(this.textToApply, this.targetEditorView);
|
|
235245
|
-
});
|
|
235246
|
-
|
|
235247
|
-
const container = document.createElement("div");
|
|
235248
|
-
container.className = "cm-merge-button-container";
|
|
235249
|
-
container.appendChild(button);
|
|
235250
|
-
return container;
|
|
235251
|
-
}
|
|
235252
|
-
|
|
235253
|
-
// 실제 변경 적용 로직
|
|
235254
|
-
applyChanges(text, editorView) {
|
|
235255
|
-
if (!editorView || !this.diffRange) {
|
|
235256
|
-
console.error("Target editor view or diffRange is undefined.");
|
|
235257
|
-
return;
|
|
235258
|
-
}
|
|
235259
|
-
|
|
235260
|
-
// ⭐️ 해당 오프셋 범위의 내용을 교체 (삽입 또는 삭제)
|
|
235261
|
-
editorView.dispatch({
|
|
235262
|
-
changes: {
|
|
235263
|
-
from: this.diffRange.from,
|
|
235264
|
-
to: this.diffRange.to, // 삭제될 범위
|
|
235265
|
-
insert: text // 삽입될 내용
|
|
235266
|
-
}
|
|
235267
|
-
});
|
|
235268
|
-
|
|
235269
|
-
// 변경 후 Diff를 다시 계산하고 데코레이션을 업데이트해야 합니다.
|
|
235270
|
-
// this.hostComponent.recalculateDiff(); 와 같은 메서드를 호출해야 함.
|
|
235271
|
-
// 이 부분은 IdeDiff 클래스 내에서 구현해야 합니다.
|
|
235272
|
-
// 일단은 콘솔 로그와 함께 작동하는지 확인합니다.
|
|
235273
|
-
console.log("Changes applied and diff recalculation needed!");
|
|
235274
|
-
|
|
235275
|
-
// 변경 후 Diff를 다시 계산하고 데코레이션을 업데이트합니다.
|
|
235276
|
-
this.hostComponent.recalculateDiff(); // ⭐️ hostComponent를 통해 메서드 호출
|
|
235277
|
-
}
|
|
235278
|
-
|
|
235279
|
-
|
|
235280
|
-
}
|
|
235281
|
-
|
|
235282
235316
|
customElements.define("ide-diff", IdeDiff);
|
|
235283
235317
|
|
|
235284
235318
|
//import "./components/ideAssi.js";
|