feat(block-editor): add Test Block preview

Preview the current unsaved block in a disposable drawing with independent history. Keep normal Draw tools available, append Close Test Block, and return to the original editor without saving. Guard persistence paths and handle refresh and parent-close lifecycle by stable document identity.
This commit is contained in:
Karim Jerbi committed 2026-10-14 14:44:58 +01:00
1 parent 0a29be07f7
commit 9632979d09
22 files changed
+801 -65

No files matched your search

+1 -1
View File
@@ -38,7 +38,7 @@ impl OpenCADStudio {
let mut saved = 0usize;
let mut skipped = 0usize;
for t in 0..self.tabs.len() {
if self.tabs[t].is_start {
if self.tabs[t].is_start || self.tabs[t].block_test.is_some() {
continue;
}
if let Some(path) = self.tabs[t].current_path.clone() {
+2
View File
@@ -614,6 +614,8 @@ impl OpenCADStudio {
"BSAVE" => {
self.save_block_edit(i);
}
"BTESTBLOCK" => return Some(self.open_block_test(i)),
"BCLOSETESTBLOCK" => return Some(self.close_block_test(i)),
"BSAVEAS" => {
self.open_block_save_as_dialog(i);
}
+27
View File
@@ -149,6 +149,33 @@ impl OpenCADStudio {
};
let resolved = self.resolve_alias(cmd);
let cmd = resolved.as_deref().unwrap_or(cmd);
if self.tabs[i].block_test.is_some() {
let name = cmd.split([' ', ':']).next().unwrap_or(cmd);
if matches!(
name,
"BEDIT"
| "BEDIT_BEGIN"
| "BEDIT_OPEN"
| "REFEDIT"
| "REFEDIT_BEGIN"
| "BSAVE"
| "BSAVEAS"
| "SAVE"
| "QSAVE"
| "SAVEAS"
| "SAVEALL"
| "WBLOCK"
| "EXPORT"
| "ETRANSMIT"
| "ARCHIVE"
) {
self.command_line.push_error(
crate::t!("Close Test Block before saving or opening another block editor.")
.as_ref(),
);
return Task::none();
}
}
if is_spacemouse_command(cmd) {
return self.run_action(cmd);
}