Skip to content

Commit

Permalink
Merge pull request #369 from TripInfoWeb/dev_refactoring
Browse files Browse the repository at this point in the history
Feat: 여행일기 이미지 resizing 기능 추가
  • Loading branch information
HyunJinNo authored Sep 22, 2024
2 parents c49be36 + 3363461 commit 5c6edd0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
10 changes: 10 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"next": "14.2.10",
"node-html-parser": "^6.1.13",
"quill-image-drop-and-paste": "^2.0.1",
"quill-image-resize-module-ts": "^3.0.3",
"rc-slider": "^11.1.5",
"react": "^18",
"react-date-range": "^2.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/constants/common/sanitizeOption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const sanitizeOption = {
blockquote: ["class", "style"],
pre: ["class", "style", "spellcheck"],
a: ["class", "style", "href", "rel", "target", "style"],
img: ["class", "style", "src"],
img: ["class", "style", "src", "width"],
iframe: ["class", "style", "frameborder", "allowfullscreen", "src"],
},
allowedSchemes: ["data", "http", "https"],
Expand Down
10 changes: 10 additions & 0 deletions src/containers/diary/write/QuillEditorContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ImageDropAndPaste, { ImageData } from "quill-image-drop-and-paste";
import { useEffect, useMemo, useRef, useState } from "react";
import { useFormContext } from "react-hook-form";
import ReactQuill, { Quill } from "react-quill";
import { ImageResize } from "quill-image-resize-module-ts";

const QuillEditorContainer = () => {
const authStore = useAuthStore();
Expand Down Expand Up @@ -106,6 +107,7 @@ const QuillEditorContainer = () => {
};

const modules = useMemo(() => {
ReactQuill.Quill.register("modules/imageResize", ImageResize);
ReactQuill.Quill.register("modules/imageDropAndPaste", ImageDropAndPaste);

return {
Expand All @@ -119,6 +121,14 @@ const QuillEditorContainer = () => {
],
handlers: { image: imageHandler },
},
imageResize: {
modules: ["Resize", "DisplaySize", "Toolbar"],
handleStyles: {
backgroundColor: "#00B488",
border: "none",
// other camelCase styles for size display
},
},
imageDropAndPaste: {
// add an custom image handler
handler: imageDropAndPasteHandler,
Expand Down

0 comments on commit 5c6edd0

Please sign in to comment.