diff --git a/frontend/src/Editor/EditorFunc.jsx b/frontend/src/Editor/EditorFunc.jsx
index b6cd82805a..2bc04a8450 100644
--- a/frontend/src/Editor/EditorFunc.jsx
+++ b/frontend/src/Editor/EditorFunc.jsx
@@ -78,31 +78,6 @@ function setWindowTitle(name) {
const decimalToHex = (alpha) => (alpha === 0 ? '00' : Math.round(255 * alpha).toString(16));
-const defaultDefinition = (darkMode) => {
- const defaultPageId = uuid();
- return {
- showViewerNavigation: true,
- homePageId: defaultPageId,
- pages: {
- [defaultPageId]: {
- components: {},
- handle: 'home',
- name: 'Home',
- index: 0,
- },
- },
- globalSettings: {
- hideHeader: false,
- appInMaintenance: false,
- canvasMaxWidth: 1292,
- canvasMaxWidthType: 'px',
- canvasMaxHeight: 2400,
- canvasBackgroundColor: darkMode ? '#2f3c4c' : '#edeff5',
- backgroundFxQuery: '',
- },
- };
-};
-
const EditorComponent = (props) => {
const { socket } = createWebsocketConnection(props?.params?.id);
const mounted = useMounted();
@@ -569,7 +544,6 @@ const EditorComponent = (props) => {
};
const computeCanvasBackgroundColor = () => {
- //!Global settings needs to be out
const { canvasBackgroundColor } = appDefinition?.globalSettings ?? '#edeff5';
if (['#2f3c4c', '#edeff5'].includes(canvasBackgroundColor)) {
return props.darkMode ? '#2f3c4c' : '#edeff5';
@@ -604,19 +578,20 @@ const EditorComponent = (props) => {
const handleEditorMarginLeftChange = (value) => setEditorMarginLeft(value);
- const globalSettingsChanged = (key, value) => {
+ const globalSettingsChanged = (globalOptions) => {
const copyOfAppDefinition = JSON.parse(JSON.stringify(appDefinition));
const newAppDefinition = _.cloneDeep(copyOfAppDefinition);
- if (value?.[1]?.a == undefined) newAppDefinition.globalSettings[key] = value;
- else {
- const hexCode = `${value?.[0]}${decimalToHex(value?.[1]?.a)}`;
- newAppDefinition.globalSettings[key] = hexCode;
+ for (const [key, value] of Object.entries(globalOptions)) {
+ if (value?.[1]?.a == undefined) newAppDefinition.globalSettings[key] = value;
+ else {
+ const hexCode = `${value?.[0]}${decimalToHex(value?.[1]?.a)}`;
+ newAppDefinition.globalSettings[key] = hexCode;
+ }
}
updateEditorState({
isSaving: true,
- // appDefinition,
});
appDefinitionChanged(newAppDefinition, {
@@ -776,11 +751,11 @@ const EditorComponent = (props) => {
// !--------
const setAppDefinitionFromVersion = (version, shouldWeEditVersion = true) => {
if (version?.id !== props.editingVersion?.id) {
- appDefinitionChanged(defaults(version.definition, defaultDefinition(props.darkMode)), {
- skipAutoSave: true,
- skipYmapUpdate: true,
- versionChanged: true,
- });
+ // appDefinitionChanged(defaults(version.definition, defaultDefinition(props.darkMode)), {
+ // skipAutoSave: true,
+ // skipYmapUpdate: true,
+ // versionChanged: true,
+ // });
if (version?.id === currentVersionId) {
updateEditorState({
canUndo: false,
diff --git a/frontend/src/Editor/Header/GlobalSettings.jsx b/frontend/src/Editor/Header/GlobalSettings.jsx
index 9b169ea7dc..a8abcc7bb5 100644
--- a/frontend/src/Editor/Header/GlobalSettings.jsx
+++ b/frontend/src/Editor/Header/GlobalSettings.jsx
@@ -49,12 +49,6 @@ export const GlobalSettings = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentState.components]);
- React.useEffect(() => {
- backgroundFxQuery &&
- globalSettingsChanged('canvasBackgroundColor', resolveReferences(backgroundFxQuery, realState));
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [JSON.stringify(resolveReferences(backgroundFxQuery, realState))]);
-
const popoverContent = (
@@ -73,7 +67,7 @@ export const GlobalSettings = ({
className="form-check-input"
type="checkbox"
checked={hideHeader}
- onChange={(e) => globalSettingsChanged('hideHeader', e.target.checked)}
+ onChange={(e) => globalSettingsChanged({ hideHeader: e.target.checked })}
/>
@@ -104,7 +98,7 @@ export const GlobalSettings = ({
placeholder={'0'}
onChange={(e) => {
const width = e.target.value;
- if (!Number.isNaN(width) && width >= 0) globalSettingsChanged('canvasMaxWidth', width);
+ if (!Number.isNaN(width) && width >= 0) globalSettingsChanged({ canvasMaxWidth: width });
}}
value={canvasMaxWidth}
/>
@@ -114,12 +108,17 @@ export const GlobalSettings = ({
aria-label="Select canvas width type"
onChange={(event) => {
const newCanvasMaxWidthType = event.currentTarget.value;
- globalSettingsChanged('canvasMaxWidthType', newCanvasMaxWidthType);
+
+ const options = {
+ canvasMaxWidthType: newCanvasMaxWidthType,
+ };
+
if (newCanvasMaxWidthType === '%') {
- globalSettingsChanged('canvasMaxWidth', 100);
+ options.canvasMaxWidth = 100;
} else if (newCanvasMaxWidthType === 'px') {
- globalSettingsChanged('canvasMaxWidth', 1292);
+ options.canvasMaxWidth = 1292;
}
+ globalSettingsChanged(options);
}}
>