@barzhsieh/nuxt-content-mermaid 2.1.2 → 2.2.0
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/README.md +162 -1
- package/README.zh-TW.md +166 -2
- package/dist/module.d.mts +83 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +126 -9
- package/dist/runtime/components/Mermaid.d.vue.ts +6 -4
- package/dist/runtime/components/Mermaid.vue +492 -36
- package/dist/runtime/components/Mermaid.vue.d.ts +6 -4
- package/dist/runtime/components/MermaidExpandOverlay.d.vue.ts +25 -0
- package/dist/runtime/components/MermaidExpandOverlay.vue +140 -0
- package/dist/runtime/components/MermaidExpandOverlay.vue.d.ts +25 -0
- package/dist/runtime/components/MermaidZoomToolbar.d.vue.ts +23 -0
- package/dist/runtime/components/MermaidZoomToolbar.vue +66 -0
- package/dist/runtime/components/MermaidZoomToolbar.vue.d.ts +23 -0
- package/dist/runtime/components/icons/IconClipboard.d.vue.ts +8 -0
- package/dist/runtime/components/icons/IconClipboard.vue +32 -0
- package/dist/runtime/components/icons/IconClipboard.vue.d.ts +8 -0
- package/dist/runtime/components/icons/IconClipboardHover.d.vue.ts +8 -0
- package/dist/runtime/components/icons/IconClipboardHover.vue +33 -0
- package/dist/runtime/components/icons/IconClipboardHover.vue.d.ts +8 -0
- package/dist/runtime/components/icons/IconClipboardSuccess.d.vue.ts +8 -0
- package/dist/runtime/components/icons/IconClipboardSuccess.vue +33 -0
- package/dist/runtime/components/icons/IconClipboardSuccess.vue.d.ts +8 -0
- package/dist/runtime/components/icons/IconCollapse.d.vue.ts +8 -0
- package/dist/runtime/components/icons/IconCollapse.vue +34 -0
- package/dist/runtime/components/icons/IconCollapse.vue.d.ts +8 -0
- package/dist/runtime/components/icons/IconExpand.d.vue.ts +8 -0
- package/dist/runtime/components/icons/IconExpand.vue +34 -0
- package/dist/runtime/components/icons/IconExpand.vue.d.ts +8 -0
- package/dist/runtime/components/icons/IconMinus.d.vue.ts +8 -0
- package/dist/runtime/components/icons/IconMinus.vue +46 -0
- package/dist/runtime/components/icons/IconMinus.vue.d.ts +8 -0
- package/dist/runtime/components/icons/IconPlus.d.vue.ts +8 -0
- package/dist/runtime/components/icons/IconPlus.vue +57 -0
- package/dist/runtime/components/icons/IconPlus.vue.d.ts +8 -0
- package/dist/runtime/components/icons/iconFullScreen.d.vue.ts +8 -0
- package/dist/runtime/components/icons/iconFullScreen.vue +26 -0
- package/dist/runtime/components/icons/iconFullScreen.vue.d.ts +8 -0
- package/dist/runtime/components/icons/iconFullScreenExit.d.vue.ts +8 -0
- package/dist/runtime/components/icons/iconFullScreenExit.vue +26 -0
- package/dist/runtime/components/icons/iconFullScreenExit.vue.d.ts +8 -0
- package/dist/runtime/composables/_configurable.d.ts +27 -0
- package/dist/runtime/composables/_configurable.js +5 -0
- package/dist/runtime/composables/shared/index.d.ts +5 -0
- package/dist/runtime/composables/shared/index.js +5 -0
- package/dist/runtime/composables/shared/tryOnMounted.d.ts +10 -0
- package/dist/runtime/composables/shared/tryOnMounted.js +11 -0
- package/dist/runtime/composables/shared/tryOnScopeDispose.d.ts +7 -0
- package/dist/runtime/composables/shared/tryOnScopeDispose.js +8 -0
- package/dist/runtime/composables/shared/watchImmediate.d.ts +5 -0
- package/dist/runtime/composables/shared/watchImmediate.js +11 -0
- package/dist/runtime/composables/unrefElement.d.ts +12 -0
- package/dist/runtime/composables/unrefElement.js +5 -0
- package/dist/runtime/composables/useEventListener.d.ts +73 -0
- package/dist/runtime/composables/useEventListener.js +40 -0
- package/dist/runtime/composables/useFullscreen.d.ts +25 -0
- package/dist/runtime/composables/useFullscreen.js +122 -0
- package/dist/runtime/composables/useMermaidCursors.d.ts +12 -0
- package/dist/runtime/composables/useMermaidCursors.js +41 -0
- package/dist/runtime/composables/useMermaidExpand.d.ts +45 -0
- package/dist/runtime/composables/useMermaidExpand.js +480 -0
- package/dist/runtime/composables/useMermaidZoom.d.ts +37 -0
- package/dist/runtime/composables/useMermaidZoom.js +261 -0
- package/dist/runtime/composables/useMounted.d.ts +8 -0
- package/dist/runtime/composables/useMounted.js +16 -0
- package/dist/runtime/composables/useSupported.d.ts +2 -0
- package/dist/runtime/composables/useSupported.js +10 -0
- package/dist/runtime/constants.d.ts +4 -0
- package/dist/runtime/constants.js +24 -0
- package/dist/runtime/mermaid-config.d.ts +1 -1
- package/dist/runtime/plugins/mermaid.client.d.ts +2 -2
- package/dist/runtime/styles.css +1 -0
- package/dist/runtime/types/expand.d.ts +48 -0
- package/dist/runtime/types/expand.js +0 -0
- package/dist/runtime/types/utils.d.ts +115 -0
- package/dist/runtime/types/utils.js +0 -0
- package/dist/runtime/utils/index.d.ts +52 -0
- package/dist/runtime/utils/index.js +113 -0
- package/dist/runtime/utils/is.d.ts +15 -0
- package/dist/runtime/utils/is.js +31 -0
- package/dist/runtime/utils/mermaid-transform.d.ts +18 -0
- package/dist/runtime/utils/mermaid-transform.js +345 -0
- package/dist/runtime/utils/vue.d.ts +2 -0
- package/dist/runtime/utils/vue.js +4 -0
- package/package.json +4 -2
- package/dist/runtime/utils.d.ts +0 -1
- package/dist/runtime/utils.js +0 -30
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
defineProps({
|
|
3
|
+
size: { type: [Number, String], required: false, default: 20 }
|
|
4
|
+
});
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<svg
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
:width="size"
|
|
11
|
+
:height="size"
|
|
12
|
+
viewBox="0 0 24 24"
|
|
13
|
+
class="ncm-icon-animate"
|
|
14
|
+
><g
|
|
15
|
+
fill="none"
|
|
16
|
+
stroke="currentColor"
|
|
17
|
+
stroke-linecap="round"
|
|
18
|
+
stroke-linejoin="round"
|
|
19
|
+
stroke-width="2"
|
|
20
|
+
><path
|
|
21
|
+
class="ncm-icon-ring"
|
|
22
|
+
stroke-dasharray="64"
|
|
23
|
+
stroke-dashoffset="64"
|
|
24
|
+
d="M3 12c0 -4.97 4.03 -9 9 -9c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9c-4.97 0 -9 -4.03 -9 -9Z"
|
|
25
|
+
><animate
|
|
26
|
+
fill="freeze"
|
|
27
|
+
attributeName="stroke-dashoffset"
|
|
28
|
+
dur="0.6s"
|
|
29
|
+
values="64;0"
|
|
30
|
+
/></path><path
|
|
31
|
+
class="ncm-icon-line"
|
|
32
|
+
stroke-dasharray="12"
|
|
33
|
+
stroke-dashoffset="12"
|
|
34
|
+
d="M7 12h10"
|
|
35
|
+
><animate
|
|
36
|
+
fill="freeze"
|
|
37
|
+
attributeName="stroke-dashoffset"
|
|
38
|
+
begin="0.6s"
|
|
39
|
+
dur="0.2s"
|
|
40
|
+
values="12;0"
|
|
41
|
+
/></path><path
|
|
42
|
+
class="ncm-icon-line"
|
|
43
|
+
stroke-dasharray="12"
|
|
44
|
+
stroke-dashoffset="12"
|
|
45
|
+
d="M12 7v10"
|
|
46
|
+
><animate
|
|
47
|
+
fill="freeze"
|
|
48
|
+
attributeName="stroke-dashoffset"
|
|
49
|
+
begin="0.8s"
|
|
50
|
+
dur="0.2s"
|
|
51
|
+
values="12;0"
|
|
52
|
+
/></path></g></svg>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<style scoped>
|
|
56
|
+
@media (prefers-reduced-motion:reduce){.ncm-icon-animate .ncm-icon-line,.ncm-icon-animate .ncm-icon-ring{stroke-dashoffset:0}.ncm-icon-animate animate{display:none}}
|
|
57
|
+
</style>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
size?: number | string;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
5
|
+
size: number | string;
|
|
6
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
size?: number | string;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
5
|
+
size: number | string;
|
|
6
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
defineProps({
|
|
3
|
+
size: { type: [Number, String], required: false, default: 20 }
|
|
4
|
+
});
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<svg
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
:width="size"
|
|
11
|
+
:height="size"
|
|
12
|
+
viewBox="0 0 24 24"
|
|
13
|
+
><g
|
|
14
|
+
fill="none"
|
|
15
|
+
stroke="currentColor"
|
|
16
|
+
stroke-width="1.5"
|
|
17
|
+
><path
|
|
18
|
+
stroke-linecap="round"
|
|
19
|
+
d="M13 22c4.055-.008 6.178-.107 7.535-1.465C22 19.072 22 16.714 22 12s0-7.071-1.465-8.536C19.071 2 16.714 2 12 2S4.929 2 3.464 3.464C2.107 4.822 2.008 6.944 2 11"
|
|
20
|
+
opacity="0.5"
|
|
21
|
+
/><path
|
|
22
|
+
stroke-linecap="round"
|
|
23
|
+
stroke-linejoin="round"
|
|
24
|
+
d="m12 12l5-5m0 0h-3.75M17 7v3.75"
|
|
25
|
+
/><path d="M2 18c0-1.886 0-2.828.586-3.414S4.114 14 6 14s2.828 0 3.414.586S10 16.114 10 18s0 2.828-.586 3.414S7.886 22 6 22s-2.828 0-3.414-.586S2 19.886 2 18Z" /></g></svg>
|
|
26
|
+
</template>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
size?: number | string;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
5
|
+
size: number | string;
|
|
6
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
size?: number | string;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
5
|
+
size: number | string;
|
|
6
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
defineProps({
|
|
3
|
+
size: { type: [Number, String], required: false, default: 20 }
|
|
4
|
+
});
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<svg
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
:width="size"
|
|
11
|
+
:height="size"
|
|
12
|
+
viewBox="0 0 24 24"
|
|
13
|
+
><g
|
|
14
|
+
fill="none"
|
|
15
|
+
stroke="currentColor"
|
|
16
|
+
stroke-width="1.5"
|
|
17
|
+
><path
|
|
18
|
+
stroke-linecap="round"
|
|
19
|
+
d="M13 22c4.055-.008 6.178-.107 7.535-1.465C22 19.072 22 16.714 22 12s0-7.071-1.465-8.536C19.071 2 16.714 2 12 2S4.929 2 3.464 3.464C2.107 4.822 2.008 6.944 2 11"
|
|
20
|
+
opacity="0.5"
|
|
21
|
+
/><path
|
|
22
|
+
stroke-linecap="round"
|
|
23
|
+
stroke-linejoin="round"
|
|
24
|
+
d="m17 7l-5 5m0 0h3.75M12 12V8.25"
|
|
25
|
+
/><path d="M2 18c0-1.886 0-2.828.586-3.414S4.114 14 6 14s2.828 0 3.414.586S10 16.114 10 18s0 2.828-.586 3.414S7.886 22 6 22s-2.828 0-3.414-.586S2 19.886 2 18Z" /></g></svg>
|
|
26
|
+
</template>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
size?: number | string;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
5
|
+
size: number | string;
|
|
6
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface ConfigurableWindow {
|
|
2
|
+
window?: Window;
|
|
3
|
+
}
|
|
4
|
+
export interface ConfigurableDocument {
|
|
5
|
+
document?: Document;
|
|
6
|
+
}
|
|
7
|
+
export interface ConfigurableDocumentOrShadowRoot {
|
|
8
|
+
document?: DocumentOrShadowRoot;
|
|
9
|
+
}
|
|
10
|
+
export interface ConfigurableNavigator {
|
|
11
|
+
navigator?: Navigator;
|
|
12
|
+
}
|
|
13
|
+
export interface ConfigurableLocation {
|
|
14
|
+
location?: Location;
|
|
15
|
+
}
|
|
16
|
+
export declare const defaultWindow: (Window & typeof globalThis) | undefined;
|
|
17
|
+
export declare const defaultDocument: Document | undefined;
|
|
18
|
+
export declare const defaultNavigator: Navigator | undefined;
|
|
19
|
+
export declare const defaultLocation: Location | undefined;
|
|
20
|
+
export interface ConfigurableDeepRefs<D extends boolean> {
|
|
21
|
+
/**
|
|
22
|
+
* Return deep refs instead of shallow refs.
|
|
23
|
+
*
|
|
24
|
+
* @default true - will be changed to `false` by default in the next major
|
|
25
|
+
*/
|
|
26
|
+
deepRefs?: D;
|
|
27
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { isClient } from "../utils/index.js";
|
|
2
|
+
export const defaultWindow = isClient ? window : void 0;
|
|
3
|
+
export const defaultDocument = isClient ? window.document : void 0;
|
|
4
|
+
export const defaultNavigator = isClient ? window.navigator : void 0;
|
|
5
|
+
export const defaultLocation = isClient ? window.location : void 0;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { tryOnMounted } from './tryOnMounted.js';
|
|
2
|
+
export { tryOnScopeDispose } from './tryOnScopeDispose.js';
|
|
3
|
+
export { watchImmediate } from './watchImmediate.js';
|
|
4
|
+
export { isObject, isClient } from '../../utils/index.js';
|
|
5
|
+
export { toArray } from '../../utils/index.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { tryOnMounted } from "./tryOnMounted.js";
|
|
2
|
+
export { tryOnScopeDispose } from "./tryOnScopeDispose.js";
|
|
3
|
+
export { watchImmediate } from "./watchImmediate.js";
|
|
4
|
+
export { isObject, isClient } from "../../utils/index.js";
|
|
5
|
+
export { toArray } from "../../utils/index.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ComponentInternalInstance } from 'vue';
|
|
2
|
+
import type { Fn } from '../../types/utils.js';
|
|
3
|
+
/**
|
|
4
|
+
* Call onMounted() if it's inside a component lifecycle, if not, just call the function
|
|
5
|
+
*
|
|
6
|
+
* @param fn
|
|
7
|
+
* @param sync if set to false, it will run in the nextTick() of Vue
|
|
8
|
+
* @param target
|
|
9
|
+
*/
|
|
10
|
+
export declare function tryOnMounted(fn: Fn, sync?: boolean, target?: ComponentInternalInstance | null): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { nextTick, onMounted } from "vue";
|
|
2
|
+
import { getLifeCycleTarget } from "../../utils/index.js";
|
|
3
|
+
export function tryOnMounted(fn, sync = true, target) {
|
|
4
|
+
const instance = getLifeCycleTarget(target);
|
|
5
|
+
if (instance)
|
|
6
|
+
onMounted(fn, target);
|
|
7
|
+
else if (sync)
|
|
8
|
+
fn();
|
|
9
|
+
else
|
|
10
|
+
nextTick(fn);
|
|
11
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MultiWatchSources, WatchCallback, WatchHandle, WatchOptions, WatchSource } from 'vue';
|
|
2
|
+
import type { MapOldSources, MapSources } from '../../types/utils.js';
|
|
3
|
+
export declare function watchImmediate<T extends Readonly<MultiWatchSources>>(source: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, true>>, options?: Omit<WatchOptions<true>, 'immediate'>): WatchHandle;
|
|
4
|
+
export declare function watchImmediate<T>(source: WatchSource<T>, cb: WatchCallback<T, T | undefined>, options?: Omit<WatchOptions<true>, 'immediate'>): WatchHandle;
|
|
5
|
+
export declare function watchImmediate<T extends object>(source: T, cb: WatchCallback<T, T | undefined>, options?: Omit<WatchOptions<true>, 'immediate'>): WatchHandle;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ComponentPublicInstance, MaybeRef, MaybeRefOrGetter } from 'vue';
|
|
2
|
+
export type VueInstance = ComponentPublicInstance;
|
|
3
|
+
export type MaybeElementRef<T extends MaybeElement = MaybeElement> = MaybeRef<T>;
|
|
4
|
+
export type MaybeComputedElementRef<T extends MaybeElement = MaybeElement> = MaybeRefOrGetter<T>;
|
|
5
|
+
export type MaybeElement = HTMLElement | SVGElement | VueInstance | undefined | null;
|
|
6
|
+
export type UnRefElementReturn<T extends MaybeElement = MaybeElement> = T extends VueInstance ? Exclude<MaybeElement, VueInstance> : T | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Get the dom element of a ref of element or Vue component instance
|
|
9
|
+
*
|
|
10
|
+
* @param elRef
|
|
11
|
+
*/
|
|
12
|
+
export declare function unrefElement<T extends MaybeElement>(elRef: MaybeComputedElementRef<T>): UnRefElementReturn<T>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Arrayable, Fn } from '../types/utils.js';
|
|
2
|
+
import type { MaybeRef, MaybeRefOrGetter } from 'vue';
|
|
3
|
+
interface InferEventTarget<Events> {
|
|
4
|
+
addEventListener: (event: Events, fn?: any, options?: any) => any;
|
|
5
|
+
removeEventListener: (event: Events, fn?: any, options?: any) => any;
|
|
6
|
+
}
|
|
7
|
+
export type WindowEventName = keyof WindowEventMap;
|
|
8
|
+
export type DocumentEventName = keyof DocumentEventMap;
|
|
9
|
+
export type ShadowRootEventName = keyof ShadowRootEventMap;
|
|
10
|
+
export interface GeneralEventListener<E = Event> {
|
|
11
|
+
(evt: E): void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Register using addEventListener on mounted, and removeEventListener automatically on unmounted.
|
|
15
|
+
*
|
|
16
|
+
* Overload 1: Omitted Window target
|
|
17
|
+
*
|
|
18
|
+
* @see https://vueuse.org/useEventListener
|
|
19
|
+
*/
|
|
20
|
+
export declare function useEventListener<E extends keyof WindowEventMap>(event: MaybeRefOrGetter<Arrayable<E>>, listener: MaybeRef<Arrayable<(this: Window, ev: WindowEventMap[E]) => any>>, options?: MaybeRefOrGetter<boolean | AddEventListenerOptions>): Fn;
|
|
21
|
+
/**
|
|
22
|
+
* Register using addEventListener on mounted, and removeEventListener automatically on unmounted.
|
|
23
|
+
*
|
|
24
|
+
* Overload 2: Explicitly Window target
|
|
25
|
+
*
|
|
26
|
+
* @see https://vueuse.org/useEventListener
|
|
27
|
+
* @param target
|
|
28
|
+
* @param event
|
|
29
|
+
* @param listener
|
|
30
|
+
* @param options
|
|
31
|
+
*/
|
|
32
|
+
export declare function useEventListener<E extends keyof WindowEventMap>(target: Window, event: MaybeRefOrGetter<Arrayable<E>>, listener: MaybeRef<Arrayable<(this: Window, ev: WindowEventMap[E]) => any>>, options?: MaybeRefOrGetter<boolean | AddEventListenerOptions>): Fn;
|
|
33
|
+
/**
|
|
34
|
+
* Register using addEventListener on mounted, and removeEventListener automatically on unmounted.
|
|
35
|
+
*
|
|
36
|
+
* Overload 3: Explicitly Document target
|
|
37
|
+
*
|
|
38
|
+
* @see https://vueuse.org/useEventListener
|
|
39
|
+
*/
|
|
40
|
+
export declare function useEventListener<E extends keyof DocumentEventMap>(target: Document, event: MaybeRefOrGetter<Arrayable<E>>, listener: MaybeRef<Arrayable<(this: Document, ev: DocumentEventMap[E]) => any>>, options?: MaybeRefOrGetter<boolean | AddEventListenerOptions>): Fn;
|
|
41
|
+
/**
|
|
42
|
+
* Register using addEventListener on mounted, and removeEventListener automatically on unmounted.
|
|
43
|
+
*
|
|
44
|
+
* Overload 4: Explicitly ShadowRoot target
|
|
45
|
+
*
|
|
46
|
+
* @see https://vueuse.org/useEventListener
|
|
47
|
+
*/
|
|
48
|
+
export declare function useEventListener<E extends keyof ShadowRootEventMap>(target: MaybeRefOrGetter<Arrayable<ShadowRoot> | null | undefined>, event: MaybeRefOrGetter<Arrayable<E>>, listener: MaybeRef<Arrayable<(this: ShadowRoot, ev: ShadowRootEventMap[E]) => any>>, options?: MaybeRefOrGetter<boolean | AddEventListenerOptions>): Fn;
|
|
49
|
+
/**
|
|
50
|
+
* Register using addEventListener on mounted, and removeEventListener automatically on unmounted.
|
|
51
|
+
*
|
|
52
|
+
* Overload 5: Explicitly HTMLElement target
|
|
53
|
+
*
|
|
54
|
+
* @see https://vueuse.org/useEventListener
|
|
55
|
+
*/
|
|
56
|
+
export declare function useEventListener<E extends keyof HTMLElementEventMap>(target: MaybeRefOrGetter<Arrayable<HTMLElement> | null | undefined>, event: MaybeRefOrGetter<Arrayable<E>>, listener: MaybeRef<(this: HTMLElement, ev: HTMLElementEventMap[E]) => any>, options?: MaybeRefOrGetter<boolean | AddEventListenerOptions>): Fn;
|
|
57
|
+
/**
|
|
58
|
+
* Register using addEventListener on mounted, and removeEventListener automatically on unmounted.
|
|
59
|
+
*
|
|
60
|
+
* Overload 6: Custom event target with event type infer
|
|
61
|
+
*
|
|
62
|
+
* @see https://vueuse.org/useEventListener
|
|
63
|
+
*/
|
|
64
|
+
export declare function useEventListener<Names extends string, EventType = Event>(target: MaybeRefOrGetter<Arrayable<InferEventTarget<Names>> | null | undefined>, event: MaybeRefOrGetter<Arrayable<Names>>, listener: MaybeRef<Arrayable<GeneralEventListener<EventType>>>, options?: MaybeRefOrGetter<boolean | AddEventListenerOptions>): Fn;
|
|
65
|
+
/**
|
|
66
|
+
* Register using addEventListener on mounted, and removeEventListener automatically on unmounted.
|
|
67
|
+
*
|
|
68
|
+
* Overload 7: Custom event target fallback
|
|
69
|
+
*
|
|
70
|
+
* @see https://vueuse.org/useEventListener
|
|
71
|
+
*/
|
|
72
|
+
export declare function useEventListener<EventType = Event>(target: MaybeRefOrGetter<Arrayable<EventTarget> | null | undefined>, event: MaybeRefOrGetter<Arrayable<string>>, listener: MaybeRef<Arrayable<GeneralEventListener<EventType>>>, options?: MaybeRefOrGetter<boolean | AddEventListenerOptions>): Fn;
|
|
73
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { isObject, toArray, watchImmediate } from "./shared/index.js";
|
|
2
|
+
import { computed, toValue, unref } from "vue";
|
|
3
|
+
import { defaultWindow } from "./_configurable.js";
|
|
4
|
+
import { unrefElement } from "./unrefElement.js";
|
|
5
|
+
export function useEventListener(...args) {
|
|
6
|
+
const register = (el, event, listener, options) => {
|
|
7
|
+
el.addEventListener(event, listener, options);
|
|
8
|
+
return () => el.removeEventListener(event, listener, options);
|
|
9
|
+
};
|
|
10
|
+
const firstParamTargets = computed(() => {
|
|
11
|
+
const test = toArray(toValue(args[0])).filter((e) => e != null);
|
|
12
|
+
return test.every((e) => typeof e !== "string") ? test : void 0;
|
|
13
|
+
});
|
|
14
|
+
return watchImmediate(
|
|
15
|
+
() => [
|
|
16
|
+
firstParamTargets.value?.map((e) => unrefElement(e)) ?? [defaultWindow].filter((e) => e != null),
|
|
17
|
+
toArray(toValue(firstParamTargets.value ? args[1] : args[0])),
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
19
|
+
toArray(unref(firstParamTargets.value ? args[2] : args[1])),
|
|
20
|
+
// @ts-expect-error - TypeScript gets the correct types, but somehow still complains
|
|
21
|
+
toValue(firstParamTargets.value ? args[3] : args[2])
|
|
22
|
+
],
|
|
23
|
+
([raw_targets, raw_events, raw_listeners, raw_options], _, onCleanup) => {
|
|
24
|
+
if (!raw_targets?.length || !raw_events?.length || !raw_listeners?.length)
|
|
25
|
+
return;
|
|
26
|
+
const optionsClone = isObject(raw_options) ? { ...raw_options } : raw_options;
|
|
27
|
+
const cleanups = raw_targets.flatMap(
|
|
28
|
+
(el) => raw_events.flatMap(
|
|
29
|
+
(event) => raw_listeners.map(
|
|
30
|
+
(listener) => register(el, event, listener, optionsClone)
|
|
31
|
+
)
|
|
32
|
+
)
|
|
33
|
+
);
|
|
34
|
+
onCleanup(() => {
|
|
35
|
+
cleanups.forEach((fn) => fn());
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
{ flush: "post" }
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ConfigurableDocument } from './_configurable.js';
|
|
2
|
+
import type { MaybeElementRef } from './unrefElement.js';
|
|
3
|
+
export interface UseFullscreenOptions extends ConfigurableDocument {
|
|
4
|
+
/**
|
|
5
|
+
* Automatically exit fullscreen when component is unmounted
|
|
6
|
+
*
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
|
+
autoExit?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Reactive Fullscreen API.
|
|
13
|
+
*
|
|
14
|
+
* @see https://vueuse.org/useFullscreen
|
|
15
|
+
* @param target
|
|
16
|
+
* @param options
|
|
17
|
+
*/
|
|
18
|
+
export declare function useFullscreen(target?: MaybeElementRef, options?: UseFullscreenOptions): {
|
|
19
|
+
isSupported: import("vue").ComputedRef<boolean>;
|
|
20
|
+
isFullscreen: import("vue").ShallowRef<boolean, boolean>;
|
|
21
|
+
enter: () => Promise<void>;
|
|
22
|
+
exit: () => Promise<void>;
|
|
23
|
+
toggle: () => Promise<void>;
|
|
24
|
+
};
|
|
25
|
+
export type UseFullscreenReturn = ReturnType<typeof useFullscreen>;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { tryOnMounted, tryOnScopeDispose } from "./shared/index.js";
|
|
2
|
+
import { computed, shallowRef } from "vue";
|
|
3
|
+
import { defaultDocument } from "./_configurable.js";
|
|
4
|
+
import { unrefElement } from "./unrefElement.js";
|
|
5
|
+
import { useEventListener } from "./useEventListener.js";
|
|
6
|
+
import { useSupported } from "./useSupported.js";
|
|
7
|
+
const eventHandlers = [
|
|
8
|
+
"fullscreenchange",
|
|
9
|
+
"webkitfullscreenchange",
|
|
10
|
+
"webkitendfullscreen",
|
|
11
|
+
"mozfullscreenchange",
|
|
12
|
+
"MSFullscreenChange"
|
|
13
|
+
];
|
|
14
|
+
export function useFullscreen(target, options = {}) {
|
|
15
|
+
const {
|
|
16
|
+
document = defaultDocument,
|
|
17
|
+
autoExit = false
|
|
18
|
+
} = options;
|
|
19
|
+
const targetRef = computed(() => unrefElement(target) ?? document?.documentElement);
|
|
20
|
+
const isFullscreen = shallowRef(false);
|
|
21
|
+
const requestMethod = computed(() => {
|
|
22
|
+
return [
|
|
23
|
+
"requestFullscreen",
|
|
24
|
+
"webkitRequestFullscreen",
|
|
25
|
+
"webkitEnterFullscreen",
|
|
26
|
+
"webkitEnterFullScreen",
|
|
27
|
+
"webkitRequestFullScreen",
|
|
28
|
+
"mozRequestFullScreen",
|
|
29
|
+
"msRequestFullscreen"
|
|
30
|
+
].find((m) => document && m in document || targetRef.value && m in targetRef.value);
|
|
31
|
+
});
|
|
32
|
+
const exitMethod = computed(() => {
|
|
33
|
+
return [
|
|
34
|
+
"exitFullscreen",
|
|
35
|
+
"webkitExitFullscreen",
|
|
36
|
+
"webkitExitFullScreen",
|
|
37
|
+
"webkitCancelFullScreen",
|
|
38
|
+
"mozCancelFullScreen",
|
|
39
|
+
"msExitFullscreen"
|
|
40
|
+
].find((m) => document && m in document || targetRef.value && m in targetRef.value);
|
|
41
|
+
});
|
|
42
|
+
const fullscreenEnabled = computed(() => {
|
|
43
|
+
return [
|
|
44
|
+
"fullScreen",
|
|
45
|
+
"webkitIsFullScreen",
|
|
46
|
+
"webkitDisplayingFullscreen",
|
|
47
|
+
"mozFullScreen",
|
|
48
|
+
"msFullscreenElement"
|
|
49
|
+
].find((m) => document && m in document || targetRef.value && m in targetRef.value);
|
|
50
|
+
});
|
|
51
|
+
const fullscreenElementMethod = [
|
|
52
|
+
"fullscreenElement",
|
|
53
|
+
"webkitFullscreenElement",
|
|
54
|
+
"mozFullScreenElement",
|
|
55
|
+
"msFullscreenElement"
|
|
56
|
+
].find((m) => document && m in document);
|
|
57
|
+
const isSupported = useSupported(() => targetRef.value && document && requestMethod.value !== void 0 && exitMethod.value !== void 0 && fullscreenEnabled.value !== void 0);
|
|
58
|
+
const isCurrentElementFullScreen = () => {
|
|
59
|
+
if (fullscreenElementMethod)
|
|
60
|
+
return document?.[fullscreenElementMethod] === targetRef.value;
|
|
61
|
+
return false;
|
|
62
|
+
};
|
|
63
|
+
const isElementFullScreen = () => {
|
|
64
|
+
if (fullscreenEnabled.value) {
|
|
65
|
+
if (document && document[fullscreenEnabled.value] != null) {
|
|
66
|
+
return document[fullscreenEnabled.value];
|
|
67
|
+
} else {
|
|
68
|
+
const target2 = targetRef.value;
|
|
69
|
+
if (target2?.[fullscreenEnabled.value] != null) {
|
|
70
|
+
return Boolean(target2[fullscreenEnabled.value]);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
};
|
|
76
|
+
async function exit() {
|
|
77
|
+
if (!isSupported.value || !isFullscreen.value)
|
|
78
|
+
return;
|
|
79
|
+
if (exitMethod.value) {
|
|
80
|
+
if (document?.[exitMethod.value] != null) {
|
|
81
|
+
await document[exitMethod.value]();
|
|
82
|
+
} else {
|
|
83
|
+
const target2 = targetRef.value;
|
|
84
|
+
if (target2?.[exitMethod.value] != null)
|
|
85
|
+
await target2[exitMethod.value]();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
isFullscreen.value = false;
|
|
89
|
+
}
|
|
90
|
+
async function enter() {
|
|
91
|
+
if (!isSupported.value || isFullscreen.value)
|
|
92
|
+
return;
|
|
93
|
+
if (isElementFullScreen())
|
|
94
|
+
await exit();
|
|
95
|
+
const target2 = targetRef.value;
|
|
96
|
+
if (requestMethod.value && target2?.[requestMethod.value] != null) {
|
|
97
|
+
await target2[requestMethod.value]();
|
|
98
|
+
isFullscreen.value = true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async function toggle() {
|
|
102
|
+
await (isFullscreen.value ? exit() : enter());
|
|
103
|
+
}
|
|
104
|
+
const handlerCallback = () => {
|
|
105
|
+
const isElementFullScreenValue = isElementFullScreen();
|
|
106
|
+
if (!isElementFullScreenValue || isElementFullScreenValue && isCurrentElementFullScreen())
|
|
107
|
+
isFullscreen.value = isElementFullScreenValue;
|
|
108
|
+
};
|
|
109
|
+
const listenerOptions = { capture: false, passive: true };
|
|
110
|
+
useEventListener(document, eventHandlers, handlerCallback, listenerOptions);
|
|
111
|
+
useEventListener(() => unrefElement(targetRef), eventHandlers, handlerCallback, listenerOptions);
|
|
112
|
+
tryOnMounted(handlerCallback, false);
|
|
113
|
+
if (autoExit)
|
|
114
|
+
tryOnScopeDispose(exit);
|
|
115
|
+
return {
|
|
116
|
+
isSupported,
|
|
117
|
+
isFullscreen,
|
|
118
|
+
enter,
|
|
119
|
+
exit,
|
|
120
|
+
toggle
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Ref, type MaybeRef } from 'vue';
|
|
2
|
+
export declare function useMermaidCursors(iconSize: Ref<number>, enabled: MaybeRef<boolean>): {
|
|
3
|
+
cursorVariables: import("vue").ComputedRef<{
|
|
4
|
+
'--ncm-cursor-expand'?: undefined;
|
|
5
|
+
'--ncm-cursor-collapse'?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
'--ncm-cursor-expand': string;
|
|
8
|
+
'--ncm-cursor-collapse': string;
|
|
9
|
+
}>;
|
|
10
|
+
cursorExpandUri: import("vue").ComputedRef<string>;
|
|
11
|
+
cursorCollapseUri: import("vue").ComputedRef<string>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { computed, toValue } from "vue";
|
|
2
|
+
export function useMermaidCursors(iconSize, enabled) {
|
|
3
|
+
const buildCursorSvg = (size, paths) => {
|
|
4
|
+
const outerWidth = Math.max(2, Math.round(size / 8));
|
|
5
|
+
const innerWidth = Math.max(1, outerWidth - 1);
|
|
6
|
+
return `<svg xmlns='http://www.w3.org/2000/svg' width='${size}' height='${size}' viewBox='0 0 24 24' fill='none' stroke-linecap='round' stroke-linejoin='round'><g stroke='black' stroke-width='${outerWidth}'>${paths}</g><g stroke='white' stroke-width='${innerWidth}'>${paths}</g></svg>`;
|
|
7
|
+
};
|
|
8
|
+
const cursorExpandUri = computed(() => {
|
|
9
|
+
const size = iconSize.value;
|
|
10
|
+
const svg = buildCursorSvg(
|
|
11
|
+
size,
|
|
12
|
+
"<polyline points='15 3 21 3 21 9'/><polyline points='9 21 3 21 3 15'/><line x1='21' y1='3' x2='14' y2='10'/><line x1='3' y1='21' x2='10' y2='14'/>"
|
|
13
|
+
);
|
|
14
|
+
const encoded = encodeURIComponent(svg);
|
|
15
|
+
const hotspot = Math.round(size / 2);
|
|
16
|
+
return `url("data:image/svg+xml,${encoded}") ${hotspot} ${hotspot}, zoom-in`;
|
|
17
|
+
});
|
|
18
|
+
const cursorCollapseUri = computed(() => {
|
|
19
|
+
const size = iconSize.value;
|
|
20
|
+
const svg = buildCursorSvg(
|
|
21
|
+
size,
|
|
22
|
+
"<polyline points='4 14 10 14 10 20'/><polyline points='20 10 14 10 14 4'/><line x1='14' y1='10' x2='21' y2='3'/><line x1='3' y1='21' x2='10' y2='14'/>"
|
|
23
|
+
);
|
|
24
|
+
const encoded = encodeURIComponent(svg);
|
|
25
|
+
const hotspot = Math.round(size / 2);
|
|
26
|
+
return `url("data:image/svg+xml,${encoded}") ${hotspot} ${hotspot}, zoom-out`;
|
|
27
|
+
});
|
|
28
|
+
const cursorVariables = computed(() => {
|
|
29
|
+
const isEnabled = toValue(enabled);
|
|
30
|
+
if (!isEnabled) return {};
|
|
31
|
+
return {
|
|
32
|
+
"--ncm-cursor-expand": cursorExpandUri.value,
|
|
33
|
+
"--ncm-cursor-collapse": cursorCollapseUri.value
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
cursorVariables,
|
|
38
|
+
cursorExpandUri,
|
|
39
|
+
cursorCollapseUri
|
|
40
|
+
};
|
|
41
|
+
}
|