diff --git a/frontend/src/Editor/ActionTypes.js b/frontend/src/Editor/ActionTypes.js index 0111eb2619..c264786d54 100644 --- a/frontend/src/Editor/ActionTypes.js +++ b/frontend/src/Editor/ActionTypes.js @@ -37,4 +37,12 @@ export const ActionTypes = [ id: 'copy-to-clipboard', options: [{ name: 'copy-to-clipboard', type: 'text', default: '' }], }, + { + name: 'Set local storage', + id: 'set-localstorage-value', + options: [ + { name: 'key', type: 'code', default: '' }, + { name: 'value', type: 'code', default: '' }, + ], + }, ]; diff --git a/frontend/src/Editor/Inspector/EventManager.jsx b/frontend/src/Editor/Inspector/EventManager.jsx index 26846e0e1f..512e0b3ca3 100644 --- a/frontend/src/Editor/Inspector/EventManager.jsx +++ b/frontend/src/Editor/Inspector/EventManager.jsx @@ -266,6 +266,33 @@ export const EventManager = ({ )} + + {event.actionId === 'set-localstorage-value' && ( + <> +
+
Key
+
+ handlerChanged(index, 'key', value)} + enablePreview={true} + /> +
+
+
+
Value
+
+ handlerChanged(index, 'value', value)} + enablePreview={true} + /> +
+
+ + )} diff --git a/frontend/src/_helpers/appUtils.js b/frontend/src/_helpers/appUtils.js index f96c6d1148..e02433d4be 100644 --- a/frontend/src/_helpers/appUtils.js +++ b/frontend/src/_helpers/appUtils.js @@ -188,6 +188,12 @@ function executeAction(_ref, event, mode) { return Promise.resolve(); } + + case 'set-localstorage-value': { + const key = resolveReferences(event.key, _ref.state.currentState); + const value = resolveReferences(event.value, _ref.state.currentState); + localStorage.setItem(key, value); + } } } }