Merged PR 194: Added option to disable any API call
Added option to disable any API call Fix http.js and node-http.js Fix MainContainer not using IAvailableContainer from MainContainer Fix generate_dts.py script More docs Fix MainContainer default style. Extend config will now be taken into account. But Main container can still have its own type.
This commit is contained in:
parent
8ba19cc96b
commit
3ecff4cf01
10 changed files with 648 additions and 570 deletions
|
@ -9,10 +9,22 @@ import { ISymbolModel } from '../Interfaces/ISymbolModel';
|
|||
|
||||
/// EDITOR DEFAULTS ///
|
||||
|
||||
export const FAST_BOOT = import.meta.env.PROD;
|
||||
/** Enable fast boot and disable main menu */
|
||||
export const FAST_BOOT = false;
|
||||
|
||||
/** Disable any call to the API */
|
||||
export const DISABLE_API = false;
|
||||
|
||||
/** Enable keyboard shortcuts */
|
||||
export const ENABLE_SHORTCUTS = true;
|
||||
|
||||
/** Size of the history */
|
||||
export const MAX_HISTORY = 200;
|
||||
|
||||
/** Apply beheviors on children */
|
||||
export const APPLY_BEHAVIORS_ON_CHILDREN = true;
|
||||
|
||||
/** Framerate of the svg controller */
|
||||
export const MAX_FRAMERATE = 60;
|
||||
|
||||
/// CONTAINER DEFAULTS ///
|
||||
|
@ -53,15 +65,58 @@ export const DEFAULT_SYMBOL_HEIGHT = 32;
|
|||
* Returns the default editor state given the configuration
|
||||
*/
|
||||
export function GetDefaultEditorState(configuration: IConfiguration): IEditorState {
|
||||
if (configuration.MainContainer.Width === undefined ||
|
||||
configuration.MainContainer.Height === undefined) {
|
||||
throw new Error('Cannot initialize project! Main container has an undefined size');
|
||||
}
|
||||
|
||||
const containerConfig = configuration.AvailableContainers.find(config => config.Type === configuration.MainContainer.Type);
|
||||
|
||||
let mainContainerConfig: IContainerProperties;
|
||||
if (containerConfig !== undefined) {
|
||||
const clone = structuredClone(containerConfig);
|
||||
const extendedContainerConfig = Object.assign(clone, configuration.MainContainer);
|
||||
|
||||
if (containerConfig.Style !== undefined) {
|
||||
const styleClone = structuredClone(containerConfig.Style);
|
||||
extendedContainerConfig.Style = Object.assign(styleClone, configuration.MainContainer.Style);
|
||||
}
|
||||
|
||||
if (extendedContainerConfig.Width === undefined ||
|
||||
extendedContainerConfig.Height === undefined) {
|
||||
throw new Error('Cannot initialize project! Main container has an undefined size');
|
||||
}
|
||||
|
||||
mainContainerConfig = GetDefaultContainerProps(
|
||||
extendedContainerConfig.Type,
|
||||
0,
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
extendedContainerConfig.Width,
|
||||
extendedContainerConfig.Height,
|
||||
extendedContainerConfig
|
||||
);
|
||||
} else {
|
||||
mainContainerConfig = GetDefaultContainerProps(
|
||||
configuration.MainContainer.Type,
|
||||
0,
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
configuration.MainContainer.Width,
|
||||
configuration.MainContainer.Height,
|
||||
configuration.MainContainer
|
||||
);
|
||||
}
|
||||
const mainContainer = new ContainerModel(
|
||||
null,
|
||||
{
|
||||
...DEFAULT_MAINCONTAINER_PROPS,
|
||||
width: Number(configuration.MainContainer.Width),
|
||||
height: Number(configuration.MainContainer.Height)
|
||||
}
|
||||
mainContainerConfig
|
||||
);
|
||||
|
||||
const typeCounters = {};
|
||||
(typeCounters as any)[mainContainer.properties.type] = 0;
|
||||
|
||||
return {
|
||||
configuration,
|
||||
history: [
|
||||
|
@ -69,7 +124,7 @@ export function GetDefaultEditorState(configuration: IConfiguration): IEditorSta
|
|||
lastAction: '',
|
||||
mainContainer,
|
||||
selectedContainerId: mainContainer.properties.id,
|
||||
typeCounters: {},
|
||||
typeCounters,
|
||||
symbols: new Map(),
|
||||
selectedSymbolId: ''
|
||||
}
|
||||
|
@ -152,7 +207,7 @@ export const DEFAULT_MAINCONTAINER_PROPS: IContainerProperties = {
|
|||
*/
|
||||
export function GetDefaultContainerProps(type: string,
|
||||
typeCount: number,
|
||||
parent: IContainerModel,
|
||||
parent: IContainerModel | undefined | null,
|
||||
x: number,
|
||||
y: number,
|
||||
width: number,
|
||||
|
@ -161,7 +216,7 @@ export function GetDefaultContainerProps(type: string,
|
|||
return ({
|
||||
id: `${type}-${typeCount}`,
|
||||
type,
|
||||
parentId: parent.properties.id,
|
||||
parentId: parent?.properties.id ?? '',
|
||||
linkedSymbolId: '',
|
||||
displayedText: `${containerConfig.DisplayedText ?? type}-${typeCount}`,
|
||||
x,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue