@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,248 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId, useState } from "react";
|
|
4
|
+
import { CommandMenu, commandOptionId } from "../ui/command-menu.js";
|
|
5
|
+
import { useEscapeFirst } from "../../hooks/use-escape-first.js";
|
|
6
|
+
import { caretOffset, caretOnEdgeLine, caretRect } from "../../lib/rich-text-dom.js";
|
|
7
|
+
import { EditableText } from "../ui/editable-text.js";
|
|
8
|
+
import { useEditor } from "./editor-state.js";
|
|
9
|
+
import { hasText, isListType } from "./kinds.js";
|
|
10
|
+
import { cut, normalize, plain, split } from "../../lib/rich-text.js";
|
|
11
|
+
import { locate } from "../../lib/tree.js";
|
|
12
|
+
import { stepActive } from "../ui/listbox.js";
|
|
13
|
+
import { matchShortcut } from "../../lib/keys.js";
|
|
14
|
+
/* The text of one block, with the keyboard behaviour that makes a column of
|
|
15
|
+
separate elements feel like one document: Enter splits, Backspace at the start
|
|
16
|
+
joins, Tab nests, arrows cross block edges, "/" opens the list of blocks.
|
|
17
|
+
Pictures, videos, cards and dividers above or below are selected by Backspace,
|
|
18
|
+
Delete and the arrows, as in Notion (see editor-state). */
|
|
19
|
+
export function BlockText({ block, placeholder, alwaysShowPlaceholder, className, }) {
|
|
20
|
+
const ed = useEditor();
|
|
21
|
+
const { schema } = ed;
|
|
22
|
+
const kind = (key) => schema.kind(key);
|
|
23
|
+
const [slash, setSlash] = useState(null);
|
|
24
|
+
const menuId = `slash-${useId()}`;
|
|
25
|
+
// Escape closes the "/" menu and nothing else: not a dialog the editor is in.
|
|
26
|
+
useEscapeFirst(slash !== null, (target) => target instanceof Element && target.getAttribute("data-text") === String(block.id), () => setSlash(null));
|
|
27
|
+
const matches = slash ? schema.kinds.filter((k) => k.label.toLowerCase().includes(slash.query.toLowerCase())) : [];
|
|
28
|
+
const place = locate(ed.blocks, block.id);
|
|
29
|
+
const parentId = place.parent?.id ?? null;
|
|
30
|
+
const setText = (text) => ed.edit(block.id, (b) => ({ ...b, text }), { rewrite: true });
|
|
31
|
+
// Makes this block a `to` block holding `text`, or, where that is impossible,
|
|
32
|
+
// keeps it and adds the new block below.
|
|
33
|
+
const turnInto = (to, text) => {
|
|
34
|
+
const made = to.make(text);
|
|
35
|
+
const empty = plain(text) === "" && block.children.length === 0;
|
|
36
|
+
if (!("text" in made)) {
|
|
37
|
+
setText(text);
|
|
38
|
+
// An extension that can take the caret (a table's first cell) gets it; the kit's own
|
|
39
|
+
// pictures, videos and cards keep it in their address field instead.
|
|
40
|
+
const id = ed.create(parentId, block.id, made, { focus: schema.extension(made.type)?.focus !== undefined });
|
|
41
|
+
if (empty)
|
|
42
|
+
ed.remove(block.id);
|
|
43
|
+
// A divider leaves the writing to go on below it.
|
|
44
|
+
if (made.type === "divider")
|
|
45
|
+
ed.create(parentId, id, { type: "paragraph", text: [] }, { focus: true });
|
|
46
|
+
}
|
|
47
|
+
else if (block.children.some((child) => !schema.holds(made.type, child.type))) {
|
|
48
|
+
setText(text);
|
|
49
|
+
ed.create(parentId, block.id, to.make([]), { focus: true });
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
ed.edit(block.id, (b) => ({ ...made, id: b.id, children: b.children }), { rewrite: true });
|
|
53
|
+
ed.focus(block.id, "end");
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const onChange = (text, el) => {
|
|
57
|
+
const typed = plain(text);
|
|
58
|
+
const shortcut = schema.shortcuts[typed];
|
|
59
|
+
if (shortcut && schema.kind(shortcut) && schema.kindOf(block)?.key !== shortcut)
|
|
60
|
+
return turnInto(kind(shortcut), []);
|
|
61
|
+
ed.edit(block.id, (b) => ({ ...b, text }), { typing: true });
|
|
62
|
+
const caret = caretOffset(el);
|
|
63
|
+
if (caret === null)
|
|
64
|
+
return setSlash(null);
|
|
65
|
+
if (slash) {
|
|
66
|
+
const query = typed.slice(slash.from + 1, caret);
|
|
67
|
+
setSlash(caret <= slash.from || typed[slash.from] !== "/" || /\s/.test(query) ? null : { ...slash, query, index: 0 });
|
|
68
|
+
}
|
|
69
|
+
else if (typed[caret - 1] === "/" && (caret === 1 || /\s/.test(typed[caret - 2] ?? ""))) {
|
|
70
|
+
const rect = caretRect();
|
|
71
|
+
if (rect)
|
|
72
|
+
setSlash({ from: caret - 1, query: "", index: 0, rect });
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const pick = (to) => {
|
|
76
|
+
if (!slash)
|
|
77
|
+
return;
|
|
78
|
+
const rest = cut(block.text, slash.from, slash.from + 1 + slash.query.length);
|
|
79
|
+
setSlash(null);
|
|
80
|
+
if (plain(rest) === "")
|
|
81
|
+
turnInto(to, []);
|
|
82
|
+
else {
|
|
83
|
+
setText(rest);
|
|
84
|
+
ed.create(parentId, block.id, to.make([]), { focus: true });
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
function outdent(caret) {
|
|
88
|
+
if (!place.parent)
|
|
89
|
+
return;
|
|
90
|
+
const grand = locate(ed.blocks, place.parent.id).parent;
|
|
91
|
+
ed.move(block.id, grand?.id ?? null, place.parent.id);
|
|
92
|
+
ed.focus(block.id, caret);
|
|
93
|
+
}
|
|
94
|
+
const onKeyDown = (e) => {
|
|
95
|
+
// The Enter (or arrow) that finishes composing Japanese, Chinese or Korean
|
|
96
|
+
// belongs to the input method, not to the editor.
|
|
97
|
+
if (e.nativeEvent.isComposing || e.keyCode === 229)
|
|
98
|
+
return;
|
|
99
|
+
if (slash && matches.length > 0) {
|
|
100
|
+
const next = e.key === "ArrowDown" || e.key === "ArrowUp" ? stepActive(slash.index, matches.length, e.key) : null;
|
|
101
|
+
if (next !== null) {
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
setSlash({ ...slash, index: next });
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (e.key === "Enter") {
|
|
107
|
+
e.preventDefault();
|
|
108
|
+
pick(matches[slash.index]);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Escape, with no menu open, leaves the text and selects its block, as
|
|
113
|
+
// Notion's does: from there Tab moves on, so the keyboard is never held.
|
|
114
|
+
if (e.key === "Escape") {
|
|
115
|
+
e.preventDefault();
|
|
116
|
+
ed.select(block.id);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// ⌘⇧↑ / ⌘⇧↓ move the block among its siblings, as Notion's do; the caret stays in it.
|
|
120
|
+
if (matchShortcut(e, "mod+shift+up") || matchShortcut(e, "mod+shift+down")) {
|
|
121
|
+
e.preventDefault();
|
|
122
|
+
const at = caretOffset(e.currentTarget) ?? "end";
|
|
123
|
+
ed.moveBy(block.id, e.key === "ArrowUp" ? -1 : 1);
|
|
124
|
+
ed.focus(block.id, at);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const caret = caretOffset(e.currentTarget);
|
|
128
|
+
const length = plain(block.text).length;
|
|
129
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
if (caret === null)
|
|
132
|
+
return;
|
|
133
|
+
// Enter on an empty list item, heading or quote backs out of it, one level at a time.
|
|
134
|
+
if (length === 0 && block.type !== "paragraph" && block.children.length === 0) {
|
|
135
|
+
if (place.parent)
|
|
136
|
+
outdent(0);
|
|
137
|
+
else
|
|
138
|
+
turnInto(kind("text"), []);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
// An empty last line inside a toggle steps back out of it, as Notion's do.
|
|
142
|
+
if (length === 0 && block.type === "paragraph" && place.parent !== null && schema.toggle(place.parent.type) && place.index === place.siblings.length - 1) {
|
|
143
|
+
outdent(0);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const [before, after] = split(block.text, caret);
|
|
147
|
+
const next = block.type === "check"
|
|
148
|
+
? { type: "check", checked: false, text: after }
|
|
149
|
+
: isListType(block.type)
|
|
150
|
+
? { type: block.type, text: after }
|
|
151
|
+
: { type: "paragraph", text: after };
|
|
152
|
+
setText(before);
|
|
153
|
+
// A toggle's own line names it; what Enter starts goes inside it (unfolded, to be seen).
|
|
154
|
+
if (schema.toggle(block.type)) {
|
|
155
|
+
ed.fold(block.id, false);
|
|
156
|
+
ed.create(block.id, null, next, { focus: true });
|
|
157
|
+
}
|
|
158
|
+
// With children, the new item goes first among them, where the caret appears to be.
|
|
159
|
+
else if (block.children.length > 0)
|
|
160
|
+
ed.create(block.id, null, next, { focus: true });
|
|
161
|
+
else
|
|
162
|
+
ed.create(parentId, block.id, next, { focus: true });
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (e.key === "Backspace" && caret === 0 && window.getSelection()?.isCollapsed) {
|
|
166
|
+
if (block.type !== "paragraph") {
|
|
167
|
+
e.preventDefault();
|
|
168
|
+
if (block.children.length === 0)
|
|
169
|
+
turnInto(kind("text"), block.text);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const order = ed.order();
|
|
173
|
+
const prev = order[order.findIndex((b) => b.id === block.id) - 1];
|
|
174
|
+
if (!prev)
|
|
175
|
+
return;
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
if (!hasText(prev)) {
|
|
178
|
+
// As in Notion: an empty line goes, and the picture or card above is
|
|
179
|
+
// selected; a second Backspace removes that. A line with words keeps them.
|
|
180
|
+
if (length === 0)
|
|
181
|
+
ed.remove(block.id);
|
|
182
|
+
ed.select(prev.id);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const joinAt = plain(prev.text).length;
|
|
186
|
+
ed.edit(prev.id, (b) => ({ ...b, text: normalize([...prev.text, ...block.text]) }), { rewrite: true });
|
|
187
|
+
ed.remove(block.id);
|
|
188
|
+
ed.focus(prev.id, joinAt);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
// Tab nests and Shift+Tab un-nests. Where neither can, Tab is left to move
|
|
192
|
+
// focus on, so it never traps the keyboard.
|
|
193
|
+
if (e.key === "Tab" && !e.altKey && !e.metaKey && !e.ctrlKey) {
|
|
194
|
+
if (e.shiftKey) {
|
|
195
|
+
if (!place.parent)
|
|
196
|
+
return;
|
|
197
|
+
e.preventDefault();
|
|
198
|
+
outdent(caret ?? "end");
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
const above = place.siblings[place.index - 1];
|
|
202
|
+
if (!above || !schema.holds(above.type, block.type))
|
|
203
|
+
return;
|
|
204
|
+
e.preventDefault();
|
|
205
|
+
ed.move(block.id, above.id, above.children.at(-1)?.id ?? null);
|
|
206
|
+
ed.focus(block.id, caret ?? "end");
|
|
207
|
+
}
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
// Delete at the end of a line takes in what follows: the next line's words,
|
|
211
|
+
// or, when a picture or card is next, selects it to be deleted.
|
|
212
|
+
if (e.key === "Delete" && caret === length && window.getSelection()?.isCollapsed) {
|
|
213
|
+
const order = ed.order();
|
|
214
|
+
const next = order[order.findIndex((b) => b.id === block.id) + 1];
|
|
215
|
+
if (next === undefined || block.children.length > 0)
|
|
216
|
+
return;
|
|
217
|
+
e.preventDefault();
|
|
218
|
+
if (!hasText(next))
|
|
219
|
+
return ed.select(next.id);
|
|
220
|
+
if (next.children.length > 0)
|
|
221
|
+
return;
|
|
222
|
+
ed.edit(block.id, (b) => ({ ...b, text: normalize([...block.text, ...next.text]) }), { rewrite: true });
|
|
223
|
+
ed.remove(next.id);
|
|
224
|
+
ed.focus(block.id, length);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
// The arrows move through every block, landing on pictures and cards too. They
|
|
228
|
+
// leave from anywhere on a block's first or last line, not only its very ends.
|
|
229
|
+
if ((e.key === "ArrowUp" && (caret === 0 || caretOnEdgeLine(e.currentTarget, "first"))) ||
|
|
230
|
+
(e.key === "ArrowDown" && (caret === length || caretOnEdgeLine(e.currentTarget, "last")))) {
|
|
231
|
+
const order = ed.order();
|
|
232
|
+
const to = order[order.findIndex((b) => b.id === block.id) + (e.key === "ArrowUp" ? -1 : 1)];
|
|
233
|
+
if (!to)
|
|
234
|
+
return;
|
|
235
|
+
e.preventDefault();
|
|
236
|
+
if (hasText(to))
|
|
237
|
+
ed.focus(to.id, e.key === "ArrowUp" ? "end" : 0);
|
|
238
|
+
else
|
|
239
|
+
ed.select(to.id);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
return (_jsxs(_Fragment, { children: [_jsx(EditableText, { id: String(block.id), text: block.text, rev: ed.rev(block.id), onChange: onChange, onKeyDown: onKeyDown, onLink: ed.onLink, placeholder: placeholder, alwaysShowPlaceholder: alwaysShowPlaceholder, className: className,
|
|
243
|
+
// The menu closes when the caret leaves; a click in it keeps the caret.
|
|
244
|
+
onBlur: () => setSlash(null), aria: slash && matches.length > 0
|
|
245
|
+
? { "aria-controls": menuId, "aria-expanded": true, "aria-haspopup": "listbox", "aria-activedescendant": commandOptionId(menuId, slash.index) }
|
|
246
|
+
: undefined }), slash && matches.length > 0 && (_jsx(CommandMenu, { id: menuId, title: "Blocks", rect: slash.rect, commands: matches, index: slash.index, onPick: (c) => pick(c) }))] }));
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=block-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block-text.js","sourceRoot":"","sources":["../../../src/components/editor/block-text.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAsB,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,uBAAwB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAyB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAoB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAwD,MAAM,YAAY,CAAC;AACvG,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAA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AC;IACL,CAAC,CAAC;IAEF,OAAO,CACH,8BACI,KAAC,YAAY,IACT,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EACpB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EACrB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,EAAE,CAAC,MAAM,EACjB,WAAW,EAAE,WAAW,EACxB,qBAAqB,EAAE,qBAAqB,EAC5C,SAAS,EAAE,SAAS;gBACpB,wEAAwE;gBACxE,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAC5B,IAAI,EACA,KAAK,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;oBACvB,CAAC,CAAC,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,uBAAuB,EAAE,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE;oBAC/I,CAAC,CAAC,SAAS,GAErB,EACD,KAAK,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAC5B,KAAC,WAAW,IAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAC,QAAQ,EAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAc,CAAC,GAAI,CAC3I,IACF,CACN,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { Text } from "../../lib/rich-text.js";
|
|
3
|
+
import { type BuiltinNode, type Node } from "./kinds.js";
|
|
4
|
+
type Of<T extends BuiltinNode["type"]> = Extract<BuiltinNode, {
|
|
5
|
+
type: T;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function BlockRow({ block, className, children, open, menu }: {
|
|
8
|
+
block: Node;
|
|
9
|
+
className?: string;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
open?: () => void;
|
|
12
|
+
menu?: ReactNode;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
14
|
+
export declare function BlockList({ blocks, depth }: {
|
|
15
|
+
blocks: Node[];
|
|
16
|
+
depth?: number;
|
|
17
|
+
}): (import("react").JSX.Element | null)[];
|
|
18
|
+
/** A caption under a picture or a video: rich text of its own, saved with the block. Enter goes on below. */
|
|
19
|
+
export declare function Caption({ block, text }: {
|
|
20
|
+
block: Node;
|
|
21
|
+
text: Text;
|
|
22
|
+
}): import("react").JSX.Element;
|
|
23
|
+
/**
|
|
24
|
+
* ImageBlock in a document. A file is handed to the owner's `uploadImage`, which
|
|
25
|
+
* says where it can be loaded from; without one, only links are taken. Once it
|
|
26
|
+
* has a picture the block is selected, so Enter goes on writing below it. A click
|
|
27
|
+
* selects it; opening it larger is in its menu.
|
|
28
|
+
*/
|
|
29
|
+
export declare function PictureBlock({ block }: {
|
|
30
|
+
block: Of<"image">;
|
|
31
|
+
}): import("react").JSX.Element;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=blocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../../src/components/editor/blocks.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAYnD,OAAO,EAAuB,KAAK,WAAW,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAG9E,KAAK,EAAE,CAAC,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,WAAW,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC;AAa3E,wBAAgB,QAAQ,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,CAAA;CAAE,+BAuFjK;AAgBD,wBAAgB,SAAS,CAAC,EAAE,MAAM,EAAE,KAAS,EAAE,EAAE;IAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,0CAUlF;AAqGD,6GAA6G;AAC7G,wBAAgB,OAAO,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,+BAmBnE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,CAAA;CAAE,+BA2D7D"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Maximize2, Trash2 } from "lucide-react";
|
|
5
|
+
import { cn } from "../../lib/utils.js";
|
|
6
|
+
import { Checkbox } from "../ui/checkbox.js";
|
|
7
|
+
import { DropdownMenuCheckboxItem, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator } from "../ui/dropdown-menu.js";
|
|
8
|
+
import { EditableText } from "../ui/editable-text.js";
|
|
9
|
+
import { HandleRow } from "../ui/handle-row.js";
|
|
10
|
+
import { ImageBlock } from "../ui/image-block.js";
|
|
11
|
+
import { LinkBlock } from "../ui/link-block.js";
|
|
12
|
+
import { VideoBlock } from "../ui/video-block.js";
|
|
13
|
+
import { locate } from "../../lib/tree.js";
|
|
14
|
+
import { BlockText } from "./block-text.js";
|
|
15
|
+
import { useEditor } from "./editor-state.js";
|
|
16
|
+
import { hasText, isListType } from "./kinds.js";
|
|
17
|
+
import { BulletMark, HEADINGS, MARK_GUTTER, QUOTE } from "./look.js";
|
|
18
|
+
/** What a press on a selectable block leaves to the control it landed on. An extension marks
|
|
19
|
+
any other area that handles its own presses (rows that open a dialog) with `data-own-press`. */
|
|
20
|
+
const OWN_CLICK = "input, textarea, a, iframe, button:not(:disabled), [contenteditable=true], [role=slider], [data-own-press]";
|
|
21
|
+
/* One block's own line, with Notion's margin controls from HandleRow: "+" adds a
|
|
22
|
+
block below, and the grip drags it and, on a click, opens its menu. Blocks
|
|
23
|
+
without words — pictures, videos, cards, dividers — are picked as a whole by a
|
|
24
|
+
click and show it with an outline; see editor-state for what keys then do.
|
|
25
|
+
A list item's children sit outside the row, so hovering a child never lights
|
|
26
|
+
up its parent's controls. `menu` adds an extension's own entries
|
|
27
|
+
(DropdownMenuItem elements) to the grip's menu, above Delete. */
|
|
28
|
+
export function BlockRow({ block, className, children, open, menu }) {
|
|
29
|
+
const ed = useEditor();
|
|
30
|
+
const place = locate(ed.blocks, block.id);
|
|
31
|
+
const parentId = place.parent?.id ?? null;
|
|
32
|
+
const { drag } = ed;
|
|
33
|
+
const current = ed.schema.kindOf(block);
|
|
34
|
+
const selectable = !hasText(block);
|
|
35
|
+
const selected = ed.selected === block.id;
|
|
36
|
+
return (_jsx(HandleRow, { className: className, onAdd: () => ed.create(parentId, block.id, { type: "paragraph", text: [] }, { focus: true }), selected: selected, onMove: {
|
|
37
|
+
up: place.index > 0 ? () => ed.moveBy(block.id, -1) : null,
|
|
38
|
+
down: place.index < place.siblings.length - 1 ? () => ed.moveBy(block.id, 1) : null,
|
|
39
|
+
}, dragging: drag.id !== null, onDragStart: () => drag.start(block.id), onDragEnd: drag.end, onDragOverSide: (side) => (drag.drop?.id !== block.id || drag.drop.side !== side) && drag.over({ id: block.id, side }), onDrop: () => {
|
|
40
|
+
if (drag.id !== null && drag.drop) {
|
|
41
|
+
const target = locate(ed.blocks, drag.drop.id);
|
|
42
|
+
const afterId = drag.drop.side === "after" ? target.node.id : (target.siblings[target.index - 1]?.id ?? null);
|
|
43
|
+
ed.move(drag.id, target.parent?.id ?? null, afterId);
|
|
44
|
+
}
|
|
45
|
+
drag.end();
|
|
46
|
+
}, drop: drag.drop?.id === block.id && drag.id !== block.id ? drag.drop.side : null, menu: _jsxs(_Fragment, { children: [hasText(block) && (_jsxs(_Fragment, { children: [_jsx(DropdownMenuLabel, { children: "Turn into" }), ed.schema.textKinds.map((k) => (_jsx(DropdownMenuCheckboxItem, { checked: k.key === current?.key,
|
|
47
|
+
// A block with children can only become something that can hold them.
|
|
48
|
+
disabled: block.children.some((child) => !ed.schema.holds(k.make([]).type, child.type)), onSelect: () => ed.edit(block.id, (b) => ({ ...k.make(hasText(b) ? b.text : []), id: b.id, children: b.children }), { rewrite: true }), children: k.label }, k.key))), _jsx(DropdownMenuSeparator, {})] })), open !== undefined && (_jsxs(DropdownMenuItem, { onSelect: open, children: [_jsx(Maximize2, {}), "Open picture"] })), menu !== undefined && (_jsxs(_Fragment, { children: [menu, _jsx(DropdownMenuSeparator, {})] })), _jsxs(DropdownMenuItem, { danger: true, onSelect: () => ed.remove(block.id), children: [_jsx(Trash2, {}), "Delete"] })] }), children: selectable ? (_jsx("div", { "data-block": block.id, "data-selected": selected || undefined, onPointerDown: (e) => {
|
|
49
|
+
if (!e.target.closest(OWN_CLICK))
|
|
50
|
+
ed.select(block.id);
|
|
51
|
+
}, className: cn("rounded-surface transition-shadow duration-(--duration-fast)", selected && "shadow-[0_0_0_2px_var(--accent),0_0_0_5px_var(--accent-tint)]"), children: children })) : (children) }));
|
|
52
|
+
}
|
|
53
|
+
const isList = (b) => isListType(b.type);
|
|
54
|
+
/** Consecutive list items of one kind form one list, so numbering restarts where a run is interrupted. */
|
|
55
|
+
function runs(blocks) {
|
|
56
|
+
const out = [];
|
|
57
|
+
for (const block of blocks) {
|
|
58
|
+
const last = out.at(-1);
|
|
59
|
+
if (isList(block) && Array.isArray(last) && last[0].type === block.type)
|
|
60
|
+
last.push(block);
|
|
61
|
+
else
|
|
62
|
+
out.push(isList(block) ? [block] : block);
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
export function BlockList({ blocks, depth = 0 }) {
|
|
67
|
+
const ed = useEditor();
|
|
68
|
+
// A page that is one empty paragraph still says what it is for, focused or not.
|
|
69
|
+
const alone = depth === 0 && blocks.length === 1;
|
|
70
|
+
return runs(blocks).map((entry) => {
|
|
71
|
+
// An app's own block draws itself.
|
|
72
|
+
const extension = Array.isArray(entry) ? undefined : ed.schema.extension(entry.type);
|
|
73
|
+
if (extension !== undefined && !Array.isArray(entry))
|
|
74
|
+
return _jsx(extension.Edit, { block: entry, depth: depth }, entry.id);
|
|
75
|
+
return builtin(entry, depth, alone);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/** The kit's own kinds, drawn. */
|
|
79
|
+
function builtin(entry, depth, alone) {
|
|
80
|
+
if (Array.isArray(entry)) {
|
|
81
|
+
const List = entry[0].type === "numbered" ? "ol" : "ul";
|
|
82
|
+
return (_jsx(List, { children: entry.map((block, index) => (_jsx(ListItem, { block: block, depth: depth, index: index }, block.id))) }, entry[0].id));
|
|
83
|
+
}
|
|
84
|
+
switch (entry.type) {
|
|
85
|
+
case "paragraph":
|
|
86
|
+
return (_jsx(BlockRow, { block: entry, className: "my-px", children: _jsx(BlockText, { block: entry, placeholder: "Write, or type '/' for pictures, video and more", alwaysShowPlaceholder: alone, className: "min-h-[1.5em] px-0.5 py-[3px]" }) }, entry.id));
|
|
87
|
+
case "heading":
|
|
88
|
+
return _jsx(Heading, { block: entry }, entry.id);
|
|
89
|
+
case "quote":
|
|
90
|
+
return (_jsx(BlockRow, { block: entry, className: "my-1", children: _jsx(BlockText, { block: entry, placeholder: "Quote", alwaysShowPlaceholder: true, className: cn(QUOTE, "py-[3px]") }) }, entry.id));
|
|
91
|
+
case "divider":
|
|
92
|
+
return (_jsx(BlockRow, { block: entry, children: _jsx("div", { className: "cursor-pointer py-2.5", children: _jsx("hr", { className: "border-hairline-strong" }) }) }, entry.id));
|
|
93
|
+
case "image":
|
|
94
|
+
return _jsx(PictureBlock, { block: entry }, entry.id);
|
|
95
|
+
case "video":
|
|
96
|
+
return _jsx(VideoEmbed, { block: entry }, entry.id);
|
|
97
|
+
case "bookmark":
|
|
98
|
+
return _jsx(Bookmark, { block: entry }, entry.id);
|
|
99
|
+
default:
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function Heading({ block }) {
|
|
104
|
+
return (_jsx(BlockRow, { block: block, className: cn("first:mt-0", HEADINGS[block.level]), children: _jsx("div", { role: "heading", "aria-level": block.level + 1, className: "text-accent-text", children: _jsx(BlockText, { block: block, placeholder: `Heading ${block.level}`, alwaysShowPlaceholder: true, className: "px-0.5 py-[3px]" }) }) }));
|
|
105
|
+
}
|
|
106
|
+
function ListItem({ block, depth, index }) {
|
|
107
|
+
const ed = useEditor();
|
|
108
|
+
const marker = block.type === "check" ? (_jsx(Checkbox, { checked: block.checked, onCheckedChange: (checked) => ed.edit(block.id, (b) => (b.type === "check" ? { ...b, checked: checked === true } : b)) })) : block.type === "numbered" ? (_jsxs("span", { className: "tabular-nums", children: [index + 1, "."] })) : (_jsx(BulletMark, { depth: depth }));
|
|
109
|
+
const done = block.type === "check" && block.checked;
|
|
110
|
+
return (_jsxs("li", { className: "my-px", children: [_jsx(BlockRow, { block: block, children: _jsxs("div", { className: "flex items-start px-0.5 py-[3px]", children: [_jsx("span", { contentEditable: false, className: MARK_GUTTER, children: marker }), _jsx(BlockText, { block: block, placeholder: block.type === "check" ? "To-do" : "List", alwaysShowPlaceholder: true, className: cn("flex-1", done && "text-ink-secondary line-through decoration-ink-tertiary") })] }) }), block.children.length > 0 && (_jsx("div", { className: "pl-6", children: _jsx(BlockList, { blocks: block.children, depth: depth + 1 }) }))] }));
|
|
111
|
+
}
|
|
112
|
+
/** A caption under a picture or a video: rich text of its own, saved with the block. Enter goes on below. */
|
|
113
|
+
export function Caption({ block, text }) {
|
|
114
|
+
const ed = useEditor();
|
|
115
|
+
return (_jsx(EditableText, { text: text, rev: ed.rev(block.id), placeholder: "Add a caption", onLink: ed.onLink, className: "px-0.5 text-center", onChange: (caption) => ed.edit(block.id, (b) => ({ ...b, caption }), { typing: true }), onKeyDown: (e) => {
|
|
116
|
+
if (e.key === "Enter" && !e.nativeEvent.isComposing && e.keyCode !== 229) {
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
const place = locate(ed.blocks, block.id);
|
|
119
|
+
ed.create(place.parent?.id ?? null, block.id, { type: "paragraph", text: [] }, { focus: true });
|
|
120
|
+
}
|
|
121
|
+
} }));
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* ImageBlock in a document. A file is handed to the owner's `uploadImage`, which
|
|
125
|
+
* says where it can be loaded from; without one, only links are taken. Once it
|
|
126
|
+
* has a picture the block is selected, so Enter goes on writing below it. A click
|
|
127
|
+
* selects it; opening it larger is in its menu.
|
|
128
|
+
*/
|
|
129
|
+
export function PictureBlock({ block }) {
|
|
130
|
+
const ed = useEditor();
|
|
131
|
+
const [busy, setBusy] = useState(false);
|
|
132
|
+
const [error, setError] = useState();
|
|
133
|
+
const set = (patch) => ed.edit(block.id, (b) => ({ ...b, ...patch }));
|
|
134
|
+
const upload = ed.uploadImage;
|
|
135
|
+
const onFile = async (file) => {
|
|
136
|
+
if (!upload)
|
|
137
|
+
return;
|
|
138
|
+
setError(undefined);
|
|
139
|
+
setBusy(0);
|
|
140
|
+
// Where focus was when the upload began: if the user has gone on to type or
|
|
141
|
+
// search elsewhere by the time it lands, the picture does not take focus back.
|
|
142
|
+
const before = document.activeElement;
|
|
143
|
+
try {
|
|
144
|
+
const image = await upload(file, setBusy);
|
|
145
|
+
set({ src: image.src, ref: image.ref, aspect: image.aspect });
|
|
146
|
+
const now = document.activeElement;
|
|
147
|
+
if (now === before || now === null || now === document.body)
|
|
148
|
+
ed.select(block.id);
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
152
|
+
}
|
|
153
|
+
finally {
|
|
154
|
+
setBusy(false);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
// Which addresses are fine to show is the owner's rule; the kit takes what it is given.
|
|
158
|
+
const src = block.src;
|
|
159
|
+
// A picture an app's extra supplies is selected like one uploaded, so Enter writes below it.
|
|
160
|
+
const extras = ed.imageExtras?.(block, (patch) => {
|
|
161
|
+
set(patch);
|
|
162
|
+
if (patch.src !== undefined)
|
|
163
|
+
ed.select(block.id);
|
|
164
|
+
}) ?? {};
|
|
165
|
+
return (_jsx(BlockRow, { block: block, className: "my-2", open: src === undefined ? undefined : () => window.open(src, "_blank", "noreferrer"), children: _jsx(ImageBlock, { src: src, aspect: block.aspect, width: block.width, onWidthChange: (width) => set({ width }), onFile: upload ? (file) => void onFile(file) : undefined, onLink: (url) => {
|
|
166
|
+
const refused = ed.checkLink?.(url, "image") ?? null;
|
|
167
|
+
if (refused !== null)
|
|
168
|
+
return setError(refused);
|
|
169
|
+
setError(undefined);
|
|
170
|
+
set({ src: url, ref: undefined, aspect: undefined });
|
|
171
|
+
ed.select(block.id);
|
|
172
|
+
}, busy: busy === false ? false : busy, error: error, more: extras.more, actions: extras.actions, placeholder: extras.placeholder, caption: src === undefined ? undefined : _jsx(Caption, { block: block, text: block.caption }) }) }));
|
|
173
|
+
}
|
|
174
|
+
function VideoEmbed({ block }) {
|
|
175
|
+
const ed = useEditor();
|
|
176
|
+
return (_jsx(BlockRow, { block: block, className: "my-2", children: _jsx(VideoBlock, { url: block.url, check: ed.checkLink === undefined ? undefined : (url) => ed.checkLink(url, "video"), onLink: (url) => {
|
|
177
|
+
ed.edit(block.id, (b) => ({ ...b, url }));
|
|
178
|
+
ed.select(block.id);
|
|
179
|
+
}, caption: _jsx(Caption, { block: block, text: block.caption }) }) }));
|
|
180
|
+
}
|
|
181
|
+
function Bookmark({ block }) {
|
|
182
|
+
const ed = useEditor();
|
|
183
|
+
return (_jsx(BlockRow, { block: block, className: "my-2", children: _jsx(LinkBlock, { url: block.url, title: block.title, check: ed.checkLink === undefined ? undefined : (url) => ed.checkLink(url, "bookmark"), onTitleChange: (title) => ed.edit(block.id, (b) => ({ ...b, title }), { typing: true }), onTitleEnter: () => {
|
|
184
|
+
const place = locate(ed.blocks, block.id);
|
|
185
|
+
ed.create(place.parent?.id ?? null, block.id, { type: "paragraph", text: [] }, { focus: true });
|
|
186
|
+
}, onLink: (url) => {
|
|
187
|
+
ed.edit(block.id, (b) => ({ ...b, url }));
|
|
188
|
+
ed.select(block.id);
|
|
189
|
+
} }) }));
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=blocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../../src/components/editor/blocks.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAoB,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,wBAAyB,CAAC;AAC/H,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAyB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAsB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAuB,CAA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AAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAS,CAAC,CAAC;gBAClD,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACxB,CAAC,GACH,GACK,CACd,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AnyBlock } from "../../lib/document.js";
|
|
2
|
+
import { type Ref } from "react";
|
|
3
|
+
import { type CheckLink, type ImageExtras, type OnLink, type ProviderProps, type UploadImage } from "./editor-state.js";
|
|
4
|
+
/**
|
|
5
|
+
* A Notion-style page of blocks, edited in place: text, headings, lists, to-dos,
|
|
6
|
+
* quotes, dividers, pictures, video and link cards. Enter splits, Backspace at the
|
|
7
|
+
* start joins, Tab nests, "/" opens the list of blocks, and blocks without words
|
|
8
|
+
* are selected and removed like Notion's. It holds the document while it is
|
|
9
|
+
* edited and reports every change; storing it is the owner's.
|
|
10
|
+
*
|
|
11
|
+
* Remount it (with a `key`) to replace the document from outside, for example
|
|
12
|
+
* with a newer version saved elsewhere.
|
|
13
|
+
*/
|
|
14
|
+
/** What an owner can do to an editor from outside it: `ref={handle}`. */
|
|
15
|
+
export type DocumentEditorHandle = {
|
|
16
|
+
/** Puts the caret in a block, the first when no id is given (from a title, on Enter). */
|
|
17
|
+
focus: (id?: number, at?: number | "end") => void;
|
|
18
|
+
/** The document as it stands, in its stored shape. */
|
|
19
|
+
blocks: () => AnyBlock[];
|
|
20
|
+
};
|
|
21
|
+
export declare function DocumentEditor({ initial, onChange, uploadImage, checkLink, onLink, imageExtras, extensions, kinds, newId, ref, placeholder, className, }: ProviderProps & {
|
|
22
|
+
ref?: Ref<DocumentEditorHandle>;
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
className?: string;
|
|
25
|
+
}): import("react").JSX.Element;
|
|
26
|
+
export type { CheckLink, ImageExtras, OnLink, UploadImage };
|
|
27
|
+
//# sourceMappingURL=document-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-editor.d.ts","sourceRoot":"","sources":["../../../src/components/editor/document-editor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGtD,OAAO,EAA+B,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,EAA+B,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAMtJ;;;;;;;;;GASG;AACH,yEAAyE;AACzE,MAAM,MAAM,oBAAoB,GAAG;IAC/B,yFAAyF;IACzF,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,KAAK,KAAK,IAAI,CAAC;IAClD,sDAAsD;IACtD,MAAM,EAAE,MAAM,QAAQ,EAAE,CAAC;CAC5B,CAAC;AAEF,wBAAgB,cAAc,CAAC,EAC3B,OAAO,EACP,QAAQ,EACR,WAAW,EACX,SAAS,EACT,MAAM,EACN,WAAW,EACX,UAAU,EACV,KAAK,EACL,KAAK,EACL,GAAG,EACH,WAA0E,EAC1E,SAAS,GACZ,EAAE,aAAa,GAAG;IACf,GAAG,CAAC,EAAE,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,+BAgBA;AA0CD,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { plain } from "../../lib/rich-text.js";
|
|
4
|
+
import { BlockList } from "./blocks.js";
|
|
5
|
+
import { useImperativeHandle, useRef } from "react";
|
|
6
|
+
import { DocumentProvider, useEditor } from "./editor-state.js";
|
|
7
|
+
import { hasText, toBlocks } from "./kinds.js";
|
|
8
|
+
import { DragRows } from "../ui/handle-row.js";
|
|
9
|
+
import { withKitBlocks } from "./extensions/kit-blocks.js";
|
|
10
|
+
export function DocumentEditor({ initial, onChange, uploadImage, checkLink, onLink, imageExtras, extensions, kinds, newId, ref, placeholder = "Write, or type “/” for headings, pictures, video and links", className, }) {
|
|
11
|
+
return (_jsx(DocumentProvider, { initial: initial, onChange: onChange, uploadImage: uploadImage, checkLink: checkLink, onLink: onLink, imageExtras: imageExtras, extensions: withKitBlocks(extensions), kinds: kinds, newId: newId, children: _jsx(Body, { placeholder: placeholder, className: className, handle: ref }) }));
|
|
12
|
+
}
|
|
13
|
+
function Body({ placeholder, className, handle }) {
|
|
14
|
+
const ed = useEditor();
|
|
15
|
+
const latest = useRef(ed);
|
|
16
|
+
latest.current = ed;
|
|
17
|
+
useImperativeHandle(handle, () => ({
|
|
18
|
+
focus: (id, at = 0) => {
|
|
19
|
+
const target = id ?? latest.current.blocks[0]?.id;
|
|
20
|
+
if (target !== undefined)
|
|
21
|
+
latest.current.focus(target, at);
|
|
22
|
+
else
|
|
23
|
+
latest.current.create(null, null, { type: "paragraph", text: [] }, { focus: true });
|
|
24
|
+
},
|
|
25
|
+
blocks: () => toBlocks(latest.current.blocks, latest.current.schema),
|
|
26
|
+
}), []);
|
|
27
|
+
// Clicking the empty space under the last block continues the page, as in Notion.
|
|
28
|
+
const continuePage = () => {
|
|
29
|
+
const last = ed.blocks.at(-1);
|
|
30
|
+
if (last?.type === "paragraph" && hasText(last) && plain(last.text) === "")
|
|
31
|
+
ed.focus(last.id);
|
|
32
|
+
else
|
|
33
|
+
ed.create(null, last?.id ?? null, { type: "paragraph", text: [] }, { focus: true });
|
|
34
|
+
};
|
|
35
|
+
return (
|
|
36
|
+
// Room on the left for the margin controls, which hang outside each block.
|
|
37
|
+
// The gutter is the margin controls' (HandleRow, 46px) and is always 3rem. A page may pull the
|
|
38
|
+
// editor left to line its text up with a title, but by no more than its own padding, or the
|
|
39
|
+
// controls land on whatever is beside the page. Phones have neither gutter nor controls.
|
|
40
|
+
_jsxs("div", { ref: ed.root, className: `relative flex min-h-24 flex-col pl-12 max-sm:pl-0 ${className ?? ""}`, children: [_jsx(DragRows, { children: _jsx(BlockList, { blocks: ed.blocks }) }), _jsx("button", { type: "button", "aria-label": "Continue writing", className: "flex min-h-16 w-full flex-1 cursor-text items-start", onClick: continuePage, children: ed.blocks.length === 0 && _jsx("span", { className: "mt-px px-0.5 py-[3px] text-left text-ink-tertiary", children: placeholder }) })] }));
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=document-editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-editor.js","sourceRoot":"","sources":["../../../src/components/editor/document-editor.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAc,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAY,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAuF,MAAM,mBAAoB,CAAC;AACtJ,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAsB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA6B,CAAC;AAqB5D,MAAM,UAAU,cAAc,CAAC,EAC3B,OAAO,EACP,QAAQ,EACR,WAAW,EACX,SAAS,EACT,MAAM,EACN,WAAW,EACX,UAAU,EACV,KAAK,EACL,KAAK,EACL,GAAG,EACH,WAAW,GAAG,4DAA4D,EAC1E,SAAS,GAKZ;IACG,OAAO,CACH,KAAC,gBAAgB,IACb,OAAO,EAAE,OAAO,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