[1059] : [HANASYS DESIGN】文字作成について]

[작업내용] : 텍스트 입력 모드 토글로 종료 모드 기능 추가
This commit is contained in:
yjnoh 2025-05-26 17:33:45 +09:00
parent 50aa5ca556
commit ed68a93b20
2 changed files with 50 additions and 27 deletions

View File

@ -210,6 +210,7 @@ export const SAVE_KEY = [
'toFixed', 'toFixed',
'startPoint', 'startPoint',
'endPoint', 'endPoint',
'editable',
'isSortedPoints', 'isSortedPoints',
] ]

View File

@ -22,12 +22,12 @@ export function useCommonUtils() {
const lengthTextFont = useRecoilValue(fontSelector('lengthText')) const lengthTextFont = useRecoilValue(fontSelector('lengthText'))
const commonTextFont = useRecoilValue(fontSelector('commonText')) const commonTextFont = useRecoilValue(fontSelector('commonText'))
const [commonUtils, setCommonUtilsState] = useRecoilState(commonUtilsState) const [commonUtils, setCommonUtilsState] = useRecoilState(commonUtilsState)
const { addPopup } = usePopup() const { addPopup, closeAll } = usePopup()
const { drawDirectionArrow, addLengthText } = usePolygon() const { drawDirectionArrow, addLengthText } = usePolygon()
const { applyDormers } = useObjectBatch({}) const { applyDormers } = useObjectBatch({})
useEffect(() => { useEffect(() => {
if (commonUtils.text) { if (commonUtils.text || !commonUtils.text) {
commonTextMode() commonTextMode()
} else if (commonUtils.dimension) { } else if (commonUtils.dimension) {
commonDimensionMode() commonDimensionMode()
@ -38,7 +38,9 @@ export function useCommonUtils() {
const commonTextMode = () => { const commonTextMode = () => {
let textbox let textbox
closeAll()
if (commonUtils.text) { if (commonUtils.text) {
setTimeout(() => {
commonTextKeyEvent() commonTextKeyEvent()
addCanvasMouseEventListener('mouse:down', (event) => { addCanvasMouseEventListener('mouse:down', (event) => {
const pointer = canvas?.getPointer(event.e) const pointer = canvas?.getPointer(event.e)
@ -67,6 +69,26 @@ export function useCommonUtils() {
textbox.enterEditing() textbox.enterEditing()
textbox.selectAll() textbox.selectAll()
}) })
}, 100)
} else {
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()
}
}
initEvent()
} }
} }