From dfcb27d09e40d7e0b19c82e191c2a4d7e0c6cf17 Mon Sep 17 00:00:00 2001 From: yjnoh Date: Wed, 4 Sep 2024 10:37:11 +0900 Subject: [PATCH 1/2] =?UTF-8?q?template=20svg=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/drawTemplates/153302.svg | 23 ------------------- public/drawTemplates/shape21.svg | 4 ---- .../context-menu/QPolygonContextMenu.jsx | 17 ++++++++++++++ src/components/ui/SurfaceShape.jsx | 4 ++-- 4 files changed, 19 insertions(+), 29 deletions(-) delete mode 100644 public/drawTemplates/153302.svg delete mode 100644 public/drawTemplates/shape21.svg diff --git a/public/drawTemplates/153302.svg b/public/drawTemplates/153302.svg deleted file mode 100644 index 3b1c97b0..00000000 --- a/public/drawTemplates/153302.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - - -Created by potrace 1.15, written by Peter Selinger 2001-2017 - - - - - - - diff --git a/public/drawTemplates/shape21.svg b/public/drawTemplates/shape21.svg deleted file mode 100644 index a2d901e7..00000000 --- a/public/drawTemplates/shape21.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/components/common/context-menu/QPolygonContextMenu.jsx b/src/components/common/context-menu/QPolygonContextMenu.jsx index b3246165..5c886816 100644 --- a/src/components/common/context-menu/QPolygonContextMenu.jsx +++ b/src/components/common/context-menu/QPolygonContextMenu.jsx @@ -7,6 +7,13 @@ export default function QPolygonContextMenu(props) { // const children = useRecoilValue(modalContent) const [contextMenu, setContextMenu] = useState({ visible: false, x: 0, y: 0 }) + const optionName = canvasProps.getActiveObject().initOptions.name + + let contextType = '' + + if (optionName.indexOf('guide') > -1) { + contextType = 'surface' + } useEffect(() => { if (!contextRef.current) return @@ -63,6 +70,16 @@ export default function QPolygonContextMenu(props) {
  • handleMenuClick(3)}> Option 3
  • + {contextType === 'surface' ? ( + <> +
  • handleMenuClick(4)}> + 모듈,회로구성 +
  • +
  • handleMenuClick(4)}> + 모듈 채우기 +
  • + + ) : null} )} diff --git a/src/components/ui/SurfaceShape.jsx b/src/components/ui/SurfaceShape.jsx index 06e2e0e3..46bac2a5 100644 --- a/src/components/ui/SurfaceShape.jsx +++ b/src/components/ui/SurfaceShape.jsx @@ -601,7 +601,7 @@ export const SurfaceShapeModal = ({ canvas }) => { fill: 'transparent', stroke: 'black', strokeWidth: 2, - selectable: false, + selectable: true, fontSize: fontSize, name: 'guideTriangle', }) @@ -610,7 +610,7 @@ export const SurfaceShapeModal = ({ canvas }) => { fill: 'transparent', stroke: 'black', strokeWidth: 2, - selectable: false, + selectable: true, fontSize: fontSize, name: 'guideTriangle', flipX: true, From 3fa147b12e7f9800ac2bdd88dfe1ef13a035ec3b Mon Sep 17 00:00:00 2001 From: yjnoh Date: Wed, 4 Sep 2024 12:45:52 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=ED=8F=B4=EB=A6=AC=EA=B3=A4=20context=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/context-menu/QPolygonContextMenu.jsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/common/context-menu/QPolygonContextMenu.jsx b/src/components/common/context-menu/QPolygonContextMenu.jsx index 5c886816..8558ee72 100644 --- a/src/components/common/context-menu/QPolygonContextMenu.jsx +++ b/src/components/common/context-menu/QPolygonContextMenu.jsx @@ -7,12 +7,12 @@ export default function QPolygonContextMenu(props) { // const children = useRecoilValue(modalContent) const [contextMenu, setContextMenu] = useState({ visible: false, x: 0, y: 0 }) - const optionName = canvasProps.getActiveObject().initOptions.name + const polygon = canvasProps.getActiveObject() //액티브된 객체를 가져옴 let contextType = '' - if (optionName.indexOf('guide') > -1) { - contextType = 'surface' + if (polygon.initOptions.name.indexOf('guide') > -1) { + contextType = 'surface' //면형상 } useEffect(() => { @@ -20,6 +20,9 @@ export default function QPolygonContextMenu(props) { const handleContextMenu = (e) => { e.preventDefault() //기존 contextmenu 막고 + + // Fabric.js 상의 객체에 직접 이벤트를 트리거할 수는 없으므로, + // 캔버스 요소에 이벤트를 디스패치하여 처리 setContextMenu({ visible: true, x: e.pageX, y: e.pageY }) canvasProps.upperCanvasEl.removeEventListener('contextmenu', handleContextMenu) //한번 노출 후 이벤트 삭제 } @@ -72,9 +75,6 @@ export default function QPolygonContextMenu(props) { {contextType === 'surface' ? ( <> -
  • handleMenuClick(4)}> - 모듈,회로구성 -
  • handleMenuClick(4)}> 모듈 채우기