@finema/core 1.4.192 → 1.4.194
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FormFields :options="formFields" :form="form" />
|
|
3
|
+
</template>
|
|
4
|
+
<script lang="ts" setup>
|
|
5
|
+
import { toTypedSchema, useForm, createFormFields, watch } from '#imports'
|
|
6
|
+
import * as z from 'zod'
|
|
7
|
+
import { INPUT_TYPES } from '#core/components/Form/types'
|
|
8
|
+
import type { IWYSIWYGFieldProps } from '#core/components/Form/InputWYSIWYG/types'
|
|
9
|
+
|
|
10
|
+
const emits = defineEmits(['submit'])
|
|
11
|
+
const props = defineProps<{
|
|
12
|
+
options: IWYSIWYGFieldProps['image']
|
|
13
|
+
}>()
|
|
14
|
+
|
|
15
|
+
const form = useForm({
|
|
16
|
+
validationSchema: toTypedSchema(
|
|
17
|
+
z.object({
|
|
18
|
+
file: z
|
|
19
|
+
.object({
|
|
20
|
+
url: z.string(),
|
|
21
|
+
path: z.string().optional(),
|
|
22
|
+
name: z.string().optional(),
|
|
23
|
+
size: z.string().optional(),
|
|
24
|
+
})
|
|
25
|
+
.optional()
|
|
26
|
+
.nullable(),
|
|
27
|
+
})
|
|
28
|
+
),
|
|
29
|
+
initialValues: {
|
|
30
|
+
file: null,
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const formFields = createFormFields(() => [
|
|
35
|
+
{
|
|
36
|
+
type: INPUT_TYPES.UPLOAD_IMAGE_AUTO,
|
|
37
|
+
props: {
|
|
38
|
+
name: 'file',
|
|
39
|
+
...((props.options || {}) as any),
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
])
|
|
43
|
+
|
|
44
|
+
watch(
|
|
45
|
+
() => form.values,
|
|
46
|
+
() => {
|
|
47
|
+
if (form.values.file?.url) {
|
|
48
|
+
emits('submit', form.values.file?.url)
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
deep: true,
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
</script>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
+
<Modal v-model="isShowUploadImageModal" title="อัพโหลดรูปภาพ">
|
|
4
|
+
<UploadImageForm :options="image" @submit="onImageSubmit" />
|
|
5
|
+
</Modal>
|
|
3
6
|
<ClientOnly>
|
|
4
7
|
<div
|
|
5
8
|
class="form-textarea focus:ring-primary-500 dark:focus:ring-primary-400 relative block w-full resize-none rounded-md border-0 bg-white p-0 pb-3 text-sm text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:outline-none focus:ring-2 disabled:cursor-not-allowed disabled:opacity-75 dark:bg-gray-900 dark:text-white dark:ring-gray-700 dark:placeholder:text-gray-500"
|
|
@@ -45,10 +48,12 @@ import TextAlign from '@tiptap/extension-text-align'
|
|
|
45
48
|
import Link from '@tiptap/extension-link'
|
|
46
49
|
import Image from '@tiptap/extension-image'
|
|
47
50
|
import Youtube from '@tiptap/extension-youtube'
|
|
48
|
-
import { computed, watch } from 'vue'
|
|
51
|
+
import { computed, watch, ref } from 'vue'
|
|
52
|
+
import UploadImageForm from '#core/components/Form/InputWYSIWYG/UploadImageForm.vue'
|
|
49
53
|
|
|
50
54
|
const props = withDefaults(defineProps<IWYSIWYGFieldProps>(), {})
|
|
51
55
|
const { value, wrapperProps } = useFieldHOC<string>(props)
|
|
56
|
+
const isShowUploadImageModal = ref(false)
|
|
52
57
|
const editor = useEditor({
|
|
53
58
|
content: value.value,
|
|
54
59
|
extensions: [
|
|
@@ -160,10 +165,14 @@ const menuItems = computed(() => [
|
|
|
160
165
|
name: 'image',
|
|
161
166
|
icon: 'ph:image',
|
|
162
167
|
action: () => {
|
|
163
|
-
|
|
168
|
+
if (props.image?.requestOptions) {
|
|
169
|
+
isShowUploadImageModal.value = true
|
|
170
|
+
} else {
|
|
171
|
+
const url = window.prompt('Image URL')
|
|
164
172
|
|
|
165
|
-
|
|
166
|
-
|
|
173
|
+
if (url) {
|
|
174
|
+
editor.value!.chain().focus().setImage({ src: url }).run()
|
|
175
|
+
}
|
|
167
176
|
}
|
|
168
177
|
},
|
|
169
178
|
title: 'Insert Image',
|
|
@@ -210,6 +219,11 @@ const menuItems = computed(() => [
|
|
|
210
219
|
},
|
|
211
220
|
],
|
|
212
221
|
])
|
|
222
|
+
|
|
223
|
+
const onImageSubmit = (url: string) => {
|
|
224
|
+
editor.value!.chain().focus().setImage({ src: url }).run()
|
|
225
|
+
isShowUploadImageModal.value = false
|
|
226
|
+
}
|
|
213
227
|
</script>
|
|
214
228
|
<style>
|
|
215
229
|
.tiptap-menu-bar{@apply flex flex-wrap border-b py-2 px-2 gap-1}.menu-item{@apply px-1 py-1 rounded hover:bg-gray-100 transition-colors flex justify-center items-center}.menu-item.is-active{@apply bg-primary-100 text-primary-600}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { type IFieldProps, type IFormFieldBase, type INPUT_TYPES } from '#core/components/Form/types';
|
|
2
|
+
import type { AxiosRequestConfig } from 'axios';
|
|
2
3
|
export interface IWYSIWYGFieldProps extends IFieldProps {
|
|
4
|
+
image?: {
|
|
5
|
+
requestOptions?: Omit<AxiosRequestConfig, 'baseURL'> & {
|
|
6
|
+
baseURL: string;
|
|
7
|
+
};
|
|
8
|
+
uploadPathURL?: string;
|
|
9
|
+
uploadAddLabel?: string;
|
|
10
|
+
accept?: string[] | string;
|
|
11
|
+
bodyKey?: string;
|
|
12
|
+
responseURL?: string;
|
|
13
|
+
responsePath?: string;
|
|
14
|
+
maxSize?: number;
|
|
15
|
+
};
|
|
3
16
|
}
|
|
4
17
|
export type IWYSIWYGField = IFormFieldBase<INPUT_TYPES.WYSIWYG, IWYSIWYGFieldProps, {
|
|
5
18
|
change?: (value: string) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finema/core",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.194",
|
|
4
4
|
"repository": "https://gitlab.finema.co/finema/ui-kit",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Finema Dev Core Team",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@nuxt/kit": "^3.13.1",
|
|
39
|
-
"@nuxt/ui": "2.18.
|
|
39
|
+
"@nuxt/ui": "2.18.5",
|
|
40
40
|
"@pinia/nuxt": "^0.5.4",
|
|
41
41
|
"@tiptap/extension-image": "^2.6.6",
|
|
42
42
|
"@tiptap/extension-link": "^2.6.6",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@finema/eslint-config": "^1.2.0",
|
|
70
|
-
"@nuxt/devtools": "^1.
|
|
70
|
+
"@nuxt/devtools": "^1.4.2",
|
|
71
71
|
"@nuxt/eslint-config": "^0.5.0",
|
|
72
72
|
"@nuxt/module-builder": "^0.5.5",
|
|
73
73
|
"@nuxt/schema": "^3.13.1",
|