key event 함수추가
This commit is contained in:
parent
5510878cc2
commit
fd7d6ad63b
@ -12,8 +12,6 @@ import { currentMenuState, currentObjectState, modifiedPlanFlagState } from '@/s
|
|||||||
import { useCanvasEvent } from '@/hooks/useCanvasEvent'
|
import { useCanvasEvent } from '@/hooks/useCanvasEvent'
|
||||||
import QContextMenu from '@/components/common/context-menu/QContextMenu'
|
import QContextMenu from '@/components/common/context-menu/QContextMenu'
|
||||||
import { useCanvasConfigInitialize } from '@/hooks/common/useCanvasConfigInitialize'
|
import { useCanvasConfigInitialize } from '@/hooks/common/useCanvasConfigInitialize'
|
||||||
|
|
||||||
import { useCommonUtils } from '@/hooks/common/useCommonUtils'
|
|
||||||
import { MENU } from '@/common/common'
|
import { MENU } from '@/common/common'
|
||||||
import PanelBatchStatistics from '@/components/floor-plan/modal/panelBatch/PanelBatchStatistics'
|
import PanelBatchStatistics from '@/components/floor-plan/modal/panelBatch/PanelBatchStatistics'
|
||||||
|
|
||||||
|
|||||||
@ -37,6 +37,7 @@ export function useCommonUtils() {
|
|||||||
const commonTextMode = () => {
|
const commonTextMode = () => {
|
||||||
let textbox
|
let textbox
|
||||||
if (commonUtils.text) {
|
if (commonUtils.text) {
|
||||||
|
commonTextKeyEvent()
|
||||||
addCanvasMouseEventListener('mouse:down', (event) => {
|
addCanvasMouseEventListener('mouse:down', (event) => {
|
||||||
const pointer = canvas?.getPointer(event.e)
|
const pointer = canvas?.getPointer(event.e)
|
||||||
textbox = new fabric.Textbox('', {
|
textbox = new fabric.Textbox('', {
|
||||||
@ -472,30 +473,32 @@ export function useCommonUtils() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//텍스트 모드일때 엔터 이벤트
|
const commonTextKeyEvent = () => {
|
||||||
addDocumentEventListener('keydown', document, (e) => {
|
//텍스트 모드일때 엔터 이벤트
|
||||||
if (e.key === 'Enter') {
|
addDocumentEventListener('keydown', document, (e) => {
|
||||||
const activeObject = canvas.getActiveObject()
|
if (e.key === 'Enter') {
|
||||||
if (activeObject && activeObject.name === 'commonText') {
|
const activeObject = canvas.getActiveObject()
|
||||||
if (activeObject && activeObject.isEditing) {
|
if (activeObject && activeObject.name === 'commonText') {
|
||||||
if (activeObject.text === '') {
|
if (activeObject && activeObject.isEditing) {
|
||||||
canvas?.remove(activeObject)
|
if (activeObject.text === '') {
|
||||||
} else {
|
canvas?.remove(activeObject)
|
||||||
activeObject.exitEditing()
|
} else {
|
||||||
}
|
activeObject.exitEditing()
|
||||||
//정책 협의
|
}
|
||||||
const texts = canvas.getObjects().filter((obj) => obj.name === 'commonText')
|
//정책 협의
|
||||||
texts.forEach((text) => {
|
const texts = canvas.getObjects().filter((obj) => obj.name === 'commonText')
|
||||||
text.set({ editable: false })
|
texts.forEach((text) => {
|
||||||
})
|
text.set({ editable: false })
|
||||||
|
})
|
||||||
|
|
||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
if (setCommonUtilsState) setCommonUtilsState({ ...commonUtils, text: false })
|
if (setCommonUtilsState) setCommonUtilsState({ ...commonUtils, text: false })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
initEvent()
|
||||||
}
|
}
|
||||||
initEvent()
|
})
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
const commonFunctions = (mode) => {
|
const commonFunctions = (mode) => {
|
||||||
let tempStates = { ...commonUtils }
|
let tempStates = { ...commonUtils }
|
||||||
@ -591,6 +594,7 @@ export function useCommonUtils() {
|
|||||||
const obj = canvas?.getActiveObject()
|
const obj = canvas?.getActiveObject()
|
||||||
obj.set({ editable: true })
|
obj.set({ editable: true })
|
||||||
obj.enterEditing()
|
obj.enterEditing()
|
||||||
|
commonTextKeyEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteObject = () => {
|
const deleteObject = () => {
|
||||||
|
|||||||
@ -43,7 +43,7 @@ export function useContextMenu() {
|
|||||||
const { addPopup } = usePopup()
|
const { addPopup } = usePopup()
|
||||||
const [popupId, setPopupId] = useState(uuidv4())
|
const [popupId, setPopupId] = useState(uuidv4())
|
||||||
const [gridColor, setGridColor] = useRecoilState(gridColorState)
|
const [gridColor, setGridColor] = useRecoilState(gridColorState)
|
||||||
const { deleteObject, moveObject, copyObject, editText, changeDimensionExtendLine } = useCommonUtils({})
|
const { deleteObject, moveObject, copyObject, editText, changeDimensionExtendLine } = useCommonUtils()
|
||||||
const [qContextMenu, setQContextMenu] = useRecoilState(contextMenuState)
|
const [qContextMenu, setQContextMenu] = useRecoilState(contextMenuState)
|
||||||
const [cell, setCell] = useState(null)
|
const [cell, setCell] = useState(null)
|
||||||
const [column, setColumn] = useState(null)
|
const [column, setColumn] = useState(null)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user