fix(editor): connector target position NaN (#11606)

Close [BS-3086](https://linear.app/affine-design/issue/BS-3086/frame里套frame,连一下connector,拖两下,白板损坏)

### What Changes
- Fixed `bound.toRelative` may be return `NaN` when `bound.w === 0 || bound.h ===0`
- Remove type assertions from `connector-manager.ts` for more type safety
This commit is contained in:
L-Sun
2025-04-10 12:33:24 +00:00
parent d5aebc1421
commit 588659ef67
5 changed files with 109 additions and 59 deletions

View File

@@ -214,7 +214,12 @@ export class Viewport {
* This property is used to calculate the scale of the editor.
*/
get viewScale() {
if (!this._shell || this._cachedOffsetWidth === null) return 1;
if (
!this._shell ||
this._cachedOffsetWidth === null ||
this._cachedOffsetWidth === 0
)
return 1;
return this.boundingClientRect.width / this._cachedOffsetWidth;
}