Test loading demo by path
This commit is contained in:
parent
b76ac89d44
commit
58a513dd11
3 changed files with 18 additions and 4 deletions
|
|
@ -57,6 +57,10 @@ export async function readStateFromFragment(): Promise<State | null> {
|
|||
// For testing
|
||||
const src = decodeURIComponent(serialized.substring('src:'.length));
|
||||
return createInitialState(null, src);
|
||||
} else if (serialized.startsWith('testpath:')) {
|
||||
// For testing
|
||||
const path = decodeURIComponent(serialized.substring('testpath:'.length));
|
||||
return createInitialState(null, '...', path);
|
||||
}
|
||||
let obj;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { State } from './app-state';
|
|||
export const defaultSourcePath = '/playground.scad';
|
||||
export const defaultModelColor = '#f9d72c';
|
||||
|
||||
export function createInitialState(state: State | null, content: string = defaultScad): State {
|
||||
export function createInitialState(state: State | null, content = defaultScad, activePath = defaultSourcePath): State {
|
||||
|
||||
type Mode = State['view']['layout']['mode'];
|
||||
const mode: Mode = window.matchMedia("(min-width: 768px)").matches
|
||||
|
|
@ -14,8 +14,8 @@ export function createInitialState(state: State | null, content: string = defaul
|
|||
|
||||
const initialState: State = {
|
||||
params: {
|
||||
activePath: defaultSourcePath,
|
||||
sources: [{path: defaultSourcePath, content}],
|
||||
activePath: activePath,
|
||||
sources: [{path: activePath, content}],
|
||||
features: [],
|
||||
exportFormat2D: 'svg',
|
||||
exportFormat3D: 'glb',
|
||||
|
|
|
|||
Loading…
Reference in a new issue