@bagelink/vue 0.0.466 → 0.0.471
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/components/Accordion.vue.d.ts.map +1 -1
- package/dist/components/AccordionItem.vue.d.ts.map +1 -1
- package/dist/components/Alert.vue.d.ts +2 -2
- package/dist/components/Alert.vue.d.ts.map +1 -1
- package/dist/components/Avatar.vue.d.ts.map +1 -1
- package/dist/components/Badge.vue.d.ts +2 -2
- package/dist/components/Badge.vue.d.ts.map +1 -1
- package/dist/components/BglVideo.vue.d.ts +2 -2
- package/dist/components/BglVideo.vue.d.ts.map +1 -1
- package/dist/components/Btn.vue.d.ts.map +1 -1
- package/dist/components/Card.vue.d.ts.map +1 -1
- package/dist/components/Carousel.vue.d.ts +4 -2
- package/dist/components/Carousel.vue.d.ts.map +1 -1
- package/dist/components/DataPreview.vue.d.ts.map +1 -1
- package/dist/components/Drop.vue.d.ts +34 -0
- package/dist/components/Drop.vue.d.ts.map +1 -0
- package/dist/components/FileUploader.vue.d.ts +60 -0
- package/dist/components/FileUploader.vue.d.ts.map +1 -0
- package/dist/components/Flag.vue.d.ts +2 -2
- package/dist/components/Flag.vue.d.ts.map +1 -1
- package/dist/components/ListItem.vue.d.ts.map +1 -1
- package/dist/components/ListView.vue.d.ts.map +1 -1
- package/dist/components/MapEmbed.vue.d.ts +2 -2
- package/dist/components/MapEmbed.vue.d.ts.map +1 -1
- package/dist/components/MaterialIcon.vue.d.ts.map +1 -1
- package/dist/components/Modal.vue.d.ts +2 -1
- package/dist/components/Modal.vue.d.ts.map +1 -1
- package/dist/components/ModalConfirm.vue.d.ts.map +1 -1
- package/dist/components/ModalForm.vue.d.ts.map +1 -1
- package/dist/components/NavBar.vue.d.ts.map +1 -1
- package/dist/components/PageTitle.vue.d.ts.map +1 -1
- package/dist/components/TableSchema.vue.d.ts.map +1 -1
- package/dist/components/Title.vue.d.ts.map +1 -1
- package/dist/components/dashboard/Lineart.vue.d.ts.map +1 -1
- package/dist/components/dashboard/index.d.ts.map +1 -1
- package/dist/components/form/BglField.vue.d.ts.map +1 -1
- package/dist/components/form/BglForm.vue.d.ts +4 -2
- package/dist/components/form/BglForm.vue.d.ts.map +1 -1
- package/dist/components/form/ItemRef.vue.d.ts +1 -0
- package/dist/components/form/ItemRef.vue.d.ts.map +1 -1
- package/dist/components/form/index.d.ts.map +1 -1
- package/dist/components/form/inputs/CheckInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/Checkbox.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/ColorPicker.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/DateInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/DatePicker.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/FileUpload.vue.d.ts +2 -1
- package/dist/components/form/inputs/FileUpload.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/JSONInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RadioPillsInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectField.vue.d.ts +1 -4
- package/dist/components/form/inputs/SelectField.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SignaturePad.vue.d.ts +56 -0
- package/dist/components/form/inputs/SignaturePad.vue.d.ts.map +1 -0
- package/dist/components/form/inputs/TableField.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/TelInput.vue.d.ts +2 -2
- package/dist/components/form/inputs/TelInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/TextInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/ToggleInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/index.d.ts +1 -0
- package/dist/components/form/inputs/index.d.ts.map +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/layout/BottomMenu.vue.d.ts.map +1 -1
- package/dist/components/layout/Layout.vue.d.ts +2 -2
- package/dist/components/layout/Layout.vue.d.ts.map +1 -1
- package/dist/components/layout/SidebarMenu.vue.d.ts.map +1 -1
- package/dist/components/layout/TabbedLayout.vue.d.ts.map +1 -1
- package/dist/components/layout/Tabs.vue.d.ts.map +1 -1
- package/dist/components/layout/TabsBody.vue.d.ts.map +1 -1
- package/dist/components/layout/TabsNav.vue.d.ts.map +1 -1
- package/dist/components/layout/index.d.ts.map +1 -1
- package/dist/index.cjs +17616 -20818
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +17616 -20818
- package/dist/plugins/bagel.d.ts +1 -1
- package/dist/plugins/bagel.d.ts.map +1 -1
- package/dist/plugins/modal.d.ts +14 -14
- package/dist/plugins/modal.d.ts.map +1 -1
- package/dist/style.css +330 -309
- package/dist/types/BagelForm.d.ts +16 -16
- package/dist/types/BagelForm.d.ts.map +1 -1
- package/dist/types/BtnOptions.d.ts +1 -1
- package/dist/types/BtnOptions.d.ts.map +1 -1
- package/dist/types/NavLink.d.ts +2 -2
- package/dist/types/NavLink.d.ts.map +1 -1
- package/dist/types/file.d.ts +2 -2
- package/dist/types/file.d.ts.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/materialIcons.d.ts.map +1 -1
- package/dist/utils/BagelFormUtils.d.ts.map +1 -1
- package/dist/utils/allCountries.d.ts +2 -2
- package/dist/utils/allCountries.d.ts.map +1 -1
- package/dist/utils/clickOutside.d.ts.map +1 -1
- package/dist/utils/index.d.ts +5 -5
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +19 -17
- package/src/components/Accordion.vue +10 -10
- package/src/components/AccordionItem.vue +47 -47
- package/src/components/Alert.vue +21 -21
- package/src/components/Avatar.vue +15 -15
- package/src/components/Badge.vue +17 -16
- package/src/components/BglVideo.vue +43 -43
- package/src/components/Btn.vue +64 -65
- package/src/components/Card.vue +26 -26
- package/src/components/Carousel.vue +130 -134
- package/src/components/DataPreview.vue +30 -30
- package/src/components/Flag.vue +26 -26
- package/src/components/ListItem.vue +13 -13
- package/src/components/ListView.vue +2 -2
- package/src/components/MapEmbed.vue +33 -33
- package/src/components/MaterialIcon.vue +12 -12
- package/src/components/Modal.vue +73 -66
- package/src/components/ModalConfirm.vue +18 -18
- package/src/components/ModalForm.vue +79 -76
- package/src/components/NavBar.vue +33 -30
- package/src/components/PageTitle.vue +10 -8
- package/src/components/TableSchema.vue +123 -113
- package/src/components/Title.vue +8 -8
- package/src/components/dashboard/Lineart.vue +103 -96
- package/src/components/dashboard/index.ts +1 -1
- package/src/components/form/BglField.vue +61 -61
- package/src/components/form/BglFieldSet.vue +9 -8
- package/src/components/form/BglForm.vue +71 -70
- package/src/components/form/index.ts +4 -4
- package/src/components/form/inputs/CheckInput.vue +25 -23
- package/src/components/form/inputs/Checkbox.vue +10 -10
- package/src/components/form/inputs/ColorPicker.vue +26 -24
- package/src/components/form/inputs/DateInput.vue +39 -39
- package/src/components/form/inputs/DatePicker.vue +37 -36
- package/src/components/form/inputs/FileUpload.vue +165 -161
- package/src/components/form/inputs/FileUploadURL.vue +134 -132
- package/src/components/form/inputs/JSONInput.vue +29 -29
- package/src/components/form/inputs/RadioPillsInput.vue +49 -49
- package/src/components/form/inputs/RichText.vue +62 -63
- package/src/components/form/inputs/SelectInput.vue +173 -167
- package/src/components/form/inputs/SignaturePad.vue +150 -0
- package/src/components/form/inputs/TableField.vue +77 -76
- package/src/components/form/inputs/TelInput.vue +280 -285
- package/src/components/form/inputs/TextInput.vue +81 -76
- package/src/components/form/inputs/ToggleInput.vue +13 -13
- package/src/components/form/inputs/index.ts +17 -15
- package/src/components/formkit/FileUploader.vue +162 -158
- package/src/components/formkit/MiscFields.vue +20 -20
- package/src/components/formkit/Toggle.vue +13 -13
- package/src/components/index.ts +28 -28
- package/src/components/layout/BottomMenu.vue +25 -21
- package/src/components/layout/Layout.vue +29 -29
- package/src/components/layout/SidebarMenu.vue +31 -27
- package/src/components/layout/TabbedLayout.vue +47 -45
- package/src/components/layout/Tabs.vue +32 -32
- package/src/components/layout/TabsBody.vue +10 -10
- package/src/components/layout/TabsNav.vue +44 -44
- package/src/components/layout/index.ts +7 -7
- package/src/components/layout/tabsManager.ts +6 -6
- package/src/index.ts +13 -8
- package/src/plugins/bagel.ts +37 -37
- package/src/plugins/modal.ts +66 -67
- package/src/styles/layout.css +5 -3
- package/src/styles/mobilLayout.css +7 -0
- package/src/types/BagelForm.ts +27 -27
- package/src/types/BtnOptions.ts +13 -13
- package/src/types/NavLink.ts +8 -8
- package/src/types/file.ts +11 -11
- package/src/types/index.ts +16 -12
- package/src/types/materialIcons.ts +3249 -3249
- package/src/utils/BagelFormUtils.ts +23 -23
- package/src/utils/allCountries.ts +11 -12
- package/src/utils/clickOutside.ts +6 -6
- package/src/utils/index.ts +39 -41
- package/src/utils/lang.ts +13 -13
- package/src/utils/strings.ts +9 -9
- package/tsconfig.json +0 -1
- package/vite.config.ts +8 -8
- package/dist/components/Popover.vue.d.ts +0 -10
- package/dist/components/Popover.vue.d.ts.map +0 -1
- package/dist/types/materialIcon.d.ts +0 -2
- package/dist/types/materialIcon.d.ts.map +0 -1
|
@@ -1,48 +1,48 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// const props =
|
|
3
|
+
withDefaults(
|
|
4
|
+
defineProps<{
|
|
5
|
+
description?: string
|
|
6
|
+
label?: string
|
|
7
|
+
modelValue: any
|
|
8
|
+
placeholder?: string
|
|
9
|
+
editMode?: boolean
|
|
10
|
+
small?: boolean
|
|
11
|
+
}>(),
|
|
12
|
+
{
|
|
13
|
+
description: '',
|
|
14
|
+
editMode: true,
|
|
15
|
+
placeholder: '',
|
|
16
|
+
label: '',
|
|
17
|
+
},
|
|
18
|
+
)
|
|
19
|
+
// TODO: remove this Nati ?
|
|
20
|
+
|
|
21
|
+
const emits = defineEmits(['update:modelValue'])
|
|
22
|
+
function handleInput(e: Event) {
|
|
23
|
+
const el = e.target as HTMLInputElement
|
|
24
|
+
emits('update:modelValue', el.value)
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
1
28
|
<template>
|
|
2
29
|
<div
|
|
3
30
|
class="bagel-input"
|
|
4
31
|
:title="description"
|
|
5
|
-
:class="{ small
|
|
32
|
+
:class="{ small }"
|
|
6
33
|
>
|
|
7
34
|
<label v-if="label">
|
|
8
35
|
<LangText :input="label" />
|
|
9
36
|
</label>
|
|
10
37
|
<textarea
|
|
11
38
|
:value="modelValue"
|
|
12
|
-
@input="handleInput"
|
|
13
39
|
:class="{ 'no-edit': !editMode }"
|
|
14
40
|
:placeholder="placeholder"
|
|
41
|
+
@input="handleInput"
|
|
15
42
|
/>
|
|
16
43
|
</div>
|
|
17
44
|
</template>
|
|
18
45
|
|
|
19
|
-
<script setup lang="ts">
|
|
20
|
-
// TODO: remove this Nati ?
|
|
21
|
-
|
|
22
|
-
const emits = defineEmits(['update:modelValue']);
|
|
23
|
-
// const props =
|
|
24
|
-
withDefaults(
|
|
25
|
-
defineProps<{
|
|
26
|
-
description?: string;
|
|
27
|
-
label?: string;
|
|
28
|
-
modelValue: any;
|
|
29
|
-
placeholder?: string;
|
|
30
|
-
editMode?: boolean;
|
|
31
|
-
small?: boolean;
|
|
32
|
-
}>(),
|
|
33
|
-
{
|
|
34
|
-
description: '',
|
|
35
|
-
editMode: true,
|
|
36
|
-
placeholder: '',
|
|
37
|
-
label: '',
|
|
38
|
-
},
|
|
39
|
-
);
|
|
40
|
-
const handleInput = (e: Event) => {
|
|
41
|
-
const el = e.target as HTMLInputElement;
|
|
42
|
-
emits('update:modelValue', el.value);
|
|
43
|
-
};
|
|
44
|
-
</script>
|
|
45
|
-
|
|
46
46
|
<style scoped>
|
|
47
47
|
.bagel-input textarea {
|
|
48
48
|
font-family: monospace;
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="bagel-input">
|
|
3
|
-
<label class="pb-025"> {{ label }}</label>
|
|
4
|
-
<div class="flex gap-05 flex-wrap">
|
|
5
|
-
<div class="radio-pill" v-for="(option, index) in options" :key="index">
|
|
6
|
-
<input
|
|
7
|
-
type="radio"
|
|
8
|
-
:id="`${id}-${getValue(option)}`"
|
|
9
|
-
:name="id"
|
|
10
|
-
:value="getValue(option)"
|
|
11
|
-
:checked="selectedValue == getValue(option)"
|
|
12
|
-
@change="handleSelect"
|
|
13
|
-
/>
|
|
14
|
-
<label :for="`${id}-${getValue(option)}`">{{ getLabel(option) }}</label>
|
|
15
|
-
</div>
|
|
16
|
-
</div>
|
|
17
|
-
</div>
|
|
18
|
-
</template>
|
|
19
|
-
|
|
20
1
|
<script setup lang="ts">
|
|
21
|
-
import { onMounted, watch } from 'vue'
|
|
2
|
+
import { onMounted, watch } from 'vue'
|
|
22
3
|
|
|
23
4
|
type Option =
|
|
24
5
|
| string
|
|
25
6
|
| number
|
|
26
7
|
| Record<string, any>
|
|
27
|
-
| { label: string
|
|
28
|
-
|
|
29
|
-
const emits = defineEmits(['update:modelValue']);
|
|
30
|
-
|
|
31
|
-
const getLabel = (option: Option) => {
|
|
32
|
-
if (typeof option === 'string') return option;
|
|
33
|
-
if (typeof option === 'number') return `${option}`;
|
|
34
|
-
return option.label;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const getValue = (option: Option) => {
|
|
38
|
-
if (typeof option === 'string') return option;
|
|
39
|
-
if (typeof option === 'number') return option;
|
|
40
|
-
return option.value;
|
|
41
|
-
};
|
|
8
|
+
| { label: string, value: string | number }
|
|
42
9
|
|
|
43
10
|
const props = withDefaults(
|
|
44
11
|
defineProps<{
|
|
45
|
-
options?: Option[]
|
|
46
|
-
modelValue?: any
|
|
47
|
-
id?: string
|
|
48
|
-
label?: string
|
|
12
|
+
options?: Option[]
|
|
13
|
+
modelValue?: any
|
|
14
|
+
id?: string
|
|
15
|
+
label?: string
|
|
49
16
|
}>(),
|
|
50
17
|
{
|
|
51
18
|
modelValue: '',
|
|
52
19
|
id: () => `radio-pill-${Math.random().toString(36).substring(2, 9)}`,
|
|
53
20
|
label: '',
|
|
54
21
|
},
|
|
55
|
-
)
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
const emits = defineEmits(['update:modelValue'])
|
|
56
25
|
|
|
57
|
-
|
|
26
|
+
function getLabel(option: Option) {
|
|
27
|
+
if (typeof option === 'string') return option
|
|
28
|
+
if (typeof option === 'number') return `${option}`
|
|
29
|
+
return option.label
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getValue(option: Option) {
|
|
33
|
+
if (typeof option === 'string') return option
|
|
34
|
+
if (typeof option === 'number') return option
|
|
35
|
+
return option.value
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let selectedValue = $ref(props.modelValue)
|
|
58
39
|
|
|
59
40
|
function handleSelect(e: Event) {
|
|
60
|
-
const newVal = (e.target as any)?.value
|
|
61
|
-
emits('update:modelValue', newVal)
|
|
62
|
-
selectedValue = newVal
|
|
41
|
+
const newVal = (e.target as any)?.value
|
|
42
|
+
emits('update:modelValue', newVal)
|
|
43
|
+
selectedValue = newVal
|
|
63
44
|
}
|
|
64
45
|
|
|
65
46
|
watch(
|
|
66
47
|
() => props.modelValue,
|
|
67
48
|
(newVal, oldVal) => {
|
|
68
|
-
if (newVal === oldVal || oldVal === undefined) return
|
|
69
|
-
if (selectedValue !== newVal) selectedValue = newVal
|
|
49
|
+
if (newVal === oldVal || oldVal === undefined) return
|
|
50
|
+
if (selectedValue !== newVal) selectedValue = newVal
|
|
70
51
|
},
|
|
71
52
|
{ immediate: true },
|
|
72
|
-
)
|
|
53
|
+
)
|
|
73
54
|
|
|
74
55
|
onMounted(() => {
|
|
75
|
-
selectedValue = props.modelValue
|
|
76
|
-
})
|
|
56
|
+
selectedValue = props.modelValue
|
|
57
|
+
})
|
|
77
58
|
</script>
|
|
78
59
|
|
|
60
|
+
<template>
|
|
61
|
+
<div class="bagel-input">
|
|
62
|
+
<label class="pb-025"> {{ label }}</label>
|
|
63
|
+
<div class="flex gap-05 flex-wrap">
|
|
64
|
+
<div v-for="(option, index) in options" :key="index" class="radio-pill">
|
|
65
|
+
<input
|
|
66
|
+
:id="`${id}-${getValue(option)}`"
|
|
67
|
+
type="radio"
|
|
68
|
+
:name="id"
|
|
69
|
+
:value="getValue(option)"
|
|
70
|
+
:checked="selectedValue == getValue(option)"
|
|
71
|
+
@change="handleSelect"
|
|
72
|
+
>
|
|
73
|
+
<label :for="`${id}-${getValue(option)}`">{{ getLabel(option) }}</label>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</template>
|
|
78
|
+
|
|
79
79
|
<style scoped>
|
|
80
80
|
.radio-pill label {
|
|
81
81
|
color: var(--bgl-primary);
|
|
@@ -1,56 +1,38 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="RichText">
|
|
3
|
-
<div class="RichText-tools" v-if="editor">
|
|
4
|
-
<Btn
|
|
5
|
-
tabindex="-1"
|
|
6
|
-
:flat="!editor.isActive(item.name, item.option)"
|
|
7
|
-
@click="item.command"
|
|
8
|
-
thin
|
|
9
|
-
v-for="item in config"
|
|
10
|
-
v-tooltip="item.name"
|
|
11
|
-
:key="item.name"
|
|
12
|
-
:icon="item.icon"
|
|
13
|
-
:disabled="item.disabled?.()"
|
|
14
|
-
/>
|
|
15
|
-
</div>
|
|
16
|
-
<editor-content :editor="editor" />
|
|
17
|
-
</div>
|
|
18
|
-
</template>
|
|
19
|
-
|
|
20
1
|
<script setup lang="ts">
|
|
21
2
|
import {
|
|
22
|
-
Btn,
|
|
23
|
-
useModal,
|
|
24
3
|
FileUpload as $el,
|
|
25
|
-
bagelFormUtils,
|
|
26
4
|
BglVideo,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
-
import
|
|
36
|
-
import
|
|
37
|
-
import
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
5
|
+
Btn,
|
|
6
|
+
bagelFormUtils,
|
|
7
|
+
useModal,
|
|
8
|
+
} from '@bagelink/vue'
|
|
9
|
+
import { onBeforeUnmount, onMounted, watch } from 'vue'
|
|
10
|
+
import StarterKit from '@tiptap/starter-kit'
|
|
11
|
+
import { Editor, EditorContent } from '@tiptap/vue-3'
|
|
12
|
+
import Image from '@tiptap/extension-image'
|
|
13
|
+
import YouTube from '@tiptap/extension-youtube'
|
|
14
|
+
import Table from '@tiptap/extension-table'
|
|
15
|
+
import TableRow from '@tiptap/extension-table-row'
|
|
16
|
+
import TableCell from '@tiptap/extension-table-cell'
|
|
17
|
+
import TableHeader from '@tiptap/extension-table-header'
|
|
18
|
+
import type { MaterialIcons } from '@bagelink/vue'
|
|
41
19
|
|
|
42
|
-
const props = defineProps<{ modelValue: string }>()
|
|
20
|
+
const props = defineProps<{ modelValue: string }>()
|
|
21
|
+
const emit = defineEmits(['update:modelValue'])
|
|
22
|
+
// import $el from './FileUploadURL.vue';
|
|
23
|
+
const { txtField } = bagelFormUtils
|
|
24
|
+
let editor = $ref<Editor>()
|
|
43
25
|
|
|
44
|
-
|
|
45
|
-
if (!editor) throw new Error('editor is not defined')
|
|
46
|
-
return editor.chain().focus()
|
|
47
|
-
}
|
|
48
|
-
const { showModalForm } = useModal()
|
|
26
|
+
function focus() {
|
|
27
|
+
if (!editor) throw new Error('editor is not defined')
|
|
28
|
+
return editor.chain().focus()
|
|
29
|
+
}
|
|
30
|
+
const { showModalForm } = useModal()
|
|
49
31
|
|
|
50
32
|
Image.configure({
|
|
51
33
|
inline: true,
|
|
52
34
|
allowBase64: true,
|
|
53
|
-
})
|
|
35
|
+
})
|
|
54
36
|
|
|
55
37
|
function addImage() {
|
|
56
38
|
showModalForm({
|
|
@@ -60,20 +42,20 @@ function addImage() {
|
|
|
60
42
|
{ $el, id: 'src', attrs: { bindkey: 'url' } },
|
|
61
43
|
txtField('alt', 'Alt Text'),
|
|
62
44
|
],
|
|
63
|
-
onSubmit:
|
|
64
|
-
})
|
|
45
|
+
onSubmit: imgObj => focus().setImage(imgObj).run(),
|
|
46
|
+
})
|
|
65
47
|
}
|
|
66
48
|
|
|
67
49
|
const config: {
|
|
68
|
-
name: string
|
|
69
|
-
command: any
|
|
70
|
-
icon: MaterialIcons
|
|
71
|
-
option?: Record<string, any
|
|
72
|
-
disabled?: () => boolean
|
|
50
|
+
name: string
|
|
51
|
+
command: any
|
|
52
|
+
icon: MaterialIcons
|
|
53
|
+
option?: Record<string, any>
|
|
54
|
+
disabled?: () => boolean
|
|
73
55
|
}[] = [
|
|
74
56
|
{
|
|
75
57
|
name: 'Bold',
|
|
76
|
-
command: () => focus()
|
|
58
|
+
command: () => focus().toggleBold().run(),
|
|
77
59
|
icon: 'format_bold',
|
|
78
60
|
disabled: () => !editor?.can().chain().focus().toggleBold()
|
|
79
61
|
.run(),
|
|
@@ -114,8 +96,8 @@ const config: {
|
|
|
114
96
|
attrs: { src: (_: any, { src }: { src: string }) => src || '' },
|
|
115
97
|
},
|
|
116
98
|
],
|
|
117
|
-
onSubmit:
|
|
118
|
-
})
|
|
99
|
+
onSubmit: videoObj => editor?.commands.setYoutubeVideo(videoObj),
|
|
100
|
+
})
|
|
119
101
|
},
|
|
120
102
|
icon: 'youtube_activity',
|
|
121
103
|
},
|
|
@@ -218,9 +200,7 @@ const config: {
|
|
|
218
200
|
disabled: () => !editor?.can().chain().focus().redo()
|
|
219
201
|
.run(),
|
|
220
202
|
},
|
|
221
|
-
]
|
|
222
|
-
|
|
223
|
-
const emit = defineEmits(['update:modelValue']);
|
|
203
|
+
]
|
|
224
204
|
|
|
225
205
|
function initEditor() {
|
|
226
206
|
editor = new Editor({
|
|
@@ -234,24 +214,43 @@ function initEditor() {
|
|
|
234
214
|
TableHeader,
|
|
235
215
|
],
|
|
236
216
|
content: props.modelValue,
|
|
237
|
-
onUpdate: ({ editor }) => emit('update:modelValue', editor.getHTML()),
|
|
238
|
-
})
|
|
217
|
+
onUpdate: ({ editor }) => { emit('update:modelValue', editor.getHTML()) },
|
|
218
|
+
})
|
|
239
219
|
}
|
|
240
220
|
|
|
241
221
|
watch(
|
|
242
222
|
() => props.modelValue,
|
|
243
223
|
(value) => {
|
|
244
|
-
if (editor?.getHTML() === value) return
|
|
245
|
-
editor?.commands.setContent(value, false)
|
|
224
|
+
if (editor?.getHTML() === value) return
|
|
225
|
+
editor?.commands.setContent(value, false)
|
|
246
226
|
},
|
|
247
227
|
{ immediate: true },
|
|
248
|
-
)
|
|
228
|
+
)
|
|
249
229
|
|
|
250
|
-
onMounted(initEditor)
|
|
230
|
+
onMounted(initEditor)
|
|
251
231
|
|
|
252
|
-
onBeforeUnmount(() => editor?.destroy())
|
|
232
|
+
onBeforeUnmount(() => editor?.destroy())
|
|
253
233
|
</script>
|
|
254
234
|
|
|
235
|
+
<template>
|
|
236
|
+
<div class="RichText">
|
|
237
|
+
<div v-if="editor" class="RichText-tools">
|
|
238
|
+
<Btn
|
|
239
|
+
v-for="item in config"
|
|
240
|
+
:key="item.name"
|
|
241
|
+
v-tooltip="item.name"
|
|
242
|
+
tabindex="-1"
|
|
243
|
+
:flat="!editor.isActive(item.name, item.option)"
|
|
244
|
+
thin
|
|
245
|
+
:icon="item.icon"
|
|
246
|
+
:disabled="item.disabled?.()"
|
|
247
|
+
@click="item.command"
|
|
248
|
+
/>
|
|
249
|
+
</div>
|
|
250
|
+
<EditorContent :editor="editor" />
|
|
251
|
+
</div>
|
|
252
|
+
</template>
|
|
253
|
+
|
|
255
254
|
<style>
|
|
256
255
|
/* Basic editor styles */
|
|
257
256
|
.tiptap > * + * {
|