@hywax/cms 0.0.23 → 1.1.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/.nuxt/cms/editor/index.ts +0 -2
- package/.nuxt/cms/form-panel-section.ts +2 -2
- package/.nuxt/cms/index.ts +8 -21
- package/.nuxt/cms/table-search-input.ts +6 -0
- package/dist/module.json +3 -3
- package/dist/module.mjs +85 -204
- package/dist/runtime/components/AutocompleteSelect.d.vue.ts +56 -0
- package/dist/runtime/components/AutocompleteSelect.vue +131 -77
- package/dist/runtime/components/AutocompleteSelect.vue.d.ts +43 -29
- package/dist/runtime/components/{ButtonDelete.vue.d.ts → ButtonDeleteConfirm.d.vue.ts} +4 -3
- package/dist/runtime/components/{ButtonDelete.vue → ButtonDeleteConfirm.vue} +1 -1
- package/dist/runtime/components/ButtonDeleteConfirm.vue.d.ts +36 -0
- package/dist/runtime/components/DatePicker.d.vue.ts +43 -0
- package/dist/runtime/components/DatePicker.vue +232 -0
- package/dist/runtime/components/DatePicker.vue.d.ts +43 -0
- package/dist/runtime/components/EditorFull.d.vue.ts +13 -0
- package/dist/runtime/components/EditorFull.vue +127 -0
- package/dist/runtime/components/EditorFull.vue.d.ts +13 -0
- package/dist/runtime/components/EditorLinkPopover.d.vue.ts +8 -0
- package/dist/runtime/components/EditorLinkPopover.vue +137 -0
- package/dist/runtime/components/EditorLinkPopover.vue.d.ts +8 -0
- package/dist/runtime/components/FormPanel.d.vue.ts +47 -0
- package/dist/runtime/components/FormPanel.vue +10 -7
- package/dist/runtime/components/FormPanel.vue.d.ts +21 -15
- package/dist/runtime/components/FormPanelAsideSection.d.vue.ts +24 -0
- package/dist/runtime/components/FormPanelAsideSection.vue.d.ts +2 -1
- package/dist/runtime/components/FormPanelSection.d.vue.ts +21 -0
- package/dist/runtime/components/FormPanelSection.vue +2 -2
- package/dist/runtime/components/FormPanelSection.vue.d.ts +3 -2
- package/dist/runtime/components/Layout.d.vue.ts +29 -0
- package/dist/runtime/components/Layout.vue +81 -0
- package/dist/runtime/components/Layout.vue.d.ts +29 -0
- package/dist/runtime/components/ModalConfirm.d.vue.ts +33 -0
- package/dist/runtime/components/ModalConfirm.vue.d.ts +3 -2
- package/dist/runtime/components/TableColumnSorting.d.vue.ts +17 -0
- package/dist/runtime/components/{TablePanelColumnSorting.vue → TableColumnSorting.vue} +27 -18
- package/dist/runtime/components/TableColumnSorting.vue.d.ts +17 -0
- package/dist/runtime/components/TableColumnVisibility.d.vue.ts +24 -0
- package/dist/runtime/components/TableColumnVisibility.vue +111 -0
- package/dist/runtime/components/TableColumnVisibility.vue.d.ts +24 -0
- package/dist/runtime/components/TableFilters.d.vue.ts +90 -0
- package/dist/runtime/components/TableFilters.vue +198 -0
- package/dist/runtime/components/TableFilters.vue.d.ts +90 -0
- package/dist/runtime/components/TablePanel.d.vue.ts +95 -0
- package/dist/runtime/components/TablePanel.vue +207 -66
- package/dist/runtime/components/TablePanel.vue.d.ts +76 -31
- package/dist/runtime/components/TableSearchInput.d.vue.ts +33 -0
- package/dist/runtime/components/TableSearchInput.vue +96 -0
- package/dist/runtime/components/TableSearchInput.vue.d.ts +33 -0
- package/dist/runtime/components/UploraImage.d.vue.ts +35 -0
- package/dist/runtime/components/UploraImage.vue.d.ts +3 -2
- package/dist/runtime/components/prose/UploraImage.d.vue.ts +14 -0
- package/dist/runtime/components/prose/UploraImage.vue.d.ts +2 -1
- package/dist/runtime/composables/useAdmin.d.ts +1 -1
- package/dist/runtime/composables/useAdmin.js +2 -1
- package/dist/runtime/composables/useApi.d.ts +1 -1
- package/dist/runtime/composables/useAsyncHandler.d.ts +1 -1
- package/dist/runtime/composables/useAsyncHandler.js +1 -1
- package/dist/runtime/composables/useEditorDragHandle.d.ts +16 -0
- package/dist/runtime/composables/useEditorDragHandle.js +95 -0
- package/dist/runtime/composables/useEditorSuggestions.d.ts +68 -0
- package/dist/runtime/composables/useEditorSuggestions.js +24 -0
- package/dist/runtime/composables/useEditorToolbar.d.ts +120 -0
- package/dist/runtime/composables/useEditorToolbar.js +87 -0
- package/dist/runtime/composables/useFormState.d.ts +12 -0
- package/dist/runtime/composables/useFormState.js +33 -0
- package/dist/runtime/composables/useLogout.d.ts +1 -1
- package/dist/runtime/composables/useLogout.js +3 -1
- package/dist/runtime/composables/useNotification.d.ts +12 -0
- package/dist/runtime/composables/useNotification.js +46 -0
- package/dist/runtime/composables/useQueryState.d.ts +28 -0
- package/dist/runtime/composables/useQueryState.js +105 -0
- package/dist/runtime/composables/useRouteQuery.d.ts +37 -0
- package/dist/runtime/composables/useRouteQuery.js +81 -0
- package/dist/runtime/composables/useRowSelection.d.ts +8 -0
- package/dist/runtime/composables/useRowSelection.js +46 -0
- package/dist/runtime/composables/useTable.d.ts +17 -11
- package/dist/runtime/composables/useTable.js +47 -53
- package/dist/runtime/composables/useUplora.d.ts +1 -1
- package/dist/runtime/composables/useUplora.js +2 -1
- package/dist/runtime/index.css +1 -1
- package/dist/runtime/plugins/zod.d.ts +2 -0
- package/dist/runtime/plugins/zod.js +26 -0
- package/dist/runtime/server/api/uplora/[id].delete.d.ts +1 -5
- package/dist/runtime/tv.d.ts +1 -1
- package/dist/runtime/types/date.d.ts +5 -0
- package/dist/runtime/types/index.d.ts +3 -21
- package/dist/runtime/types/index.js +1 -21
- package/dist/runtime/types/utils.d.ts +7 -0
- package/dist/runtime/utils/date.d.ts +9 -0
- package/dist/runtime/utils/date.js +28 -0
- package/dist/runtime/utils/formatters.d.ts +2 -0
- package/dist/runtime/utils/formatters.js +8 -0
- package/dist/runtime/utils/index.d.ts +5 -2
- package/dist/runtime/utils/index.js +5 -2
- package/dist/runtime/utils/storage.d.ts +2 -0
- package/dist/runtime/utils/storage.js +10 -0
- package/dist/runtime/utils/table.d.ts +23 -0
- package/dist/runtime/utils/table.js +51 -0
- package/package.json +26 -25
- package/.nuxt/cms/button-clear.ts +0 -5
- package/.nuxt/cms/button-copy.ts +0 -5
- package/.nuxt/cms/button-delete.ts +0 -5
- package/.nuxt/cms/editor/callout.ts +0 -21
- package/.nuxt/cms/editor/uplora-image.ts +0 -5
- package/.nuxt/cms/editor-content-full.ts +0 -13
- package/.nuxt/cms/editor-content-light.ts +0 -13
- package/.nuxt/cms/input-seo.ts +0 -5
- package/.nuxt/cms/input-slug.ts +0 -5
- package/.nuxt/cms/input-uplora-image.ts +0 -22
- package/.nuxt/cms/table-cell-preview.ts +0 -9
- package/.nuxt/cms/table-cell-seo.ts +0 -5
- package/.nuxt/cms/table-cell-user.ts +0 -9
- package/.nuxt/cms/table-panel-column-sorting.ts +0 -5
- package/.nuxt/cms/table-panel-column-visibility.ts +0 -5
- package/.nuxt/cms/table-panel-filters.ts +0 -5
- package/dist/runtime/components/ButtonClear.vue +0 -35
- package/dist/runtime/components/ButtonClear.vue.d.ts +0 -35
- package/dist/runtime/components/ButtonCopy.vue +0 -40
- package/dist/runtime/components/ButtonCopy.vue.d.ts +0 -23
- package/dist/runtime/components/EditorContentFull.vue +0 -67
- package/dist/runtime/components/EditorContentFull.vue.d.ts +0 -23
- package/dist/runtime/components/EditorContentLight.vue +0 -60
- package/dist/runtime/components/EditorContentLight.vue.d.ts +0 -23
- package/dist/runtime/components/InputSeo.vue +0 -73
- package/dist/runtime/components/InputSeo.vue.d.ts +0 -19
- package/dist/runtime/components/InputSlug.vue +0 -70
- package/dist/runtime/components/InputSlug.vue.d.ts +0 -29
- package/dist/runtime/components/InputUploraImage.vue +0 -156
- package/dist/runtime/components/InputUploraImage.vue.d.ts +0 -38
- package/dist/runtime/components/TableCellPreview.vue +0 -41
- package/dist/runtime/components/TableCellPreview.vue.d.ts +0 -18
- package/dist/runtime/components/TableCellSeo.vue +0 -34
- package/dist/runtime/components/TableCellSeo.vue.d.ts +0 -13
- package/dist/runtime/components/TableCellUser.vue +0 -40
- package/dist/runtime/components/TableCellUser.vue.d.ts +0 -18
- package/dist/runtime/components/TablePanelColumnSorting.vue.d.ts +0 -20
- package/dist/runtime/components/TablePanelColumnVisibility.vue +0 -49
- package/dist/runtime/components/TablePanelColumnVisibility.vue.d.ts +0 -20
- package/dist/runtime/components/TablePanelFilters.vue +0 -79
- package/dist/runtime/components/TablePanelFilters.vue.d.ts +0 -34
- package/dist/runtime/composables/useDeleteConfirm.d.ts +0 -15
- package/dist/runtime/composables/useDeleteConfirm.js +0 -27
- package/dist/runtime/composables/useSeoStats.d.ts +0 -12
- package/dist/runtime/composables/useSeoStats.js +0 -44
- package/dist/runtime/editor/components/BlockMenu.vue +0 -43
- package/dist/runtime/editor/components/BlockMenu.vue.d.ts +0 -2
- package/dist/runtime/editor/components/SlashCommand.vue +0 -92
- package/dist/runtime/editor/components/SlashCommand.vue.d.ts +0 -7
- package/dist/runtime/editor/components/TooltipLink.vue +0 -81
- package/dist/runtime/editor/components/TooltipLink.vue.d.ts +0 -9
- package/dist/runtime/editor/components/TooltipMenu.vue +0 -75
- package/dist/runtime/editor/components/TooltipMenu.vue.d.ts +0 -9
- package/dist/runtime/editor/extensions/callout/CalloutView.vue +0 -85
- package/dist/runtime/editor/extensions/callout/CalloutView.vue.d.ts +0 -7
- package/dist/runtime/editor/extensions/callout/extension.d.ts +0 -13
- package/dist/runtime/editor/extensions/callout/extension.js +0 -48
- package/dist/runtime/editor/extensions/callout/index.d.ts +0 -2
- package/dist/runtime/editor/extensions/callout/index.js +0 -2
- package/dist/runtime/editor/extensions/callout/types.d.ts +0 -3
- package/dist/runtime/editor/extensions/index.d.ts +0 -26
- package/dist/runtime/editor/extensions/index.js +0 -85
- package/dist/runtime/editor/extensions/uplora-image/UploraImageView.vue +0 -29
- package/dist/runtime/editor/extensions/uplora-image/UploraImageView.vue.d.ts +0 -7
- package/dist/runtime/editor/extensions/uplora-image/extension.d.ts +0 -13
- package/dist/runtime/editor/extensions/uplora-image/extension.js +0 -60
- package/dist/runtime/editor/extensions/uplora-image/index.d.ts +0 -2
- package/dist/runtime/editor/extensions/uplora-image/index.js +0 -2
- package/dist/runtime/editor/extensions/uplora-image/types.d.ts +0 -5
- package/dist/runtime/editor/extensions/uplora-image/types.js +0 -0
- package/dist/runtime/editor/markdown/index.d.ts +0 -3
- package/dist/runtime/editor/markdown/index.js +0 -47
- package/dist/runtime/editor/markdown/nodes/callout.d.ts +0 -2
- package/dist/runtime/editor/markdown/nodes/callout.js +0 -21
- package/dist/runtime/editor/markdown/nodes/uploraImage.d.ts +0 -2
- package/dist/runtime/editor/markdown/nodes/uploraImage.js +0 -31
- package/dist/runtime/utils/dictionaries.d.ts +0 -4
- package/dist/runtime/utils/dictionaries.js +0 -6
- /package/.nuxt/cms/{autocomplete-select.ts → button-delete-confirm.ts} +0 -0
- /package/dist/runtime/{editor/extensions/callout/types.js → types/date.js} +0 -0
- /package/dist/runtime/utils/{image.d.ts → uplora.d.ts} +0 -0
- /package/dist/runtime/utils/{image.js → uplora.js} +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AppConfig } from '@nuxt/schema';
|
|
2
|
+
import type { ImgHTMLAttributes } from 'vue';
|
|
3
|
+
import type { ComponentConfig, ImageFormat, ImageSize } from '../types';
|
|
4
|
+
import theme from '#build/cms/uplora-image';
|
|
5
|
+
export type UploraImage = ComponentConfig<typeof theme, AppConfig, 'uploraImage'>;
|
|
6
|
+
export interface UploraImageProps {
|
|
7
|
+
image: string;
|
|
8
|
+
alt: string;
|
|
9
|
+
formats?: ImageFormat[];
|
|
10
|
+
sizes?: ImageSize[];
|
|
11
|
+
lqip?: string;
|
|
12
|
+
loading?: 'lazy' | 'eager';
|
|
13
|
+
preload?: boolean | {
|
|
14
|
+
fetchPriority: 'auto' | 'high' | 'low';
|
|
15
|
+
};
|
|
16
|
+
nonce?: string;
|
|
17
|
+
imgAttrs?: ImgHTMLAttributes;
|
|
18
|
+
class?: any;
|
|
19
|
+
ui?: UploraImage['slots'];
|
|
20
|
+
}
|
|
21
|
+
export interface UploraImageEmits {
|
|
22
|
+
load: [Event];
|
|
23
|
+
error: [string | Event];
|
|
24
|
+
}
|
|
25
|
+
declare const _default: typeof __VLS_export;
|
|
26
|
+
export default _default;
|
|
27
|
+
declare const __VLS_export: import("vue").DefineComponent<UploraImageProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
28
|
+
error: (args_0: string | Event) => any;
|
|
29
|
+
load: (args_0: Event) => any;
|
|
30
|
+
}, string, import("vue").PublicProps, Readonly<UploraImageProps> & Readonly<{
|
|
31
|
+
onError?: ((args_0: string | Event) => any) | undefined;
|
|
32
|
+
onLoad?: ((args_0: Event) => any) | undefined;
|
|
33
|
+
}>, {
|
|
34
|
+
loading: "lazy" | "eager";
|
|
35
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -22,7 +22,9 @@ export interface UploraImageEmits {
|
|
|
22
22
|
load: [Event];
|
|
23
23
|
error: [string | Event];
|
|
24
24
|
}
|
|
25
|
-
declare const _default:
|
|
25
|
+
declare const _default: typeof __VLS_export;
|
|
26
|
+
export default _default;
|
|
27
|
+
declare const __VLS_export: import("vue").DefineComponent<UploraImageProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
26
28
|
error: (args_0: string | Event) => any;
|
|
27
29
|
load: (args_0: Event) => any;
|
|
28
30
|
}, string, import("vue").PublicProps, Readonly<UploraImageProps> & Readonly<{
|
|
@@ -31,4 +33,3 @@ declare const _default: import("vue").DefineComponent<UploraImageProps, {}, {},
|
|
|
31
33
|
}>, {
|
|
32
34
|
loading: "lazy" | "eager";
|
|
33
35
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
34
|
-
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AppConfig } from '@nuxt/schema';
|
|
2
|
+
import type { ComponentConfig } from '../../types';
|
|
3
|
+
import theme from '#build/cms/prose/uplora-image';
|
|
4
|
+
export type ProseUploraImage = ComponentConfig<typeof theme, AppConfig, 'uploraImage', 'cms.prose'>;
|
|
5
|
+
export interface ProseUploraImageProps {
|
|
6
|
+
image: string;
|
|
7
|
+
alt: string;
|
|
8
|
+
lqip?: string;
|
|
9
|
+
class?: any;
|
|
10
|
+
ui?: ProseUploraImage['slots'];
|
|
11
|
+
}
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
14
|
+
declare const __VLS_export: import("vue").DefineComponent<ProseUploraImageProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ProseUploraImageProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -9,5 +9,6 @@ export interface ProseUploraImageProps {
|
|
|
9
9
|
class?: any;
|
|
10
10
|
ui?: ProseUploraImage['slots'];
|
|
11
11
|
}
|
|
12
|
-
declare const _default:
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
13
|
export default _default;
|
|
14
|
+
declare const __VLS_export: import("vue").DefineComponent<ProseUploraImageProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ProseUploraImageProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSharedComposable,
|
|
1
|
+
import { createSharedComposable, useRoute } from "#imports";
|
|
2
|
+
import { ref, watch } from "vue";
|
|
2
3
|
export const useAdmin = createSharedComposable(() => {
|
|
3
4
|
const route = useRoute();
|
|
4
5
|
const isSidebarOpen = ref(false);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { AvailableRouterMethod, NitroFetchRequest } from 'nitropack';
|
|
2
2
|
import type { AsyncData, FetchResult, UseFetchOptions } from 'nuxt/app';
|
|
3
|
-
import type { DefaultAsyncDataValue } from 'nuxt/app/defaults';
|
|
4
3
|
import type { FetchError } from 'ofetch';
|
|
5
4
|
import type { Ref } from 'vue';
|
|
6
5
|
type PickFrom<T, K extends Array<string>> = T extends Array<any> ? T : T extends Record<string, any> ? keyof T extends K[number] ? T : K[number] extends never ? T : Pick<T, K[number]> : T;
|
|
7
6
|
type KeysOf<T> = Array<T extends T ? (keyof T extends string ? keyof T : never) : never>;
|
|
7
|
+
type DefaultAsyncDataValue = undefined;
|
|
8
8
|
/**
|
|
9
9
|
* На данный момент нет возможности использовать `useFetch` со своим $fetch,
|
|
10
10
|
* поэтому приходится использовать костыль.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AsyncDataRequestStatus } from '#app';
|
|
2
|
-
import type { Ref } from '
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
3
|
type AsyncHandler<D> = (...args: any[]) => Promise<D> | D;
|
|
4
4
|
export interface UseAsyncHandlerResult<D, E> {
|
|
5
5
|
status: Ref<AsyncDataRequestStatus>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DropdownMenuItem, EditorCustomHandlers } from '@nuxt/ui';
|
|
2
|
+
import type { Editor, JSONContent } from '@tiptap/vue-3';
|
|
3
|
+
export declare function useEditorDragHandle<T extends EditorCustomHandlers>(customHandlers?: T): {
|
|
4
|
+
selectedNode: import("vue").Ref<{
|
|
5
|
+
node: JSONContent | null;
|
|
6
|
+
pos: number;
|
|
7
|
+
} | undefined, {
|
|
8
|
+
node: JSONContent | null;
|
|
9
|
+
pos: number;
|
|
10
|
+
} | undefined>;
|
|
11
|
+
getItems: (editor: Editor) => DropdownMenuItem[][];
|
|
12
|
+
onNodeChange: (event: {
|
|
13
|
+
node: JSONContent | null;
|
|
14
|
+
pos: number;
|
|
15
|
+
}) => void;
|
|
16
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { useAppConfig } from "#imports";
|
|
2
|
+
import { mapEditorItems } from "@nuxt/ui/utils/editor";
|
|
3
|
+
import { upperFirst } from "scule";
|
|
4
|
+
import { ref } from "vue";
|
|
5
|
+
export function useEditorDragHandle(customHandlers) {
|
|
6
|
+
const appConfig = useAppConfig();
|
|
7
|
+
const selectedNode = ref();
|
|
8
|
+
const getItems = (editor) => {
|
|
9
|
+
if (!selectedNode.value?.node?.type) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
return mapEditorItems(editor, [
|
|
13
|
+
[
|
|
14
|
+
{
|
|
15
|
+
type: "label",
|
|
16
|
+
label: upperFirst(selectedNode.value.node.type)
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
label: "\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C",
|
|
20
|
+
icon: appConfig.ui.icons.repeat,
|
|
21
|
+
children: [
|
|
22
|
+
{ kind: "paragraph", label: "\u041F\u0430\u0440\u0430\u0433\u0440\u0430\u0444", icon: appConfig.ui.icons.paragraph },
|
|
23
|
+
{ kind: "heading", level: 1, label: "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 1", icon: appConfig.ui.icons.heading1 },
|
|
24
|
+
{ kind: "heading", level: 2, label: "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 2", icon: appConfig.ui.icons.heading2 },
|
|
25
|
+
{ kind: "heading", level: 3, label: "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 3", icon: appConfig.ui.icons.heading3 },
|
|
26
|
+
{ kind: "heading", level: 4, label: "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 4", icon: appConfig.ui.icons.heading4 },
|
|
27
|
+
{ kind: "bulletList", label: "\u041C\u0430\u0440\u043A\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0441\u043F\u0438\u0441\u043E\u043A", icon: appConfig.ui.icons.list },
|
|
28
|
+
{ kind: "orderedList", label: "\u041D\u0443\u043C\u0435\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0441\u043F\u0438\u0441\u043E\u043A", icon: appConfig.ui.icons.listOrdered },
|
|
29
|
+
{ kind: "blockquote", label: "\u0426\u0438\u0442\u0430\u0442\u0430", icon: appConfig.ui.icons.blockquote },
|
|
30
|
+
{ kind: "codeBlock", label: "\u0411\u043B\u043E\u043A \u043A\u043E\u0434\u0430", icon: appConfig.ui.icons.codeBlock }
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
kind: "clearFormatting",
|
|
35
|
+
pos: selectedNode.value?.pos,
|
|
36
|
+
label: "\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C \u0444\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435",
|
|
37
|
+
icon: appConfig.ui.icons.reload
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
[
|
|
41
|
+
{
|
|
42
|
+
kind: "duplicate",
|
|
43
|
+
pos: selectedNode.value?.pos,
|
|
44
|
+
label: "\u0414\u0443\u0431\u043B\u0438\u0440\u043E\u0432\u0430\u0442\u044C",
|
|
45
|
+
icon: appConfig.ui.icons.copy
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: "\u0421\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C",
|
|
49
|
+
icon: appConfig.ui.icons.clipboard,
|
|
50
|
+
onSelect: async () => {
|
|
51
|
+
if (!selectedNode.value) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const pos = selectedNode.value.pos;
|
|
55
|
+
const node = editor.state.doc.nodeAt(pos);
|
|
56
|
+
if (node) {
|
|
57
|
+
await navigator.clipboard.writeText(node.textContent);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
{
|
|
64
|
+
kind: "moveUp",
|
|
65
|
+
pos: selectedNode.value?.pos,
|
|
66
|
+
label: "\u041F\u0435\u0440\u0435\u043C\u0435\u0441\u0442\u0438\u0442\u044C \u0432\u0432\u0435\u0440\u0445",
|
|
67
|
+
icon: appConfig.ui.icons.arrowUp
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
kind: "moveDown",
|
|
71
|
+
pos: selectedNode.value?.pos,
|
|
72
|
+
label: "\u041F\u0435\u0440\u0435\u043C\u0435\u0441\u0442\u0438\u0442\u044C \u0432\u043D\u0438\u0437",
|
|
73
|
+
icon: appConfig.ui.icons.arrowDown
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
[
|
|
77
|
+
{
|
|
78
|
+
kind: "delete",
|
|
79
|
+
pos: selectedNode.value?.pos,
|
|
80
|
+
label: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C",
|
|
81
|
+
color: "error",
|
|
82
|
+
icon: appConfig.ui.icons.trash
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
], customHandlers);
|
|
86
|
+
};
|
|
87
|
+
const onNodeChange = (event) => {
|
|
88
|
+
selectedNode.value = event;
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
selectedNode,
|
|
92
|
+
getItems,
|
|
93
|
+
onNodeChange
|
|
94
|
+
};
|
|
95
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { EditorCustomHandlers } from '@nuxt/ui';
|
|
2
|
+
export declare function useEditorSuggestions<T extends EditorCustomHandlers>(_customHandlers?: T): {
|
|
3
|
+
items: (({
|
|
4
|
+
type: "label";
|
|
5
|
+
label: string;
|
|
6
|
+
kind?: undefined;
|
|
7
|
+
icon?: undefined;
|
|
8
|
+
level?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
kind: "paragraph";
|
|
11
|
+
label: string;
|
|
12
|
+
icon: any;
|
|
13
|
+
type?: undefined;
|
|
14
|
+
level?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
kind: "heading";
|
|
17
|
+
level: 1;
|
|
18
|
+
label: string;
|
|
19
|
+
icon: any;
|
|
20
|
+
type?: undefined;
|
|
21
|
+
} | {
|
|
22
|
+
kind: "heading";
|
|
23
|
+
level: 2;
|
|
24
|
+
label: string;
|
|
25
|
+
icon: any;
|
|
26
|
+
type?: undefined;
|
|
27
|
+
} | {
|
|
28
|
+
kind: "heading";
|
|
29
|
+
level: 3;
|
|
30
|
+
label: string;
|
|
31
|
+
icon: any;
|
|
32
|
+
type?: undefined;
|
|
33
|
+
} | {
|
|
34
|
+
kind: "bulletList";
|
|
35
|
+
label: string;
|
|
36
|
+
icon: any;
|
|
37
|
+
type?: undefined;
|
|
38
|
+
level?: undefined;
|
|
39
|
+
} | {
|
|
40
|
+
kind: "orderedList";
|
|
41
|
+
label: string;
|
|
42
|
+
icon: any;
|
|
43
|
+
type?: undefined;
|
|
44
|
+
level?: undefined;
|
|
45
|
+
} | {
|
|
46
|
+
kind: "blockquote";
|
|
47
|
+
label: string;
|
|
48
|
+
icon: any;
|
|
49
|
+
type?: undefined;
|
|
50
|
+
level?: undefined;
|
|
51
|
+
} | {
|
|
52
|
+
kind: "codeBlock";
|
|
53
|
+
label: string;
|
|
54
|
+
icon: any;
|
|
55
|
+
type?: undefined;
|
|
56
|
+
level?: undefined;
|
|
57
|
+
})[] | ({
|
|
58
|
+
type: "label";
|
|
59
|
+
label: string;
|
|
60
|
+
kind?: undefined;
|
|
61
|
+
icon?: undefined;
|
|
62
|
+
} | {
|
|
63
|
+
kind: "horizontalRule";
|
|
64
|
+
label: string;
|
|
65
|
+
icon: any;
|
|
66
|
+
type?: undefined;
|
|
67
|
+
})[])[];
|
|
68
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useAppConfig } from "#imports";
|
|
2
|
+
export function useEditorSuggestions(_customHandlers) {
|
|
3
|
+
const appConfig = useAppConfig();
|
|
4
|
+
const items = [
|
|
5
|
+
[
|
|
6
|
+
{ type: "label", label: "\u0422\u0438\u043F" },
|
|
7
|
+
{ kind: "paragraph", label: "\u041F\u0430\u0440\u0430\u0433\u0440\u0430\u0444", icon: appConfig.ui.icons.paragraph },
|
|
8
|
+
{ kind: "heading", level: 1, label: "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 1", icon: appConfig.ui.icons.heading1 },
|
|
9
|
+
{ kind: "heading", level: 2, label: "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 2", icon: appConfig.ui.icons.heading2 },
|
|
10
|
+
{ kind: "heading", level: 3, label: "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 3", icon: appConfig.ui.icons.heading3 },
|
|
11
|
+
{ kind: "bulletList", label: "\u041C\u0430\u0440\u043A\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0441\u043F\u0438\u0441\u043E\u043A", icon: appConfig.ui.icons.list },
|
|
12
|
+
{ kind: "orderedList", label: "\u041D\u0443\u043C\u0435\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0441\u043F\u0438\u0441\u043E\u043A", icon: appConfig.ui.icons.listOrdered },
|
|
13
|
+
{ kind: "blockquote", label: "\u0426\u0438\u0442\u0430\u0442\u0430", icon: appConfig.ui.icons.blockquote },
|
|
14
|
+
{ kind: "codeBlock", label: "\u0411\u043B\u043E\u043A \u043A\u043E\u0434\u0430", icon: appConfig.ui.icons.codeBlock }
|
|
15
|
+
],
|
|
16
|
+
[
|
|
17
|
+
{ type: "label", label: "\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C" },
|
|
18
|
+
{ kind: "horizontalRule", label: "\u0413\u043E\u0440\u0438\u0437\u043E\u043D\u0442\u0430\u043B\u044C\u043D\u0430\u044F \u043B\u0438\u043D\u0438\u044F", icon: appConfig.ui.icons.horizontalRule }
|
|
19
|
+
]
|
|
20
|
+
];
|
|
21
|
+
return {
|
|
22
|
+
items
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { EditorCustomHandlers, EditorToolbarItem } from '@nuxt/ui';
|
|
2
|
+
import type { Editor } from '@tiptap/vue-3';
|
|
3
|
+
export declare function useEditorToolbar<T extends EditorCustomHandlers>(_customHandlers?: T): {
|
|
4
|
+
toolbarItems: EditorToolbarItem<T>[][];
|
|
5
|
+
bubbleToolbarItems: import("vue").ComputedRef<({
|
|
6
|
+
label: string;
|
|
7
|
+
trailingIcon: any;
|
|
8
|
+
activeColor: "neutral";
|
|
9
|
+
activeVariant: "ghost";
|
|
10
|
+
tooltip: {
|
|
11
|
+
text: string;
|
|
12
|
+
};
|
|
13
|
+
content: {
|
|
14
|
+
align: "start";
|
|
15
|
+
};
|
|
16
|
+
ui: {
|
|
17
|
+
label: string;
|
|
18
|
+
};
|
|
19
|
+
items: ({
|
|
20
|
+
type: "label";
|
|
21
|
+
label: string;
|
|
22
|
+
kind?: undefined;
|
|
23
|
+
icon?: undefined;
|
|
24
|
+
level?: undefined;
|
|
25
|
+
} | {
|
|
26
|
+
kind: "paragraph";
|
|
27
|
+
label: string;
|
|
28
|
+
icon: any;
|
|
29
|
+
type?: undefined;
|
|
30
|
+
level?: undefined;
|
|
31
|
+
} | {
|
|
32
|
+
kind: "heading";
|
|
33
|
+
level: 1;
|
|
34
|
+
icon: any;
|
|
35
|
+
label: string;
|
|
36
|
+
type?: undefined;
|
|
37
|
+
} | {
|
|
38
|
+
kind: "heading";
|
|
39
|
+
level: 2;
|
|
40
|
+
icon: any;
|
|
41
|
+
label: string;
|
|
42
|
+
type?: undefined;
|
|
43
|
+
} | {
|
|
44
|
+
kind: "heading";
|
|
45
|
+
level: 3;
|
|
46
|
+
icon: any;
|
|
47
|
+
label: string;
|
|
48
|
+
type?: undefined;
|
|
49
|
+
} | {
|
|
50
|
+
kind: "heading";
|
|
51
|
+
level: 4;
|
|
52
|
+
icon: any;
|
|
53
|
+
label: string;
|
|
54
|
+
type?: undefined;
|
|
55
|
+
} | {
|
|
56
|
+
kind: "bulletList";
|
|
57
|
+
icon: any;
|
|
58
|
+
label: string;
|
|
59
|
+
type?: undefined;
|
|
60
|
+
level?: undefined;
|
|
61
|
+
} | {
|
|
62
|
+
kind: "orderedList";
|
|
63
|
+
icon: any;
|
|
64
|
+
label: string;
|
|
65
|
+
type?: undefined;
|
|
66
|
+
level?: undefined;
|
|
67
|
+
} | {
|
|
68
|
+
kind: "blockquote";
|
|
69
|
+
icon: any;
|
|
70
|
+
label: string;
|
|
71
|
+
type?: undefined;
|
|
72
|
+
level?: undefined;
|
|
73
|
+
} | {
|
|
74
|
+
kind: "codeBlock";
|
|
75
|
+
icon: any;
|
|
76
|
+
label: string;
|
|
77
|
+
type?: undefined;
|
|
78
|
+
level?: undefined;
|
|
79
|
+
})[];
|
|
80
|
+
}[] | ({
|
|
81
|
+
kind: "mark";
|
|
82
|
+
mark: "bold";
|
|
83
|
+
icon: any;
|
|
84
|
+
tooltip: {
|
|
85
|
+
text: string;
|
|
86
|
+
};
|
|
87
|
+
} | {
|
|
88
|
+
kind: "mark";
|
|
89
|
+
mark: "italic";
|
|
90
|
+
icon: any;
|
|
91
|
+
tooltip: {
|
|
92
|
+
text: string;
|
|
93
|
+
};
|
|
94
|
+
} | {
|
|
95
|
+
kind: "mark";
|
|
96
|
+
mark: "underline";
|
|
97
|
+
icon: any;
|
|
98
|
+
tooltip: {
|
|
99
|
+
text: string;
|
|
100
|
+
};
|
|
101
|
+
} | {
|
|
102
|
+
kind: "mark";
|
|
103
|
+
mark: "strike";
|
|
104
|
+
icon: any;
|
|
105
|
+
tooltip: {
|
|
106
|
+
text: string;
|
|
107
|
+
};
|
|
108
|
+
} | {
|
|
109
|
+
kind: "mark";
|
|
110
|
+
mark: "code";
|
|
111
|
+
icon: any;
|
|
112
|
+
tooltip: {
|
|
113
|
+
text: string;
|
|
114
|
+
};
|
|
115
|
+
})[] | {
|
|
116
|
+
slot: "link";
|
|
117
|
+
icon: any;
|
|
118
|
+
}[])[]>;
|
|
119
|
+
getImageToolbarItems: (editor: Editor) => EditorToolbarItem<T>[][];
|
|
120
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { useAppConfig } from "#imports";
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
export function useEditorToolbar(_customHandlers) {
|
|
4
|
+
const appConfig = useAppConfig();
|
|
5
|
+
const toolbarItems = [];
|
|
6
|
+
const bubbleToolbarItems = computed(() => [
|
|
7
|
+
[
|
|
8
|
+
{
|
|
9
|
+
label: "\u041F\u0440\u0435\u043E\u0431\u0440\u0430\u0437\u043E\u0432\u0430\u0442\u044C",
|
|
10
|
+
trailingIcon: appConfig.ui.icons.chevronDown,
|
|
11
|
+
activeColor: "neutral",
|
|
12
|
+
activeVariant: "ghost",
|
|
13
|
+
tooltip: { text: "\u041F\u0440\u0435\u043E\u0431\u0440\u0430\u0437\u043E\u0432\u0430\u0442\u044C" },
|
|
14
|
+
content: { align: "start" },
|
|
15
|
+
ui: { label: "text-xs" },
|
|
16
|
+
items: [
|
|
17
|
+
{ type: "label", label: "\u041F\u0440\u0435\u043E\u0431\u0440\u0430\u0437\u043E\u0432\u0430\u0442\u044C" },
|
|
18
|
+
{ kind: "paragraph", label: "\u041F\u0430\u0440\u0430\u0433\u0440\u0430\u0444", icon: appConfig.ui.icons.paragraph },
|
|
19
|
+
{ kind: "heading", level: 1, icon: appConfig.ui.icons.heading1, label: "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 1" },
|
|
20
|
+
{ kind: "heading", level: 2, icon: appConfig.ui.icons.heading2, label: "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 2" },
|
|
21
|
+
{ kind: "heading", level: 3, icon: appConfig.ui.icons.heading3, label: "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 3" },
|
|
22
|
+
{ kind: "heading", level: 4, icon: appConfig.ui.icons.heading4, label: "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 4" },
|
|
23
|
+
{ kind: "bulletList", icon: appConfig.ui.icons.list, label: "\u041C\u0430\u0440\u043A\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0441\u043F\u0438\u0441\u043E\u043A" },
|
|
24
|
+
{ kind: "orderedList", icon: appConfig.ui.icons.listOrdered, label: "\u041D\u0443\u043C\u0435\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0441\u043F\u0438\u0441\u043E\u043A" },
|
|
25
|
+
{ kind: "blockquote", icon: appConfig.ui.icons.blockquote, label: "\u0426\u0438\u0442\u0430\u0442\u0430" },
|
|
26
|
+
{ kind: "codeBlock", icon: appConfig.ui.icons.codeBlock, label: "\u0411\u043B\u043E\u043A \u043A\u043E\u0434\u0430" }
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
[
|
|
31
|
+
{ kind: "mark", mark: "bold", icon: appConfig.ui.icons.bold, tooltip: { text: "\u0416\u0438\u0440\u043D\u044B\u0439" } },
|
|
32
|
+
{ kind: "mark", mark: "italic", icon: appConfig.ui.icons.italic, tooltip: { text: "\u041A\u0443\u0440\u0441\u0438\u0432" } },
|
|
33
|
+
{ kind: "mark", mark: "underline", icon: appConfig.ui.icons.underline, tooltip: { text: "\u041F\u043E\u0434\u0447\u0435\u0440\u043A\u043D\u0443\u0442\u044B\u0439" } },
|
|
34
|
+
{ kind: "mark", mark: "strike", icon: appConfig.ui.icons.strikethrough, tooltip: { text: "\u0417\u0430\u0447\u0435\u0440\u043A\u043D\u0443\u0442\u044B\u0439" } },
|
|
35
|
+
{ kind: "mark", mark: "code", icon: appConfig.ui.icons.code, tooltip: { text: "\u041A\u043E\u0434" } }
|
|
36
|
+
],
|
|
37
|
+
[
|
|
38
|
+
{ slot: "link", icon: appConfig.ui.icons.link }
|
|
39
|
+
]
|
|
40
|
+
]);
|
|
41
|
+
const getImageToolbarItems = (editor) => {
|
|
42
|
+
const node = editor.state.doc.nodeAt(editor.state.selection.from);
|
|
43
|
+
return [
|
|
44
|
+
[
|
|
45
|
+
{
|
|
46
|
+
icon: appConfig.ui.icons.download,
|
|
47
|
+
to: node?.attrs?.src,
|
|
48
|
+
download: true,
|
|
49
|
+
tooltip: { text: "\u0421\u043A\u0430\u0447\u0430\u0442\u044C" }
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
icon: appConfig.ui.icons.reload,
|
|
53
|
+
tooltip: { text: "\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C" },
|
|
54
|
+
onClick: () => {
|
|
55
|
+
const { state } = editor;
|
|
56
|
+
const { selection } = state;
|
|
57
|
+
const pos = selection.from;
|
|
58
|
+
const node2 = state.doc.nodeAt(pos);
|
|
59
|
+
if (node2 && node2.type.name === "image") {
|
|
60
|
+
editor.chain().focus().deleteRange({ from: pos, to: pos + node2.nodeSize }).insertContentAt(pos, { type: "imageUpload" }).run();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
{
|
|
67
|
+
icon: appConfig.ui.icons.trash,
|
|
68
|
+
tooltip: { text: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C" },
|
|
69
|
+
onClick: () => {
|
|
70
|
+
const { state } = editor;
|
|
71
|
+
const { selection } = state;
|
|
72
|
+
const pos = selection.from;
|
|
73
|
+
const node2 = state.doc.nodeAt(pos);
|
|
74
|
+
if (node2 && node2.type.name === "image") {
|
|
75
|
+
editor.chain().focus().deleteRange({ from: pos, to: pos + node2.nodeSize }).run();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
];
|
|
81
|
+
};
|
|
82
|
+
return {
|
|
83
|
+
toolbarItems,
|
|
84
|
+
bubbleToolbarItems,
|
|
85
|
+
getImageToolbarItems
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FormData, FormSchema, FormSubmitEvent, InferInput } from '@nuxt/ui';
|
|
2
|
+
import type { MaybeRefOrGetter } from 'vue';
|
|
3
|
+
export declare function useFormState<S extends FormSchema>(schema: MaybeRefOrGetter<S>, source?: MaybeRefOrGetter<Partial<InferInput<S>>>, options?: {
|
|
4
|
+
success?: string;
|
|
5
|
+
}): {
|
|
6
|
+
schema: import("vue").ComputedRef<S>;
|
|
7
|
+
state: import("vue").Ref<Partial<InferInput<S>>, Partial<InferInput<S>>>;
|
|
8
|
+
isModified: import("vue").Ref<boolean, boolean>;
|
|
9
|
+
isLoading: import("vue").Ref<boolean, boolean>;
|
|
10
|
+
reset: () => void;
|
|
11
|
+
onSubmit: (fn: Parameters<import("@vueuse/shared").EventHookOn<FormSubmitEvent<import("@nuxt/ui").InferOutput<S>>>>[0]) => (event: FormSubmitEvent<FormData<S>>) => Promise<void>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createEventHook, useCloned } from "@vueuse/core";
|
|
2
|
+
import clone from "fast-copy";
|
|
3
|
+
import { computed, ref, toValue } from "vue";
|
|
4
|
+
import { useNotification } from "./useNotification.js";
|
|
5
|
+
export function useFormState(schema, source = {}, options) {
|
|
6
|
+
const notification = useNotification();
|
|
7
|
+
const submitHook = createEventHook();
|
|
8
|
+
const { cloned: state, isModified, sync: reset } = useCloned(source, { clone });
|
|
9
|
+
const isLoading = ref(false);
|
|
10
|
+
const onSubmit = async (event) => {
|
|
11
|
+
isLoading.value = true;
|
|
12
|
+
try {
|
|
13
|
+
await submitHook.trigger(event);
|
|
14
|
+
} catch {
|
|
15
|
+
return;
|
|
16
|
+
} finally {
|
|
17
|
+
isLoading.value = false;
|
|
18
|
+
}
|
|
19
|
+
options?.success && notification.success(options.success);
|
|
20
|
+
};
|
|
21
|
+
const onSubmitWrapper = (fn) => {
|
|
22
|
+
submitHook.on(fn);
|
|
23
|
+
return onSubmit;
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
schema: computed(() => toValue(schema)),
|
|
27
|
+
state,
|
|
28
|
+
isModified,
|
|
29
|
+
isLoading,
|
|
30
|
+
reset,
|
|
31
|
+
onSubmit: onSubmitWrapper
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createEventHook, createSharedComposable, useUserSession } from "#imports";
|
|
2
|
+
import { clearNuxtData } from "nuxt/app";
|
|
3
|
+
import { ref } from "vue";
|
|
2
4
|
export const useLogout = createSharedComposable(() => {
|
|
3
5
|
const isLoading = ref(false);
|
|
4
6
|
const { clear } = useUserSession();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StringOrVNode, ToastProps } from '@nuxt/ui';
|
|
2
|
+
type NotificationOptions = Omit<ToastProps, 'title' | 'icon' | 'color' | 'defaultOpen'> & {
|
|
3
|
+
onClick?: (toast: Omit<ToastProps, 'defaultOpen'>) => void;
|
|
4
|
+
};
|
|
5
|
+
export declare function useNotification(): {
|
|
6
|
+
success: (message: string, options?: NotificationOptions) => import("@nuxt/ui/runtime/composables/useToast.js").Toast;
|
|
7
|
+
error: (message: string, options?: NotificationOptions) => import("@nuxt/ui/runtime/composables/useToast.js").Toast;
|
|
8
|
+
warning: (message: StringOrVNode, options?: NotificationOptions) => import("@nuxt/ui/runtime/composables/useToast.js").Toast;
|
|
9
|
+
notify: (toast: Partial<import("@nuxt/ui/runtime/composables/useToast.js").Toast>) => import("@nuxt/ui/runtime/composables/useToast.js").Toast;
|
|
10
|
+
info: (message: StringOrVNode, options?: NotificationOptions) => import("@nuxt/ui/runtime/composables/useToast.js").Toast;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useAppConfig, useToast } from "#imports";
|
|
2
|
+
export function useNotification() {
|
|
3
|
+
const { add: notify } = useToast();
|
|
4
|
+
const appConfig = useAppConfig();
|
|
5
|
+
const success = (message, options) => {
|
|
6
|
+
return notify({
|
|
7
|
+
title: message,
|
|
8
|
+
icon: appConfig.ui.icons.success,
|
|
9
|
+
color: "success",
|
|
10
|
+
...options
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
const error = (message, options) => {
|
|
14
|
+
return notify({
|
|
15
|
+
title: "\u041E\u0448\u0438\u0431\u043A\u0430",
|
|
16
|
+
description: message,
|
|
17
|
+
color: "error",
|
|
18
|
+
icon: appConfig.ui.icons.error,
|
|
19
|
+
...options
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const warning = (message, options) => {
|
|
23
|
+
return notify({
|
|
24
|
+
title: "\u0412\u043D\u0438\u043C\u0430\u043D\u0438\u0435",
|
|
25
|
+
description: message,
|
|
26
|
+
color: "warning",
|
|
27
|
+
icon: appConfig.ui.icons.warning,
|
|
28
|
+
...options
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
const info = (message, options) => {
|
|
32
|
+
return notify({
|
|
33
|
+
title: message,
|
|
34
|
+
color: "info",
|
|
35
|
+
icon: appConfig.ui.icons.info,
|
|
36
|
+
...options
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
success,
|
|
41
|
+
error,
|
|
42
|
+
warning,
|
|
43
|
+
notify,
|
|
44
|
+
info
|
|
45
|
+
};
|
|
46
|
+
}
|