ide-assi 0.436.0 → 0.437.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 +169 -141
- package/dist/bundle.esm.js +169 -141
- package/dist/components/ideDiff.js +162 -146
- package/package.json +1 -1
- package/src/components/ideDiff.js +162 -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
|
+
}
|
|
234855
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
|
+
}
|
|
234923
|
+
|
|
234924
|
+
|
|
234925
|
+
class IdeDiff extends HTMLElement {
|
|
234856
234926
|
#asisEditorView;
|
|
234857
234927
|
#tobeEditorView;
|
|
234858
234928
|
#asisEditorEl;
|
|
@@ -234876,6 +234946,62 @@ class IdeDiff extends HTMLElement {
|
|
|
234876
234946
|
/* ninegrid CSS 및 필요한 기본 스타일 */
|
|
234877
234947
|
@import "https://cdn.jsdelivr.net/npm/ninegrid@${ninegrid.version}/dist/css/ideDiff.css";
|
|
234878
234948
|
${ninegrid.getCustomPath(this, "ideDiff.css")}
|
|
234949
|
+
|
|
234950
|
+
/* --- 추가된 CSS 규칙 (버튼 및 선택 관련) --- */
|
|
234951
|
+
.cm-line {
|
|
234952
|
+
position: relative;
|
|
234953
|
+
}
|
|
234954
|
+
.cm-merge-button-container {
|
|
234955
|
+
position: absolute;
|
|
234956
|
+
right: 5px;
|
|
234957
|
+
top: 50%;
|
|
234958
|
+
transform: translateY(-50%);
|
|
234959
|
+
z-index: 10;
|
|
234960
|
+
display: flex;
|
|
234961
|
+
gap: 5px;
|
|
234962
|
+
}
|
|
234963
|
+
.cm-merge-button {
|
|
234964
|
+
background-color: #f0f0f0;
|
|
234965
|
+
border: 1px solid #ccc;
|
|
234966
|
+
border-radius: 3px;
|
|
234967
|
+
padding: 2px 6px;
|
|
234968
|
+
cursor: pointer;
|
|
234969
|
+
font-size: 0.8em;
|
|
234970
|
+
line-height: 1;
|
|
234971
|
+
white-space: nowrap;
|
|
234972
|
+
opacity: 0.7;
|
|
234973
|
+
transition: opacity 0.2s ease-in-out;
|
|
234974
|
+
}
|
|
234975
|
+
.cm-merge-button:hover {
|
|
234976
|
+
opacity: 1;
|
|
234977
|
+
background-color: #e0e0e0;
|
|
234978
|
+
}
|
|
234979
|
+
.cm-merge-button.accept {
|
|
234980
|
+
background-color: #4CAF50;
|
|
234981
|
+
color: white;
|
|
234982
|
+
border-color: #4CAF50;
|
|
234983
|
+
}
|
|
234984
|
+
.cm-merge-button.revert {
|
|
234985
|
+
background-color: #f44336;
|
|
234986
|
+
color: white;
|
|
234987
|
+
border-color: #f44336;
|
|
234988
|
+
}
|
|
234989
|
+
/* Diff 데코레이션 CSS (ideDiff.css에 없으면 여기에 추가) */
|
|
234990
|
+
.cm-inserted-line-bg { background-color: #e6ffed; border-left: 3px solid #66bb6a; }
|
|
234991
|
+
.cm-deleted-line-bg { background-color: #ffebe9; border-left: 3px solid #ef5350; }
|
|
234992
|
+
|
|
234993
|
+
/* CodeMirror 선택 스타일 (ideDiff.css에 없으면 여기에 추가) */
|
|
234994
|
+
.cm-selectionBackground {
|
|
234995
|
+
background-color: #d7d4f9 !important;
|
|
234996
|
+
}
|
|
234997
|
+
.cm-editor ::selection {
|
|
234998
|
+
background-color: #d7d4f9 !important;
|
|
234999
|
+
color: inherit !important;
|
|
235000
|
+
}
|
|
235001
|
+
.cm-editor::-moz-selection {
|
|
235002
|
+
background-color: #d7d4f9 !important;
|
|
235003
|
+
color: inherit !important;
|
|
235004
|
+
}
|
|
234879
235005
|
</style>
|
|
234880
235006
|
|
|
234881
235007
|
<div class="wrapper">
|
|
@@ -234921,7 +235047,7 @@ class IdeDiff extends HTMLElement {
|
|
|
234921
235047
|
drawSelection(),
|
|
234922
235048
|
dropCursor(),
|
|
234923
235049
|
EditorState.allowMultipleSelections.of(true),
|
|
234924
|
-
indentOnInput(),
|
|
235050
|
+
indentOnInput(),
|
|
234925
235051
|
bracketMatching(),
|
|
234926
235052
|
highlightActiveLine(),
|
|
234927
235053
|
highlightActiveLineGutter(),
|
|
@@ -234932,11 +235058,11 @@ class IdeDiff extends HTMLElement {
|
|
|
234932
235058
|
...historyKeymap,
|
|
234933
235059
|
...lintKeymap,
|
|
234934
235060
|
...completionKeymap,
|
|
234935
|
-
|
|
234936
|
-
|
|
235061
|
+
indentWithTab, // ⭐️ 함수가 아닌 확장 자체를 전달
|
|
235062
|
+
selectAll // ⭐️ 함수가 아닌 확장 자체를 전달
|
|
234937
235063
|
]),
|
|
234938
|
-
syntaxHighlighting(defaultHighlightStyle),
|
|
234939
|
-
autocompletion(),
|
|
235064
|
+
syntaxHighlighting(defaultHighlightStyle),
|
|
235065
|
+
autocompletion(),
|
|
234940
235066
|
];
|
|
234941
235067
|
|
|
234942
235068
|
// ASIS 에디터 뷰 초기화
|
|
@@ -234945,9 +235071,9 @@ class IdeDiff extends HTMLElement {
|
|
|
234945
235071
|
doc: '',
|
|
234946
235072
|
extensions: [
|
|
234947
235073
|
basicExtensions,
|
|
234948
|
-
this.#languageCompartment.of(javascript()),
|
|
234949
|
-
EditorState.readOnly.of(true),
|
|
234950
|
-
asisDiffDecorations,
|
|
235074
|
+
this.#languageCompartment.of(javascript()),
|
|
235075
|
+
EditorState.readOnly.of(true), // ASIS는 읽기 전용 유지
|
|
235076
|
+
asisDiffDecorations,
|
|
234951
235077
|
EditorView.updateListener.of((update) => {
|
|
234952
235078
|
if (update.view.contentDOM.firstChild && !update.view._initialAsisContentLoaded) {
|
|
234953
235079
|
update.view._initialAsisContentLoaded = true;
|
|
@@ -234965,9 +235091,9 @@ class IdeDiff extends HTMLElement {
|
|
|
234965
235091
|
doc: '',
|
|
234966
235092
|
extensions: [
|
|
234967
235093
|
basicExtensions,
|
|
234968
|
-
this.#languageCompartment.of(javascript()),
|
|
234969
|
-
//EditorState.readOnly.of(true),
|
|
234970
|
-
tobeDiffDecorations,
|
|
235094
|
+
this.#languageCompartment.of(javascript()),
|
|
235095
|
+
// EditorState.readOnly.of(true), // TOBE는 편집 가능하도록 주석 처리 유지
|
|
235096
|
+
tobeDiffDecorations,
|
|
234971
235097
|
EditorView.updateListener.of((update) => {
|
|
234972
235098
|
if (update.view.contentDOM.firstChild && !update.view._initialTobeContentLoaded) {
|
|
234973
235099
|
update.view._initialTobeContentLoaded = true;
|
|
@@ -235020,96 +235146,66 @@ class IdeDiff extends HTMLElement {
|
|
|
235020
235146
|
#applyDiffDecorations = (asisSrc, tobeSrc) => {
|
|
235021
235147
|
const dmp = new diffMatchPatchExports.diff_match_patch();
|
|
235022
235148
|
|
|
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
235149
|
const a = dmp.diff_linesToChars_(asisSrc, tobeSrc);
|
|
235032
235150
|
const lineText1 = a.chars1;
|
|
235033
235151
|
const lineText2 = a.chars2;
|
|
235034
235152
|
const lineArray = a.lineArray;
|
|
235035
235153
|
|
|
235036
|
-
// dmp.diff_main(text1, text2, checklines, deadline)
|
|
235037
|
-
// checklines: true (기본값)는 줄 단위 최적화, false는 문자 단위로.
|
|
235038
|
-
// 여기서는 diff_linesToChars_를 사용했으므로 true가 적절.
|
|
235039
235154
|
const diffs = dmp.diff_main(lineText1, lineText2, true);
|
|
235040
|
-
|
|
235041
|
-
// cleanupEfficiency를 먼저 적용하여 효율적인 Diff를 만듭니다.
|
|
235042
|
-
// 이는 작은 변경사항이 인접해 있을 때 하나의 큰 변경으로 합치는 경향이 있습니다.
|
|
235043
|
-
// dmp.diff_cleanupEfficiency(diffs); // 오히려 이동을 놓칠 수 있음
|
|
235044
|
-
|
|
235045
|
-
// 그 다음 의미론적 정리를 적용합니다.
|
|
235046
235155
|
dmp.diff_cleanupSemantic(diffs);
|
|
235047
|
-
|
|
235048
|
-
// 다시 문자열로 변환
|
|
235049
235156
|
dmp.diff_charsToLines_(diffs, lineArray);
|
|
235050
235157
|
|
|
235051
|
-
console.log(diffs);
|
|
235158
|
+
console.log("Calculated Diffs:", diffs); // Diff 결과 확인용
|
|
235052
235159
|
|
|
235053
235160
|
const asisLineBuilder = new RangeSetBuilder();
|
|
235054
235161
|
const tobeLineBuilder = new RangeSetBuilder();
|
|
235055
235162
|
|
|
235056
|
-
let asisCursor = 0;
|
|
235057
|
-
let tobeCursor = 0;
|
|
235163
|
+
let asisCursor = 0; // ASIS 텍스트에서의 현재 오프셋
|
|
235164
|
+
let tobeCursor = 0; // TOBE 텍스트에서의 현재 오프셋
|
|
235058
235165
|
|
|
235059
|
-
// 변경된 줄에 대한 새로운 데코레이션 클래스를 추가할 수 있습니다.
|
|
235060
235166
|
const insertedLineDeco = Decoration.line({ class: "cm-inserted-line-bg" });
|
|
235061
235167
|
const deletedLineDeco = Decoration.line({ class: "cm-deleted-line-bg" });
|
|
235062
|
-
// const changedLineDeco = Decoration.line({ class: "cm-changed-line-bg" }); // 필요하다면
|
|
235063
235168
|
|
|
235064
|
-
// ⭐️ IdeDiff 인스턴스에 대한 참조를 위젯에 넘겨주기 위해 임시 변수 사용
|
|
235065
|
-
// 실제로는 Closure나 Bound method로 넘겨줄 수 있음
|
|
235066
235169
|
const currentInstance = this;
|
|
235067
235170
|
|
|
235068
235171
|
for (const [op, text] of diffs) {
|
|
235069
235172
|
const len = text.length;
|
|
235070
235173
|
|
|
235071
|
-
//
|
|
235072
|
-
const
|
|
235073
|
-
const
|
|
235174
|
+
// 각 diff op 이전에 현재 커서 위치를 저장
|
|
235175
|
+
const asisRangeStart = asisCursor;
|
|
235176
|
+
const tobeRangeStart = tobeCursor;
|
|
235074
235177
|
|
|
235075
235178
|
switch (op) {
|
|
235076
|
-
case diffMatchPatchExports.diff_match_patch.DIFF_INSERT:
|
|
235077
|
-
console.log(
|
|
235179
|
+
case diffMatchPatchExports.diff_match_patch.DIFF_INSERT: // TOBE에 추가된 내용 (ASIS에는 없음)
|
|
235180
|
+
console.log("DIFF_INSERT (TOBE added):", JSON.stringify(text));
|
|
235078
235181
|
const tobeLines = text.split('\n');
|
|
235079
|
-
|
|
235080
235182
|
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
235183
|
if (!(i === tobeLines.length - 1 && tobeLines[i] === '' && text.endsWith('\n'))) {
|
|
235089
235184
|
tobeLineBuilder.add(tobeCursor, tobeCursor, insertedLineDeco);
|
|
235090
235185
|
}
|
|
235091
235186
|
tobeCursor += tobeLines[i].length + (i < tobeLines.length - 1 ? 1 : 0);
|
|
235092
235187
|
}
|
|
235093
235188
|
|
|
235189
|
+
// ⭐️ TOBE 에디터에 버튼 추가: TOBE의 추가 내용을 ASIS로 '되돌리기' (ASIS에서 삭제)
|
|
235190
|
+
// 즉, TOBE에서 삽입된 내용을 ASIS에서 '없애는' 작업
|
|
235094
235191
|
tobeLineBuilder.add(
|
|
235095
|
-
|
|
235096
|
-
|
|
235192
|
+
tobeRangeStart, // TOBE에서의 해당 Diff 청크 시작 오프셋
|
|
235193
|
+
tobeRangeStart,
|
|
235097
235194
|
Decoration.widget({
|
|
235098
|
-
widget:
|
|
235099
|
-
|
|
235100
|
-
|
|
235101
|
-
|
|
235102
|
-
|
|
235103
|
-
|
|
235104
|
-
|
|
235105
|
-
),
|
|
235195
|
+
widget: new MergeButtonWidget(
|
|
235196
|
+
false, // 이 버튼은 TOBE 에디터에 붙는 버튼 (되돌리기)
|
|
235197
|
+
"", // 텍스트를 ""로 삽입하면 삭제 효과 (ASIS에서 없앨 내용)
|
|
235198
|
+
currentInstance.#asisEditorView, // 대상 에디터는 ASIS
|
|
235199
|
+
{ from: asisRangeStart, to: asisRangeStart + 0 }, // ASIS에서의 대상 범위 (삽입 지점)
|
|
235200
|
+
currentInstance
|
|
235201
|
+
),
|
|
235106
235202
|
side: 1 // 텍스트 뒤에 삽입
|
|
235107
235203
|
})
|
|
235108
235204
|
);
|
|
235109
235205
|
break;
|
|
235110
235206
|
|
|
235111
|
-
case diffMatchPatchExports.diff_match_patch.DIFF_DELETE:
|
|
235112
|
-
console.log(
|
|
235207
|
+
case diffMatchPatchExports.diff_match_patch.DIFF_DELETE: // ASIS에서 삭제된 내용 (TOBE에는 없음)
|
|
235208
|
+
console.log("DIFF_DELETE (ASIS deleted):", JSON.stringify(text));
|
|
235113
235209
|
const asisLines = text.split('\n');
|
|
235114
235210
|
for (let i = 0; i < asisLines.length; i++) {
|
|
235115
235211
|
if (!(i === asisLines.length - 1 && asisLines[i] === '' && text.endsWith('\n'))) {
|
|
@@ -235118,30 +235214,28 @@ class IdeDiff extends HTMLElement {
|
|
|
235118
235214
|
asisCursor += asisLines[i].length + (i < asisLines.length - 1 ? 1 : 0);
|
|
235119
235215
|
}
|
|
235120
235216
|
|
|
235121
|
-
// ⭐️ ASIS
|
|
235217
|
+
// ⭐️ ASIS 에디터에 버튼 추가: ASIS의 삭제 내용을 TOBE로 '적용' (TOBE에 삽입)
|
|
235218
|
+
// 즉, ASIS에서 삭제된 내용을 TOBE에 '넣는' 작업
|
|
235122
235219
|
asisLineBuilder.add(
|
|
235123
|
-
|
|
235124
|
-
|
|
235220
|
+
asisRangeStart, // ASIS에서의 해당 Diff 청크 시작 오프셋
|
|
235221
|
+
asisRangeStart,
|
|
235125
235222
|
Decoration.widget({
|
|
235126
235223
|
widget: new MergeButtonWidget(
|
|
235127
|
-
true, // ASIS
|
|
235128
|
-
text,
|
|
235129
|
-
currentInstance.#tobeEditorView //
|
|
235224
|
+
true, // 이 버튼은 ASIS 에디터에 붙는 버튼 (적용)
|
|
235225
|
+
text, // ASIS에서 삭제된 내용을 TOBE에 삽입
|
|
235226
|
+
currentInstance.#tobeEditorView, // 대상 에디터는 TOBE
|
|
235227
|
+
{ from: tobeRangeStart, to: tobeRangeStart + 0 }, // TOBE에서의 대상 범위 (삽입 지점)
|
|
235228
|
+
currentInstance
|
|
235130
235229
|
),
|
|
235131
235230
|
side: 1 // 텍스트 뒤에 삽입
|
|
235132
235231
|
})
|
|
235133
235232
|
);
|
|
235134
|
-
|
|
235135
235233
|
break;
|
|
235136
235234
|
|
|
235137
|
-
case diffMatchPatchExports.diff_match_patch.DIFF_EQUAL:
|
|
235235
|
+
case diffMatchPatchExports.diff_match_patch.DIFF_EQUAL: // 동일한 내용
|
|
235138
235236
|
asisCursor += len;
|
|
235139
235237
|
tobeCursor += len;
|
|
235140
235238
|
break;
|
|
235141
|
-
|
|
235142
|
-
default:
|
|
235143
|
-
console.log(op);
|
|
235144
|
-
break;
|
|
235145
235239
|
}
|
|
235146
235240
|
}
|
|
235147
235241
|
|
|
@@ -235151,7 +235245,6 @@ class IdeDiff extends HTMLElement {
|
|
|
235151
235245
|
};
|
|
235152
235246
|
};
|
|
235153
235247
|
|
|
235154
|
-
// IdeDiff 클래스 내부에 변경 후 Diff를 다시 계산하는 메서드 추가
|
|
235155
235248
|
recalculateDiff = () => {
|
|
235156
235249
|
const asisDoc = this.#asisEditorView.state.doc.toString();
|
|
235157
235250
|
const tobeDoc = this.#tobeEditorView.state.doc.toString();
|
|
@@ -235214,71 +235307,6 @@ class IdeDiff extends HTMLElement {
|
|
|
235214
235307
|
};
|
|
235215
235308
|
}
|
|
235216
235309
|
|
|
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
235310
|
customElements.define("ide-diff", IdeDiff);
|
|
235283
235311
|
|
|
235284
235312
|
//import "./components/ideAssi.js";
|