@team-monolith/cds 1.84.7 → 1.84.9
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/patterns/LexicalEditor/components/FileSelectInput.js +4 -4
- package/dist/patterns/LexicalEditor/components/UploadFileDialog/UploadFileDialog.js +2 -3
- package/dist/patterns/LexicalEditor/nodes/FileNode/FileComponent.js +1 -1
- package/dist/patterns/LexicalEditor/nodes/FileNode/FileDownloadButton.js +12 -5
- package/dist/patterns/LexicalEditor/plugins/ComponentAdderPlugin/ComponentAdderPlugin.js +2 -2
- package/dist/patterns/LexicalEditor/plugins/ComponentPickerMenuPlugin/ComponentPickerMenuPlugin.js +2 -2
- package/package.json +1 -1
|
@@ -44,10 +44,10 @@ export function FileSelectInput(props) {
|
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
if (accept) {
|
|
47
|
-
const isTypeValid = accept === "*" ||
|
|
48
|
-
|
|
49
|
-
accept.slice(1) === ((_b = file.name.split(".").pop()) === null || _b === void 0 ? void 0 : _b.toLowerCase())
|
|
50
|
-
|
|
47
|
+
const isTypeValid = accept === "*" ||
|
|
48
|
+
(accept.startsWith(".")
|
|
49
|
+
? accept.slice(1) === ((_b = file.name.split(".").pop()) === null || _b === void 0 ? void 0 : _b.toLowerCase())
|
|
50
|
+
: new RegExp(accept.replace("*", ".*")).test(file.type));
|
|
51
51
|
if (!isTypeValid) {
|
|
52
52
|
setErrorMessage(`업로드할 수 없는 파일입니다. ${typeStr}을 업로드해주세요.`);
|
|
53
53
|
event.target.value = "";
|
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { jsx as _jsx
|
|
10
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
11
11
|
/** @jsxImportSource @emotion/react */
|
|
12
12
|
import { useContext, useEffect, useRef } from "react";
|
|
13
13
|
import moment from "moment";
|
|
@@ -43,7 +43,6 @@ export function UploadFileDialog({ open, onClose, onChange, }) {
|
|
|
43
43
|
fileSize: file.size,
|
|
44
44
|
fileUploadDate: moment().format("YYYY.MM.DD HH:mm:ss"),
|
|
45
45
|
});
|
|
46
|
-
onClose();
|
|
47
46
|
}
|
|
48
47
|
onClose();
|
|
49
48
|
});
|
|
@@ -53,7 +52,7 @@ export function UploadFileDialog({ open, onClose, onChange, }) {
|
|
|
53
52
|
inputRef.current.click();
|
|
54
53
|
}
|
|
55
54
|
}, [open]);
|
|
56
|
-
return (_jsx(
|
|
55
|
+
return (_jsx(HiddenInput, { ref: inputRef, type: "file", accept: "*", onChange: handleFileChange }));
|
|
57
56
|
}
|
|
58
57
|
const HiddenInput = styled.input `
|
|
59
58
|
display: none;
|
|
@@ -43,7 +43,7 @@ export function FileComponent({ fileName, fileSize, nodeKey, fileUrl, fileUpload
|
|
|
43
43
|
}
|
|
44
44
|
return false;
|
|
45
45
|
}, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW)), [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected]);
|
|
46
|
-
return (_jsx(_Fragment, { children: isEditable ? (_jsx(FileDetailContainer, Object.assign({ isSelected: isSelected }, { children: _jsxs(FileInfo,
|
|
46
|
+
return (_jsx(_Fragment, { children: isEditable ? (_jsx(FileDetailContainer, Object.assign({ isSelected: isSelected, ref: ref }, { children: _jsxs(FileInfo, { children: [_jsx(IconContainer, { children: getFileIcon(fileName) }), _jsx(FileName, { children: _jsx(OverflowTooltip, { text: fileName }) }), _jsx(FileOptionalInfo, { children: fileUploadDate }), _jsxs(FileSize, { children: [(fileSize / (1024 * 1024)).toFixed(1), " MB"] })] }) }))) : (_jsx(FileDownloadButton, { fileName: fileName, fileUrl: fileUrl, fileSize: fileSize })) }));
|
|
47
47
|
}
|
|
48
48
|
export const FileName = styled.div `
|
|
49
49
|
flex: 1;
|
|
@@ -14,6 +14,7 @@ import { FileSize, getFileIcon, IconContainer } from "./FileComponent";
|
|
|
14
14
|
import { OverflowTooltip } from "../../../../components/OverflowTooltip";
|
|
15
15
|
import { useContext } from "react";
|
|
16
16
|
import { CdsContext } from "../../../../CdsProvider";
|
|
17
|
+
import { HOVER } from "../../../../utils/hover";
|
|
17
18
|
/**
|
|
18
19
|
* 파일 업로드 블록 내에서 삽입하기를 통해 렉시컬에 삽입된 파일블록을 표시하는 컴포넌트입니다. (ReadOnly)
|
|
19
20
|
* images/2025-02-05-10-53-19.png
|
|
@@ -29,23 +30,28 @@ export function FileDownloadButton({ fileName, fileSize, fileUrl, }) {
|
|
|
29
30
|
showFileError === null || showFileError === void 0 ? void 0 : showFileError("download", "다운로드 중 오류가 발생했어요");
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
33
|
+
// fileUrl에 대해 GET 요청을 보냅니다.
|
|
32
34
|
const response = yield fetch(fileUrl, { method: "GET" });
|
|
33
35
|
if (!response.ok) {
|
|
34
36
|
showFileError === null || showFileError === void 0 ? void 0 : showFileError("download", "파일이 삭제되어 다운로드할 수 없어요.");
|
|
35
37
|
return;
|
|
36
38
|
}
|
|
39
|
+
// 요청이 성공하면 응답 데이터를 Blob(파일 데이터)로 변환
|
|
37
40
|
const blob = yield response.blob();
|
|
41
|
+
// Blob으로부터 임시 URL을 생성
|
|
38
42
|
const blobUrl = URL.createObjectURL(blob);
|
|
43
|
+
// 다운로드를 위해 anchor 요소를 생성
|
|
39
44
|
const link = document.createElement("a");
|
|
40
45
|
link.href = blobUrl;
|
|
46
|
+
// 다운로드할 때 사용할 파일명을 지정
|
|
41
47
|
link.download = fileName;
|
|
42
48
|
document.body.appendChild(link);
|
|
43
49
|
link.click();
|
|
44
50
|
document.body.removeChild(link);
|
|
51
|
+
// 생성된 Blob URL을 해제
|
|
45
52
|
URL.revokeObjectURL(blobUrl);
|
|
46
53
|
}
|
|
47
|
-
catch (
|
|
48
|
-
console.error("다운로드 실패:", error);
|
|
54
|
+
catch (_b) {
|
|
49
55
|
showFileError === null || showFileError === void 0 ? void 0 : showFileError("download", "파일을 다운로드할 수 없어요.");
|
|
50
56
|
}
|
|
51
57
|
});
|
|
@@ -70,9 +76,10 @@ const ButtonContainer = styled.button(({ theme }) => css `
|
|
|
70
76
|
text-align: left;
|
|
71
77
|
overflow: hidden;
|
|
72
78
|
|
|
73
|
-
|
|
74
|
-
background
|
|
75
|
-
|
|
79
|
+
${HOVER(css `
|
|
80
|
+
background: ${theme.color.background.neutralAltActive};
|
|
81
|
+
color: ${theme.color.foreground.neutralBaseActive};
|
|
82
|
+
`)}
|
|
76
83
|
`);
|
|
77
84
|
const FileNameLabel = styled.div `
|
|
78
85
|
max-width: 152px;
|
|
@@ -156,9 +156,9 @@ export function ComponentAdderPlugin(props) {
|
|
|
156
156
|
const { onDragStart, onDragEnd, targetLineRef } = useDraggableBlockMenu(editor, anchorElem, blockElem, setBlockElem);
|
|
157
157
|
return (_jsxs(_Fragment, { children: [_jsx(InsertImageDialog, { open: imageOpen, title: "\uC774\uBBF8\uC9C0 \uC0BD\uC785\uD558\uAE30", onClose: () => setImageOpen(false), onChange: (props) => {
|
|
158
158
|
editor.dispatchCommand(INSERT_IMAGE_COMMAND, props);
|
|
159
|
-
}, shouldReset: true }),
|
|
159
|
+
}, shouldReset: true }), _jsx(UploadFileDialog, { open: fileOpen, onClose: () => setFileOpen(false), onChange: (props) => {
|
|
160
160
|
editor.dispatchCommand(UPLOAD_FILE_COMMAND, props);
|
|
161
|
-
} })
|
|
161
|
+
} }), _jsx(LexicalNodeMenuPlugin, { nodeKey: nodeKey, anchorClassName: cssToClassName `
|
|
162
162
|
z-index: ${ZINDEX.DIALOG + 1};
|
|
163
163
|
`, options: filteredOptions, menuRenderFn: (anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => anchorElementRef.current && filteredOptions.length
|
|
164
164
|
? ReactDOM.createPortal(_jsx(ComponentPickerMenuList, { options: filteredOptions, selectedIndex: selectedIndex, selectOptionAndCleanUp: selectOptionAndCleanUp, setHighlightedIndex: setHighlightedIndex }), anchorElementRef.current)
|
package/dist/patterns/LexicalEditor/plugins/ComponentPickerMenuPlugin/ComponentPickerMenuPlugin.js
CHANGED
|
@@ -339,9 +339,9 @@ export function ComponentPickerMenuPlugin(props) {
|
|
|
339
339
|
}, [editor]);
|
|
340
340
|
return (_jsxs(_Fragment, { children: [_jsx(InsertImageDialog, { title: "\uC774\uBBF8\uC9C0 \uC0BD\uC785\uD558\uAE30", open: open, onChange: (props) => {
|
|
341
341
|
editor.dispatchCommand(INSERT_IMAGE_COMMAND, props);
|
|
342
|
-
}, onClose: () => setOpen(false), shouldReset: true }),
|
|
342
|
+
}, onClose: () => setOpen(false), shouldReset: true }), _jsx(UploadFileDialog, { open: fileOpen, onClose: () => setFileOpen(false), onChange: (props) => {
|
|
343
343
|
editor.dispatchCommand(UPLOAD_FILE_COMMAND, props);
|
|
344
|
-
} })
|
|
344
|
+
} }), _jsx(LexicalTypeaheadMenuPlugin, { onQueryChange: setQueryString, onSelectOption: onSelectOption, triggerFn: checkForTriggerMatch, options: options, anchorClassName: cssToClassName `
|
|
345
345
|
z-index: ${ZINDEX.DIALOG + 1};
|
|
346
346
|
`, menuRenderFn: (anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => anchorElementRef.current && options.length
|
|
347
347
|
? ReactDOM.createPortal(_jsx(ComponentPickerMenuList, { options: options, selectedIndex: selectedIndex, selectOptionAndCleanUp: selectOptionAndCleanUp, setHighlightedIndex: setHighlightedIndex }), anchorElementRef.current)
|