UNPKG

nuxt-live-editor

Version:
44 lines (43 loc) 1.24 kB
import { defineStore as definePiniaStore } from "pinia"; import { useContentAsync } from "../composables/useContentAsync.mjs"; import { ref, watch, computed } from "vue"; import { useTextSelection } from "@vueuse/core"; export const useSettingPopup = definePiniaStore("settingPopup", () => { const is_open_popup_login = ref(false); const is_open = ref(false); const key = ref(""); const current_value_selected = ref(); const type_popup = ref(""); const position_x = ref(0); const position_y = ref(0); const popup_width = ref(400); const popup_height = ref(0); const current_tab = ref(0); const { text } = useTextSelection(); const text_content_selection = computed(() => { if (!text.value) return; return text.value; }); const setPositionPopup = (x, y) => { position_x.value = x; position_y.value = y; }; watch(current_value_selected, (val) => { const { contentModal } = useContentAsync(key.value, ""); contentModal.value = val; }); return { is_open_popup_login, is_open, key, current_value_selected, type_popup, position_x, position_y, popup_width, popup_height, setPositionPopup, current_tab, text_content_selection }; });