Skip to content

Commit 16386eb

Browse files
update
1 parent 72d09ac commit 16386eb

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

packages/core/src/parse/template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const getSyntaxTemplate = ({
7777
wrapper?.properties?.className || []
7878
)?.join(
7979
" "
80-
)}" style="${wrapper?.properties?.style || ""}">${escapeHtml(str1)}<span data-diff-highlight style="background-color: var(${operator === "add" ? addContentHighlightBGName : delContentHighlightBGName});border-top-left-radius: ${isStart ? "0.2em" : ""};border-bottom-left-radius: ${isStart ? "0.2em" : ""};border-top-right-radius: ${isEnd || isLast ? "0.2em" : ""};border-bottom-right-radius: ${isEnd || isLast ? "0.2em" : ""}">${
80+
)}" style="${wrapper?.properties?.style || ""}">${escapeHtml(str1)}<span data-diff-highlight style="background-color: var(${operator === "add" ? addContentHighlightBGName : delContentHighlightBGName});border-top-left-radius: ${isStart ? "0.2em" : "0"};border-bottom-left-radius: ${isStart ? "0.2em" : "0"};border-top-right-radius: ${isEnd || isLast ? "0.2em" : "0"};border-bottom-right-radius: ${isEnd || isLast ? "0.2em" : "0"}">${
8181
isLast
8282
? `${escapeHtml(_str2)}<span data-newline-symbol>${getSymbol(changes.newLineSymbol)}</span>`
8383
: escapeHtml(str2)

packages/react/src/components/DiffContent.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ const DiffString = ({
6868

6969
if (changes?.hasLineChange) {
7070
const isNewLineSymbolChanged = changes.newLineSymbol;
71-
if (!diffLine?.plainTemplate) {
71+
72+
if (!diffLine?.plainTemplate && typeof getPlainTemplate === "function") {
7273
getPlainTemplate({ diffLine, rawLine, operator });
7374
}
75+
7476
if (diffLine?.plainTemplate) {
7577
return (
7678
<span className="diff-line-content-raw">
@@ -97,7 +99,6 @@ const DiffString = ({
9799
const str3 = rawLine.slice(range.location + range.length);
98100
const isLast = str2.includes("\n");
99101
const _str2 = isLast ? str2.replace("\n", "").replace("\r", "") : str2;
100-
const isNewLineSymbolChanged = changes.newLineSymbol;
101102
return (
102103
<span className="diff-line-content-raw">
103104
<span data-range-start={range.location} data-range-end={range.location + range.length}>
@@ -162,9 +163,11 @@ const DiffSyntax = ({
162163

163164
if (changes?.hasLineChange) {
164165
const isNewLineSymbolChanged = changes.newLineSymbol;
165-
if (!diffLine?.syntaxTemplate) {
166+
167+
if (!diffLine?.syntaxTemplate && typeof getSyntaxTemplate === "function") {
166168
getSyntaxTemplate({ diffLine, syntaxLine, operator });
167169
}
170+
168171
if (diffLine?.syntaxTemplate) {
169172
return (
170173
<span className="diff-line-syntax-raw">

packages/vue/src/components/DiffContent.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ const DiffString = ({
3737

3838
if (changes?.hasLineChange) {
3939
const isNewLineSymbolChanged = changes.newLineSymbol;
40-
if (!diffLine?.plainTemplate) {
40+
41+
if (!diffLine?.plainTemplate && typeof getPlainTemplate === "function") {
4142
getPlainTemplate({ diffLine, rawLine, operator });
4243
}
44+
4345
if (diffLine?.plainTemplate) {
4446
return (
4547
<span class="diff-line-content-raw">
@@ -66,7 +68,6 @@ const DiffString = ({
6668
const str3 = rawLine.slice(range.location + range.length);
6769
const isLast = str2.includes("\n");
6870
const _str2 = isLast ? str2.replace("\n", "").replace("\r", "") : str2;
69-
const isNewLineSymbolChanged = changes.newLineSymbol;
7071
return (
7172
<span class="diff-line-content-raw">
7273
<span data-range-start={range.location} data-range-end={range.location + range.length}>
@@ -132,7 +133,7 @@ const DiffSyntax = ({
132133
if (changes?.hasLineChange) {
133134
const isNewLineSymbolChanged = changes.newLineSymbol;
134135

135-
if (!diffLine?.syntaxTemplate) {
136+
if (!diffLine?.syntaxTemplate && typeof getSyntaxTemplate === "function") {
136137
getSyntaxTemplate({ diffLine, syntaxLine, operator });
137138
}
138139

@@ -155,8 +156,9 @@ const DiffSyntax = ({
155156
</span>
156157
);
157158
} else {
159+
// TODO remove
158160
const range = changes.range;
159-
161+
160162
return (
161163
<span class="diff-line-syntax-raw">
162164
<span data-range-start={range.location} data-range-end={range.location + range.length}>

0 commit comments

Comments
 (0)