@vitnode/core 1.2.0-canary.59 → 1.2.0-canary.61
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/scripts/get-config.js +15 -0
- package/dist/scripts/plugin.js +188 -0
- package/dist/scripts/prepare-database.js +177 -0
- package/dist/scripts/prepare-plugins-files.js +134 -0
- package/dist/scripts/run-interactive-shell-command.js +21 -0
- package/dist/scripts/scripts.js +39 -13
- package/dist/scripts/shared/file-utils.js +203 -0
- package/dist/src/api/adapters/sso/discord.js +1 -77
- package/dist/src/api/adapters/sso/facebook.js +1 -76
- package/dist/src/api/adapters/sso/google.js +1 -87
- package/dist/src/api/config.js +1 -67
- package/dist/src/api/lib/check-plugin-id.js +1 -43
- package/dist/src/api/lib/cron.js +1 -22
- package/dist/src/api/lib/logger-middleware.js +1 -35
- package/dist/src/api/lib/module.js +1 -22
- package/dist/src/api/lib/plugin.js +1 -22
- package/dist/src/api/lib/route.js +1 -27
- package/dist/src/api/lib/with-pagination.js +1 -83
- package/dist/src/api/middlewares/captcha.middleware.js +1 -63
- package/dist/src/api/middlewares/cron-auth.middleware.js +1 -19
- package/dist/src/api/middlewares/global.middleware.d.ts.map +1 -1
- package/dist/src/api/middlewares/global.middleware.js +1 -104
- package/dist/src/api/middlewares/rate-limiter.middleware.js +1 -32
- package/dist/src/api/models/device.js +1 -61
- package/dist/src/api/models/email.d.ts.map +1 -1
- package/dist/src/api/models/email.js +1 -77
- package/dist/src/api/models/password.js +1 -36
- package/dist/src/api/models/session-admin.d.ts.map +1 -1
- package/dist/src/api/models/session-admin.js +1 -97
- package/dist/src/api/models/session.d.ts.map +1 -1
- package/dist/src/api/models/session.js +1 -76
- package/dist/src/api/models/sso.js +1 -120
- package/dist/src/api/models/user/get-user-by-id.js +1 -19
- package/dist/src/api/models/user/sign-in-with-passwords.js +1 -22
- package/dist/src/api/models/user/sign-up.js +1 -73
- package/dist/src/api/models/user.js +1 -8
- package/dist/src/api/modules/admin/admin.module.js +1 -19
- package/dist/src/api/modules/admin/advanced/advanced.admin.module.js +1 -11
- package/dist/src/api/modules/admin/advanced/cron/cron.admin.module.js +1 -12
- package/dist/src/api/modules/admin/advanced/cron/routes/get.route.js +1 -66
- package/dist/src/api/modules/admin/advanced/cron/routes/run.route.js +1 -95
- package/dist/src/api/modules/admin/debug/debug.admin.module.js +1 -10
- package/dist/src/api/modules/admin/debug/routes/logs.route.js +1 -94
- package/dist/src/api/modules/admin/routes/session.route.js +1 -47
- package/dist/src/api/modules/admin/users/routes/list.route.js +1 -79
- package/dist/src/api/modules/admin/users/routes/users.route.js +1 -84
- package/dist/src/api/modules/admin/users/users.admin.module.js +1 -10
- package/dist/src/api/modules/cron/cron/clean.cron.js +1 -24
- package/dist/src/api/modules/cron/cron.module.js +1 -14
- package/dist/src/api/modules/cron/helpers/process-cron-jobs.d.ts.map +1 -1
- package/dist/src/api/modules/cron/helpers/process-cron-jobs.js +1 -72
- package/dist/src/api/modules/cron/routes/cron.route.d.ts.map +1 -1
- package/dist/src/api/modules/cron/routes/cron.route.js +1 -95
- package/dist/src/api/modules/middleware/middleware.module.js +1 -10
- package/dist/src/api/modules/middleware/route.js +1 -49
- package/dist/src/api/modules/users/avatar-color.js +1 -43
- package/dist/src/api/modules/users/routes/change-password.route.js +1 -58
- package/dist/src/api/modules/users/routes/reset-passowrd.route.js +1 -91
- package/dist/src/api/modules/users/routes/session.route.js +1 -46
- package/dist/src/api/modules/users/routes/sign-in.route.js +1 -71
- package/dist/src/api/modules/users/routes/sign-out.route.js +1 -43
- package/dist/src/api/modules/users/routes/sign-up.route.js +1 -77
- package/dist/src/api/modules/users/routes/test.route.js +1 -33
- package/dist/src/api/modules/users/sso/routes/callback.route.js +1 -52
- package/dist/src/api/modules/users/sso/routes/create-url.route.js +1 -36
- package/dist/src/api/modules/users/sso/sso.module.js +1 -12
- package/dist/src/api/modules/users/users.module.js +1 -26
- package/dist/src/api/plugin.js +1 -15
- package/dist/src/app/login/page.js +1 -16
- package/dist/src/app/login/reset-password/page.js +1 -18
- package/dist/src/app/login/sso/[providerId]/page.js +1 -10
- package/dist/src/app/register/page.js +1 -16
- package/dist/src/app_admin/core/advanced/cron/page.js +1 -42
- package/dist/src/app_admin/core/debug/page.js +1 -45
- package/dist/src/app_admin/core/page.js +1 -5
- package/dist/src/app_admin/core/test/page.js +1 -5
- package/dist/src/app_admin/core/users/page.js +1 -38
- package/dist/src/components/avatar.js +1 -14
- package/dist/src/components/confirm-action/confirm-action-alert-dialog.js +1 -42
- package/dist/src/components/confirm-action/content.js +1 -31
- package/dist/src/components/date-format.js +1 -41
- package/dist/src/components/form/auto-form.js +1 -103
- package/dist/src/components/form/common/desc.js +1 -9
- package/dist/src/components/form/common/label.js +1 -18
- package/dist/src/components/form/fields/checkbox.js +1 -37
- package/dist/src/components/form/fields/combobox-async.js +1 -123
- package/dist/src/components/form/fields/combobox.js +1 -87
- package/dist/src/components/form/fields/input.js +1 -39
- package/dist/src/components/form/fields/radio-group.js +1 -50
- package/dist/src/components/form/fields/select.js +1 -58
- package/dist/src/components/form/fields/switch.js +1 -36
- package/dist/src/components/form/fields/textarea.js +1 -36
- package/dist/src/components/i18n-provider.js +1 -43
- package/dist/src/components/logo-vitnode.js +1 -119
- package/dist/src/components/switchers/langs/language-switcher.js +1 -47
- package/dist/src/components/switchers/themes/theme-switcher.js +1 -28
- package/dist/src/components/table/content.js +1 -81
- package/dist/src/components/table/data-table.js +1 -68
- package/dist/src/components/table/order-table-head.js +1 -50
- package/dist/src/components/table/pagination.js +1 -122
- package/dist/src/components/tiptap/extension.js +1 -33
- package/dist/src/components/tiptap/toolbar/actions/alignment-action.js +1 -91
- package/dist/src/components/tiptap/toolbar/actions/bold-action.js +1 -39
- package/dist/src/components/tiptap/toolbar/actions/headings-action.js +1 -93
- package/dist/src/components/tiptap/toolbar/actions/italic-action.js +1 -38
- package/dist/src/components/tiptap/toolbar/actions/list-action.js +1 -61
- package/dist/src/components/tiptap/toolbar/actions/text-format-more/text-format-more.js +1 -59
- package/dist/src/components/tiptap/toolbar/actions/underline-action.js +1 -38
- package/dist/src/components/tiptap/toolbar/actions/undo-redo-actions.js +1 -63
- package/dist/src/components/tiptap/toolbar/actions/utils/tooltip-shortcut.js +1 -11
- package/dist/src/components/tiptap/toolbar/tiptap-toolbar.js +1 -55
- package/dist/src/components/tiptap/toolbar/use-toolbar-editor.js +1 -5
- package/dist/src/components/ui/accordion.js +1 -46
- package/dist/src/components/ui/alert-dialog.js +1 -123
- package/dist/src/components/ui/alert.js +1 -39
- package/dist/src/components/ui/badge.js +1 -28
- package/dist/src/components/ui/button-client.js +1 -57
- package/dist/src/components/ui/button.js +1 -32
- package/dist/src/components/ui/card.js +1 -52
- package/dist/src/components/ui/checkbox.js +1 -20
- package/dist/src/components/ui/collapsible.js +1 -22
- package/dist/src/components/ui/command.js +1 -98
- package/dist/src/components/ui/context-menu.js +1 -140
- package/dist/src/components/ui/dialog.js +1 -189
- package/dist/src/components/ui/drawer.js +1 -83
- package/dist/src/components/ui/dropdown-menu.js +1 -141
- package/dist/src/components/ui/editor-content.js +1 -10
- package/dist/src/components/ui/editor.js +1 -35
- package/dist/src/components/ui/form.js +1 -148
- package/dist/src/components/ui/header-content.js +1 -30
- package/dist/src/components/ui/hover-card.js +1 -29
- package/dist/src/components/ui/input-otp.js +1 -48
- package/dist/src/components/ui/input.js +1 -11
- package/dist/src/components/ui/label.js +1 -12
- package/dist/src/components/ui/loader.js +1 -16
- package/dist/src/components/ui/menubar.js +1 -151
- package/dist/src/components/ui/navigation-menu.js +1 -82
- package/dist/src/components/ui/popover.js +1 -35
- package/dist/src/components/ui/progress.js +1 -19
- package/dist/src/components/ui/radio-group.js +1 -27
- package/dist/src/components/ui/scroll-area.js +1 -33
- package/dist/src/components/ui/select.js +1 -113
- package/dist/src/components/ui/separator.js +1 -14
- package/dist/src/components/ui/sheet.js +1 -92
- package/dist/src/components/ui/sidebar.js +1 -433
- package/dist/src/components/ui/skeleton.js +1 -10
- package/dist/src/components/ui/slider.js +1 -50
- package/dist/src/components/ui/sonner.js +1 -26
- package/dist/src/components/ui/switch.js +1 -16
- package/dist/src/components/ui/table.js +1 -63
- package/dist/src/components/ui/tabs.js +1 -33
- package/dist/src/components/ui/textarea.js +1 -10
- package/dist/src/components/ui/toggle-group.js +1 -45
- package/dist/src/components/ui/toggle.js +1 -34
- package/dist/src/components/ui/tooltip.js +1 -57
- package/dist/src/config.js +1 -4
- package/dist/src/database/admins.js +1 -74
- package/dist/src/database/cron.js +1 -22
- package/dist/src/database/languages.js +1 -52
- package/dist/src/database/logs.js +1 -34
- package/dist/src/database/moderators.js +1 -37
- package/dist/src/database/roles.js +1 -13
- package/dist/src/database/sessions.js +1 -60
- package/dist/src/database/users.js +1 -145
- package/dist/src/drizzle.config.js +1 -67
- package/dist/src/emails/default-template.js +1 -99
- package/dist/src/emails/reset-password.js +1 -132
- package/dist/src/emails/ui/button.js +1 -36
- package/dist/src/emails/ui/card.js +1 -39
- package/dist/src/hooks/use-before-unload.js +1 -30
- package/dist/src/hooks/use-captcha.js +1 -122
- package/dist/src/hooks/use-mobile.js +1 -16
- package/dist/src/lib/api/get-middleware-api.js +1 -13
- package/dist/src/lib/api/get-next-cron-run-date.js +1 -14
- package/dist/src/lib/api/get-next-cron-run-date.test.js +1 -55
- package/dist/src/lib/api/get-session-admin-api.js +1 -19
- package/dist/src/lib/api/get-session-api.js +1 -14
- package/dist/src/lib/api/should-cron-job-run.js +1 -16
- package/dist/src/lib/api/should-cron-job-run.test.js +1 -213
- package/dist/src/lib/api/validate-cron-schedule.d.ts +2 -0
- package/dist/src/lib/api/validate-cron-schedule.d.ts.map +1 -0
- package/dist/src/lib/api/validate-cron-schedule.js +1 -0
- package/dist/src/lib/api/validate-cron-schedule.test.d.ts +2 -0
- package/dist/src/lib/api/validate-cron-schedule.test.d.ts.map +1 -0
- package/dist/src/lib/api/validate-cron-schedule.test.js +1 -0
- package/dist/src/lib/colors.js +1 -140
- package/dist/src/lib/colors.test.js +1 -173
- package/dist/src/lib/config.js +1 -14
- package/dist/src/lib/ctrl-or-command-character.js +1 -5
- package/dist/src/lib/fetcher/cookie-from-string-to-object.js +1 -12
- package/dist/src/lib/fetcher/cookie-from-string-to-object.test.js +1 -78
- package/dist/src/lib/fetcher/core.js +3 -48
- package/dist/src/lib/fetcher/helpers-server.js +1 -18
- package/dist/src/lib/fetcher/helpers.js +1 -16
- package/dist/src/lib/fetcher/helpers.test.js +1 -37
- package/dist/src/lib/fetcher/types.js +1 -1
- package/dist/src/lib/fetcher-client.js +1 -17
- package/dist/src/lib/fetcher.js +1 -33
- package/dist/src/lib/helpers/auto-form.js +1 -98
- package/dist/src/lib/helpers/auto-form.test.js +1 -336
- package/dist/src/lib/navigation.d.ts +15 -13
- package/dist/src/lib/navigation.d.ts.map +1 -1
- package/dist/src/lib/navigation.js +1 -11
- package/dist/src/lib/plugin.js +1 -3
- package/dist/src/lib/special-characters.js +1 -4
- package/dist/src/lib/special-characters.test.js +1 -56
- package/dist/src/lib/utils.js +1 -5
- package/dist/src/locales/en.json +308 -0
- package/dist/src/tests/setup.js +1 -6
- package/dist/src/views/admin/layouts/admin-layout.js +1 -73
- package/dist/src/views/admin/layouts/sidebar/nav/item.js +1 -98
- package/dist/src/views/admin/layouts/sidebar/nav/nav.js +1 -60
- package/dist/src/views/admin/layouts/sidebar/sidebar.js +1 -28
- package/dist/src/views/admin/layouts/sidebar/sign-out.js +1 -14
- package/dist/src/views/admin/layouts/user-bar/client.js +1 -69
- package/dist/src/views/admin/layouts/user-bar/user-bar.js +1 -32
- package/dist/src/views/admin/sign-in/sign-in-admin-view.js +1 -27
- package/dist/src/views/admin/views/core/advanced/cron/cron-table-view.js +1 -97
- package/dist/src/views/admin/views/core/advanced/cron/run-action/mutation-api.js +1 -23
- package/dist/src/views/admin/views/core/advanced/cron/run-action/run-action.js +1 -38
- package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.js +1 -44
- package/dist/src/views/admin/views/core/debug/actions/clear-cache/clear-cache.js +1 -35
- package/dist/src/views/admin/views/core/debug/actions/clear-cache/mutation-api.js +1 -5
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/content.js +1 -281
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/more.js +1 -67
- package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-status.js +1 -14
- package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-type-log.js +1 -30
- package/dist/src/views/admin/views/core/debug/system-logs/system-logs-view.js +1 -96
- package/dist/src/views/admin/views/core/test.js +1 -161
- package/dist/src/views/admin/views/core/users/users-admin-view.js +1 -89
- package/dist/src/views/auth/password-reset/change-password-form/form.js +1 -48
- package/dist/src/views/auth/password-reset/change-password-form/mutation-api.js +1 -22
- package/dist/src/views/auth/password-reset/change-password-form/use-form.js +1 -36
- package/dist/src/views/auth/password-reset/form/form.js +1 -104
- package/dist/src/views/auth/password-reset/form/mutation-api.js +1 -21
- package/dist/src/views/auth/password-reset/form/use-form.js +1 -33
- package/dist/src/views/auth/password-reset/password-reset-view.js +1 -37
- package/dist/src/views/auth/sign-in/form/form.js +1 -64
- package/dist/src/views/auth/sign-in/form/mutation-api.js +1 -33
- package/dist/src/views/auth/sign-in/form/use-form.d.ts.map +1 -1
- package/dist/src/views/auth/sign-in/form/use-form.js +1 -38
- package/dist/src/views/auth/sign-in/sign-in-view.js +1 -61
- package/dist/src/views/auth/sign-up/components/password-input.js +1 -96
- package/dist/src/views/auth/sign-up/email-confirmation-view.js +1 -55
- package/dist/src/views/auth/sign-up/form/form.js +1 -89
- package/dist/src/views/auth/sign-up/form/mutation-api.js +1 -30
- package/dist/src/views/auth/sign-up/form/use-form.js +1 -70
- package/dist/src/views/auth/sign-up/sign-up-view.js +1 -65
- package/dist/src/views/auth/sign-up/wrapper.js +1 -22
- package/dist/src/views/auth/sso/buttons/client.js +1 -22
- package/dist/src/views/auth/sso/buttons/mutation-api.js +1 -24
- package/dist/src/views/auth/sso/buttons/sso-buttons.js +1 -56
- package/dist/src/views/auth/sso/callback/callback-sso-view.js +1 -32
- package/dist/src/views/auth/sso/callback/client/client.js +1 -68
- package/dist/src/views/auth/sso/callback/client/mutation-api.js +1 -32
- package/dist/src/views/error/back-button.js +1 -14
- package/dist/src/views/error/error-view.js +1 -58
- package/dist/src/views/error/global-error-view.js +1 -50
- package/dist/src/views/layouts/provider.js +1 -44
- package/dist/src/views/layouts/root-layout.js +1 -25
- package/dist/src/views/layouts/theme/header/header.js +1 -38
- package/dist/src/views/layouts/theme/header/user/auth/auth.js +1 -33
- package/dist/src/views/layouts/theme/header/user/auth/client.js +1 -47
- package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.js +1 -27
- package/dist/src/views/layouts/theme/header/user/user.js +1 -32
- package/dist/src/views/layouts/theme/layout.js +1 -16
- package/dist/src/vitnode.config.d.ts.map +1 -1
- package/dist/src/vitnode.config.js +1 -42
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/tsup.config.js +18 -0
- package/dist/vitest.config.d.ts.map +1 -1
- package/dist/vitest.config.js +49 -0
- package/eslint.config.mjs +2 -0
- package/package.json +40 -44
- package/dist/src/api/adapters/cron/node-cron.adapter.d.ts +0 -3
- package/dist/src/api/adapters/cron/node-cron.adapter.d.ts.map +0 -1
- package/dist/src/api/adapters/cron/node-cron.adapter.js +0 -11
- package/dist/src/api/adapters/email/nodemailer.d.ts +0 -10
- package/dist/src/api/adapters/email/nodemailer.d.ts.map +0 -1
- package/dist/src/api/adapters/email/nodemailer.js +0 -30
- package/dist/src/api/adapters/email/resend.d.ts +0 -6
- package/dist/src/api/adapters/email/resend.d.ts.map +0 -1
- package/dist/src/api/adapters/email/resend.js +0 -21
|
@@ -1,91 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useEditorState } from "@tiptap/react";
|
|
3
|
-
import { AlignCenterIcon, AlignJustifyIcon, AlignLeftIcon, AlignRightIcon, ChevronDown } from "lucide-react";
|
|
4
|
-
import { useTranslations } from "next-intl";
|
|
5
|
-
import { Button } from "../../../ui/button.js";
|
|
6
|
-
import { DropdownMenu, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuShortcut, DropdownMenuTrigger } from "../../../ui/dropdown-menu.js";
|
|
7
|
-
import { CtrlOrCommandCharacter } from "../../../../lib/ctrl-or-command-character.js";
|
|
8
|
-
import { useToolbarEditor } from "../use-toolbar-editor.js";
|
|
9
|
-
export const AlignmentAction = ()=>{
|
|
10
|
-
const t = useTranslations("core.global.editor");
|
|
11
|
-
const { editor } = useToolbarEditor();
|
|
12
|
-
const activeValue = useEditorState({
|
|
13
|
-
editor,
|
|
14
|
-
selector: (ctx)=>{
|
|
15
|
-
return [
|
|
16
|
-
"left",
|
|
17
|
-
"center",
|
|
18
|
-
"right",
|
|
19
|
-
"justify"
|
|
20
|
-
].find((align)=>ctx.editor.isActive({
|
|
21
|
-
textAlign: align
|
|
22
|
-
})) ?? "left";
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
const alignments = [
|
|
26
|
-
{
|
|
27
|
-
label: t("alignments.left"),
|
|
28
|
-
value: "left",
|
|
29
|
-
icon: /*#__PURE__*/ _jsx(AlignLeftIcon, {}),
|
|
30
|
-
shortcut: "L"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
label: t("alignments.center"),
|
|
34
|
-
value: "center",
|
|
35
|
-
icon: /*#__PURE__*/ _jsx(AlignCenterIcon, {}),
|
|
36
|
-
shortcut: "E"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
label: t("alignments.right"),
|
|
40
|
-
value: "right",
|
|
41
|
-
icon: /*#__PURE__*/ _jsx(AlignRightIcon, {}),
|
|
42
|
-
shortcut: "R"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
label: t("alignments.justify"),
|
|
46
|
-
value: "justify",
|
|
47
|
-
icon: /*#__PURE__*/ _jsx(AlignJustifyIcon, {}),
|
|
48
|
-
shortcut: "J"
|
|
49
|
-
}
|
|
50
|
-
];
|
|
51
|
-
const activeAlignment = alignments.find((a)=>a.value === activeValue) ?? alignments[0];
|
|
52
|
-
return /*#__PURE__*/ _jsxs(DropdownMenu, {
|
|
53
|
-
children: [
|
|
54
|
-
/*#__PURE__*/ _jsx(DropdownMenuTrigger, {
|
|
55
|
-
asChild: true,
|
|
56
|
-
children: /*#__PURE__*/ _jsxs(Button, {
|
|
57
|
-
className: "w-40 justify-between",
|
|
58
|
-
variant: "ghost",
|
|
59
|
-
children: [
|
|
60
|
-
activeAlignment.icon,
|
|
61
|
-
t(`alignments.${activeAlignment.value}`),
|
|
62
|
-
/*#__PURE__*/ _jsx(ChevronDown, {
|
|
63
|
-
className: "ml-auto"
|
|
64
|
-
})
|
|
65
|
-
]
|
|
66
|
-
})
|
|
67
|
-
}),
|
|
68
|
-
/*#__PURE__*/ _jsx(DropdownMenuContent, {
|
|
69
|
-
className: "min-w-[16rem]",
|
|
70
|
-
children: /*#__PURE__*/ _jsx(DropdownMenuRadioGroup, {
|
|
71
|
-
value: activeAlignment.value,
|
|
72
|
-
children: alignments.map((item)=>/*#__PURE__*/ _jsxs(DropdownMenuRadioItem, {
|
|
73
|
-
onClick: ()=>editor.chain().focus().setTextAlign(item.value).run(),
|
|
74
|
-
value: item.value,
|
|
75
|
-
children: [
|
|
76
|
-
item.icon,
|
|
77
|
-
t(`alignments.${item.value}`),
|
|
78
|
-
/*#__PURE__*/ _jsxs(DropdownMenuShortcut, {
|
|
79
|
-
children: [
|
|
80
|
-
/*#__PURE__*/ _jsx(CtrlOrCommandCharacter, {}),
|
|
81
|
-
"+Shift+",
|
|
82
|
-
item.shortcut
|
|
83
|
-
]
|
|
84
|
-
})
|
|
85
|
-
]
|
|
86
|
-
}, item.value))
|
|
87
|
-
})
|
|
88
|
-
})
|
|
89
|
-
]
|
|
90
|
-
});
|
|
91
|
-
};
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useEditorState}from"@tiptap/react";import{AlignCenterIcon,AlignJustifyIcon,AlignLeftIcon,AlignRightIcon,ChevronDown}from"lucide-react";import{useTranslations}from"next-intl";import{Button}from"../../../ui/button.js";import{DropdownMenu,DropdownMenuContent,DropdownMenuRadioGroup,DropdownMenuRadioItem,DropdownMenuShortcut,DropdownMenuTrigger}from"../../../ui/dropdown-menu.js";import{CtrlOrCommandCharacter}from"../../../../lib/ctrl-or-command-character.js";import{useToolbarEditor}from"../use-toolbar-editor.js";export const AlignmentAction=()=>{const t=useTranslations("core.global.editor");const{editor}=useToolbarEditor();const activeValue=useEditorState({editor,selector:ctx=>{return["left","center","right","justify"].find(align=>ctx.editor.isActive({textAlign:align}))??"left"}});const alignments=[{label:t("alignments.left"),value:"left",icon:_jsx(AlignLeftIcon,{}),shortcut:"L"},{label:t("alignments.center"),value:"center",icon:_jsx(AlignCenterIcon,{}),shortcut:"E"},{label:t("alignments.right"),value:"right",icon:_jsx(AlignRightIcon,{}),shortcut:"R"},{label:t("alignments.justify"),value:"justify",icon:_jsx(AlignJustifyIcon,{}),shortcut:"J"}];const activeAlignment=alignments.find(a=>a.value===activeValue)??alignments[0];return _jsxs(DropdownMenu,{children:[_jsx(DropdownMenuTrigger,{asChild:true,children:_jsxs(Button,{className:"w-40 justify-between",variant:"ghost",children:[activeAlignment.icon,t(`alignments.${activeAlignment.value}`),_jsx(ChevronDown,{className:"ml-auto"})]})}),_jsx(DropdownMenuContent,{className:"min-w-[16rem]",children:_jsx(DropdownMenuRadioGroup,{value:activeAlignment.value,children:alignments.map(item=>_jsxs(DropdownMenuRadioItem,{onClick:()=>editor.chain().focus().setTextAlign(item.value).run(),value:item.value,children:[item.icon,t(`alignments.${item.value}`),_jsxs(DropdownMenuShortcut,{children:[_jsx(CtrlOrCommandCharacter,{}),"+Shift+",item.shortcut]})]},item.value))})})]})};
|
|
@@ -1,39 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useEditorState } from "@tiptap/react";
|
|
3
|
-
import { BoldIcon } from "lucide-react";
|
|
4
|
-
import { useTranslations } from "next-intl";
|
|
5
|
-
import { Toggle } from "../../../ui/toggle.js";
|
|
6
|
-
import { TooltipWithContent } from "../../../ui/tooltip.js";
|
|
7
|
-
import { useToolbarEditor } from "../use-toolbar-editor.js";
|
|
8
|
-
import { TooltipShortcut } from "./utils/tooltip-shortcut.js";
|
|
9
|
-
export const BoldAction = ()=>{
|
|
10
|
-
const t = useTranslations("core.global.editor");
|
|
11
|
-
const { editor } = useToolbarEditor();
|
|
12
|
-
const { isBold } = useEditorState({
|
|
13
|
-
editor,
|
|
14
|
-
selector: (ctx)=>{
|
|
15
|
-
return {
|
|
16
|
-
isBold: ctx.editor.isActive("bold")
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
return /*#__PURE__*/ _jsx(TooltipWithContent, {
|
|
21
|
-
text: /*#__PURE__*/ _jsxs(_Fragment, {
|
|
22
|
-
children: [
|
|
23
|
-
t("bold"),
|
|
24
|
-
" ",
|
|
25
|
-
/*#__PURE__*/ _jsx(TooltipShortcut, {
|
|
26
|
-
children: "+B"
|
|
27
|
-
})
|
|
28
|
-
]
|
|
29
|
-
}),
|
|
30
|
-
children: /*#__PURE__*/ _jsx("div", {
|
|
31
|
-
children: /*#__PURE__*/ _jsx(Toggle, {
|
|
32
|
-
"aria-label": t("bold"),
|
|
33
|
-
onClick: ()=>editor.chain().focus().toggleBold().run(),
|
|
34
|
-
pressed: isBold,
|
|
35
|
-
children: /*#__PURE__*/ _jsx(BoldIcon, {})
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
|
-
});
|
|
39
|
-
};
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useEditorState}from"@tiptap/react";import{BoldIcon}from"lucide-react";import{useTranslations}from"next-intl";import{Toggle}from"../../../ui/toggle.js";import{TooltipWithContent}from"../../../ui/tooltip.js";import{useToolbarEditor}from"../use-toolbar-editor.js";import{TooltipShortcut}from"./utils/tooltip-shortcut.js";export const BoldAction=()=>{const t=useTranslations("core.global.editor");const{editor}=useToolbarEditor();const{isBold}=useEditorState({editor,selector:ctx=>{return{isBold:ctx.editor.isActive("bold")}}});return _jsx(TooltipWithContent,{text:_jsxs(_Fragment,{children:[t("bold")," ",_jsx(TooltipShortcut,{children:"+B"})]}),children:_jsx("div",{children:_jsx(Toggle,{"aria-label":t("bold"),onClick:()=>editor.chain().focus().toggleBold().run(),pressed:isBold,children:_jsx(BoldIcon,{})})})})};
|
|
@@ -1,93 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useEditorState } from "@tiptap/react";
|
|
3
|
-
import { ChevronDown, Heading1Icon, Heading2Icon, Heading3Icon, Heading4Icon, PilcrowIcon } from "lucide-react";
|
|
4
|
-
import { useTranslations } from "next-intl";
|
|
5
|
-
import { Button } from "../../../ui/button.js";
|
|
6
|
-
import { DropdownMenu, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuShortcut, DropdownMenuTrigger } from "../../../ui/dropdown-menu.js";
|
|
7
|
-
import { CtrlOrCommandCharacter } from "../../../../lib/ctrl-or-command-character.js";
|
|
8
|
-
import { SUPPORTED_HEADINGS_LEVELS } from "../../extension.js";
|
|
9
|
-
import { useToolbarEditor } from "../use-toolbar-editor.js";
|
|
10
|
-
const ICONS = {
|
|
11
|
-
paragraph: /*#__PURE__*/ _jsx(PilcrowIcon, {}),
|
|
12
|
-
heading_1: /*#__PURE__*/ _jsx(Heading1Icon, {}),
|
|
13
|
-
heading_2: /*#__PURE__*/ _jsx(Heading2Icon, {}),
|
|
14
|
-
heading_3: /*#__PURE__*/ _jsx(Heading3Icon, {}),
|
|
15
|
-
heading_4: /*#__PURE__*/ _jsx(Heading4Icon, {})
|
|
16
|
-
};
|
|
17
|
-
export const HeadingsAction = ()=>{
|
|
18
|
-
const t = useTranslations("core.global.editor");
|
|
19
|
-
const { editor } = useToolbarEditor();
|
|
20
|
-
const activeValue = useEditorState({
|
|
21
|
-
editor,
|
|
22
|
-
selector: (ctx)=>{
|
|
23
|
-
if (!ctx.editor.isActive("heading")) return "paragraph";
|
|
24
|
-
const level = ctx.editor.getAttributes("heading").level;
|
|
25
|
-
return `heading-${level}`;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
const options = [
|
|
29
|
-
{
|
|
30
|
-
value: "paragraph",
|
|
31
|
-
label: t("paragraph"),
|
|
32
|
-
icon: ICONS.paragraph,
|
|
33
|
-
shortcut: "0"
|
|
34
|
-
},
|
|
35
|
-
...SUPPORTED_HEADINGS_LEVELS.map((level)=>({
|
|
36
|
-
value: `heading-${level}`,
|
|
37
|
-
label: t("heading", {
|
|
38
|
-
level
|
|
39
|
-
}),
|
|
40
|
-
icon: ICONS[`heading_${level}`],
|
|
41
|
-
shortcut: level.toString()
|
|
42
|
-
}))
|
|
43
|
-
];
|
|
44
|
-
const activeOption = options.find((o)=>o.value === activeValue) ?? options[0];
|
|
45
|
-
return /*#__PURE__*/ _jsxs(DropdownMenu, {
|
|
46
|
-
children: [
|
|
47
|
-
/*#__PURE__*/ _jsx(DropdownMenuTrigger, {
|
|
48
|
-
asChild: true,
|
|
49
|
-
children: /*#__PURE__*/ _jsxs(Button, {
|
|
50
|
-
className: "w-32 justify-between",
|
|
51
|
-
variant: "ghost",
|
|
52
|
-
children: [
|
|
53
|
-
activeOption.icon,
|
|
54
|
-
activeOption.label,
|
|
55
|
-
/*#__PURE__*/ _jsx(ChevronDown, {
|
|
56
|
-
className: "ml-auto"
|
|
57
|
-
})
|
|
58
|
-
]
|
|
59
|
-
})
|
|
60
|
-
}),
|
|
61
|
-
/*#__PURE__*/ _jsx(DropdownMenuContent, {
|
|
62
|
-
className: "min-w-[14rem]",
|
|
63
|
-
children: /*#__PURE__*/ _jsx(DropdownMenuRadioGroup, {
|
|
64
|
-
value: activeValue,
|
|
65
|
-
children: options.map((item)=>/*#__PURE__*/ _jsxs(DropdownMenuRadioItem, {
|
|
66
|
-
onClick: ()=>{
|
|
67
|
-
if (item.value === "paragraph") {
|
|
68
|
-
editor.chain().focus().setParagraph().run();
|
|
69
|
-
} else {
|
|
70
|
-
const level = parseInt(item.value.split("-")[1]);
|
|
71
|
-
editor.chain().focus().toggleHeading({
|
|
72
|
-
level
|
|
73
|
-
}).run();
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
value: item.value,
|
|
77
|
-
children: [
|
|
78
|
-
item.icon,
|
|
79
|
-
item.label,
|
|
80
|
-
/*#__PURE__*/ _jsxs(DropdownMenuShortcut, {
|
|
81
|
-
children: [
|
|
82
|
-
/*#__PURE__*/ _jsx(CtrlOrCommandCharacter, {}),
|
|
83
|
-
"+Alt+",
|
|
84
|
-
item.shortcut
|
|
85
|
-
]
|
|
86
|
-
})
|
|
87
|
-
]
|
|
88
|
-
}, item.value))
|
|
89
|
-
})
|
|
90
|
-
})
|
|
91
|
-
]
|
|
92
|
-
});
|
|
93
|
-
};
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useEditorState}from"@tiptap/react";import{ChevronDown,Heading1Icon,Heading2Icon,Heading3Icon,Heading4Icon,PilcrowIcon}from"lucide-react";import{useTranslations}from"next-intl";import{Button}from"../../../ui/button.js";import{DropdownMenu,DropdownMenuContent,DropdownMenuRadioGroup,DropdownMenuRadioItem,DropdownMenuShortcut,DropdownMenuTrigger}from"../../../ui/dropdown-menu.js";import{CtrlOrCommandCharacter}from"../../../../lib/ctrl-or-command-character.js";import{SUPPORTED_HEADINGS_LEVELS}from"../../extension.js";import{useToolbarEditor}from"../use-toolbar-editor.js";const ICONS={paragraph:_jsx(PilcrowIcon,{}),heading_1:_jsx(Heading1Icon,{}),heading_2:_jsx(Heading2Icon,{}),heading_3:_jsx(Heading3Icon,{}),heading_4:_jsx(Heading4Icon,{})};export const HeadingsAction=()=>{const t=useTranslations("core.global.editor");const{editor}=useToolbarEditor();const activeValue=useEditorState({editor,selector:ctx=>{if(!ctx.editor.isActive("heading"))return"paragraph";const level=ctx.editor.getAttributes("heading").level;return`heading-${level}`}});const options=[{value:"paragraph",label:t("paragraph"),icon:ICONS.paragraph,shortcut:"0"},...SUPPORTED_HEADINGS_LEVELS.map(level=>({value:`heading-${level}`,label:t("heading",{level}),icon:ICONS[`heading_${level}`],shortcut:level.toString()}))];const activeOption=options.find(o=>o.value===activeValue)??options[0];return _jsxs(DropdownMenu,{children:[_jsx(DropdownMenuTrigger,{asChild:true,children:_jsxs(Button,{className:"w-32 justify-between",variant:"ghost",children:[activeOption.icon,activeOption.label,_jsx(ChevronDown,{className:"ml-auto"})]})}),_jsx(DropdownMenuContent,{className:"min-w-[14rem]",children:_jsx(DropdownMenuRadioGroup,{value:activeValue,children:options.map(item=>_jsxs(DropdownMenuRadioItem,{onClick:()=>{if(item.value==="paragraph"){editor.chain().focus().setParagraph().run()}else{const level=parseInt(item.value.split("-")[1]);editor.chain().focus().toggleHeading({level}).run()}},value:item.value,children:[item.icon,item.label,_jsxs(DropdownMenuShortcut,{children:[_jsx(CtrlOrCommandCharacter,{}),"+Alt+",item.shortcut]})]},item.value))})})]})};
|
|
@@ -1,38 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useEditorState } from "@tiptap/react";
|
|
3
|
-
import { ItalicIcon } from "lucide-react";
|
|
4
|
-
import { useTranslations } from "next-intl";
|
|
5
|
-
import { Toggle } from "../../../ui/toggle.js";
|
|
6
|
-
import { TooltipWithContent } from "../../../ui/tooltip.js";
|
|
7
|
-
import { useToolbarEditor } from "../use-toolbar-editor.js";
|
|
8
|
-
import { TooltipShortcut } from "./utils/tooltip-shortcut.js";
|
|
9
|
-
export const ItalicAction = ()=>{
|
|
10
|
-
const t = useTranslations("core.global.editor");
|
|
11
|
-
const { editor } = useToolbarEditor();
|
|
12
|
-
const { isItalic } = useEditorState({
|
|
13
|
-
editor,
|
|
14
|
-
selector: (ctx)=>{
|
|
15
|
-
return {
|
|
16
|
-
isItalic: ctx.editor.isActive("italic")
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
return /*#__PURE__*/ _jsx(TooltipWithContent, {
|
|
21
|
-
text: /*#__PURE__*/ _jsxs(_Fragment, {
|
|
22
|
-
children: [
|
|
23
|
-
t("italic"),
|
|
24
|
-
/*#__PURE__*/ _jsx(TooltipShortcut, {
|
|
25
|
-
children: "+I"
|
|
26
|
-
})
|
|
27
|
-
]
|
|
28
|
-
}),
|
|
29
|
-
children: /*#__PURE__*/ _jsx("div", {
|
|
30
|
-
children: /*#__PURE__*/ _jsx(Toggle, {
|
|
31
|
-
"aria-label": t("italic"),
|
|
32
|
-
onClick: ()=>editor.chain().focus().toggleItalic().run(),
|
|
33
|
-
pressed: isItalic,
|
|
34
|
-
children: /*#__PURE__*/ _jsx(ItalicIcon, {})
|
|
35
|
-
})
|
|
36
|
-
})
|
|
37
|
-
});
|
|
38
|
-
};
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useEditorState}from"@tiptap/react";import{ItalicIcon}from"lucide-react";import{useTranslations}from"next-intl";import{Toggle}from"../../../ui/toggle.js";import{TooltipWithContent}from"../../../ui/tooltip.js";import{useToolbarEditor}from"../use-toolbar-editor.js";import{TooltipShortcut}from"./utils/tooltip-shortcut.js";export const ItalicAction=()=>{const t=useTranslations("core.global.editor");const{editor}=useToolbarEditor();const{isItalic}=useEditorState({editor,selector:ctx=>{return{isItalic:ctx.editor.isActive("italic")}}});return _jsx(TooltipWithContent,{text:_jsxs(_Fragment,{children:[t("italic"),_jsx(TooltipShortcut,{children:"+I"})]}),children:_jsx("div",{children:_jsx(Toggle,{"aria-label":t("italic"),onClick:()=>editor.chain().focus().toggleItalic().run(),pressed:isItalic,children:_jsx(ItalicIcon,{})})})})};
|
|
@@ -1,61 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useEditorState } from "@tiptap/react";
|
|
3
|
-
import { ListIcon, ListOrderedIcon } from "lucide-react";
|
|
4
|
-
import { useTranslations } from "next-intl";
|
|
5
|
-
import { Toggle } from "../../../ui/toggle.js";
|
|
6
|
-
import { TooltipWithContent } from "../../../ui/tooltip.js";
|
|
7
|
-
import { useToolbarEditor } from "../use-toolbar-editor.js";
|
|
8
|
-
import { TooltipShortcut } from "./utils/tooltip-shortcut.js";
|
|
9
|
-
export const ListAction = ()=>{
|
|
10
|
-
const t = useTranslations("core.global.editor");
|
|
11
|
-
const { editor } = useToolbarEditor();
|
|
12
|
-
const { isBulletList, isOrderedList } = useEditorState({
|
|
13
|
-
editor,
|
|
14
|
-
selector: (ctx)=>{
|
|
15
|
-
return {
|
|
16
|
-
isOrderedList: ctx.editor.isActive("orderedList"),
|
|
17
|
-
isBulletList: ctx.editor.isActive("bulletList")
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
22
|
-
children: [
|
|
23
|
-
/*#__PURE__*/ _jsx(TooltipWithContent, {
|
|
24
|
-
text: /*#__PURE__*/ _jsxs(_Fragment, {
|
|
25
|
-
children: [
|
|
26
|
-
t("bullet_list"),
|
|
27
|
-
/*#__PURE__*/ _jsx(TooltipShortcut, {
|
|
28
|
-
children: "+I"
|
|
29
|
-
})
|
|
30
|
-
]
|
|
31
|
-
}),
|
|
32
|
-
children: /*#__PURE__*/ _jsx("div", {
|
|
33
|
-
children: /*#__PURE__*/ _jsx(Toggle, {
|
|
34
|
-
"aria-label": t("bullet_list"),
|
|
35
|
-
onClick: ()=>editor.chain().focus().toggleBulletList().run(),
|
|
36
|
-
pressed: isBulletList,
|
|
37
|
-
children: /*#__PURE__*/ _jsx(ListIcon, {})
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
}),
|
|
41
|
-
/*#__PURE__*/ _jsx(TooltipWithContent, {
|
|
42
|
-
text: /*#__PURE__*/ _jsxs(_Fragment, {
|
|
43
|
-
children: [
|
|
44
|
-
t("ordered_list"),
|
|
45
|
-
/*#__PURE__*/ _jsx(TooltipShortcut, {
|
|
46
|
-
children: "+I"
|
|
47
|
-
})
|
|
48
|
-
]
|
|
49
|
-
}),
|
|
50
|
-
children: /*#__PURE__*/ _jsx("div", {
|
|
51
|
-
children: /*#__PURE__*/ _jsx(Toggle, {
|
|
52
|
-
"aria-label": t("ordered_list"),
|
|
53
|
-
onClick: ()=>editor.chain().focus().toggleOrderedList().run(),
|
|
54
|
-
pressed: isOrderedList,
|
|
55
|
-
children: /*#__PURE__*/ _jsx(ListOrderedIcon, {})
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
]
|
|
60
|
-
});
|
|
61
|
-
};
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useEditorState}from"@tiptap/react";import{ListIcon,ListOrderedIcon}from"lucide-react";import{useTranslations}from"next-intl";import{Toggle}from"../../../ui/toggle.js";import{TooltipWithContent}from"../../../ui/tooltip.js";import{useToolbarEditor}from"../use-toolbar-editor.js";import{TooltipShortcut}from"./utils/tooltip-shortcut.js";export const ListAction=()=>{const t=useTranslations("core.global.editor");const{editor}=useToolbarEditor();const{isBulletList,isOrderedList}=useEditorState({editor,selector:ctx=>{return{isOrderedList:ctx.editor.isActive("orderedList"),isBulletList:ctx.editor.isActive("bulletList")}}});return _jsxs(_Fragment,{children:[_jsx(TooltipWithContent,{text:_jsxs(_Fragment,{children:[t("bullet_list"),_jsx(TooltipShortcut,{children:"+I"})]}),children:_jsx("div",{children:_jsx(Toggle,{"aria-label":t("bullet_list"),onClick:()=>editor.chain().focus().toggleBulletList().run(),pressed:isBulletList,children:_jsx(ListIcon,{})})})}),_jsx(TooltipWithContent,{text:_jsxs(_Fragment,{children:[t("ordered_list"),_jsx(TooltipShortcut,{children:"+I"})]}),children:_jsx("div",{children:_jsx(Toggle,{"aria-label":t("ordered_list"),onClick:()=>editor.chain().focus().toggleOrderedList().run(),pressed:isOrderedList,children:_jsx(ListOrderedIcon,{})})})})]})};
|
|
@@ -1,59 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useEditorState } from "@tiptap/react";
|
|
3
|
-
import { EllipsisVerticalIcon, StrikethroughIcon } from "lucide-react";
|
|
4
|
-
import { useTranslations } from "next-intl";
|
|
5
|
-
import { Button } from "../../../../ui/button.js";
|
|
6
|
-
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuShortcut, DropdownMenuTrigger } from "../../../../ui/dropdown-menu.js";
|
|
7
|
-
import { CtrlOrCommandCharacter } from "../../../../../lib/ctrl-or-command-character.js";
|
|
8
|
-
import { cn } from "../../../../../lib/utils.js";
|
|
9
|
-
import { useToolbarEditor } from "../../use-toolbar-editor.js";
|
|
10
|
-
export const TextFormatMore = ()=>{
|
|
11
|
-
const t = useTranslations("core.global.editor.text_format_more");
|
|
12
|
-
const { editor } = useToolbarEditor();
|
|
13
|
-
const { isStrike } = useEditorState({
|
|
14
|
-
editor,
|
|
15
|
-
selector: (ctx)=>{
|
|
16
|
-
return {
|
|
17
|
-
isStrike: ctx.editor.isActive("strike")
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
return /*#__PURE__*/ _jsxs(DropdownMenu, {
|
|
22
|
-
children: [
|
|
23
|
-
/*#__PURE__*/ _jsx(DropdownMenuTrigger, {
|
|
24
|
-
asChild: true,
|
|
25
|
-
children: /*#__PURE__*/ _jsx(Button, {
|
|
26
|
-
"aria-label": t("label"),
|
|
27
|
-
className: cn({
|
|
28
|
-
"bg-accent": isStrike
|
|
29
|
-
}),
|
|
30
|
-
size: "icon",
|
|
31
|
-
variant: "ghost",
|
|
32
|
-
children: /*#__PURE__*/ _jsx(EllipsisVerticalIcon, {})
|
|
33
|
-
})
|
|
34
|
-
}),
|
|
35
|
-
/*#__PURE__*/ _jsx(DropdownMenuContent, {
|
|
36
|
-
className: "min-w-[12rem]",
|
|
37
|
-
children: /*#__PURE__*/ _jsxs(DropdownMenuItem, {
|
|
38
|
-
className: cn({
|
|
39
|
-
"bg-accent": isStrike
|
|
40
|
-
}),
|
|
41
|
-
onClick: ()=>{
|
|
42
|
-
editor.chain().focus().toggleStrike().run();
|
|
43
|
-
editor.view.focus();
|
|
44
|
-
},
|
|
45
|
-
children: [
|
|
46
|
-
/*#__PURE__*/ _jsx(StrikethroughIcon, {}),
|
|
47
|
-
t("strike"),
|
|
48
|
-
/*#__PURE__*/ _jsxs(DropdownMenuShortcut, {
|
|
49
|
-
children: [
|
|
50
|
-
/*#__PURE__*/ _jsx(CtrlOrCommandCharacter, {}),
|
|
51
|
-
"+S"
|
|
52
|
-
]
|
|
53
|
-
})
|
|
54
|
-
]
|
|
55
|
-
})
|
|
56
|
-
})
|
|
57
|
-
]
|
|
58
|
-
});
|
|
59
|
-
};
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useEditorState}from"@tiptap/react";import{EllipsisVerticalIcon,StrikethroughIcon}from"lucide-react";import{useTranslations}from"next-intl";import{Button}from"../../../../ui/button.js";import{DropdownMenu,DropdownMenuContent,DropdownMenuItem,DropdownMenuShortcut,DropdownMenuTrigger}from"../../../../ui/dropdown-menu.js";import{CtrlOrCommandCharacter}from"../../../../../lib/ctrl-or-command-character.js";import{cn}from"../../../../../lib/utils.js";import{useToolbarEditor}from"../../use-toolbar-editor.js";export const TextFormatMore=()=>{const t=useTranslations("core.global.editor.text_format_more");const{editor}=useToolbarEditor();const{isStrike}=useEditorState({editor,selector:ctx=>{return{isStrike:ctx.editor.isActive("strike")}}});return _jsxs(DropdownMenu,{children:[_jsx(DropdownMenuTrigger,{asChild:true,children:_jsx(Button,{"aria-label":t("label"),className:cn({"bg-accent":isStrike}),size:"icon",variant:"ghost",children:_jsx(EllipsisVerticalIcon,{})})}),_jsx(DropdownMenuContent,{className:"min-w-[12rem]",children:_jsxs(DropdownMenuItem,{className:cn({"bg-accent":isStrike}),onClick:()=>{editor.chain().focus().toggleStrike().run();editor.view.focus()},children:[_jsx(StrikethroughIcon,{}),t("strike"),_jsxs(DropdownMenuShortcut,{children:[_jsx(CtrlOrCommandCharacter,{}),"+S"]})]})})]})};
|
|
@@ -1,38 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useEditorState } from "@tiptap/react";
|
|
3
|
-
import { UnderlineIcon } from "lucide-react";
|
|
4
|
-
import { useTranslations } from "next-intl";
|
|
5
|
-
import { Toggle } from "../../../ui/toggle.js";
|
|
6
|
-
import { TooltipWithContent } from "../../../ui/tooltip.js";
|
|
7
|
-
import { useToolbarEditor } from "../use-toolbar-editor.js";
|
|
8
|
-
import { TooltipShortcut } from "./utils/tooltip-shortcut.js";
|
|
9
|
-
export const UnderlineAction = ()=>{
|
|
10
|
-
const t = useTranslations("core.global.editor");
|
|
11
|
-
const { editor } = useToolbarEditor();
|
|
12
|
-
const { isUnderline } = useEditorState({
|
|
13
|
-
editor,
|
|
14
|
-
selector: (ctx)=>{
|
|
15
|
-
return {
|
|
16
|
-
isUnderline: ctx.editor.isActive("underline")
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
return /*#__PURE__*/ _jsx(TooltipWithContent, {
|
|
21
|
-
text: /*#__PURE__*/ _jsxs(_Fragment, {
|
|
22
|
-
children: [
|
|
23
|
-
t("underline"),
|
|
24
|
-
/*#__PURE__*/ _jsx(TooltipShortcut, {
|
|
25
|
-
children: "+U"
|
|
26
|
-
})
|
|
27
|
-
]
|
|
28
|
-
}),
|
|
29
|
-
children: /*#__PURE__*/ _jsx("div", {
|
|
30
|
-
children: /*#__PURE__*/ _jsx(Toggle, {
|
|
31
|
-
"aria-label": t("underline"),
|
|
32
|
-
onClick: ()=>editor.chain().focus().toggleUnderline().run(),
|
|
33
|
-
pressed: isUnderline,
|
|
34
|
-
children: /*#__PURE__*/ _jsx(UnderlineIcon, {})
|
|
35
|
-
})
|
|
36
|
-
})
|
|
37
|
-
});
|
|
38
|
-
};
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useEditorState}from"@tiptap/react";import{UnderlineIcon}from"lucide-react";import{useTranslations}from"next-intl";import{Toggle}from"../../../ui/toggle.js";import{TooltipWithContent}from"../../../ui/tooltip.js";import{useToolbarEditor}from"../use-toolbar-editor.js";import{TooltipShortcut}from"./utils/tooltip-shortcut.js";export const UnderlineAction=()=>{const t=useTranslations("core.global.editor");const{editor}=useToolbarEditor();const{isUnderline}=useEditorState({editor,selector:ctx=>{return{isUnderline:ctx.editor.isActive("underline")}}});return _jsx(TooltipWithContent,{text:_jsxs(_Fragment,{children:[t("underline"),_jsx(TooltipShortcut,{children:"+U"})]}),children:_jsx("div",{children:_jsx(Toggle,{"aria-label":t("underline"),onClick:()=>editor.chain().focus().toggleUnderline().run(),pressed:isUnderline,children:_jsx(UnderlineIcon,{})})})})};
|
|
@@ -1,63 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useEditorState } from "@tiptap/react";
|
|
3
|
-
import { RedoIcon, UndoIcon } from "lucide-react";
|
|
4
|
-
import { useTranslations } from "next-intl";
|
|
5
|
-
import { Button } from "../../../ui/button.js";
|
|
6
|
-
import { TooltipWithContent } from "../../../ui/tooltip.js";
|
|
7
|
-
import { useToolbarEditor } from "../use-toolbar-editor.js";
|
|
8
|
-
import { TooltipShortcut } from "./utils/tooltip-shortcut.js";
|
|
9
|
-
export const UndoRedoActions = ()=>{
|
|
10
|
-
const t = useTranslations("core.global.editor");
|
|
11
|
-
const { editor } = useToolbarEditor();
|
|
12
|
-
const { canUndo, canRedo } = useEditorState({
|
|
13
|
-
editor,
|
|
14
|
-
selector: (ctx)=>{
|
|
15
|
-
return {
|
|
16
|
-
canUndo: ctx.editor.can().chain().focus().undo().run(),
|
|
17
|
-
canRedo: ctx.editor.can().chain().focus().redo().run()
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
22
|
-
children: [
|
|
23
|
-
/*#__PURE__*/ _jsx(TooltipWithContent, {
|
|
24
|
-
text: /*#__PURE__*/ _jsxs(_Fragment, {
|
|
25
|
-
children: [
|
|
26
|
-
t("undo"),
|
|
27
|
-
" ",
|
|
28
|
-
/*#__PURE__*/ _jsx(TooltipShortcut, {
|
|
29
|
-
children: "+Z"
|
|
30
|
-
})
|
|
31
|
-
]
|
|
32
|
-
}),
|
|
33
|
-
children: /*#__PURE__*/ _jsx(Button, {
|
|
34
|
-
"aria-label": t("undo"),
|
|
35
|
-
disabled: !canUndo,
|
|
36
|
-
onClick: ()=>editor.chain().focus().undo().run(),
|
|
37
|
-
size: "icon",
|
|
38
|
-
variant: "ghost",
|
|
39
|
-
children: /*#__PURE__*/ _jsx(UndoIcon, {})
|
|
40
|
-
})
|
|
41
|
-
}),
|
|
42
|
-
/*#__PURE__*/ _jsx(TooltipWithContent, {
|
|
43
|
-
text: /*#__PURE__*/ _jsxs(_Fragment, {
|
|
44
|
-
children: [
|
|
45
|
-
t("redo"),
|
|
46
|
-
" ",
|
|
47
|
-
/*#__PURE__*/ _jsx(TooltipShortcut, {
|
|
48
|
-
children: "+Shift+Z"
|
|
49
|
-
})
|
|
50
|
-
]
|
|
51
|
-
}),
|
|
52
|
-
children: /*#__PURE__*/ _jsx(Button, {
|
|
53
|
-
"aria-label": t("redo"),
|
|
54
|
-
disabled: !canRedo,
|
|
55
|
-
onClick: ()=>editor.chain().focus().redo().run(),
|
|
56
|
-
size: "icon",
|
|
57
|
-
variant: "ghost",
|
|
58
|
-
children: /*#__PURE__*/ _jsx(RedoIcon, {})
|
|
59
|
-
})
|
|
60
|
-
})
|
|
61
|
-
]
|
|
62
|
-
});
|
|
63
|
-
};
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useEditorState}from"@tiptap/react";import{RedoIcon,UndoIcon}from"lucide-react";import{useTranslations}from"next-intl";import{Button}from"../../../ui/button.js";import{TooltipWithContent}from"../../../ui/tooltip.js";import{useToolbarEditor}from"../use-toolbar-editor.js";import{TooltipShortcut}from"./utils/tooltip-shortcut.js";export const UndoRedoActions=()=>{const t=useTranslations("core.global.editor");const{editor}=useToolbarEditor();const{canUndo,canRedo}=useEditorState({editor,selector:ctx=>{return{canUndo:ctx.editor.can().chain().focus().undo().run(),canRedo:ctx.editor.can().chain().focus().redo().run()}}});return _jsxs(_Fragment,{children:[_jsx(TooltipWithContent,{text:_jsxs(_Fragment,{children:[t("undo")," ",_jsx(TooltipShortcut,{children:"+Z"})]}),children:_jsx(Button,{"aria-label":t("undo"),disabled:!canUndo,onClick:()=>editor.chain().focus().undo().run(),size:"icon",variant:"ghost",children:_jsx(UndoIcon,{})})}),_jsx(TooltipWithContent,{text:_jsxs(_Fragment,{children:[t("redo")," ",_jsx(TooltipShortcut,{children:"+Shift+Z"})]}),children:_jsx(Button,{"aria-label":t("redo"),disabled:!canRedo,onClick:()=>editor.chain().focus().redo().run(),size:"icon",variant:"ghost",children:_jsx(RedoIcon,{})})})]})};
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { CtrlOrCommandCharacter } from "../../../../../lib/ctrl-or-command-character.js";
|
|
3
|
-
export const TooltipShortcut = ({ children })=>{
|
|
4
|
-
return /*#__PURE__*/ _jsxs("span", {
|
|
5
|
-
className: "ml-2 text-xs tracking-widest",
|
|
6
|
-
children: [
|
|
7
|
-
/*#__PURE__*/ _jsx(CtrlOrCommandCharacter, {}),
|
|
8
|
-
children
|
|
9
|
-
]
|
|
10
|
-
});
|
|
11
|
-
};
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{CtrlOrCommandCharacter}from"../../../../../lib/ctrl-or-command-character.js";export const TooltipShortcut=({children})=>{return _jsxs("span",{className:"ml-2 text-xs tracking-widest",children:[_jsx(CtrlOrCommandCharacter,{}),children]})};
|
|
@@ -1,55 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { ScrollArea, ScrollBar } from "../../ui/scroll-area.js";
|
|
4
|
-
import { Separator } from "../../ui/separator.js";
|
|
5
|
-
import { AlignmentAction } from "./actions/alignment-action.js";
|
|
6
|
-
import { BoldAction } from "./actions/bold-action.js";
|
|
7
|
-
import { HeadingsAction } from "./actions/headings-action.js";
|
|
8
|
-
import { ItalicAction } from "./actions/italic-action.js";
|
|
9
|
-
import { ListAction } from "./actions/list-action.js";
|
|
10
|
-
import { TextFormatMore } from "./actions/text-format-more/text-format-more.js";
|
|
11
|
-
import { UnderlineAction } from "./actions/underline-action.js";
|
|
12
|
-
import { UndoRedoActions } from "./actions/undo-redo-actions.js";
|
|
13
|
-
import { ToolbarEditorContext } from "./use-toolbar-editor.js";
|
|
14
|
-
export const TipTapToolbar = ({ editor })=>{
|
|
15
|
-
const contextValue = useMemo(()=>({
|
|
16
|
-
editor
|
|
17
|
-
}), [
|
|
18
|
-
editor
|
|
19
|
-
]);
|
|
20
|
-
return /*#__PURE__*/ _jsx(ToolbarEditorContext, {
|
|
21
|
-
value: contextValue,
|
|
22
|
-
children: /*#__PURE__*/ _jsxs(ScrollArea, {
|
|
23
|
-
children: [
|
|
24
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
25
|
-
className: "flex h-14 items-center gap-1 border-b p-2",
|
|
26
|
-
children: [
|
|
27
|
-
/*#__PURE__*/ _jsx(UndoRedoActions, {}),
|
|
28
|
-
/*#__PURE__*/ _jsx(Separator, {
|
|
29
|
-
className: "mx-2",
|
|
30
|
-
orientation: "vertical"
|
|
31
|
-
}),
|
|
32
|
-
/*#__PURE__*/ _jsx(HeadingsAction, {}),
|
|
33
|
-
/*#__PURE__*/ _jsx(Separator, {
|
|
34
|
-
className: "mx-2",
|
|
35
|
-
orientation: "vertical"
|
|
36
|
-
}),
|
|
37
|
-
/*#__PURE__*/ _jsx(BoldAction, {}),
|
|
38
|
-
/*#__PURE__*/ _jsx(ItalicAction, {}),
|
|
39
|
-
/*#__PURE__*/ _jsx(UnderlineAction, {}),
|
|
40
|
-
/*#__PURE__*/ _jsx(TextFormatMore, {}),
|
|
41
|
-
/*#__PURE__*/ _jsx(AlignmentAction, {}),
|
|
42
|
-
/*#__PURE__*/ _jsx(Separator, {
|
|
43
|
-
className: "mx-2",
|
|
44
|
-
orientation: "vertical"
|
|
45
|
-
}),
|
|
46
|
-
/*#__PURE__*/ _jsx(ListAction, {})
|
|
47
|
-
]
|
|
48
|
-
}),
|
|
49
|
-
/*#__PURE__*/ _jsx(ScrollBar, {
|
|
50
|
-
orientation: "horizontal"
|
|
51
|
-
})
|
|
52
|
-
]
|
|
53
|
-
})
|
|
54
|
-
});
|
|
55
|
-
};
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useMemo}from"react";import{ScrollArea,ScrollBar}from"../../ui/scroll-area.js";import{Separator}from"../../ui/separator.js";import{AlignmentAction}from"./actions/alignment-action.js";import{BoldAction}from"./actions/bold-action.js";import{HeadingsAction}from"./actions/headings-action.js";import{ItalicAction}from"./actions/italic-action.js";import{ListAction}from"./actions/list-action.js";import{TextFormatMore}from"./actions/text-format-more/text-format-more.js";import{UnderlineAction}from"./actions/underline-action.js";import{UndoRedoActions}from"./actions/undo-redo-actions.js";import{ToolbarEditorContext}from"./use-toolbar-editor.js";export const TipTapToolbar=({editor})=>{const contextValue=useMemo(()=>({editor}),[editor]);return _jsx(ToolbarEditorContext,{value:contextValue,children:_jsxs(ScrollArea,{children:[_jsxs("div",{className:"flex h-14 items-center gap-1 border-b p-2",children:[_jsx(UndoRedoActions,{}),_jsx(Separator,{className:"mx-2",orientation:"vertical"}),_jsx(HeadingsAction,{}),_jsx(Separator,{className:"mx-2",orientation:"vertical"}),_jsx(BoldAction,{}),_jsx(ItalicAction,{}),_jsx(UnderlineAction,{}),_jsx(TextFormatMore,{}),_jsx(AlignmentAction,{}),_jsx(Separator,{className:"mx-2",orientation:"vertical"}),_jsx(ListAction,{})]}),_jsx(ScrollBar,{orientation:"horizontal"})]})})};
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
export const ToolbarEditorContext = React.createContext({
|
|
3
|
-
editor: {}
|
|
4
|
-
});
|
|
5
|
-
export const useToolbarEditor = ()=>React.use(ToolbarEditorContext);
|
|
1
|
+
import React from"react";export const ToolbarEditorContext=React.createContext({editor:{}});export const useToolbarEditor=()=>React.use(ToolbarEditorContext);
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { ChevronDownIcon } from "lucide-react";
|
|
4
|
-
import { Accordion as AccordionPrimitive } from "radix-ui";
|
|
5
|
-
import { cn } from "../../lib/utils.js";
|
|
6
|
-
function Accordion({ ...props }) {
|
|
7
|
-
return /*#__PURE__*/ _jsx(AccordionPrimitive.Root, {
|
|
8
|
-
"data-slot": "accordion",
|
|
9
|
-
...props
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
function AccordionItem({ className, ...props }) {
|
|
13
|
-
return /*#__PURE__*/ _jsx(AccordionPrimitive.Item, {
|
|
14
|
-
className: cn("border-b last:border-b-0", className),
|
|
15
|
-
"data-slot": "accordion-item",
|
|
16
|
-
...props
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
function AccordionTrigger({ className, children, ...props }) {
|
|
20
|
-
return /*#__PURE__*/ _jsx(AccordionPrimitive.Header, {
|
|
21
|
-
className: "flex",
|
|
22
|
-
children: /*#__PURE__*/ _jsxs(AccordionPrimitive.Trigger, {
|
|
23
|
-
className: cn("focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium outline-none transition-all hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180", className),
|
|
24
|
-
"data-slot": "accordion-trigger",
|
|
25
|
-
...props,
|
|
26
|
-
children: [
|
|
27
|
-
children,
|
|
28
|
-
/*#__PURE__*/ _jsx(ChevronDownIcon, {
|
|
29
|
-
className: "text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200"
|
|
30
|
-
})
|
|
31
|
-
]
|
|
32
|
-
})
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
function AccordionContent({ className, children, ...props }) {
|
|
36
|
-
return /*#__PURE__*/ _jsx(AccordionPrimitive.Content, {
|
|
37
|
-
className: "data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",
|
|
38
|
-
"data-slot": "accordion-content",
|
|
39
|
-
...props,
|
|
40
|
-
children: /*#__PURE__*/ _jsx("div", {
|
|
41
|
-
className: cn("pb-4 pt-0", className),
|
|
42
|
-
children: children
|
|
43
|
-
})
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger };
|
|
1
|
+
"use client";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{ChevronDownIcon}from"lucide-react";import{Accordion as AccordionPrimitive}from"radix-ui";import{cn}from"../../lib/utils.js";function Accordion({...props}){return _jsx(AccordionPrimitive.Root,{"data-slot":"accordion",...props})}function AccordionItem({className,...props}){return _jsx(AccordionPrimitive.Item,{className:cn("border-b last:border-b-0",className),"data-slot":"accordion-item",...props})}function AccordionTrigger({className,children,...props}){return _jsx(AccordionPrimitive.Header,{className:"flex",children:_jsxs(AccordionPrimitive.Trigger,{className:cn("focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",className),"data-slot":"accordion-trigger",...props,children:[children,_jsx(ChevronDownIcon,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200"})]})})}function AccordionContent({className,children,...props}){return _jsx(AccordionPrimitive.Content,{className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm","data-slot":"accordion-content",...props,children:_jsx("div",{className:cn("pt-0 pb-4",className),children:children})})}export{Accordion,AccordionContent,AccordionItem,AccordionTrigger};
|