@vamos-ui/react 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +27 -2
- package/dist/blocks/block-heading.d.ts +29 -0
- package/dist/blocks/block-heading.js +39 -0
- package/dist/blocks/block-image.d.ts +52 -0
- package/dist/blocks/block-image.js +48 -0
- package/dist/blocks/block-link.d.ts +30 -0
- package/dist/blocks/block-link.js +36 -0
- package/dist/blocks/create-blocks.d.ts +54 -0
- package/dist/blocks/create-blocks.js +52 -0
- package/dist/blocks/index.d.ts +55 -0
- package/dist/blocks/index.js +59 -0
- package/dist/blocks/json-ld.d.ts +18 -0
- package/dist/blocks/json-ld.js +44 -0
- package/dist/blocks/labels.d.ts +20 -0
- package/dist/blocks/labels.js +43 -0
- package/dist/blocks/rich-text.d.ts +36 -0
- package/dist/blocks/rich-text.js +106 -0
- package/dist/blocks/schema/define-block.d.ts +151 -0
- package/dist/blocks/schema/define-block.js +120 -0
- package/dist/blocks/schema/emphasis.d.ts +17 -0
- package/dist/blocks/schema/emphasis.js +69 -0
- package/dist/blocks/schema/fields.d.ts +497 -0
- package/dist/blocks/schema/fields.js +240 -0
- package/dist/blocks/schema/icons.d.ts +2 -0
- package/dist/blocks/schema/icons.js +26 -0
- package/dist/blocks/schema/index.d.ts +18 -0
- package/dist/blocks/schema/index.js +21 -0
- package/dist/blocks/schema/lint-types.d.ts +16 -0
- package/dist/blocks/schema/lint-types.js +2 -0
- package/dist/blocks/schema/lint.d.ts +32 -0
- package/dist/blocks/schema/lint.js +164 -0
- package/dist/blocks/schema/localize.d.ts +20 -0
- package/dist/blocks/schema/localize.js +29 -0
- package/dist/blocks/schema/localized.d.ts +25 -0
- package/dist/blocks/schema/localized.js +53 -0
- package/dist/blocks/schema/migrate.d.ts +24 -0
- package/dist/blocks/schema/migrate.js +75 -0
- package/dist/blocks/schema/nodes.d.ts +196 -0
- package/dist/blocks/schema/nodes.js +78 -0
- package/dist/blocks/schema/rich-doc-schema.d.ts +32 -0
- package/dist/blocks/schema/rich-doc-schema.js +66 -0
- package/dist/blocks/schema/rich-doc.d.ts +90 -0
- package/dist/blocks/schema/rich-doc.js +62 -0
- package/dist/blocks/schema/safety.d.ts +20 -0
- package/dist/blocks/schema/safety.js +49 -0
- package/dist/blocks/schema/types.d.ts +172 -0
- package/dist/blocks/schema/types.js +3 -0
- package/dist/blocks/schema/validate.d.ts +17 -0
- package/dist/blocks/schema/validate.js +32 -0
- package/dist/blocks/schema/walk.d.ts +22 -0
- package/dist/blocks/schema/walk.js +60 -0
- package/dist/blocks/section-header.d.ts +38 -0
- package/dist/blocks/section-header.js +22 -0
- package/dist/blocks/section.d.ts +59 -0
- package/dist/blocks/section.js +66 -0
- package/dist/blocks/site/_kit-1.d.ts +101 -0
- package/dist/blocks/site/_kit-1.js +137 -0
- package/dist/blocks/site/_site-icon-1.d.ts +6 -0
- package/dist/blocks/site/_site-icon-1.js +15 -0
- package/dist/blocks/site/announcement-bar.d.ts +42 -0
- package/dist/blocks/site/announcement-bar.js +38 -0
- package/dist/blocks/site/announcement-dismiss.d.ts +18 -0
- package/dist/blocks/site/announcement-dismiss.js +28 -0
- package/dist/blocks/site/article-layout.d.ts +65 -0
- package/dist/blocks/site/article-layout.js +88 -0
- package/dist/blocks/site/blog-list.d.ts +79 -0
- package/dist/blocks/site/blog-list.js +78 -0
- package/dist/blocks/site/comparison-table.d.ts +54 -0
- package/dist/blocks/site/comparison-table.js +38 -0
- package/dist/blocks/site/consent-banner.d.ts +52 -0
- package/dist/blocks/site/consent-banner.js +33 -0
- package/dist/blocks/site/contact-dock.d.ts +52 -0
- package/dist/blocks/site/contact-dock.js +55 -0
- package/dist/blocks/site/contact-form.d.ts +60 -0
- package/dist/blocks/site/contact-form.js +45 -0
- package/dist/blocks/site/cta-booking.d.ts +43 -0
- package/dist/blocks/site/cta-booking.js +69 -0
- package/dist/blocks/site/cta.d.ts +74 -0
- package/dist/blocks/site/cta.js +113 -0
- package/dist/blocks/site/embed-facade.d.ts +20 -0
- package/dist/blocks/site/embed-facade.js +21 -0
- package/dist/blocks/site/faq.d.ts +48 -0
- package/dist/blocks/site/faq.js +52 -0
- package/dist/blocks/site/feature-grid.d.ts +46 -0
- package/dist/blocks/site/feature-grid.js +50 -0
- package/dist/blocks/site/feature-tabs.d.ts +22 -0
- package/dist/blocks/site/feature-tabs.js +11 -0
- package/dist/blocks/site/footer.d.ts +68 -0
- package/dist/blocks/site/footer.js +61 -0
- package/dist/blocks/site/gallery-section.d.ts +42 -0
- package/dist/blocks/site/gallery-section.js +48 -0
- package/dist/blocks/site/hero-video.d.ts +15 -0
- package/dist/blocks/site/hero-video.js +31 -0
- package/dist/blocks/site/hero.d.ts +64 -0
- package/dist/blocks/site/hero.js +73 -0
- package/dist/blocks/site/logo-strip.d.ts +44 -0
- package/dist/blocks/site/logo-strip.js +27 -0
- package/dist/blocks/site/map-hours.d.ts +83 -0
- package/dist/blocks/site/map-hours.js +125 -0
- package/dist/blocks/site/media-text.d.ts +45 -0
- package/dist/blocks/site/media-text.js +56 -0
- package/dist/blocks/site/menu-list.d.ts +74 -0
- package/dist/blocks/site/menu-list.js +84 -0
- package/dist/blocks/site/navbar-submenu.d.ts +18 -0
- package/dist/blocks/site/navbar-submenu.js +51 -0
- package/dist/blocks/site/navbar.d.ts +67 -0
- package/dist/blocks/site/navbar.js +64 -0
- package/dist/blocks/site/not-found.d.ts +40 -0
- package/dist/blocks/site/not-found.js +38 -0
- package/dist/blocks/site/page-intro.d.ts +46 -0
- package/dist/blocks/site/page-intro.js +44 -0
- package/dist/blocks/site/pricing-table.d.ts +67 -0
- package/dist/blocks/site/pricing-table.js +83 -0
- package/dist/blocks/site/process.d.ts +36 -0
- package/dist/blocks/site/process.js +42 -0
- package/dist/blocks/site/registry-1.d.ts +720 -0
- package/dist/blocks/site/registry-1.js +783 -0
- package/dist/blocks/site/registry-2.d.ts +914 -0
- package/dist/blocks/site/registry-2.js +563 -0
- package/dist/blocks/site/rich-text-section.d.ts +34 -0
- package/dist/blocks/site/rich-text-section.js +32 -0
- package/dist/blocks/site/shared/brand-icons.d.ts +21 -0
- package/dist/blocks/site/shared/brand-icons.js +56 -0
- package/dist/blocks/site/shared/consent-gate.d.ts +41 -0
- package/dist/blocks/site/shared/consent-gate.js +43 -0
- package/dist/blocks/site/shared/consent-island.d.ts +38 -0
- package/dist/blocks/site/shared/consent-island.js +63 -0
- package/dist/blocks/site/shared/consent.d.ts +49 -0
- package/dist/blocks/site/shared/consent.js +130 -0
- package/dist/blocks/site/shared/contact-form-island.d.ts +41 -0
- package/dist/blocks/site/shared/contact-form-island.js +100 -0
- package/dist/blocks/site/shared/copy-link.d.ts +10 -0
- package/dist/blocks/site/shared/copy-link.js +25 -0
- package/dist/blocks/site/shared/dock-avoid.d.ts +15 -0
- package/dist/blocks/site/shared/dock-avoid.js +107 -0
- package/dist/blocks/site/shared/dock-hours.d.ts +13 -0
- package/dist/blocks/site/shared/dock-hours.js +25 -0
- package/dist/blocks/site/shared/gallery-lightbox.d.ts +12 -0
- package/dist/blocks/site/shared/gallery-lightbox.js +10 -0
- package/dist/blocks/site/shared/island-keys.d.ts +10 -0
- package/dist/blocks/site/shared/island-keys.js +44 -0
- package/dist/blocks/site/shared/kit-2.d.ts +55 -0
- package/dist/blocks/site/shared/kit-2.js +84 -0
- package/dist/blocks/site/shared/labels-2.d.ts +209 -0
- package/dist/blocks/site/shared/labels-2.js +427 -0
- package/dist/blocks/site/shared/open-now.d.ts +22 -0
- package/dist/blocks/site/shared/open-now.js +27 -0
- package/dist/blocks/site/shared/opening-hours.d.ts +117 -0
- package/dist/blocks/site/shared/opening-hours.js +245 -0
- package/dist/blocks/site/shared/site-accent.d.ts +48 -0
- package/dist/blocks/site/shared/site-accent.js +249 -0
- package/dist/blocks/site/shared/site-form.d.ts +79 -0
- package/dist/blocks/site/shared/site-form.js +111 -0
- package/dist/blocks/site/shared/site-routing.d.ts +54 -0
- package/dist/blocks/site/shared/site-routing.js +86 -0
- package/dist/blocks/site/shared/testimonials-carousel.d.ts +17 -0
- package/dist/blocks/site/shared/testimonials-carousel.js +64 -0
- package/dist/blocks/site/site-shell.d.ts +108 -0
- package/dist/blocks/site/site-shell.js +254 -0
- package/dist/blocks/site/stats-band.d.ts +42 -0
- package/dist/blocks/site/stats-band.js +45 -0
- package/dist/blocks/site/team.d.ts +44 -0
- package/dist/blocks/site/team.js +48 -0
- package/dist/blocks/site/testimonials.d.ts +68 -0
- package/dist/blocks/site/testimonials.js +66 -0
- package/dist/blocks/types.d.ts +63 -0
- package/dist/blocks/types.js +2 -0
- package/dist/business/approval-flow.d.ts +152 -0
- package/dist/business/approval-flow.js +221 -0
- package/dist/business/export-core.d.ts +55 -0
- package/dist/business/export-core.js +101 -0
- package/dist/business/export.d.ts +148 -0
- package/dist/business/export.js +264 -0
- package/dist/business/import-core.d.ts +104 -0
- package/dist/business/import-core.js +281 -0
- package/dist/business/import-wizard.d.ts +186 -0
- package/dist/business/import-wizard.js +401 -0
- package/dist/business/index.d.ts +12 -0
- package/dist/business/index.js +22 -0
- package/dist/business/line-items-core.d.ts +129 -0
- package/dist/business/line-items-core.js +183 -0
- package/dist/business/line-items.d.ts +119 -0
- package/dist/business/line-items.js +299 -0
- package/dist/business/multi-step-form.d.ts +131 -0
- package/dist/business/multi-step-form.js +337 -0
- package/dist/business/permission-core.d.ts +59 -0
- package/dist/business/permission-core.js +99 -0
- package/dist/business/permission-matrix.d.ts +158 -0
- package/dist/business/permission-matrix.js +341 -0
- package/dist/business/setup-checklist.d.ts +80 -0
- package/dist/business/setup-checklist.js +92 -0
- package/dist/business/signer-status.d.ts +53 -0
- package/dist/business/signer-status.js +76 -0
- package/dist/charts/area-chart.d.ts +35 -0
- package/dist/charts/area-chart.js +33 -0
- package/dist/charts/bar-chart.d.ts +27 -0
- package/dist/charts/bar-chart.js +46 -0
- package/dist/charts/bar-list.d.ts +47 -0
- package/dist/charts/bar-list.js +60 -0
- package/dist/charts/chart-shell.d.ts +173 -0
- package/dist/charts/chart-shell.js +205 -0
- package/dist/charts/chart.d.ts +73 -0
- package/dist/charts/chart.js +106 -0
- package/dist/charts/combo-chart.d.ts +29 -0
- package/dist/charts/combo-chart.js +47 -0
- package/dist/charts/donut-chart.d.ts +33 -0
- package/dist/charts/donut-chart.js +113 -0
- package/dist/charts/funnel.d.ts +51 -0
- package/dist/charts/funnel.js +69 -0
- package/dist/charts/gauge.d.ts +62 -0
- package/dist/charts/gauge.js +104 -0
- package/dist/charts/heatmap.d.ts +81 -0
- package/dist/charts/heatmap.js +338 -0
- package/dist/charts/index.d.ts +12 -0
- package/dist/charts/index.js +14 -0
- package/dist/charts/line-chart.d.ts +21 -0
- package/dist/charts/line-chart.js +36 -0
- package/dist/charts/test-utils.d.ts +2 -0
- package/dist/charts/test-utils.js +38 -0
- package/dist/charts/utils.d.ts +130 -0
- package/dist/charts/utils.js +262 -0
- package/dist/components/_qr-core.d.ts +26 -0
- package/dist/components/_qr-core.js +376 -0
- package/dist/components/accordion.d.ts +47 -0
- package/dist/components/accordion.js +70 -0
- package/dist/components/activity-timeline.d.ts +149 -0
- package/dist/components/activity-timeline.js +122 -0
- package/dist/components/address-field.d.ts +116 -0
- package/dist/components/address-field.js +219 -0
- package/dist/components/alert-dialog.d.ts +99 -0
- package/dist/components/alert-dialog.js +192 -0
- package/dist/components/alert.d.ts +42 -0
- package/dist/components/alert.js +82 -0
- package/dist/components/app-shell.d.ts +159 -0
- package/dist/components/app-shell.js +289 -0
- package/dist/components/attachment-list.d.ts +96 -0
- package/dist/components/attachment-list.js +196 -0
- package/dist/components/audit-log.d.ts +150 -0
- package/dist/components/audit-log.js +205 -0
- package/dist/components/avatar.d.ts +87 -0
- package/dist/components/avatar.js +126 -0
- package/dist/components/backup-codes.d.ts +42 -0
- package/dist/components/backup-codes.js +67 -0
- package/dist/components/badge.d.ts +41 -0
- package/dist/components/badge.js +68 -0
- package/dist/components/breadcrumb.d.ts +78 -0
- package/dist/components/breadcrumb.js +106 -0
- package/dist/components/button-group.d.ts +52 -0
- package/dist/components/button-group.js +77 -0
- package/dist/components/button.d.ts +58 -0
- package/dist/components/button.js +107 -0
- package/dist/components/calendar.d.ts +240 -0
- package/dist/components/calendar.js +483 -0
- package/dist/components/card.d.ts +66 -0
- package/dist/components/card.js +76 -0
- package/dist/components/carousel.d.ts +170 -0
- package/dist/components/carousel.js +348 -0
- package/dist/components/checkbox.d.ts +78 -0
- package/dist/components/checkbox.js +138 -0
- package/dist/components/color-picker.d.ts +112 -0
- package/dist/components/color-picker.js +235 -0
- package/dist/components/combobox.d.ts +136 -0
- package/dist/components/combobox.js +294 -0
- package/dist/components/command.d.ts +281 -0
- package/dist/components/command.js +498 -0
- package/dist/components/comment-thread.d.ts +252 -0
- package/dist/components/comment-thread.js +449 -0
- package/dist/components/context-menu.d.ts +77 -0
- package/dist/components/context-menu.js +82 -0
- package/dist/components/currency-input.d.ts +43 -0
- package/dist/components/currency-input.js +85 -0
- package/dist/components/date-picker.d.ts +141 -0
- package/dist/components/date-picker.js +241 -0
- package/dist/components/date-range-picker.d.ts +91 -0
- package/dist/components/date-range-picker.js +251 -0
- package/dist/components/description-list.d.ts +92 -0
- package/dist/components/description-list.js +42 -0
- package/dist/components/dialog.d.ts +139 -0
- package/dist/components/dialog.js +185 -0
- package/dist/components/dropdown-menu.d.ts +100 -0
- package/dist/components/dropdown-menu.js +102 -0
- package/dist/components/editor-layout.d.ts +166 -0
- package/dist/components/editor-layout.js +237 -0
- package/dist/components/empty-state.d.ts +49 -0
- package/dist/components/empty-state.js +68 -0
- package/dist/components/entity-card.d.ts +83 -0
- package/dist/components/entity-card.js +92 -0
- package/dist/components/file-upload.d.ts +256 -0
- package/dist/components/file-upload.js +490 -0
- package/dist/components/formatted-input.d.ts +177 -0
- package/dist/components/formatted-input.js +399 -0
- package/dist/components/hierarchy-chart.d.ts +190 -0
- package/dist/components/hierarchy-chart.js +890 -0
- package/dist/components/hover-card.d.ts +21 -0
- package/dist/components/hover-card.js +32 -0
- package/dist/components/iban-input.d.ts +38 -0
- package/dist/components/iban-input.js +112 -0
- package/dist/components/id-input.d.ts +65 -0
- package/dist/components/id-input.js +130 -0
- package/dist/components/image.d.ts +130 -0
- package/dist/components/image.js +168 -0
- package/dist/components/input-otp.d.ts +62 -0
- package/dist/components/input-otp.js +73 -0
- package/dist/components/input.d.ts +141 -0
- package/dist/components/input.js +187 -0
- package/dist/components/item.d.ts +96 -0
- package/dist/components/item.js +113 -0
- package/dist/components/kbd.d.ts +64 -0
- package/dist/components/kbd.js +119 -0
- package/dist/components/list-layout.d.ts +144 -0
- package/dist/components/list-layout.js +210 -0
- package/dist/components/native-select.d.ts +33 -0
- package/dist/components/native-select.js +48 -0
- package/dist/components/navigation-menu.d.ts +127 -0
- package/dist/components/navigation-menu.js +129 -0
- package/dist/components/notification-center.d.ts +164 -0
- package/dist/components/notification-center.js +399 -0
- package/dist/components/page-header.d.ts +60 -0
- package/dist/components/page-header.js +60 -0
- package/dist/components/pagination.d.ts +121 -0
- package/dist/components/pagination.js +174 -0
- package/dist/components/phone-input.d.ts +49 -0
- package/dist/components/phone-input.js +266 -0
- package/dist/components/pin-map.d.ts +58 -0
- package/dist/components/pin-map.js +167 -0
- package/dist/components/popover.d.ts +38 -0
- package/dist/components/popover.js +69 -0
- package/dist/components/progress.d.ts +79 -0
- package/dist/components/progress.js +97 -0
- package/dist/components/qr-code.d.ts +36 -0
- package/dist/components/qr-code.js +27 -0
- package/dist/components/radio-group.d.ts +43 -0
- package/dist/components/radio-group.js +81 -0
- package/dist/components/record-detail-layout.d.ts +167 -0
- package/dist/components/record-detail-layout.js +233 -0
- package/dist/components/record-picker.d.ts +199 -0
- package/dist/components/record-picker.js +650 -0
- package/dist/components/resizable.d.ts +50 -0
- package/dist/components/resizable.js +88 -0
- package/dist/components/scroll-area.d.ts +40 -0
- package/dist/components/scroll-area.js +56 -0
- package/dist/components/select.d.ts +126 -0
- package/dist/components/select.js +137 -0
- package/dist/components/separator.d.ts +31 -0
- package/dist/components/separator.js +41 -0
- package/dist/components/settings-layout.d.ts +134 -0
- package/dist/components/settings-layout.js +180 -0
- package/dist/components/sheet.d.ts +103 -0
- package/dist/components/sheet.js +165 -0
- package/dist/components/sidebar.d.ts +171 -0
- package/dist/components/sidebar.js +421 -0
- package/dist/components/signature-pad.d.ts +85 -0
- package/dist/components/signature-pad.js +283 -0
- package/dist/components/skeleton.d.ts +64 -0
- package/dist/components/skeleton.js +53 -0
- package/dist/components/sla-timer.d.ts +75 -0
- package/dist/components/sla-timer.js +142 -0
- package/dist/components/slider.d.ts +57 -0
- package/dist/components/slider.js +133 -0
- package/dist/components/slug-input.d.ts +69 -0
- package/dist/components/slug-input.js +201 -0
- package/dist/components/sparkline.d.ts +54 -0
- package/dist/components/sparkline.js +122 -0
- package/dist/components/spinner.d.ts +34 -0
- package/dist/components/spinner.js +34 -0
- package/dist/components/stat.d.ts +135 -0
- package/dist/components/stat.js +130 -0
- package/dist/components/status-picker.d.ts +107 -0
- package/dist/components/status-picker.js +175 -0
- package/dist/components/stepper.d.ts +86 -0
- package/dist/components/stepper.js +103 -0
- package/dist/components/switch.d.ts +34 -0
- package/dist/components/switch.js +70 -0
- package/dist/components/table.d.ts +101 -0
- package/dist/components/table.js +72 -0
- package/dist/components/tabs.d.ts +103 -0
- package/dist/components/tabs.js +173 -0
- package/dist/components/tag-input.d.ts +77 -0
- package/dist/components/tag-input.js +305 -0
- package/dist/components/task-list.d.ts +89 -0
- package/dist/components/task-list.js +238 -0
- package/dist/components/time-picker.d.ts +119 -0
- package/dist/components/time-picker.js +399 -0
- package/dist/components/toast.d.ts +87 -0
- package/dist/components/toast.js +142 -0
- package/dist/components/toggle.d.ts +77 -0
- package/dist/components/toggle.js +109 -0
- package/dist/components/tooltip.d.ts +69 -0
- package/dist/components/tooltip.js +105 -0
- package/dist/components/top-bar.d.ts +87 -0
- package/dist/components/top-bar.js +99 -0
- package/dist/components/tour.d.ts +60 -0
- package/dist/components/tour.js +139 -0
- package/dist/components/tree-select.d.ts +89 -0
- package/dist/components/tree-select.js +243 -0
- package/dist/components/tree-view.d.ts +109 -0
- package/dist/components/tree-view.js +170 -0
- package/dist/components/typography.d.ts +107 -0
- package/dist/components/typography.js +128 -0
- package/dist/components/user-picker.d.ts +89 -0
- package/dist/components/user-picker.js +162 -0
- package/dist/components/version-history.d.ts +191 -0
- package/dist/components/version-history.js +431 -0
- package/dist/data-table/csv.d.ts +27 -0
- package/dist/data-table/csv.js +68 -0
- package/dist/data-table/data-table.d.ts +423 -0
- package/dist/data-table/data-table.js +1259 -0
- package/dist/data-table/filter-bar.d.ts +146 -0
- package/dist/data-table/filter-bar.js +569 -0
- package/dist/data-table/filter-fns.d.ts +65 -0
- package/dist/data-table/filter-fns.js +382 -0
- package/dist/data-table/index.d.ts +8 -0
- package/dist/data-table/index.js +9 -0
- package/dist/data-table/saved-views.d.ts +100 -0
- package/dist/data-table/saved-views.js +251 -0
- package/dist/data-table/types.d.ts +168 -0
- package/dist/data-table/types.js +87 -0
- package/dist/data-table/url-state.d.ts +94 -0
- package/dist/data-table/url-state.js +303 -0
- package/dist/data-table/view-state.d.ts +16 -0
- package/dist/data-table/view-state.js +81 -0
- package/dist/editor/_test-setup.d.ts +1 -0
- package/dist/editor/_test-setup.js +33 -0
- package/dist/editor/block-editor.d.ts +137 -0
- package/dist/editor/block-editor.js +280 -0
- package/dist/editor/commands.d.ts +31 -0
- package/dist/editor/commands.js +150 -0
- package/dist/editor/context.d.ts +108 -0
- package/dist/editor/context.js +30 -0
- package/dist/editor/convert.d.ts +66 -0
- package/dist/editor/convert.js +567 -0
- package/dist/editor/drag-handle.d.ts +10 -0
- package/dist/editor/drag-handle.js +69 -0
- package/dist/editor/extensions.d.ts +34 -0
- package/dist/editor/extensions.js +239 -0
- package/dist/editor/index.d.ts +14 -0
- package/dist/editor/index.js +17 -0
- package/dist/editor/inserter.d.ts +12 -0
- package/dist/editor/inserter.js +88 -0
- package/dist/editor/inspector.d.ts +17 -0
- package/dist/editor/inspector.js +65 -0
- package/dist/editor/items.d.ts +62 -0
- package/dist/editor/items.js +195 -0
- package/dist/editor/labels.d.ts +119 -0
- package/dist/editor/labels.js +130 -0
- package/dist/editor/markdown.d.ts +14 -0
- package/dist/editor/markdown.js +209 -0
- package/dist/editor/menus.d.ts +20 -0
- package/dist/editor/menus.js +236 -0
- package/dist/editor/nodes.d.ts +14 -0
- package/dist/editor/nodes.js +201 -0
- package/dist/editor/outline.d.ts +11 -0
- package/dist/editor/outline.js +52 -0
- package/dist/editor/schema-form.d.ts +64 -0
- package/dist/editor/schema-form.js +290 -0
- package/dist/editor/slash-menu.d.ts +15 -0
- package/dist/editor/slash-menu.js +119 -0
- package/dist/fonts/catalog.d.ts +53 -0
- package/dist/fonts/catalog.js +121 -0
- package/dist/fonts/font-picker.d.ts +70 -0
- package/dist/fonts/font-picker.js +225 -0
- package/dist/fonts/index.d.ts +6 -0
- package/dist/fonts/index.js +7 -0
- package/dist/fonts/loader.d.ts +66 -0
- package/dist/fonts/loader.js +161 -0
- package/dist/fonts/pairing-picker.d.ts +31 -0
- package/dist/fonts/pairing-picker.js +81 -0
- package/dist/fonts/pairings.d.ts +84 -0
- package/dist/fonts/pairings.js +149 -0
- package/dist/fonts/provider.d.ts +34 -0
- package/dist/fonts/provider.js +51 -0
- package/dist/form/index.d.ts +1 -0
- package/dist/form/index.js +1 -0
- package/dist/format/core.d.ts +149 -0
- package/dist/format/core.js +357 -0
- package/dist/format/index.d.ts +4 -0
- package/dist/format/index.js +5 -0
- package/dist/format/use-format.d.ts +1 -0
- package/dist/format/use-format.js +3 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.js +92 -0
- package/dist/lib/cn.d.ts +3 -0
- package/dist/lib/cn.js +16 -0
- package/dist/lib/color.d.ts +64 -0
- package/dist/lib/color.js +177 -0
- package/dist/lib/compose-refs.d.ts +24 -0
- package/dist/lib/compose-refs.js +45 -0
- package/dist/lib/data-islands.d.ts +194 -0
- package/dist/lib/data-islands.js +368 -0
- package/dist/lib/date.d.ts +129 -0
- package/dist/lib/date.js +386 -0
- package/dist/lib/field-context.d.ts +64 -0
- package/dist/lib/field-context.js +62 -0
- package/dist/lib/floating-arrow.d.ts +18 -0
- package/dist/lib/floating-arrow.js +15 -0
- package/dist/lib/islands.d.ts +38 -0
- package/dist/lib/islands.js +40 -0
- package/dist/lib/labels.d.ts +51 -0
- package/dist/lib/labels.js +56 -0
- package/dist/lib/layer.d.ts +36 -0
- package/dist/lib/layer.js +42 -0
- package/dist/lib/locale.d.ts +85 -0
- package/dist/lib/locale.js +105 -0
- package/dist/lib/menu.d.ts +58 -0
- package/dist/lib/menu.js +99 -0
- package/dist/lib/message-format.d.ts +20 -0
- package/dist/lib/message-format.js +116 -0
- package/dist/lib/nav.d.ts +132 -0
- package/dist/lib/nav.js +178 -0
- package/dist/lib/provider.d.ts +100 -0
- package/dist/lib/provider.js +105 -0
- package/dist/lib/public.d.ts +23 -0
- package/dist/lib/public.js +34 -0
- package/dist/lib/sr-name.d.ts +18 -0
- package/dist/lib/sr-name.js +17 -0
- package/dist/lib/text.d.ts +100 -0
- package/dist/lib/text.js +233 -0
- package/dist/lib/theme-scope.d.ts +58 -0
- package/dist/lib/theme-scope.js +59 -0
- package/dist/lib/use-async-list.d.ts +60 -0
- package/dist/lib/use-async-list.js +119 -0
- package/dist/lib/use-container-width.d.ts +19 -0
- package/dist/lib/use-container-width.js +39 -0
- package/dist/lib/use-controllable-state.d.ts +33 -0
- package/dist/lib/use-controllable-state.js +56 -0
- package/dist/lib/use-edge-fade.d.ts +13 -0
- package/dist/lib/use-edge-fade.js +43 -0
- package/dist/lib/use-formatted-input.d.ts +69 -0
- package/dist/lib/use-formatted-input.js +152 -0
- package/dist/lib/use-hotkeys.d.ts +80 -0
- package/dist/lib/use-hotkeys.js +221 -0
- package/dist/lib/use-hover-intent.d.ts +44 -0
- package/dist/lib/use-hover-intent.js +119 -0
- package/dist/lib/use-media-query.d.ts +21 -0
- package/dist/lib/use-media-query.js +28 -0
- package/dist/lib/use-reduced-motion.d.ts +8 -0
- package/dist/lib/use-reduced-motion.js +13 -0
- package/dist/lib/use-tree.d.ts +153 -0
- package/dist/lib/use-tree.js +534 -0
- package/dist/lib/value-format.d.ts +25 -0
- package/dist/lib/value-format.js +56 -0
- package/dist/lib/variants.d.ts +131 -0
- package/dist/lib/variants.js +109 -0
- package/dist/locale-data/core/date.d.ts +24 -0
- package/dist/locale-data/core/date.js +68 -0
- package/dist/locale-data/core/decimal.d.ts +19 -0
- package/dist/locale-data/core/decimal.js +79 -0
- package/dist/locale-data/core/holidays.d.ts +30 -0
- package/dist/locale-data/core/holidays.js +79 -0
- package/dist/locale-data/core/iban.d.ts +29 -0
- package/dist/locale-data/core/iban.js +74 -0
- package/dist/locale-data/core/index.d.ts +7 -0
- package/dist/locale-data/core/index.js +6 -0
- package/dist/locale-data/core/types.d.ts +173 -0
- package/dist/locale-data/core/types.js +6 -0
- package/dist/locale-data/core/week-info.d.ts +23 -0
- package/dist/locale-data/core/week-info.js +85 -0
- package/dist/locale-data/core/working-days.d.ts +27 -0
- package/dist/locale-data/core/working-days.js +133 -0
- package/dist/locale-data/index.d.ts +2 -0
- package/dist/locale-data/index.js +4 -0
- package/dist/locale-data/tr/address-tr.json +1 -0
- package/dist/locale-data/tr/address.d.ts +23 -0
- package/dist/locale-data/tr/address.js +52 -0
- package/dist/locale-data/tr/holidays.d.ts +31 -0
- package/dist/locale-data/tr/holidays.js +81 -0
- package/dist/locale-data/tr/iban.d.ts +21 -0
- package/dist/locale-data/tr/iban.js +45 -0
- package/dist/locale-data/tr/id.d.ts +36 -0
- package/dist/locale-data/tr/id.js +120 -0
- package/dist/locale-data/tr/index.d.ts +12 -0
- package/dist/locale-data/tr/index.js +33 -0
- package/dist/locale-data/tr/kdv.d.ts +91 -0
- package/dist/locale-data/tr/kdv.js +222 -0
- package/dist/locales/en.d.ts +2102 -0
- package/dist/locales/en.js +2088 -0
- package/dist/locales/tr.d.ts +2086 -0
- package/dist/locales/tr.js +2087 -0
- package/dist/media/focal-point.d.ts +42 -0
- package/dist/media/focal-point.js +96 -0
- package/dist/media/gallery-layout.d.ts +19 -0
- package/dist/media/gallery-layout.js +61 -0
- package/dist/media/gallery.d.ts +64 -0
- package/dist/media/gallery.js +140 -0
- package/dist/media/image-cropper.d.ts +86 -0
- package/dist/media/image-cropper.js +170 -0
- package/dist/media/image-field.d.ts +115 -0
- package/dist/media/image-field.js +212 -0
- package/dist/media/index.d.ts +19 -0
- package/dist/media/index.js +23 -0
- package/dist/media/lightbox.d.ts +82 -0
- package/dist/media/lightbox.js +171 -0
- package/dist/media/link-preview.d.ts +97 -0
- package/dist/media/link-preview.js +177 -0
- package/dist/media/media-library.d.ts +244 -0
- package/dist/media/media-library.js +776 -0
- package/dist/media/media-picker.d.ts +96 -0
- package/dist/media/media-picker.js +209 -0
- package/dist/media/media-provider.d.ts +23 -0
- package/dist/media/media-provider.js +44 -0
- package/dist/media/media-utils.d.ts +39 -0
- package/dist/media/media-utils.js +145 -0
- package/dist/media/memory-adapter.d.ts +22 -0
- package/dist/media/memory-adapter.js +162 -0
- package/dist/media/rest-adapter.d.ts +90 -0
- package/dist/media/rest-adapter.js +208 -0
- package/dist/media/serp.d.ts +62 -0
- package/dist/media/serp.js +108 -0
- package/dist/media/test-fixtures.d.ts +3 -0
- package/dist/media/test-fixtures.js +37 -0
- package/dist/media/types.d.ts +183 -0
- package/dist/media/types.js +3 -0
- package/dist/media/use-pan-zoom.d.ts +51 -0
- package/dist/media/use-pan-zoom.js +156 -0
- package/dist/media/use-upload-queue.d.ts +64 -0
- package/dist/media/use-upload-queue.js +115 -0
- package/dist/media/video-player.d.ts +135 -0
- package/dist/media/video-player.js +319 -0
- package/dist/motion/core.d.ts +32 -0
- package/dist/motion/core.js +77 -0
- package/dist/motion/count-up.d.ts +29 -0
- package/dist/motion/count-up.js +92 -0
- package/dist/motion/index.d.ts +11 -0
- package/dist/motion/index.js +13 -0
- package/dist/motion/motion-scope.d.ts +17 -0
- package/dist/motion/motion-scope.js +16 -0
- package/dist/motion/page-transition.d.ts +33 -0
- package/dist/motion/page-transition.js +61 -0
- package/dist/motion/parallax.d.ts +37 -0
- package/dist/motion/parallax.js +90 -0
- package/dist/motion/pointer.d.ts +38 -0
- package/dist/motion/pointer.js +117 -0
- package/dist/motion/reveal.d.ts +72 -0
- package/dist/motion/reveal.js +133 -0
- package/dist/motion/scroll-shrink.d.ts +18 -0
- package/dist/motion/scroll-shrink.js +47 -0
- package/dist/motion/skeleton-swap.d.ts +17 -0
- package/dist/motion/skeleton-swap.js +43 -0
- package/dist/motion/text-reveal.d.ts +30 -0
- package/dist/motion/text-reveal.js +29 -0
- package/dist/motion/ticker.d.ts +35 -0
- package/dist/motion/ticker.js +16 -0
- package/dist/next/index.d.ts +42 -0
- package/dist/next/index.js +36 -0
- package/dist/render/block-renderer.d.ts +56 -0
- package/dist/render/block-renderer.js +137 -0
- package/dist/render/index.d.ts +6 -0
- package/dist/render/index.js +7 -0
- package/dist/render/prepare.d.ts +61 -0
- package/dist/render/prepare.js +119 -0
- package/dist/scheduler/core/duration.d.ts +83 -0
- package/dist/scheduler/core/duration.js +174 -0
- package/dist/scheduler/core/gantt.d.ts +63 -0
- package/dist/scheduler/core/gantt.js +226 -0
- package/dist/scheduler/core/index.d.ts +6 -0
- package/dist/scheduler/core/index.js +7 -0
- package/dist/scheduler/core/layout.d.ts +97 -0
- package/dist/scheduler/core/layout.js +249 -0
- package/dist/scheduler/core/time-scale.d.ts +89 -0
- package/dist/scheduler/core/time-scale.js +173 -0
- package/dist/scheduler/gantt.d.ts +125 -0
- package/dist/scheduler/gantt.js +532 -0
- package/dist/scheduler/index.d.ts +6 -0
- package/dist/scheduler/index.js +7 -0
- package/dist/scheduler/resource-calendar.d.ts +218 -0
- package/dist/scheduler/resource-calendar.js +661 -0
- package/dist/scheduler/scheduler.d.ts +168 -0
- package/dist/scheduler/scheduler.js +768 -0
- package/dist/scheduler/shared.d.ts +63 -0
- package/dist/scheduler/shared.js +145 -0
- package/dist/scheduler/time-tracker.d.ts +138 -0
- package/dist/scheduler/time-tracker.js +403 -0
- package/dist/sortable/core.d.ts +67 -0
- package/dist/sortable/core.js +167 -0
- package/dist/sortable/index.d.ts +8 -0
- package/dist/sortable/index.js +10 -0
- package/dist/sortable/kanban-core.d.ts +70 -0
- package/dist/sortable/kanban-core.js +67 -0
- package/dist/sortable/kanban.d.ts +147 -0
- package/dist/sortable/kanban.js +472 -0
- package/dist/sortable/sortable-list.d.ts +71 -0
- package/dist/sortable/sortable-list.js +76 -0
- package/dist/sortable/sortable-tree.d.ts +105 -0
- package/dist/sortable/sortable-tree.js +462 -0
- package/dist/sortable/sortable.d.ts +188 -0
- package/dist/sortable/sortable.js +485 -0
- package/dist/sortable/use-pointer-drag.d.ts +75 -0
- package/dist/sortable/use-pointer-drag.js +173 -0
- package/dist/sortable/use-time-scale.d.ts +11 -0
- package/dist/sortable/use-time-scale.js +19 -0
- package/dist/styles/base.css +51 -0
- package/dist/styles/blocks.css +949 -0
- package/dist/styles/calendar.css +642 -0
- package/dist/styles/charts.css +264 -0
- package/dist/styles/data.css +474 -0
- package/dist/styles/editors.css +1022 -0
- package/dist/styles/forms.css +406 -0
- package/dist/styles/media.css +515 -0
- package/dist/styles/motion.css +389 -0
- package/dist/styles/navigation.css +293 -0
- package/dist/styles/overlays.css +244 -0
- package/dist/styles.css +743 -0
- package/package.json +160 -4
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
// VamosDoc <-> ProseMirror JSON. Pure functions, no Tiptap runtime: usable on the server
|
|
2
|
+
// (imports, AI drafts, tests) and by the editor. The storage format is frozen in
|
|
3
|
+
// docs/plan/BLOCK-FORMAT.md; this file is the "editor mapping" described there.
|
|
4
|
+
import { migrateDoc } from "../blocks/schema/migrate.js";
|
|
5
|
+
import { inlineToText, isBreak, countWords as countWordsRegex } from "../blocks/schema/rich-doc.js";
|
|
6
|
+
/** ProseMirror node name of component blocks (hero, pricing, FAQ…). */
|
|
7
|
+
export const COMPONENT_BLOCK = "vamosBlock";
|
|
8
|
+
/** Block types the editor edits as native text (everything else is a component block). */
|
|
9
|
+
export const EDITOR_TEXT_TYPES = ["paragraph", "heading", "list", "list-item", "quote", "code", "divider", "image", "table", "table-row", "table-cell"];
|
|
10
|
+
export const isEditorTextType = (t) => EDITOR_TEXT_TYPES.includes(t);
|
|
11
|
+
// ---------------------------------------------------------------- ids
|
|
12
|
+
const ID_ALPHABET = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
13
|
+
const ID_RE = /^[A-Za-z0-9_-]{4,64}$/;
|
|
14
|
+
/** A new stable block id (`b_` + 8 random characters). */
|
|
15
|
+
export function createBlockId() {
|
|
16
|
+
const bytes = new Uint8Array(8);
|
|
17
|
+
const c = globalThis.crypto;
|
|
18
|
+
if (c?.getRandomValues)
|
|
19
|
+
c.getRandomValues(bytes);
|
|
20
|
+
else
|
|
21
|
+
for (let i = 0; i < bytes.length; i++)
|
|
22
|
+
bytes[i] = Math.floor(Math.random() * 256);
|
|
23
|
+
let out = "b_";
|
|
24
|
+
for (const b of bytes)
|
|
25
|
+
out += ID_ALPHABET[b % ID_ALPHABET.length];
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
export const isValidBlockId = (id) => typeof id === "string" && ID_RE.test(id);
|
|
29
|
+
// ---------------------------------------------------------------- marks
|
|
30
|
+
const MARK_TO_PM = { bold: "bold", italic: "italic", underline: "underline", strike: "strike", code: "code", highlight: "highlight", sub: "subscript", sup: "superscript", link: "link" };
|
|
31
|
+
const MARK_FROM_PM = { bold: "bold", italic: "italic", underline: "underline", strike: "strike", code: "code", highlight: "highlight", subscript: "sub", superscript: "sup", link: "link" };
|
|
32
|
+
/** Canonical nesting order (BLOCK-FORMAT §3). */
|
|
33
|
+
const MARK_ORDER = ["link", "bold", "italic", "underline", "strike", "highlight", "code", "sub", "sup"];
|
|
34
|
+
function markToPM(m) {
|
|
35
|
+
const type = MARK_TO_PM[m.type];
|
|
36
|
+
if (!type)
|
|
37
|
+
return null;
|
|
38
|
+
if (m.type === "link")
|
|
39
|
+
return { type, attrs: { href: m.href, target: m.newTab ? "_blank" : null, title: m.title ?? null } };
|
|
40
|
+
return { type };
|
|
41
|
+
}
|
|
42
|
+
function markFromPM(m) {
|
|
43
|
+
const type = MARK_FROM_PM[m.type];
|
|
44
|
+
if (!type)
|
|
45
|
+
return null;
|
|
46
|
+
if (type === "link") {
|
|
47
|
+
const href = typeof m.attrs?.href === "string" ? m.attrs.href : "";
|
|
48
|
+
if (!href)
|
|
49
|
+
return null;
|
|
50
|
+
const out = { type: "link", href };
|
|
51
|
+
if (m.attrs?.target === "_blank")
|
|
52
|
+
out.newTab = true;
|
|
53
|
+
if (typeof m.attrs?.title === "string" && m.attrs.title)
|
|
54
|
+
out.title = m.attrs.title;
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
return { type };
|
|
58
|
+
}
|
|
59
|
+
const sortMarks = (marks) => [...marks].sort((a, b) => MARK_ORDER.indexOf(a.type) - MARK_ORDER.indexOf(b.type));
|
|
60
|
+
const marksKey = (marks) => (marks?.length ? JSON.stringify(sortMarks(marks)) : "");
|
|
61
|
+
/** Inline runs → ProseMirror inline nodes (`br` → hardBreak, stray `\n` tolerated). */
|
|
62
|
+
export function inlineToPM(content) {
|
|
63
|
+
const out = [];
|
|
64
|
+
for (const run of content ?? []) {
|
|
65
|
+
if (isBreak(run)) {
|
|
66
|
+
out.push({ type: "hardBreak" });
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const marks = (run.marks ?? []).map(markToPM).filter((m) => !!m);
|
|
70
|
+
run.text.split("\n").forEach((part, i) => {
|
|
71
|
+
if (i > 0)
|
|
72
|
+
out.push({ type: "hardBreak" });
|
|
73
|
+
if (part)
|
|
74
|
+
out.push(marks.length ? { type: "text", text: part, marks } : { type: "text", text: part });
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
/** ProseMirror inline nodes → inline runs (adjacent runs with equal marks merged). */
|
|
80
|
+
export function inlineFromPM(nodes) {
|
|
81
|
+
const out = [];
|
|
82
|
+
for (const n of nodes ?? []) {
|
|
83
|
+
if (n.type === "hardBreak") {
|
|
84
|
+
out.push({ type: "br" });
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (n.type !== "text" || !n.text)
|
|
88
|
+
continue;
|
|
89
|
+
const marks = sortMarks((n.marks ?? []).map((m) => markFromPM(m)).filter((m) => !!m));
|
|
90
|
+
const prev = out[out.length - 1];
|
|
91
|
+
if (prev && !isBreak(prev) && marksKey(prev.marks) === marksKey(marks)) {
|
|
92
|
+
prev.text += n.text;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
out.push(marks.length ? { text: n.text, marks } : { text: n.text });
|
|
96
|
+
}
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
function extraOf(b, skipAnchor = false) {
|
|
100
|
+
const e = {};
|
|
101
|
+
if (b.hidden)
|
|
102
|
+
e.hidden = true;
|
|
103
|
+
if (b.theme)
|
|
104
|
+
e.theme = b.theme;
|
|
105
|
+
if (b.schedule)
|
|
106
|
+
e.schedule = b.schedule;
|
|
107
|
+
if (b.variant)
|
|
108
|
+
e.variant = b.variant;
|
|
109
|
+
if (b.anchor && !skipAnchor)
|
|
110
|
+
e.anchor = b.anchor;
|
|
111
|
+
return Object.keys(e).length ? e : null;
|
|
112
|
+
}
|
|
113
|
+
function applyExtra(node, extra) {
|
|
114
|
+
if (!extra || typeof extra !== "object")
|
|
115
|
+
return node;
|
|
116
|
+
const e = extra;
|
|
117
|
+
return {
|
|
118
|
+
...node,
|
|
119
|
+
...(e.variant ? { variant: e.variant } : null),
|
|
120
|
+
...(e.theme ? { theme: e.theme } : null),
|
|
121
|
+
...(e.anchor && !node.anchor ? { anchor: e.anchor } : null),
|
|
122
|
+
...(e.hidden ? { hidden: true } : null),
|
|
123
|
+
...(e.schedule ? { schedule: e.schedule } : null),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
const para = (content, id) => {
|
|
127
|
+
const inner = inlineToPM(content);
|
|
128
|
+
return { type: "paragraph", attrs: { id: id ?? null }, ...(inner.length ? { content: inner } : null) };
|
|
129
|
+
};
|
|
130
|
+
function listItemToPM(item) {
|
|
131
|
+
const kids = item.slots?.items ?? [];
|
|
132
|
+
const content = [];
|
|
133
|
+
let rest = kids;
|
|
134
|
+
if (item.content !== undefined || !kids.length || kids[0].type !== "paragraph")
|
|
135
|
+
content.push(para(item.content));
|
|
136
|
+
else {
|
|
137
|
+
content.push(para(kids[0].content, kids[0].id));
|
|
138
|
+
rest = kids.slice(1);
|
|
139
|
+
}
|
|
140
|
+
for (const k of rest)
|
|
141
|
+
content.push(...blockToPM(k));
|
|
142
|
+
return { type: "listItem", attrs: { id: item.id }, content };
|
|
143
|
+
}
|
|
144
|
+
function cellToPM(cell) {
|
|
145
|
+
const p = (cell.props ?? {});
|
|
146
|
+
const paragraphs = cell.slots?.items?.length ? cell.slots.items.flatMap(blockToPM) : [para(cell.content)];
|
|
147
|
+
return {
|
|
148
|
+
type: p.header ? "tableHeader" : "tableCell",
|
|
149
|
+
attrs: { id: cell.id, colspan: p.colspan ?? 1, rowspan: p.rowspan ?? 1, colwidth: null },
|
|
150
|
+
content: paragraphs.length ? paragraphs : [para(undefined)],
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function blockToPM(b) {
|
|
154
|
+
const p = (b.props ?? {});
|
|
155
|
+
const extra = extraOf(b, b.type === "heading");
|
|
156
|
+
const base = { id: b.id, extra };
|
|
157
|
+
switch (b.type) {
|
|
158
|
+
case "paragraph": {
|
|
159
|
+
const inner = inlineToPM(b.content);
|
|
160
|
+
return [{ type: "paragraph", attrs: base, ...(inner.length ? { content: inner } : null) }];
|
|
161
|
+
}
|
|
162
|
+
case "heading": {
|
|
163
|
+
const inner = inlineToPM(b.content);
|
|
164
|
+
const level = Math.min(6, Math.max(1, Number(p.level) || 2));
|
|
165
|
+
return [{ type: "heading", attrs: { ...base, level, anchor: b.anchor ?? null }, ...(inner.length ? { content: inner } : null) }];
|
|
166
|
+
}
|
|
167
|
+
case "list": {
|
|
168
|
+
const items = (b.slots?.items ?? []).map((it) => (it.type === "list-item" ? it : { id: createBlockId(), type: "list-item", slots: { items: [it] } }));
|
|
169
|
+
const content = items.length ? items.map(listItemToPM) : [{ type: "listItem", attrs: { id: null }, content: [para(undefined)] }];
|
|
170
|
+
return p.ordered
|
|
171
|
+
? [{ type: "orderedList", attrs: { ...base, start: typeof p.start === "number" ? p.start : 1 }, content }]
|
|
172
|
+
: [{ type: "bulletList", attrs: base, content }];
|
|
173
|
+
}
|
|
174
|
+
case "list-item":
|
|
175
|
+
// A list item outside a list: wrap it.
|
|
176
|
+
return [{ type: "bulletList", attrs: { id: createBlockId(), extra: null }, content: [listItemToPM(b)] }];
|
|
177
|
+
case "quote": {
|
|
178
|
+
const content = [];
|
|
179
|
+
if (b.content?.length)
|
|
180
|
+
content.push(para(b.content));
|
|
181
|
+
for (const k of b.slots?.items ?? [])
|
|
182
|
+
content.push(...blockToPM(k));
|
|
183
|
+
if (!content.length)
|
|
184
|
+
content.push(para(undefined));
|
|
185
|
+
return [{ type: "blockquote", attrs: { ...base, cite: typeof p.cite === "string" ? p.cite : null }, content }];
|
|
186
|
+
}
|
|
187
|
+
case "code": {
|
|
188
|
+
const text = inlineToText(b.content);
|
|
189
|
+
return [{ type: "codeBlock", attrs: { ...base, language: typeof p.language === "string" ? p.language : null }, ...(text ? { content: [{ type: "text", text }] } : null) }];
|
|
190
|
+
}
|
|
191
|
+
case "divider":
|
|
192
|
+
return [{ type: "horizontalRule", attrs: base }];
|
|
193
|
+
case "image": {
|
|
194
|
+
const ip = p;
|
|
195
|
+
return [
|
|
196
|
+
{
|
|
197
|
+
type: "image",
|
|
198
|
+
attrs: {
|
|
199
|
+
...base,
|
|
200
|
+
src: ip.src ?? null,
|
|
201
|
+
alt: ip.alt ?? null,
|
|
202
|
+
width: ip.width ?? null,
|
|
203
|
+
height: ip.height ?? null,
|
|
204
|
+
caption: ip.caption ?? null,
|
|
205
|
+
focal: ip.focal ?? null,
|
|
206
|
+
assetId: ip.assetId ?? null,
|
|
207
|
+
decorative: ip.decorative ?? null,
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
];
|
|
211
|
+
}
|
|
212
|
+
case "table": {
|
|
213
|
+
const rows = (b.slots?.items ?? []).map((row) => ({ type: "tableRow", attrs: { id: row.id }, content: (row.slots?.items ?? []).map(cellToPM) })).filter((r) => r.content.length);
|
|
214
|
+
if (!rows.length)
|
|
215
|
+
return [];
|
|
216
|
+
return [{ type: "table", attrs: base, content: rows }];
|
|
217
|
+
}
|
|
218
|
+
default:
|
|
219
|
+
return [componentToPM(b)];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function componentToPM(b) {
|
|
223
|
+
return {
|
|
224
|
+
type: COMPONENT_BLOCK,
|
|
225
|
+
attrs: {
|
|
226
|
+
id: b.id,
|
|
227
|
+
blockType: b.type,
|
|
228
|
+
v: b.v ?? null,
|
|
229
|
+
variant: b.variant ?? null,
|
|
230
|
+
props: b.props ?? null,
|
|
231
|
+
theme: b.theme ?? null,
|
|
232
|
+
anchor: b.anchor ?? null,
|
|
233
|
+
hidden: b.hidden ?? null,
|
|
234
|
+
schedule: b.schedule ?? null,
|
|
235
|
+
slots: b.slots ?? null,
|
|
236
|
+
content: b.content ?? null,
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* A VamosDoc as a ProseMirror document. With a `registry`, the doc and every component block are
|
|
242
|
+
* first migrated to their current version, so the editor always works on current props.
|
|
243
|
+
* Unknown block types become component blocks too: their data is carried untouched.
|
|
244
|
+
*/
|
|
245
|
+
export function toProseMirror(doc, registry) {
|
|
246
|
+
const d = doc ? migrateDoc(doc, registry) : { version: 1, blocks: [] };
|
|
247
|
+
const content = d.blocks.flatMap(blockToPM);
|
|
248
|
+
return { type: "doc", content: content.length ? content : [{ type: "paragraph", attrs: { id: null } }] };
|
|
249
|
+
}
|
|
250
|
+
function takeId(ctx, raw) {
|
|
251
|
+
let id = isValidBlockId(raw) ? raw : createBlockId();
|
|
252
|
+
while (ctx.seen.has(id))
|
|
253
|
+
id = createBlockId();
|
|
254
|
+
ctx.seen.add(id);
|
|
255
|
+
return id;
|
|
256
|
+
}
|
|
257
|
+
const attrs = (n) => (n.attrs ?? {});
|
|
258
|
+
const compact = (o) => {
|
|
259
|
+
const r = {};
|
|
260
|
+
for (const [k, v] of Object.entries(o))
|
|
261
|
+
if (v !== undefined && v !== null)
|
|
262
|
+
r[k] = v;
|
|
263
|
+
return r;
|
|
264
|
+
};
|
|
265
|
+
function listItemFromPM(n, ctx) {
|
|
266
|
+
const id = takeId(ctx, attrs(n).id);
|
|
267
|
+
const kids = n.content ?? [];
|
|
268
|
+
const first = kids[0];
|
|
269
|
+
const node = { id, type: "list-item" };
|
|
270
|
+
let rest = kids;
|
|
271
|
+
if (first?.type === "paragraph") {
|
|
272
|
+
node.content = inlineFromPM(first.content);
|
|
273
|
+
rest = kids.slice(1);
|
|
274
|
+
}
|
|
275
|
+
else
|
|
276
|
+
node.content = [];
|
|
277
|
+
const nested = rest.flatMap((k) => blockFromPM(k, ctx));
|
|
278
|
+
if (nested.length)
|
|
279
|
+
node.slots = { items: nested };
|
|
280
|
+
return node;
|
|
281
|
+
}
|
|
282
|
+
function cellFromPM(n, ctx) {
|
|
283
|
+
const a = attrs(n);
|
|
284
|
+
const props = compact({
|
|
285
|
+
header: n.type === "tableHeader" ? true : undefined,
|
|
286
|
+
colspan: typeof a.colspan === "number" && a.colspan > 1 ? a.colspan : undefined,
|
|
287
|
+
rowspan: typeof a.rowspan === "number" && a.rowspan > 1 ? a.rowspan : undefined,
|
|
288
|
+
});
|
|
289
|
+
const paragraphs = (n.content ?? []).filter((k) => k.type === "paragraph");
|
|
290
|
+
const node = { id: takeId(ctx, a.id), type: "table-cell" };
|
|
291
|
+
if (Object.keys(props).length)
|
|
292
|
+
node.props = props;
|
|
293
|
+
// Several paragraphs in one cell are joined with line breaks (cells hold inline runs).
|
|
294
|
+
node.content = paragraphs.flatMap((pp, i) => (i === 0 ? inlineFromPM(pp.content) : [{ type: "br" }, ...inlineFromPM(pp.content)]));
|
|
295
|
+
return node;
|
|
296
|
+
}
|
|
297
|
+
function blockFromPM(n, ctx) {
|
|
298
|
+
const a = attrs(n);
|
|
299
|
+
const finish = (node) => [applyExtra(node, a.extra)];
|
|
300
|
+
switch (n.type) {
|
|
301
|
+
case "paragraph":
|
|
302
|
+
return finish({ id: takeId(ctx, a.id), type: "paragraph", content: inlineFromPM(n.content) });
|
|
303
|
+
case "heading": {
|
|
304
|
+
const node = { id: takeId(ctx, a.id), type: "heading", props: { level: Number(a.level) || 2 }, content: inlineFromPM(n.content) };
|
|
305
|
+
if (typeof a.anchor === "string" && /^[a-z0-9-]+$/.test(a.anchor))
|
|
306
|
+
node.anchor = a.anchor;
|
|
307
|
+
return finish(node);
|
|
308
|
+
}
|
|
309
|
+
case "bulletList":
|
|
310
|
+
case "orderedList": {
|
|
311
|
+
const ordered = n.type === "orderedList";
|
|
312
|
+
const props = ordered ? { ordered: true } : {};
|
|
313
|
+
if (ordered && typeof a.start === "number" && a.start !== 1)
|
|
314
|
+
props.start = a.start;
|
|
315
|
+
const node = { id: takeId(ctx, a.id), type: "list", slots: { items: (n.content ?? []).filter((k) => k.type === "listItem").map((k) => listItemFromPM(k, ctx)) } };
|
|
316
|
+
if (Object.keys(props).length)
|
|
317
|
+
node.props = props;
|
|
318
|
+
return finish(node);
|
|
319
|
+
}
|
|
320
|
+
case "blockquote": {
|
|
321
|
+
const kids = n.content ?? [];
|
|
322
|
+
const node = { id: takeId(ctx, a.id), type: "quote" };
|
|
323
|
+
if (kids.length === 1 && kids[0].type === "paragraph")
|
|
324
|
+
node.content = inlineFromPM(kids[0].content);
|
|
325
|
+
else
|
|
326
|
+
node.slots = { items: kids.flatMap((k) => blockFromPM(k, ctx)) };
|
|
327
|
+
if (typeof a.cite === "string" && a.cite)
|
|
328
|
+
node.props = { cite: a.cite };
|
|
329
|
+
return finish(node);
|
|
330
|
+
}
|
|
331
|
+
case "codeBlock": {
|
|
332
|
+
const text = (n.content ?? []).map((t) => t.text ?? "").join("");
|
|
333
|
+
const lines = text.split("\n");
|
|
334
|
+
const content = lines.flatMap((l, i) => {
|
|
335
|
+
const parts = i > 0 ? [{ type: "br" }] : [];
|
|
336
|
+
if (l)
|
|
337
|
+
parts.push({ text: l });
|
|
338
|
+
return parts;
|
|
339
|
+
});
|
|
340
|
+
const node = { id: takeId(ctx, a.id), type: "code", content: text ? content : [] };
|
|
341
|
+
if (typeof a.language === "string" && a.language)
|
|
342
|
+
node.props = { language: a.language };
|
|
343
|
+
return finish(node);
|
|
344
|
+
}
|
|
345
|
+
case "horizontalRule":
|
|
346
|
+
return finish({ id: takeId(ctx, a.id), type: "divider" });
|
|
347
|
+
case "image": {
|
|
348
|
+
if (typeof a.src !== "string" || !a.src || a.uploading)
|
|
349
|
+
return [];
|
|
350
|
+
const props = compact({
|
|
351
|
+
src: a.src,
|
|
352
|
+
alt: typeof a.alt === "string" ? a.alt : undefined,
|
|
353
|
+
width: typeof a.width === "number" ? a.width : undefined,
|
|
354
|
+
height: typeof a.height === "number" ? a.height : undefined,
|
|
355
|
+
caption: typeof a.caption === "string" && a.caption ? a.caption : undefined,
|
|
356
|
+
focal: a.focal ?? undefined,
|
|
357
|
+
assetId: typeof a.assetId === "string" ? a.assetId : undefined,
|
|
358
|
+
decorative: a.decorative === true ? true : undefined,
|
|
359
|
+
});
|
|
360
|
+
return finish({ id: takeId(ctx, a.id), type: "image", props: props });
|
|
361
|
+
}
|
|
362
|
+
case "table": {
|
|
363
|
+
const rows = (n.content ?? []).filter((r) => r.type === "tableRow").map((r) => ({ id: takeId(ctx, attrs(r).id), type: "table-row", slots: { items: (r.content ?? []).map((c) => cellFromPM(c, ctx)) } }));
|
|
364
|
+
return finish({ id: takeId(ctx, a.id), type: "table", slots: { items: rows } });
|
|
365
|
+
}
|
|
366
|
+
case COMPONENT_BLOCK: {
|
|
367
|
+
const type = typeof a.blockType === "string" ? a.blockType : "";
|
|
368
|
+
if (!type)
|
|
369
|
+
return [];
|
|
370
|
+
const node = compact({
|
|
371
|
+
id: takeId(ctx, a.id),
|
|
372
|
+
type,
|
|
373
|
+
v: typeof a.v === "number" ? a.v : undefined,
|
|
374
|
+
variant: typeof a.variant === "string" ? a.variant : undefined,
|
|
375
|
+
props: a.props ?? undefined,
|
|
376
|
+
content: a.content ?? undefined,
|
|
377
|
+
slots: a.slots ?? undefined,
|
|
378
|
+
theme: a.theme ?? undefined,
|
|
379
|
+
anchor: typeof a.anchor === "string" ? a.anchor : undefined,
|
|
380
|
+
hidden: a.hidden === true ? true : undefined,
|
|
381
|
+
schedule: a.schedule ?? undefined,
|
|
382
|
+
});
|
|
383
|
+
return [node];
|
|
384
|
+
}
|
|
385
|
+
default:
|
|
386
|
+
return [];
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
/** A ProseMirror document (JSON) as a VamosDoc. Missing or duplicate ids are replaced. */
|
|
390
|
+
export function fromProseMirror(json, opts = {}) {
|
|
391
|
+
const ctx = { seen: new Set() };
|
|
392
|
+
let blocks = (json.content ?? []).flatMap((n) => blockFromPM(n, ctx));
|
|
393
|
+
// Trailing empty paragraphs are an editing artifact (the caret line after a page block).
|
|
394
|
+
const isBlank = (b) => b.type === "paragraph" && !b.content?.length && !b.hidden && !b.theme && !b.anchor;
|
|
395
|
+
while (blocks.length && isBlank(blocks[blocks.length - 1]))
|
|
396
|
+
blocks = blocks.slice(0, -1);
|
|
397
|
+
const { blocks: _b, meta: _m, ...rest } = (opts.base ?? {});
|
|
398
|
+
const doc = { ...rest, version: 1, blocks };
|
|
399
|
+
if (opts.meta !== false)
|
|
400
|
+
doc.meta = computeDocMeta(doc, opts.lang ?? rest.lang ?? "en");
|
|
401
|
+
return doc;
|
|
402
|
+
}
|
|
403
|
+
// ---------------------------------------------------------------- meta
|
|
404
|
+
const segmenters = new Map();
|
|
405
|
+
/** Word count with `Intl.Segmenter(lang, { granularity: "word" })` (regex fallback). */
|
|
406
|
+
export function countWords(text, lang = "en") {
|
|
407
|
+
if (!text.trim())
|
|
408
|
+
return 0;
|
|
409
|
+
let seg = segmenters.get(lang);
|
|
410
|
+
if (seg === undefined) {
|
|
411
|
+
try {
|
|
412
|
+
seg = typeof Intl !== "undefined" && "Segmenter" in Intl ? new Intl.Segmenter(lang, { granularity: "word" }) : null;
|
|
413
|
+
}
|
|
414
|
+
catch {
|
|
415
|
+
seg = null;
|
|
416
|
+
}
|
|
417
|
+
segmenters.set(lang, seg);
|
|
418
|
+
}
|
|
419
|
+
if (!seg)
|
|
420
|
+
return countWordsRegex(text);
|
|
421
|
+
let n = 0;
|
|
422
|
+
for (const s of seg.segment(text))
|
|
423
|
+
if (s.isWordLike)
|
|
424
|
+
n++;
|
|
425
|
+
return n;
|
|
426
|
+
}
|
|
427
|
+
function nodeText(b) {
|
|
428
|
+
const own = b.content ? inlineToText(b.content) : "";
|
|
429
|
+
const kids = Object.values(b.slots ?? {})
|
|
430
|
+
.flat()
|
|
431
|
+
.map(nodeText)
|
|
432
|
+
.filter(Boolean);
|
|
433
|
+
const caption = b.type === "image" && typeof b.props?.caption === "string" ? b.props.caption : "";
|
|
434
|
+
return [own, caption, ...kids].filter(Boolean).join("\n");
|
|
435
|
+
}
|
|
436
|
+
/** Plain text of the editable text in a doc (component block props are not included). */
|
|
437
|
+
export function docToPlainText(doc) {
|
|
438
|
+
return doc.blocks.map(nodeText).filter(Boolean).join("\n\n");
|
|
439
|
+
}
|
|
440
|
+
/** Derived doc meta: word count, reading time (230 wpm, min 1) and the heading outline. */
|
|
441
|
+
export function computeDocMeta(doc, lang = "en") {
|
|
442
|
+
const wordCount = countWords(docToPlainText(doc), lang);
|
|
443
|
+
const toc = doc.blocks
|
|
444
|
+
.filter((b) => b.type === "heading")
|
|
445
|
+
.map((b) => ({ id: b.id, level: Number(b.props?.level) || 2, text: inlineToText(b.content).replace(/\n/g, " ").trim() }))
|
|
446
|
+
.filter((h) => h.text);
|
|
447
|
+
return { wordCount, readingTime: wordCount ? Math.max(1, Math.ceil(wordCount / 230)) : 0, toc };
|
|
448
|
+
}
|
|
449
|
+
/** JSON with sorted object keys: equal content compares equal regardless of key order. */
|
|
450
|
+
export function stableStringify(v) {
|
|
451
|
+
return JSON.stringify(v, (_k, val) => val && typeof val === "object" && !Array.isArray(val) ? Object.fromEntries(Object.keys(val).sort().map((k) => [k, val[k]])) : val);
|
|
452
|
+
}
|
|
453
|
+
/** Ids of top-level blocks that were added, removed or changed between two docs. */
|
|
454
|
+
export function changedBlockIds(prev, next) {
|
|
455
|
+
const before = new Map((prev?.blocks ?? []).map((b) => [b.id, stableStringify(b)]));
|
|
456
|
+
const out = [];
|
|
457
|
+
const seen = new Set();
|
|
458
|
+
for (const b of next.blocks) {
|
|
459
|
+
seen.add(b.id);
|
|
460
|
+
if (before.get(b.id) !== stableStringify(b))
|
|
461
|
+
out.push(b.id);
|
|
462
|
+
}
|
|
463
|
+
for (const id of before.keys())
|
|
464
|
+
if (!seen.has(id))
|
|
465
|
+
out.push(id);
|
|
466
|
+
return out;
|
|
467
|
+
}
|
|
468
|
+
// ---------------------------------------------------------------- RichDoc (f.rich fields)
|
|
469
|
+
function richBlockToPM(b) {
|
|
470
|
+
switch (b.type) {
|
|
471
|
+
case "paragraph":
|
|
472
|
+
return [para(b.content)];
|
|
473
|
+
case "heading": {
|
|
474
|
+
const inner = inlineToPM(b.content);
|
|
475
|
+
return [{ type: "heading", attrs: { level: b.level, anchor: b.anchor ?? null }, ...(inner.length ? { content: inner } : null) }];
|
|
476
|
+
}
|
|
477
|
+
case "list": {
|
|
478
|
+
const items = b.items.map((it) => {
|
|
479
|
+
const content = it.content.flatMap(richBlockToPM);
|
|
480
|
+
if (!content.length || content[0].type !== "paragraph")
|
|
481
|
+
content.unshift(para(undefined));
|
|
482
|
+
return { type: "listItem", content };
|
|
483
|
+
});
|
|
484
|
+
if (!items.length)
|
|
485
|
+
return [];
|
|
486
|
+
return [b.ordered ? { type: "orderedList", attrs: { start: b.start ?? 1 }, content: items } : { type: "bulletList", content: items }];
|
|
487
|
+
}
|
|
488
|
+
case "blockquote": {
|
|
489
|
+
const content = b.content.flatMap(richBlockToPM);
|
|
490
|
+
return [{ type: "blockquote", attrs: { cite: b.cite ?? null }, content: content.length ? content : [para(undefined)] }];
|
|
491
|
+
}
|
|
492
|
+
case "code":
|
|
493
|
+
return [{ type: "codeBlock", attrs: { language: b.language ?? null }, ...(b.text ? { content: [{ type: "text", text: b.text }] } : null) }];
|
|
494
|
+
case "hr":
|
|
495
|
+
return [{ type: "horizontalRule" }];
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
/** A RichDoc (the value of an `f.rich()` field) as a ProseMirror document. */
|
|
499
|
+
export function richDocToProseMirror(doc) {
|
|
500
|
+
const content = (doc?.content ?? []).flatMap(richBlockToPM);
|
|
501
|
+
return { type: "doc", content: content.length ? content : [{ type: "paragraph" }] };
|
|
502
|
+
}
|
|
503
|
+
function richBlockFromPM(n, minHeading = 2) {
|
|
504
|
+
const a = attrs(n);
|
|
505
|
+
switch (n.type) {
|
|
506
|
+
case "paragraph":
|
|
507
|
+
return [{ type: "paragraph", content: inlineFromPM(n.content) }];
|
|
508
|
+
case "heading": {
|
|
509
|
+
const level = Math.min(4, Math.max(minHeading, Number(a.level) || 2));
|
|
510
|
+
const h = { type: "heading", level, content: inlineFromPM(n.content) };
|
|
511
|
+
if (typeof a.anchor === "string" && a.anchor)
|
|
512
|
+
h.anchor = a.anchor;
|
|
513
|
+
return [h];
|
|
514
|
+
}
|
|
515
|
+
case "bulletList":
|
|
516
|
+
case "orderedList": {
|
|
517
|
+
const items = (n.content ?? []).map((li) => ({ content: (li.content ?? []).flatMap((k) => richBlockFromPM(k, minHeading)) }));
|
|
518
|
+
const l = { type: "list", items };
|
|
519
|
+
if (n.type === "orderedList") {
|
|
520
|
+
l.ordered = true;
|
|
521
|
+
if (typeof a.start === "number" && a.start !== 1)
|
|
522
|
+
l.start = a.start;
|
|
523
|
+
}
|
|
524
|
+
return [l];
|
|
525
|
+
}
|
|
526
|
+
case "blockquote": {
|
|
527
|
+
const q = { type: "blockquote", content: (n.content ?? []).flatMap((k) => richBlockFromPM(k, minHeading)) };
|
|
528
|
+
if (typeof a.cite === "string" && a.cite)
|
|
529
|
+
q.cite = a.cite;
|
|
530
|
+
return [q];
|
|
531
|
+
}
|
|
532
|
+
case "codeBlock": {
|
|
533
|
+
const c = { type: "code", text: (n.content ?? []).map((t) => t.text ?? "").join("") };
|
|
534
|
+
if (typeof a.language === "string" && a.language)
|
|
535
|
+
c.language = a.language;
|
|
536
|
+
return [c];
|
|
537
|
+
}
|
|
538
|
+
case "horizontalRule":
|
|
539
|
+
return [{ type: "hr" }];
|
|
540
|
+
default:
|
|
541
|
+
return [];
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
/** A ProseMirror document as a RichDoc. Headings are clamped to h2–h4 (rich fields never hold h1). */
|
|
545
|
+
export function proseMirrorToRichDoc(json) {
|
|
546
|
+
let content = (json.content ?? []).flatMap((n) => richBlockFromPM(n));
|
|
547
|
+
if (content.length === 1 && content[0].type === "paragraph" && !content[0].content?.length)
|
|
548
|
+
content = [];
|
|
549
|
+
return { type: "doc", content };
|
|
550
|
+
}
|
|
551
|
+
/** True when a RichDoc has no text at all. */
|
|
552
|
+
export function isRichDocEmpty(doc) {
|
|
553
|
+
if (!doc)
|
|
554
|
+
return true;
|
|
555
|
+
const visit = (blocks) => blocks.every((b) => {
|
|
556
|
+
if (b.type === "paragraph" || b.type === "heading")
|
|
557
|
+
return !inlineToText(b.content).trim();
|
|
558
|
+
if (b.type === "code")
|
|
559
|
+
return !b.text.trim();
|
|
560
|
+
if (b.type === "hr")
|
|
561
|
+
return false;
|
|
562
|
+
if (b.type === "blockquote")
|
|
563
|
+
return visit(b.content);
|
|
564
|
+
return b.items.every((it) => visit(it.content));
|
|
565
|
+
});
|
|
566
|
+
return visit(doc.content);
|
|
567
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface BlockEditorDragHandleProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The gutter handle beside the hovered block: "+" inserts below, the grip drags (drop line in
|
|
7
|
+
* `--accent`) and opens the block menu — duplicate, move up/down, turn into, copy link, hide,
|
|
8
|
+
* delete. Every drag action has a menu and keyboard twin (WCAG 2.5.7).
|
|
9
|
+
*/
|
|
10
|
+
export declare function BlockEditorDragHandle({ className }: BlockEditorDragHandleProps): React.JSX.Element | null;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import DragHandle from "@tiptap/extension-drag-handle-react";
|
|
5
|
+
import { ArrowDown, ArrowUp, Copy, Eye, EyeOff, GripVertical, Link as LinkIcon, Plus, Repeat2, Trash2 } from "lucide-react";
|
|
6
|
+
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { slugify } from "../lib/text.js";
|
|
8
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from "../components/dropdown-menu.js";
|
|
9
|
+
import { useBlockEditor } from "./context.js";
|
|
10
|
+
import { COMPONENT_BLOCK } from "./convert.js";
|
|
11
|
+
import { deleteBlock, duplicateBlock, moveBlock, setNodeAttrs, selectBlock } from "./commands.js";
|
|
12
|
+
import { blockTitle, turnIntoItems } from "./items.js";
|
|
13
|
+
/**
|
|
14
|
+
* The gutter handle beside the hovered block: "+" inserts below, the grip drags (drop line in
|
|
15
|
+
* `--accent`) and opens the block menu — duplicate, move up/down, turn into, copy link, hide,
|
|
16
|
+
* delete. Every drag action has a menu and keyboard twin (WCAG 2.5.7).
|
|
17
|
+
*/
|
|
18
|
+
export function BlockEditorDragHandle({ className }) {
|
|
19
|
+
const { editor, t, registry, openInserter, announce, lang } = useBlockEditor();
|
|
20
|
+
const [target, setTarget] = React.useState(null);
|
|
21
|
+
const [menuOpen, setMenuOpen] = React.useState(false);
|
|
22
|
+
const turnInto = React.useMemo(() => turnIntoItems(t), [t]);
|
|
23
|
+
const lock = React.useCallback((on) => {
|
|
24
|
+
const cmds = editor?.commands;
|
|
25
|
+
if (on)
|
|
26
|
+
cmds?.lockDragHandle?.();
|
|
27
|
+
else
|
|
28
|
+
cmds?.unlockDragHandle?.();
|
|
29
|
+
}, [editor]);
|
|
30
|
+
if (!editor)
|
|
31
|
+
return null;
|
|
32
|
+
const node = target?.node;
|
|
33
|
+
const title = node ? blockTitle(node, registry, t) : "";
|
|
34
|
+
const isComponent = node?.type.name === COMPONENT_BLOCK;
|
|
35
|
+
const textBlock = node && !isComponent && node.type.name !== "image" && node.type.name !== "table" && node.type.name !== "horizontalRule";
|
|
36
|
+
const index = target ? editor.state.doc.resolve(target.pos).index(0) : 0;
|
|
37
|
+
const count = editor.state.doc.childCount;
|
|
38
|
+
const run = (fn) => {
|
|
39
|
+
fn();
|
|
40
|
+
setMenuOpen(false);
|
|
41
|
+
lock(false);
|
|
42
|
+
};
|
|
43
|
+
const anchorOf = () => {
|
|
44
|
+
if (!node)
|
|
45
|
+
return "";
|
|
46
|
+
if (isComponent && typeof node.attrs.anchor === "string" && node.attrs.anchor)
|
|
47
|
+
return node.attrs.anchor;
|
|
48
|
+
if (node.type.name === "heading")
|
|
49
|
+
return node.attrs.anchor || slugify(node.textContent, { locale: lang });
|
|
50
|
+
return String(node.attrs.id ?? "");
|
|
51
|
+
};
|
|
52
|
+
return (_jsx(DragHandle, { editor: editor, onNodeChange: ({ node: n, pos }) => !menuOpen && setTarget(n ? { node: n, pos } : null), className: cn("vui-drag-handle", className), children: _jsxs("div", { className: "flex items-center gap-0.5", "data-slot": "block-editor-drag-handle", children: [_jsx("button", { type: "button", className: "vui-handle-btn focus-ring", "aria-label": t("insertBelow"), title: t("insertBelow"), onClick: (e) => target && openInserter({ at: target.pos, anchor: e.currentTarget }), children: _jsx(Plus, { "aria-hidden": true }) }), _jsxs(DropdownMenu, { modal: false, open: menuOpen, onOpenChange: (o) => {
|
|
53
|
+
setMenuOpen(o);
|
|
54
|
+
lock(o);
|
|
55
|
+
if (o && target)
|
|
56
|
+
selectBlock(editor, target.pos);
|
|
57
|
+
}, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { type: "button", className: "vui-handle-btn vui-handle-grip focus-ring", "aria-label": `${t("blockMenu")}: ${title}`, title: t("dragHandle"), "data-drag-handle": "", children: _jsx(GripVertical, { "aria-hidden": true }) }) }), _jsxs(DropdownMenuContent, { size: "sm", side: "left", align: "start", onCloseAutoFocus: (e) => e.preventDefault(), children: [_jsx("div", { className: "px-2.5 pb-1 pt-1.5 font-mono text-[10.5px] uppercase tracking-[0.08em] text-fg-subtle", children: title }), _jsx(DropdownMenuItem, { icon: _jsx(Copy, {}), shortcut: "mod+shift+d", onSelect: () => run(() => target && duplicateBlock(editor, target.pos) && announce(t("announceDuplicated", { title }))), children: t("duplicate") }), _jsx(DropdownMenuItem, { icon: _jsx(ArrowUp, {}), shortcut: "alt+shift+arrowup", disabled: index === 0, onSelect: () => run(() => target && moveBlock(editor, -1, target.pos) && announce(t("announceMovedUp", { title }))), children: t("moveUp") }), _jsx(DropdownMenuItem, { icon: _jsx(ArrowDown, {}), shortcut: "alt+shift+arrowdown", disabled: index >= count - 1, onSelect: () => run(() => target && moveBlock(editor, 1, target.pos) && announce(t("announceMovedDown", { title }))), children: t("moveDown") }), textBlock ? (_jsxs(DropdownMenuSub, { children: [_jsx(DropdownMenuSubTrigger, { icon: _jsx(Repeat2, {}), children: t("turnInto") }), _jsx(DropdownMenuSubContent, { size: "sm", children: turnInto.map((it) => (_jsx(DropdownMenuItem, { icon: _jsx(it.icon, {}), onSelect: () => run(() => {
|
|
58
|
+
if (!target)
|
|
59
|
+
return;
|
|
60
|
+
editor.chain().focus().setTextSelection(target.pos + 1).run();
|
|
61
|
+
it.run(editor);
|
|
62
|
+
}), children: it.label }, it.id))) })] })) : null, _jsx(DropdownMenuItem, { icon: _jsx(LinkIcon, {}), onSelect: () => run(() => {
|
|
63
|
+
const a = anchorOf();
|
|
64
|
+
if (!a)
|
|
65
|
+
return;
|
|
66
|
+
const url = typeof location !== "undefined" ? `${location.origin}${location.pathname}#${a}` : `#${a}`;
|
|
67
|
+
navigator.clipboard?.writeText(url).then(() => announce(t("announceCopied")), () => undefined);
|
|
68
|
+
}), children: t("copyAnchor") }), isComponent && target ? (_jsx(DropdownMenuItem, { icon: node?.attrs.hidden ? _jsx(Eye, {}) : _jsx(EyeOff, {}), onSelect: () => run(() => setNodeAttrs(editor, target.pos, { hidden: node?.attrs.hidden ? null : true })), children: node?.attrs.hidden ? t("show") : t("hide") })) : null, _jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuItem, { icon: _jsx(Trash2, {}), tone: "danger", shortcut: "alt+shift+z", onSelect: () => run(() => target && deleteBlock(editor, target.pos) && announce(t("announceDeleted", { title }))), children: t("delete") })] })] })] }) }));
|
|
69
|
+
}
|