@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.
Files changed (283) hide show
  1. package/dist/scripts/get-config.js +15 -0
  2. package/dist/scripts/plugin.js +188 -0
  3. package/dist/scripts/prepare-database.js +177 -0
  4. package/dist/scripts/prepare-plugins-files.js +134 -0
  5. package/dist/scripts/run-interactive-shell-command.js +21 -0
  6. package/dist/scripts/scripts.js +39 -13
  7. package/dist/scripts/shared/file-utils.js +203 -0
  8. package/dist/src/api/adapters/sso/discord.js +1 -77
  9. package/dist/src/api/adapters/sso/facebook.js +1 -76
  10. package/dist/src/api/adapters/sso/google.js +1 -87
  11. package/dist/src/api/config.js +1 -67
  12. package/dist/src/api/lib/check-plugin-id.js +1 -43
  13. package/dist/src/api/lib/cron.js +1 -22
  14. package/dist/src/api/lib/logger-middleware.js +1 -35
  15. package/dist/src/api/lib/module.js +1 -22
  16. package/dist/src/api/lib/plugin.js +1 -22
  17. package/dist/src/api/lib/route.js +1 -27
  18. package/dist/src/api/lib/with-pagination.js +1 -83
  19. package/dist/src/api/middlewares/captcha.middleware.js +1 -63
  20. package/dist/src/api/middlewares/cron-auth.middleware.js +1 -19
  21. package/dist/src/api/middlewares/global.middleware.d.ts.map +1 -1
  22. package/dist/src/api/middlewares/global.middleware.js +1 -104
  23. package/dist/src/api/middlewares/rate-limiter.middleware.js +1 -32
  24. package/dist/src/api/models/device.js +1 -61
  25. package/dist/src/api/models/email.d.ts.map +1 -1
  26. package/dist/src/api/models/email.js +1 -77
  27. package/dist/src/api/models/password.js +1 -36
  28. package/dist/src/api/models/session-admin.d.ts.map +1 -1
  29. package/dist/src/api/models/session-admin.js +1 -97
  30. package/dist/src/api/models/session.d.ts.map +1 -1
  31. package/dist/src/api/models/session.js +1 -76
  32. package/dist/src/api/models/sso.js +1 -120
  33. package/dist/src/api/models/user/get-user-by-id.js +1 -19
  34. package/dist/src/api/models/user/sign-in-with-passwords.js +1 -22
  35. package/dist/src/api/models/user/sign-up.js +1 -73
  36. package/dist/src/api/models/user.js +1 -8
  37. package/dist/src/api/modules/admin/admin.module.js +1 -19
  38. package/dist/src/api/modules/admin/advanced/advanced.admin.module.js +1 -11
  39. package/dist/src/api/modules/admin/advanced/cron/cron.admin.module.js +1 -12
  40. package/dist/src/api/modules/admin/advanced/cron/routes/get.route.js +1 -66
  41. package/dist/src/api/modules/admin/advanced/cron/routes/run.route.js +1 -95
  42. package/dist/src/api/modules/admin/debug/debug.admin.module.js +1 -10
  43. package/dist/src/api/modules/admin/debug/routes/logs.route.js +1 -94
  44. package/dist/src/api/modules/admin/routes/session.route.js +1 -47
  45. package/dist/src/api/modules/admin/users/routes/list.route.js +1 -79
  46. package/dist/src/api/modules/admin/users/routes/users.route.js +1 -84
  47. package/dist/src/api/modules/admin/users/users.admin.module.js +1 -10
  48. package/dist/src/api/modules/cron/cron/clean.cron.js +1 -24
  49. package/dist/src/api/modules/cron/cron.module.js +1 -14
  50. package/dist/src/api/modules/cron/helpers/process-cron-jobs.d.ts.map +1 -1
  51. package/dist/src/api/modules/cron/helpers/process-cron-jobs.js +1 -72
  52. package/dist/src/api/modules/cron/routes/cron.route.d.ts.map +1 -1
  53. package/dist/src/api/modules/cron/routes/cron.route.js +1 -95
  54. package/dist/src/api/modules/middleware/middleware.module.js +1 -10
  55. package/dist/src/api/modules/middleware/route.js +1 -49
  56. package/dist/src/api/modules/users/avatar-color.js +1 -43
  57. package/dist/src/api/modules/users/routes/change-password.route.js +1 -58
  58. package/dist/src/api/modules/users/routes/reset-passowrd.route.js +1 -91
  59. package/dist/src/api/modules/users/routes/session.route.js +1 -46
  60. package/dist/src/api/modules/users/routes/sign-in.route.js +1 -71
  61. package/dist/src/api/modules/users/routes/sign-out.route.js +1 -43
  62. package/dist/src/api/modules/users/routes/sign-up.route.js +1 -77
  63. package/dist/src/api/modules/users/routes/test.route.js +1 -33
  64. package/dist/src/api/modules/users/sso/routes/callback.route.js +1 -52
  65. package/dist/src/api/modules/users/sso/routes/create-url.route.js +1 -36
  66. package/dist/src/api/modules/users/sso/sso.module.js +1 -12
  67. package/dist/src/api/modules/users/users.module.js +1 -26
  68. package/dist/src/api/plugin.js +1 -15
  69. package/dist/src/app/login/page.js +1 -16
  70. package/dist/src/app/login/reset-password/page.js +1 -18
  71. package/dist/src/app/login/sso/[providerId]/page.js +1 -10
  72. package/dist/src/app/register/page.js +1 -16
  73. package/dist/src/app_admin/core/advanced/cron/page.js +1 -42
  74. package/dist/src/app_admin/core/debug/page.js +1 -45
  75. package/dist/src/app_admin/core/page.js +1 -5
  76. package/dist/src/app_admin/core/test/page.js +1 -5
  77. package/dist/src/app_admin/core/users/page.js +1 -38
  78. package/dist/src/components/avatar.js +1 -14
  79. package/dist/src/components/confirm-action/confirm-action-alert-dialog.js +1 -42
  80. package/dist/src/components/confirm-action/content.js +1 -31
  81. package/dist/src/components/date-format.js +1 -41
  82. package/dist/src/components/form/auto-form.js +1 -103
  83. package/dist/src/components/form/common/desc.js +1 -9
  84. package/dist/src/components/form/common/label.js +1 -18
  85. package/dist/src/components/form/fields/checkbox.js +1 -37
  86. package/dist/src/components/form/fields/combobox-async.js +1 -123
  87. package/dist/src/components/form/fields/combobox.js +1 -87
  88. package/dist/src/components/form/fields/input.js +1 -39
  89. package/dist/src/components/form/fields/radio-group.js +1 -50
  90. package/dist/src/components/form/fields/select.js +1 -58
  91. package/dist/src/components/form/fields/switch.js +1 -36
  92. package/dist/src/components/form/fields/textarea.js +1 -36
  93. package/dist/src/components/i18n-provider.js +1 -43
  94. package/dist/src/components/logo-vitnode.js +1 -119
  95. package/dist/src/components/switchers/langs/language-switcher.js +1 -47
  96. package/dist/src/components/switchers/themes/theme-switcher.js +1 -28
  97. package/dist/src/components/table/content.js +1 -81
  98. package/dist/src/components/table/data-table.js +1 -68
  99. package/dist/src/components/table/order-table-head.js +1 -50
  100. package/dist/src/components/table/pagination.js +1 -122
  101. package/dist/src/components/tiptap/extension.js +1 -33
  102. package/dist/src/components/tiptap/toolbar/actions/alignment-action.js +1 -91
  103. package/dist/src/components/tiptap/toolbar/actions/bold-action.js +1 -39
  104. package/dist/src/components/tiptap/toolbar/actions/headings-action.js +1 -93
  105. package/dist/src/components/tiptap/toolbar/actions/italic-action.js +1 -38
  106. package/dist/src/components/tiptap/toolbar/actions/list-action.js +1 -61
  107. package/dist/src/components/tiptap/toolbar/actions/text-format-more/text-format-more.js +1 -59
  108. package/dist/src/components/tiptap/toolbar/actions/underline-action.js +1 -38
  109. package/dist/src/components/tiptap/toolbar/actions/undo-redo-actions.js +1 -63
  110. package/dist/src/components/tiptap/toolbar/actions/utils/tooltip-shortcut.js +1 -11
  111. package/dist/src/components/tiptap/toolbar/tiptap-toolbar.js +1 -55
  112. package/dist/src/components/tiptap/toolbar/use-toolbar-editor.js +1 -5
  113. package/dist/src/components/ui/accordion.js +1 -46
  114. package/dist/src/components/ui/alert-dialog.js +1 -123
  115. package/dist/src/components/ui/alert.js +1 -39
  116. package/dist/src/components/ui/badge.js +1 -28
  117. package/dist/src/components/ui/button-client.js +1 -57
  118. package/dist/src/components/ui/button.js +1 -32
  119. package/dist/src/components/ui/card.js +1 -52
  120. package/dist/src/components/ui/checkbox.js +1 -20
  121. package/dist/src/components/ui/collapsible.js +1 -22
  122. package/dist/src/components/ui/command.js +1 -98
  123. package/dist/src/components/ui/context-menu.js +1 -140
  124. package/dist/src/components/ui/dialog.js +1 -189
  125. package/dist/src/components/ui/drawer.js +1 -83
  126. package/dist/src/components/ui/dropdown-menu.js +1 -141
  127. package/dist/src/components/ui/editor-content.js +1 -10
  128. package/dist/src/components/ui/editor.js +1 -35
  129. package/dist/src/components/ui/form.js +1 -148
  130. package/dist/src/components/ui/header-content.js +1 -30
  131. package/dist/src/components/ui/hover-card.js +1 -29
  132. package/dist/src/components/ui/input-otp.js +1 -48
  133. package/dist/src/components/ui/input.js +1 -11
  134. package/dist/src/components/ui/label.js +1 -12
  135. package/dist/src/components/ui/loader.js +1 -16
  136. package/dist/src/components/ui/menubar.js +1 -151
  137. package/dist/src/components/ui/navigation-menu.js +1 -82
  138. package/dist/src/components/ui/popover.js +1 -35
  139. package/dist/src/components/ui/progress.js +1 -19
  140. package/dist/src/components/ui/radio-group.js +1 -27
  141. package/dist/src/components/ui/scroll-area.js +1 -33
  142. package/dist/src/components/ui/select.js +1 -113
  143. package/dist/src/components/ui/separator.js +1 -14
  144. package/dist/src/components/ui/sheet.js +1 -92
  145. package/dist/src/components/ui/sidebar.js +1 -433
  146. package/dist/src/components/ui/skeleton.js +1 -10
  147. package/dist/src/components/ui/slider.js +1 -50
  148. package/dist/src/components/ui/sonner.js +1 -26
  149. package/dist/src/components/ui/switch.js +1 -16
  150. package/dist/src/components/ui/table.js +1 -63
  151. package/dist/src/components/ui/tabs.js +1 -33
  152. package/dist/src/components/ui/textarea.js +1 -10
  153. package/dist/src/components/ui/toggle-group.js +1 -45
  154. package/dist/src/components/ui/toggle.js +1 -34
  155. package/dist/src/components/ui/tooltip.js +1 -57
  156. package/dist/src/config.js +1 -4
  157. package/dist/src/database/admins.js +1 -74
  158. package/dist/src/database/cron.js +1 -22
  159. package/dist/src/database/languages.js +1 -52
  160. package/dist/src/database/logs.js +1 -34
  161. package/dist/src/database/moderators.js +1 -37
  162. package/dist/src/database/roles.js +1 -13
  163. package/dist/src/database/sessions.js +1 -60
  164. package/dist/src/database/users.js +1 -145
  165. package/dist/src/drizzle.config.js +1 -67
  166. package/dist/src/emails/default-template.js +1 -99
  167. package/dist/src/emails/reset-password.js +1 -132
  168. package/dist/src/emails/ui/button.js +1 -36
  169. package/dist/src/emails/ui/card.js +1 -39
  170. package/dist/src/hooks/use-before-unload.js +1 -30
  171. package/dist/src/hooks/use-captcha.js +1 -122
  172. package/dist/src/hooks/use-mobile.js +1 -16
  173. package/dist/src/lib/api/get-middleware-api.js +1 -13
  174. package/dist/src/lib/api/get-next-cron-run-date.js +1 -14
  175. package/dist/src/lib/api/get-next-cron-run-date.test.js +1 -55
  176. package/dist/src/lib/api/get-session-admin-api.js +1 -19
  177. package/dist/src/lib/api/get-session-api.js +1 -14
  178. package/dist/src/lib/api/should-cron-job-run.js +1 -16
  179. package/dist/src/lib/api/should-cron-job-run.test.js +1 -213
  180. package/dist/src/lib/api/validate-cron-schedule.d.ts +2 -0
  181. package/dist/src/lib/api/validate-cron-schedule.d.ts.map +1 -0
  182. package/dist/src/lib/api/validate-cron-schedule.js +1 -0
  183. package/dist/src/lib/api/validate-cron-schedule.test.d.ts +2 -0
  184. package/dist/src/lib/api/validate-cron-schedule.test.d.ts.map +1 -0
  185. package/dist/src/lib/api/validate-cron-schedule.test.js +1 -0
  186. package/dist/src/lib/colors.js +1 -140
  187. package/dist/src/lib/colors.test.js +1 -173
  188. package/dist/src/lib/config.js +1 -14
  189. package/dist/src/lib/ctrl-or-command-character.js +1 -5
  190. package/dist/src/lib/fetcher/cookie-from-string-to-object.js +1 -12
  191. package/dist/src/lib/fetcher/cookie-from-string-to-object.test.js +1 -78
  192. package/dist/src/lib/fetcher/core.js +3 -48
  193. package/dist/src/lib/fetcher/helpers-server.js +1 -18
  194. package/dist/src/lib/fetcher/helpers.js +1 -16
  195. package/dist/src/lib/fetcher/helpers.test.js +1 -37
  196. package/dist/src/lib/fetcher/types.js +1 -1
  197. package/dist/src/lib/fetcher-client.js +1 -17
  198. package/dist/src/lib/fetcher.js +1 -33
  199. package/dist/src/lib/helpers/auto-form.js +1 -98
  200. package/dist/src/lib/helpers/auto-form.test.js +1 -336
  201. package/dist/src/lib/navigation.d.ts +15 -13
  202. package/dist/src/lib/navigation.d.ts.map +1 -1
  203. package/dist/src/lib/navigation.js +1 -11
  204. package/dist/src/lib/plugin.js +1 -3
  205. package/dist/src/lib/special-characters.js +1 -4
  206. package/dist/src/lib/special-characters.test.js +1 -56
  207. package/dist/src/lib/utils.js +1 -5
  208. package/dist/src/locales/en.json +308 -0
  209. package/dist/src/tests/setup.js +1 -6
  210. package/dist/src/views/admin/layouts/admin-layout.js +1 -73
  211. package/dist/src/views/admin/layouts/sidebar/nav/item.js +1 -98
  212. package/dist/src/views/admin/layouts/sidebar/nav/nav.js +1 -60
  213. package/dist/src/views/admin/layouts/sidebar/sidebar.js +1 -28
  214. package/dist/src/views/admin/layouts/sidebar/sign-out.js +1 -14
  215. package/dist/src/views/admin/layouts/user-bar/client.js +1 -69
  216. package/dist/src/views/admin/layouts/user-bar/user-bar.js +1 -32
  217. package/dist/src/views/admin/sign-in/sign-in-admin-view.js +1 -27
  218. package/dist/src/views/admin/views/core/advanced/cron/cron-table-view.js +1 -97
  219. package/dist/src/views/admin/views/core/advanced/cron/run-action/mutation-api.js +1 -23
  220. package/dist/src/views/admin/views/core/advanced/cron/run-action/run-action.js +1 -38
  221. package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.js +1 -44
  222. package/dist/src/views/admin/views/core/debug/actions/clear-cache/clear-cache.js +1 -35
  223. package/dist/src/views/admin/views/core/debug/actions/clear-cache/mutation-api.js +1 -5
  224. package/dist/src/views/admin/views/core/debug/system-logs/actions/more/content.js +1 -281
  225. package/dist/src/views/admin/views/core/debug/system-logs/actions/more/more.js +1 -67
  226. package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-status.js +1 -14
  227. package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-type-log.js +1 -30
  228. package/dist/src/views/admin/views/core/debug/system-logs/system-logs-view.js +1 -96
  229. package/dist/src/views/admin/views/core/test.js +1 -161
  230. package/dist/src/views/admin/views/core/users/users-admin-view.js +1 -89
  231. package/dist/src/views/auth/password-reset/change-password-form/form.js +1 -48
  232. package/dist/src/views/auth/password-reset/change-password-form/mutation-api.js +1 -22
  233. package/dist/src/views/auth/password-reset/change-password-form/use-form.js +1 -36
  234. package/dist/src/views/auth/password-reset/form/form.js +1 -104
  235. package/dist/src/views/auth/password-reset/form/mutation-api.js +1 -21
  236. package/dist/src/views/auth/password-reset/form/use-form.js +1 -33
  237. package/dist/src/views/auth/password-reset/password-reset-view.js +1 -37
  238. package/dist/src/views/auth/sign-in/form/form.js +1 -64
  239. package/dist/src/views/auth/sign-in/form/mutation-api.js +1 -33
  240. package/dist/src/views/auth/sign-in/form/use-form.d.ts.map +1 -1
  241. package/dist/src/views/auth/sign-in/form/use-form.js +1 -38
  242. package/dist/src/views/auth/sign-in/sign-in-view.js +1 -61
  243. package/dist/src/views/auth/sign-up/components/password-input.js +1 -96
  244. package/dist/src/views/auth/sign-up/email-confirmation-view.js +1 -55
  245. package/dist/src/views/auth/sign-up/form/form.js +1 -89
  246. package/dist/src/views/auth/sign-up/form/mutation-api.js +1 -30
  247. package/dist/src/views/auth/sign-up/form/use-form.js +1 -70
  248. package/dist/src/views/auth/sign-up/sign-up-view.js +1 -65
  249. package/dist/src/views/auth/sign-up/wrapper.js +1 -22
  250. package/dist/src/views/auth/sso/buttons/client.js +1 -22
  251. package/dist/src/views/auth/sso/buttons/mutation-api.js +1 -24
  252. package/dist/src/views/auth/sso/buttons/sso-buttons.js +1 -56
  253. package/dist/src/views/auth/sso/callback/callback-sso-view.js +1 -32
  254. package/dist/src/views/auth/sso/callback/client/client.js +1 -68
  255. package/dist/src/views/auth/sso/callback/client/mutation-api.js +1 -32
  256. package/dist/src/views/error/back-button.js +1 -14
  257. package/dist/src/views/error/error-view.js +1 -58
  258. package/dist/src/views/error/global-error-view.js +1 -50
  259. package/dist/src/views/layouts/provider.js +1 -44
  260. package/dist/src/views/layouts/root-layout.js +1 -25
  261. package/dist/src/views/layouts/theme/header/header.js +1 -38
  262. package/dist/src/views/layouts/theme/header/user/auth/auth.js +1 -33
  263. package/dist/src/views/layouts/theme/header/user/auth/client.js +1 -47
  264. package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.js +1 -27
  265. package/dist/src/views/layouts/theme/header/user/user.js +1 -32
  266. package/dist/src/views/layouts/theme/layout.js +1 -16
  267. package/dist/src/vitnode.config.d.ts.map +1 -1
  268. package/dist/src/vitnode.config.js +1 -42
  269. package/dist/tsconfig.tsbuildinfo +1 -1
  270. package/dist/tsup.config.js +18 -0
  271. package/dist/vitest.config.d.ts.map +1 -1
  272. package/dist/vitest.config.js +49 -0
  273. package/eslint.config.mjs +2 -0
  274. package/package.json +40 -44
  275. package/dist/src/api/adapters/cron/node-cron.adapter.d.ts +0 -3
  276. package/dist/src/api/adapters/cron/node-cron.adapter.d.ts.map +0 -1
  277. package/dist/src/api/adapters/cron/node-cron.adapter.js +0 -11
  278. package/dist/src/api/adapters/email/nodemailer.d.ts +0 -10
  279. package/dist/src/api/adapters/email/nodemailer.d.ts.map +0 -1
  280. package/dist/src/api/adapters/email/nodemailer.js +0 -30
  281. package/dist/src/api/adapters/email/resend.d.ts +0 -6
  282. package/dist/src/api/adapters/email/resend.d.ts.map +0 -1
  283. package/dist/src/api/adapters/email/resend.js +0 -21
@@ -1,91 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
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 { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
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 { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
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 { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
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 { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
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 { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
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 "react";
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};