From f0f3733ac1e993774b99fe5cc588b8869338041f Mon Sep 17 00:00:00 2001 From: Jesse Mazzella Date: Thu, 21 Dec 2023 16:45:24 -0800 Subject: [PATCH] feat: add `isEditing` composable --- src/ui/composables/editor.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/ui/composables/editor.js diff --git a/src/ui/composables/editor.js b/src/ui/composables/editor.js new file mode 100644 index 0000000000..10638ed8c7 --- /dev/null +++ b/src/ui/composables/editor.js @@ -0,0 +1,19 @@ +import { ref } from 'vue'; + +import { useEventListener } from './event'; + +/** + * @param {import('../../../openmct').OpenMCT} openmct + * @returns {{isEditing: import('vue').Ref}} isEditing + */ +export function useIsEditing(openmct) { + const isEditing = ref(false); + + // eslint-disable-next-line func-style + const handler = (value) => (isEditing.value = value); + + // Use the base event listener composable + useEventListener(openmct.editor, 'isEditing', handler); + + return { isEditing }; +}