Start with an empty document; offer Datei › Neu and Datei › Muster
A first start (nothing in localStorage) now opens a blank document -- one sheet "Blatt 1" with an empty "Tabelle 1" -- instead of the pre-filled sample. The file menu gets "Neu" (blank document) and "Muster · Umsatzanalyse" (the former seed), both behind a confirm and both starting a fresh undo history. The toolbar's "Zurücksetzen" button is gone; its job is now Datei › Muster. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -120,6 +120,19 @@ describe('seed document acceptance (canvas model)', () => {
|
||||
expect(val(s, 'Übersicht', 'B2')).toBe(5970);
|
||||
});
|
||||
|
||||
it('newDocument replaces everything with one empty sheet + table and a fresh history', () => {
|
||||
const s = fresh();
|
||||
setCell(s, 'Umsatz', 'B2', '99999');
|
||||
s.newDocument();
|
||||
expect(s.doc.sheets).toHaveLength(1);
|
||||
expect(s.doc.sheets[0].name).toBe('Blatt 1');
|
||||
const [table] = s.doc.sheets[0].objects;
|
||||
expect(table.kind === 'table' && table.name).toBe('Tabelle 1');
|
||||
expect(table.kind === 'table' && Object.keys(table.cells)).toEqual([]);
|
||||
expect(s.doc.namedRanges).toEqual([]);
|
||||
expect(s.canUndo.value).toBe(false);
|
||||
});
|
||||
|
||||
it('inserting a new table and referencing it across sheets works', () => {
|
||||
const s = fresh();
|
||||
const sheet2 = s.doc.sheets[1].id;
|
||||
|
||||
@@ -77,7 +77,7 @@ import type {
|
||||
TextObject,
|
||||
} from './types';
|
||||
import { defaultTableView, DEFAULT_ROW_H, MIN_GRID_SIZE, MAX_GRID_SIZE } from './types';
|
||||
import { createSeedDocument } from '../data/seed';
|
||||
import { createBlankDocument, createSeedDocument } from '../data/seed';
|
||||
import { validateDocument } from '../io/json';
|
||||
|
||||
const STORAGE_KEY = 'numolus:doc:v2';
|
||||
@@ -535,7 +535,7 @@ function loadInitial(): DocumentState {
|
||||
} catch {
|
||||
/* missing / corrupt / stale-schema -> clean fallback */
|
||||
}
|
||||
return createSeedDocument();
|
||||
return createBlankDocument();
|
||||
}
|
||||
|
||||
// ---- store singleton --------------------------------------------------
|
||||
@@ -2848,6 +2848,11 @@ function createStore() {
|
||||
applyDocumentState(next);
|
||||
resetHistory();
|
||||
}
|
||||
/** Datei › Neu: an empty document. */
|
||||
function newDocument() {
|
||||
replaceDocument(createBlankDocument());
|
||||
}
|
||||
/** Datei › Muster: the pre-filled sample document. */
|
||||
function resetToSeed() {
|
||||
replaceDocument(createSeedDocument());
|
||||
}
|
||||
@@ -3040,6 +3045,7 @@ function createStore() {
|
||||
pointDrag,
|
||||
// document
|
||||
replaceDocument,
|
||||
newDocument,
|
||||
resetToSeed,
|
||||
appendSheets,
|
||||
addTableFromCells,
|
||||
|
||||
Reference in New Issue
Block a user