|
|
|
|
@@ -6,49 +6,65 @@
|
|
|
|
|
Back to products</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="container mx-auto ">
|
|
|
|
|
<div
|
|
|
|
|
class=" gap-4 mb-6 bg-(--second-light) dark:bg-(--main-dark) border border-(--border-light) dark:border-(--border-dark) p-4 rounded-md">
|
|
|
|
|
<div v-if="!isShowProductView" class="flex items-center justify-between">
|
|
|
|
|
<div class=" gap-4 mb-6 p-4 border-b border-(--border-light)">
|
|
|
|
|
<div class="flex items-center justify-between">
|
|
|
|
|
<div class="flex flex-col items-center gap-3" v-if="!isTranslations">
|
|
|
|
|
<p class="light:text-(--accent-green-light) dark:text-(--accent-green-dark) text-md whitespace-nowrap">
|
|
|
|
|
Translate from Polish to :</p>
|
|
|
|
|
<USelectMenu v-model="toLangId" :items="availableLangs" value-key="id" label-key="name"
|
|
|
|
|
<USelectMenu v-model="toLangId" :items="langs" value-key="id"
|
|
|
|
|
class="w-48 bg-(--main-light) dark:bg-(--black) rounded-md shadow-sm" :searchInput="false">
|
|
|
|
|
<template #default>
|
|
|
|
|
<div class="flex items-center gap-2">
|
|
|
|
|
<div class="flex flex-col leading-tight items-start">
|
|
|
|
|
<span class="text-xs text-gray-400">
|
|
|
|
|
Select language
|
|
|
|
|
</span>
|
|
|
|
|
<span class="font-medium dark:text-white text-black">
|
|
|
|
|
{{availableLangs.find(l => l.id === toLangId)?.name || 'Select language'}}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex flex-col items-start leading-tight">
|
|
|
|
|
<span class="text-xs text-gray-400">
|
|
|
|
|
Selected language
|
|
|
|
|
</span>
|
|
|
|
|
<span class="font-medium dark:text-white text-black">
|
|
|
|
|
{{langs.find(l => l.id === toLangId)?.name || 'Select language'}}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template #item-leading="{ item }">
|
|
|
|
|
<div class="flex items-center gap-2">
|
|
|
|
|
<span>{{ item.flag }}</span>
|
|
|
|
|
<span class="font-medium dark:text-white text-black">{{ item.name }}</span>
|
|
|
|
|
<div class="flex items-center gap-2 cursor-pointer">
|
|
|
|
|
<span class="text-lg">{{ item.flag }}</span>
|
|
|
|
|
<span class="font-medium dark:text-white text-black">
|
|
|
|
|
{{ item.name }}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</USelectMenu>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="flex gap-7">
|
|
|
|
|
<div v-if="toLangId !== settingStore.shopDefaultLanguage && !isTranslations" class="flex gap-7">
|
|
|
|
|
<UButton @click="translateToSelectedLanguage" color="info" :loading="translating">
|
|
|
|
|
Translate from Polish to {{langs.find(l => l.id === toLangId)?.name}}
|
|
|
|
|
</UButton>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-if="isTranslations" class="flex gap-3 w-full justify-end">
|
|
|
|
|
<UButton @click="() => {
|
|
|
|
|
fetchForLanguage(toLangId)
|
|
|
|
|
isShowProductView = true
|
|
|
|
|
}" v-if="isTranslations === false" class="text-(--accent-blue-light) dark:text-(--accent-blue-dark)"
|
|
|
|
|
color="neutral" variant="outline">
|
|
|
|
|
<p class="dark:text-white"> Show product</p>
|
|
|
|
|
toLangId = settingStore.shopDefaultLanguage
|
|
|
|
|
isTranslations = false
|
|
|
|
|
}" color="info" variant="outline">
|
|
|
|
|
Cancel and back to Polish
|
|
|
|
|
</UButton>
|
|
|
|
|
<UButton @click="translateToSelectedLanguage" color="primary" :loading="translating"
|
|
|
|
|
v-if="isTranslations === false"
|
|
|
|
|
class="text-white bg-(--accent-blue-light) dark:bg-(--accent-blue-dark) flex items-center! justify-center! px-12">
|
|
|
|
|
Translate
|
|
|
|
|
<UButton color="info" @click="productStore.saveProductDescription(productID, toLangId)">
|
|
|
|
|
Save translations
|
|
|
|
|
</UButton>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- <div class="flex gap-7">
|
|
|
|
|
<div v-if="isTranslations === false">
|
|
|
|
|
<UButton @click="() => {
|
|
|
|
|
fetchForLanguage(toLangId)
|
|
|
|
|
isShowProductView = true
|
|
|
|
|
}" class="text-(--accent-blue-light) dark:text-(--accent-blue-dark)"
|
|
|
|
|
color="neutral" variant="outline">
|
|
|
|
|
<p class="dark:text-white"> Show product</p>
|
|
|
|
|
</UButton>
|
|
|
|
|
<UButton @click="translateToSelectedLanguage" color="primary" :loading="translating"
|
|
|
|
|
class="text-white bg-(--accent-blue-light) dark:bg-(--accent-blue-dark) flex items-center! justify-center! px-12">
|
|
|
|
|
Translate
|
|
|
|
|
</UButton>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else class="flex gap-3">
|
|
|
|
|
<UButton @click="() => {
|
|
|
|
|
toLangId = settingStore.shopDefaultLanguage
|
|
|
|
|
@@ -61,23 +77,16 @@
|
|
|
|
|
Save
|
|
|
|
|
</UButton>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else>
|
|
|
|
|
<UButton @click="isShowProductView = false" color="primary"
|
|
|
|
|
class="text-white bg-(--accent-blue-light) dark:bg-(--accent-blue-dark) gap-2">
|
|
|
|
|
<UIcon name="line-md:arrow-left" class="" />
|
|
|
|
|
Back
|
|
|
|
|
</UButton>
|
|
|
|
|
</div> -->
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-if="translating" class="fixed inset-0 z-50 flex items-center justify-center bg-black/50">
|
|
|
|
|
<!-- <div v-if="translating" class="fixed inset-0 z-50 flex items-center justify-center bg-black/50">
|
|
|
|
|
<div class="flex flex-col items-center gap-4 p-8 bg-(--main-light) dark:bg-(--main-dark) rounded-lg shadow-xl">
|
|
|
|
|
<UIcon name="svg-spinners:ring-resize" class="text-4xl text-primary" />
|
|
|
|
|
<p class="text-lg font-medium dark:text-white text-black">Translating...</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div> -->
|
|
|
|
|
|
|
|
|
|
<div v-if="productStore.loading" class="flex items-center justify-center py-20">
|
|
|
|
|
<UIcon name="svg-spinners:ring-resize" class="text-4xl text-primary" />
|
|
|
|
|
@@ -86,88 +95,80 @@
|
|
|
|
|
<p class="text-red-500">{{ productStore.error }}</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-else-if="productStore.productDescription" class="flex items-start gap-30">
|
|
|
|
|
<div class="w-80 h-80 bg-(--second-light) dark:bg-gray-700 rounded-lg flex items-center justify-center">
|
|
|
|
|
<span class="text-gray-500 dark:text-gray-400">Product Image</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex flex-col gap-2">
|
|
|
|
|
<p class="text-[25px] font-bold text-black dark:text-white">
|
|
|
|
|
{{ productStore.productDescription.name || 'Product Name' }}
|
|
|
|
|
</p>
|
|
|
|
|
<p v-html="productStore.productDescription.description_short" class="text-black dark:text-white"></p>
|
|
|
|
|
|
|
|
|
|
<div class="space-y-[10px]">
|
|
|
|
|
<div class="flex items-center gap-1">
|
|
|
|
|
<UIcon name="lets-icons:done-ring-round-fill"
|
|
|
|
|
class="text-[20px] light:text-(--accent-green-light) dark:text-(--accent-green-dark)" />
|
|
|
|
|
<p class="text-[16px] font-bold text-(--accent-blue-light) dark:text-(--accent-blue-dark)">
|
|
|
|
|
{{ productStore.productDescription.available_now }}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex items-center gap-1">
|
|
|
|
|
<UIcon name="marketeq:car-shipping"
|
|
|
|
|
class="text-[25px] light:text-(--accent-green-light) dark:text-(--accent-green-dark)" />
|
|
|
|
|
<p class="text-[18px] font-bold text-black dark:text-white">
|
|
|
|
|
{{ productStore.productDescription.delivery_in_stock || 'Delivery information' }}
|
|
|
|
|
</p>
|
|
|
|
|
<div v-else-if="productStore.productDescription" class="">
|
|
|
|
|
<div class="flex items-start gap-30">
|
|
|
|
|
<div class="w-80 h-80 bg-(--second-light) dark:bg-gray-700 rounded-lg flex items-center justify-center">
|
|
|
|
|
<span class="text-gray-500 dark:text-gray-400">Product Image</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex flex-col gap-2">
|
|
|
|
|
<p class="text-[25px] font-bold text-black dark:text-white">
|
|
|
|
|
{{ productStore.productDescription.name || 'Product Name' }}
|
|
|
|
|
</p>
|
|
|
|
|
<p v-html="productStore.productDescription.description_short" class="text-black dark:text-white"></p>
|
|
|
|
|
|
|
|
|
|
<div class="space-y-[10px]">
|
|
|
|
|
<div class="flex items-center gap-1">
|
|
|
|
|
<UIcon name="lets-icons:done-ring-round-fill"
|
|
|
|
|
class="text-[20px] light:text-(--accent-green-light) dark:text-(--accent-green-dark)" />
|
|
|
|
|
<p class="text-[16px] font-bold text-(--accent-blue-light) dark:text-(--accent-blue-dark)">
|
|
|
|
|
{{ productStore.productDescription.available_now }}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex items-center gap-1">
|
|
|
|
|
<UIcon name="marketeq:car-shipping"
|
|
|
|
|
class="text-[25px] light:text-(--accent-green-light) dark:text-(--accent-green-dark)" />
|
|
|
|
|
<p class="text-[18px] font-bold text-black dark:text-white">
|
|
|
|
|
{{ productStore.productDescription.delivery_in_stock || 'Delivery information' }}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-if="productStore.productDescription" class="mt-16">
|
|
|
|
|
<div class="flex gap-4 my-6">
|
|
|
|
|
<UButton @click="activeTab = 'description'"
|
|
|
|
|
:class="['cursor-pointer', activeTab === 'description' ? 'bg-blue-500 text-white' : '']" color="neutral"
|
|
|
|
|
variant="outline">
|
|
|
|
|
<p class="dark:text-white">Description</p>
|
|
|
|
|
</UButton>
|
|
|
|
|
|
|
|
|
|
<UButton @click="activeTab = 'usage'"
|
|
|
|
|
:class="['cursor-pointer', activeTab === 'usage' ? 'bg-blue-500 text-white' : '']" color="neutral"
|
|
|
|
|
variant="outline">
|
|
|
|
|
<p class="dark:text-white">Usage</p>
|
|
|
|
|
</UButton>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-if="activeTab === 'usage'"
|
|
|
|
|
class="px-8 py-4 border border-(--border-light) dark:border-(--border-dark) rounded-md bg-(--second-light) dark:bg-(--main-dark)">
|
|
|
|
|
|
|
|
|
|
<div class="flex justify-end items-center gap-3 mb-4">
|
|
|
|
|
<UButton v-if="!isEditing" @click="enableEdit"
|
|
|
|
|
class="flex items-center gap-2 m-2 cursor-pointer bg-(--accent-blue-light)! dark:bg-(--accent-blue-dark)!">
|
|
|
|
|
<p class="text-white">Change Text</p>
|
|
|
|
|
<UIcon name="material-symbols-light:stylus-note-sharp" class="text-[30px] text-white!" />
|
|
|
|
|
<div class="mt-16">
|
|
|
|
|
<div class="flex gap-4 my-6">
|
|
|
|
|
<UButton @click="activeTab = 'description'"
|
|
|
|
|
:class="['cursor-pointer', activeTab === 'description' ? 'bg-blue-500 text-white' : '']" color="neutral"
|
|
|
|
|
variant="outline">
|
|
|
|
|
<p class="dark:text-white">Description</p>
|
|
|
|
|
</UButton>
|
|
|
|
|
<UButton v-if="isEditing" @click="saveText" color="neutral" variant="outline" class="p-2.5 cursor-pointer">
|
|
|
|
|
<p class="dark:text-white text-black">Save the edited text</p>
|
|
|
|
|
</UButton>
|
|
|
|
|
<UButton v-if="isEditing" @click="cancelEdit" color="neutral" variant="outline"
|
|
|
|
|
class="p-2.5 cursor-pointer">
|
|
|
|
|
Cancel
|
|
|
|
|
|
|
|
|
|
<UButton @click="activeTab = 'usage'"
|
|
|
|
|
:class="['cursor-pointer', activeTab === 'usage' ? 'bg-blue-500 text-white' : '']" color="neutral"
|
|
|
|
|
variant="outline">
|
|
|
|
|
<p class="dark:text-white">Usage</p>
|
|
|
|
|
</UButton>
|
|
|
|
|
</div>
|
|
|
|
|
<p ref="usageRef" v-html="productStore.productDescription.usage"
|
|
|
|
|
class="flex flex-col justify-center w-full text-start dark:text-white! text-black!"></p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-if="activeTab === 'description'"
|
|
|
|
|
class="px-8 py-4 border border-(--border-light) dark:border-(--border-dark) rounded-md bg-(--second-light) dark:bg-(--main-dark)">
|
|
|
|
|
<div class="flex items-center justify-end gap-3 mb-4">
|
|
|
|
|
<UButton v-if="!descriptionEdit.isEditing.value" @click="enableDescriptionEdit"
|
|
|
|
|
class="flex items-center gap-2 m-2 cursor-pointer bg-(--accent-blue-light)! dark:bg-(--accent-blue-dark)!">
|
|
|
|
|
<p class="text-white">Change Text</p>
|
|
|
|
|
<UIcon name="material-symbols-light:stylus-note-sharp" class="text-[30px] text-white!" />
|
|
|
|
|
</UButton>
|
|
|
|
|
<UButton v-if="descriptionEdit.isEditing.value" @click="saveDescription" color="neutral" variant="outline"
|
|
|
|
|
class="p-2.5 cursor-pointer">
|
|
|
|
|
<p class="dark:text-white text-black ">Save the edited text</p>
|
|
|
|
|
</UButton>
|
|
|
|
|
<UButton v-if="descriptionEdit.isEditing.value" @click="cancelDescriptionEdit" color="neutral"
|
|
|
|
|
variant="outline" class="p-2.5 cursor-pointer">Cancel</UButton>
|
|
|
|
|
</div>
|
|
|
|
|
<div ref="descriptionRef" v-html="productStore.productDescription.description"
|
|
|
|
|
class="flex flex-col justify-center dark:text-white text-black">
|
|
|
|
|
<div
|
|
|
|
|
class="px-8 py-4 border border-(--border-light) dark:border-(--border-dark) rounded-md bg-(--second-light) dark:bg-(--main-dark)">
|
|
|
|
|
<div v-if="!isTranslations" class="flex justify-end items-center gap-3 mb-4">
|
|
|
|
|
<UButton v-if="!isEditing" @click="activeTab === 'usage' ? enableEdit() : enableDescriptionEdit()"
|
|
|
|
|
class="flex items-center gap-2 m-2 cursor-pointer bg-(--accent-blue-light)! dark:bg-(--accent-blue-dark)!">
|
|
|
|
|
<p class="text-white">Change Text</p>
|
|
|
|
|
<UIcon name="material-symbols-light:stylus-note-sharp" class="text-[30px] text-white!" />
|
|
|
|
|
</UButton>
|
|
|
|
|
<UButton v-if="isEditing" @click="activeTab === 'usage' ? saveText : saveDescription" color="neutral"
|
|
|
|
|
variant="outline" class="p-2.5 cursor-pointer">
|
|
|
|
|
<p class="dark:text-white text-black">Save the edited text</p>
|
|
|
|
|
</UButton>
|
|
|
|
|
<UButton v-if="isEditing" @click="activeTab === 'usage' ? cancelEdit : cancelDescriptionEdit"
|
|
|
|
|
color="neutral" variant="outline" class="p-2.5 cursor-pointer">
|
|
|
|
|
Cancel
|
|
|
|
|
</UButton>
|
|
|
|
|
</div>
|
|
|
|
|
<UEditor v-slot="{ editor }" v-model="productStore.productDescription.description" content-type="html"
|
|
|
|
|
:ui="{ base: 'p-8 sm:px-16' }" class="w-full min-h-74">
|
|
|
|
|
<UEditorToolbar :editor="editor" :items="toolbarItems" class="sm:px-8">
|
|
|
|
|
<template #link>
|
|
|
|
|
<EditorLinkPopover :editor="editor" auto-open />
|
|
|
|
|
</template>
|
|
|
|
|
</UEditorToolbar>
|
|
|
|
|
</UEditor>
|
|
|
|
|
<!-- <p v-if="activeTab === 'usage'" ref="usageRef" v-html="productStore.productDescription.usage"
|
|
|
|
|
class="flex flex-col justify-center w-full text-start dark:text-white! text-black!"></p>
|
|
|
|
|
<div v-else ref="descriptionRef" v-html="productStore.productDescription.description"
|
|
|
|
|
class="flex flex-col justify-center dark:text-white text-black"></div> -->
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
@@ -181,10 +182,141 @@ import Default from '@/layouts/default.vue';
|
|
|
|
|
import { langs } from '@/router/langs';
|
|
|
|
|
import { useProductStore } from '@/stores/product';
|
|
|
|
|
import { useSettingsStore } from '@/stores/settings';
|
|
|
|
|
import { onMounted, ref } from 'vue';
|
|
|
|
|
import { computed } from 'vue';
|
|
|
|
|
import type { EditorToolbarItem } from '@nuxt/ui';
|
|
|
|
|
import { onMounted, ref, watch } from 'vue';
|
|
|
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
|
|
|
|
|
|
|
|
const toolbarItems: EditorToolbarItem[][] = [
|
|
|
|
|
// History controls
|
|
|
|
|
[{
|
|
|
|
|
kind: 'undo',
|
|
|
|
|
icon: 'i-lucide-undo',
|
|
|
|
|
tooltip: { text: 'Undo' }
|
|
|
|
|
}, {
|
|
|
|
|
kind: 'redo',
|
|
|
|
|
icon: 'i-lucide-redo',
|
|
|
|
|
tooltip: { text: 'Redo' }
|
|
|
|
|
}],
|
|
|
|
|
// Block types
|
|
|
|
|
[{
|
|
|
|
|
icon: 'i-lucide-heading',
|
|
|
|
|
tooltip: { text: 'Headings' },
|
|
|
|
|
content: {
|
|
|
|
|
align: 'start'
|
|
|
|
|
},
|
|
|
|
|
items: [{
|
|
|
|
|
kind: 'heading',
|
|
|
|
|
level: 1,
|
|
|
|
|
icon: 'i-lucide-heading-1',
|
|
|
|
|
label: 'Heading 1'
|
|
|
|
|
}, {
|
|
|
|
|
kind: 'heading',
|
|
|
|
|
level: 2,
|
|
|
|
|
icon: 'i-lucide-heading-2',
|
|
|
|
|
label: 'Heading 2'
|
|
|
|
|
}, {
|
|
|
|
|
kind: 'heading',
|
|
|
|
|
level: 3,
|
|
|
|
|
icon: 'i-lucide-heading-3',
|
|
|
|
|
label: 'Heading 3'
|
|
|
|
|
}, {
|
|
|
|
|
kind: 'heading',
|
|
|
|
|
level: 4,
|
|
|
|
|
icon: 'i-lucide-heading-4',
|
|
|
|
|
label: 'Heading 4'
|
|
|
|
|
}]
|
|
|
|
|
}, {
|
|
|
|
|
icon: 'i-lucide-list',
|
|
|
|
|
tooltip: { text: 'Lists' },
|
|
|
|
|
content: {
|
|
|
|
|
align: 'start'
|
|
|
|
|
},
|
|
|
|
|
items: [{
|
|
|
|
|
kind: 'bulletList',
|
|
|
|
|
icon: 'i-lucide-list',
|
|
|
|
|
label: 'Bullet List'
|
|
|
|
|
}, {
|
|
|
|
|
kind: 'orderedList',
|
|
|
|
|
icon: 'i-lucide-list-ordered',
|
|
|
|
|
label: 'Ordered List'
|
|
|
|
|
}]
|
|
|
|
|
}, {
|
|
|
|
|
kind: 'blockquote',
|
|
|
|
|
icon: 'i-lucide-text-quote',
|
|
|
|
|
tooltip: { text: 'Blockquote' }
|
|
|
|
|
}, {
|
|
|
|
|
kind: 'codeBlock',
|
|
|
|
|
icon: 'i-lucide-square-code',
|
|
|
|
|
tooltip: { text: 'Code Block' }
|
|
|
|
|
}, {
|
|
|
|
|
kind: 'horizontalRule',
|
|
|
|
|
icon: 'i-lucide-separator-horizontal',
|
|
|
|
|
tooltip: { text: 'Horizontal Rule' }
|
|
|
|
|
}],
|
|
|
|
|
// Text formatting
|
|
|
|
|
[{
|
|
|
|
|
kind: 'mark',
|
|
|
|
|
mark: 'bold',
|
|
|
|
|
icon: 'i-lucide-bold',
|
|
|
|
|
tooltip: { text: 'Bold' }
|
|
|
|
|
}, {
|
|
|
|
|
kind: 'mark',
|
|
|
|
|
mark: 'italic',
|
|
|
|
|
icon: 'i-lucide-italic',
|
|
|
|
|
tooltip: { text: 'Italic' }
|
|
|
|
|
}, {
|
|
|
|
|
kind: 'mark',
|
|
|
|
|
mark: 'underline',
|
|
|
|
|
icon: 'i-lucide-underline',
|
|
|
|
|
tooltip: { text: 'Underline' }
|
|
|
|
|
}, {
|
|
|
|
|
kind: 'mark',
|
|
|
|
|
mark: 'strike',
|
|
|
|
|
icon: 'i-lucide-strikethrough',
|
|
|
|
|
tooltip: { text: 'Strikethrough' }
|
|
|
|
|
}, {
|
|
|
|
|
kind: 'mark',
|
|
|
|
|
mark: 'code',
|
|
|
|
|
icon: 'i-lucide-code',
|
|
|
|
|
tooltip: { text: 'Code' }
|
|
|
|
|
}],
|
|
|
|
|
// Link
|
|
|
|
|
[{
|
|
|
|
|
kind: 'link',
|
|
|
|
|
icon: 'i-lucide-link',
|
|
|
|
|
tooltip: { text: 'Link' }
|
|
|
|
|
}],
|
|
|
|
|
// Text alignment
|
|
|
|
|
[{
|
|
|
|
|
icon: 'i-lucide-align-justify',
|
|
|
|
|
tooltip: { text: 'Text Align' },
|
|
|
|
|
content: {
|
|
|
|
|
align: 'end'
|
|
|
|
|
},
|
|
|
|
|
items: [{
|
|
|
|
|
kind: 'textAlign',
|
|
|
|
|
align: 'left',
|
|
|
|
|
icon: 'i-lucide-align-left',
|
|
|
|
|
label: 'Align Left'
|
|
|
|
|
}, {
|
|
|
|
|
kind: 'textAlign',
|
|
|
|
|
align: 'center',
|
|
|
|
|
icon: 'i-lucide-align-center',
|
|
|
|
|
label: 'Align Center'
|
|
|
|
|
}, {
|
|
|
|
|
kind: 'textAlign',
|
|
|
|
|
align: 'right',
|
|
|
|
|
icon: 'i-lucide-align-right',
|
|
|
|
|
label: 'Align Right'
|
|
|
|
|
}, {
|
|
|
|
|
kind: 'textAlign',
|
|
|
|
|
align: 'justify',
|
|
|
|
|
icon: 'i-lucide-align-justify',
|
|
|
|
|
label: 'Align Justify'
|
|
|
|
|
}]
|
|
|
|
|
}]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
function backFromProduct() {
|
|
|
|
|
let path = localStorage.getItem('back_from_product')
|
|
|
|
|
@@ -210,7 +342,7 @@ const settingStore = useSettingsStore()
|
|
|
|
|
const productStore = useProductStore()
|
|
|
|
|
const isTranslations = ref(false)
|
|
|
|
|
|
|
|
|
|
const toLangId = ref(null)
|
|
|
|
|
const toLangId = ref<number>(settingStore.shopDefaultLanguage)
|
|
|
|
|
const productID = ref<number>(0)
|
|
|
|
|
const translating = ref(false)
|
|
|
|
|
|
|
|
|
|
@@ -223,10 +355,6 @@ const descriptionRef = ref<HTMLElement | null>(null)
|
|
|
|
|
const descriptionEdit = useEditable(descriptionRef)
|
|
|
|
|
const originalDescription = ref('')
|
|
|
|
|
|
|
|
|
|
const isShowProductView = ref(false)
|
|
|
|
|
|
|
|
|
|
const availableLangs = computed(() => langs.filter(item => item.id !== settingStore.shopDefaultLanguage))
|
|
|
|
|
|
|
|
|
|
const translateToSelectedLanguage = async () => {
|
|
|
|
|
if (toLangId.value && productID.value) {
|
|
|
|
|
translating.value = true
|
|
|
|
|
@@ -234,6 +362,8 @@ const translateToSelectedLanguage = async () => {
|
|
|
|
|
await productStore.translateProductDescription(productID.value, toLangId.value)
|
|
|
|
|
} finally {
|
|
|
|
|
translating.value = false
|
|
|
|
|
enableEdit()
|
|
|
|
|
enableDescriptionEdit()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (productStore.productDescription) {
|
|
|
|
|
@@ -248,6 +378,10 @@ const fetchForLanguage = async (langId: number | null) => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watch(toLangId, () => {
|
|
|
|
|
fetchForLanguage(toLangId.value)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
const id = route.params.product_id
|
|
|
|
|
if (id) {
|
|
|
|
|
@@ -259,6 +393,8 @@ onMounted(async () => {
|
|
|
|
|
|
|
|
|
|
// text edit
|
|
|
|
|
const enableEdit = () => {
|
|
|
|
|
console.log(usageRef.value, 'usageRef');
|
|
|
|
|
|
|
|
|
|
if (usageRef.value) {
|
|
|
|
|
originalUsage.value = usageRef.value.innerHTML
|
|
|
|
|
}
|
|
|
|
|
@@ -266,6 +402,15 @@ const enableEdit = () => {
|
|
|
|
|
usageEdit.enableEdit()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const enableDescriptionEdit = () => {
|
|
|
|
|
console.log(usageRef.value, 'usageRef');
|
|
|
|
|
|
|
|
|
|
if (descriptionRef.value) {
|
|
|
|
|
originalDescription.value = descriptionRef.value.innerHTML
|
|
|
|
|
}
|
|
|
|
|
descriptionEdit.enableEdit()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const saveText = () => {
|
|
|
|
|
if (usageRef.value) {
|
|
|
|
|
productStore.productDescription.usage = usageRef.value.innerHTML
|
|
|
|
|
@@ -285,13 +430,6 @@ const cancelEdit = () => {
|
|
|
|
|
isEditing.value = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const enableDescriptionEdit = () => {
|
|
|
|
|
if (descriptionRef.value) {
|
|
|
|
|
originalDescription.value = descriptionRef.value.innerHTML
|
|
|
|
|
}
|
|
|
|
|
descriptionEdit.enableEdit()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const saveDescription = async () => {
|
|
|
|
|
if (descriptionRef.value) {
|
|
|
|
|
productStore.productDescription.description = descriptionRef.value.innerHTML
|
|
|
|
|
@@ -364,5 +502,4 @@ function removeInlineStylesFromAll(product) {
|
|
|
|
|
product.description_short = removeStyles(product.description_short)
|
|
|
|
|
product.usage = removeStyles(product.usage)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|