Compare commits
15 Commits
27e41c783b
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| afb9ff8fa8 | |||
| 904bbd6509 | |||
| 88b36bf27d | |||
| a1835bd63a | |||
| 359969c13f | |||
| 02a830f3ee | |||
| f0cf4a3f71 | |||
| d76176ef5b | |||
| 939a112513 | |||
| 679a5f4b19 | |||
| 2338c991d9 | |||
| 052fb97a51 | |||
| 8ef8de9dae | |||
| 3b7377a5ab | |||
| c575094aad |
20
package-lock.json
generated
20
package-lock.json
generated
@@ -61,7 +61,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/postcss": "^4",
|
"@tailwindcss/postcss": "^4",
|
||||||
"@types/node": "^20",
|
"@types/node": "^24.19.2",
|
||||||
"@types/qrcode": "^1.5.6",
|
"@types/qrcode": "^1.5.6",
|
||||||
"@types/react": "^19",
|
"@types/react": "^19",
|
||||||
"@types/react-dom": "^19",
|
"@types/react-dom": "^19",
|
||||||
@@ -3823,12 +3823,13 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "20.19.25",
|
"version": "24.19.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.25.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.2.tgz",
|
||||||
"integrity": "sha512-ZsJzA5thDQMSQO788d7IocwwQbI8B5OPzmqNvpf3NY/+MHDAS759Wo0gd2WQeXYt5AAAQjzcrTVC6SKCuYgoCQ==",
|
"integrity": "sha512-93d49wCWJkCyN87MxLpNN6KXPCwFw7bVUg79mGUV1OS40JGWwVCr8n61DXCSqz7CV6/VfPkb7xec7uP2M+QHWQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~6.21.0"
|
"undici-types": ">=7.24.0 <7.24.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/qrcode": {
|
"node_modules/@types/qrcode": {
|
||||||
@@ -9111,10 +9112,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici-types": {
|
"node_modules/undici-types": {
|
||||||
"version": "6.21.0",
|
"version": "7.24.6",
|
||||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz",
|
||||||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
"integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/unrs-resolver": {
|
"node_modules/unrs-resolver": {
|
||||||
"version": "1.11.1",
|
"version": "1.11.1",
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/postcss": "^4",
|
"@tailwindcss/postcss": "^4",
|
||||||
"@types/node": "^20",
|
"@types/node": "^24.19.2",
|
||||||
"@types/qrcode": "^1.5.6",
|
"@types/qrcode": "^1.5.6",
|
||||||
"@types/react": "^19",
|
"@types/react": "^19",
|
||||||
"@types/react-dom": "^19",
|
"@types/react-dom": "^19",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useEffect, useMemo, useState } from 'react'
|
import { useEffect, useMemo, useState } from 'react'
|
||||||
|
import { RotateCcw } from 'lucide-react'
|
||||||
import { KriDialog } from '@/components/common/KriDialog'
|
import { KriDialog } from '@/components/common/KriDialog'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { Input } from '@/components/ui/input'
|
import { Input } from '@/components/ui/input'
|
||||||
@@ -107,6 +108,18 @@ const ListFilterDialog = ({
|
|||||||
[rows, headerOptions],
|
[rows, headerOptions],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 잠긴 헤더는 조회 조건에 쓰이지 않으므로 초기화 필요 여부 판단에서 제외한다.
|
||||||
|
const isResettable = rows.some((row) => {
|
||||||
|
if (isDisabledHeader(row.headerId)) return false
|
||||||
|
const defaultOperator = getHeaderOption(row.headerId)?.defaultOperator ?? 'eq'
|
||||||
|
return row.operator !== defaultOperator || row.textValue !== '' || row.multiValues.length > 0
|
||||||
|
})
|
||||||
|
|
||||||
|
// 다이얼로그 내 입력만 기본값으로 되돌린다. 실제 반영은 "적용"을 눌러야 이뤄진다.
|
||||||
|
const handleReset = () => {
|
||||||
|
setRows(headerOptions.map((option) => createFilterRow(option.id, headerOptions)))
|
||||||
|
}
|
||||||
|
|
||||||
const handleConfirm = async () => {
|
const handleConfirm = async () => {
|
||||||
setSubmitting(true)
|
setSubmitting(true)
|
||||||
try {
|
try {
|
||||||
@@ -138,7 +151,20 @@ const ListFilterDialog = ({
|
|||||||
<div className="grid h-11 grid-cols-[1fr_140px_1.4fr] items-center border-b bg-muted px-4 text-sm font-semibold">
|
<div className="grid h-11 grid-cols-[1fr_140px_1.4fr] items-center border-b bg-muted px-4 text-sm font-semibold">
|
||||||
<span>헤더</span>
|
<span>헤더</span>
|
||||||
<span>비교 연산자</span>
|
<span>비교 연산자</span>
|
||||||
|
<div className="flex items-center justify-between gap-2">
|
||||||
<span>값</span>
|
<span>값</span>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
className="h-7 text-muted-foreground"
|
||||||
|
onClick={handleReset}
|
||||||
|
disabled={submitting || !isResettable}
|
||||||
|
>
|
||||||
|
<RotateCcw className="size-3.5" />
|
||||||
|
초기화
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="max-h-170 overflow-auto">
|
<div className="max-h-170 overflow-auto">
|
||||||
|
|||||||
@@ -8,10 +8,25 @@ import { useTextareaInsert } from './hooks/useTextareaInsert'
|
|||||||
|
|
||||||
type SmsEditorProps = Omit<KriEditorProps, 'mode'> & { mode: 'sms' }
|
type SmsEditorProps = Omit<KriEditorProps, 'mode'> & { mode: 'sms' }
|
||||||
|
|
||||||
|
type SmsMessageType = 'SMS' | 'LMS' | 'MMS'
|
||||||
|
|
||||||
function calculateBytes(value: string): number {
|
function calculateBytes(value: string): number {
|
||||||
return new TextEncoder().encode(value).byteLength
|
return new TextEncoder().encode(value).byteLength
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 첨부파일이 있으면 MMS, 제목이 있거나 smsMaxBytes 이상이면 LMS, 나머지는 SMS로 미리보기 판정한다.
|
||||||
|
function getSmsMessageType(hasAttachment: boolean, byteSize: number, smsMaxBytes: number, title: string): SmsMessageType {
|
||||||
|
if (hasAttachment) return 'MMS'
|
||||||
|
if (byteSize >= smsMaxBytes || Boolean(title)) return 'LMS'
|
||||||
|
return 'SMS'
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTextareaMinHeight(hasImages: boolean, hasTitle: boolean): string {
|
||||||
|
if (hasImages) return '160px'
|
||||||
|
if (hasTitle) return '320px'
|
||||||
|
return '360px'
|
||||||
|
}
|
||||||
|
|
||||||
export function KriEditorSms({
|
export function KriEditorSms({
|
||||||
label,
|
label,
|
||||||
value,
|
value,
|
||||||
@@ -34,12 +49,12 @@ export function KriEditorSms({
|
|||||||
const [text, setText] = React.useState(value || '')
|
const [text, setText] = React.useState(value || '')
|
||||||
const textareaRef = React.useRef<HTMLTextAreaElement | null>(null)
|
const textareaRef = React.useRef<HTMLTextAreaElement | null>(null)
|
||||||
const latestTextRef = React.useRef(text)
|
const latestTextRef = React.useRef(text)
|
||||||
const lastTypeRef = React.useRef<'SMS' | 'LMS' | 'MMS' | null>(null)
|
const lastTypeRef = React.useRef<SmsMessageType | null>(null)
|
||||||
const { scheduleChange, flushChange } = useDebouncedChange(onChange, debounceMs)
|
const { scheduleChange, flushChange } = useDebouncedChange(onChange, debounceMs)
|
||||||
const textareaInsert = useTextareaInsert(textareaRef)
|
const textareaInsert = useTextareaInsert(textareaRef)
|
||||||
const previewText = smsPreviewSuffix ? `${text}\n${smsPreviewSuffix}` : text
|
const previewText = smsPreviewSuffix ? `${text}\n${smsPreviewSuffix}` : text
|
||||||
const byteSize = React.useMemo(() => calculateBytes(previewText), [previewText])
|
const byteSize = React.useMemo(() => calculateBytes(previewText), [previewText])
|
||||||
const messageType: 'SMS' | 'LMS' | 'MMS' = smsHasAttachment ? 'MMS' : byteSize >= smsMaxBytes || Boolean(smsTitle) ? 'LMS' : 'SMS'
|
const messageType = getSmsMessageType(smsHasAttachment, byteSize, smsMaxBytes, smsTitle)
|
||||||
const maxBytes = messageType === 'SMS' ? smsMaxBytes : lmsMaxBytes
|
const maxBytes = messageType === 'SMS' ? smsMaxBytes : lmsMaxBytes
|
||||||
|
|
||||||
function getBadgeColor(): string {
|
function getBadgeColor(): string {
|
||||||
@@ -127,7 +142,7 @@ export function KriEditorSms({
|
|||||||
onBlur={() => flushChange(latestTextRef.current)}
|
onBlur={() => flushChange(latestTextRef.current)}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
readOnly={isSmsReadOnly}
|
readOnly={isSmsReadOnly}
|
||||||
style={{ minHeight: smsImages.length > 0 ? '160px' : smsTitle ? '320px' : '360px' }}
|
style={{ minHeight: getTextareaMinHeight(smsImages.length > 0, Boolean(smsTitle)) }}
|
||||||
{...textareaInsert.bindSelectionHandlers}
|
{...textareaInsert.bindSelectionHandlers}
|
||||||
/>
|
/>
|
||||||
{smsPreviewSuffix ? (
|
{smsPreviewSuffix ? (
|
||||||
|
|||||||
@@ -39,6 +39,58 @@ import { useImageMapOverlay } from "./hooks/useImageMapOverlay";
|
|||||||
|
|
||||||
type ViewMode = "wysiwyg" | "html";
|
type ViewMode = "wysiwyg" | "html";
|
||||||
|
|
||||||
|
type ToolbarEndSlotProps = Pick<KriEditorProps, "renderToolbarEnd"> & {
|
||||||
|
editor: Editor;
|
||||||
|
command: KriEditorCommand;
|
||||||
|
view: ViewMode;
|
||||||
|
};
|
||||||
|
|
||||||
|
// command는 ref를 사용하는 함수 묶음이라, 렌더 중 외부 함수에 직접 넘기면 React Compiler가
|
||||||
|
// ref 접근으로 판단한다. 별도 컴포넌트의 props로 전달해 렌더 범위를 분리한다(동작 동일).
|
||||||
|
function ToolbarEndSlot({ renderToolbarEnd, editor, command, view }: Readonly<ToolbarEndSlotProps>) {
|
||||||
|
return <>{renderToolbarEnd?.({ editor, command, view })}</>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 주입된 정제 함수가 우선이고, 없으면 sanitizeHtml 옵션에 따라 기본 정제기를 사용한다.
|
||||||
|
function sanitizeEditorHtml(
|
||||||
|
html: string,
|
||||||
|
htmlSanitizer: KriEditorProps["htmlSanitizer"],
|
||||||
|
sanitizeEnabled: boolean,
|
||||||
|
allowedCustomHtml: KriEditorProps["allowedCustomHtml"],
|
||||||
|
): string {
|
||||||
|
if (htmlSanitizer) return htmlSanitizer(html);
|
||||||
|
if (sanitizeEnabled) return sanitizeHtml(html, allowedCustomHtml);
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeHtmlDraft(
|
||||||
|
draftRef: { current: string },
|
||||||
|
textareaRef: { current: HTMLTextAreaElement | null },
|
||||||
|
html: string,
|
||||||
|
): void {
|
||||||
|
draftRef.current = html;
|
||||||
|
if (textareaRef.current) textareaRef.current.value = html;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 외부에서 본문이 변경된 경우에만 기존 editor 문서를 갱신한다.
|
||||||
|
function syncEditorContent(editor: Editor, value: string, optimisticHtml: string): void {
|
||||||
|
// 빈 문자열("")은 ProseMirror 스키마상 유효한 문서가 아니라 setContent가 조용히 실패해
|
||||||
|
// 이전 템플릿 본문이 그대로 남는 문제가 있었음 -> 빈 값은 빈 문단으로 정규화해서 비교/설정.
|
||||||
|
const normalizedValue = value || "<p></p>";
|
||||||
|
if (normalizedValue === editor.getHTML() || normalizedValue === optimisticHtml) return;
|
||||||
|
|
||||||
|
editor.commands.setContent(normalizedValue, {
|
||||||
|
emitUpdate: false,
|
||||||
|
parseOptions: { preserveWhitespace: "full" },
|
||||||
|
});
|
||||||
|
|
||||||
|
// resize가 활성화된 TipTap 이미지 NodeView는 노드의 src 변경을 기존 DOM에 반영하지 않는다.
|
||||||
|
// editor 전체 대신 NodeView만 다시 생성해 이미지를 갱신하고 편집 포커스는 유지한다.
|
||||||
|
if (normalizedValue.includes("<img")) {
|
||||||
|
editor.createNodeViews();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getToolbarState(editor: Editor): ToolbarState {
|
function getToolbarState(editor: Editor): ToolbarState {
|
||||||
const ts = editor.getAttributes("textStyle") as { fontSize?: string | null; fontFamily?: string | null; color?: string | null };
|
const ts = editor.getAttributes("textStyle") as { fontSize?: string | null; fontFamily?: string | null; color?: string | null };
|
||||||
const hl = editor.getAttributes("highlight") as { color?: string | null };
|
const hl = editor.getAttributes("highlight") as { color?: string | null };
|
||||||
@@ -70,7 +122,7 @@ function getToolbarState(editor: Editor): ToolbarState {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function KriEditorWysiwyg(props: KriEditorProps) {
|
export function KriEditorWysiwyg(props: Readonly<KriEditorProps>) {
|
||||||
const {
|
const {
|
||||||
|
|
||||||
label,
|
label,
|
||||||
@@ -134,6 +186,9 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
|||||||
}, [view]);
|
}, [view]);
|
||||||
|
|
||||||
const htmlDraftRef = useRef<string>(value ?? "");
|
const htmlDraftRef = useRef<string>(value ?? "");
|
||||||
|
// HTML textarea는 비제어 컴포넌트다. 렌더 중 ref를 읽지 않도록, HTML 보기로 전환하는 시점의
|
||||||
|
// 초안을 state로 보관해 textarea가 마운트될 때의 초기값(defaultValue)으로만 사용한다.
|
||||||
|
const [htmlTextareaSeed, setHtmlTextareaSeed] = useState<string>(value ?? "");
|
||||||
const canImageUpload = Boolean(onImageUpload);
|
const canImageUpload = Boolean(onImageUpload);
|
||||||
|
|
||||||
const selectionRef = useRef<{ from: number; to: number } | null>(null);
|
const selectionRef = useRef<{ from: number; to: number } | null>(null);
|
||||||
@@ -471,6 +526,7 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
|||||||
if (viewRef.current === "wysiwyg") {
|
if (viewRef.current === "wysiwyg") {
|
||||||
const raw = editor.getHTML();
|
const raw = editor.getHTML();
|
||||||
htmlDraftRef.current = raw;
|
htmlDraftRef.current = raw;
|
||||||
|
setHtmlTextareaSeed(raw);
|
||||||
setView("html");
|
setView("html");
|
||||||
|
|
||||||
// WYSIWYG에서 막 넘어온, 사용자가 직접 타이핑하지 않은 HTML이므로
|
// WYSIWYG에서 막 넘어온, 사용자가 직접 타이핑하지 않은 HTML이므로
|
||||||
@@ -492,14 +548,12 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
|||||||
toast.message(compatibility.reason ?? "현재 HTML은 WYSIWYG로 전환할 수 없습니다.");
|
toast.message(compatibility.reason ?? "현재 HTML은 WYSIWYG로 전환할 수 없습니다.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const safe = htmlSanitizer
|
const safe = sanitizeEditorHtml(raw, htmlSanitizer, sanitizeHtmlOpt, allowedCustomHtml);
|
||||||
? htmlSanitizer(raw)
|
|
||||||
: sanitizeHtmlOpt ? sanitizeHtml(raw, allowedCustomHtml) : raw;
|
|
||||||
|
|
||||||
editor.commands.setContent(safe, { emitUpdate: false, parseOptions: { preserveWhitespace: "full" } });
|
editor.commands.setContent(safe, { emitUpdate: false, parseOptions: { preserveWhitespace: "full" } });
|
||||||
flushChange(preserveEmptyParagraphs(editor.getHTML()));
|
flushChange(preserveEmptyParagraphs(editor.getHTML()));
|
||||||
setView("wysiwyg");
|
setView("wysiwyg");
|
||||||
}, [allowedCustomHtml, editor, flushChange, getCompatibility, htmlSanitizer, sanitizeHtmlOpt]);
|
}, [allowedCustomHtml, editor, flushChange, getCompatibility, htmlSanitizer, sanitizeHtmlOpt, setView, setPreviewSource, setHtmlTextareaSeed]);
|
||||||
|
|
||||||
const formatHtmlView = useCallback(async () => {
|
const formatHtmlView = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
@@ -512,7 +566,7 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
|||||||
toast.error("HTML 정렬에 실패했습니다.");
|
toast.error("HTML 정렬에 실패했습니다.");
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
}, [scheduleChange]);
|
}, [scheduleChange, setPreviewSource]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!editor) return;
|
if (!editor) return;
|
||||||
@@ -544,46 +598,28 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setPreviewSource(value ?? "");
|
setPreviewSource(value ?? "");
|
||||||
if (!editor) return;
|
if (!editor || value == null) return;
|
||||||
if (value == null) return;
|
|
||||||
|
|
||||||
const compatibility = getCompatibility(value);
|
// WYSIWYG로 손실 없이 편집할 수 없는 값은 HTML 보기로 전환해 원문을 유지한다.
|
||||||
if (showHtmlToggle && !compatibility.compatible) {
|
if (showHtmlToggle && !getCompatibility(value).compatible) {
|
||||||
htmlDraftRef.current = value;
|
writeHtmlDraft(htmlDraftRef, htmlTextareaRef, value);
|
||||||
if (htmlTextareaRef.current) htmlTextareaRef.current.value = value;
|
|
||||||
if (viewRef.current !== "html") {
|
if (viewRef.current !== "html") {
|
||||||
viewRef.current = "html";
|
viewRef.current = "html";
|
||||||
|
setHtmlTextareaSeed(value);
|
||||||
setView("html");
|
setView("html");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viewRef.current === "html") {
|
if (viewRef.current === "html") {
|
||||||
if (getWysiwygCompatibility && value !== optimisticHtmlRef.current && value !== htmlDraftRef.current) {
|
const isExternalChange = value !== optimisticHtmlRef.current && value !== htmlDraftRef.current;
|
||||||
htmlDraftRef.current = value;
|
if (getWysiwygCompatibility && isExternalChange) {
|
||||||
if (htmlTextareaRef.current) htmlTextareaRef.current.value = value;
|
writeHtmlDraft(htmlDraftRef, htmlTextareaRef, value);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 빈 문자열("")은 ProseMirror 스키마상 유효한 문서가 아니라 setContent가 조용히 실패해
|
syncEditorContent(editor, value, optimisticHtmlRef.current);
|
||||||
// 이전 템플릿 본문이 그대로 남는 문제가 있었음 -> 빈 값은 빈 문단으로 정규화해서 비교/설정.
|
|
||||||
const normalizedValue = value || "<p></p>";
|
|
||||||
const current = editor.getHTML();
|
|
||||||
|
|
||||||
if (normalizedValue !== current && normalizedValue !== optimisticHtmlRef.current) {
|
|
||||||
// 외부에서 본문이 변경된 경우에만 기존 editor 문서를 갱신한다.
|
|
||||||
editor.commands.setContent(normalizedValue, {
|
|
||||||
emitUpdate: false,
|
|
||||||
parseOptions: {preserveWhitespace: "full"},
|
|
||||||
});
|
|
||||||
|
|
||||||
// resize가 활성화된 TipTap 이미지 NodeView는 노드의 src 변경을 기존 DOM에 반영하지 않는다.
|
|
||||||
// editor 전체 대신 NodeView만 다시 생성해 이미지를 갱신하고 편집 포커스는 유지한다.
|
|
||||||
if (normalizedValue.includes("<img")) {
|
|
||||||
editor.createNodeViews();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [value, editor, view, getCompatibility, getWysiwygCompatibility, showHtmlToggle]);
|
}, [value, editor, view, getCompatibility, getWysiwygCompatibility, showHtmlToggle]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -648,14 +684,13 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
|||||||
|
|
||||||
const previewHtml = useMemo(() => {
|
const previewHtml = useMemo(() => {
|
||||||
const preserved = preserveEmptyParagraphs(previewSource);
|
const preserved = preserveEmptyParagraphs(previewSource);
|
||||||
const sanitized = htmlSanitizer
|
const sanitized = sanitizeEditorHtml(preserved, htmlSanitizer, sanitizeHtmlOpt, allowedCustomHtml);
|
||||||
? htmlSanitizer(preserved)
|
|
||||||
: sanitizeHtmlOpt ? sanitizeHtml(preserved, allowedCustomHtml) : preserved;
|
|
||||||
const withLinkStyle = applyLinkPreviewClass(sanitized);
|
const withLinkStyle = applyLinkPreviewClass(sanitized);
|
||||||
return transformPreviewHtml ? transformPreviewHtml(withLinkStyle) : withLinkStyle;
|
return transformPreviewHtml ? transformPreviewHtml(withLinkStyle) : withLinkStyle;
|
||||||
}, [allowedCustomHtml, htmlSanitizer, previewSource, sanitizeHtmlOpt, transformPreviewHtml]);
|
}, [allowedCustomHtml, htmlSanitizer, previewSource, sanitizeHtmlOpt, transformPreviewHtml]);
|
||||||
|
|
||||||
const imageMapOverlayBoxes = useImageMapOverlay(previewContainerRef, previewHtml);
|
// 이미지맵을 사용할 때만 미리보기에 <area> 영역을 표시한다.
|
||||||
|
const imageMapOverlayBoxes = useImageMapOverlay(previewContainerRef, previewHtml, enableImageMap && showPreview);
|
||||||
|
|
||||||
const wysiwygCompatibility = useMemo(
|
const wysiwygCompatibility = useMemo(
|
||||||
() => getCompatibility(view === "html" ? previewSource : (editor?.getHTML() ?? previewSource)),
|
() => getCompatibility(view === "html" ? previewSource : (editor?.getHTML() ?? previewSource)),
|
||||||
@@ -704,7 +739,11 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
|||||||
onAddRow={addRow}
|
onAddRow={addRow}
|
||||||
onAddColumn={addColumn}
|
onAddColumn={addColumn}
|
||||||
onDeleteTable={deleteTable}
|
onDeleteTable={deleteTable}
|
||||||
customContent={props.renderToolbarEnd?.({ editor, command, view })}
|
customContent={
|
||||||
|
props.renderToolbarEnd ? (
|
||||||
|
<ToolbarEndSlot renderToolbarEnd={props.renderToolbarEnd} editor={editor} command={command} view={view} />
|
||||||
|
) : undefined
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
@@ -718,7 +757,7 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
|||||||
<textarea
|
<textarea
|
||||||
ref={htmlTextareaRef}
|
ref={htmlTextareaRef}
|
||||||
className="h-[220px] w-full resize-y rounded-md border bg-background p-3 font-mono text-sm outline-none"
|
className="h-[220px] w-full resize-y rounded-md border bg-background p-3 font-mono text-sm outline-none"
|
||||||
defaultValue={htmlDraftRef.current}
|
defaultValue={htmlTextareaSeed}
|
||||||
onMouseDown={(e) => e.stopPropagation()}
|
onMouseDown={(e) => e.stopPropagation()}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
htmlDraftRef.current = e.target.value;
|
htmlDraftRef.current = e.target.value;
|
||||||
@@ -730,9 +769,9 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
|||||||
{...htmlTi.bindSelectionHandlers}
|
{...htmlTi.bindSelectionHandlers}
|
||||||
/>
|
/>
|
||||||
{!wysiwygCompatibility.compatible ? (
|
{!wysiwygCompatibility.compatible ? (
|
||||||
<p className="mt-2 text-xs text-amber-700" role="status">
|
<output className="mt-2 block text-xs text-amber-700">
|
||||||
{wysiwygCompatibility.reason ?? "현재 HTML은 WYSIWYG에서 손실 없이 편집할 수 없습니다."}
|
{wysiwygCompatibility.reason ?? "현재 HTML은 WYSIWYG에서 손실 없이 편집할 수 없습니다."}
|
||||||
</p>
|
</output>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -2,16 +2,18 @@ import { useLayoutEffect, useRef, useState } from "react"
|
|||||||
import { computeImageMapOverlayBoxes, type ImageMapOverlayBox } from "../utils/imageMapOverlay"
|
import { computeImageMapOverlayBoxes, type ImageMapOverlayBox } from "../utils/imageMapOverlay"
|
||||||
|
|
||||||
// previewHtml이 바뀔 때마다(이미지 로드/리사이즈 포함) <map>/<area> 오버레이 위치를 다시 계산한다.
|
// previewHtml이 바뀔 때마다(이미지 로드/리사이즈 포함) <map>/<area> 오버레이 위치를 다시 계산한다.
|
||||||
|
// enabled가 false이면 계산·관찰하지 않는다.
|
||||||
export function useImageMapOverlay(
|
export function useImageMapOverlay(
|
||||||
containerRef: React.RefObject<HTMLElement | null>,
|
containerRef: React.RefObject<HTMLElement | null>,
|
||||||
previewHtml: string,
|
previewHtml: string,
|
||||||
|
enabled = true,
|
||||||
): ImageMapOverlayBox[] {
|
): ImageMapOverlayBox[] {
|
||||||
const [boxes, setBoxes] = useState<ImageMapOverlayBox[]>([])
|
const [boxes, setBoxes] = useState<ImageMapOverlayBox[]>([])
|
||||||
const frameRef = useRef<number | null>(null)
|
const frameRef = useRef<number | null>(null)
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
const container = containerRef.current
|
const container = containerRef.current
|
||||||
if (!container) {
|
if (!enabled || !container) {
|
||||||
setBoxes([])
|
setBoxes([])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -40,7 +42,7 @@ export function useImageMapOverlay(
|
|||||||
resizeObserver.disconnect()
|
resizeObserver.disconnect()
|
||||||
window.removeEventListener("resize", scheduleRecompute)
|
window.removeEventListener("resize", scheduleRecompute)
|
||||||
}
|
}
|
||||||
}, [containerRef, previewHtml])
|
}, [containerRef, previewHtml, enabled])
|
||||||
|
|
||||||
return boxes
|
return boxes
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,10 @@
|
|||||||
|
|
||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
import { useAtom } from 'jotai'
|
import { useAtom } from 'jotai'
|
||||||
import { HttpError } from '@kri/common/http'
|
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { ListJobProgress } from '@/components/list/ListJobProgress'
|
import { ListJobProgress } from '@/components/list/ListJobProgress'
|
||||||
import { useAuth } from '@/hooks/useAuth'
|
import { useAuth } from '@/hooks/useAuth'
|
||||||
import { isAvailabilityUnsupported, useListJob, useListJobAvailability, useUploadResetActive } from '@/query/list-job'
|
import { isAvailabilityUnsupported, isListJobGone, useListJob, useListJobAvailability, useUploadResetActive } from '@/query/list-job'
|
||||||
import { findTrackedListJob, trackListJob, untrackListJob, useTrackedListJobs } from '@/store/list-job-tracker'
|
import { findTrackedListJob, trackListJob, untrackListJob, useTrackedListJobs } from '@/store/list-job-tracker'
|
||||||
import { listJobLabel } from '@/const/listJobConst'
|
import { listJobLabel } from '@/const/listJobConst'
|
||||||
import { blockerJobLabel, blockerPhaseLabel, blockerUserLabel, describeListJobAvailability } from '@/utils/listJobAvailability'
|
import { blockerJobLabel, blockerPhaseLabel, blockerUserLabel, describeListJobAvailability } from '@/utils/listJobAvailability'
|
||||||
@@ -45,7 +44,7 @@ export function useListJobGate({ prjctIdx, jobType, active, requestLabel, pollWh
|
|||||||
const detail = useListJob(prjctIdx, jobKey, active)
|
const detail = useListJob(prjctIdx, jobKey, active)
|
||||||
const job = detail.data?.jobKey === jobKey ? detail.data : undefined
|
const job = detail.data?.jobKey === jobKey ? detail.data : undefined
|
||||||
const finishedJob = job && !isActiveListJob(job.jobStatus) ? job : undefined
|
const finishedJob = job && !isActiveListJob(job.jobStatus) ? job : undefined
|
||||||
const detailNotFound = detail.error instanceof HttpError && detail.error.status === 404
|
const detailNotFound = isListJobGone(detail.error)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!active && requestMatches && openRequest.opened) setOpenRequest(null)
|
if (!active && requestMatches && openRequest.opened) setOpenRequest(null)
|
||||||
|
|||||||
@@ -4,10 +4,9 @@ import { useEffect } from 'react'
|
|||||||
import { usePathname, useRouter } from 'next/navigation'
|
import { usePathname, useRouter } from 'next/navigation'
|
||||||
import { useAtom } from 'jotai'
|
import { useAtom } from 'jotai'
|
||||||
import { useQueries, useQueryClient } from '@tanstack/react-query'
|
import { useQueries, useQueryClient } from '@tanstack/react-query'
|
||||||
import { HttpError } from '@kri/common/http'
|
|
||||||
import { toast } from 'sonner'
|
import { toast } from 'sonner'
|
||||||
import { nextApi } from '@/lib/http-client'
|
import { nextApi } from '@/lib/http-client'
|
||||||
import { listJobKeys, useMyActiveListJobs } from '@/query/list-job'
|
import { isListJobGone, listJobKeys, useMyActiveListJobs } from '@/query/list-job'
|
||||||
import { listJobOpenRequestAtom } from '@/store/jotai/list-job'
|
import { listJobOpenRequestAtom } from '@/store/jotai/list-job'
|
||||||
import { useSelectedProject } from '@/hooks/useSelectedProject'
|
import { useSelectedProject } from '@/hooks/useSelectedProject'
|
||||||
import { useDialog } from '@/hooks/useDialog'
|
import { useDialog } from '@/hooks/useDialog'
|
||||||
@@ -90,7 +89,7 @@ export function ListJobWatcher({ userId, prjctIdx }: { userId: string; prjctIdx:
|
|||||||
details.forEach((result, index) => {
|
details.forEach((result, index) => {
|
||||||
const tracked = trackedJobs[index]
|
const tracked = trackedJobs[index]
|
||||||
if (!tracked) return
|
if (!tracked) return
|
||||||
if (result.error instanceof HttpError && result.error.status === 404) {
|
if (isListJobGone(result.error)) {
|
||||||
untrackListJob(tracked.jobKey)
|
untrackListJob(tracked.jobKey)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { useSetAtom } from "jotai";
|
||||||
import { nextApi } from "@/lib/http-client";
|
import { nextApi } from "@/lib/http-client";
|
||||||
import { useAuth } from "@/hooks/useAuth";
|
import { useAuth } from "@/hooks/useAuth";
|
||||||
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
||||||
|
import { clearTrackedListJobs } from "@/store/list-job-tracker";
|
||||||
|
import { listJobOpenRequestAtom } from "@/store/jotai/list-job";
|
||||||
import type { LoginUser } from "@kri/common";
|
import type { LoginUser } from "@kri/common";
|
||||||
|
|
||||||
export const useLoginMutation = () => {
|
export const useLoginMutation = () => {
|
||||||
@@ -31,6 +34,7 @@ export const useLogoutMutation = () => {
|
|||||||
const qc = useQueryClient();
|
const qc = useQueryClient();
|
||||||
const { auth, logout } = useAuth();
|
const { auth, logout } = useAuth();
|
||||||
const { clearSelectedProject } = useSelectedProject();
|
const { clearSelectedProject } = useSelectedProject();
|
||||||
|
const setListJobOpenRequest = useSetAtom(listJobOpenRequestAtom);
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
@@ -49,6 +53,8 @@ export const useLogoutMutation = () => {
|
|||||||
},
|
},
|
||||||
onSettled: () => {
|
onSettled: () => {
|
||||||
clearSelectedProject();
|
clearSelectedProject();
|
||||||
|
clearTrackedListJobs();
|
||||||
|
setListJobOpenRequest(null);
|
||||||
logout();
|
logout();
|
||||||
qc.clear(); // 다음 사용자/세션에 서버상태 남지 않게
|
qc.clear(); // 다음 사용자/세션에 서버상태 남지 않게
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -38,6 +38,14 @@ const fetchAvailability = async (prjctIdx: number, jobType: ListJobType) =>
|
|||||||
/** 신규 API 미배포·롤백 상태. 반복 호출하지 않고 사전 안내만 중단한다. */
|
/** 신규 API 미배포·롤백 상태. 반복 호출하지 않고 사전 안내만 중단한다. */
|
||||||
export const isAvailabilityUnsupported = (error: unknown) => error instanceof HttpError && error.status === 404
|
export const isAvailabilityUnsupported = (error: unknown) => error instanceof HttpError && error.status === 404
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 작업을 더 이상 조회할 수 없는 경우. 기록을 지우고 반복 조회를 멈춘다.
|
||||||
|
* - 404: 작업이 만료됐거나 내 작업이 아니다.
|
||||||
|
* - 403 PROJECT_ACCESS_DENIED: 프로젝트가 삭제됐거나 접근 권한·배정·상태가 바뀌었다.
|
||||||
|
*/
|
||||||
|
export const isListJobGone = (error: unknown) => error instanceof HttpError
|
||||||
|
&& (error.status === 404 || (error.status === 403 && apiError(error).code === 'PROJECT_ACCESS_DENIED'))
|
||||||
|
|
||||||
export function useSubmitListJob(prjctIdx: number) {
|
export function useSubmitListJob(prjctIdx: number) {
|
||||||
const qc = useQueryClient()
|
const qc = useQueryClient()
|
||||||
const { auth } = useAuth()
|
const { auth } = useAuth()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useSyncExternalStore } from 'react'
|
import { useSyncExternalStore } from 'react'
|
||||||
import { getLocalStorage, setLocalStorage } from '@/store/storage/secure-storage'
|
import { getLocalStorage, removeLocalStorage, setLocalStorage } from '@/store/storage/secure-storage'
|
||||||
import { StorageKeys } from '@/store/storage/storage-keys'
|
import { StorageKeys } from '@/store/storage/storage-keys'
|
||||||
import { isListJobType, type ListJobType } from '@/types/list-job'
|
import { isListJobType, type ListJobType } from '@/types/list-job'
|
||||||
|
|
||||||
@@ -77,6 +77,14 @@ export const untrackListJob = (jobKey: string) => {
|
|||||||
write(jobs.filter((job) => job.jobKey !== jobKey))
|
write(jobs.filter((job) => job.jobKey !== jobKey))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 로그아웃 시 다음 사용자에게 기록이 남지 않게 모두 지운다. 진행 중인 작업은 재로그인 후 my-active 조회로 다시 채워진다. */
|
||||||
|
export const clearTrackedListJobs = () => {
|
||||||
|
if (typeof window === 'undefined') return
|
||||||
|
removeLocalStorage(StorageKeys.ListJobs)
|
||||||
|
cache = EMPTY
|
||||||
|
window.dispatchEvent(new Event(CHANGE_EVENT))
|
||||||
|
}
|
||||||
|
|
||||||
export const findTrackedListJob = (jobs: TrackedListJob[], userId: string, prjctIdx: number, jobType: ListJobType) =>
|
export const findTrackedListJob = (jobs: TrackedListJob[], userId: string, prjctIdx: number, jobType: ListJobType) =>
|
||||||
jobs.find((job) => job.userId === userId && job.prjctIdx === prjctIdx && job.jobType === jobType)
|
jobs.find((job) => job.userId === userId && job.prjctIdx === prjctIdx && job.jobType === jobType)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user