Implémenter l'orientation verticale Modifier l'effet de append Implementer RigidBody Implementer Flex et simplex Implémenter Push Implémenter Swap Implement MinMaxHeight without behaviors Fix Margin for Height Implement PositionReference Fix dimension vertical position inside children Add orientation change in form Implement sortChildren Implement Anchor Fix warning message on overlapping Fix minimap when root container is vertical #7287 #7288 #7289 #7290 #7291 #7292 #7294 #7295 #7296 #7297 #7298 #7299 #7300 #7301 #7302
77 lines
2 KiB
TypeScript
77 lines
2 KiB
TypeScript
import { FindContainerById, MakeDFSIterator } from './itertools';
|
|
import { IEditorState } from '../Interfaces/IEditorState';
|
|
import { IHistoryState } from '../Interfaces/IHistoryState';
|
|
|
|
/**
|
|
* Revive the Editor state
|
|
* by setting the containers references to their parent
|
|
* @param editorState Editor state
|
|
*/
|
|
export function Revive(editorState: IEditorState): void {
|
|
const history = editorState.history;
|
|
|
|
// restore last step
|
|
editorState.historyCurrentStep = history.length - 1;
|
|
|
|
// restore the parents and the selected container
|
|
ReviveHistory(history);
|
|
}
|
|
|
|
export function ReviveHistory(history: IHistoryState[]): void {
|
|
for (const state of history) {
|
|
ReviveState(state);
|
|
}
|
|
}
|
|
|
|
export function ReviveState(state: IHistoryState): void {
|
|
if (state.mainContainer === null || state.mainContainer === undefined) {
|
|
return;
|
|
}
|
|
|
|
state.symbols = new Map(state.symbols);
|
|
for (const symbol of state.symbols.values()) {
|
|
symbol.linkedContainers = new Set(symbol.linkedContainers);
|
|
}
|
|
|
|
const it = MakeDFSIterator(state.mainContainer);
|
|
for (const container of it) {
|
|
const parentId = container.properties.parentId;
|
|
if (parentId === null) {
|
|
container.parent = null;
|
|
continue;
|
|
}
|
|
const parent = FindContainerById(state.mainContainer, parentId);
|
|
if (parent === undefined) {
|
|
continue;
|
|
}
|
|
container.parent = parent;
|
|
}
|
|
}
|
|
|
|
export function GetCircularReplacer(): (key: any, value: object | Map<string, any> | null) => object | null | undefined {
|
|
return (key: any, value: object | null) => {
|
|
if (key === 'parent') {
|
|
return;
|
|
}
|
|
|
|
if (key === 'symbols') {
|
|
return Array.from((value as Map<string, any>).entries());
|
|
}
|
|
|
|
if (key === 'linkedContainers') {
|
|
return Array.from(value as Set<string>);
|
|
}
|
|
|
|
return value;
|
|
};
|
|
}
|
|
|
|
export function GetCircularReplacerKeepDataStructure(): (key: any, value: object | Map<string, any> | null) => object | null | undefined {
|
|
return (key: any, value: object | null) => {
|
|
if (key === 'parent') {
|
|
return;
|
|
}
|
|
|
|
return value;
|
|
};
|
|
}
|