Merged PR 167: Add Flex and fix bugs (read desc)

Note: The branch name does not fit the new features.

- Implement Flex with simplex
- Enable rigid body by default (removed IsRigidBody property) <=== possibly a bad idea
- Sort children in add and update properties
- Implement MaxWidth
- Add more docs

Fixes :
- .env.production url
- Symbols: not blocking the linked container when the parent is moving
This commit is contained in:
Eric Nguyen 2022-08-25 13:28:32 +00:00
parent ec3fddec9d
commit 7f3f6a489a
43 changed files with 1127 additions and 453 deletions

View file

@ -4,7 +4,7 @@ import { IConfiguration } from '../../Interfaces/IConfiguration';
import { SVG } from '../SVG/SVG';
import { IHistoryState } from '../../Interfaces/IHistoryState';
import { UI } from '../UI/UI';
import { SelectContainer, DeleteContainer, AddContainerToSelectedContainer, AddContainer, OnPropertyChange } from './Actions/ContainerOperations';
import { SelectContainer, DeleteContainer, AddContainerToSelectedContainer, OnPropertyChange } from './Actions/ContainerOperations';
import { SaveEditorAsJSON, SaveEditorAsSVG } from './Actions/Save';
import { onKeyDown } from './Actions/Shortcuts';
import EditorEvents from '../../Events/EditorEvents';
@ -60,7 +60,9 @@ function useWindowEvents(
history: IHistoryState[],
historyCurrentStep: number,
configuration: IConfiguration,
editorRef: React.RefObject<HTMLDivElement>
editorRef: React.RefObject<HTMLDivElement>,
setHistory: Dispatch<SetStateAction<IHistoryState[]>>,
setHistoryCurrentStep: Dispatch<SetStateAction<number>>
): void {
useEffect(() => {
const events = EditorEvents;
@ -72,7 +74,12 @@ function useWindowEvents(
const funcs = new Map<string, () => void>();
for (const event of events) {
const func = (): void => event.func(editorState);
const func = (eventInitDict?: CustomEventInit): void => event.func(
editorState,
setHistory,
setHistoryCurrentStep,
eventInitDict
);
editorRef.current?.addEventListener(event.name, func);
funcs.set(event.name, func);
}
@ -94,7 +101,14 @@ const Editor: React.FunctionComponent<IEditorProps> = (props) => {
const editorRef = useRef<HTMLDivElement>(null);
useShortcuts(history, historyCurrentStep, setHistoryCurrentStep);
useWindowEvents(history, historyCurrentStep, props.configuration, editorRef);
useWindowEvents(
history,
historyCurrentStep,
props.configuration,
editorRef,
setHistory,
setHistoryCurrentStep
);
const configuration = props.configuration;
const current = getCurrentHistoryState(history, historyCurrentStep);
@ -122,15 +136,15 @@ const Editor: React.FunctionComponent<IEditorProps> = (props) => {
setHistory,
setHistoryCurrentStep
)}
OnPropertyChange={(key, value, isStyle) => OnPropertyChange(
key, value, isStyle,
OnPropertyChange={(key, value, type) => OnPropertyChange(
key, value, type,
selected,
history,
historyCurrentStep,
setHistory,
setHistoryCurrentStep
)}
AddContainerToSelectedContainer={(type) => AddContainerToSelectedContainer(
AddContainer={(type) => AddContainerToSelectedContainer(
type,
selected,
configuration,
@ -139,16 +153,6 @@ const Editor: React.FunctionComponent<IEditorProps> = (props) => {
setHistory,
setHistoryCurrentStep
)}
AddContainer={(index, type, parentId) => AddContainer(
index,
type,
parentId,
configuration,
history,
historyCurrentStep,
setHistory,
setHistoryCurrentStep
)}
AddSymbol={(type) => AddSymbol(
type,
configuration,