260811_01_ENH: 폰트 추가 및 html보기, 프리티어 적용

This commit is contained in:
2026-08-11 08:46:59 +09:00
parent 9b93d45ed0
commit e8f3308814
10 changed files with 196 additions and 110 deletions

44
package-lock.json generated
View File

@@ -49,6 +49,7 @@
"lucide-react": "^0.553.0",
"next": "^16.0.7",
"next-themes": "^0.4.6",
"prettier": "^3.9.6",
"qrcode": "^1.5.4",
"radix-ui": "^1.6.1",
"react": "^19.2.1",
@@ -114,7 +115,6 @@
"integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==",
"devOptional": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/code-frame": "^7.29.7",
"@babel/generator": "^7.29.7",
@@ -282,7 +282,6 @@
"integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==",
"devOptional": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/code-frame": "^7.29.7",
"@babel/parser": "^7.29.7",
@@ -348,7 +347,6 @@
"resolved": "https://registry.npmjs.org/@dnd-kit/core/-/core-6.3.1.tgz",
"integrity": "sha512-xkGBRQQab4RLwgXxoqETICr6S5JlogafbhNsidmrkVv2YRs5MLwpjoF2qpiGjQt8S9AoxtIV603s0GIUpY5eYQ==",
"license": "MIT",
"peer": true,
"dependencies": {
"@dnd-kit/accessibility": "^3.1.1",
"@dnd-kit/utilities": "^3.2.2",
@@ -561,7 +559,6 @@
"version": "1.7.4",
"resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.7.4.tgz",
"integrity": "sha512-OOchDgh4F2CchOX94cRVqhvy7b3AFb+/rQXyswmzmGakRfkMgoWVjfnLWkRirfLEfuD4ysVW16eXzwt3jHIzKA==",
"peer": true,
"dependencies": {
"@floating-ui/core": "^1.7.3",
"@floating-ui/utils": "^0.2.10"
@@ -3127,7 +3124,6 @@
"resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.90.21.tgz",
"integrity": "sha512-0Lu6y5t+tvlTJMTO7oh5NSpJfpg/5D41LlThfepTixPYkJ0sE2Jj0m0f6yYqujBwIXlId87e234+MxG3D3g7kg==",
"license": "MIT",
"peer": true,
"dependencies": {
"@tanstack/query-core": "5.90.20"
},
@@ -3174,7 +3170,6 @@
"version": "3.13.0",
"resolved": "https://registry.npmjs.org/@tiptap/core/-/core-3.13.0.tgz",
"integrity": "sha512-iUelgiTMgPVMpY5ZqASUpk8mC8HuR9FWKaDzK27w9oWip9tuB54Z8mePTxNcQaSPb6ErzEaC8x8egrRt7OsdGQ==",
"peer": true,
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -3430,7 +3425,6 @@
"version": "3.12.0",
"resolved": "https://registry.npmjs.org/@tiptap/extension-list/-/extension-list-3.12.0.tgz",
"integrity": "sha512-RCQb3MPsTsKZZ8Wf0maMnfcICcmYEbMfWJMUNwVUJCfEv1hGiA5J7jMEJWr7z6kH2ULDHmrkhg6BYCdLrJap/w==",
"peer": true,
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -3516,7 +3510,6 @@
"version": "3.13.0",
"resolved": "https://registry.npmjs.org/@tiptap/extension-table/-/extension-table-3.13.0.tgz",
"integrity": "sha512-LcH9KE4QBUJ6IPwt1Uo5iU7zatFjUUvXbctIu2fKQ9nqJ7nNSFxRhkNyporVFkTWYH7/rb0qMoF1VxSUGefG5w==",
"peer": true,
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -3590,7 +3583,6 @@
"version": "3.13.0",
"resolved": "https://registry.npmjs.org/@tiptap/extension-text-style/-/extension-text-style-3.13.0.tgz",
"integrity": "sha512-M7ob3pfYNYgFPihncEp33r9477hXQgC8j3iU8BsewvPlSx2bMSy5jp2XHDXyEX8dV6flr7acH4GkXXw+DHpaPA==",
"peer": true,
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -3615,7 +3607,6 @@
"version": "3.13.0",
"resolved": "https://registry.npmjs.org/@tiptap/extensions/-/extensions-3.13.0.tgz",
"integrity": "sha512-i7O0ptSibEtTy+2PIPsNKEvhTvMaFJg1W4Oxfnbuxvaigs7cJV9Q0lwDUcc7CPsNw2T1+44wcxg431CzTvdYoA==",
"peer": true,
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
@@ -3629,7 +3620,6 @@
"version": "3.13.0",
"resolved": "https://registry.npmjs.org/@tiptap/pm/-/pm-3.13.0.tgz",
"integrity": "sha512-WKR4ucALq+lwx0WJZW17CspeTpXorbIOpvKv5mulZica6QxqfMhn8n1IXCkDws/mCoLRx4Drk5d377tIjFNsvQ==",
"peer": true,
"dependencies": {
"prosemirror-changeset": "^2.3.0",
"prosemirror-collab": "^1.3.1",
@@ -3786,7 +3776,6 @@
"version": "19.2.4",
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.4.tgz",
"integrity": "sha512-tBFxBp9Nfyy5rsmefN+WXc1JeW/j2BpBHFdLZbEVfs9wn3E3NRFxwV0pJg8M1qQAexFpvz73hJXFofV0ZAu92A==",
"peer": true,
"dependencies": {
"csstype": "^3.0.2"
}
@@ -3795,7 +3784,6 @@
"version": "19.2.3",
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.2.3.tgz",
"integrity": "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==",
"peer": true,
"peerDependencies": {
"@types/react": "^19.2.0"
}
@@ -3855,7 +3843,6 @@
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.46.4.tgz",
"integrity": "sha512-tK3GPFWbirvNgsNKto+UmB/cRtn6TZfyw0D6IKrW55n6Vbs7KJoZtI//kpTKzE/DUmmnAFD8/Ca46s7Obs92/w==",
"dev": true,
"peer": true,
"dependencies": {
"@typescript-eslint/scope-manager": "8.46.4",
"@typescript-eslint/types": "8.46.4",
@@ -4368,7 +4355,6 @@
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
"dev": true,
"peer": true,
"bin": {
"acorn": "bin/acorn"
},
@@ -4664,7 +4650,6 @@
"resolved": "https://registry.npmjs.org/babel-plugin-react-compiler/-/babel-plugin-react-compiler-1.0.0.tgz",
"integrity": "sha512-Ixm8tFfoKKIPYdCCKYTsqv+Fd4IJ0DQqMyEimo+pxUOMUR9cVPlwTrFt9Avu+3cb6Zp3mAzl+t1MrG2fxxKsxw==",
"devOptional": true,
"peer": true,
"dependencies": {
"@babel/types": "^7.26.0"
}
@@ -4730,7 +4715,6 @@
}
],
"license": "MIT",
"peer": true,
"dependencies": {
"baseline-browser-mapping": "^2.10.42",
"caniuse-lite": "^1.0.30001803",
@@ -5438,7 +5422,6 @@
"resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.1.tgz",
"integrity": "sha512-BhHmn2yNOFA9H9JmmIVKJmd288g9hrVRDkdoIgRCRuSySRUHH7r/DI6aAXW9T1WwUuY3DFgrcaqB+deURBLR5g==",
"dev": true,
"peer": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.8.0",
"@eslint-community/regexpp": "^4.12.1",
@@ -5616,7 +5599,6 @@
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.32.0.tgz",
"integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==",
"dev": true,
"peer": true,
"dependencies": {
"@rtsao/scc": "^1.1.0",
"array-includes": "^3.1.9",
@@ -6777,7 +6759,6 @@
"version": "2.15.1",
"resolved": "https://registry.npmjs.org/jotai/-/jotai-2.15.1.tgz",
"integrity": "sha512-yHT1HAZ3ba2Q8wgaUQ+xfBzEtcS8ie687I8XVCBinfg4bNniyqLIN+utPXWKQE93LMF5fPbQSVRZqgpcN5yd6Q==",
"peer": true,
"engines": {
"node": ">=12.20.0"
},
@@ -7792,6 +7773,21 @@
"node": ">= 0.8.0"
}
},
"node_modules/prettier": {
"version": "3.9.6",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.6.tgz",
"integrity": "sha512-OpN0zzVdiaiAhxpuuj5efpIS4sY9j7bY6uR5mnj5yPzGkdkjNKSJeUThPb60Jw29QuAZgA4o+/iB49kFiaBX6g==",
"license": "MIT",
"bin": {
"prettier": "bin/prettier.cjs"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/prop-types": {
"version": "15.8.1",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
@@ -7904,7 +7900,6 @@
"version": "1.25.4",
"resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.25.4.tgz",
"integrity": "sha512-PIM7E43PBxKce8OQeezAs9j4TP+5yDpZVbuurd1h5phUxEKIu+G2a+EUZzIC5nS1mJktDJWzbqS23n1tsAf5QA==",
"peer": true,
"dependencies": {
"orderedmap": "^2.0.0"
}
@@ -7931,7 +7926,6 @@
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/prosemirror-state/-/prosemirror-state-1.4.4.tgz",
"integrity": "sha512-6jiYHH2CIGbCfnxdHbXZ12gySFY/fz/ulZE333G6bPqIZ4F+TXo9ifiR86nAHpWnfoNjOb3o5ESi7J8Uz1jXHw==",
"peer": true,
"dependencies": {
"prosemirror-model": "^1.0.0",
"prosemirror-transform": "^1.0.0",
@@ -7976,7 +7970,6 @@
"version": "1.41.4",
"resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.41.4.tgz",
"integrity": "sha512-WkKgnyjNncri03Gjaz3IFWvCAE94XoiEgvtr0/r2Xw7R8/IjK3sKLSiDoCHWcsXSAinVaKlGRZDvMCsF1kbzjA==",
"peer": true,
"dependencies": {
"prosemirror-model": "^1.20.0",
"prosemirror-state": "^1.0.0",
@@ -8118,7 +8111,6 @@
"version": "19.2.1",
"resolved": "https://registry.npmjs.org/react/-/react-19.2.1.tgz",
"integrity": "sha512-DGrYcCWK7tvYMnWh79yrPHt+vdx9tY+1gPZa7nJQtO/p8bLTDaHp4dzwEhQB7pZ4Xe3ok4XKuEPrVuc+wlpkmw==",
"peer": true,
"engines": {
"node": ">=0.10.0"
}
@@ -8153,7 +8145,6 @@
"version": "19.2.1",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.1.tgz",
"integrity": "sha512-ibrK8llX2a4eOskq1mXKu/TGZj9qzomO+sNfO98M6d9zIPOEhlBkMkBUBLd1vgS0gQsLDBzA+8jJBVXDnfHmJg==",
"peer": true,
"dependencies": {
"scheduler": "^0.27.0"
},
@@ -8963,7 +8954,6 @@
"integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=12"
},
@@ -9124,7 +9114,6 @@
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"dev": true,
"peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
@@ -9600,7 +9589,6 @@
"resolved": "https://registry.npmjs.org/zod/-/zod-4.1.12.tgz",
"integrity": "sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ==",
"dev": true,
"peer": true,
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}

View File

@@ -50,6 +50,7 @@
"lucide-react": "^0.553.0",
"next": "^16.0.7",
"next-themes": "^0.4.6",
"prettier": "^3.9.6",
"qrcode": "^1.5.4",
"radix-ui": "^1.6.1",
"react": "^19.2.1",

View File

@@ -100,7 +100,6 @@ const MainPage = () => {
const [searchDept, setSearchDept] = useState<string[]>([]);
const [searchFw, setSearchFw] = useState<string[]>([]);
const columns = getProjectColumns(users, groupCodeLabelMap);
const userId = auth.user?.userId ?? "";
const userRole = auth.user?.userRole;
const isInternal = isInternalManager(userRole);
@@ -124,9 +123,7 @@ const MainPage = () => {
showDialog('projectCreateDialog');
}
const handleSubmit = async (data: ProjectCreateRequest): Promise<void> => {
const projectInfo = await createMutation.mutateAsync(data);
const navigateWithProject = (projectInfo: ProjectInfo, path: string) => {
setSelectedProject({
prjctIdx: projectInfo.prjctIdx,
prjctCd: projectInfo.prjctCd,
@@ -137,22 +134,19 @@ const MainPage = () => {
ff: projectInfo.ff
} as SelectedProject);
router.push("/project/info");
router.push(path);
};
const handleClick = (projectInfo:ProjectInfo) => {
setSelectedProject({
prjctIdx: projectInfo.prjctIdx,
prjctCd: projectInfo.prjctCd,
prjctName: projectInfo.prjctName,
itrntPrjctCd: projectInfo.itrntPrjctCd,
ownerDept: projectInfo.ownerDept,
ownerFw: projectInfo.ownerFw,
ff: projectInfo.ff
} as SelectedProject);
const handleSubmit = async (data: ProjectCreateRequest): Promise<void> => {
const projectInfo = await createMutation.mutateAsync(data);
navigateWithProject(projectInfo, "/project/info");
};
router.push(`/list/manage`);
}
const handleClick = (projectInfo: ProjectInfo) => navigateWithProject(projectInfo, "/list/manage");
const handleNavigateToInfo = (projectInfo: ProjectInfo) => navigateWithProject(projectInfo, "/project/info");
const columns = getProjectColumns(users, groupCodeLabelMap, isInternal ? handleNavigateToInfo : undefined);
if (!mounted || isLoading) return <LoadingOverlayAdapter force />;

View File

@@ -9,6 +9,7 @@ import { compressImage } from './utils/imageCompression'
import { useDebouncedChange } from './hooks/useDebouncedChange'
import { sanitizeHtmlForPreview } from './utils/sanitizeHtml'
import { preserveEmptyParagraphs } from './utils/emptyParagraph'
import { formatHtmlSource } from './utils/formatHtml'
import { useTextareaInsert } from './hooks/useTextareaInsert'
type HtmlOnlyProps = Omit<KriEditorProps, 'mode'> & { mode: 'html' }
@@ -47,12 +48,31 @@ export function KriEditorHtmlOnly({
else scheduleChange(next)
}, [flushChange, scheduleChange])
// 사용자가 타이핑한 값이 아니라 외부에서 새로 세팅된 데이터일 때만(최초 마운트 포함)
// prettier로 포맷팅해서 반영한다 — 편집 중(commitHtml 경로)에는 절대 재포맷하지 않는다.
const applyExternalValue = React.useCallback((next: string) => {
setHtml(next)
latestHtmlRef.current = next
formatHtmlSource(next)
.then((formatted) => {
if (latestHtmlRef.current !== next) return // 그 사이 값이 또 바뀌었으면 건너뜀
setHtml(formatted)
latestHtmlRef.current = formatted
})
.catch(() => {})
}, [])
React.useEffect(() => {
applyExternalValue(value || '')
// 최초 마운트 시 1회만 실행 — 이후 value 변경은 아래 effect가 처리한다.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
React.useEffect(() => {
if ((value || '') !== latestHtmlRef.current) {
setHtml(value || '')
latestHtmlRef.current = value || ''
applyExternalValue(value || '')
}
}, [value])
}, [value, applyExternalValue])
React.useEffect(() => {
onEditorReady?.(textareaRef.current)
@@ -122,6 +142,16 @@ export function KriEditorHtmlOnly({
}
}
const handleFormatHtml = React.useCallback(async () => {
try {
const formatted = await formatHtmlSource(latestHtmlRef.current)
commitHtml(formatted)
} catch (error) {
toast.error('HTML 정렬에 실패했습니다.')
console.error(error)
}
}, [commitHtml])
const previewHtml = React.useMemo(
() => sanitizeHtmlForPreview(preserveEmptyParagraphs(html)),
[html],
@@ -133,11 +163,16 @@ export function KriEditorHtmlOnly({
<div className="flex flex-col gap-2 px-3 py-2">
<div className="text-muted-foreground flex items-center justify-between text-xs">
<span>HTML 모드</span>
{onImageUpload ? (
<button type="button" onClick={() => fileRef.current?.click()} className="rounded border px-2 py-1 hover:bg-muted">
이미지 업로드
<div className="flex items-center gap-2">
<button type="button" onClick={handleFormatHtml} className="rounded border px-2 py-1 hover:bg-muted">
정렬
</button>
) : null}
{onImageUpload ? (
<button type="button" onClick={() => fileRef.current?.click()} className="rounded border px-2 py-1 hover:bg-muted">
이미지 업로드
</button>
) : null}
</div>
</div>
<textarea
ref={textareaRef}

View File

@@ -29,6 +29,7 @@ import { compressImage } from "./utils/imageCompression";
import { sanitizeHtml } from "./utils/sanitizeHtml";
import { preserveEmptyParagraphs } from "./utils/emptyParagraph";
import { DEFAULT_FONT_FAMILY_OPTIONS } from "./utils/fontFamilyOptions";
import { formatHtmlSource } from "./utils/formatHtml";
import { applyLinkPreviewClass, KRI_EDITOR_LINK_CLASS } from "./utils/linkPreview";
import { Toolbar } from "./toolbar/Toolbar";
import { useDebouncedChange } from "./hooks/useDebouncedChange";
@@ -456,8 +457,20 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
if (!editor) return;
if (viewRef.current === "wysiwyg") {
htmlDraftRef.current = editor.getHTML();
const raw = editor.getHTML();
htmlDraftRef.current = raw;
setView("html");
// WYSIWYG에서 막 넘어온, 사용자가 직접 타이핑하지 않은 HTML이므로
// 화면 표시용으로만 정렬한다(onChange는 호출하지 않음 — 저장값은 그대로 유지).
formatHtmlSource(raw)
.then((formatted) => {
if (viewRef.current !== "html" || htmlDraftRef.current !== raw) return;
htmlDraftRef.current = formatted;
if (htmlTextareaRef.current) htmlTextareaRef.current.value = formatted;
setPreviewSource(formatted);
})
.catch(() => {});
return;
}
@@ -469,6 +482,19 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
setView("wysiwyg");
}, [allowedCustomHtml, editor, flushChange, sanitizeHtmlOpt]);
const formatHtmlView = useCallback(async () => {
try {
const formatted = await formatHtmlSource(htmlDraftRef.current);
htmlDraftRef.current = formatted;
if (htmlTextareaRef.current) htmlTextareaRef.current.value = formatted;
setPreviewSource(formatted);
scheduleChange(preserveEmptyParagraphs(formatted));
} catch (err) {
toast.error("HTML 정렬에 실패했습니다.");
console.error(err);
}
}, [scheduleChange]);
useEffect(() => {
if (!editor) return;
@@ -615,6 +641,7 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
showHtmlToggle={showHtmlToggle}
isHtmlView={view === "html"}
onToggleHtmlView={onToggleHtmlView}
onFormatHtml={formatHtmlView}
fontFamilyOptions={fontFamilyOptions}
onSetFontFamily={setFontFamily}
onSetFontSize={setFontSize}
@@ -661,7 +688,7 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
<div className={cn("border-t p-3", previewClassName)}>
<div className="mb-2 text-sm font-semibold">미리보기</div>
<div className="rounded-md border bg-muted/30 p-3">
<div className="kri-editor-preview" dangerouslySetInnerHTML={{ __html: previewHtml }} />
<div dangerouslySetInnerHTML={{ __html: previewHtml }} />
</div>
</div>
)}

View File

@@ -10,6 +10,7 @@ import {
Code2,
Highlighter,
Image as ImageIcon,
IndentIncrease,
Italic,
Link2,
List,
@@ -38,6 +39,7 @@ interface ToolbarProps {
showHtmlToggle: boolean
isHtmlView: boolean
onToggleHtmlView: () => void
onFormatHtml: () => void
fontFamilyOptions: KriEditorFontFamilyOption[]
onSetFontFamily: (value: string) => void
onSetFontSize: (value: string) => void
@@ -76,6 +78,7 @@ export function Toolbar({
showHtmlToggle,
isHtmlView,
onToggleHtmlView,
onFormatHtml,
fontFamilyOptions,
onSetFontFamily,
onSetFontSize,
@@ -115,7 +118,7 @@ export function Toolbar({
<div className={cn('flex items-center gap-1 overflow-x-auto whitespace-nowrap px-2 py-1', className)}>
{enabled('fontFamily') ? (
<select
className="h-8 w-[132px] rounded-md border bg-background px-2 text-sm"
className="h-8 w-[150px] rounded-md border bg-background px-2 text-sm"
value={state.fontFamily ?? ''}
onChange={(event) => onSetFontFamily(event.target.value)}
title="글꼴"
@@ -296,6 +299,9 @@ export function Toolbar({
<>
<Separator orientation="vertical" className="mx-1 h-6" />
<ToolbarButton active={isHtmlView} title={isHtmlView ? 'WYSIWYG로 전환' : 'HTML 편집'} onClick={onToggleHtmlView}><Code2 className="size-4" /></ToolbarButton>
{isHtmlView ? (
<ToolbarButton title="HTML 정렬" onClick={onFormatHtml}><IndentIncrease className="size-4" /></ToolbarButton>
) : null}
</>
) : null}
{customContent ? (

View File

@@ -2,7 +2,7 @@ import type { KriEditorFontFamilyOption } from "../types";
/**
* OS/이메일 클라이언트에 기본 설치돼 있어 별도 @font-face 로딩 없이 바로 렌더링되는 웹 세이프 폰트 목록.
* "기본값"은 fontFamily 속성을 제거(unset)해 상위 스타일을 상속한다.
* "자동"은 fontFamily 속성을 제거(unset)해 상위 스타일을 상속한다.
*/
export const DEFAULT_FONT_FAMILY_OPTIONS: KriEditorFontFamilyOption[] = [
{ label: "없음", value: "" },

View File

@@ -0,0 +1,16 @@
export async function formatHtmlSource(html: string): Promise<string> {
if (!html.trim()) return html;
const [{ format }, htmlPlugin] = await Promise.all([
import("prettier/standalone"),
import("prettier/plugins/html"),
]);
return format(html, {
parser: "html",
plugins: [htmlPlugin],
printWidth: 100,
// 인라인 요소(span/a/mark 등) 사이 공백은 실제 렌더링에 영향을 주므로 보존한다.
htmlWhitespaceSensitivity: "css",
});
}

View File

@@ -535,7 +535,7 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
{!isSms && (
<KriEditor
//mode="both"
mode="wysiwyg"
mode="both"
showPreview={true}
value={normalizeQrCodeForEditor(selectedTemplate.tmplatBody) || "<p></p>"}
onChange={(html: string) => setTemplateBody(html)}
@@ -549,6 +549,7 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
toolbar={{ strike: false, table: false, bulletList: false, orderedList: false }}
editorExtensions={MESSAGE_EDITOR_EXTENSIONS}
allowedCustomHtml={QR_CODE_ALLOWED_HTML}
previewClassName="kri-editor-preview"
transformPreviewHtml={renderQrCodePreviewHtml}
renderToolbarEnd={({editor}) => (
<QrCodeToolbar editor={editor} surveys={surveys} />

View File

@@ -5,62 +5,80 @@ import { formatKst } from "@kri/common";
import {cn} from "@/lib/utils";
import {PROJECT_STATUS_CLASS, PROJECT_STATUS_LABEL} from "@/const/projectConst";
import {ItrntUserInfo} from "@/types/user";
import type {MouseEvent} from "react";
export const getProjectColumns = (
users:ItrntUserInfo[],
groupCodeLabelMap: Map<string, string> = new Map(),
): ColumnDef<ProjectInfo>[] => [
{
accessorKey: "prjctIdx",
header: "No",
enableSorting: true,
},
{
accessorKey: "prjctCd",
header: "프로젝트 코드",
enableSorting: true,
meta: {
maxWidth: 180
onNavigateToInfo?: (projectInfo: ProjectInfo) => void,
): ColumnDef<ProjectInfo>[] => {
// 진행 상태/담당 그룹/담당 실사/등록일 셀은 행 클릭(list/manage)과 분기해 project/info로 이동시킨다.
const handleInfoCellClick = (e: MouseEvent, projectInfo: ProjectInfo) => {
if (!onNavigateToInfo) return;
e.stopPropagation();
onNavigateToInfo(projectInfo);
};
const infoCellClass = "flex h-full w-full items-center cursor-pointer";
return [
{
accessorKey: "prjctIdx",
header: "No",
enableSorting: true,
},
},
{
accessorKey: "prjctName",
header: "프로젝트 명",
enableSorting: true,
meta: {
maxWidth: 1000
{
accessorKey: "prjctCd",
header: "프로젝트 코드",
enableSorting: true,
meta: {
maxWidth: 180
},
},
},
{
accessorKey: "prjctStatus",
header: "진행 상태",
cell: ({row}) => (
<Badge className={cn("w-15 h-7 my-1.5", PROJECT_STATUS_CLASS[row.original.prjctStatus])}>
{PROJECT_STATUS_LABEL[row.original.prjctStatus]}
</Badge>
) ,
enableSorting: true,
},
{
accessorKey: "ownerDept",
header: "담당 그룹",
enableSorting: true,
cell: ({row}) => (
groupCodeLabelMap.get(row.original.ownerDept) ?? row.original.ownerDept
),
},
{
accessorKey: "ownerFw",
header: "담당 실사",
enableSorting: true,
cell: ({row}) => (
users.find(u => u.userId === row.original.ownerFw)?.userNm ?? ""
) ,
},
{
accessorKey: "regDt",
header: "등록일",
cell: ({row}) => (formatKst(row.original.regDt ?? "", "date")),
enableSorting: true,
}
];
{
accessorKey: "prjctName",
header: "프로젝트 명",
enableSorting: true,
meta: {
maxWidth: 1000
},
},
{
accessorKey: "prjctStatus",
header: "진행 상태",
cell: ({row}) => (
<div className={infoCellClass} onClick={(e) => handleInfoCellClick(e, row.original)}>
<Badge className={cn("w-15 h-7 my-1.5", PROJECT_STATUS_CLASS[row.original.prjctStatus])}>
{PROJECT_STATUS_LABEL[row.original.prjctStatus]}
</Badge>
</div>
) ,
enableSorting: true,
},
{
accessorKey: "ownerDept",
header: "담당 그룹",
enableSorting: true,
cell: ({row}) => (
<div className={infoCellClass} onClick={(e) => handleInfoCellClick(e, row.original)}>
{groupCodeLabelMap.get(row.original.ownerDept) ?? row.original.ownerDept}
</div>
),
},
{
accessorKey: "ownerFw",
header: "담당 실사",
enableSorting: true,
cell: ({row}) => (
<div className={infoCellClass} onClick={(e) => handleInfoCellClick(e, row.original)}>
{users.find(u => u.userId === row.original.ownerFw)?.userNm ?? ""}
</div>
) ,
},
{
accessorKey: "regDt",
header: "등록일",
cell: ({row}) => (formatKst(row.original.regDt ?? "", "date")),
enableSorting: true,
}
];
};