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 QContextMenu from '@/components/common/context-menu/QContextMenu'
|
||||
import { useCanvasConfigInitialize } from '@/hooks/common/useCanvasConfigInitialize'
|
||||
|
||||
import { useCommonUtils } from '@/hooks/common/useCommonUtils'
|
||||
import { MENU } from '@/common/common'
|
||||
import PanelBatchStatistics from '@/components/floor-plan/modal/panelBatch/PanelBatchStatistics'
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@ export function useCommonUtils() {
|
||||
const commonTextMode = () => {
|
||||
let textbox
|
||||
if (commonUtils.text) {
|
||||
commonTextKeyEvent()
|
||||
addCanvasMouseEventListener('mouse:down', (event) => {
|
||||
const pointer = canvas?.getPointer(event.e)
|
||||
textbox = new fabric.Textbox('', {
|
||||
@ -472,30 +473,32 @@ export function useCommonUtils() {
|
||||
}
|
||||
}
|
||||
|
||||
//텍스트 모드일때 엔터 이벤트
|
||||
addDocumentEventListener('keydown', document, (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
const activeObject = canvas.getActiveObject()
|
||||
if (activeObject && activeObject.name === 'commonText') {
|
||||
if (activeObject && activeObject.isEditing) {
|
||||
if (activeObject.text === '') {
|
||||
canvas?.remove(activeObject)
|
||||
} else {
|
||||
activeObject.exitEditing()
|
||||
}
|
||||
//정책 협의
|
||||
const texts = canvas.getObjects().filter((obj) => obj.name === 'commonText')
|
||||
texts.forEach((text) => {
|
||||
text.set({ editable: false })
|
||||
})
|
||||
const commonTextKeyEvent = () => {
|
||||
//텍스트 모드일때 엔터 이벤트
|
||||
addDocumentEventListener('keydown', document, (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
const activeObject = canvas.getActiveObject()
|
||||
if (activeObject && activeObject.name === 'commonText') {
|
||||
if (activeObject && activeObject.isEditing) {
|
||||
if (activeObject.text === '') {
|
||||
canvas?.remove(activeObject)
|
||||
} else {
|
||||
activeObject.exitEditing()
|
||||
}
|
||||
//정책 협의
|
||||
const texts = canvas.getObjects().filter((obj) => obj.name === 'commonText')
|
||||
texts.forEach((text) => {
|
||||
text.set({ editable: false })
|
||||
})
|
||||
|
||||
canvas.renderAll()
|
||||
if (setCommonUtilsState) setCommonUtilsState({ ...commonUtils, text: false })
|
||||
canvas.renderAll()
|
||||
if (setCommonUtilsState) setCommonUtilsState({ ...commonUtils, text: false })
|
||||
}
|
||||
}
|
||||
initEvent()
|
||||
}
|
||||
initEvent()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const commonFunctions = (mode) => {
|
||||
let tempStates = { ...commonUtils }
|
||||
@ -591,6 +594,7 @@ export function useCommonUtils() {
|
||||
const obj = canvas?.getActiveObject()
|
||||
obj.set({ editable: true })
|
||||
obj.enterEditing()
|
||||
commonTextKeyEvent()
|
||||
}
|
||||
|
||||
const deleteObject = () => {
|
||||
|
||||
@ -43,7 +43,7 @@ export function useContextMenu() {
|
||||
const { addPopup } = usePopup()
|
||||
const [popupId, setPopupId] = useState(uuidv4())
|
||||
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 [cell, setCell] = useState(null)
|
||||
const [column, setColumn] = useState(null)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user