Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] 전사 스크립트에서 추임새랑 침묵시간 표기 #44

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 21 additions & 22 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 38 additions & 1 deletion src/pages/Feedback/components/ScriptBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,43 @@ const ScriptBox = ({
));
};

const beforeScriptFormatContent = (text) => {
const parseContent = (line) => {
// 단어 단위로 분리하여 처리
const words = line.split(" ");
return words.map((word, index) => {
// 추임새를 포함한 단어 처리
if (word.match(/^[^\s]+?\(추임새\),?$/)) {
const cleanWord = word.replace(",", ""); // 쉼표 제거
return (
<span key={index} style={{backgroundColor: "yellow", padding: "0 2px", marginRight: "4px"}}>
{cleanWord}
</span>
);
}
// 침묵 시간 처리
else if (word.match(/^\(\d+(\.\d+)?초\.\.\),?$/)) {
const cleanWord = word.replace(",", ""); // 쉼표 제거
return (
<span key={index} style={{backgroundColor: "lightgreen", padding: "0 2px", marginRight: "4px"}}>
{cleanWord}
</span>
);
}
// 일반 단어 처리
else {
return <React.Fragment key={index}>{word} </React.Fragment>;
}
});
};
return text.split("\n").map((line, index) => (
<React.Fragment key={index}>
{parseContent(line)}
<br/>
</React.Fragment>
));
};

return (
<div
className="relative flex flex-col w-full p-4 transition-all bg-white border rounded-lg shadow cursor-pointer border-grayscale-40 hover:shadow-md"
Expand Down Expand Up @@ -123,7 +160,7 @@ const ScriptBox = ({
{/* 드롭다운 텍스트 */}
{isOpen && (
<div className="mt-3 text-sm text-justify transition-all duration-300 ease-in-out text-grayscale-90">
{title === "AI 피드백" ? formatContent(content) : content}
{title === "AI 피드백" ? formatContent(content) : beforeScriptFormatContent(content)}
</div>
)}
</div>
Expand Down
39 changes: 38 additions & 1 deletion src/pages/RecordScript/components/ScriptBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,43 @@ const ScriptBox = ({
));
};

const beforeScriptFormatContent = (text) => {
const parseContent = (line) => {
// 단어 단위로 분리하여 처리
const words = line.split(" ");
return words.map((word, index) => {
// 추임새를 포함한 단어 처리
if (word.match(/^[^\s]+?\(추임새\),?$/)) {
const cleanWord = word.replace(",", ""); // 쉼표 제거
return (
<span key={index} style={{backgroundColor: "yellow", padding: "0 2px", marginRight: "4px"}}>
{cleanWord}
</span>
);
}
// 침묵 시간 처리
else if (word.match(/^\(\d+(\.\d+)?초\.\.\),?$/)) {
const cleanWord = word.replace(",", ""); // 쉼표 제거
return (
<span key={index} style={{backgroundColor: "lightgreen", padding: "0 2px", marginRight: "4px"}}>
{cleanWord}
</span>
);
}
// 일반 단어 처리
else {
return <React.Fragment key={index}>{word} </React.Fragment>;
}
});
};
return text.split("\n").map((line, index) => (
<React.Fragment key={index}>
{parseContent(line)}
<br/>
</React.Fragment>
));
};

return (
<div
className="relative flex flex-col w-full p-4 transition-all bg-white border rounded-lg shadow cursor-pointer border-grayscale-40 hover:shadow-md"
Expand Down Expand Up @@ -123,7 +160,7 @@ const ScriptBox = ({
{/* 드롭다운 텍스트 */}
{isOpen && (
<div className="mt-3 text-sm text-justify transition-all duration-300 ease-in-out text-grayscale-90">
{title === "AI 피드백" ? formatContent(content) : content}
{title === "AI 피드백" ? formatContent(content) : beforeScriptFormatContent(content)}
</div>
)}
</div>
Expand Down
Loading