@kujoforall/paper-ui 0.1.0 → 0.2.1
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 +94 -0
- package/README.md +50 -7
- package/dist/components/editor/block-text.d.ts.map +1 -1
- package/dist/components/editor/block-text.js +52 -17
- package/dist/components/editor/block-text.js.map +1 -1
- package/dist/components/editor/blocks.d.ts.map +1 -1
- package/dist/components/editor/blocks.js +17 -13
- package/dist/components/editor/blocks.js.map +1 -1
- package/dist/components/editor/document-editor.d.ts.map +1 -1
- package/dist/components/editor/document-editor.js +4 -2
- package/dist/components/editor/document-editor.js.map +1 -1
- package/dist/components/editor/document-view.d.ts.map +1 -1
- package/dist/components/editor/document-view.js +17 -12
- package/dist/components/editor/document-view.js.map +1 -1
- package/dist/components/editor/editor-state.d.ts +7 -0
- package/dist/components/editor/editor-state.d.ts.map +1 -1
- package/dist/components/editor/editor-state.js +28 -3
- package/dist/components/editor/editor-state.js.map +1 -1
- 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.map +1 -1
- package/dist/components/editor/extensions/spoiler.js +2 -2
- package/dist/components/editor/extensions/spoiler.js.map +1 -1
- package/dist/components/editor/index.d.ts +1 -0
- package/dist/components/editor/index.d.ts.map +1 -1
- package/dist/components/editor/index.js +1 -0
- package/dist/components/editor/index.js.map +1 -1
- package/dist/components/editor/kinds.js +1 -1
- package/dist/components/editor/kinds.js.map +1 -1
- 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/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.js +1 -1
- package/dist/components/ui/accent-picker.js.map +1 -1
- 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 +1 -0
- package/dist/components/ui/app-shell.d.ts.map +1 -1
- package/dist/components/ui/app-shell.js +5 -3
- package/dist/components/ui/app-shell.js.map +1 -1
- 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 +3 -3
- package/dist/components/ui/badge.d.ts.map +1 -1
- package/dist/components/ui/badge.js +2 -2
- package/dist/components/ui/badge.js.map +1 -1
- 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.js +1 -1
- package/dist/components/ui/breadcrumbs.js.map +1 -1
- package/dist/components/ui/button.d.ts +8 -6
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +91 -26
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/calendar.d.ts.map +1 -1
- package/dist/components/ui/calendar.js +6 -5
- package/dist/components/ui/calendar.js.map +1 -1
- package/dist/components/ui/callout.d.ts +23 -4
- package/dist/components/ui/callout.d.ts.map +1 -1
- package/dist/components/ui/callout.js +28 -15
- package/dist/components/ui/callout.js.map +1 -1
- package/dist/components/ui/card.d.ts +13 -8
- package/dist/components/ui/card.d.ts.map +1 -1
- package/dist/components/ui/card.js +10 -9
- package/dist/components/ui/card.js.map +1 -1
- package/dist/components/ui/checkbox.d.ts +9 -4
- package/dist/components/ui/checkbox.d.ts.map +1 -1
- package/dist/components/ui/checkbox.js +25 -5
- package/dist/components/ui/checkbox.js.map +1 -1
- 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 +5 -2
- package/dist/components/ui/command-menu.d.ts.map +1 -1
- package/dist/components/ui/command-menu.js +31 -6
- package/dist/components/ui/command-menu.js.map +1 -1
- 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 +6 -1
- package/dist/components/ui/date-picker.d.ts.map +1 -1
- package/dist/components/ui/date-picker.js +20 -12
- package/dist/components/ui/date-picker.js.map +1 -1
- package/dist/components/ui/date-time-picker.d.ts +3 -1
- package/dist/components/ui/date-time-picker.d.ts.map +1 -1
- package/dist/components/ui/date-time-picker.js +17 -15
- package/dist/components/ui/date-time-picker.js.map +1 -1
- package/dist/components/ui/dialog.d.ts +13 -9
- package/dist/components/ui/dialog.d.ts.map +1 -1
- package/dist/components/ui/dialog.js +33 -3
- package/dist/components/ui/dialog.js.map +1 -1
- 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 +14 -10
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu.js +22 -13
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/editable-text.d.ts +9 -2
- package/dist/components/ui/editable-text.d.ts.map +1 -1
- package/dist/components/ui/editable-text.js +27 -10
- package/dist/components/ui/editable-text.js.map +1 -1
- 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 +2 -1
- package/dist/components/ui/field-button.d.ts.map +1 -1
- package/dist/components/ui/field-button.js +7 -5
- package/dist/components/ui/field-button.js.map +1 -1
- package/dist/components/ui/file-preview.js +1 -1
- package/dist/components/ui/file-preview.js.map +1 -1
- package/dist/components/ui/file-uploader.d.ts.map +1 -1
- package/dist/components/ui/file-uploader.js +5 -4
- package/dist/components/ui/file-uploader.js.map +1 -1
- 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 +11 -1
- package/dist/components/ui/handle-row.d.ts.map +1 -1
- package/dist/components/ui/handle-row.js +101 -32
- package/dist/components/ui/handle-row.js.map +1 -1
- 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.js +4 -4
- package/dist/components/ui/image-block.js.map +1 -1
- package/dist/components/ui/image-card.d.ts.map +1 -1
- package/dist/components/ui/image-card.js +5 -4
- package/dist/components/ui/image-card.js.map +1 -1
- 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.map +1 -1
- package/dist/components/ui/image-viewer.js +38 -5
- package/dist/components/ui/image-viewer.js.map +1 -1
- package/dist/components/ui/image.d.ts +25 -3
- package/dist/components/ui/image.d.ts.map +1 -1
- package/dist/components/ui/image.js +50 -21
- package/dist/components/ui/image.js.map +1 -1
- package/dist/components/ui/index.d.ts +54 -11
- package/dist/components/ui/index.d.ts.map +1 -1
- package/dist/components/ui/index.js +53 -10
- package/dist/components/ui/index.js.map +1 -1
- package/dist/components/ui/input.d.ts +71 -12
- package/dist/components/ui/input.d.ts.map +1 -1
- package/dist/components/ui/input.js +236 -23
- package/dist/components/ui/input.js.map +1 -1
- package/dist/components/ui/link-block.d.ts.map +1 -1
- package/dist/components/ui/link-block.js +1 -1
- package/dist/components/ui/link-block.js.map +1 -1
- 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.js +1 -1
- package/dist/components/ui/mac-card.js.map +1 -1
- 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.map +1 -1
- package/dist/components/ui/nav-tree.js +10 -3
- package/dist/components/ui/nav-tree.js.map +1 -1
- package/dist/components/ui/page.d.ts +16 -5
- package/dist/components/ui/page.d.ts.map +1 -1
- package/dist/components/ui/page.js +23 -10
- package/dist/components/ui/page.js.map +1 -1
- 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 +2 -2
- package/dist/components/ui/popover.d.ts.map +1 -1
- package/dist/components/ui/popover.js +1 -1
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/progress.d.ts +11 -1
- package/dist/components/ui/progress.d.ts.map +1 -1
- package/dist/components/ui/progress.js +17 -4
- package/dist/components/ui/progress.js.map +1 -1
- package/dist/components/ui/property.d.ts +2 -6
- package/dist/components/ui/property.d.ts.map +1 -1
- package/dist/components/ui/property.js +6 -22
- package/dist/components/ui/property.js.map +1 -1
- 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 +15 -7
- package/dist/components/ui/segmented.d.ts.map +1 -1
- package/dist/components/ui/segmented.js +8 -6
- package/dist/components/ui/segmented.js.map +1 -1
- package/dist/components/ui/select-menu.d.ts +3 -1
- package/dist/components/ui/select-menu.d.ts.map +1 -1
- package/dist/components/ui/select-menu.js +2 -2
- package/dist/components/ui/select-menu.js.map +1 -1
- package/dist/components/ui/select.d.ts +7 -2
- package/dist/components/ui/select.d.ts.map +1 -1
- package/dist/components/ui/select.js +19 -5
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/selection-bar.js +1 -1
- package/dist/components/ui/selection-bar.js.map +1 -1
- 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.map +1 -1
- package/dist/components/ui/spotlight.js +14 -11
- package/dist/components/ui/spotlight.js.map +1 -1
- package/dist/components/ui/step-dialog.js +3 -3
- package/dist/components/ui/step-dialog.js.map +1 -1
- 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 +13 -5
- package/dist/components/ui/table.d.ts.map +1 -1
- package/dist/components/ui/table.js +65 -12
- package/dist/components/ui/table.js.map +1 -1
- 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 +14 -0
- package/dist/components/ui/theme-toggle.d.ts.map +1 -1
- package/dist/components/ui/theme-toggle.js +69 -41
- package/dist/components/ui/theme-toggle.js.map +1 -1
- 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 +37 -11
- package/dist/components/ui/time-picker.d.ts.map +1 -1
- package/dist/components/ui/time-picker.js +130 -52
- package/dist/components/ui/time-picker.js.map +1 -1
- 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 +1 -1
- package/dist/components/ui/tooltip.d.ts.map +1 -1
- package/dist/components/ui/tooltip.js +13 -2
- package/dist/components/ui/tooltip.js.map +1 -1
- 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 +11 -5
- package/dist/components/ui/typography.d.ts.map +1 -1
- package/dist/components/ui/typography.js +31 -5
- package/dist/components/ui/typography.js.map +1 -1
- package/dist/components/ui/video-block.d.ts.map +1 -1
- package/dist/components/ui/video-block.js +5 -1
- package/dist/components/ui/video-block.js.map +1 -1
- 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.map +1 -1
- package/dist/hooks/use-save-queue.js +19 -7
- package/dist/hooks/use-save-queue.js.map +1 -1
- package/dist/hooks/use-selection.d.ts.map +1 -1
- package/dist/hooks/use-selection.js +10 -1
- package/dist/hooks/use-selection.js.map +1 -1
- 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 +16 -0
- package/dist/lib/dates.d.ts.map +1 -1
- package/dist/lib/dates.js +27 -0
- package/dist/lib/dates.js.map +1 -1
- 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 +2 -0
- package/dist/lib/rich-text-dom.d.ts.map +1 -1
- package/dist/lib/rich-text-dom.js +5 -3
- package/dist/lib/rich-text-dom.js.map +1 -1
- 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/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +20 -2
- package/dist/lib/utils.js.map +1 -1
- package/dist/styles/notion.css +342 -51
- package/package.json +27 -4
- package/src/components/editor/block-text.tsx +58 -17
- package/src/components/editor/blocks.tsx +19 -14
- package/src/components/editor/document-editor.tsx +7 -2
- package/src/components/editor/document-view.tsx +37 -24
- package/src/components/editor/editor-state.tsx +31 -3
- package/src/components/editor/extensions/kit-blocks.tsx +452 -0
- package/src/components/editor/extensions/spoiler.tsx +9 -4
- package/src/components/editor/index.ts +1 -0
- package/src/components/editor/kinds.ts +1 -1
- package/src/components/editor/look.tsx +36 -0
- package/src/components/three/model-viewer.tsx +514 -0
- package/src/components/ui/accent-picker.tsx +2 -2
- 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 +9 -7
- package/src/components/ui/avatar.tsx +106 -0
- package/src/components/ui/badge.tsx +4 -4
- package/src/components/ui/banner.tsx +53 -0
- package/src/components/ui/breadcrumbs.tsx +1 -1
- package/src/components/ui/button.tsx +115 -41
- package/src/components/ui/calendar.tsx +8 -7
- package/src/components/ui/callout.tsx +41 -42
- package/src/components/ui/card.tsx +27 -58
- package/src/components/ui/checkbox.tsx +53 -19
- 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 +61 -31
- 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 +99 -61
- package/src/components/ui/date-time-picker.tsx +68 -62
- package/src/components/ui/dialog.tsx +48 -21
- package/src/components/ui/document-layout.tsx +52 -0
- package/src/components/ui/dropdown-menu.tsx +33 -31
- package/src/components/ui/editable-text.tsx +40 -7
- 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 +11 -9
- package/src/components/ui/file-preview.tsx +1 -1
- package/src/components/ui/file-uploader.tsx +23 -24
- 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 +176 -40
- 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 +6 -6
- package/src/components/ui/image-card.tsx +18 -25
- package/src/components/ui/image-framer.tsx +160 -0
- package/src/components/ui/image-viewer.tsx +53 -10
- package/src/components/ui/image.tsx +133 -29
- package/src/components/ui/index.ts +106 -11
- package/src/components/ui/input.tsx +437 -65
- package/src/components/ui/link-block.tsx +5 -2
- package/src/components/ui/list-detail.tsx +115 -0
- package/src/components/ui/listbox.ts +26 -0
- package/src/components/ui/mac-card.tsx +5 -5
- 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 +11 -5
- package/src/components/ui/page.tsx +63 -15
- package/src/components/ui/pagination.tsx +143 -0
- package/src/components/ui/picker-panel.tsx +69 -0
- package/src/components/ui/popover.tsx +3 -3
- package/src/components/ui/progress.tsx +56 -16
- package/src/components/ui/property.tsx +6 -37
- 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 +48 -16
- package/src/components/ui/select-menu.tsx +11 -3
- package/src/components/ui/select.tsx +33 -10
- package/src/components/ui/selection-bar.tsx +1 -1
- 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 +21 -21
- package/src/components/ui/step-dialog.tsx +6 -6
- package/src/components/ui/steps-layout.tsx +91 -0
- package/src/components/ui/switch.tsx +55 -0
- package/src/components/ui/table.tsx +75 -18
- package/src/components/ui/tabs.tsx +41 -0
- package/src/components/ui/theme-toggle.tsx +74 -83
- package/src/components/ui/time-list.tsx +106 -0
- package/src/components/ui/time-picker.tsx +305 -134
- package/src/components/ui/toast.tsx +132 -0
- package/src/components/ui/toggle.tsx +76 -0
- package/src/components/ui/tooltip.tsx +20 -6
- package/src/components/ui/top-bar.tsx +118 -0
- package/src/components/ui/typography.tsx +45 -9
- package/src/components/ui/video-block.tsx +9 -3
- 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 +19 -7
- package/src/hooks/use-selection.ts +8 -1
- package/src/lib/database.ts +322 -0
- package/src/lib/dates.ts +36 -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 +5 -3
- package/src/lib/theme.ts +18 -0
- package/src/lib/time.ts +83 -0
- package/src/lib/utils.ts +21 -2
- package/src/styles/notion.css +342 -51
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { useState, type KeyboardEvent } from "react";
|
|
3
|
+
import { useId, useState, type KeyboardEvent } from "react";
|
|
4
4
|
import type { Text } from "../../lib/rich-text.ts";
|
|
5
|
-
import { CommandMenu } from "../ui/command-menu.tsx";
|
|
5
|
+
import { CommandMenu, commandOptionId } from "../ui/command-menu.tsx";
|
|
6
|
+
import { useEscapeFirst } from "../../hooks/use-escape-first.ts";
|
|
6
7
|
import { caretOffset, caretOnEdgeLine, caretRect } from "../../lib/rich-text-dom.ts";
|
|
7
8
|
import { EditableText } from "../ui/editable-text.tsx";
|
|
8
9
|
import { useEditor } from "./editor-state.tsx";
|
|
9
10
|
import { hasText, isListType, type BlockKind, type Draft, type Node, type TextNode } from "./kinds.ts";
|
|
10
11
|
import { cut, normalize, plain, split } from "../../lib/rich-text.ts";
|
|
11
|
-
import {
|
|
12
|
+
import { locate } from "../../lib/tree.ts";
|
|
13
|
+
import { stepActive } from "../ui/listbox.ts";
|
|
14
|
+
import { matchShortcut } from "../../lib/keys.ts";
|
|
12
15
|
|
|
13
16
|
type Slash = { from: number; query: string; index: number; rect: DOMRect };
|
|
14
17
|
|
|
@@ -32,6 +35,9 @@ export function BlockText({
|
|
|
32
35
|
const { schema } = ed;
|
|
33
36
|
const kind = (key: string) => schema.kind(key)!;
|
|
34
37
|
const [slash, setSlash] = useState<Slash | null>(null);
|
|
38
|
+
const menuId = `slash-${useId()}`;
|
|
39
|
+
// Escape closes the "/" menu and nothing else: not a dialog the editor is in.
|
|
40
|
+
useEscapeFirst(slash !== null, (target) => target instanceof Element && target.getAttribute("data-text") === String(block.id), () => setSlash(null));
|
|
35
41
|
const matches = slash ? schema.kinds.filter((k) => k.label.toLowerCase().includes(slash.query.toLowerCase())) : [];
|
|
36
42
|
|
|
37
43
|
const place = locate(ed.blocks, block.id)!;
|
|
@@ -97,11 +103,14 @@ export function BlockText({
|
|
|
97
103
|
}
|
|
98
104
|
|
|
99
105
|
const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
|
|
106
|
+
// The Enter (or arrow) that finishes composing Japanese, Chinese or Korean
|
|
107
|
+
// belongs to the input method, not to the editor.
|
|
108
|
+
if (e.nativeEvent.isComposing || e.keyCode === 229) return;
|
|
100
109
|
if (slash && matches.length > 0) {
|
|
101
|
-
const
|
|
102
|
-
if (
|
|
110
|
+
const next = e.key === "ArrowDown" || e.key === "ArrowUp" ? stepActive(slash.index, matches.length, e.key) : null;
|
|
111
|
+
if (next !== null) {
|
|
103
112
|
e.preventDefault();
|
|
104
|
-
setSlash({ ...slash, index:
|
|
113
|
+
setSlash({ ...slash, index: next });
|
|
105
114
|
return;
|
|
106
115
|
}
|
|
107
116
|
if (e.key === "Enter") {
|
|
@@ -110,7 +119,22 @@ export function BlockText({
|
|
|
110
119
|
return;
|
|
111
120
|
}
|
|
112
121
|
}
|
|
113
|
-
|
|
122
|
+
// Escape, with no menu open, leaves the text and selects its block, as
|
|
123
|
+
// Notion's does: from there Tab moves on, so the keyboard is never held.
|
|
124
|
+
if (e.key === "Escape") {
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
ed.select(block.id);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ⌘⇧↑ / ⌘⇧↓ move the block among its siblings, as Notion's do; the caret stays in it.
|
|
131
|
+
if (matchShortcut(e, "mod+shift+up") || matchShortcut(e, "mod+shift+down")) {
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
const at = caretOffset(e.currentTarget) ?? "end";
|
|
134
|
+
ed.moveBy(block.id, e.key === "ArrowUp" ? -1 : 1);
|
|
135
|
+
ed.focus(block.id, at);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
114
138
|
|
|
115
139
|
const caret = caretOffset(e.currentTarget);
|
|
116
140
|
const length = plain(block.text).length;
|
|
@@ -137,8 +161,11 @@ export function BlockText({
|
|
|
137
161
|
? { type: block.type as "bullet" | "numbered", text: after }
|
|
138
162
|
: { type: "paragraph", text: after };
|
|
139
163
|
setText(before);
|
|
140
|
-
// A toggle's own line names it; what Enter starts goes inside it.
|
|
141
|
-
if (schema.toggle(block.type))
|
|
164
|
+
// A toggle's own line names it; what Enter starts goes inside it (unfolded, to be seen).
|
|
165
|
+
if (schema.toggle(block.type)) {
|
|
166
|
+
ed.fold(block.id, false);
|
|
167
|
+
ed.create(block.id, null, next, { focus: true });
|
|
168
|
+
}
|
|
142
169
|
// With children, the new item goes first among them, where the caret appears to be.
|
|
143
170
|
else if (block.children.length > 0) ed.create(block.id, null, next, { focus: true });
|
|
144
171
|
else ed.create(parentId, block.id, next, { focus: true });
|
|
@@ -151,7 +178,7 @@ export function BlockText({
|
|
|
151
178
|
if (block.children.length === 0) turnInto(kind("text"), block.text);
|
|
152
179
|
return;
|
|
153
180
|
}
|
|
154
|
-
const order =
|
|
181
|
+
const order = ed.order();
|
|
155
182
|
const prev = order[order.findIndex((b) => b.id === block.id) - 1];
|
|
156
183
|
if (!prev) return;
|
|
157
184
|
e.preventDefault();
|
|
@@ -169,12 +196,17 @@ export function BlockText({
|
|
|
169
196
|
return;
|
|
170
197
|
}
|
|
171
198
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
199
|
+
// Tab nests and Shift+Tab un-nests. Where neither can, Tab is left to move
|
|
200
|
+
// focus on, so it never traps the keyboard.
|
|
201
|
+
if (e.key === "Tab" && !e.altKey && !e.metaKey && !e.ctrlKey) {
|
|
202
|
+
if (e.shiftKey) {
|
|
203
|
+
if (!place.parent) return;
|
|
204
|
+
e.preventDefault();
|
|
205
|
+
outdent(caret ?? "end");
|
|
206
|
+
} else {
|
|
176
207
|
const above = place.siblings[place.index - 1];
|
|
177
208
|
if (!above || !schema.holds(above.type, block.type)) return;
|
|
209
|
+
e.preventDefault();
|
|
178
210
|
ed.move(block.id, above.id, above.children.at(-1)?.id ?? null);
|
|
179
211
|
ed.focus(block.id, caret ?? "end");
|
|
180
212
|
}
|
|
@@ -184,7 +216,7 @@ export function BlockText({
|
|
|
184
216
|
// Delete at the end of a line takes in what follows: the next line's words,
|
|
185
217
|
// or, when a picture or card is next, selects it to be deleted.
|
|
186
218
|
if (e.key === "Delete" && caret === length && window.getSelection()?.isCollapsed) {
|
|
187
|
-
const order =
|
|
219
|
+
const order = ed.order();
|
|
188
220
|
const next = order[order.findIndex((b) => b.id === block.id) + 1];
|
|
189
221
|
if (next === undefined || block.children.length > 0) return;
|
|
190
222
|
e.preventDefault();
|
|
@@ -202,7 +234,7 @@ export function BlockText({
|
|
|
202
234
|
(e.key === "ArrowUp" && (caret === 0 || caretOnEdgeLine(e.currentTarget, "first"))) ||
|
|
203
235
|
(e.key === "ArrowDown" && (caret === length || caretOnEdgeLine(e.currentTarget, "last")))
|
|
204
236
|
) {
|
|
205
|
-
const order =
|
|
237
|
+
const order = ed.order();
|
|
206
238
|
const to = order[order.findIndex((b) => b.id === block.id) + (e.key === "ArrowUp" ? -1 : 1)];
|
|
207
239
|
if (!to) return;
|
|
208
240
|
e.preventDefault();
|
|
@@ -223,8 +255,17 @@ export function BlockText({
|
|
|
223
255
|
placeholder={placeholder}
|
|
224
256
|
alwaysShowPlaceholder={alwaysShowPlaceholder}
|
|
225
257
|
className={className}
|
|
258
|
+
// The menu closes when the caret leaves; a click in it keeps the caret.
|
|
259
|
+
onBlur={() => setSlash(null)}
|
|
260
|
+
aria={
|
|
261
|
+
slash && matches.length > 0
|
|
262
|
+
? { "aria-controls": menuId, "aria-expanded": true, "aria-haspopup": "listbox", "aria-activedescendant": commandOptionId(menuId, slash.index) }
|
|
263
|
+
: undefined
|
|
264
|
+
}
|
|
226
265
|
/>
|
|
227
|
-
{slash && matches.length > 0 &&
|
|
266
|
+
{slash && matches.length > 0 && (
|
|
267
|
+
<CommandMenu id={menuId} title="Blocks" rect={slash.rect} commands={matches} index={slash.index} onPick={(c) => pick(c as BlockKind)} />
|
|
268
|
+
)}
|
|
228
269
|
</>
|
|
229
270
|
);
|
|
230
271
|
}
|
|
@@ -15,6 +15,7 @@ import { locate } from "../../lib/tree.ts";
|
|
|
15
15
|
import { BlockText } from "./block-text.tsx";
|
|
16
16
|
import { useEditor } from "./editor-state.tsx";
|
|
17
17
|
import { hasText, isListType, type BuiltinNode, type Node } from "./kinds.ts";
|
|
18
|
+
import { BulletMark, HEADINGS, MARK_GUTTER, QUOTE } from "./look.tsx";
|
|
18
19
|
|
|
19
20
|
type Of<T extends BuiltinNode["type"]> = Extract<BuiltinNode, { type: T }>;
|
|
20
21
|
|
|
@@ -42,6 +43,11 @@ export function BlockRow({ block, className, children, open, menu }: { block: No
|
|
|
42
43
|
<HandleRow
|
|
43
44
|
className={className}
|
|
44
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
|
+
}}
|
|
45
51
|
dragging={drag.id !== null}
|
|
46
52
|
onDragStart={() => drag.start(block.id)}
|
|
47
53
|
onDragEnd={drag.end}
|
|
@@ -96,11 +102,13 @@ export function BlockRow({ block, className, children, open, menu }: { block: No
|
|
|
96
102
|
{selectable ? (
|
|
97
103
|
<div
|
|
98
104
|
data-block={block.id}
|
|
99
|
-
|
|
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}
|
|
100
108
|
onPointerDown={(e) => {
|
|
101
109
|
if (!(e.target as HTMLElement).closest(OWN_CLICK)) ed.select(block.id);
|
|
102
110
|
}}
|
|
103
|
-
className={cn("rounded-surface transition-shadow duration-
|
|
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)]")}
|
|
104
112
|
>
|
|
105
113
|
{children}
|
|
106
114
|
</div>
|
|
@@ -166,7 +174,7 @@ function builtin(entry: BuiltinNode | ListNode[], depth: number, alone: boolean)
|
|
|
166
174
|
case "quote":
|
|
167
175
|
return (
|
|
168
176
|
<BlockRow key={entry.id} block={entry} className="my-1">
|
|
169
|
-
<BlockText block={entry} placeholder="Quote" alwaysShowPlaceholder className="
|
|
177
|
+
<BlockText block={entry} placeholder="Quote" alwaysShowPlaceholder className={cn(QUOTE, "py-[3px]")} />
|
|
170
178
|
</BlockRow>
|
|
171
179
|
);
|
|
172
180
|
case "divider":
|
|
@@ -189,10 +197,6 @@ function builtin(entry: BuiltinNode | ListNode[], depth: number, alone: boolean)
|
|
|
189
197
|
}
|
|
190
198
|
}
|
|
191
199
|
|
|
192
|
-
/* Rank comes from size and the space above, nothing else. A heading sits much
|
|
193
|
-
closer to what follows it than to what came before. */
|
|
194
|
-
const HEADINGS = { 1: "text-h1 mt-8 mb-1", 2: "text-h2 mt-6 mb-1", 3: "text-h3 mt-4 mb-0.5" } as const;
|
|
195
|
-
|
|
196
200
|
function Heading({ block }: { block: Of<"heading"> }) {
|
|
197
201
|
return (
|
|
198
202
|
<BlockRow block={block} className={cn("first:mt-0", HEADINGS[block.level])}>
|
|
@@ -204,9 +208,6 @@ function Heading({ block }: { block: Of<"heading"> }) {
|
|
|
204
208
|
);
|
|
205
209
|
}
|
|
206
210
|
|
|
207
|
-
/** Notion cycles the bullet by depth: disc, ring, square. Drawn as shapes, since the glyphs fall back to emoji on some platforms. */
|
|
208
|
-
const BULLETS = ["rounded-full bg-current", "rounded-full border border-current", "bg-current"];
|
|
209
|
-
|
|
210
211
|
function ListItem({ block, depth, index }: { block: ListNode; depth: number; index: number }) {
|
|
211
212
|
const ed = useEditor();
|
|
212
213
|
const marker =
|
|
@@ -215,7 +216,7 @@ function ListItem({ block, depth, index }: { block: ListNode; depth: number; ind
|
|
|
215
216
|
) : block.type === "numbered" ? (
|
|
216
217
|
<span className="tabular-nums">{index + 1}.</span>
|
|
217
218
|
) : (
|
|
218
|
-
<
|
|
219
|
+
<BulletMark depth={depth} />
|
|
219
220
|
);
|
|
220
221
|
const done = block.type === "check" && block.checked;
|
|
221
222
|
|
|
@@ -223,7 +224,7 @@ function ListItem({ block, depth, index }: { block: ListNode; depth: number; ind
|
|
|
223
224
|
<li className="my-px">
|
|
224
225
|
<BlockRow block={block}>
|
|
225
226
|
<div className="flex items-start px-0.5 py-[3px]">
|
|
226
|
-
<span contentEditable={false} className=
|
|
227
|
+
<span contentEditable={false} className={MARK_GUTTER}>
|
|
227
228
|
{marker}
|
|
228
229
|
</span>
|
|
229
230
|
<BlockText
|
|
@@ -255,7 +256,7 @@ export function Caption({ block, text }: { block: Node; text: Text }) {
|
|
|
255
256
|
className="px-0.5 text-center"
|
|
256
257
|
onChange={(caption) => ed.edit(block.id, (b) => ({ ...b, caption }) as Node, { typing: true })}
|
|
257
258
|
onKeyDown={(e) => {
|
|
258
|
-
if (e.key === "Enter") {
|
|
259
|
+
if (e.key === "Enter" && !e.nativeEvent.isComposing && e.keyCode !== 229) {
|
|
259
260
|
e.preventDefault();
|
|
260
261
|
const place = locate(ed.blocks, block.id)!;
|
|
261
262
|
ed.create(place.parent?.id ?? null, block.id, { type: "paragraph", text: [] }, { focus: true });
|
|
@@ -282,10 +283,14 @@ export function PictureBlock({ block }: { block: Of<"image"> }) {
|
|
|
282
283
|
if (!upload) return;
|
|
283
284
|
setError(undefined);
|
|
284
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;
|
|
285
289
|
try {
|
|
286
290
|
const image = await upload(file, setBusy);
|
|
287
291
|
set({ src: image.src, ref: image.ref, aspect: image.aspect });
|
|
288
|
-
|
|
292
|
+
const now = document.activeElement;
|
|
293
|
+
if (now === before || now === null || now === document.body) ed.select(block.id);
|
|
289
294
|
} catch (err) {
|
|
290
295
|
setError(err instanceof Error ? err.message : String(err));
|
|
291
296
|
} finally {
|
|
@@ -6,6 +6,9 @@ import { BlockList } from "./blocks.tsx";
|
|
|
6
6
|
import { useImperativeHandle, useRef, type Ref } from "react";
|
|
7
7
|
import { DocumentProvider, useEditor, type CheckLink, type ImageExtras, type OnLink, type ProviderProps, type UploadImage } from "./editor-state.tsx";
|
|
8
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";
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* A Notion-style page of blocks, edited in place: text, headings, lists, to-dos,
|
|
@@ -51,7 +54,7 @@ export function DocumentEditor({
|
|
|
51
54
|
checkLink={checkLink}
|
|
52
55
|
onLink={onLink}
|
|
53
56
|
imageExtras={imageExtras}
|
|
54
|
-
extensions={extensions}
|
|
57
|
+
extensions={withKitBlocks(extensions) as AnyExtension[]}
|
|
55
58
|
kinds={kinds}
|
|
56
59
|
newId={newId}
|
|
57
60
|
>
|
|
@@ -90,7 +93,9 @@ function Body({ placeholder, className, handle }: { placeholder: string; classNa
|
|
|
90
93
|
// editor left to line its text up with a title, but by no more than its own padding, or the
|
|
91
94
|
// controls land on whatever is beside the page. Phones have neither gutter nor controls.
|
|
92
95
|
<div ref={ed.root} className={`relative flex min-h-24 flex-col pl-12 max-sm:pl-0 ${className ?? ""}`}>
|
|
93
|
-
<
|
|
96
|
+
<DragRows>
|
|
97
|
+
<BlockList blocks={ed.blocks} />
|
|
98
|
+
</DragRows>
|
|
94
99
|
<button type="button" aria-label="Continue writing" className="flex min-h-16 w-full flex-1 cursor-text items-start" onClick={continuePage}>
|
|
95
100
|
{ed.blocks.length === 0 && <span className="mt-px px-0.5 py-[3px] text-left text-ink-tertiary">{placeholder}</span>}
|
|
96
101
|
</button>
|
|
@@ -8,6 +8,9 @@ import type { Span, Text } from "../../lib/rich-text.ts";
|
|
|
8
8
|
import { cn } from "../../lib/utils.ts";
|
|
9
9
|
import { Image } from "../ui/image.tsx";
|
|
10
10
|
import type { AnyExtension } from "./kinds.ts";
|
|
11
|
+
import { CODE_CLASSES } from "../../lib/rich-text-dom.ts";
|
|
12
|
+
import { BulletMark, CheckMark, HEADINGS as PAGE_HEADINGS, MARK_GUTTER, QUOTE } from "./look.tsx";
|
|
13
|
+
import { withKitBlocks } from "./extensions/kit-blocks.tsx";
|
|
11
14
|
|
|
12
15
|
/*
|
|
13
16
|
* A document read-only, for readers: what DocumentEditor writes, drawn as React
|
|
@@ -29,14 +32,14 @@ export function Spans({ text }: { text: Text }) {
|
|
|
29
32
|
|
|
30
33
|
function SpanView({ span }: { span: Span }) {
|
|
31
34
|
let node: ReactNode = span.text;
|
|
32
|
-
if (span.code) node = <code className=
|
|
35
|
+
if (span.code) node = <code className={CODE_CLASSES}>{node}</code>;
|
|
33
36
|
if (span.bold) node = <strong className="font-semibold">{node}</strong>;
|
|
34
37
|
if (span.italic) node = <em>{node}</em>;
|
|
35
38
|
if (span.strike) node = <s>{node}</s>;
|
|
36
39
|
if (span.page !== undefined) node = <span className="font-medium text-accent-text">{node}</span>;
|
|
37
40
|
else if (span.href !== undefined && safe(span.href)) {
|
|
38
41
|
node = (
|
|
39
|
-
<a href={span.href} target="_blank" rel="noreferrer nofollow ugc" className="
|
|
42
|
+
<a href={span.href} target="_blank" rel="noreferrer nofollow ugc" className="link">
|
|
40
43
|
{node}
|
|
41
44
|
</a>
|
|
42
45
|
);
|
|
@@ -45,20 +48,19 @@ function SpanView({ span }: { span: Span }) {
|
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
const HEADINGS = {
|
|
48
|
-
page:
|
|
51
|
+
page: PAGE_HEADINGS,
|
|
49
52
|
// Inside a list, a heading ranks by weight more than size, so it never outgrows what holds it.
|
|
50
|
-
compact: { 1: "text-
|
|
53
|
+
compact: { 1: "text-lead font-semibold mt-4 mb-0.5", 2: "text-body font-semibold mt-3 mb-0.5", 3: "text-sm font-semibold mt-2" },
|
|
51
54
|
} as const;
|
|
52
55
|
const SPACE = {
|
|
53
|
-
page: { p: "my-2 leading-
|
|
54
|
-
compact: { p: "my-1", quote: "my-2 px-3", figure: "my-3", divider: "my-3", list: "my-0.5" },
|
|
56
|
+
page: { p: "my-2 leading-prose", quote: cn("my-4", QUOTE), figure: "my-6", divider: "my-6", list: "my-1" },
|
|
57
|
+
compact: { p: "my-1", quote: cn("my-2", QUOTE, "px-3 text-body"), figure: "my-3", divider: "my-3", list: "my-0.5" },
|
|
55
58
|
} as const;
|
|
56
|
-
const BULLETS = ["list-disc", "list-[circle]", "list-[square]"];
|
|
57
59
|
|
|
58
60
|
/** Draws `blocks`. Pass the same `extensions` the editor was given, for an app's own blocks. */
|
|
59
61
|
export function DocumentView({ blocks, extensions, density = "page", className }: { blocks: AnyBlock[]; extensions?: AnyExtension[]; density?: Density; className?: string }) {
|
|
60
62
|
return (
|
|
61
|
-
<Extensions value={new Map((extensions
|
|
63
|
+
<Extensions value={new Map(withKitBlocks(extensions).map((x) => [x.type, x as AnyExtension]))}>
|
|
62
64
|
<Dense value={density}>
|
|
63
65
|
<div className={cn("text-ink", className)}>
|
|
64
66
|
<Blocks blocks={blocks} />
|
|
@@ -87,22 +89,33 @@ export function Blocks({ blocks, depth = 0 }: { blocks: AnyBlock[]; depth?: numb
|
|
|
87
89
|
i -= 1;
|
|
88
90
|
const List = b.type === "numbered" ? "ol" : "ul";
|
|
89
91
|
out.push(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
92
|
+
// The marks are drawn as the editor draws them (the list's own markers are
|
|
93
|
+
// off), so a saved page reads as it was written.
|
|
94
|
+
<List key={b.id} className={cn(space.list, "list-none")}>
|
|
95
|
+
{run.map((item, n) => (
|
|
96
|
+
<li key={item.id} className="py-[3px]">
|
|
97
|
+
<span className="flex items-start">
|
|
98
|
+
<span className={MARK_GUTTER}>
|
|
99
|
+
{item.type === "check" ? (
|
|
100
|
+
<>
|
|
101
|
+
<CheckMark checked={item.checked} />
|
|
102
|
+
<span className="sr-only">{item.checked ? "Done: " : "To do: "}</span>
|
|
103
|
+
</>
|
|
104
|
+
) : item.type === "numbered" ? (
|
|
105
|
+
<span aria-hidden className="tabular-nums">{n + 1}.</span>
|
|
106
|
+
) : (
|
|
107
|
+
<BulletMark depth={depth} />
|
|
108
|
+
)}
|
|
101
109
|
</span>
|
|
102
|
-
|
|
103
|
-
|
|
110
|
+
<span className={cn("flex-1 min-w-0", item.type === "check" && item.checked && "text-ink-secondary line-through decoration-ink-tertiary")}>
|
|
111
|
+
<Spans text={item.text} />
|
|
112
|
+
</span>
|
|
113
|
+
</span>
|
|
114
|
+
{item.children.length > 0 && (
|
|
115
|
+
<div className="pl-6">
|
|
116
|
+
<Blocks blocks={item.children} depth={depth + 1} />
|
|
117
|
+
</div>
|
|
104
118
|
)}
|
|
105
|
-
{item.children.length > 0 && <Blocks blocks={item.children} depth={depth + 1} />}
|
|
106
119
|
</li>
|
|
107
120
|
))}
|
|
108
121
|
</List>,
|
|
@@ -132,7 +145,7 @@ function BlockView({ block }: { block: Block }) {
|
|
|
132
145
|
);
|
|
133
146
|
case "quote":
|
|
134
147
|
return (
|
|
135
|
-
<blockquote className={
|
|
148
|
+
<blockquote className={space.quote}>
|
|
136
149
|
<Spans text={block.text} />
|
|
137
150
|
</blockquote>
|
|
138
151
|
);
|
|
@@ -177,7 +190,7 @@ function BlockView({ block }: { block: Block }) {
|
|
|
177
190
|
case "bookmark":
|
|
178
191
|
if (block.url === "" || !safe(block.url)) return null;
|
|
179
192
|
return (
|
|
180
|
-
<a href={block.url} target="_blank" rel="noreferrer nofollow ugc" className={cn(density === "compact" ? "my-2" : "my-4", "flex items-center gap-3 rounded-surface px-3.5 py-3 shadow-
|
|
193
|
+
<a href={block.url} target="_blank" rel="noreferrer nofollow ugc" className={cn(density === "compact" ? "my-2" : "my-4", "flex items-center gap-3 rounded-surface px-3.5 py-3 shadow-edge transition-colors duration-(--duration-fast) hover:bg-tint-hover")}>
|
|
181
194
|
<span className="flex size-9 shrink-0 items-center justify-center rounded-control bg-accent-tint text-accent-text">
|
|
182
195
|
<Globe className="size-4" />
|
|
183
196
|
</span>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, type ReactNode, type RefObject } from "react";
|
|
4
4
|
import type { AnyBlock } from "../../lib/document.ts";
|
|
5
|
-
import { contains,
|
|
5
|
+
import { contains, insert, locate, remove, update } from "../../lib/tree.ts";
|
|
6
6
|
import { setCaret } from "../../lib/rich-text-dom.ts";
|
|
7
7
|
import { hasText, schemaFor, toBlocks, toNodes, type AnyExtension, type Draft, type BuiltinNode, type KindOptions, type Node, type Schema } from "./kinds.ts";
|
|
8
8
|
|
|
@@ -43,6 +43,8 @@ type Editor = {
|
|
|
43
43
|
create: (parentId: number | null, afterId: number | null, draft: Draft, opts?: { focus?: boolean }) => number;
|
|
44
44
|
remove: (id: number) => void;
|
|
45
45
|
move: (id: number, parentId: number | null, afterId: number | null) => void;
|
|
46
|
+
/** One place up (-1) or down (1) among its siblings; nothing at either end. */
|
|
47
|
+
moveBy: (id: number, by: -1 | 1) => void;
|
|
46
48
|
/** The caret into a block: its text, an extension's `focus`, or else the block selected whole. */
|
|
47
49
|
focus: (id: number, at?: FocusAt) => void;
|
|
48
50
|
/**
|
|
@@ -52,6 +54,11 @@ type Editor = {
|
|
|
52
54
|
*/
|
|
53
55
|
selected: number | null;
|
|
54
56
|
select: (id: number | null) => void;
|
|
57
|
+
/** Toggles folded shut in this editor (a reader's choice, not saved in the document). */
|
|
58
|
+
folded: (id: number) => boolean;
|
|
59
|
+
fold: (id: number, shut: boolean) => void;
|
|
60
|
+
/** Every block in reading order, leaving out what is inside a folded toggle: what the arrows walk. */
|
|
61
|
+
order: () => Node[];
|
|
55
62
|
drag: { id: number | null; drop: Drop | null; start: (id: number) => void; over: (drop: Drop | null) => void; end: () => void };
|
|
56
63
|
};
|
|
57
64
|
|
|
@@ -112,6 +119,10 @@ export function DocumentProvider({
|
|
|
112
119
|
const [drop, setDrop] = useState<Drop | null>(null);
|
|
113
120
|
const [pendingFocus, setPendingFocus] = useState<{ id: number; at: FocusAt } | null>(null);
|
|
114
121
|
const [selected, setSelected] = useState<number | null>(null);
|
|
122
|
+
const [shut, setShut] = useState<ReadonlySet<number>>(() => new Set());
|
|
123
|
+
const shutRef = useRef(shut);
|
|
124
|
+
shutRef.current = shut;
|
|
125
|
+
const visible = (nodes: Node[]): Node[] => nodes.flatMap((n) => [n, ...(shutRef.current.has(n.id) ? [] : visible(n.children))]);
|
|
115
126
|
|
|
116
127
|
const tree = useRef(blocks);
|
|
117
128
|
const counter = useRef(nextId(blocks));
|
|
@@ -166,7 +177,7 @@ export function DocumentProvider({
|
|
|
166
177
|
// selected block, are not the selection's: only those on the page itself are.
|
|
167
178
|
if (e.target instanceof Element && e.target !== document.body && !root.current?.contains(e.target)) return;
|
|
168
179
|
if (e.target instanceof Element && e.target.closest("input, textarea, select, [contenteditable=true], [role=dialog], [role=menu]")) return;
|
|
169
|
-
const order =
|
|
180
|
+
const order = visible(tree.current);
|
|
170
181
|
const index = order.findIndex((n) => n.id === selected);
|
|
171
182
|
const node = order[index];
|
|
172
183
|
if (node === undefined) return setSelected(null);
|
|
@@ -246,10 +257,27 @@ export function DocumentProvider({
|
|
|
246
257
|
commit(insert(remove(tree.current, id), parentId, afterId, place.node));
|
|
247
258
|
schedule(CHANGE);
|
|
248
259
|
},
|
|
260
|
+
moveBy: (id, by) => {
|
|
261
|
+
const place = locate(tree.current, id);
|
|
262
|
+
if (!place) return;
|
|
263
|
+
const to = place.index + by;
|
|
264
|
+
if (to < 0 || to >= place.siblings.length) return;
|
|
265
|
+
// After the sibling two above (moving up) or the one below (moving down).
|
|
266
|
+
const afterId = by === -1 ? (place.siblings[to - 1]?.id ?? null) : place.siblings[to]!.id;
|
|
267
|
+
commit(insert(remove(tree.current, id), place.parent?.id ?? null, afterId, place.node));
|
|
268
|
+
schedule(CHANGE);
|
|
269
|
+
},
|
|
249
270
|
focus: (id, at = "end") => {
|
|
250
271
|
setSelected(null);
|
|
272
|
+
// A line inside a folded toggle is unfolded to, rather than focused unseen.
|
|
273
|
+
const inside = new Set<number>();
|
|
274
|
+
for (let p = locate(tree.current, id)?.parent; p; p = locate(tree.current, p.id)?.parent) inside.add(p.id);
|
|
275
|
+
if ([...inside].some((p) => shutRef.current.has(p))) setShut((s) => new Set([...s].filter((x) => !inside.has(x))));
|
|
251
276
|
setPendingFocus({ id, at });
|
|
252
277
|
},
|
|
278
|
+
folded: (id) => shut.has(id),
|
|
279
|
+
fold: (id, close) => setShut((s) => (close ? new Set([...s, id]) : new Set([...s].filter((x) => x !== id)))),
|
|
280
|
+
order: () => visible(tree.current),
|
|
253
281
|
selected,
|
|
254
282
|
select: setSelected,
|
|
255
283
|
drag: {
|
|
@@ -263,7 +291,7 @@ export function DocumentProvider({
|
|
|
263
291
|
},
|
|
264
292
|
},
|
|
265
293
|
}),
|
|
266
|
-
[schema, uploadImage, checkLink, onLink, imageExtras, blocks, revs, dragId, drop, commit, schedule, selected, fresh],
|
|
294
|
+
[schema, uploadImage, checkLink, onLink, imageExtras, blocks, revs, dragId, drop, commit, schedule, selected, fresh, shut],
|
|
267
295
|
);
|
|
268
296
|
|
|
269
297
|
return <Ctx.Provider value={editor}>{children}</Ctx.Provider>;
|