feat(editor): repair out-of-frame annotations when attaching a drawing

This commit is contained in:
bchanot committed 2026-11-04 20:10:07 +01:00
1 parent 4ab85adeb0
commit 3776a33b79
22 files changed
+1277 -19

No files matched your search

+8 -3
View File
@@ -8,6 +8,7 @@ import {
rejectedDrawingFault,
type GeometryRefusal,
} from './issues'
import { markRepairable } from './repair'
import { useEditorStore } from './state/editorStore'
import type { CommitOutcome } from './state/editorTypes'
@@ -18,7 +19,8 @@ export type ViewPatch = Partial<
/**
* One `update` of a view through the store. A frame change (drawing, crop, parent) is
* `guarded`: the core's geometry verdict decides through `geometryAccept`, so no annotation
* gets a geometry error it did not have and no measured view becomes unmeasured.
* gets a geometry error it did not have and no measured view becomes unmeasured. A new
* drawing refused for annotations of a view that was unmeasured comes back repairable.
*/
export function updateView(
viewId: string,
@@ -35,8 +37,11 @@ export function updateView(
const value = { ...view, ...patch } as SheetView
const geometry = geometryAccept({ before, changedIds: [] })
const newAsset = patch.svg_asset_id
const accept = (after: PreviewState) =>
(newAsset ? rejectedDrawingFault(after, newAsset) : null) ?? geometry(after)
const accept = (after: PreviewState) => {
const rejected = newAsset ? rejectedDrawingFault(after, newAsset) : null
const verdict = rejected ?? geometry(after)
return newAsset ? markRepairable(verdict, before, after) : verdict
}
return store.commit(
{
op: 'update',