@tulip-systems/core 0.5.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/common/icons.d.mts +52 -52
- package/dist/components/common/icons.d.mts.map +1 -1
- package/dist/components/common/status.d.mts +3 -3
- package/dist/components/common/status.d.mts.map +1 -1
- package/dist/components/editor/components/content.client.d.mts +2 -2
- package/dist/components/editor/components/editor.client.d.mts +4 -4
- package/dist/components/editor/components/editor.client.mjs +2 -2
- package/dist/components/editor/components/editor.client.mjs.map +1 -1
- package/dist/components/editor/components/menu.client.d.mts +3 -3
- package/dist/components/editor/components/menu.client.mjs +3 -0
- package/dist/components/editor/components/menu.client.mjs.map +1 -1
- package/dist/components/editor/extensions/file-handler/extension.d.mts +21 -0
- package/dist/components/editor/extensions/file-handler/extension.d.mts.map +1 -0
- package/dist/components/editor/extensions/file-handler/extension.mjs +40 -0
- package/dist/components/editor/extensions/file-handler/extension.mjs.map +1 -0
- package/dist/components/editor/extensions/file-handler/strategy.d.mts +29 -0
- package/dist/components/editor/extensions/file-handler/strategy.d.mts.map +1 -0
- package/dist/components/editor/extensions/file-handler/strategy.mjs +111 -0
- package/dist/components/editor/extensions/file-handler/strategy.mjs.map +1 -0
- package/dist/components/editor/extensions/file-handler/utils.mjs +50 -0
- package/dist/components/editor/extensions/file-handler/utils.mjs.map +1 -0
- package/dist/components/editor/extensions/image/extension.d.mts +8 -0
- package/dist/components/editor/extensions/image/extension.d.mts.map +1 -0
- package/dist/components/editor/extensions/image/extension.mjs +52 -0
- package/dist/components/editor/extensions/image/extension.mjs.map +1 -0
- package/dist/components/editor/extensions/skeleton/extension.mjs +41 -0
- package/dist/components/editor/extensions/skeleton/extension.mjs.map +1 -0
- package/dist/components/editor/extensions/skeleton/renderer.mjs +25 -0
- package/dist/components/editor/extensions/skeleton/renderer.mjs.map +1 -0
- package/dist/components/editor/lib/constants.d.mts +29 -26
- package/dist/components/editor/lib/constants.d.mts.map +1 -1
- package/dist/components/editor/lib/constants.mjs +14 -2
- package/dist/components/editor/lib/constants.mjs.map +1 -1
- package/dist/components/editor/lib/extensions.d.mts +5 -1
- package/dist/components/editor/lib/extensions.d.mts.map +1 -1
- package/dist/components/editor/lib/extensions.mjs.map +1 -1
- package/dist/components/editor/lib/variants.mjs +10 -2
- package/dist/components/editor/lib/variants.mjs.map +1 -1
- package/dist/components/header/back-button.client.d.mts +2 -2
- package/dist/components/header/bottom-bar.client.d.mts +3 -3
- package/dist/components/header/breadcrumbs.client.d.mts +7 -7
- package/dist/components/header/header.client.d.mts +2 -2
- package/dist/components/header/mobile-nav-switcher.client.d.mts +2 -2
- package/dist/components/header/top-bar.client.d.mts +4 -4
- package/dist/components/layouts/admin-content.client.d.mts +2 -2
- package/dist/components/layouts/admin-layout.d.mts +2 -2
- package/dist/components/layouts/admin-loading.d.mts +2 -2
- package/dist/components/layouts/admin-loading.d.mts.map +1 -1
- package/dist/components/layouts/empty-page.d.mts +4 -4
- package/dist/components/layouts/empty-page.d.mts.map +1 -1
- package/dist/components/layouts/list-layout.d.mts +2 -2
- package/dist/components/layouts/list-layout.d.mts.map +1 -1
- package/dist/components/layouts/not-found-page.d.mts +3 -3
- package/dist/components/layouts/not-found-page.d.mts.map +1 -1
- package/dist/components/layouts/providers.client.d.mts +2 -2
- package/dist/components/layouts/root-layout.server.d.mts +2 -2
- package/dist/components/layouts/root-layout.server.d.mts.map +1 -1
- package/dist/components/layouts/root-loading.d.mts +2 -2
- package/dist/components/layouts/root-loading.d.mts.map +1 -1
- package/dist/components/layouts/tab-layout.d.mts +2 -2
- package/dist/components/layouts/tab-layout.d.mts.map +1 -1
- package/dist/components/lists/data-list.d.mts +5 -5
- package/dist/components/lists/data-list.d.mts.map +1 -1
- package/dist/components/lists/data-stack.d.mts +8 -8
- package/dist/components/navigation/admin-sidebar-paths.client.d.mts +10 -10
- package/dist/components/ui/accordion.d.mts +5 -5
- package/dist/components/ui/alert-dialog.d.mts +12 -12
- package/dist/components/ui/alert.d.mts +6 -6
- package/dist/components/ui/aspect-ratio.d.mts +2 -2
- package/dist/components/ui/avatar.client.d.mts +4 -4
- package/dist/components/ui/badge.d.mts +4 -4
- package/dist/components/ui/breadcrumb.d.mts +8 -8
- package/dist/components/ui/breadcrumb.d.mts.map +1 -1
- package/dist/components/ui/button.d.mts +5 -5
- package/dist/components/ui/button.d.mts.map +1 -1
- package/dist/components/ui/calendar.d.mts +3 -3
- package/dist/components/ui/calendar.d.mts.map +1 -1
- package/dist/components/ui/card.d.mts +7 -7
- package/dist/components/ui/card.d.mts.map +1 -1
- package/dist/components/ui/carousel.d.mts +6 -6
- package/dist/components/ui/carousel.d.mts.map +1 -1
- package/dist/components/ui/chart.client.d.mts +5 -5
- package/dist/components/ui/checkbox.d.mts +2 -2
- package/dist/components/ui/checkbox.d.mts.map +1 -1
- package/dist/components/ui/collapsible.client.d.mts +4 -4
- package/dist/components/ui/color-picker.client.d.mts +2 -2
- package/dist/components/ui/combobox-dropdown.client.d.mts +2 -2
- package/dist/components/ui/combobox.client.d.mts +2 -2
- package/dist/components/ui/command.d.mts +10 -10
- package/dist/components/ui/command.d.mts.map +1 -1
- package/dist/components/ui/context-menu.d.mts +16 -16
- package/dist/components/ui/date-picker.client.d.mts +2 -2
- package/dist/components/ui/dialog.client.d.mts +11 -11
- package/dist/components/ui/drawer.client.d.mts +11 -11
- package/dist/components/ui/dropdown-menu.d.mts +16 -16
- package/dist/components/ui/form.client.d.mts +7 -7
- package/dist/components/ui/hover-card.client.d.mts +4 -4
- package/dist/components/ui/input-recipient.d.mts +2 -2
- package/dist/components/ui/input.d.mts +2 -2
- package/dist/components/ui/label.d.mts +2 -2
- package/dist/components/ui/navigation-menu.d.mts +11 -11
- package/dist/components/ui/pagination.d.mts +8 -8
- package/dist/components/ui/popover.d.mts +5 -5
- package/dist/components/ui/popover.d.mts.map +1 -1
- package/dist/components/ui/progress.client.d.mts +2 -2
- package/dist/components/ui/radio-group.d.mts +3 -3
- package/dist/components/ui/resizable.client.d.mts +4 -4
- package/dist/components/ui/scroll-area.d.mts +3 -3
- package/dist/components/ui/select.client.d.mts +11 -11
- package/dist/components/ui/separator.d.mts +2 -2
- package/dist/components/ui/sheet.client.d.mts +9 -9
- package/dist/components/ui/sidebar.client.d.mts +24 -24
- package/dist/components/ui/skeleton.d.mts +2 -2
- package/dist/components/ui/slider.d.mts +2 -2
- package/dist/components/ui/sonner.client.d.mts +2 -2
- package/dist/components/ui/switch.d.mts +2 -2
- package/dist/components/ui/tabs.d.mts +5 -5
- package/dist/components/ui/textarea.d.mts +2 -2
- package/dist/components/ui/time-input.client.d.mts +2 -2
- package/dist/components/ui/toggle-group.client.d.mts +3 -3
- package/dist/components/ui/toggle.d.mts +2 -2
- package/dist/components/ui/tooltip.client.d.mts +5 -5
- package/dist/components.d.mts +2 -1
- package/dist/components.mjs +3 -2
- package/dist/data-tables.d.mts +2 -2
- package/dist/data-tables.mjs +2 -2
- package/dist/inline-edit/client.d.mts +2 -3
- package/dist/inline-edit/client.mjs +1 -2
- package/dist/lib/client.d.mts +2 -2
- package/dist/lib/client.mjs +2 -2
- package/dist/lib/hooks/use-action.d.mts +2 -2
- package/dist/lib/hooks/use-indicator.d.mts +11 -3
- package/dist/lib/hooks/use-indicator.d.mts.map +1 -1
- package/dist/lib/hooks/use-indicator.mjs +19 -8
- package/dist/lib/hooks/use-indicator.mjs.map +1 -1
- package/dist/modules/auth/components/allowed.client.d.mts +2 -2
- package/dist/modules/auth/components/allowed.client.d.mts.map +1 -1
- package/dist/modules/auth/components/auth-layout.server.d.mts +2 -2
- package/dist/modules/auth/components/auth-layout.server.d.mts.map +1 -1
- package/dist/modules/auth/components/auth-loading.d.mts +2 -2
- package/dist/modules/auth/components/create-first-user-page.client.d.mts +2 -2
- package/dist/modules/auth/components/create-first-user-page.client.d.mts.map +1 -1
- package/dist/modules/auth/components/forget-password-page.client.d.mts +2 -2
- package/dist/modules/auth/components/forget-password-page.client.d.mts.map +1 -1
- package/dist/modules/auth/components/guard-first-user.server.d.mts +2 -2
- package/dist/modules/auth/components/guard-first-user.server.d.mts.map +1 -1
- package/dist/modules/auth/components/guard.server.d.mts +2 -2
- package/dist/modules/auth/components/guard.server.d.mts.map +1 -1
- package/dist/modules/auth/components/login-page.client.d.mts +2 -2
- package/dist/modules/auth/components/login-page.client.d.mts.map +1 -1
- package/dist/modules/auth/components/reset-password-page.client.d.mts +2 -2
- package/dist/modules/auth/components/reset-password-page.client.d.mts.map +1 -1
- package/dist/modules/auth/components/update-password-command.d.mts +2 -2
- package/dist/modules/auth/components/update-password-command.d.mts.map +1 -1
- package/dist/modules/auth/db/schema.d.mts +73 -73
- package/dist/modules/auth/db/schema.d.mts.map +1 -1
- package/dist/modules/auth/handler/client.client.d.mts +8 -8
- package/dist/modules/auth/hooks/use-permission.d.mts +2 -2
- package/dist/modules/auth/hooks/use-session.d.mts +4 -4
- package/dist/modules/auth/lib/validators.d.mts +2 -2
- package/dist/modules/auth/lib/validators.d.mts.map +1 -1
- package/dist/modules/commands/components/alert-dialog-command.client.d.mts +10 -10
- package/dist/modules/commands/components/alert-dialog-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/click-command.client.d.mts +2 -2
- package/dist/modules/commands/components/click-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/command-trigger.client.d.mts +6 -6
- package/dist/modules/commands/components/command-trigger.client.d.mts.map +1 -1
- package/dist/modules/commands/components/dialog-command.client.d.mts +8 -8
- package/dist/modules/commands/components/dialog-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/dropdown-command.client.d.mts +5 -5
- package/dist/modules/commands/components/dropdown-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/empty-command.client.d.mts +2 -2
- package/dist/modules/commands/components/empty-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/form-dialog-command.client.d.mts +11 -11
- package/dist/modules/commands/components/form-dialog-command.client.d.mts.map +1 -1
- package/dist/modules/commands/hooks/use-command-mutation.client.d.mts +2 -2
- package/dist/modules/commands/menus/context-menu.client.d.mts +2 -2
- package/dist/modules/commands/menus/context-menu.client.d.mts.map +1 -1
- package/dist/modules/commands/menus/dropdown-menu.client.d.mts +3 -3
- package/dist/modules/commands/menus/dropdown-menu.client.d.mts.map +1 -1
- package/dist/modules/commands/menus/inline-menu.client.d.mts +3 -3
- package/dist/modules/commands/menus/inline-menu.client.d.mts.map +1 -1
- package/dist/modules/commands/menus/responsive-menu.client.d.mts +3 -3
- package/dist/modules/commands/menus/responsive-menu.client.d.mts.map +1 -1
- package/dist/modules/commands/utils/archive-command.client.d.mts +3 -3
- package/dist/modules/commands/utils/archive-command.client.d.mts.map +1 -1
- package/dist/modules/commands/utils/delete-command.client.d.mts +3 -3
- package/dist/modules/commands/utils/delete-command.client.d.mts.map +1 -1
- package/dist/modules/config/db/helpers.d.mts +5 -5
- package/dist/modules/config/db/helpers.d.mts.map +1 -1
- package/dist/modules/data-tables/components/cell/common.client.d.mts +5 -5
- package/dist/modules/data-tables/components/cell/common.client.d.mts.map +1 -1
- package/dist/modules/data-tables/components/column-header.d.mts +2 -2
- package/dist/modules/data-tables/components/filters/combobox.client.d.mts +2 -2
- package/dist/modules/data-tables/components/filters/combobox.client.d.mts.map +1 -1
- package/dist/modules/data-tables/components/filters/slider.client.d.mts +2 -2
- package/dist/modules/data-tables/components/filters/slider.client.d.mts.map +1 -1
- package/dist/modules/data-tables/components/header.d.mts +4 -4
- package/dist/modules/data-tables/components/layout.d.mts +2 -2
- package/dist/modules/data-tables/components/search-input.client.d.mts +2 -2
- package/dist/modules/data-tables/components/search-input.client.d.mts.map +1 -1
- package/dist/modules/data-tables/components/skeleton.d.mts +2 -2
- package/dist/modules/data-tables/components/table.d.mts +7 -7
- package/dist/modules/data-tables/components/toolbar.d.mts +3 -3
- package/dist/modules/data-tables/hooks/use-context.client.d.mts +2 -2
- package/dist/modules/data-tables/hooks/use-context.client.d.mts.map +1 -1
- package/dist/modules/data-tables/lib/filters/parsers.d.mts +6 -1
- package/dist/modules/data-tables/lib/filters/parsers.d.mts.map +1 -1
- package/dist/modules/data-tables/lib/filters/parsers.mjs +6 -1
- package/dist/modules/data-tables/lib/filters/parsers.mjs.map +1 -1
- package/dist/modules/data-tables/tables/data-table/components/table.d.mts +2 -2
- package/dist/modules/data-tables/tables/data-table/components/table.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/cells/common.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/cells/common.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/inputs/advanced-select.client.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/inputs/advanced-select.client.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/inputs/combobox.client.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/inputs/combobox.client.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/inputs/input.client.d.mts +3 -3
- package/dist/modules/data-tables/tables/inline-table/components/inputs/input.client.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/inputs/read-only.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/inputs/read-only.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/inputs/select.client.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/inputs/select.client.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/table.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/table.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/combobox-dropdown.client.d.mts +6 -4
- package/dist/modules/inline-edit/components/combobox-dropdown.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/combobox-dropdown.client.mjs +11 -6
- package/dist/modules/inline-edit/components/combobox-dropdown.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/combobox.client.d.mts +6 -4
- package/dist/modules/inline-edit/components/combobox.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/combobox.client.mjs +7 -5
- package/dist/modules/inline-edit/components/combobox.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/date-input.client.d.mts +5 -3
- package/dist/modules/inline-edit/components/date-input.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/date-input.client.mjs +26 -13
- package/dist/modules/inline-edit/components/date-input.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/date-picker.client.d.mts +6 -4
- package/dist/modules/inline-edit/components/date-picker.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/date-picker.client.mjs +12 -7
- package/dist/modules/inline-edit/components/date-picker.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/editor.client.d.mts +6 -4
- package/dist/modules/inline-edit/components/editor.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/editor.client.mjs +11 -6
- package/dist/modules/inline-edit/components/editor.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/input-recipient.client.d.mts +6 -4
- package/dist/modules/inline-edit/components/input-recipient.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/input-recipient.client.mjs +11 -6
- package/dist/modules/inline-edit/components/input-recipient.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/input-toggle.client.d.mts +6 -4
- package/dist/modules/inline-edit/components/input-toggle.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/input-toggle.client.mjs +9 -7
- package/dist/modules/inline-edit/components/input-toggle.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/input.client.d.mts +13 -10
- package/dist/modules/inline-edit/components/input.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/input.client.mjs +35 -19
- package/dist/modules/inline-edit/components/input.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/select.client.d.mts +10 -9
- package/dist/modules/inline-edit/components/select.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/select.client.mjs +14 -7
- package/dist/modules/inline-edit/components/select.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/switch.client.d.mts +5 -3
- package/dist/modules/inline-edit/components/switch.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/switch.client.mjs +8 -6
- package/dist/modules/inline-edit/components/switch.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/toggle.client.d.mts +6 -4
- package/dist/modules/inline-edit/components/toggle.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/toggle.client.mjs +9 -7
- package/dist/modules/inline-edit/components/toggle.client.mjs.map +1 -1
- package/dist/modules/inline-edit/hooks/use-inline.client.d.mts +35 -3
- package/dist/modules/inline-edit/hooks/use-inline.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/hooks/use-inline.client.mjs +71 -9
- package/dist/modules/inline-edit/hooks/use-inline.client.mjs.map +1 -1
- package/dist/modules/inline-edit/lib/variants.d.mts +1 -0
- package/dist/modules/inline-edit/lib/variants.d.mts.map +1 -1
- package/dist/modules/inline-edit/lib/variants.mjs +12 -4
- package/dist/modules/inline-edit/lib/variants.mjs.map +1 -1
- package/dist/modules/router/handler/init.server.d.mts +6 -6
- package/dist/modules/router/handler/init.server.d.mts.map +1 -1
- package/dist/modules/router/lib/query-client.server.d.mts +2 -2
- package/dist/modules/storage/components/dropzone-context.client.d.mts +2 -2
- package/dist/modules/storage/components/dropzone-context.client.d.mts.map +1 -1
- package/dist/modules/storage/components/dropzone.client.d.mts +5 -5
- package/dist/modules/storage/components/dropzone.client.d.mts.map +1 -1
- package/dist/modules/storage/components/dropzone.client.mjs +1 -1
- package/dist/modules/storage/components/image-grid.client.d.mts +3 -3
- package/dist/modules/storage/components/image-grid.client.d.mts.map +1 -1
- package/dist/modules/storage/components/image-grid.client.mjs +3 -3
- package/dist/modules/storage/components/image-grid.client.mjs.map +1 -1
- package/dist/modules/storage/components/upload-zone-context.client.d.mts +3 -11
- package/dist/modules/storage/components/upload-zone-context.client.d.mts.map +1 -1
- package/dist/modules/storage/components/upload-zone-context.client.mjs.map +1 -1
- package/dist/modules/storage/components/upload-zone.client.d.mts +10 -31
- package/dist/modules/storage/components/upload-zone.client.d.mts.map +1 -1
- package/dist/modules/storage/components/upload-zone.client.mjs +19 -91
- package/dist/modules/storage/components/upload-zone.client.mjs.map +1 -1
- package/dist/modules/storage/config/filters.d.mts +2 -0
- package/dist/modules/storage/config/filters.d.mts.map +1 -1
- package/dist/modules/storage/config/filters.mjs +3 -1
- package/dist/modules/storage/config/filters.mjs.map +1 -1
- package/dist/modules/storage/lib/create-upload.client.d.mts +56 -0
- package/dist/modules/storage/lib/create-upload.client.d.mts.map +1 -0
- package/dist/modules/storage/lib/create-upload.client.mjs +98 -0
- package/dist/modules/storage/lib/create-upload.client.mjs.map +1 -0
- package/dist/modules/storage/lib/helpers.d.mts +2 -2
- package/dist/modules/storage/lib/helpers.d.mts.map +1 -1
- package/dist/modules/storage/lib/helpers.mjs +1 -0
- package/dist/modules/storage/lib/helpers.mjs.map +1 -1
- package/dist/modules/storage/lib/router.server.d.mts +4181 -2283
- package/dist/modules/storage/lib/router.server.d.mts.map +1 -1
- package/dist/modules/storage/lib/router.server.mjs +5 -2
- package/dist/modules/storage/lib/router.server.mjs.map +1 -1
- package/dist/modules/storage/lib/schema.d.mts +156 -88
- package/dist/modules/storage/lib/schema.d.mts.map +1 -1
- package/dist/modules/storage/lib/schema.mjs +3 -1
- package/dist/modules/storage/lib/schema.mjs.map +1 -1
- package/dist/modules/storage/lib/service.server.d.mts +54 -38
- package/dist/modules/storage/lib/service.server.d.mts.map +1 -1
- package/dist/modules/storage/lib/service.server.mjs +11 -5
- package/dist/modules/storage/lib/service.server.mjs.map +1 -1
- package/dist/modules/storage/lib/validators.d.mts +232 -71
- package/dist/modules/storage/lib/validators.d.mts.map +1 -1
- package/dist/modules/storage/lib/validators.mjs +16 -25
- package/dist/modules/storage/lib/validators.mjs.map +1 -1
- package/dist/storage/client.d.mts +2 -1
- package/dist/storage/client.mjs +2 -8
- package/dist/storage.d.mts +3 -3
- package/dist/storage.mjs +3 -3
- package/package.json +2 -1
- package/src/components/editor/components/editor.client.tsx +7 -2
- package/src/components/editor/components/menu.client.tsx +26 -0
- package/src/components/editor/extensions/file-handler/extension.ts +69 -0
- package/src/components/editor/extensions/file-handler/strategy.ts +167 -0
- package/src/components/editor/extensions/file-handler/utils.ts +51 -0
- package/src/components/editor/extensions/image/extension.ts +57 -0
- package/src/components/editor/extensions/skeleton/extension.ts +35 -0
- package/src/components/editor/extensions/skeleton/renderer.tsx +14 -0
- package/src/components/editor/lib/constants.ts +16 -2
- package/src/components/editor/lib/extensions.ts +4 -1
- package/src/components/editor/lib/utils.ts +32 -0
- package/src/components/editor/lib/variants.ts +72 -1
- package/src/components/entry.ts +2 -1
- package/src/lib/hooks/use-indicator.tsx +27 -18
- package/src/modules/data-tables/lib/filters/parsers.ts +14 -0
- package/src/modules/inline-edit/components/combobox-dropdown.client.tsx +21 -12
- package/src/modules/inline-edit/components/combobox.client.tsx +13 -6
- package/src/modules/inline-edit/components/date-input.client.tsx +29 -13
- package/src/modules/inline-edit/components/date-picker.client.tsx +13 -9
- package/src/modules/inline-edit/components/editor.client.tsx +14 -14
- package/src/modules/inline-edit/components/input-recipient.client.tsx +15 -8
- package/src/modules/inline-edit/components/input-toggle.client.tsx +16 -9
- package/src/modules/inline-edit/components/input.client.tsx +38 -24
- package/src/modules/inline-edit/components/select.client.tsx +16 -9
- package/src/modules/inline-edit/components/switch.client.tsx +10 -6
- package/src/modules/inline-edit/components/toggle.client.tsx +13 -9
- package/src/modules/inline-edit/entry.client.ts +0 -1
- package/src/modules/inline-edit/hooks/use-inline.client copy.tsx +97 -0
- package/src/modules/inline-edit/hooks/use-inline.client.tsx +139 -20
- package/src/modules/inline-edit/lib/variants.ts +7 -0
- package/src/modules/storage/components/image-grid.client.tsx +2 -2
- package/src/modules/storage/components/upload-zone-context.client.tsx +3 -4
- package/src/modules/storage/components/upload-zone.client.tsx +17 -113
- package/src/modules/storage/config/filters.ts +2 -0
- package/src/modules/storage/entry.client.ts +2 -1
- package/src/modules/storage/lib/create-upload.client.ts +134 -0
- package/src/modules/storage/lib/helpers.ts +3 -2
- package/src/modules/storage/lib/router.server.ts +1 -0
- package/src/modules/storage/lib/schema.ts +2 -0
- package/src/modules/storage/lib/service.server.ts +18 -4
- package/src/modules/storage/lib/validators.ts +21 -31
- package/dist/modules/inline-edit/components/deprecated-editor.client.d.mts +0 -21
- package/dist/modules/inline-edit/components/deprecated-editor.client.d.mts.map +0 -1
- package/dist/modules/inline-edit/components/deprecated-editor.client.mjs +0 -37
- package/dist/modules/inline-edit/components/deprecated-editor.client.mjs.map +0 -1
- package/dist/storage/client.mjs.map +0 -1
- package/src/modules/inline-edit/components/deprecated-editor.client.tsx +0 -48
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
import { LucideIcon, LucideProps } from "lucide-react";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime83 from "react/jsx-runtime";
|
|
3
|
+
import * as react0 from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/components/common/icons.d.ts
|
|
6
6
|
type Icon = LucideIcon;
|
|
7
7
|
declare const Icons: {
|
|
8
|
-
close:
|
|
9
|
-
save:
|
|
10
|
-
spinner:
|
|
11
|
-
chevronLeft:
|
|
12
|
-
chevronRight:
|
|
13
|
-
chevronDown:
|
|
14
|
-
chevronUp:
|
|
15
|
-
trash:
|
|
16
|
-
post:
|
|
17
|
-
page:
|
|
18
|
-
media:
|
|
19
|
-
download:
|
|
20
|
-
settings:
|
|
21
|
-
billing:
|
|
22
|
-
ellipsis:
|
|
23
|
-
add:
|
|
24
|
-
edit:
|
|
25
|
-
warning:
|
|
26
|
-
user:
|
|
27
|
-
users:
|
|
28
|
-
arrowUp:
|
|
29
|
-
arrowDown:
|
|
30
|
-
arrowRight:
|
|
31
|
-
arrowLeft:
|
|
32
|
-
moveLeft:
|
|
33
|
-
moveRight:
|
|
34
|
-
help:
|
|
35
|
-
pizza:
|
|
36
|
-
check:
|
|
37
|
-
copy:
|
|
38
|
-
copyDone:
|
|
39
|
-
refresh:
|
|
40
|
-
preview:
|
|
41
|
-
externalLink:
|
|
42
|
-
sun:
|
|
43
|
-
lock:
|
|
44
|
-
unLock:
|
|
45
|
-
moon:
|
|
46
|
-
search:
|
|
47
|
-
laptop:
|
|
48
|
-
active:
|
|
49
|
-
draft:
|
|
50
|
-
archive:
|
|
51
|
-
restore:
|
|
52
|
-
dashboard:
|
|
53
|
-
regulations:
|
|
54
|
-
home:
|
|
55
|
-
mail:
|
|
56
|
-
building:
|
|
57
|
-
logo: (props: LucideProps) =>
|
|
8
|
+
close: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
9
|
+
save: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
10
|
+
spinner: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
11
|
+
chevronLeft: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
12
|
+
chevronRight: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
13
|
+
chevronDown: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
14
|
+
chevronUp: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
15
|
+
trash: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
16
|
+
post: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
17
|
+
page: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
18
|
+
media: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
19
|
+
download: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
20
|
+
settings: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
21
|
+
billing: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
22
|
+
ellipsis: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
23
|
+
add: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
24
|
+
edit: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
25
|
+
warning: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
26
|
+
user: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
27
|
+
users: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
28
|
+
arrowUp: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
29
|
+
arrowDown: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
30
|
+
arrowRight: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
31
|
+
arrowLeft: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
32
|
+
moveLeft: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
33
|
+
moveRight: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
34
|
+
help: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
35
|
+
pizza: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
36
|
+
check: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
37
|
+
copy: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
38
|
+
copyDone: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
39
|
+
refresh: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
40
|
+
preview: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
41
|
+
externalLink: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
42
|
+
sun: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
43
|
+
lock: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
44
|
+
unLock: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
45
|
+
moon: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
46
|
+
search: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
47
|
+
laptop: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
48
|
+
active: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
49
|
+
draft: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
50
|
+
archive: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
51
|
+
restore: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
52
|
+
dashboard: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
53
|
+
regulations: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
54
|
+
home: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
55
|
+
mail: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
56
|
+
building: react0.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & react0.RefAttributes<SVGSVGElement>>;
|
|
57
|
+
logo: (props: LucideProps) => react_jsx_runtime83.JSX.Element;
|
|
58
58
|
};
|
|
59
59
|
//#endregion
|
|
60
60
|
export { Icon, Icons };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.d.mts","names":[],"sources":["../../../src/components/common/icons.tsx"],"sourcesContent":[],"mappings":";;;;;KAsDY,IAAA,GAAO;cAEN;;;EAFD,OAAI,kCAAa,KAAA,YAAA,EAAA,KAAA,CAAA,uBAAA,cAAA,CAAA,CAAA;EAEhB,WA8GZ,kCAAA,KAAA,YAAA,EAAA,KAAA,CAAA,uBAAA,cAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA5De,gBAAW,
|
|
1
|
+
{"version":3,"file":"icons.d.mts","names":[],"sources":["../../../src/components/common/icons.tsx"],"sourcesContent":[],"mappings":";;;;;KAsDY,IAAA,GAAO;cAEN;;;EAFD,OAAI,kCAAa,KAAA,YAAA,EAAA,KAAA,CAAA,uBAAA,cAAA,CAAA,CAAA;EAEhB,WA8GZ,kCAAA,KAAA,YAAA,EAAA,KAAA,CAAA,uBAAA,cAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA5De,gBAAW,mBAAA,CAAA,GAAA,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConfigWithIcon } from "../../lib/types/config.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime84 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/common/status.d.ts
|
|
5
5
|
/**
|
|
@@ -43,11 +43,11 @@ type StatusComponentProps<TStatus extends string> = {
|
|
|
43
43
|
/**
|
|
44
44
|
* Status column
|
|
45
45
|
*/
|
|
46
|
-
declare function StatusField<TStatus extends string>(props: StatusComponentProps<TStatus>):
|
|
46
|
+
declare function StatusField<TStatus extends string>(props: StatusComponentProps<TStatus>): react_jsx_runtime84.JSX.Element;
|
|
47
47
|
/**
|
|
48
48
|
* Status badge
|
|
49
49
|
*/
|
|
50
|
-
declare function StatusBadge<TStatus extends string>(props: StatusComponentProps<TStatus>):
|
|
50
|
+
declare function StatusBadge<TStatus extends string>(props: StatusComponentProps<TStatus>): react_jsx_runtime84.JSX.Element;
|
|
51
51
|
//#endregion
|
|
52
52
|
export { CreateStatusComponentProps, StatusBadge, StatusField, createStatusConfig, createStatusVariants, findStatus };
|
|
53
53
|
//# sourceMappingURL=status.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.mts","names":[],"sources":["../../../src/components/common/status.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAOa,cAAA,kBACL,EAAA,CAAA,gBAAA,MAAA,CAAA,CAAA,MAAA,EAD2D,cAC3D,CAD0E,OAC1E,CAAA,EAAA,EAAA,GADoF,cACpF,CADoF,OACpF,CAAA,EAAA;;;;;;AAQR;AAYgB,iBAZA,UAYoB,CAAA,gBAAA;EACjB,KAAA,EAAA,MAAA;CACT,CAAA,CAAA,MAAA,EAbA,OAaA,EAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAXP,OAWO,GAAA,SAAA;;;AAaV;AAEE;;AAMQ,iBAvBM,oBAuBN,CAAA,gBAAA,MAAA,CAAA,CAAA,MAAA,EAAA;EACoB,KAAA,EAvBX,OAuBW;EACpB,SAAA,EAAA,MAAA;CAAO,EAAA,CAAA,EAvBd,MAuBc,CAvBP,OAuBO,EAAA,MAAA,CAAA;AAMjB;;;AAAwF,KAhB5E,0BAgB4E,CAAA,gBAAA,MAAA,CAAA,GAAA;EAAA,MAAA,EAf9E,OAe8E,GAAA,IAAA;AAexF,CAAA;;;;KAxBK,oBAwBmF,CAAA,gBAAA,MAAA,CAAA,GAAA;UAvB9E,eAAe;;YACK;;UACpB;;;;;iBAMM,2CAA2C,qBAAqB,WAAQ,
|
|
1
|
+
{"version":3,"file":"status.d.mts","names":[],"sources":["../../../src/components/common/status.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAOa,cAAA,kBACL,EAAA,CAAA,gBAAA,MAAA,CAAA,CAAA,MAAA,EAD2D,cAC3D,CAD0E,OAC1E,CAAA,EAAA,EAAA,GADoF,cACpF,CADoF,OACpF,CAAA,EAAA;;;;;;AAQR;AAYgB,iBAZA,UAYoB,CAAA,gBAAA;EACjB,KAAA,EAAA,MAAA;CACT,CAAA,CAAA,MAAA,EAbA,OAaA,EAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAXP,OAWO,GAAA,SAAA;;;AAaV;AAEE;;AAMQ,iBAvBM,oBAuBN,CAAA,gBAAA,MAAA,CAAA,CAAA,MAAA,EAAA;EACoB,KAAA,EAvBX,OAuBW;EACpB,SAAA,EAAA,MAAA;CAAO,EAAA,CAAA,EAvBd,MAuBc,CAvBP,OAuBO,EAAA,MAAA,CAAA;AAMjB;;;AAAwF,KAhB5E,0BAgB4E,CAAA,gBAAA,MAAA,CAAA,GAAA;EAAA,MAAA,EAf9E,OAe8E,GAAA,IAAA;AAexF,CAAA;;;;KAxBK,oBAwBmF,CAAA,gBAAA,MAAA,CAAA,GAAA;UAvB9E,eAAe;;YACK;;UACpB;;;;;iBAMM,2CAA2C,qBAAqB,WAAQ,mBAAA,CAAA,GAAA,CAAA;;;;iBAexE,2CAA2C,qBAAqB,WAAQ,mBAAA,CAAA,GAAA,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime255 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/components/editor/components/content.client.d.ts
|
|
4
|
-
declare function EditorContent():
|
|
4
|
+
declare function EditorContent(): react_jsx_runtime255.JSX.Element;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { EditorContent };
|
|
7
7
|
//# sourceMappingURL=content.client.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EditorExtensionsConfig, EditorExtensionsConfigResult } from "../lib/extensions.mjs";
|
|
2
2
|
import { EditorJSONContent } from "../lib/types.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react_jsx_runtime260 from "react/jsx-runtime";
|
|
4
4
|
import { VariantProps } from "class-variance-authority";
|
|
5
|
-
import * as
|
|
5
|
+
import * as react105 from "react";
|
|
6
6
|
import { PropsWithChildren } from "react";
|
|
7
7
|
import { Content, Editor } from "@tiptap/react";
|
|
8
8
|
import * as class_variance_authority_types4 from "class-variance-authority/types";
|
|
@@ -15,7 +15,7 @@ type EditorContextValue = {
|
|
|
15
15
|
editor: Editor;
|
|
16
16
|
extensions: EditorExtensionsConfigResult;
|
|
17
17
|
};
|
|
18
|
-
declare const EditorContext:
|
|
18
|
+
declare const EditorContext: react105.Context<EditorContextValue>;
|
|
19
19
|
/**
|
|
20
20
|
* Editor variants
|
|
21
21
|
*/
|
|
@@ -42,7 +42,7 @@ declare function Editor$1({
|
|
|
42
42
|
variant,
|
|
43
43
|
className,
|
|
44
44
|
children
|
|
45
|
-
}: EditorProps):
|
|
45
|
+
}: EditorProps): react_jsx_runtime260.JSX.Element | null;
|
|
46
46
|
//#endregion
|
|
47
47
|
export { Editor$1 as Editor, EditorContext, EditorProps, editorVariants };
|
|
48
48
|
//# sourceMappingURL=editor.client.d.mts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { cn } from "../../../lib/utils/cn.mjs";
|
|
4
4
|
import { editorExtensionsConfigToExtensions, flattenEditorExtensionsConfig } from "../lib/extensions.mjs";
|
|
5
|
-
import { editorProseVariants } from "../lib/variants.mjs";
|
|
5
|
+
import { editorImageVariants, editorProseVariants } from "../lib/variants.mjs";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
import { cva } from "class-variance-authority";
|
|
8
8
|
import { createContext } from "react";
|
|
@@ -32,7 +32,7 @@ function Editor$1({ value, extensions, onUpdate, onBlur, disabled, variant, clas
|
|
|
32
32
|
immediatelyRender: false,
|
|
33
33
|
editorProps: {
|
|
34
34
|
transformPastedHTML: (html) => html.replace(/<img.*?>/g, ""),
|
|
35
|
-
attributes: { class: cn("editor-content text-sm max-w-full focus:outline-none", editorProseVariants(), className) }
|
|
35
|
+
attributes: { class: cn("editor-content text-sm max-w-full focus:outline-none", editorProseVariants(), editorImageVariants(), className) }
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
if (!editor) return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.client.mjs","names":["Editor","editor"],"sources":["../../../../src/components/editor/components/editor.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { cn } from \"@/lib/utils/cn\";\nimport { Content, Editor as TiptapEditor, useEditor } from \"@tiptap/react\";\nimport { cva, VariantProps } from \"class-variance-authority\";\nimport { createContext, PropsWithChildren } from \"react\";\nimport {\n EditorExtensionsConfig,\n EditorExtensionsConfigResult,\n editorExtensionsConfigToExtensions,\n flattenEditorExtensionsConfig,\n} from \"../lib/extensions\";\nimport { EditorJSONContent } from \"../lib/types\";\nimport { editorProseVariants } from \"../lib/variants\";\n\n/**\n * Editor context\n */\ntype EditorContextValue = {\n editor: TiptapEditor;\n extensions: EditorExtensionsConfigResult;\n};\n\nexport const EditorContext = createContext({} as EditorContextValue);\n\n/**\n * Editor variants\n */\nexport const editorVariants = cva(\"\", {\n variants: {\n variant: {\n default:\n \"border-input rounded-lg border [&_.editor-content]:p-3 [&_.editor-content[contenteditable='false']]:pointer-events-none [&_.editor-content[contenteditable='false']]:cursor-not-allowed [&_.editor-content[contenteditable='false']]:opacity-50\",\n table:\n \"[&_.editor-content[contenteditable='false']]:pointer-events-none [&_.editor-content[contenteditable='false']]:cursor-not-allowed [&_.editor-content[contenteditable='false']]:opacity-50\",\n preview: \"bg-transparent [&_.editor-content]:p-0 [&_.editor-content]:min-h-0\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n});\n\n/**\n * Editor context provider\n */\nexport type EditorProps = VariantProps<typeof editorVariants> &\n PropsWithChildren<{\n value?: Content;\n extensions?: Partial<EditorExtensionsConfig>;\n onUpdate?: (value: EditorJSONContent) => void;\n onBlur?: (value: EditorJSONContent) => void;\n disabled?: boolean;\n className?: string;\n }>;\n\nexport function Editor({\n value,\n extensions,\n onUpdate,\n onBlur,\n disabled,\n variant,\n className,\n children,\n}: EditorProps) {\n const editor = useEditor({\n extensions: editorExtensionsConfigToExtensions(extensions),\n content: value,\n onUpdate: ({ editor }) => onUpdate?.(editor.getJSON()),\n onBlur: ({ editor }) => onBlur?.(editor.getJSON()),\n editable: !disabled,\n injectCSS: false,\n immediatelyRender: false,\n editorProps: {\n transformPastedHTML: (html) => html.replace(/<img.*?>/g, \"\"),\n attributes: {\n class: cn(\"editor-content text-sm max-w-full focus:outline-none\"
|
|
1
|
+
{"version":3,"file":"editor.client.mjs","names":["Editor","editor"],"sources":["../../../../src/components/editor/components/editor.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { cn } from \"@/lib/utils/cn\";\nimport { Content, Editor as TiptapEditor, useEditor } from \"@tiptap/react\";\nimport { cva, VariantProps } from \"class-variance-authority\";\nimport { createContext, PropsWithChildren } from \"react\";\nimport {\n EditorExtensionsConfig,\n EditorExtensionsConfigResult,\n editorExtensionsConfigToExtensions,\n flattenEditorExtensionsConfig,\n} from \"../lib/extensions\";\nimport { EditorJSONContent } from \"../lib/types\";\nimport { editorImageVariants, editorProseVariants } from \"../lib/variants\";\n\n/**\n * Editor context\n */\ntype EditorContextValue = {\n editor: TiptapEditor;\n extensions: EditorExtensionsConfigResult;\n};\n\nexport const EditorContext = createContext({} as EditorContextValue);\n\n/**\n * Editor variants\n */\nexport const editorVariants = cva(\"\", {\n variants: {\n variant: {\n default:\n \"border-input rounded-lg border [&_.editor-content]:p-3 [&_.editor-content[contenteditable='false']]:pointer-events-none [&_.editor-content[contenteditable='false']]:cursor-not-allowed [&_.editor-content[contenteditable='false']]:opacity-50\",\n table:\n \"[&_.editor-content[contenteditable='false']]:pointer-events-none [&_.editor-content[contenteditable='false']]:cursor-not-allowed [&_.editor-content[contenteditable='false']]:opacity-50\",\n preview: \"bg-transparent [&_.editor-content]:p-0 [&_.editor-content]:min-h-0\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n});\n\n/**\n * Editor context provider\n */\nexport type EditorProps = VariantProps<typeof editorVariants> &\n PropsWithChildren<{\n value?: Content;\n extensions?: Partial<EditorExtensionsConfig>;\n onUpdate?: (value: EditorJSONContent) => void;\n onBlur?: (value: EditorJSONContent) => void;\n disabled?: boolean;\n className?: string;\n }>;\n\nexport function Editor({\n value,\n extensions,\n onUpdate,\n onBlur,\n disabled,\n variant,\n className,\n children,\n}: EditorProps) {\n const editor = useEditor({\n extensions: editorExtensionsConfigToExtensions(extensions),\n content: value,\n onUpdate: ({ editor }) => onUpdate?.(editor.getJSON()),\n onBlur: ({ editor }) => onBlur?.(editor.getJSON()),\n editable: !disabled,\n injectCSS: false,\n immediatelyRender: false,\n editorProps: {\n transformPastedHTML: (html) => html.replace(/<img.*?>/g, \"\"),\n attributes: {\n class: cn(\n \"editor-content text-sm max-w-full focus:outline-none\",\n editorProseVariants(),\n editorImageVariants(),\n className,\n ),\n },\n },\n });\n\n if (!editor) return null;\n\n return (\n <EditorContext.Provider\n value={{\n editor,\n extensions: flattenEditorExtensionsConfig(extensions),\n }}\n >\n <div className={editorVariants({ variant })}>{children}</div>\n </EditorContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;AAuBA,MAAa,gBAAgB,cAAc,EAAE,CAAuB;;;;AAKpE,MAAa,iBAAiB,IAAI,IAAI;CACpC,UAAU,EACR,SAAS;EACP,SACE;EACF,OACE;EACF,SAAS;EACV,EACF;CACD,iBAAiB,EACf,SAAS,WACV;CACF,CAAC;AAeF,SAAgBA,SAAO,EACrB,OACA,YACA,UACA,QACA,UACA,SACA,WACA,YACc;CACd,MAAM,SAAS,UAAU;EACvB,YAAY,mCAAmC,WAAW;EAC1D,SAAS;EACT,WAAW,EAAE,uBAAa,WAAWC,SAAO,SAAS,CAAC;EACtD,SAAS,EAAE,uBAAa,SAASA,SAAO,SAAS,CAAC;EAClD,UAAU,CAAC;EACX,WAAW;EACX,mBAAmB;EACnB,aAAa;GACX,sBAAsB,SAAS,KAAK,QAAQ,aAAa,GAAG;GAC5D,YAAY,EACV,OAAO,GACL,wDACA,qBAAqB,EACrB,qBAAqB,EACrB,UACD,EACF;GACF;EACF,CAAC;AAEF,KAAI,CAAC,OAAQ,QAAO;AAEpB,QACE,oBAAC,cAAc;EACb,OAAO;GACL;GACA,YAAY,8BAA8B,WAAW;GACtD;YAED,oBAAC;GAAI,WAAW,eAAe,EAAE,SAAS,CAAC;GAAG;IAAe;GACtC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime261 from "react/jsx-runtime";
|
|
2
2
|
import { ComponentProps } from "react";
|
|
3
3
|
import { BubbleMenu } from "@tiptap/react/menus";
|
|
4
4
|
|
|
5
5
|
//#region src/components/editor/components/menu.client.d.ts
|
|
6
|
-
declare function EditorMenuFixed(props: React.ComponentProps<"div">):
|
|
7
|
-
declare function EditorMenuBubble(props: ComponentProps<typeof BubbleMenu>):
|
|
6
|
+
declare function EditorMenuFixed(props: React.ComponentProps<"div">): react_jsx_runtime261.JSX.Element;
|
|
7
|
+
declare function EditorMenuBubble(props: ComponentProps<typeof BubbleMenu>): react_jsx_runtime261.JSX.Element;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { EditorMenuBubble, EditorMenuFixed };
|
|
10
10
|
//# sourceMappingURL=menu.client.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.client.mjs","names":[],"sources":["../../../../src/components/editor/components/menu.client.tsx"],"sourcesContent":["import { Button } from \"@/components/ui/button\";\nimport { ColorPicker } from \"@/components/ui/color-picker.client\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"@/components/ui/popover\";\nimport { cn } from \"@/lib/entry\";\nimport { BubbleMenu } from \"@tiptap/react/menus\";\nimport {\n BaselineIcon,\n BoldIcon,\n EraserIcon,\n ItalicIcon,\n PaintBucketIcon,\n RedoIcon,\n StrikethroughIcon,\n UnderlineIcon,\n UndoIcon,\n} from \"lucide-react\";\nimport { ComponentProps, PropsWithChildren, useContext } from \"react\";\nimport { EditorContext } from \"./editor.client\";\nimport { EditorMenuNodes } from \"./menu-nodes.client\";\n\nexport function EditorMenuFixed(props: React.ComponentProps<\"div\">) {\n return (\n <div\n {...props}\n className={cn(\"border-input bg-muted/30 z-10 overflow-auto border-b p-2\", props.className)}\n >\n <EditorMenuContent>\n <EditorMenuUndoRedo />\n <EditorMenuNodes />\n <EditorMenuMarks />\n <EditorMenuColor />\n </EditorMenuContent>\n </div>\n );\n}\n\nexport function EditorMenuBubble(props: ComponentProps<typeof BubbleMenu>) {\n const { editor } = useContext(EditorContext);\n\n return (\n <BubbleMenu\n {...props}\n editor={editor}\n options={{ ...props.options, strategy: \"fixed\" }}\n className={cn(\"border-input bg-muted z-10 rounded-lg border p-2\", props.className)}\n >\n <EditorMenuContent>\n <EditorMenuMarks />\n </EditorMenuContent>\n </BubbleMenu>\n );\n}\n\nfunction EditorMenuContent(props: PropsWithChildren) {\n return <div className=\"flex items-center gap-6\">{props.children}</div>;\n}\n\n/**\n * Editor menu undo/redo\n */\nfunction EditorMenuUndoRedo() {\n const { editor, extensions } = useContext(EditorContext);\n\n if (!extensions.undoRedo) return null;\n\n return (\n <div className=\"flex items-center gap-1\">\n <Button\n onClick={() => editor.commands.undo()}\n disabled={!editor?.can().undo()}\n type=\"button\"\n aria-label=\"Undo\"\n size=\"icon\"\n className=\"p-2\"\n variant=\"outline\"\n >\n <UndoIcon className=\"size-3.5\" />\n </Button>\n\n <Button\n onClick={() => editor.commands.redo()}\n disabled={!editor?.can().redo()}\n type=\"button\"\n aria-label=\"Redo\"\n size=\"icon\"\n className=\"p-2\"\n variant=\"outline\"\n >\n <RedoIcon className=\"size-3.5\" />\n </Button>\n </div>\n );\n}\n\n/**\n * Editor menu marks\n */\nfunction EditorMenuMarks() {\n const { editor, extensions } = useContext(EditorContext);\n\n if (!extensions.bold && !extensions.italic && !extensions.underline && !extensions.strike) {\n return null;\n }\n\n return (\n <div className=\"flex items-center gap-1\">\n {extensions.bold && (\n <Button\n type=\"button\"\n size=\"icon\"\n variant={editor?.isActive(\"bold\") ? \"secondary\" : \"outline\"}\n onClick={() => editor.chain().focus().toggleBold().run()}\n className=\"border\"\n >\n <BoldIcon className=\"h-3.5 w-3.5\" />\n </Button>\n )}\n\n {extensions.italic && (\n <Button\n type=\"button\"\n size=\"icon\"\n variant={editor?.isActive(\"italic\") ? \"secondary\" : \"outline\"}\n onClick={() => editor.chain().focus().toggleItalic().run()}\n className=\"border\"\n >\n <ItalicIcon className=\"size-3.5\" />\n </Button>\n )}\n\n {extensions.underline && (\n <Button\n type=\"button\"\n size=\"icon\"\n variant={editor?.isActive(\"underline\") ? \"secondary\" : \"outline\"}\n onClick={() => editor.chain().focus().toggleUnderline().run()}\n className=\"border\"\n >\n <UnderlineIcon className=\"size-3.5\" />\n </Button>\n )}\n\n {extensions.strike && (\n <Button\n type=\"button\"\n size=\"icon\"\n variant={editor?.isActive(\"strike\") ? \"secondary\" : \"outline\"}\n onClick={() => editor.chain().focus().toggleStrike().run()}\n className=\"border\"\n >\n <StrikethroughIcon className=\"size-3.5\" />\n </Button>\n )}\n </div>\n );\n}\n\n/**\n * Editor menu alignment\n */\nfunction EditorMenuColor() {\n const { editor, extensions } = useContext(EditorContext);\n\n if (!extensions.color && !extensions.highlight) {\n return null;\n }\n\n return (\n <div className=\"flex items-center gap-1\">\n {extensions.color && (\n <Popover>\n <PopoverTrigger asChild>\n <Button size=\"icon\" variant=\"outline\">\n <BaselineIcon className=\"size-3.5\" />\n </Button>\n </PopoverTrigger>\n\n <PopoverContent className=\"w-fit p-0\">\n <ColorPicker onValueChange={(color) => editor.chain().focus().setColor(color).run()} />\n </PopoverContent>\n </Popover>\n )}\n\n {extensions.highlight && (\n <Popover>\n <PopoverTrigger asChild>\n <Button size=\"icon\" variant=\"outline\" disabled={!editor?.can().setHighlight()}>\n <PaintBucketIcon className=\"size-3.5\" />\n </Button>\n </PopoverTrigger>\n\n <PopoverContent className=\"w-fit p-0\">\n <ColorPicker\n onValueChange={(color) => editor.chain().focus().setHighlight({ color }).run()}\n />\n </PopoverContent>\n </Popover>\n )}\n\n <Button\n type=\"button\"\n size=\"icon\"\n variant=\"outline\"\n className=\"border\"\n onClick={() => {\n editor.commands.unsetColor();\n editor.commands.unsetHighlight();\n }}\n >\n <EraserIcon className=\"h-4 w-4\" />\n </Button>\n </div>\n );\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"menu.client.mjs","names":[],"sources":["../../../../src/components/editor/components/menu.client.tsx"],"sourcesContent":["import { Button } from \"@/components/ui/button\";\nimport { ColorPicker } from \"@/components/ui/color-picker.client\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"@/components/ui/popover\";\nimport { cn } from \"@/lib/entry\";\nimport { BubbleMenu } from \"@tiptap/react/menus\";\nimport {\n BaselineIcon,\n BoldIcon,\n EraserIcon,\n ItalicIcon,\n PaintBucketIcon,\n RedoIcon,\n StrikethroughIcon,\n UnderlineIcon,\n UndoIcon,\n} from \"lucide-react\";\nimport { ComponentProps, PropsWithChildren, useContext } from \"react\";\nimport { EditorContext } from \"./editor.client\";\nimport { EditorMenuNodes } from \"./menu-nodes.client\";\n\nexport function EditorMenuFixed(props: React.ComponentProps<\"div\">) {\n return (\n <div\n {...props}\n className={cn(\"border-input bg-muted/30 z-10 overflow-auto border-b p-2\", props.className)}\n >\n <EditorMenuContent>\n <EditorMenuUndoRedo />\n <EditorMenuNodes />\n <EditorMenuMarks />\n <EditorMenuColor />\n </EditorMenuContent>\n </div>\n );\n}\n\nexport function EditorMenuBubble(props: ComponentProps<typeof BubbleMenu>) {\n const { editor } = useContext(EditorContext);\n\n return (\n <BubbleMenu\n {...props}\n editor={editor}\n options={{ ...props.options, strategy: \"fixed\" }}\n className={cn(\"border-input bg-muted z-10 rounded-lg border p-2\", props.className)}\n >\n <EditorMenuContent>\n <EditorMenuMarks />\n </EditorMenuContent>\n </BubbleMenu>\n );\n}\n\nfunction EditorMenuContent(props: PropsWithChildren) {\n return <div className=\"flex items-center gap-6\">{props.children}</div>;\n}\n\n/**\n * Editor menu undo/redo\n */\nfunction EditorMenuUndoRedo() {\n const { editor, extensions } = useContext(EditorContext);\n\n if (!extensions.undoRedo) return null;\n\n return (\n <div className=\"flex items-center gap-1\">\n <Button\n onClick={() => editor.commands.undo()}\n disabled={!editor?.can().undo()}\n type=\"button\"\n aria-label=\"Undo\"\n size=\"icon\"\n className=\"p-2\"\n variant=\"outline\"\n >\n <UndoIcon className=\"size-3.5\" />\n </Button>\n\n <Button\n onClick={() => editor.commands.redo()}\n disabled={!editor?.can().redo()}\n type=\"button\"\n aria-label=\"Redo\"\n size=\"icon\"\n className=\"p-2\"\n variant=\"outline\"\n >\n <RedoIcon className=\"size-3.5\" />\n </Button>\n </div>\n );\n}\n\n/**\n * Editor menu marks\n */\nfunction EditorMenuMarks() {\n const { editor, extensions } = useContext(EditorContext);\n\n if (!extensions.bold && !extensions.italic && !extensions.underline && !extensions.strike) {\n return null;\n }\n\n return (\n <div className=\"flex items-center gap-1\">\n {extensions.bold && (\n <Button\n type=\"button\"\n size=\"icon\"\n variant={editor?.isActive(\"bold\") ? \"secondary\" : \"outline\"}\n onClick={() => editor.chain().focus().toggleBold().run()}\n className=\"border\"\n >\n <BoldIcon className=\"h-3.5 w-3.5\" />\n </Button>\n )}\n\n {extensions.italic && (\n <Button\n type=\"button\"\n size=\"icon\"\n variant={editor?.isActive(\"italic\") ? \"secondary\" : \"outline\"}\n onClick={() => editor.chain().focus().toggleItalic().run()}\n className=\"border\"\n >\n <ItalicIcon className=\"size-3.5\" />\n </Button>\n )}\n\n {extensions.underline && (\n <Button\n type=\"button\"\n size=\"icon\"\n variant={editor?.isActive(\"underline\") ? \"secondary\" : \"outline\"}\n onClick={() => editor.chain().focus().toggleUnderline().run()}\n className=\"border\"\n >\n <UnderlineIcon className=\"size-3.5\" />\n </Button>\n )}\n\n {extensions.strike && (\n <Button\n type=\"button\"\n size=\"icon\"\n variant={editor?.isActive(\"strike\") ? \"secondary\" : \"outline\"}\n onClick={() => editor.chain().focus().toggleStrike().run()}\n className=\"border\"\n >\n <StrikethroughIcon className=\"size-3.5\" />\n </Button>\n )}\n </div>\n );\n}\n\n/**\n * Editor menu alignment\n */\nfunction EditorMenuColor() {\n const { editor, extensions } = useContext(EditorContext);\n\n if (!extensions.color && !extensions.highlight) {\n return null;\n }\n\n return (\n <div className=\"flex items-center gap-1\">\n {extensions.color && (\n <Popover>\n <PopoverTrigger asChild>\n <Button size=\"icon\" variant=\"outline\">\n <BaselineIcon className=\"size-3.5\" />\n </Button>\n </PopoverTrigger>\n\n <PopoverContent className=\"w-fit p-0\">\n <ColorPicker onValueChange={(color) => editor.chain().focus().setColor(color).run()} />\n </PopoverContent>\n </Popover>\n )}\n\n {extensions.highlight && (\n <Popover>\n <PopoverTrigger asChild>\n <Button size=\"icon\" variant=\"outline\" disabled={!editor?.can().setHighlight()}>\n <PaintBucketIcon className=\"size-3.5\" />\n </Button>\n </PopoverTrigger>\n\n <PopoverContent className=\"w-fit p-0\">\n <ColorPicker\n onValueChange={(color) => editor.chain().focus().setHighlight({ color }).run()}\n />\n </PopoverContent>\n </Popover>\n )}\n\n <Button\n type=\"button\"\n size=\"icon\"\n variant=\"outline\"\n className=\"border\"\n onClick={() => {\n editor.commands.unsetColor();\n editor.commands.unsetHighlight();\n }}\n >\n <EraserIcon className=\"h-4 w-4\" />\n </Button>\n </div>\n );\n}\n\n/**\n * Editor menu image\n */\n// function EditorMenuImage() {\n// const { editor, extensions } = useContext(EditorContext);\n\n// if (!extensions.image) return null;\n\n// return (\n// <div className=\"flex items-center gap-1\">\n// {extensions.image && (\n// <Button\n// type=\"button\"\n// size=\"icon\"\n// variant=\"outline\"\n// onClick={() => editor.chain().focus().downloadImage().run()}\n// disabled={!editor?.can().downloadImage()}\n// className=\"border\"\n// >\n// <DownloadIcon className=\"size-3.5\" />\n// </Button>\n// )}\n// </div>\n// );\n// }\n"],"mappings":";;;;;;;;;;;;AAoBA,SAAgB,gBAAgB,OAAoC;AAClE,QACE,oBAAC;EACC,GAAI;EACJ,WAAW,GAAG,4DAA4D,MAAM,UAAU;YAE1F,qBAAC;GACC,oBAAC,uBAAqB;GACtB,oBAAC,oBAAkB;GACnB,oBAAC,oBAAkB;GACnB,oBAAC,oBAAkB;MACD;GAChB;;AAIV,SAAgB,iBAAiB,OAA0C;CACzE,MAAM,EAAE,WAAW,WAAW,cAAc;AAE5C,QACE,oBAAC;EACC,GAAI;EACI;EACR,SAAS;GAAE,GAAG,MAAM;GAAS,UAAU;GAAS;EAChD,WAAW,GAAG,oDAAoD,MAAM,UAAU;YAElF,oBAAC,+BACC,oBAAC,oBAAkB,GACD;GACT;;AAIjB,SAAS,kBAAkB,OAA0B;AACnD,QAAO,oBAAC;EAAI,WAAU;YAA2B,MAAM;GAAe;;;;;AAMxE,SAAS,qBAAqB;CAC5B,MAAM,EAAE,QAAQ,eAAe,WAAW,cAAc;AAExD,KAAI,CAAC,WAAW,SAAU,QAAO;AAEjC,QACE,qBAAC;EAAI,WAAU;aACb,oBAAC;GACC,eAAe,OAAO,SAAS,MAAM;GACrC,UAAU,CAAC,QAAQ,KAAK,CAAC,MAAM;GAC/B,MAAK;GACL,cAAW;GACX,MAAK;GACL,WAAU;GACV,SAAQ;aAER,oBAAC,YAAS,WAAU,aAAa;IAC1B,EAET,oBAAC;GACC,eAAe,OAAO,SAAS,MAAM;GACrC,UAAU,CAAC,QAAQ,KAAK,CAAC,MAAM;GAC/B,MAAK;GACL,cAAW;GACX,MAAK;GACL,WAAU;GACV,SAAQ;aAER,oBAAC,YAAS,WAAU,aAAa;IAC1B;GACL;;;;;AAOV,SAAS,kBAAkB;CACzB,MAAM,EAAE,QAAQ,eAAe,WAAW,cAAc;AAExD,KAAI,CAAC,WAAW,QAAQ,CAAC,WAAW,UAAU,CAAC,WAAW,aAAa,CAAC,WAAW,OACjF,QAAO;AAGT,QACE,qBAAC;EAAI,WAAU;;GACZ,WAAW,QACV,oBAAC;IACC,MAAK;IACL,MAAK;IACL,SAAS,QAAQ,SAAS,OAAO,GAAG,cAAc;IAClD,eAAe,OAAO,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK;IACxD,WAAU;cAEV,oBAAC,YAAS,WAAU,gBAAgB;KAC7B;GAGV,WAAW,UACV,oBAAC;IACC,MAAK;IACL,MAAK;IACL,SAAS,QAAQ,SAAS,SAAS,GAAG,cAAc;IACpD,eAAe,OAAO,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK;IAC1D,WAAU;cAEV,oBAAC,cAAW,WAAU,aAAa;KAC5B;GAGV,WAAW,aACV,oBAAC;IACC,MAAK;IACL,MAAK;IACL,SAAS,QAAQ,SAAS,YAAY,GAAG,cAAc;IACvD,eAAe,OAAO,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK;IAC7D,WAAU;cAEV,oBAAC,iBAAc,WAAU,aAAa;KAC/B;GAGV,WAAW,UACV,oBAAC;IACC,MAAK;IACL,MAAK;IACL,SAAS,QAAQ,SAAS,SAAS,GAAG,cAAc;IACpD,eAAe,OAAO,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK;IAC1D,WAAU;cAEV,oBAAC,qBAAkB,WAAU,aAAa;KACnC;;GAEP;;;;;AAOV,SAAS,kBAAkB;CACzB,MAAM,EAAE,QAAQ,eAAe,WAAW,cAAc;AAExD,KAAI,CAAC,WAAW,SAAS,CAAC,WAAW,UACnC,QAAO;AAGT,QACE,qBAAC;EAAI,WAAU;;GACZ,WAAW,SACV,qBAAC,sBACC,oBAAC;IAAe;cACd,oBAAC;KAAO,MAAK;KAAO,SAAQ;eAC1B,oBAAC,gBAAa,WAAU,aAAa;MAC9B;KACM,EAEjB,oBAAC;IAAe,WAAU;cACxB,oBAAC,eAAY,gBAAgB,UAAU,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,MAAM,CAAC,KAAK,GAAI;KACxE,IACT;GAGX,WAAW,aACV,qBAAC,sBACC,oBAAC;IAAe;cACd,oBAAC;KAAO,MAAK;KAAO,SAAQ;KAAU,UAAU,CAAC,QAAQ,KAAK,CAAC,cAAc;eAC3E,oBAAC,mBAAgB,WAAU,aAAa;MACjC;KACM,EAEjB,oBAAC;IAAe,WAAU;cACxB,oBAAC,eACC,gBAAgB,UAAU,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,KAAK,GAC9E;KACa,IACT;GAGZ,oBAAC;IACC,MAAK;IACL,MAAK;IACL,SAAQ;IACR,WAAU;IACV,eAAe;AACb,YAAO,SAAS,YAAY;AAC5B,YAAO,SAAS,gBAAgB;;cAGlC,oBAAC,cAAW,WAAU,YAAY;KAC3B;;GACL"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FileHandlerOptions } from "@tiptap/extension-file-handler";
|
|
2
|
+
import "@tiptap/core";
|
|
3
|
+
|
|
4
|
+
//#region src/components/editor/extensions/file-handler/extension.d.ts
|
|
5
|
+
interface FileHandlerOptions$1 extends FileHandlerOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Callback function invoked when a image reference is removed from the editor. Receives the node ID of the removed node.
|
|
8
|
+
* @type {(nodeId: string) => void}
|
|
9
|
+
* @default undefined
|
|
10
|
+
**/
|
|
11
|
+
onReferenceRemoved?: (nodeId: string) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Callback function invoked when a image reference is added to the editor. Receives the node ID of the added node.
|
|
14
|
+
* @type {(nodeId: string) => void}
|
|
15
|
+
* @default undefined
|
|
16
|
+
**/
|
|
17
|
+
onReferenceAdded?: (nodeId: string) => void;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { FileHandlerOptions$1 as FileHandlerOptions };
|
|
21
|
+
//# sourceMappingURL=extension.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.d.mts","names":[],"sources":["../../../../../src/components/editor/extensions/file-handler/extension.ts"],"sourcesContent":[],"mappings":";;;;UASiB,oBAAA,SAA2B;;;AAA5C"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { collectImageIds, diffIds } from "./utils.mjs";
|
|
4
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
5
|
+
import { FileHandler } from "@tiptap/extension-file-handler";
|
|
6
|
+
|
|
7
|
+
//#region src/components/editor/extensions/file-handler/extension.ts
|
|
8
|
+
/**
|
|
9
|
+
* File Handler extension for Tiptap Editor
|
|
10
|
+
*/
|
|
11
|
+
const FileHandler$1 = FileHandler.extend({
|
|
12
|
+
addOptions() {
|
|
13
|
+
return {
|
|
14
|
+
...this.parent?.(),
|
|
15
|
+
onReferenceRemoved: void 0,
|
|
16
|
+
onReferenceAdded: void 0
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
addProseMirrorPlugins() {
|
|
20
|
+
const parent = this.parent?.() ?? [];
|
|
21
|
+
const key = new PluginKey("fileHandlerItemTracker");
|
|
22
|
+
return [...parent, new Plugin({
|
|
23
|
+
key,
|
|
24
|
+
appendTransaction: (trs, oldState, newState) => {
|
|
25
|
+
if (!trs.some((tr) => tr.docChanged)) return null;
|
|
26
|
+
const onReferenceRemoved = this.options.onReferenceRemoved;
|
|
27
|
+
const onReferenceAdded = this.options.onReferenceAdded;
|
|
28
|
+
if (!onReferenceRemoved && !onReferenceAdded) return null;
|
|
29
|
+
const { removed, added } = diffIds(collectImageIds(oldState.doc), collectImageIds(newState.doc));
|
|
30
|
+
for (const id of removed) onReferenceRemoved?.(id);
|
|
31
|
+
for (const id of added) onReferenceAdded?.(id);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
})];
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { FileHandler$1 as FileHandler };
|
|
40
|
+
//# sourceMappingURL=extension.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.mjs","names":["FileHandler","TiptapFileHandler"],"sources":["../../../../../src/components/editor/extensions/file-handler/extension.ts"],"sourcesContent":["\"use client\";\n\nimport {\n FileHandler as TiptapFileHandler,\n FileHandlerOptions as TiptapFileHandlerOptions,\n} from \"@tiptap/extension-file-handler\";\nimport { Plugin, PluginKey } from \"@tiptap/pm/state\";\nimport { collectImageIds, diffIds } from \"./utils\";\n\nexport interface FileHandlerOptions extends TiptapFileHandlerOptions {\n /**\n * Callback function invoked when a image reference is removed from the editor. Receives the node ID of the removed node.\n * @type {(nodeId: string) => void}\n * @default undefined\n **/\n onReferenceRemoved?: (nodeId: string) => void;\n\n /**\n * Callback function invoked when a image reference is added to the editor. Receives the node ID of the added node.\n * @type {(nodeId: string) => void}\n * @default undefined\n **/\n onReferenceAdded?: (nodeId: string) => void;\n}\n\n/**\n * File Handler extension for Tiptap Editor\n */\nexport const FileHandler = TiptapFileHandler.extend<FileHandlerOptions>({\n addOptions() {\n return {\n ...this.parent?.(),\n onReferenceRemoved: undefined,\n onReferenceAdded: undefined,\n };\n },\n addProseMirrorPlugins() {\n const parent = this.parent?.() ?? [];\n const key = new PluginKey(\"fileHandlerItemTracker\");\n\n return [\n ...parent,\n new Plugin({\n key,\n appendTransaction: (trs, oldState, newState) => {\n if (!trs.some((tr) => tr.docChanged)) return null;\n\n const onReferenceRemoved = this.options.onReferenceRemoved;\n const onReferenceAdded = this.options.onReferenceAdded;\n if (!onReferenceRemoved && !onReferenceAdded) return null;\n\n const before = collectImageIds(oldState.doc);\n const after = collectImageIds(newState.doc);\n const { removed, added } = diffIds(before, after);\n\n for (const id of removed) {\n onReferenceRemoved?.(id);\n }\n\n for (const id of added) {\n onReferenceAdded?.(id);\n }\n\n return null;\n },\n }),\n ];\n },\n});\n"],"mappings":";;;;;;;;;;AA4BA,MAAaA,gBAAcC,YAAkB,OAA2B;CACtE,aAAa;AACX,SAAO;GACL,GAAG,KAAK,UAAU;GAClB,oBAAoB;GACpB,kBAAkB;GACnB;;CAEH,wBAAwB;EACtB,MAAM,SAAS,KAAK,UAAU,IAAI,EAAE;EACpC,MAAM,MAAM,IAAI,UAAU,yBAAyB;AAEnD,SAAO,CACL,GAAG,QACH,IAAI,OAAO;GACT;GACA,oBAAoB,KAAK,UAAU,aAAa;AAC9C,QAAI,CAAC,IAAI,MAAM,OAAO,GAAG,WAAW,CAAE,QAAO;IAE7C,MAAM,qBAAqB,KAAK,QAAQ;IACxC,MAAM,mBAAmB,KAAK,QAAQ;AACtC,QAAI,CAAC,sBAAsB,CAAC,iBAAkB,QAAO;IAIrD,MAAM,EAAE,SAAS,UAAU,QAFZ,gBAAgB,SAAS,IAAI,EAC9B,gBAAgB,SAAS,IAAI,CACM;AAEjD,SAAK,MAAM,MAAM,QACf,sBAAqB,GAAG;AAG1B,SAAK,MAAM,MAAM,MACf,oBAAmB,GAAG;AAGxB,WAAO;;GAEV,CAAC,CACH;;CAEJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FileHandlerOptions } from "./extension.mjs";
|
|
2
|
+
import { SelectNodeSchema, UploadFileSchema } from "../../../../modules/storage/lib/validators.mjs";
|
|
3
|
+
import "../../../../storage.mjs";
|
|
4
|
+
import { UploadClient, UploadHooks } from "../../../../modules/storage/lib/create-upload.client.mjs";
|
|
5
|
+
import "../../../../storage/client.mjs";
|
|
6
|
+
|
|
7
|
+
//#region src/components/editor/extensions/file-handler/strategy.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Handle File Handler props
|
|
10
|
+
*/
|
|
11
|
+
type CreateFileHandlerUploadStrategyProps = {
|
|
12
|
+
variables: Pick<UploadFileSchema, "namespace" | "parentId" | "mode" | "hidden" | "readonly">;
|
|
13
|
+
uploadClient: UploadClient;
|
|
14
|
+
uploadHooks?: UploadHooks;
|
|
15
|
+
allowedMimeTypes?: string[];
|
|
16
|
+
onUploadCompleted?: (node: SelectNodeSchema) => Promise<void> | void;
|
|
17
|
+
onUploadFailed?: (error: unknown) => Promise<void> | void;
|
|
18
|
+
};
|
|
19
|
+
declare function createFileHandlerUploadStrategy({
|
|
20
|
+
variables,
|
|
21
|
+
uploadClient,
|
|
22
|
+
uploadHooks,
|
|
23
|
+
onUploadCompleted,
|
|
24
|
+
onUploadFailed,
|
|
25
|
+
allowedMimeTypes
|
|
26
|
+
}: CreateFileHandlerUploadStrategyProps): FileHandlerOptions;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { createFileHandlerUploadStrategy };
|
|
29
|
+
//# sourceMappingURL=strategy.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy.d.mts","names":[],"sources":["../../../../../src/components/editor/extensions/file-handler/strategy.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;KASK,oCAAA;EAAA,SAAA,EACQ,IADR,CACa,gBADb,EAAA,WAAoC,GAAA,UAAA,GAAA,MAAA,GAAA,QAAA,GAAA,UAAA,CAAA;EACvB,YAAA,EACF,YADE;EAAL,WAAA,CAAA,EAEG,WAFH;EACG,gBAAA,CAAA,EAAA,MAAA,EAAA;EACA,iBAAA,CAAA,EAAA,CAAA,IAAA,EAEa,gBAFb,EAAA,GAEkC,OAFlC,CAAA,IAAA,CAAA,GAAA,IAAA;EAEa,cAAA,CAAA,EAAA,CAAA,KAAA,EAAA,OAAA,EAAA,GACU,OADV,CAAA,IAAA,CAAA,GAAA,IAAA;CAAqB;AACX,iBAGvB,+BAAA,CAHuB;EAAA,SAAA;EAAA,YAAA;EAAA,WAAA;EAAA,iBAAA;EAAA,cAAA;EAAA;AAAA,CAAA,EAUpC,oCAVoC,CAAA,EAUG,kBAVH"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { TextSelection } from "@tiptap/pm/state";
|
|
2
|
+
|
|
3
|
+
//#region src/components/editor/extensions/file-handler/strategy.ts
|
|
4
|
+
function createFileHandlerUploadStrategy({ variables, uploadClient, uploadHooks, onUploadCompleted, onUploadFailed, allowedMimeTypes }) {
|
|
5
|
+
const handleUpload = async (editor, files, startPos) => {
|
|
6
|
+
const insertPos = startPos;
|
|
7
|
+
for (const file of files) {
|
|
8
|
+
/**
|
|
9
|
+
* Prepare upload
|
|
10
|
+
*/
|
|
11
|
+
const input = uploadClient.prepareUpload({
|
|
12
|
+
file,
|
|
13
|
+
...variables
|
|
14
|
+
});
|
|
15
|
+
const imageType = editor.schema.nodes.image;
|
|
16
|
+
if (!imageType) {
|
|
17
|
+
console.error("Image type not found");
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
/**
|
|
22
|
+
* Create skeleton node
|
|
23
|
+
*/
|
|
24
|
+
const skeletonNode = editor.schema.nodes.skeleton?.create({
|
|
25
|
+
imageNodeId: input.id,
|
|
26
|
+
width: 500,
|
|
27
|
+
height: 500
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Insert skeleton node into the document
|
|
31
|
+
*/
|
|
32
|
+
if (skeletonNode) {
|
|
33
|
+
const tr = editor.state.tr.insert(insertPos, skeletonNode);
|
|
34
|
+
tr.setSelection(TextSelection.create(tr.doc, insertPos + skeletonNode.nodeSize));
|
|
35
|
+
tr.setMeta("addToHistory", false);
|
|
36
|
+
editor.view.dispatch(tr);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Upload the file
|
|
40
|
+
*/
|
|
41
|
+
const fileNode = await uploadClient.upload(input, uploadHooks);
|
|
42
|
+
/**
|
|
43
|
+
* Replace skeleton with image node
|
|
44
|
+
*/
|
|
45
|
+
const replacedTr = editor.state.tr;
|
|
46
|
+
let replaced = false;
|
|
47
|
+
replacedTr.doc.descendants((node, pos) => {
|
|
48
|
+
if (node.type.name === "skeleton" && node.attrs?.imageNodeId === input.id) {
|
|
49
|
+
const imageNode = imageType.create({
|
|
50
|
+
nodeId: fileNode.id,
|
|
51
|
+
alt: file.name,
|
|
52
|
+
fileName: file.name,
|
|
53
|
+
width: node.attrs.width ?? 500
|
|
54
|
+
});
|
|
55
|
+
replacedTr.replaceWith(pos, pos + node.nodeSize, imageNode);
|
|
56
|
+
replaced = true;
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
if (replaced) editor.view.dispatch(replacedTr);
|
|
61
|
+
else {
|
|
62
|
+
const tr = editor.state.tr;
|
|
63
|
+
const imageNode = imageType.create({
|
|
64
|
+
nodeId: fileNode.id,
|
|
65
|
+
alt: file.name,
|
|
66
|
+
fileName: file.name,
|
|
67
|
+
width: 500
|
|
68
|
+
});
|
|
69
|
+
tr.insert(insertPos, imageNode);
|
|
70
|
+
editor.view.dispatch(tr);
|
|
71
|
+
}
|
|
72
|
+
await onUploadCompleted?.(fileNode);
|
|
73
|
+
} catch (err) {
|
|
74
|
+
console.error("Upload error:", err);
|
|
75
|
+
/**
|
|
76
|
+
* Remove the pending image node from the document
|
|
77
|
+
*/
|
|
78
|
+
const tr = editor.state.tr;
|
|
79
|
+
tr.doc.descendants((node, pos) => {
|
|
80
|
+
if (node.type.name === "image" && node.attrs?.nodeId === input.id) {
|
|
81
|
+
tr.delete(pos, pos + node.nodeSize);
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
editor.view.dispatch(tr);
|
|
86
|
+
await onUploadFailed?.(err);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
allowedMimeTypes,
|
|
92
|
+
onDrop: async (editor, files, pos) => {
|
|
93
|
+
await handleUpload(editor, files, pos);
|
|
94
|
+
},
|
|
95
|
+
onPaste: async (editor, files, htmlContent) => {
|
|
96
|
+
if (htmlContent?.length) return;
|
|
97
|
+
const startPos = editor.state.selection.anchor;
|
|
98
|
+
await handleUpload(editor, files, startPos);
|
|
99
|
+
},
|
|
100
|
+
onReferenceRemoved: async (nodeId) => {
|
|
101
|
+
await uploadClient.updateNode(nodeId, { orphanedAt: /* @__PURE__ */ new Date() });
|
|
102
|
+
},
|
|
103
|
+
onReferenceAdded: async (nodeId) => {
|
|
104
|
+
await uploadClient.updateNode(nodeId, { orphanedAt: null });
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
110
|
+
export { createFileHandlerUploadStrategy };
|
|
111
|
+
//# sourceMappingURL=strategy.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy.mjs","names":[],"sources":["../../../../../src/components/editor/extensions/file-handler/strategy.ts"],"sourcesContent":["import { SelectNodeSchema, UploadFileSchema } from \"@/modules/storage/entry\";\nimport { UploadClient, UploadHooks } from \"@/modules/storage/entry.client\";\nimport { Editor } from \"@tiptap/core\";\nimport { TextSelection } from \"@tiptap/pm/state\";\nimport { FileHandlerOptions } from \"./extension\";\n\n/**\n * Handle File Handler props\n */\ntype CreateFileHandlerUploadStrategyProps = {\n variables: Pick<UploadFileSchema, \"namespace\" | \"parentId\" | \"mode\" | \"hidden\" | \"readonly\">;\n uploadClient: UploadClient;\n uploadHooks?: UploadHooks;\n allowedMimeTypes?: string[];\n onUploadCompleted?: (node: SelectNodeSchema) => Promise<void> | void;\n onUploadFailed?: (error: unknown) => Promise<void> | void;\n};\n\nexport function createFileHandlerUploadStrategy({\n variables,\n uploadClient,\n uploadHooks,\n onUploadCompleted,\n onUploadFailed,\n allowedMimeTypes,\n}: CreateFileHandlerUploadStrategyProps): FileHandlerOptions {\n const handleUpload = async (editor: Editor, files: File[], startPos: number) => {\n const insertPos = startPos;\n\n for (const file of files) {\n /**\n * Prepare upload\n */\n const input = uploadClient.prepareUpload({ file, ...variables });\n\n const imageType = editor.schema.nodes.image;\n if (!imageType) {\n console.error(\"Image type not found\");\n return;\n }\n\n try {\n /**\n * Create skeleton node\n */\n const skeletonNode = editor.schema.nodes.skeleton?.create({\n imageNodeId: input.id,\n width: 500,\n height: 500,\n });\n\n /**\n * Insert skeleton node into the document\n */\n if (skeletonNode) {\n // editor.chain().insertContentAt(insertPos, skeletonNode).focus().run();\n const tr = editor.state.tr.insert(insertPos, skeletonNode);\n tr.setSelection(TextSelection.create(tr.doc, insertPos + skeletonNode.nodeSize));\n tr.setMeta(\"addToHistory\", false);\n editor.view.dispatch(tr);\n }\n\n /**\n * Upload the file\n */\n const fileNode = await uploadClient.upload(input, uploadHooks);\n\n /**\n * Replace skeleton with image node\n */\n const replacedTr = editor.state.tr;\n let replaced = false;\n\n replacedTr.doc.descendants((node, pos) => {\n if (node.type.name === \"skeleton\" && node.attrs?.imageNodeId === input.id) {\n const imageNode = imageType.create({\n nodeId: fileNode.id,\n alt: file.name,\n fileName: file.name,\n width: node.attrs.width ?? 500,\n });\n\n replacedTr.replaceWith(pos, pos + node.nodeSize, imageNode);\n replaced = true;\n return false;\n }\n });\n\n if (replaced) {\n editor.view.dispatch(replacedTr);\n } else {\n // In case skeleton is not found, insert the image node at the original position\n const tr = editor.state.tr;\n const imageNode = imageType.create({\n nodeId: fileNode.id,\n alt: file.name,\n fileName: file.name,\n width: 500,\n });\n tr.insert(insertPos, imageNode);\n editor.view.dispatch(tr);\n }\n\n // /**\n // * Remove skeleton node from the document\n // */\n // const tr = editor.state.tr;\n // tr.doc.descendants((node, pos) => {\n // if (node.type.name === \"skeleton\" && node.attrs?.imageNodeId === input.id) {\n // tr.delete(pos, pos + node.nodeSize);\n // return false;\n // }\n // });\n // editor.view.dispatch(tr);\n\n // /**\n // * Add image node to the document\n // */\n // const imageNode = imageType.create({\n // nodeId: fileNode.id,\n // alt: file.name,\n // fileName: file.name,\n // width: 500,\n // });\n // editor.commands.insertContentAt(insertPos, imageNode);\n // // insertPos += imageNode.nodeSize - skeletonNode.nodeSize;\n\n await onUploadCompleted?.(fileNode);\n } catch (err) {\n console.error(\"Upload error:\", err);\n\n /**\n * Remove the pending image node from the document\n */\n const tr = editor.state.tr;\n tr.doc.descendants((node, pos) => {\n if (node.type.name === \"image\" && node.attrs?.nodeId === input.id) {\n tr.delete(pos, pos + node.nodeSize);\n return false;\n }\n });\n editor.view.dispatch(tr);\n\n await onUploadFailed?.(err);\n }\n }\n };\n\n return {\n allowedMimeTypes,\n onDrop: async (editor, files, pos) => {\n await handleUpload(editor, files, pos);\n },\n onPaste: async (editor, files, htmlContent) => {\n if (htmlContent?.length) return;\n\n const startPos = editor.state.selection.anchor;\n await handleUpload(editor, files, startPos);\n },\n onReferenceRemoved: async (nodeId) => {\n await uploadClient.updateNode(nodeId, { orphanedAt: new Date() });\n },\n onReferenceAdded: async (nodeId) => {\n await uploadClient.updateNode(nodeId, { orphanedAt: null });\n },\n };\n}\n"],"mappings":";;;AAkBA,SAAgB,gCAAgC,EAC9C,WACA,cACA,aACA,mBACA,gBACA,oBAC2D;CAC3D,MAAM,eAAe,OAAO,QAAgB,OAAe,aAAqB;EAC9E,MAAM,YAAY;AAElB,OAAK,MAAM,QAAQ,OAAO;;;;GAIxB,MAAM,QAAQ,aAAa,cAAc;IAAE;IAAM,GAAG;IAAW,CAAC;GAEhE,MAAM,YAAY,OAAO,OAAO,MAAM;AACtC,OAAI,CAAC,WAAW;AACd,YAAQ,MAAM,uBAAuB;AACrC;;AAGF,OAAI;;;;IAIF,MAAM,eAAe,OAAO,OAAO,MAAM,UAAU,OAAO;KACxD,aAAa,MAAM;KACnB,OAAO;KACP,QAAQ;KACT,CAAC;;;;AAKF,QAAI,cAAc;KAEhB,MAAM,KAAK,OAAO,MAAM,GAAG,OAAO,WAAW,aAAa;AAC1D,QAAG,aAAa,cAAc,OAAO,GAAG,KAAK,YAAY,aAAa,SAAS,CAAC;AAChF,QAAG,QAAQ,gBAAgB,MAAM;AACjC,YAAO,KAAK,SAAS,GAAG;;;;;IAM1B,MAAM,WAAW,MAAM,aAAa,OAAO,OAAO,YAAY;;;;IAK9D,MAAM,aAAa,OAAO,MAAM;IAChC,IAAI,WAAW;AAEf,eAAW,IAAI,aAAa,MAAM,QAAQ;AACxC,SAAI,KAAK,KAAK,SAAS,cAAc,KAAK,OAAO,gBAAgB,MAAM,IAAI;MACzE,MAAM,YAAY,UAAU,OAAO;OACjC,QAAQ,SAAS;OACjB,KAAK,KAAK;OACV,UAAU,KAAK;OACf,OAAO,KAAK,MAAM,SAAS;OAC5B,CAAC;AAEF,iBAAW,YAAY,KAAK,MAAM,KAAK,UAAU,UAAU;AAC3D,iBAAW;AACX,aAAO;;MAET;AAEF,QAAI,SACF,QAAO,KAAK,SAAS,WAAW;SAC3B;KAEL,MAAM,KAAK,OAAO,MAAM;KACxB,MAAM,YAAY,UAAU,OAAO;MACjC,QAAQ,SAAS;MACjB,KAAK,KAAK;MACV,UAAU,KAAK;MACf,OAAO;MACR,CAAC;AACF,QAAG,OAAO,WAAW,UAAU;AAC/B,YAAO,KAAK,SAAS,GAAG;;AA2B1B,UAAM,oBAAoB,SAAS;YAC5B,KAAK;AACZ,YAAQ,MAAM,iBAAiB,IAAI;;;;IAKnC,MAAM,KAAK,OAAO,MAAM;AACxB,OAAG,IAAI,aAAa,MAAM,QAAQ;AAChC,SAAI,KAAK,KAAK,SAAS,WAAW,KAAK,OAAO,WAAW,MAAM,IAAI;AACjE,SAAG,OAAO,KAAK,MAAM,KAAK,SAAS;AACnC,aAAO;;MAET;AACF,WAAO,KAAK,SAAS,GAAG;AAExB,UAAM,iBAAiB,IAAI;;;;AAKjC,QAAO;EACL;EACA,QAAQ,OAAO,QAAQ,OAAO,QAAQ;AACpC,SAAM,aAAa,QAAQ,OAAO,IAAI;;EAExC,SAAS,OAAO,QAAQ,OAAO,gBAAgB;AAC7C,OAAI,aAAa,OAAQ;GAEzB,MAAM,WAAW,OAAO,MAAM,UAAU;AACxC,SAAM,aAAa,QAAQ,OAAO,SAAS;;EAE7C,oBAAoB,OAAO,WAAW;AACpC,SAAM,aAAa,WAAW,QAAQ,EAAE,4BAAY,IAAI,MAAM,EAAE,CAAC;;EAEnE,kBAAkB,OAAO,WAAW;AAClC,SAAM,aAAa,WAAW,QAAQ,EAAE,YAAY,MAAM,CAAC;;EAE9D"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/components/editor/extensions/file-handler/utils.ts
|
|
2
|
+
/**
|
|
3
|
+
* Collects and counts all image node IDs from a document.
|
|
4
|
+
*
|
|
5
|
+
* @param doc - The document node to traverse and analyze
|
|
6
|
+
* @returns A Map where keys are image node IDs and values are their occurrence counts
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const imageCounts = collectImageIds(editorDoc);
|
|
10
|
+
* imageCounts.forEach((count, imageId) => {
|
|
11
|
+
* console.log(`Image ${imageId} appears ${count} times`);
|
|
12
|
+
* });
|
|
13
|
+
*/
|
|
14
|
+
function collectImageIds(doc) {
|
|
15
|
+
const counts = /* @__PURE__ */ new Map();
|
|
16
|
+
doc.descendants((node) => {
|
|
17
|
+
if (node.type.name !== "image") return;
|
|
18
|
+
const id = node.attrs?.nodeId;
|
|
19
|
+
if (!id) return;
|
|
20
|
+
counts.set(id, (counts.get(id) ?? 0) + 1);
|
|
21
|
+
});
|
|
22
|
+
return counts;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Compares two maps of string keys to numeric values and identifies which keys have been removed or restored.
|
|
26
|
+
* @param before - A Map containing the previous state of string keys with their associated numeric values
|
|
27
|
+
* @param after - A Map containing the current state of string keys with their associated numeric values
|
|
28
|
+
* @returns An object containing two arrays:
|
|
29
|
+
* - `removed`: Array of keys where the numeric value decreased (or was deleted)
|
|
30
|
+
* - `restored`: Array of keys where the numeric value increased
|
|
31
|
+
*/
|
|
32
|
+
function diffIds(before, after) {
|
|
33
|
+
const removed = [];
|
|
34
|
+
const added = [];
|
|
35
|
+
const keys = new Set([...before.keys(), ...after.keys()]);
|
|
36
|
+
for (const key of keys) {
|
|
37
|
+
const b = before.get(key) ?? 0;
|
|
38
|
+
const a = after.get(key) ?? 0;
|
|
39
|
+
if (a < b) removed.push(key);
|
|
40
|
+
if (a > b) added.push(key);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
removed,
|
|
44
|
+
added
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
export { collectImageIds, diffIds };
|
|
50
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":["removed: string[]","added: string[]"],"sources":["../../../../../src/components/editor/extensions/file-handler/utils.ts"],"sourcesContent":["/**\n * Collects and counts all image node IDs from a document.\n *\n * @param doc - The document node to traverse and analyze\n * @returns A Map where keys are image node IDs and values are their occurrence counts\n *\n * @example\n * const imageCounts = collectImageIds(editorDoc);\n * imageCounts.forEach((count, imageId) => {\n * console.log(`Image ${imageId} appears ${count} times`);\n * });\n */\nexport function collectImageIds(doc: any): Map<string, number> {\n const counts = new Map<string, number>();\n\n doc.descendants((node: any) => {\n if (node.type.name !== \"image\") return;\n\n const id = node.attrs?.nodeId;\n if (!id) return;\n\n counts.set(id, (counts.get(id) ?? 0) + 1);\n });\n\n return counts;\n}\n\n/**\n * Compares two maps of string keys to numeric values and identifies which keys have been removed or restored.\n * @param before - A Map containing the previous state of string keys with their associated numeric values\n * @param after - A Map containing the current state of string keys with their associated numeric values\n * @returns An object containing two arrays:\n * - `removed`: Array of keys where the numeric value decreased (or was deleted)\n * - `restored`: Array of keys where the numeric value increased\n */\nexport function diffIds(before: Map<string, number>, after: Map<string, number>) {\n const removed: string[] = [];\n const added: string[] = [];\n\n const keys = new Set([...before.keys(), ...after.keys()]);\n\n for (const key of keys) {\n const b = before.get(key) ?? 0;\n const a = after.get(key) ?? 0;\n\n if (a < b) removed.push(key);\n if (a > b) added.push(key);\n }\n\n return { removed, added };\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,SAAgB,gBAAgB,KAA+B;CAC7D,MAAM,yBAAS,IAAI,KAAqB;AAExC,KAAI,aAAa,SAAc;AAC7B,MAAI,KAAK,KAAK,SAAS,QAAS;EAEhC,MAAM,KAAK,KAAK,OAAO;AACvB,MAAI,CAAC,GAAI;AAET,SAAO,IAAI,KAAK,OAAO,IAAI,GAAG,IAAI,KAAK,EAAE;GACzC;AAEF,QAAO;;;;;;;;;;AAWT,SAAgB,QAAQ,QAA6B,OAA4B;CAC/E,MAAMA,UAAoB,EAAE;CAC5B,MAAMC,QAAkB,EAAE;CAE1B,MAAM,OAAO,IAAI,IAAI,CAAC,GAAG,OAAO,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,CAAC;AAEzD,MAAK,MAAM,OAAO,MAAM;EACtB,MAAM,IAAI,OAAO,IAAI,IAAI,IAAI;EAC7B,MAAM,IAAI,MAAM,IAAI,IAAI,IAAI;AAE5B,MAAI,IAAI,EAAG,SAAQ,KAAK,IAAI;AAC5B,MAAI,IAAI,EAAG,OAAM,KAAK,IAAI;;AAG5B,QAAO;EAAE;EAAS;EAAO"}
|