@bagelink/vue 0.0.726 → 0.0.728
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/BglVideo.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText2/Toolbar.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText2/index.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText2/richtext-types.d.ts +1 -1
- package/dist/components/form/inputs/RichText2/richtext-types.d.ts.map +1 -1
- package/dist/components/lightbox/Lightbox.vue.d.ts.map +1 -1
- package/dist/components/lightbox/index.d.ts.map +1 -1
- package/dist/index.cjs +217 -220
- package/dist/index.mjs +218 -221
- package/dist/style.css +72 -59
- package/package.json +1 -1
- package/src/components/BglVideo.vue +6 -3
- package/src/components/form/inputs/RichText2/Toolbar.vue +30 -28
- package/src/components/form/inputs/RichText2/index.vue +38 -2
- package/src/components/form/inputs/RichText2/richtext-types.ts +3 -0
- package/src/components/lightbox/Lightbox.vue +96 -115
- package/src/components/lightbox/index.ts +18 -25
- package/src/styles/modal.css +18 -0
- package/src/components/form/inputs/RichText2/FontWithASyntaxHighlighter-Regular.woff2 +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { App, DirectiveBinding } from 'vue'
|
|
1
|
+
import type { App, Directive, DirectiveBinding } from 'vue'
|
|
2
2
|
import { createApp } from 'vue'
|
|
3
3
|
import { IMAGE_FORMATS_REGEXP, VIDEO_FORMATS_REGEXP } from '@bagelink/vue'
|
|
4
4
|
import Lightbox from './Lightbox.vue'
|
|
@@ -6,44 +6,37 @@ import type { LightboxItem } from './lightbox.types'
|
|
|
6
6
|
|
|
7
7
|
type OpenFunction = (item: LightboxItem, groupItems?: LightboxItem[]) => void
|
|
8
8
|
const groups: Record<string, LightboxItem[]> = {}
|
|
9
|
-
const lightboxDirective = {
|
|
10
|
-
mounted(el: HTMLElement, binding
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
name: binding.value.name || ''
|
|
20
|
-
})
|
|
9
|
+
const lightboxDirective: Directive = {
|
|
10
|
+
mounted(el: HTMLElement, binding) {
|
|
11
|
+
el.classList.add('hover')
|
|
12
|
+
let { group, src, type, name, thumbnail } = binding.value || {}
|
|
13
|
+
src = src || binding.value || el.getAttribute('src') || ''
|
|
14
|
+
type = type || determineFileType(src)
|
|
15
|
+
const item: LightboxItem = { src, type, name, thumbnail }
|
|
16
|
+
if (group) {
|
|
17
|
+
if (!groups[group]) groups[group] = []
|
|
18
|
+
groups[group].push(item)
|
|
21
19
|
}
|
|
22
20
|
el.addEventListener('click', (e) => {
|
|
23
21
|
e.stopPropagation()
|
|
24
|
-
const group = binding.value.group || null
|
|
25
|
-
const item: LightboxItem = {
|
|
26
|
-
src: binding.value.src || binding.value,
|
|
27
|
-
type: binding.value.type || determineFileType(binding.value.src || binding.value),
|
|
28
|
-
name: binding.value.name || '',
|
|
29
|
-
thumbnail: binding.value.thumbnail || '',
|
|
30
|
-
}
|
|
31
22
|
const lightboxInstance = createLightboxInstance()
|
|
32
23
|
if (!lightboxInstance || !lightboxInstance.open) return
|
|
33
|
-
if (binding.value.group) {
|
|
34
|
-
if (!groups[binding.value.group]) groups[binding.value.group] = []
|
|
35
|
-
groups[binding.value.group].push(item)
|
|
36
|
-
}
|
|
37
24
|
const open = lightboxInstance.open as OpenFunction
|
|
38
25
|
open(item, groups[group])
|
|
39
26
|
})
|
|
40
27
|
},
|
|
28
|
+
unmounted(el: HTMLElement, binding) {
|
|
29
|
+
// TODO: remove click event handler
|
|
30
|
+
}
|
|
41
31
|
}
|
|
42
32
|
|
|
33
|
+
const youtubeRegex = /youtube\.com|youtu\.be/
|
|
34
|
+
const vimeoRegex = /vimeo\.com/
|
|
35
|
+
|
|
43
36
|
function determineFileType(url: string): string {
|
|
44
37
|
const extension = url.split('.').pop()?.toLowerCase() || ''
|
|
45
38
|
if (IMAGE_FORMATS_REGEXP.test(extension)) return 'image'
|
|
46
|
-
if (VIDEO_FORMATS_REGEXP.test(extension)) return 'video'
|
|
39
|
+
if (VIDEO_FORMATS_REGEXP.test(extension) || youtubeRegex.test(url) || vimeoRegex.test(url)) return 'video'
|
|
47
40
|
if (['pdf'].includes(extension)) return 'pdf'
|
|
48
41
|
return 'unknown'
|
|
49
42
|
}
|
package/src/styles/modal.css
CHANGED
|
@@ -34,6 +34,24 @@
|
|
|
34
34
|
height: fit-content;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
.is-active .modal {
|
|
38
|
+
animation: 200ms ease bgl-modal-animation;
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@keyframes bgl-modal-animation {
|
|
43
|
+
from {
|
|
44
|
+
scale: 0.7;
|
|
45
|
+
transform: translateY(2rem);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
to {
|
|
49
|
+
scale: 1;
|
|
50
|
+
transform: translateY(0);
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
37
55
|
.small-modal .modal {
|
|
38
56
|
max-width: 300px;
|
|
39
57
|
text-align: center;
|