瀏覽代碼

Fixed bug related to locked tools & select tool (#331)

main
Proful Sadangi 3 年之前
父節點
當前提交
a1f4149efe
No account linked to committer's email address
共有 2 個文件被更改,包括 4 次插入4 次删除
  1. 1
    0
      packages/tldraw/src/components/ToolsPanel/PrimaryTools.tsx
  2. 3
    4
      packages/tldraw/src/state/TldrawApp.ts

+ 1
- 0
packages/tldraw/src/components/ToolsPanel/PrimaryTools.tsx 查看文件

87
         kbd={'7'}
87
         kbd={'7'}
88
         label={TDShapeType.Text}
88
         label={TDShapeType.Text}
89
         onClick={selectTextTool}
89
         onClick={selectTextTool}
90
+        isLocked={isToolLocked}
90
         isActive={activeTool === TDShapeType.Text}
91
         isActive={activeTool === TDShapeType.Text}
91
       >
92
       >
92
         <TextIcon />
93
         <TextIcon />

+ 3
- 4
packages/tldraw/src/state/TldrawApp.ts 查看文件

1839
 
1839
 
1840
     this.addToSelectHistory(this.selectedIds)
1840
     this.addToSelectHistory(this.selectedIds)
1841
 
1841
 
1842
-    if (this.appState.activeTool !== 'select') {
1843
-      this.selectTool('select')
1844
-    }
1842
+    this.selectTool('select')
1845
 
1843
 
1846
     return this
1844
     return this
1847
   }
1845
   }
2730
     if (Date.now() - this.editingStartTime < 50) return
2728
     if (Date.now() - this.editingStartTime < 50) return
2731
 
2729
 
2732
     const { editingId } = this.pageState
2730
     const { editingId } = this.pageState
2731
+    const { isToolLocked } = this.getAppState()
2733
 
2732
 
2734
     if (editingId) {
2733
     if (editingId) {
2735
       // If we're editing text, then delete the text if it's empty
2734
       // If we're editing text, then delete the text if it's empty
2738
       if (shape.type === TDShapeType.Text) {
2737
       if (shape.type === TDShapeType.Text) {
2739
         if (shape.text.trim().length <= 0) {
2738
         if (shape.text.trim().length <= 0) {
2740
           this.patchState(Commands.deleteShapes(this, [editingId]).after, 'delete_empty_text')
2739
           this.patchState(Commands.deleteShapes(this, [editingId]).after, 'delete_empty_text')
2741
-        } else {
2740
+        } else if (!isToolLocked) {
2742
           this.select(editingId)
2741
           this.select(editingId)
2743
         }
2742
         }
2744
       }
2743
       }

Loading…
取消
儲存