@kujoforall/paper-ui 0.0.0-stage → 0.2.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/CHANGELOG.md +93 -0
- package/LICENSE +21 -0
- package/README.md +295 -2
- package/dist/components/editor/block-text.d.ts +8 -0
- package/dist/components/editor/block-text.d.ts.map +1 -0
- package/dist/components/editor/block-text.js +248 -0
- package/dist/components/editor/block-text.js.map +1 -0
- package/dist/components/editor/blocks.d.ts +33 -0
- package/dist/components/editor/blocks.d.ts.map +1 -0
- package/dist/components/editor/blocks.js +191 -0
- package/dist/components/editor/blocks.js.map +1 -0
- package/dist/components/editor/document-editor.d.ts +27 -0
- package/dist/components/editor/document-editor.d.ts.map +1 -0
- package/dist/components/editor/document-editor.js +42 -0
- package/dist/components/editor/document-editor.js.map +1 -0
- package/dist/components/editor/document-view.d.ts +22 -0
- package/dist/components/editor/document-view.d.ts.map +1 -0
- package/dist/components/editor/document-view.js +110 -0
- package/dist/components/editor/document-view.js.map +1 -0
- package/dist/components/editor/editor-state.d.ts +107 -0
- package/dist/components/editor/editor-state.d.ts.map +1 -0
- package/dist/components/editor/editor-state.js +217 -0
- package/dist/components/editor/editor-state.js.map +1 -0
- package/dist/components/editor/extensions/kit-blocks.d.ts +34 -0
- package/dist/components/editor/extensions/kit-blocks.d.ts.map +1 -0
- package/dist/components/editor/extensions/kit-blocks.js +201 -0
- package/dist/components/editor/extensions/kit-blocks.js.map +1 -0
- package/dist/components/editor/extensions/spoiler.d.ts +8 -0
- package/dist/components/editor/extensions/spoiler.d.ts.map +1 -0
- package/dist/components/editor/extensions/spoiler.js +36 -0
- package/dist/components/editor/extensions/spoiler.js.map +1 -0
- package/dist/components/editor/index.d.ts +10 -0
- package/dist/components/editor/index.d.ts.map +1 -0
- package/dist/components/editor/index.js +10 -0
- package/dist/components/editor/index.js.map +1 -0
- package/dist/components/editor/kinds.d.ts +99 -0
- package/dist/components/editor/kinds.d.ts.map +1 -0
- package/dist/components/editor/kinds.js +74 -0
- package/dist/components/editor/kinds.js.map +1 -0
- package/dist/components/editor/look.d.ts +18 -0
- package/dist/components/editor/look.d.ts.map +1 -0
- package/dist/components/editor/look.js +21 -0
- package/dist/components/editor/look.js.map +1 -0
- package/dist/components/sketch/rough.d.ts +38 -0
- package/dist/components/sketch/rough.d.ts.map +1 -0
- package/dist/components/sketch/rough.js +57 -0
- package/dist/components/sketch/rough.js.map +1 -0
- package/dist/components/three/model-viewer.d.ts +36 -0
- package/dist/components/three/model-viewer.d.ts.map +1 -0
- package/dist/components/three/model-viewer.js +338 -0
- package/dist/components/three/model-viewer.js.map +1 -0
- package/dist/components/ui/accent-picker.d.ts +2 -0
- package/dist/components/ui/accent-picker.d.ts.map +1 -0
- package/dist/components/ui/accent-picker.js +44 -0
- package/dist/components/ui/accent-picker.js.map +1 -0
- package/dist/components/ui/address-field.d.ts +10 -0
- package/dist/components/ui/address-field.d.ts.map +1 -0
- package/dist/components/ui/address-field.js +24 -0
- package/dist/components/ui/address-field.js.map +1 -0
- package/dist/components/ui/alert-dialog.d.ts +29 -0
- package/dist/components/ui/alert-dialog.d.ts.map +1 -0
- package/dist/components/ui/alert-dialog.js +72 -0
- package/dist/components/ui/alert-dialog.js.map +1 -0
- package/dist/components/ui/animated-height.d.ts +6 -0
- package/dist/components/ui/animated-height.d.ts.map +1 -0
- package/dist/components/ui/animated-height.js +26 -0
- package/dist/components/ui/animated-height.js.map +1 -0
- package/dist/components/ui/app-shell.d.ts +26 -0
- package/dist/components/ui/app-shell.d.ts.map +1 -0
- package/dist/components/ui/app-shell.js +71 -0
- package/dist/components/ui/app-shell.js.map +1 -0
- package/dist/components/ui/avatar.d.ts +30 -0
- package/dist/components/ui/avatar.d.ts.map +1 -0
- package/dist/components/ui/avatar.js +50 -0
- package/dist/components/ui/avatar.js.map +1 -0
- package/dist/components/ui/badge.d.ts +19 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/badge.js +62 -0
- package/dist/components/ui/badge.js.map +1 -0
- package/dist/components/ui/banner.d.ts +33 -0
- package/dist/components/ui/banner.d.ts.map +1 -0
- package/dist/components/ui/banner.js +21 -0
- package/dist/components/ui/banner.js.map +1 -0
- package/dist/components/ui/breadcrumbs.d.ts +10 -0
- package/dist/components/ui/breadcrumbs.d.ts.map +1 -0
- package/dist/components/ui/breadcrumbs.js +9 -0
- package/dist/components/ui/breadcrumbs.js.map +1 -0
- package/dist/components/ui/button.d.ts +15 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +110 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/calendar.d.ts +5 -0
- package/dist/components/ui/calendar.d.ts.map +1 -0
- package/dist/components/ui/calendar.js +65 -0
- package/dist/components/ui/calendar.js.map +1 -0
- package/dist/components/ui/callout.d.ts +32 -0
- package/dist/components/ui/callout.d.ts.map +1 -0
- package/dist/components/ui/callout.js +40 -0
- package/dist/components/ui/callout.js.map +1 -0
- package/dist/components/ui/card.d.ts +18 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/card.js +28 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/checkbox.d.ts +11 -0
- package/dist/components/ui/checkbox.d.ts.map +1 -0
- package/dist/components/ui/checkbox.js +30 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/choice-label.d.ts +13 -0
- package/dist/components/ui/choice-label.d.ts.map +1 -0
- package/dist/components/ui/choice-label.js +17 -0
- package/dist/components/ui/choice-label.js.map +1 -0
- package/dist/components/ui/collapsible.d.ts +10 -0
- package/dist/components/ui/collapsible.d.ts.map +1 -0
- package/dist/components/ui/collapsible.js +21 -0
- package/dist/components/ui/collapsible.js.map +1 -0
- package/dist/components/ui/collection-layout.d.ts +24 -0
- package/dist/components/ui/collection-layout.d.ts.map +1 -0
- package/dist/components/ui/collection-layout.js +16 -0
- package/dist/components/ui/collection-layout.js.map +1 -0
- package/dist/components/ui/combobox.d.ts +10 -0
- package/dist/components/ui/combobox.d.ts.map +1 -0
- package/dist/components/ui/combobox.js +93 -0
- package/dist/components/ui/combobox.js.map +1 -0
- package/dist/components/ui/command-menu.d.ts +18 -0
- package/dist/components/ui/command-menu.d.ts.map +1 -0
- package/dist/components/ui/command-menu.js +49 -0
- package/dist/components/ui/command-menu.js.map +1 -0
- package/dist/components/ui/context-menu.d.ts +19 -0
- package/dist/components/ui/context-menu.d.ts.map +1 -0
- package/dist/components/ui/context-menu.js +42 -0
- package/dist/components/ui/context-menu.js.map +1 -0
- package/dist/components/ui/copy-button.d.ts +11 -0
- package/dist/components/ui/copy-button.d.ts.map +1 -0
- package/dist/components/ui/copy-button.js +48 -0
- package/dist/components/ui/copy-button.js.map +1 -0
- package/dist/components/ui/database/calendar-view.d.ts +10 -0
- package/dist/components/ui/database/calendar-view.d.ts.map +1 -0
- package/dist/components/ui/database/calendar-view.js +65 -0
- package/dist/components/ui/database/calendar-view.js.map +1 -0
- package/dist/components/ui/database/card-views.d.ts +22 -0
- package/dist/components/ui/database/card-views.d.ts.map +1 -0
- package/dist/components/ui/database/card-views.js +74 -0
- package/dist/components/ui/database/card-views.js.map +1 -0
- package/dist/components/ui/database/cells.d.ts +20 -0
- package/dist/components/ui/database/cells.d.ts.map +1 -0
- package/dist/components/ui/database/cells.js +132 -0
- package/dist/components/ui/database/cells.js.map +1 -0
- package/dist/components/ui/database/database.d.ts +19 -0
- package/dist/components/ui/database/database.d.ts.map +1 -0
- package/dist/components/ui/database/database.js +102 -0
- package/dist/components/ui/database/database.js.map +1 -0
- package/dist/components/ui/database/icons.d.ts +5 -0
- package/dist/components/ui/database/icons.d.ts.map +1 -0
- package/dist/components/ui/database/icons.js +13 -0
- package/dist/components/ui/database/icons.js.map +1 -0
- package/dist/components/ui/database/table-view.d.ts +11 -0
- package/dist/components/ui/database/table-view.d.ts.map +1 -0
- package/dist/components/ui/database/table-view.js +157 -0
- package/dist/components/ui/database/table-view.js.map +1 -0
- package/dist/components/ui/date-picker.d.ts +40 -0
- package/dist/components/ui/date-picker.d.ts.map +1 -0
- package/dist/components/ui/date-picker.js +64 -0
- package/dist/components/ui/date-picker.js.map +1 -0
- package/dist/components/ui/date-time-picker.d.ts +21 -0
- package/dist/components/ui/date-time-picker.d.ts.map +1 -0
- package/dist/components/ui/date-time-picker.js +34 -0
- package/dist/components/ui/date-time-picker.js.map +1 -0
- package/dist/components/ui/dialog.d.ts +21 -0
- package/dist/components/ui/dialog.d.ts.map +1 -0
- package/dist/components/ui/dialog.js +63 -0
- package/dist/components/ui/dialog.js.map +1 -0
- package/dist/components/ui/document-layout.d.ts +15 -0
- package/dist/components/ui/document-layout.d.ts.map +1 -0
- package/dist/components/ui/document-layout.js +15 -0
- package/dist/components/ui/document-layout.js.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +24 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.js +65 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -0
- package/dist/components/ui/editable-text.d.ts +24 -0
- package/dist/components/ui/editable-text.d.ts.map +1 -0
- package/dist/components/ui/editable-text.js +85 -0
- package/dist/components/ui/editable-text.js.map +1 -0
- package/dist/components/ui/empty-state.d.ts +11 -0
- package/dist/components/ui/empty-state.d.ts.map +1 -0
- package/dist/components/ui/empty-state.js +9 -0
- package/dist/components/ui/empty-state.js.map +1 -0
- package/dist/components/ui/error-state.d.ts +20 -0
- package/dist/components/ui/error-state.d.ts.map +1 -0
- package/dist/components/ui/error-state.js +17 -0
- package/dist/components/ui/error-state.js.map +1 -0
- package/dist/components/ui/field-button.d.ts +15 -0
- package/dist/components/ui/field-button.d.ts.map +1 -0
- package/dist/components/ui/field-button.js +18 -0
- package/dist/components/ui/field-button.js.map +1 -0
- package/dist/components/ui/file-preview.d.ts +5 -0
- package/dist/components/ui/file-preview.d.ts.map +1 -0
- package/dist/components/ui/file-preview.js +66 -0
- package/dist/components/ui/file-preview.js.map +1 -0
- package/dist/components/ui/file-uploader.d.ts +39 -0
- package/dist/components/ui/file-uploader.d.ts.map +1 -0
- package/dist/components/ui/file-uploader.js +111 -0
- package/dist/components/ui/file-uploader.js.map +1 -0
- package/dist/components/ui/filter-builder.d.ts +18 -0
- package/dist/components/ui/filter-builder.d.ts.map +1 -0
- package/dist/components/ui/filter-builder.js +98 -0
- package/dist/components/ui/filter-builder.js.map +1 -0
- package/dist/components/ui/focus-shell.d.ts +14 -0
- package/dist/components/ui/focus-shell.d.ts.map +1 -0
- package/dist/components/ui/focus-shell.js +13 -0
- package/dist/components/ui/focus-shell.js.map +1 -0
- package/dist/components/ui/handle-row.d.ts +25 -0
- package/dist/components/ui/handle-row.d.ts.map +1 -0
- package/dist/components/ui/handle-row.js +110 -0
- package/dist/components/ui/handle-row.js.map +1 -0
- package/dist/components/ui/header-bar.d.ts +5 -0
- package/dist/components/ui/header-bar.d.ts.map +1 -0
- package/dist/components/ui/header-bar.js +10 -0
- package/dist/components/ui/header-bar.js.map +1 -0
- package/dist/components/ui/hover-card.d.ts +6 -0
- package/dist/components/ui/hover-card.d.ts.map +1 -0
- package/dist/components/ui/hover-card.js +13 -0
- package/dist/components/ui/hover-card.js.map +1 -0
- package/dist/components/ui/image-block.d.ts +31 -0
- package/dist/components/ui/image-block.d.ts.map +1 -0
- package/dist/components/ui/image-block.js +103 -0
- package/dist/components/ui/image-block.js.map +1 -0
- package/dist/components/ui/image-card.d.ts +17 -0
- package/dist/components/ui/image-card.d.ts.map +1 -0
- package/dist/components/ui/image-card.js +39 -0
- package/dist/components/ui/image-card.js.map +1 -0
- package/dist/components/ui/image-framer.d.ts +24 -0
- package/dist/components/ui/image-framer.d.ts.map +1 -0
- package/dist/components/ui/image-framer.js +89 -0
- package/dist/components/ui/image-framer.js.map +1 -0
- package/dist/components/ui/image-viewer.d.ts +31 -0
- package/dist/components/ui/image-viewer.d.ts.map +1 -0
- package/dist/components/ui/image-viewer.js +114 -0
- package/dist/components/ui/image-viewer.js.map +1 -0
- package/dist/components/ui/image.d.ts +33 -0
- package/dist/components/ui/image.d.ts.map +1 -0
- package/dist/components/ui/image.js +61 -0
- package/dist/components/ui/image.js.map +1 -0
- package/dist/components/ui/index.d.ts +92 -0
- package/dist/components/ui/index.d.ts.map +1 -0
- package/dist/components/ui/index.js +92 -0
- package/dist/components/ui/index.js.map +1 -0
- package/dist/components/ui/input.d.ts +75 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +245 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/link-block.d.ts +13 -0
- package/dist/components/ui/link-block.d.ts.map +1 -0
- package/dist/components/ui/link-block.js +21 -0
- package/dist/components/ui/link-block.js.map +1 -0
- package/dist/components/ui/list-detail.d.ts +23 -0
- package/dist/components/ui/list-detail.d.ts.map +1 -0
- package/dist/components/ui/list-detail.js +33 -0
- package/dist/components/ui/list-detail.js.map +1 -0
- package/dist/components/ui/listbox.d.ts +7 -0
- package/dist/components/ui/listbox.d.ts.map +1 -0
- package/dist/components/ui/listbox.js +29 -0
- package/dist/components/ui/listbox.js.map +1 -0
- package/dist/components/ui/mac-card.d.ts +15 -0
- package/dist/components/ui/mac-card.d.ts.map +1 -0
- package/dist/components/ui/mac-card.js +9 -0
- package/dist/components/ui/mac-card.js.map +1 -0
- package/dist/components/ui/month-picker.d.ts +13 -0
- package/dist/components/ui/month-picker.d.ts.map +1 -0
- package/dist/components/ui/month-picker.js +53 -0
- package/dist/components/ui/month-picker.js.map +1 -0
- package/dist/components/ui/multi-select.d.ts +22 -0
- package/dist/components/ui/multi-select.d.ts.map +1 -0
- package/dist/components/ui/multi-select.js +88 -0
- package/dist/components/ui/multi-select.js.map +1 -0
- package/dist/components/ui/nav-tree.d.ts +16 -0
- package/dist/components/ui/nav-tree.d.ts.map +1 -0
- package/dist/components/ui/nav-tree.js +41 -0
- package/dist/components/ui/nav-tree.js.map +1 -0
- package/dist/components/ui/page.d.ts +23 -0
- package/dist/components/ui/page.d.ts.map +1 -0
- package/dist/components/ui/page.js +28 -0
- package/dist/components/ui/page.js.map +1 -0
- package/dist/components/ui/pagination.d.ts +26 -0
- package/dist/components/ui/pagination.d.ts.map +1 -0
- package/dist/components/ui/pagination.js +54 -0
- package/dist/components/ui/pagination.js.map +1 -0
- package/dist/components/ui/picker-panel.d.ts +13 -0
- package/dist/components/ui/picker-panel.d.ts.map +1 -0
- package/dist/components/ui/picker-panel.js +19 -0
- package/dist/components/ui/picker-panel.js.map +1 -0
- package/dist/components/ui/popover.d.ts +8 -0
- package/dist/components/ui/popover.d.ts.map +1 -0
- package/dist/components/ui/popover.js +18 -0
- package/dist/components/ui/popover.js.map +1 -0
- package/dist/components/ui/progress.d.ts +19 -0
- package/dist/components/ui/progress.d.ts.map +1 -0
- package/dist/components/ui/progress.js +22 -0
- package/dist/components/ui/progress.js.map +1 -0
- package/dist/components/ui/property.d.ts +11 -0
- package/dist/components/ui/property.d.ts.map +1 -0
- package/dist/components/ui/property.js +18 -0
- package/dist/components/ui/property.js.map +1 -0
- package/dist/components/ui/radio-group.d.ts +8 -0
- package/dist/components/ui/radio-group.d.ts.map +1 -0
- package/dist/components/ui/radio-group.js +18 -0
- package/dist/components/ui/radio-group.js.map +1 -0
- package/dist/components/ui/rating.d.ts +14 -0
- package/dist/components/ui/rating.d.ts.map +1 -0
- package/dist/components/ui/rating.js +61 -0
- package/dist/components/ui/rating.js.map +1 -0
- package/dist/components/ui/save-status.d.ts +8 -0
- package/dist/components/ui/save-status.d.ts.map +1 -0
- package/dist/components/ui/save-status.js +31 -0
- package/dist/components/ui/save-status.js.map +1 -0
- package/dist/components/ui/segmented.d.ts +21 -0
- package/dist/components/ui/segmented.d.ts.map +1 -0
- package/dist/components/ui/segmented.js +12 -0
- package/dist/components/ui/segmented.js.map +1 -0
- package/dist/components/ui/select-menu.d.ts +12 -0
- package/dist/components/ui/select-menu.d.ts.map +1 -0
- package/dist/components/ui/select-menu.js +10 -0
- package/dist/components/ui/select-menu.js.map +1 -0
- package/dist/components/ui/select.d.ts +16 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/select.js +45 -0
- package/dist/components/ui/select.js.map +1 -0
- package/dist/components/ui/selection-bar.d.ts +12 -0
- package/dist/components/ui/selection-bar.d.ts.map +1 -0
- package/dist/components/ui/selection-bar.js +15 -0
- package/dist/components/ui/selection-bar.js.map +1 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/separator.js +12 -0
- package/dist/components/ui/separator.js.map +1 -0
- package/dist/components/ui/settings-layout.d.ts +34 -0
- package/dist/components/ui/settings-layout.d.ts.map +1 -0
- package/dist/components/ui/settings-layout.js +16 -0
- package/dist/components/ui/settings-layout.js.map +1 -0
- package/dist/components/ui/share-link.d.ts +14 -0
- package/dist/components/ui/share-link.d.ts.map +1 -0
- package/dist/components/ui/share-link.js +16 -0
- package/dist/components/ui/share-link.js.map +1 -0
- package/dist/components/ui/sheet.d.ts +21 -0
- package/dist/components/ui/sheet.d.ts.map +1 -0
- package/dist/components/ui/sheet.js +53 -0
- package/dist/components/ui/sheet.js.map +1 -0
- package/dist/components/ui/sidebar.d.ts +82 -0
- package/dist/components/ui/sidebar.d.ts.map +1 -0
- package/dist/components/ui/sidebar.js +258 -0
- package/dist/components/ui/sidebar.js.map +1 -0
- package/dist/components/ui/skeleton.d.ts +8 -0
- package/dist/components/ui/skeleton.d.ts.map +1 -0
- package/dist/components/ui/skeleton.js +15 -0
- package/dist/components/ui/skeleton.js.map +1 -0
- package/dist/components/ui/spinner.d.ts +12 -0
- package/dist/components/ui/spinner.d.ts.map +1 -0
- package/dist/components/ui/spinner.js +14 -0
- package/dist/components/ui/spinner.js.map +1 -0
- package/dist/components/ui/spotlight.d.ts +23 -0
- package/dist/components/ui/spotlight.d.ts.map +1 -0
- package/dist/components/ui/spotlight.js +110 -0
- package/dist/components/ui/spotlight.js.map +1 -0
- package/dist/components/ui/stat-tile.d.ts +8 -0
- package/dist/components/ui/stat-tile.d.ts.map +1 -0
- package/dist/components/ui/stat-tile.js +9 -0
- package/dist/components/ui/stat-tile.js.map +1 -0
- package/dist/components/ui/step-dialog.d.ts +20 -0
- package/dist/components/ui/step-dialog.d.ts.map +1 -0
- package/dist/components/ui/step-dialog.js +36 -0
- package/dist/components/ui/step-dialog.js.map +1 -0
- package/dist/components/ui/steps-layout.d.ts +20 -0
- package/dist/components/ui/steps-layout.d.ts.map +1 -0
- package/dist/components/ui/steps-layout.js +26 -0
- package/dist/components/ui/steps-layout.js.map +1 -0
- package/dist/components/ui/switch.d.ts +8 -0
- package/dist/components/ui/switch.d.ts.map +1 -0
- package/dist/components/ui/switch.js +21 -0
- package/dist/components/ui/switch.js.map +1 -0
- package/dist/components/ui/table.d.ts +16 -0
- package/dist/components/ui/table.d.ts.map +1 -0
- package/dist/components/ui/table.js +76 -0
- package/dist/components/ui/table.js.map +1 -0
- package/dist/components/ui/tabs.d.ts +7 -0
- package/dist/components/ui/tabs.d.ts.map +1 -0
- package/dist/components/ui/tabs.js +19 -0
- package/dist/components/ui/tabs.js.map +1 -0
- package/dist/components/ui/theme-toggle.d.ts +16 -0
- package/dist/components/ui/theme-toggle.d.ts.map +1 -0
- package/dist/components/ui/theme-toggle.js +65 -0
- package/dist/components/ui/theme-toggle.js.map +1 -0
- package/dist/components/ui/time-list.d.ts +16 -0
- package/dist/components/ui/time-list.d.ts.map +1 -0
- package/dist/components/ui/time-list.js +49 -0
- package/dist/components/ui/time-list.js.map +1 -0
- package/dist/components/ui/time-picker.d.ts +47 -0
- package/dist/components/ui/time-picker.d.ts.map +1 -0
- package/dist/components/ui/time-picker.js +141 -0
- package/dist/components/ui/time-picker.js.map +1 -0
- package/dist/components/ui/toast.d.ts +18 -0
- package/dist/components/ui/toast.d.ts.map +1 -0
- package/dist/components/ui/toast.js +77 -0
- package/dist/components/ui/toast.js.map +1 -0
- package/dist/components/ui/toggle.d.ts +15 -0
- package/dist/components/ui/toggle.d.ts.map +1 -0
- package/dist/components/ui/toggle.js +55 -0
- package/dist/components/ui/toggle.js.map +1 -0
- package/dist/components/ui/tooltip.d.ts +15 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip.js +32 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/components/ui/top-bar.d.ts +25 -0
- package/dist/components/ui/top-bar.d.ts.map +1 -0
- package/dist/components/ui/top-bar.js +23 -0
- package/dist/components/ui/top-bar.js.map +1 -0
- package/dist/components/ui/typography.d.ts +40 -0
- package/dist/components/ui/typography.d.ts.map +1 -0
- package/dist/components/ui/typography.js +98 -0
- package/dist/components/ui/typography.js.map +1 -0
- package/dist/components/ui/video-block.d.ts +14 -0
- package/dist/components/ui/video-block.d.ts.map +1 -0
- package/dist/components/ui/video-block.js +22 -0
- package/dist/components/ui/video-block.js.map +1 -0
- package/dist/hooks/use-dismiss.d.ts +5 -0
- package/dist/hooks/use-dismiss.d.ts.map +1 -0
- package/dist/hooks/use-dismiss.js +23 -0
- package/dist/hooks/use-dismiss.js.map +1 -0
- package/dist/hooks/use-escape-first.d.ts +3 -0
- package/dist/hooks/use-escape-first.d.ts.map +1 -0
- package/dist/hooks/use-escape-first.js +27 -0
- package/dist/hooks/use-escape-first.js.map +1 -0
- package/dist/hooks/use-media-query.d.ts +5 -0
- package/dist/hooks/use-media-query.d.ts.map +1 -0
- package/dist/hooks/use-media-query.js +16 -0
- package/dist/hooks/use-media-query.js.map +1 -0
- package/dist/hooks/use-save-queue.d.ts +13 -0
- package/dist/hooks/use-save-queue.d.ts.map +1 -0
- package/dist/hooks/use-save-queue.js +57 -0
- package/dist/hooks/use-save-queue.js.map +1 -0
- package/dist/hooks/use-selection.d.ts +10 -0
- package/dist/hooks/use-selection.d.ts.map +1 -0
- package/dist/hooks/use-selection.js +52 -0
- package/dist/hooks/use-selection.js.map +1 -0
- package/dist/hooks/use-shared-transition.d.ts +3 -0
- package/dist/hooks/use-shared-transition.d.ts.map +1 -0
- package/dist/hooks/use-shared-transition.js +38 -0
- package/dist/hooks/use-shared-transition.js.map +1 -0
- package/dist/hooks/use-upload-queue.d.ts +22 -0
- package/dist/hooks/use-upload-queue.d.ts.map +1 -0
- package/dist/hooks/use-upload-queue.js +78 -0
- package/dist/hooks/use-upload-queue.js.map +1 -0
- package/dist/lib/accent.d.ts +5 -0
- package/dist/lib/accent.d.ts.map +1 -0
- package/dist/lib/accent.js +10 -0
- package/dist/lib/accent.js.map +1 -0
- package/dist/lib/bento.d.ts +17 -0
- package/dist/lib/bento.d.ts.map +1 -0
- package/dist/lib/bento.js +92 -0
- package/dist/lib/bento.js.map +1 -0
- package/dist/lib/database.d.ts +92 -0
- package/dist/lib/database.d.ts.map +1 -0
- package/dist/lib/database.js +272 -0
- package/dist/lib/database.js.map +1 -0
- package/dist/lib/dates.d.ts +30 -0
- package/dist/lib/dates.d.ts.map +1 -0
- package/dist/lib/dates.js +61 -0
- package/dist/lib/dates.js.map +1 -0
- package/dist/lib/document.d.ts +79 -0
- package/dist/lib/document.d.ts.map +1 -0
- package/dist/lib/document.js +11 -0
- package/dist/lib/document.js.map +1 -0
- package/dist/lib/embed.d.ts +14 -0
- package/dist/lib/embed.d.ts.map +1 -0
- package/dist/lib/embed.js +63 -0
- package/dist/lib/embed.js.map +1 -0
- package/dist/lib/files.d.ts +23 -0
- package/dist/lib/files.d.ts.map +1 -0
- package/dist/lib/files.js +69 -0
- package/dist/lib/files.js.map +1 -0
- package/dist/lib/justified.d.ts +50 -0
- package/dist/lib/justified.d.ts.map +1 -0
- package/dist/lib/justified.js +78 -0
- package/dist/lib/justified.js.map +1 -0
- package/dist/lib/keys.d.ts +18 -0
- package/dist/lib/keys.d.ts.map +1 -0
- package/dist/lib/keys.js +66 -0
- package/dist/lib/keys.js.map +1 -0
- package/dist/lib/number.d.ts +4 -0
- package/dist/lib/number.d.ts.map +1 -0
- package/dist/lib/number.js +33 -0
- package/dist/lib/number.js.map +1 -0
- package/dist/lib/pointer.d.ts +2 -0
- package/dist/lib/pointer.d.ts.map +1 -0
- package/dist/lib/pointer.js +4 -0
- package/dist/lib/pointer.js.map +1 -0
- package/dist/lib/prepare-image.d.ts +43 -0
- package/dist/lib/prepare-image.d.ts.map +1 -0
- package/dist/lib/prepare-image.js +105 -0
- package/dist/lib/prepare-image.js.map +1 -0
- package/dist/lib/rich-text-dom.d.ts +16 -0
- package/dist/lib/rich-text-dom.d.ts.map +1 -0
- package/dist/lib/rich-text-dom.js +145 -0
- package/dist/lib/rich-text-dom.js.map +1 -0
- package/dist/lib/rich-text.d.ts +15 -0
- package/dist/lib/rich-text.d.ts.map +1 -0
- package/dist/lib/rich-text.js +35 -0
- package/dist/lib/rich-text.js.map +1 -0
- package/dist/lib/spotlight.d.ts +22 -0
- package/dist/lib/spotlight.d.ts.map +1 -0
- package/dist/lib/spotlight.js +66 -0
- package/dist/lib/spotlight.js.map +1 -0
- package/dist/lib/theme.d.ts +6 -0
- package/dist/lib/theme.d.ts.map +1 -0
- package/dist/lib/theme.js +15 -0
- package/dist/lib/theme.js.map +1 -0
- package/dist/lib/time.d.ts +19 -0
- package/dist/lib/time.d.ts.map +1 -0
- package/dist/lib/time.js +91 -0
- package/dist/lib/time.js.map +1 -0
- package/dist/lib/tree.d.ts +17 -0
- package/dist/lib/tree.d.ts.map +1 -0
- package/dist/lib/tree.js +35 -0
- package/dist/lib/tree.js.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +24 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/styles/notion.css +817 -0
- package/package.json +129 -5
- package/src/components/editor/block-text.tsx +271 -0
- package/src/components/editor/blocks.tsx +373 -0
- package/src/components/editor/document-editor.tsx +106 -0
- package/src/components/editor/document-view.tsx +205 -0
- package/src/components/editor/editor-state.tsx +298 -0
- package/src/components/editor/extensions/kit-blocks.tsx +452 -0
- package/src/components/editor/extensions/spoiler.tsx +81 -0
- package/src/components/editor/index.ts +10 -0
- package/src/components/editor/kinds.ts +158 -0
- package/src/components/editor/look.tsx +36 -0
- package/src/components/sketch/rough.tsx +90 -0
- package/src/components/three/model-viewer.tsx +514 -0
- package/src/components/ui/accent-picker.tsx +72 -0
- package/src/components/ui/address-field.tsx +57 -0
- package/src/components/ui/alert-dialog.tsx +136 -0
- package/src/components/ui/animated-height.tsx +34 -0
- package/src/components/ui/app-shell.tsx +140 -0
- package/src/components/ui/avatar.tsx +106 -0
- package/src/components/ui/badge.tsx +81 -0
- package/src/components/ui/banner.tsx +53 -0
- package/src/components/ui/breadcrumbs.tsx +25 -0
- package/src/components/ui/button.tsx +147 -0
- package/src/components/ui/calendar.tsx +101 -0
- package/src/components/ui/callout.tsx +61 -0
- package/src/components/ui/card.tsx +59 -0
- package/src/components/ui/checkbox.tsx +66 -0
- package/src/components/ui/choice-label.tsx +43 -0
- package/src/components/ui/collapsible.tsx +58 -0
- package/src/components/ui/collection-layout.tsx +69 -0
- package/src/components/ui/combobox.tsx +155 -0
- package/src/components/ui/command-menu.tsx +102 -0
- package/src/components/ui/context-menu.tsx +89 -0
- package/src/components/ui/copy-button.tsx +80 -0
- package/src/components/ui/database/calendar-view.tsx +180 -0
- package/src/components/ui/database/card-views.tsx +221 -0
- package/src/components/ui/database/cells.tsx +237 -0
- package/src/components/ui/database/database.tsx +279 -0
- package/src/components/ui/database/icons.ts +15 -0
- package/src/components/ui/database/table-view.tsx +311 -0
- package/src/components/ui/date-picker.tsx +208 -0
- package/src/components/ui/date-time-picker.tsx +123 -0
- package/src/components/ui/dialog.tsx +151 -0
- package/src/components/ui/document-layout.tsx +52 -0
- package/src/components/ui/dropdown-menu.tsx +185 -0
- package/src/components/ui/editable-text.tsx +142 -0
- package/src/components/ui/empty-state.tsx +35 -0
- package/src/components/ui/error-state.tsx +67 -0
- package/src/components/ui/field-button.tsx +70 -0
- package/src/components/ui/file-preview.tsx +80 -0
- package/src/components/ui/file-uploader.tsx +375 -0
- package/src/components/ui/filter-builder.tsx +304 -0
- package/src/components/ui/focus-shell.tsx +48 -0
- package/src/components/ui/handle-row.tsx +252 -0
- package/src/components/ui/header-bar.tsx +15 -0
- package/src/components/ui/hover-card.tsx +30 -0
- package/src/components/ui/image-block.tsx +238 -0
- package/src/components/ui/image-card.tsx +95 -0
- package/src/components/ui/image-framer.tsx +160 -0
- package/src/components/ui/image-viewer.tsx +230 -0
- package/src/components/ui/image.tsx +200 -0
- package/src/components/ui/index.ts +178 -0
- package/src/components/ui/input.tsx +471 -0
- package/src/components/ui/link-block.tsx +85 -0
- package/src/components/ui/list-detail.tsx +115 -0
- package/src/components/ui/listbox.ts +26 -0
- package/src/components/ui/mac-card.tsx +46 -0
- package/src/components/ui/month-picker.tsx +119 -0
- package/src/components/ui/multi-select.tsx +221 -0
- package/src/components/ui/nav-tree.tsx +92 -0
- package/src/components/ui/page.tsx +73 -0
- package/src/components/ui/pagination.tsx +143 -0
- package/src/components/ui/picker-panel.tsx +69 -0
- package/src/components/ui/popover.tsx +42 -0
- package/src/components/ui/progress.tsx +76 -0
- package/src/components/ui/property.tsx +33 -0
- package/src/components/ui/radio-group.tsx +61 -0
- package/src/components/ui/rating.tsx +122 -0
- package/src/components/ui/save-status.tsx +53 -0
- package/src/components/ui/segmented.tsx +74 -0
- package/src/components/ui/select-menu.tsx +54 -0
- package/src/components/ui/select.tsx +147 -0
- package/src/components/ui/selection-bar.tsx +50 -0
- package/src/components/ui/separator.tsx +30 -0
- package/src/components/ui/settings-layout.tsx +117 -0
- package/src/components/ui/share-link.tsx +66 -0
- package/src/components/ui/sheet.tsx +90 -0
- package/src/components/ui/sidebar.tsx +627 -0
- package/src/components/ui/skeleton.tsx +22 -0
- package/src/components/ui/spinner.tsx +28 -0
- package/src/components/ui/spotlight.tsx +222 -0
- package/src/components/ui/stat-tile.tsx +25 -0
- package/src/components/ui/step-dialog.tsx +104 -0
- package/src/components/ui/steps-layout.tsx +91 -0
- package/src/components/ui/switch.tsx +55 -0
- package/src/components/ui/table.tsx +99 -0
- package/src/components/ui/tabs.tsx +41 -0
- package/src/components/ui/theme-toggle.tsx +80 -0
- package/src/components/ui/time-list.tsx +106 -0
- package/src/components/ui/time-picker.tsx +344 -0
- package/src/components/ui/toast.tsx +132 -0
- package/src/components/ui/toggle.tsx +76 -0
- package/src/components/ui/tooltip.tsx +78 -0
- package/src/components/ui/top-bar.tsx +118 -0
- package/src/components/ui/typography.tsx +204 -0
- package/src/components/ui/video-block.tsx +66 -0
- package/src/hooks/use-dismiss.ts +24 -0
- package/src/hooks/use-escape-first.ts +25 -0
- package/src/hooks/use-media-query.ts +23 -0
- package/src/hooks/use-save-queue.ts +78 -0
- package/src/hooks/use-selection.ts +51 -0
- package/src/hooks/use-shared-transition.ts +40 -0
- package/src/hooks/use-upload-queue.ts +111 -0
- package/src/lib/accent.ts +11 -0
- package/src/lib/bento.ts +87 -0
- package/src/lib/database.ts +322 -0
- package/src/lib/dates.ts +75 -0
- package/src/lib/document.ts +55 -0
- package/src/lib/embed.ts +62 -0
- package/src/lib/files.ts +73 -0
- package/src/lib/justified.ts +106 -0
- package/src/lib/keys.ts +72 -0
- package/src/lib/number.ts +29 -0
- package/src/lib/pointer.ts +3 -0
- package/src/lib/prepare-image.ts +141 -0
- package/src/lib/rich-text-dom.ts +138 -0
- package/src/lib/rich-text.ts +50 -0
- package/src/lib/spotlight.ts +78 -0
- package/src/lib/theme.ts +18 -0
- package/src/lib/time.ts +83 -0
- package/src/lib/tree.ts +41 -0
- package/src/lib/utils.ts +25 -0
- package/src/styles/notion.css +817 -0
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState, type ReactNode } from "react";
|
|
4
|
+
import { Maximize2, Trash2 } from "lucide-react";
|
|
5
|
+
import type { Text } from "../../lib/rich-text.ts";
|
|
6
|
+
import { cn } from "../../lib/utils.ts";
|
|
7
|
+
import { Checkbox } from "../ui/checkbox.tsx";
|
|
8
|
+
import { DropdownMenuCheckboxItem, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator } from "../ui/dropdown-menu.tsx";
|
|
9
|
+
import { EditableText } from "../ui/editable-text.tsx";
|
|
10
|
+
import { HandleRow } from "../ui/handle-row.tsx";
|
|
11
|
+
import { ImageBlock } from "../ui/image-block.tsx";
|
|
12
|
+
import { LinkBlock } from "../ui/link-block.tsx";
|
|
13
|
+
import { VideoBlock } from "../ui/video-block.tsx";
|
|
14
|
+
import { locate } from "../../lib/tree.ts";
|
|
15
|
+
import { BlockText } from "./block-text.tsx";
|
|
16
|
+
import { useEditor } from "./editor-state.tsx";
|
|
17
|
+
import { hasText, isListType, type BuiltinNode, type Node } from "./kinds.ts";
|
|
18
|
+
import { BulletMark, HEADINGS, MARK_GUTTER, QUOTE } from "./look.tsx";
|
|
19
|
+
|
|
20
|
+
type Of<T extends BuiltinNode["type"]> = Extract<BuiltinNode, { type: T }>;
|
|
21
|
+
|
|
22
|
+
/** What a press on a selectable block leaves to the control it landed on. An extension marks
|
|
23
|
+
any other area that handles its own presses (rows that open a dialog) with `data-own-press`. */
|
|
24
|
+
const OWN_CLICK = "input, textarea, a, iframe, button:not(:disabled), [contenteditable=true], [role=slider], [data-own-press]";
|
|
25
|
+
|
|
26
|
+
/* One block's own line, with Notion's margin controls from HandleRow: "+" adds a
|
|
27
|
+
block below, and the grip drags it and, on a click, opens its menu. Blocks
|
|
28
|
+
without words — pictures, videos, cards, dividers — are picked as a whole by a
|
|
29
|
+
click and show it with an outline; see editor-state for what keys then do.
|
|
30
|
+
A list item's children sit outside the row, so hovering a child never lights
|
|
31
|
+
up its parent's controls. `menu` adds an extension's own entries
|
|
32
|
+
(DropdownMenuItem elements) to the grip's menu, above Delete. */
|
|
33
|
+
export function BlockRow({ block, className, children, open, menu }: { block: Node; className?: string; children: ReactNode; open?: () => void; menu?: ReactNode }) {
|
|
34
|
+
const ed = useEditor();
|
|
35
|
+
const place = locate(ed.blocks, block.id)!;
|
|
36
|
+
const parentId = place.parent?.id ?? null;
|
|
37
|
+
const { drag } = ed;
|
|
38
|
+
const current = ed.schema.kindOf(block);
|
|
39
|
+
const selectable = !hasText(block);
|
|
40
|
+
const selected = ed.selected === block.id;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<HandleRow
|
|
44
|
+
className={className}
|
|
45
|
+
onAdd={() => ed.create(parentId, block.id, { type: "paragraph", text: [] }, { focus: true })}
|
|
46
|
+
selected={selected}
|
|
47
|
+
onMove={{
|
|
48
|
+
up: place.index > 0 ? () => ed.moveBy(block.id, -1) : null,
|
|
49
|
+
down: place.index < place.siblings.length - 1 ? () => ed.moveBy(block.id, 1) : null,
|
|
50
|
+
}}
|
|
51
|
+
dragging={drag.id !== null}
|
|
52
|
+
onDragStart={() => drag.start(block.id)}
|
|
53
|
+
onDragEnd={drag.end}
|
|
54
|
+
onDragOverSide={(side) => (drag.drop?.id !== block.id || drag.drop.side !== side) && drag.over({ id: block.id, side })}
|
|
55
|
+
onDrop={() => {
|
|
56
|
+
if (drag.id !== null && drag.drop) {
|
|
57
|
+
const target = locate(ed.blocks, drag.drop.id)!;
|
|
58
|
+
const afterId = drag.drop.side === "after" ? target.node.id : (target.siblings[target.index - 1]?.id ?? null);
|
|
59
|
+
ed.move(drag.id, target.parent?.id ?? null, afterId);
|
|
60
|
+
}
|
|
61
|
+
drag.end();
|
|
62
|
+
}}
|
|
63
|
+
drop={drag.drop?.id === block.id && drag.id !== block.id ? drag.drop.side : null}
|
|
64
|
+
menu={
|
|
65
|
+
<>
|
|
66
|
+
{hasText(block) && (
|
|
67
|
+
<>
|
|
68
|
+
<DropdownMenuLabel>Turn into</DropdownMenuLabel>
|
|
69
|
+
{ed.schema.textKinds.map((k) => (
|
|
70
|
+
<DropdownMenuCheckboxItem
|
|
71
|
+
key={k.key}
|
|
72
|
+
checked={k.key === current?.key}
|
|
73
|
+
// A block with children can only become something that can hold them.
|
|
74
|
+
disabled={block.children.some((child) => !ed.schema.holds(k.make([]).type, child.type))}
|
|
75
|
+
onSelect={() => ed.edit(block.id, (b) => ({ ...k.make(hasText(b) ? b.text : []), id: b.id, children: b.children }) as Node, { rewrite: true })}
|
|
76
|
+
>
|
|
77
|
+
{k.label}
|
|
78
|
+
</DropdownMenuCheckboxItem>
|
|
79
|
+
))}
|
|
80
|
+
<DropdownMenuSeparator />
|
|
81
|
+
</>
|
|
82
|
+
)}
|
|
83
|
+
{open !== undefined && (
|
|
84
|
+
<DropdownMenuItem onSelect={open}>
|
|
85
|
+
<Maximize2 />
|
|
86
|
+
Open picture
|
|
87
|
+
</DropdownMenuItem>
|
|
88
|
+
)}
|
|
89
|
+
{menu !== undefined && (
|
|
90
|
+
<>
|
|
91
|
+
{menu}
|
|
92
|
+
<DropdownMenuSeparator />
|
|
93
|
+
</>
|
|
94
|
+
)}
|
|
95
|
+
<DropdownMenuItem danger onSelect={() => ed.remove(block.id)}>
|
|
96
|
+
<Trash2 />
|
|
97
|
+
Delete
|
|
98
|
+
</DropdownMenuItem>
|
|
99
|
+
</>
|
|
100
|
+
}
|
|
101
|
+
>
|
|
102
|
+
{selectable ? (
|
|
103
|
+
<div
|
|
104
|
+
data-block={block.id}
|
|
105
|
+
// A plain group has no selected state for assistive technology; the
|
|
106
|
+
// block's own controls (its menu) are how it is acted on.
|
|
107
|
+
data-selected={selected || undefined}
|
|
108
|
+
onPointerDown={(e) => {
|
|
109
|
+
if (!(e.target as HTMLElement).closest(OWN_CLICK)) ed.select(block.id);
|
|
110
|
+
}}
|
|
111
|
+
className={cn("rounded-surface transition-shadow duration-(--duration-fast)", selected && "shadow-[0_0_0_2px_var(--accent),0_0_0_5px_var(--accent-tint)]")}
|
|
112
|
+
>
|
|
113
|
+
{children}
|
|
114
|
+
</div>
|
|
115
|
+
) : (
|
|
116
|
+
children
|
|
117
|
+
)}
|
|
118
|
+
</HandleRow>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
type ListNode = Extract<BuiltinNode, { type: "bullet" | "numbered" | "check" }>;
|
|
123
|
+
const isList = (b: Node): b is ListNode => isListType(b.type);
|
|
124
|
+
|
|
125
|
+
/** Consecutive list items of one kind form one list, so numbering restarts where a run is interrupted. */
|
|
126
|
+
function runs(blocks: Node[]): (Node | ListNode[])[] {
|
|
127
|
+
const out: (Node | ListNode[])[] = [];
|
|
128
|
+
for (const block of blocks) {
|
|
129
|
+
const last = out.at(-1);
|
|
130
|
+
if (isList(block) && Array.isArray(last) && last[0]!.type === block.type) last.push(block);
|
|
131
|
+
else out.push(isList(block) ? [block] : block);
|
|
132
|
+
}
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function BlockList({ blocks, depth = 0 }: { blocks: Node[]; depth?: number }) {
|
|
137
|
+
const ed = useEditor();
|
|
138
|
+
// A page that is one empty paragraph still says what it is for, focused or not.
|
|
139
|
+
const alone = depth === 0 && blocks.length === 1;
|
|
140
|
+
return runs(blocks).map((entry) => {
|
|
141
|
+
// An app's own block draws itself.
|
|
142
|
+
const extension = Array.isArray(entry) ? undefined : ed.schema.extension(entry.type);
|
|
143
|
+
if (extension !== undefined && !Array.isArray(entry)) return <extension.Edit key={entry.id} block={entry} depth={depth} />;
|
|
144
|
+
return builtin(entry as BuiltinNode | ListNode[], depth, alone);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** The kit's own kinds, drawn. */
|
|
149
|
+
function builtin(entry: BuiltinNode | ListNode[], depth: number, alone: boolean) {
|
|
150
|
+
if (Array.isArray(entry)) {
|
|
151
|
+
const List = entry[0]!.type === "numbered" ? "ol" : "ul";
|
|
152
|
+
return (
|
|
153
|
+
<List key={entry[0]!.id}>
|
|
154
|
+
{entry.map((block, index) => (
|
|
155
|
+
<ListItem key={block.id} block={block} depth={depth} index={index} />
|
|
156
|
+
))}
|
|
157
|
+
</List>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
switch (entry.type) {
|
|
161
|
+
case "paragraph":
|
|
162
|
+
return (
|
|
163
|
+
<BlockRow key={entry.id} block={entry} className="my-px">
|
|
164
|
+
<BlockText
|
|
165
|
+
block={entry}
|
|
166
|
+
placeholder="Write, or type '/' for pictures, video and more"
|
|
167
|
+
alwaysShowPlaceholder={alone}
|
|
168
|
+
className="min-h-[1.5em] px-0.5 py-[3px]"
|
|
169
|
+
/>
|
|
170
|
+
</BlockRow>
|
|
171
|
+
);
|
|
172
|
+
case "heading":
|
|
173
|
+
return <Heading key={entry.id} block={entry} />;
|
|
174
|
+
case "quote":
|
|
175
|
+
return (
|
|
176
|
+
<BlockRow key={entry.id} block={entry} className="my-1">
|
|
177
|
+
<BlockText block={entry} placeholder="Quote" alwaysShowPlaceholder className={cn(QUOTE, "py-[3px]")} />
|
|
178
|
+
</BlockRow>
|
|
179
|
+
);
|
|
180
|
+
case "divider":
|
|
181
|
+
return (
|
|
182
|
+
<BlockRow key={entry.id} block={entry}>
|
|
183
|
+
{/* The space around the line is part of what a click selects. */}
|
|
184
|
+
<div className="cursor-pointer py-2.5">
|
|
185
|
+
<hr className="border-hairline-strong" />
|
|
186
|
+
</div>
|
|
187
|
+
</BlockRow>
|
|
188
|
+
);
|
|
189
|
+
case "image":
|
|
190
|
+
return <PictureBlock key={entry.id} block={entry} />;
|
|
191
|
+
case "video":
|
|
192
|
+
return <VideoEmbed key={entry.id} block={entry} />;
|
|
193
|
+
case "bookmark":
|
|
194
|
+
return <Bookmark key={entry.id} block={entry} />;
|
|
195
|
+
default:
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function Heading({ block }: { block: Of<"heading"> }) {
|
|
201
|
+
return (
|
|
202
|
+
<BlockRow block={block} className={cn("first:mt-0", HEADINGS[block.level])}>
|
|
203
|
+
{/* Colour sits apart from the size class: tailwind-merge takes both for text colours and keeps one. */}
|
|
204
|
+
<div role="heading" aria-level={block.level + 1} className="text-accent-text">
|
|
205
|
+
<BlockText block={block} placeholder={`Heading ${block.level}`} alwaysShowPlaceholder className="px-0.5 py-[3px]" />
|
|
206
|
+
</div>
|
|
207
|
+
</BlockRow>
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function ListItem({ block, depth, index }: { block: ListNode; depth: number; index: number }) {
|
|
212
|
+
const ed = useEditor();
|
|
213
|
+
const marker =
|
|
214
|
+
block.type === "check" ? (
|
|
215
|
+
<Checkbox checked={block.checked} onCheckedChange={(checked) => ed.edit(block.id, (b) => (b.type === "check" ? { ...b, checked: checked === true } : b))} />
|
|
216
|
+
) : block.type === "numbered" ? (
|
|
217
|
+
<span className="tabular-nums">{index + 1}.</span>
|
|
218
|
+
) : (
|
|
219
|
+
<BulletMark depth={depth} />
|
|
220
|
+
);
|
|
221
|
+
const done = block.type === "check" && block.checked;
|
|
222
|
+
|
|
223
|
+
return (
|
|
224
|
+
<li className="my-px">
|
|
225
|
+
<BlockRow block={block}>
|
|
226
|
+
<div className="flex items-start px-0.5 py-[3px]">
|
|
227
|
+
<span contentEditable={false} className={MARK_GUTTER}>
|
|
228
|
+
{marker}
|
|
229
|
+
</span>
|
|
230
|
+
<BlockText
|
|
231
|
+
block={block}
|
|
232
|
+
placeholder={block.type === "check" ? "To-do" : "List"}
|
|
233
|
+
alwaysShowPlaceholder
|
|
234
|
+
className={cn("flex-1", done && "text-ink-secondary line-through decoration-ink-tertiary")}
|
|
235
|
+
/>
|
|
236
|
+
</div>
|
|
237
|
+
</BlockRow>
|
|
238
|
+
{block.children.length > 0 && (
|
|
239
|
+
<div className="pl-6">
|
|
240
|
+
<BlockList blocks={block.children} depth={depth + 1} />
|
|
241
|
+
</div>
|
|
242
|
+
)}
|
|
243
|
+
</li>
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** A caption under a picture or a video: rich text of its own, saved with the block. Enter goes on below. */
|
|
248
|
+
export function Caption({ block, text }: { block: Node; text: Text }) {
|
|
249
|
+
const ed = useEditor();
|
|
250
|
+
return (
|
|
251
|
+
<EditableText
|
|
252
|
+
text={text}
|
|
253
|
+
rev={ed.rev(block.id)}
|
|
254
|
+
placeholder="Add a caption"
|
|
255
|
+
onLink={ed.onLink}
|
|
256
|
+
className="px-0.5 text-center"
|
|
257
|
+
onChange={(caption) => ed.edit(block.id, (b) => ({ ...b, caption }) as Node, { typing: true })}
|
|
258
|
+
onKeyDown={(e) => {
|
|
259
|
+
if (e.key === "Enter" && !e.nativeEvent.isComposing && e.keyCode !== 229) {
|
|
260
|
+
e.preventDefault();
|
|
261
|
+
const place = locate(ed.blocks, block.id)!;
|
|
262
|
+
ed.create(place.parent?.id ?? null, block.id, { type: "paragraph", text: [] }, { focus: true });
|
|
263
|
+
}
|
|
264
|
+
}}
|
|
265
|
+
/>
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* ImageBlock in a document. A file is handed to the owner's `uploadImage`, which
|
|
271
|
+
* says where it can be loaded from; without one, only links are taken. Once it
|
|
272
|
+
* has a picture the block is selected, so Enter goes on writing below it. A click
|
|
273
|
+
* selects it; opening it larger is in its menu.
|
|
274
|
+
*/
|
|
275
|
+
export function PictureBlock({ block }: { block: Of<"image"> }) {
|
|
276
|
+
const ed = useEditor();
|
|
277
|
+
const [busy, setBusy] = useState<number | false>(false);
|
|
278
|
+
const [error, setError] = useState<string>();
|
|
279
|
+
const set = (patch: Partial<Of<"image">>) => ed.edit(block.id, (b) => ({ ...b, ...patch }) as Node);
|
|
280
|
+
const upload = ed.uploadImage;
|
|
281
|
+
|
|
282
|
+
const onFile = async (file: File) => {
|
|
283
|
+
if (!upload) return;
|
|
284
|
+
setError(undefined);
|
|
285
|
+
setBusy(0);
|
|
286
|
+
// Where focus was when the upload began: if the user has gone on to type or
|
|
287
|
+
// search elsewhere by the time it lands, the picture does not take focus back.
|
|
288
|
+
const before = document.activeElement;
|
|
289
|
+
try {
|
|
290
|
+
const image = await upload(file, setBusy);
|
|
291
|
+
set({ src: image.src, ref: image.ref, aspect: image.aspect });
|
|
292
|
+
const now = document.activeElement;
|
|
293
|
+
if (now === before || now === null || now === document.body) ed.select(block.id);
|
|
294
|
+
} catch (err) {
|
|
295
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
296
|
+
} finally {
|
|
297
|
+
setBusy(false);
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
// Which addresses are fine to show is the owner's rule; the kit takes what it is given.
|
|
302
|
+
const src = block.src;
|
|
303
|
+
// A picture an app's extra supplies is selected like one uploaded, so Enter writes below it.
|
|
304
|
+
const extras =
|
|
305
|
+
ed.imageExtras?.(block, (patch) => {
|
|
306
|
+
set(patch);
|
|
307
|
+
if (patch.src !== undefined) ed.select(block.id);
|
|
308
|
+
}) ?? {};
|
|
309
|
+
|
|
310
|
+
return (
|
|
311
|
+
<BlockRow block={block} className="my-2" open={src === undefined ? undefined : () => window.open(src, "_blank", "noreferrer")}>
|
|
312
|
+
<ImageBlock
|
|
313
|
+
src={src}
|
|
314
|
+
aspect={block.aspect}
|
|
315
|
+
width={block.width}
|
|
316
|
+
onWidthChange={(width) => set({ width })}
|
|
317
|
+
onFile={upload ? (file) => void onFile(file) : undefined}
|
|
318
|
+
onLink={(url) => {
|
|
319
|
+
const refused = ed.checkLink?.(url, "image") ?? null;
|
|
320
|
+
if (refused !== null) return setError(refused);
|
|
321
|
+
setError(undefined);
|
|
322
|
+
set({ src: url, ref: undefined, aspect: undefined });
|
|
323
|
+
ed.select(block.id);
|
|
324
|
+
}}
|
|
325
|
+
busy={busy === false ? false : busy}
|
|
326
|
+
error={error}
|
|
327
|
+
more={extras.more}
|
|
328
|
+
actions={extras.actions}
|
|
329
|
+
placeholder={extras.placeholder}
|
|
330
|
+
caption={src === undefined ? undefined : <Caption block={block} text={block.caption} />}
|
|
331
|
+
/>
|
|
332
|
+
</BlockRow>
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function VideoEmbed({ block }: { block: Of<"video"> }) {
|
|
337
|
+
const ed = useEditor();
|
|
338
|
+
return (
|
|
339
|
+
<BlockRow block={block} className="my-2">
|
|
340
|
+
<VideoBlock
|
|
341
|
+
url={block.url}
|
|
342
|
+
check={ed.checkLink === undefined ? undefined : (url) => ed.checkLink!(url, "video")}
|
|
343
|
+
onLink={(url) => {
|
|
344
|
+
ed.edit(block.id, (b) => ({ ...b, url }) as Node);
|
|
345
|
+
ed.select(block.id);
|
|
346
|
+
}}
|
|
347
|
+
caption={<Caption block={block} text={block.caption} />}
|
|
348
|
+
/>
|
|
349
|
+
</BlockRow>
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function Bookmark({ block }: { block: Of<"bookmark"> }) {
|
|
354
|
+
const ed = useEditor();
|
|
355
|
+
return (
|
|
356
|
+
<BlockRow block={block} className="my-2">
|
|
357
|
+
<LinkBlock
|
|
358
|
+
url={block.url}
|
|
359
|
+
title={block.title}
|
|
360
|
+
check={ed.checkLink === undefined ? undefined : (url) => ed.checkLink!(url, "bookmark")}
|
|
361
|
+
onTitleChange={(title) => ed.edit(block.id, (b) => ({ ...b, title }) as Node, { typing: true })}
|
|
362
|
+
onTitleEnter={() => {
|
|
363
|
+
const place = locate(ed.blocks, block.id)!;
|
|
364
|
+
ed.create(place.parent?.id ?? null, block.id, { type: "paragraph", text: [] }, { focus: true });
|
|
365
|
+
}}
|
|
366
|
+
onLink={(url) => {
|
|
367
|
+
ed.edit(block.id, (b) => ({ ...b, url }) as Node);
|
|
368
|
+
ed.select(block.id);
|
|
369
|
+
}}
|
|
370
|
+
/>
|
|
371
|
+
</BlockRow>
|
|
372
|
+
);
|
|
373
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { AnyBlock } from "../../lib/document.ts";
|
|
4
|
+
import { plain } from "../../lib/rich-text.ts";
|
|
5
|
+
import { BlockList } from "./blocks.tsx";
|
|
6
|
+
import { useImperativeHandle, useRef, type Ref } from "react";
|
|
7
|
+
import { DocumentProvider, useEditor, type CheckLink, type ImageExtras, type OnLink, type ProviderProps, type UploadImage } from "./editor-state.tsx";
|
|
8
|
+
import { hasText, toBlocks } from "./kinds.ts";
|
|
9
|
+
import { DragRows } from "../ui/handle-row.tsx";
|
|
10
|
+
import { withKitBlocks } from "./extensions/kit-blocks.tsx";
|
|
11
|
+
import type { AnyExtension } from "./kinds.ts";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A Notion-style page of blocks, edited in place: text, headings, lists, to-dos,
|
|
15
|
+
* quotes, dividers, pictures, video and link cards. Enter splits, Backspace at the
|
|
16
|
+
* start joins, Tab nests, "/" opens the list of blocks, and blocks without words
|
|
17
|
+
* are selected and removed like Notion's. It holds the document while it is
|
|
18
|
+
* edited and reports every change; storing it is the owner's.
|
|
19
|
+
*
|
|
20
|
+
* Remount it (with a `key`) to replace the document from outside, for example
|
|
21
|
+
* with a newer version saved elsewhere.
|
|
22
|
+
*/
|
|
23
|
+
/** What an owner can do to an editor from outside it: `ref={handle}`. */
|
|
24
|
+
export type DocumentEditorHandle = {
|
|
25
|
+
/** Puts the caret in a block, the first when no id is given (from a title, on Enter). */
|
|
26
|
+
focus: (id?: number, at?: number | "end") => void;
|
|
27
|
+
/** The document as it stands, in its stored shape. */
|
|
28
|
+
blocks: () => AnyBlock[];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export function DocumentEditor({
|
|
32
|
+
initial,
|
|
33
|
+
onChange,
|
|
34
|
+
uploadImage,
|
|
35
|
+
checkLink,
|
|
36
|
+
onLink,
|
|
37
|
+
imageExtras,
|
|
38
|
+
extensions,
|
|
39
|
+
kinds,
|
|
40
|
+
newId,
|
|
41
|
+
ref,
|
|
42
|
+
placeholder = "Write, or type “/” for headings, pictures, video and links",
|
|
43
|
+
className,
|
|
44
|
+
}: ProviderProps & {
|
|
45
|
+
ref?: Ref<DocumentEditorHandle>;
|
|
46
|
+
placeholder?: string;
|
|
47
|
+
className?: string;
|
|
48
|
+
}) {
|
|
49
|
+
return (
|
|
50
|
+
<DocumentProvider
|
|
51
|
+
initial={initial}
|
|
52
|
+
onChange={onChange}
|
|
53
|
+
uploadImage={uploadImage}
|
|
54
|
+
checkLink={checkLink}
|
|
55
|
+
onLink={onLink}
|
|
56
|
+
imageExtras={imageExtras}
|
|
57
|
+
extensions={withKitBlocks(extensions) as AnyExtension[]}
|
|
58
|
+
kinds={kinds}
|
|
59
|
+
newId={newId}
|
|
60
|
+
>
|
|
61
|
+
<Body placeholder={placeholder} className={className} handle={ref} />
|
|
62
|
+
</DocumentProvider>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function Body({ placeholder, className, handle }: { placeholder: string; className?: string; handle?: Ref<DocumentEditorHandle> }) {
|
|
67
|
+
const ed = useEditor();
|
|
68
|
+
const latest = useRef(ed);
|
|
69
|
+
latest.current = ed;
|
|
70
|
+
useImperativeHandle(
|
|
71
|
+
handle,
|
|
72
|
+
() => ({
|
|
73
|
+
focus: (id, at = 0) => {
|
|
74
|
+
const target = id ?? latest.current.blocks[0]?.id;
|
|
75
|
+
if (target !== undefined) latest.current.focus(target, at);
|
|
76
|
+
else latest.current.create(null, null, { type: "paragraph", text: [] }, { focus: true });
|
|
77
|
+
},
|
|
78
|
+
blocks: () => toBlocks(latest.current.blocks, latest.current.schema),
|
|
79
|
+
}),
|
|
80
|
+
[],
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
// Clicking the empty space under the last block continues the page, as in Notion.
|
|
84
|
+
const continuePage = () => {
|
|
85
|
+
const last = ed.blocks.at(-1);
|
|
86
|
+
if (last?.type === "paragraph" && hasText(last) && plain(last.text) === "") ed.focus(last.id);
|
|
87
|
+
else ed.create(null, last?.id ?? null, { type: "paragraph", text: [] }, { focus: true });
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
// Room on the left for the margin controls, which hang outside each block.
|
|
92
|
+
// The gutter is the margin controls' (HandleRow, 46px) and is always 3rem. A page may pull the
|
|
93
|
+
// editor left to line its text up with a title, but by no more than its own padding, or the
|
|
94
|
+
// controls land on whatever is beside the page. Phones have neither gutter nor controls.
|
|
95
|
+
<div ref={ed.root} className={`relative flex min-h-24 flex-col pl-12 max-sm:pl-0 ${className ?? ""}`}>
|
|
96
|
+
<DragRows>
|
|
97
|
+
<BlockList blocks={ed.blocks} />
|
|
98
|
+
</DragRows>
|
|
99
|
+
<button type="button" aria-label="Continue writing" className="flex min-h-16 w-full flex-1 cursor-text items-start" onClick={continuePage}>
|
|
100
|
+
{ed.blocks.length === 0 && <span className="mt-px px-0.5 py-[3px] text-left text-ink-tertiary">{placeholder}</span>}
|
|
101
|
+
</button>
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type { CheckLink, ImageExtras, OnLink, UploadImage };
|