@kujoforall/paper-ui 0.0.0-stage → 0.1.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 +5 -0
- package/LICENSE +21 -0
- package/README.md +252 -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 +213 -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 +187 -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 +40 -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 +105 -0
- package/dist/components/editor/document-view.js.map +1 -0
- package/dist/components/editor/editor-state.d.ts +100 -0
- package/dist/components/editor/editor-state.d.ts.map +1 -0
- package/dist/components/editor/editor-state.js +192 -0
- package/dist/components/editor/editor-state.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 +9 -0
- package/dist/components/editor/index.d.ts.map +1 -0
- package/dist/components/editor/index.js +9 -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/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/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/app-shell.d.ts +25 -0
- package/dist/components/ui/app-shell.d.ts.map +1 -0
- package/dist/components/ui/app-shell.js +69 -0
- package/dist/components/ui/app-shell.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/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 +13 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +45 -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 +64 -0
- package/dist/components/ui/calendar.js.map +1 -0
- package/dist/components/ui/callout.d.ts +13 -0
- package/dist/components/ui/callout.d.ts.map +1 -0
- package/dist/components/ui/callout.js +27 -0
- package/dist/components/ui/callout.js.map +1 -0
- package/dist/components/ui/card.d.ts +13 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/card.js +27 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/checkbox.d.ts +6 -0
- package/dist/components/ui/checkbox.d.ts.map +1 -0
- package/dist/components/ui/checkbox.js +10 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/command-menu.d.ts +15 -0
- package/dist/components/ui/command-menu.d.ts.map +1 -0
- package/dist/components/ui/command-menu.js +24 -0
- package/dist/components/ui/command-menu.js.map +1 -0
- package/dist/components/ui/date-picker.d.ts +35 -0
- package/dist/components/ui/date-picker.d.ts.map +1 -0
- package/dist/components/ui/date-picker.js +56 -0
- package/dist/components/ui/date-picker.js.map +1 -0
- package/dist/components/ui/date-time-picker.d.ts +19 -0
- package/dist/components/ui/date-time-picker.d.ts.map +1 -0
- package/dist/components/ui/date-time-picker.js +32 -0
- package/dist/components/ui/date-time-picker.js.map +1 -0
- package/dist/components/ui/dialog.d.ts +17 -0
- package/dist/components/ui/dialog.d.ts.map +1 -0
- package/dist/components/ui/dialog.js +33 -0
- package/dist/components/ui/dialog.js.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +20 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.js +56 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -0
- package/dist/components/ui/editable-text.d.ts +17 -0
- package/dist/components/ui/editable-text.d.ts.map +1 -0
- package/dist/components/ui/editable-text.js +68 -0
- package/dist/components/ui/editable-text.js.map +1 -0
- package/dist/components/ui/field-button.d.ts +14 -0
- package/dist/components/ui/field-button.d.ts.map +1 -0
- package/dist/components/ui/field-button.js +16 -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 +110 -0
- package/dist/components/ui/file-uploader.js.map +1 -0
- package/dist/components/ui/handle-row.d.ts +15 -0
- package/dist/components/ui/handle-row.d.ts.map +1 -0
- package/dist/components/ui/handle-row.js +41 -0
- package/dist/components/ui/handle-row.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 +38 -0
- package/dist/components/ui/image-card.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 +81 -0
- package/dist/components/ui/image-viewer.js.map +1 -0
- package/dist/components/ui/image.d.ts +11 -0
- package/dist/components/ui/image.d.ts.map +1 -0
- package/dist/components/ui/image.js +32 -0
- package/dist/components/ui/image.js.map +1 -0
- package/dist/components/ui/index.d.ts +49 -0
- package/dist/components/ui/index.d.ts.map +1 -0
- package/dist/components/ui/index.js +49 -0
- package/dist/components/ui/index.js.map +1 -0
- package/dist/components/ui/input.d.ts +16 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +32 -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/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/nav-tree.d.ts +16 -0
- package/dist/components/ui/nav-tree.d.ts.map +1 -0
- package/dist/components/ui/nav-tree.js +34 -0
- package/dist/components/ui/nav-tree.js.map +1 -0
- package/dist/components/ui/page.d.ts +12 -0
- package/dist/components/ui/page.d.ts.map +1 -0
- package/dist/components/ui/page.js +15 -0
- package/dist/components/ui/page.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 +9 -0
- package/dist/components/ui/progress.d.ts.map +1 -0
- package/dist/components/ui/progress.js +9 -0
- package/dist/components/ui/progress.js.map +1 -0
- package/dist/components/ui/property.d.ts +15 -0
- package/dist/components/ui/property.d.ts.map +1 -0
- package/dist/components/ui/property.js +34 -0
- package/dist/components/ui/property.js.map +1 -0
- package/dist/components/ui/segmented.d.ts +13 -0
- package/dist/components/ui/segmented.d.ts.map +1 -0
- package/dist/components/ui/segmented.js +10 -0
- package/dist/components/ui/segmented.js.map +1 -0
- package/dist/components/ui/select-menu.d.ts +10 -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 +11 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/select.js +31 -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/spotlight.d.ts +23 -0
- package/dist/components/ui/spotlight.d.ts.map +1 -0
- package/dist/components/ui/spotlight.js +107 -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/table.d.ts +8 -0
- package/dist/components/ui/table.d.ts.map +1 -0
- package/dist/components/ui/table.js +23 -0
- package/dist/components/ui/table.js.map +1 -0
- package/dist/components/ui/theme-toggle.d.ts +2 -0
- package/dist/components/ui/theme-toggle.d.ts.map +1 -0
- package/dist/components/ui/theme-toggle.js +49 -0
- package/dist/components/ui/theme-toggle.js.map +1 -0
- package/dist/components/ui/time-picker.d.ts +21 -0
- package/dist/components/ui/time-picker.d.ts.map +1 -0
- package/dist/components/ui/time-picker.js +63 -0
- package/dist/components/ui/time-picker.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 +21 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/components/ui/typography.d.ts +34 -0
- package/dist/components/ui/typography.d.ts.map +1 -0
- package/dist/components/ui/typography.js +72 -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 +18 -0
- package/dist/components/ui/video-block.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 +45 -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 +43 -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/dates.d.ts +14 -0
- package/dist/lib/dates.d.ts.map +1 -0
- package/dist/lib/dates.js +34 -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/rich-text-dom.d.ts +14 -0
- package/dist/lib/rich-text-dom.d.ts.map +1 -0
- package/dist/lib/rich-text-dom.js +143 -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/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 +6 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/styles/notion.css +526 -0
- package/package.json +106 -5
- package/src/components/editor/block-text.tsx +230 -0
- package/src/components/editor/blocks.tsx +368 -0
- package/src/components/editor/document-editor.tsx +101 -0
- package/src/components/editor/document-view.tsx +192 -0
- package/src/components/editor/editor-state.tsx +270 -0
- package/src/components/editor/extensions/spoiler.tsx +76 -0
- package/src/components/editor/index.ts +9 -0
- package/src/components/editor/kinds.ts +158 -0
- package/src/components/sketch/rough.tsx +90 -0
- package/src/components/ui/accent-picker.tsx +72 -0
- package/src/components/ui/address-field.tsx +57 -0
- package/src/components/ui/app-shell.tsx +138 -0
- package/src/components/ui/badge.tsx +81 -0
- package/src/components/ui/breadcrumbs.tsx +25 -0
- package/src/components/ui/button.tsx +73 -0
- package/src/components/ui/calendar.tsx +100 -0
- package/src/components/ui/callout.tsx +62 -0
- package/src/components/ui/card.tsx +90 -0
- package/src/components/ui/checkbox.tsx +32 -0
- package/src/components/ui/command-menu.tsx +72 -0
- package/src/components/ui/date-picker.tsx +170 -0
- package/src/components/ui/date-time-picker.tsx +117 -0
- package/src/components/ui/dialog.tsx +124 -0
- package/src/components/ui/dropdown-menu.tsx +183 -0
- package/src/components/ui/editable-text.tsx +109 -0
- package/src/components/ui/field-button.tsx +68 -0
- package/src/components/ui/file-preview.tsx +80 -0
- package/src/components/ui/file-uploader.tsx +376 -0
- package/src/components/ui/handle-row.tsx +116 -0
- package/src/components/ui/image-block.tsx +238 -0
- package/src/components/ui/image-card.tsx +102 -0
- package/src/components/ui/image-viewer.tsx +187 -0
- package/src/components/ui/image.tsx +96 -0
- package/src/components/ui/index.ts +83 -0
- package/src/components/ui/input.tsx +99 -0
- package/src/components/ui/link-block.tsx +82 -0
- package/src/components/ui/mac-card.tsx +46 -0
- package/src/components/ui/nav-tree.tsx +86 -0
- package/src/components/ui/page.tsx +25 -0
- package/src/components/ui/popover.tsx +42 -0
- package/src/components/ui/progress.tsx +36 -0
- package/src/components/ui/property.tsx +64 -0
- package/src/components/ui/segmented.tsx +42 -0
- package/src/components/ui/select-menu.tsx +46 -0
- package/src/components/ui/select.tsx +124 -0
- package/src/components/ui/selection-bar.tsx +50 -0
- package/src/components/ui/separator.tsx +30 -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/table.tsx +42 -0
- package/src/components/ui/theme-toggle.tsx +101 -0
- package/src/components/ui/time-picker.tsx +173 -0
- package/src/components/ui/tooltip.tsx +64 -0
- package/src/components/ui/typography.tsx +168 -0
- package/src/components/ui/video-block.tsx +60 -0
- package/src/hooks/use-save-queue.ts +66 -0
- package/src/hooks/use-selection.ts +44 -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/dates.ts +39 -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/rich-text-dom.ts +136 -0
- package/src/lib/rich-text.ts +50 -0
- package/src/lib/spotlight.ts +78 -0
- package/src/lib/tree.ts +41 -0
- package/src/lib/utils.ts +6 -0
- package/src/styles/notion.css +526 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type Cell<T> = {
|
|
2
|
+
item: T;
|
|
3
|
+
width: number;
|
|
4
|
+
};
|
|
5
|
+
export type Line<T> = {
|
|
6
|
+
kind: "heading";
|
|
7
|
+
key: string;
|
|
8
|
+
label: string;
|
|
9
|
+
height: number;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "row";
|
|
12
|
+
key: string;
|
|
13
|
+
height: number;
|
|
14
|
+
cells: Cell<T>[];
|
|
15
|
+
};
|
|
16
|
+
/** One height for every row, or a rhythm: a height chosen by the row's number. */
|
|
17
|
+
export type RowHeight = number | ((row: number) => number);
|
|
18
|
+
/** A row height from the room there is: about one and a half pictures across a phone, three a tablet, four a wide screen. */
|
|
19
|
+
export declare const rowHeightFor: (width: number) => number;
|
|
20
|
+
/** A magazine's rhythm: every fourth row is a tall one of one or two pictures, and the rows between alternate taller and shorter. For a selection, not an archive. */
|
|
21
|
+
export declare const editorialRhythm: (width: number) => ((row: number) => number);
|
|
22
|
+
export declare function justify<T>(items: T[], width: number, options: {
|
|
23
|
+
id: (item: T) => string;
|
|
24
|
+
/** Width over height. */
|
|
25
|
+
aspect: (item: T) => number;
|
|
26
|
+
rowHeight: RowHeight;
|
|
27
|
+
gap?: number;
|
|
28
|
+
/** A value that starts a new section when it changes, and that section's heading. */
|
|
29
|
+
group?: (item: T) => {
|
|
30
|
+
key: string;
|
|
31
|
+
label: string;
|
|
32
|
+
};
|
|
33
|
+
headingHeight?: number;
|
|
34
|
+
}): Line<T>[];
|
|
35
|
+
export declare function masonry<T>(items: T[], width: number, options: {
|
|
36
|
+
aspect: (item: T) => number;
|
|
37
|
+
columns: number;
|
|
38
|
+
gap?: number;
|
|
39
|
+
below?: number;
|
|
40
|
+
}): {
|
|
41
|
+
places: {
|
|
42
|
+
item: T;
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
}[];
|
|
48
|
+
height: number;
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=justified.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"justified.d.ts","sourceRoot":"","sources":["../../src/lib/justified.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AACjD,MAAM,MAAM,IAAI,CAAC,CAAC,IACZ;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CA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IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACxF;IAAE,MAAM,EAAE;QAAE,IAAI,EAAE,CAAC,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAehG"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/* Rows of pictures that each fill the width exactly, like a contact sheet:
|
|
2
|
+
every row is one height, scaled so its pictures and the gaps between them
|
|
3
|
+
add up to the width. The heights are known before anything is drawn, which
|
|
4
|
+
is what lets a long list be virtualised without measuring.
|
|
5
|
+
|
|
6
|
+
Works on anything with an aspect ratio. Give `group` to start a new section
|
|
7
|
+
(with a heading line) whenever its value changes: months, say. */
|
|
8
|
+
/** A row height from the room there is: about one and a half pictures across a phone, three a tablet, four a wide screen. */
|
|
9
|
+
export const rowHeightFor = (width) => Math.round(Math.min(300, Math.max(170, width / 4.6)));
|
|
10
|
+
/** A magazine's rhythm: every fourth row is a tall one of one or two pictures, and the rows between alternate taller and shorter. For a selection, not an archive. */
|
|
11
|
+
export const editorialRhythm = (width) => (row) => {
|
|
12
|
+
const base = rowHeightFor(width);
|
|
13
|
+
if (row % 4 === 0)
|
|
14
|
+
return Math.round(Math.min(560, Math.max(base * 1.5, width * 0.4)));
|
|
15
|
+
return Math.round(base * (row % 2 === 1 ? 1.2 : 0.95));
|
|
16
|
+
};
|
|
17
|
+
export function justify(items, width, options) {
|
|
18
|
+
const { id, aspect, rowHeight, gap = 12, group, headingHeight = 64 } = options;
|
|
19
|
+
const lines = [];
|
|
20
|
+
if (width <= 0)
|
|
21
|
+
return lines;
|
|
22
|
+
// A panorama or a sliver would otherwise set the height of its whole row.
|
|
23
|
+
const clamped = (item) => Math.min(Math.max(aspect(item), 0.5), 3);
|
|
24
|
+
let section = "";
|
|
25
|
+
let pending = [];
|
|
26
|
+
let ratios = 0;
|
|
27
|
+
let row = 0;
|
|
28
|
+
const target = () => (typeof rowHeight === "number" ? rowHeight : rowHeight(row));
|
|
29
|
+
const flush = (full) => {
|
|
30
|
+
if (pending.length === 0)
|
|
31
|
+
return;
|
|
32
|
+
const room = width - gap * (pending.length - 1);
|
|
33
|
+
// A last row that is not full keeps the target height and stays ragged;
|
|
34
|
+
// stretching three pictures across the page would blow them up.
|
|
35
|
+
const height = full ? room / ratios : Math.min(target(), room / ratios);
|
|
36
|
+
lines.push({ kind: "row", key: id(pending[0]), height: Math.round(height) + gap, cells: pending.map((item) => ({ item, width: height * clamped(item) })) });
|
|
37
|
+
pending = [];
|
|
38
|
+
ratios = 0;
|
|
39
|
+
row += 1;
|
|
40
|
+
};
|
|
41
|
+
for (const item of items) {
|
|
42
|
+
const next = group?.(item);
|
|
43
|
+
if (next !== undefined && next.key !== section) {
|
|
44
|
+
flush(false);
|
|
45
|
+
section = next.key;
|
|
46
|
+
lines.push({ kind: "heading", key: next.key, label: next.label, height: headingHeight });
|
|
47
|
+
}
|
|
48
|
+
pending.push(item);
|
|
49
|
+
ratios += clamped(item);
|
|
50
|
+
if (ratios * target() + gap * (pending.length - 1) >= width)
|
|
51
|
+
flush(true);
|
|
52
|
+
}
|
|
53
|
+
flush(false);
|
|
54
|
+
return lines;
|
|
55
|
+
}
|
|
56
|
+
/* Pinterest columns: each picture at its own shape, dealt across the columns
|
|
57
|
+
in order like cards, so the board reads left to right and a last row that
|
|
58
|
+
is not full starts at the left. (Putting each in the shortest column packs
|
|
59
|
+
tighter but drops the last one wherever there is room.) Fewer pictures than
|
|
60
|
+
columns are centred. `below` is room under each picture for a caption. */
|
|
61
|
+
export function masonry(items, width, options) {
|
|
62
|
+
const { aspect, columns, gap = 22, below = 0 } = options;
|
|
63
|
+
if (width <= 0 || columns <= 0)
|
|
64
|
+
return { places: [], height: 0 };
|
|
65
|
+
const column = (width - gap * (columns - 1)) / columns;
|
|
66
|
+
const heights = Array.from({ length: columns }, () => 0);
|
|
67
|
+
const used = Math.min(columns, items.length);
|
|
68
|
+
const inset = (width - (used * column + gap * (used - 1))) / 2;
|
|
69
|
+
const places = items.map((item, index) => {
|
|
70
|
+
const at = index % columns;
|
|
71
|
+
const height = column / aspect(item);
|
|
72
|
+
const y = heights[at];
|
|
73
|
+
heights[at] = y + height + below + gap;
|
|
74
|
+
return { item, x: inset + at * (column + gap), y, width: column, height };
|
|
75
|
+
});
|
|
76
|
+
return { places, height: Math.max(0, Math.max(...heights) - gap) };
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=justified.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"justified.js","sourceRoot":"","sources":["../../src/lib/justified.ts"],"names":[],"mappings":"AAAA;;;;;;oEAMoE;AAUpE,6HAA6H;AAC7H,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AAE7G,sKAAsK;AACtK,MAAM,CAAC,MAAM,eAAe,GACxB,CAAC,KAAa,EAA6B,EAAE,CAC7C,CAAC,GAAG,EAAE,EAAE;IACJ,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,EAAE,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IACvF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,C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AAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC9E,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Text } from "./rich-text.js";
|
|
2
|
+
export declare function spansToHtml(text: Text): string;
|
|
3
|
+
export declare function readSpans(root: HTMLElement): Text;
|
|
4
|
+
export declare function caretOffset(root: HTMLElement): number | null;
|
|
5
|
+
export declare function setCaret(root: HTMLElement, at: number | "end"): void;
|
|
6
|
+
export declare function caretRect(): DOMRect | null;
|
|
7
|
+
/**
|
|
8
|
+
* Whether the caret sits on the first or the last visual line of `root`, where
|
|
9
|
+
* ArrowUp or ArrowDown leaves the block, as in Notion. Measured, because a
|
|
10
|
+
* wrapped paragraph has several lines and only its edges lead out. An empty
|
|
11
|
+
* block, or a caret the browser cannot place, counts as both.
|
|
12
|
+
*/
|
|
13
|
+
export declare function caretOnEdgeLine(root: HTMLElement, edge: "first" | "last"): boolean;
|
|
14
|
+
//# sourceMappingURL=rich-text-dom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-text-dom.d.ts","sourceRoot":"","sources":["../../src/lib/rich-text-dom.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAajE,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAe9C;AAMD,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CA8BjD;AAYD,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAS5D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAsBpE;AAED,wBAAgB,SAAS,IAAI,OAAO,GAAG,IAAI,CAS1C;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAMlF"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { isSafeHref } from "./embed.js";
|
|
2
|
+
import { normalize } from "./rich-text.js";
|
|
3
|
+
/* Bridges the span model and the DOM inside a contentEditable element. A link is
|
|
4
|
+
written and read back only when it is a web or mail address, so a `javascript:`
|
|
5
|
+
href pasted in as HTML never survives into the document. */
|
|
6
|
+
const escape = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
7
|
+
const UNDERLINE = "underline decoration-accent/50 underline-offset-[3px] hover:decoration-accent cursor-pointer";
|
|
8
|
+
const CODE = "rounded-[3px] bg-tag-red-bg/70 px-1.5 py-0.5 font-mono text-[0.85em] text-tag-red-ink";
|
|
9
|
+
const PAGE_ICON = '<svg class="mr-1 mb-0.5 inline size-[1em] text-ink-secondary" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/></svg>';
|
|
10
|
+
export function spansToHtml(text) {
|
|
11
|
+
return text
|
|
12
|
+
.map((span) => {
|
|
13
|
+
// A page link is one uneditable token, as a Notion mention is.
|
|
14
|
+
if (span.page)
|
|
15
|
+
return `<a data-page="${escape(span.page)}" href="/${escape(span.page)}" contenteditable="false" class="font-medium cursor-pointer rounded-[3px] hover:bg-tint-hover">${PAGE_ICON}<span class="${UNDERLINE}">${escape(span.text)}</span></a>`;
|
|
16
|
+
let html = escape(span.text);
|
|
17
|
+
if (span.code)
|
|
18
|
+
html = `<code class="${CODE}">${html}</code>`;
|
|
19
|
+
if (span.strike)
|
|
20
|
+
html = `<s>${html}</s>`;
|
|
21
|
+
if (span.italic)
|
|
22
|
+
html = `<em>${html}</em>`;
|
|
23
|
+
if (span.bold)
|
|
24
|
+
html = `<strong class="font-semibold">${html}</strong>`;
|
|
25
|
+
if (span.href && isSafeHref(span.href))
|
|
26
|
+
html = `<a href="${escape(span.href)}" target="_blank" rel="noreferrer" class="${UNDERLINE}">${html}</a>`;
|
|
27
|
+
return html;
|
|
28
|
+
})
|
|
29
|
+
.join("");
|
|
30
|
+
}
|
|
31
|
+
// Reads back whatever the browser left after an edit: our own tags, plus the <b>,
|
|
32
|
+
// <i>, <strike> and styled spans that execCommand produces.
|
|
33
|
+
export function readSpans(root) {
|
|
34
|
+
const out = [];
|
|
35
|
+
const walk = (node, marks) => {
|
|
36
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
37
|
+
out.push({ ...marks, text: (node.nodeValue ?? "").replace(/ /g, " ") });
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!(node instanceof HTMLElement))
|
|
41
|
+
return;
|
|
42
|
+
if (node.tagName === "BR") {
|
|
43
|
+
out.push({ ...marks, text: "\n" });
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (node.dataset.page) {
|
|
47
|
+
out.push({ text: node.textContent ?? "", page: node.dataset.page });
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const m = { ...marks };
|
|
51
|
+
const tag = node.tagName;
|
|
52
|
+
const { fontWeight, fontStyle, textDecorationLine } = node.style;
|
|
53
|
+
if (tag === "B" || tag === "STRONG" || fontWeight === "bold" || Number(fontWeight) >= 600)
|
|
54
|
+
m.bold = true;
|
|
55
|
+
if (fontWeight === "normal" || fontWeight === "400")
|
|
56
|
+
delete m.bold;
|
|
57
|
+
if (tag === "I" || tag === "EM" || fontStyle === "italic")
|
|
58
|
+
m.italic = true;
|
|
59
|
+
if (tag === "S" || tag === "STRIKE" || tag === "DEL" || textDecorationLine.includes("line-through"))
|
|
60
|
+
m.strike = true;
|
|
61
|
+
if (tag === "CODE")
|
|
62
|
+
m.code = true;
|
|
63
|
+
const href = tag === "A" ? node.getAttribute("href") : null;
|
|
64
|
+
if (href !== null && isSafeHref(href))
|
|
65
|
+
m.href = href;
|
|
66
|
+
node.childNodes.forEach((child) => walk(child, m));
|
|
67
|
+
};
|
|
68
|
+
root.childNodes.forEach((child) => walk(child, {}));
|
|
69
|
+
return normalize(out);
|
|
70
|
+
}
|
|
71
|
+
const length = (node) => {
|
|
72
|
+
if (node.nodeType === Node.TEXT_NODE)
|
|
73
|
+
return node.nodeValue?.length ?? 0;
|
|
74
|
+
if (node instanceof HTMLElement && node.tagName === "BR")
|
|
75
|
+
return 1;
|
|
76
|
+
let n = 0;
|
|
77
|
+
node.childNodes.forEach((child) => (n += length(child)));
|
|
78
|
+
return n;
|
|
79
|
+
};
|
|
80
|
+
// The caret as a character offset into the element's text, or null when the
|
|
81
|
+
// selection is elsewhere or is a range.
|
|
82
|
+
export function caretOffset(root) {
|
|
83
|
+
const sel = window.getSelection();
|
|
84
|
+
if (!sel || sel.rangeCount === 0 || !sel.isCollapsed)
|
|
85
|
+
return null;
|
|
86
|
+
const range = sel.getRangeAt(0);
|
|
87
|
+
if (!root.contains(range.endContainer))
|
|
88
|
+
return null;
|
|
89
|
+
const before = document.createRange();
|
|
90
|
+
before.selectNodeContents(root);
|
|
91
|
+
before.setEnd(range.endContainer, range.endOffset);
|
|
92
|
+
return length(before.cloneContents());
|
|
93
|
+
}
|
|
94
|
+
export function setCaret(root, at) {
|
|
95
|
+
root.focus();
|
|
96
|
+
const sel = window.getSelection();
|
|
97
|
+
if (!sel)
|
|
98
|
+
return;
|
|
99
|
+
const range = document.createRange();
|
|
100
|
+
range.selectNodeContents(root);
|
|
101
|
+
range.collapse(at !== "end");
|
|
102
|
+
if (typeof at === "number" && at > 0) {
|
|
103
|
+
let left = at;
|
|
104
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
105
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
106
|
+
const n = node.nodeValue?.length ?? 0;
|
|
107
|
+
if (left <= n) {
|
|
108
|
+
range.setStart(node, left);
|
|
109
|
+
range.collapse(true);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
left -= n;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
sel.removeAllRanges();
|
|
116
|
+
sel.addRange(range);
|
|
117
|
+
}
|
|
118
|
+
export function caretRect() {
|
|
119
|
+
const sel = window.getSelection();
|
|
120
|
+
if (!sel || sel.rangeCount === 0)
|
|
121
|
+
return null;
|
|
122
|
+
const range = sel.getRangeAt(0);
|
|
123
|
+
const rect = range.getClientRects()[0] ?? range.getBoundingClientRect();
|
|
124
|
+
// An empty line has no rects; fall back to the element the caret sits in.
|
|
125
|
+
if (rect.width === 0 && rect.height === 0 && range.startContainer instanceof Element)
|
|
126
|
+
return range.startContainer.getBoundingClientRect();
|
|
127
|
+
return rect;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Whether the caret sits on the first or the last visual line of `root`, where
|
|
131
|
+
* ArrowUp or ArrowDown leaves the block, as in Notion. Measured, because a
|
|
132
|
+
* wrapped paragraph has several lines and only its edges lead out. An empty
|
|
133
|
+
* block, or a caret the browser cannot place, counts as both.
|
|
134
|
+
*/
|
|
135
|
+
export function caretOnEdgeLine(root, edge) {
|
|
136
|
+
const rect = caretRect();
|
|
137
|
+
if (rect === null || (rect.top === 0 && rect.bottom === 0))
|
|
138
|
+
return true;
|
|
139
|
+
const box = root.getBoundingClientRect();
|
|
140
|
+
const line = parseFloat(getComputedStyle(root).lineHeight) || rect.height || 20;
|
|
141
|
+
return edge === "first" ? rect.top - box.top < line * 0.8 : box.bottom - rect.bottom < line * 0.8;
|
|
142
|
+
}
|
|
143
|
+
//# source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C,UAAU,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,IAAI,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,qBAAqB,EAAE,CAAC;IACxE,0EAA0E;IAC1E,IAAI,IAAI,CAAC,KAAK,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,cAAc,YAAY,OAAO;QAChF,OAAO,KAAK,CAAC,cAAc,CAAC,qBAAqB,EAAE,CAAC;IACxD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,IAAiB,EAAE,IAAsB;IACrE,MAAM,IAAI,GAAG,SAAS,EAAE,CAAC;IACzB,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACxE,MAAM,GAAG,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;IACzC,MAAM,IAAI,GAAG,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;IAChF,OAAO,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC;AACtG,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type Span = {
|
|
2
|
+
text: string;
|
|
3
|
+
bold?: true;
|
|
4
|
+
italic?: true;
|
|
5
|
+
strike?: true;
|
|
6
|
+
code?: true;
|
|
7
|
+
href?: string;
|
|
8
|
+
page?: string;
|
|
9
|
+
};
|
|
10
|
+
export type Text = Span[];
|
|
11
|
+
export declare const plain: (text: Text) => string;
|
|
12
|
+
export declare function normalize(text: Text): Text;
|
|
13
|
+
export declare function split(text: Text, at: number): [Text, Text];
|
|
14
|
+
export declare function cut(text: Text, from: number, to: number): Text;
|
|
15
|
+
//# sourceMappingURL=rich-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-text.d.ts","sourceRoot":"","sources":["../../src/lib/rich-text.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,IAAI,GAAG;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AACF,MAAM,MAAM,IAAI,GAAG,IAAI,EAAE,CAAC;AAE1B,eAAO,MAAM,KAAK,GAAI,MAAM,IAAI,KAAG,MAA0C,CAAC;AAO9E,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAS1C;AAGD,wBAAgB,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAW1D;AAGD,wBAAgB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAE9D"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const plain = (text) => text.map((s) => s.text).join("");
|
|
2
|
+
const sameMarks = (a, b) => a.bold === b.bold && a.italic === b.italic && a.strike === b.strike && a.code === b.code && a.href === b.href && a.page === b.page;
|
|
3
|
+
// Drops empty spans and merges neighbours that carry the same marks. A page link
|
|
4
|
+
// never merges: two links to one page side by side are still two links.
|
|
5
|
+
export function normalize(text) {
|
|
6
|
+
const out = [];
|
|
7
|
+
for (const span of text) {
|
|
8
|
+
if (span.text === "")
|
|
9
|
+
continue;
|
|
10
|
+
const last = out.at(-1);
|
|
11
|
+
if (last && !span.page && sameMarks(last, span))
|
|
12
|
+
out[out.length - 1] = { ...last, text: last.text + span.text };
|
|
13
|
+
else
|
|
14
|
+
out.push(span);
|
|
15
|
+
}
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
// Splits at a character offset into what comes before and what comes after.
|
|
19
|
+
export function split(text, at) {
|
|
20
|
+
const before = [];
|
|
21
|
+
const after = [];
|
|
22
|
+
let seen = 0;
|
|
23
|
+
for (const span of text) {
|
|
24
|
+
const cut = Math.min(Math.max(at - seen, 0), span.text.length);
|
|
25
|
+
before.push({ ...span, text: span.text.slice(0, cut) });
|
|
26
|
+
after.push({ ...span, text: span.text.slice(cut) });
|
|
27
|
+
seen += span.text.length;
|
|
28
|
+
}
|
|
29
|
+
return [normalize(before), normalize(after)];
|
|
30
|
+
}
|
|
31
|
+
// Removes the characters in [from, to).
|
|
32
|
+
export function cut(text, from, to) {
|
|
33
|
+
return normalize([...split(text, from)[0], ...split(text, to)[1]]);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=rich-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-text.js","sourceRoot":"","sources":["../../src/lib/rich-text.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAU,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAE9E,MAAM,SAAS,GAAG,CAAC,CAAO,EAAE,CAAO,EAAE,EAAE,CACnC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,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AAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QACxD,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACpD,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IAC7B,CAAC;IACD,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,wCAAwC;AACxC,MAAM,UAAU,GAAG,CAAC,IAAU,EAAE,IAAY,EAAE,EAAU;IACpD,OAAO,SAAS,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type SpotlightEntry = {
|
|
2
|
+
key: string;
|
|
3
|
+
label: string;
|
|
4
|
+
/** Shown after the label, and searched: where the page lives, what it is. */
|
|
5
|
+
hint?: string;
|
|
6
|
+
/** Heads a run of entries while nothing is typed; searched too. */
|
|
7
|
+
group?: string;
|
|
8
|
+
/** Searched but never shown: other names for the same page. */
|
|
9
|
+
keywords?: string[];
|
|
10
|
+
};
|
|
11
|
+
export type Ranked<T> = {
|
|
12
|
+
item: T;
|
|
13
|
+
score: number;
|
|
14
|
+
hits: number[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The entries that match `query`, best first, each with the label positions to
|
|
18
|
+
* highlight. Nothing typed keeps every entry in the order given; equal scores
|
|
19
|
+
* keep that order too, so the owner's ordering breaks ties.
|
|
20
|
+
*/
|
|
21
|
+
export declare function rankEntries<T extends SpotlightEntry>(entries: T[], query: string): Ranked<T>[];
|
|
22
|
+
//# sourceMappingURL=spotlight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spotlight.d.ts","sourceRoot":"","sources":["../../src/lib/spotlight.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,cAAc,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AA6BnE;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,cAAc,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,CAwB9F"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/* Ranking for the Spotlight: what was typed against a list of places to go.
|
|
2
|
+
|
|
3
|
+
Every word typed has to be found somewhere in an entry — its label, or the
|
|
4
|
+
quieter words around it (its hint, its group, keywords) — so "korea money" finds
|
|
5
|
+
the Money page of the Korea trip. A word found in the label counts for more,
|
|
6
|
+
and more again at the start of the label or of one of its words; a word whose
|
|
7
|
+
letters only appear in order ("gwngjng") still counts, for the label alone. */
|
|
8
|
+
const wordStart = (text, at) => at === 0 || !/[\p{L}\p{N}]/u.test(text[at - 1]);
|
|
9
|
+
/** The positions of `word`'s letters, in order, in `text`, or null. */
|
|
10
|
+
function inOrder(text, word) {
|
|
11
|
+
const hits = [];
|
|
12
|
+
let from = 0;
|
|
13
|
+
for (const ch of word) {
|
|
14
|
+
const at = text.indexOf(ch, from);
|
|
15
|
+
if (at < 0)
|
|
16
|
+
return null;
|
|
17
|
+
hits.push(at);
|
|
18
|
+
from = at + 1;
|
|
19
|
+
}
|
|
20
|
+
return hits;
|
|
21
|
+
}
|
|
22
|
+
function scoreWord(label, rest, word) {
|
|
23
|
+
const at = label.indexOf(word);
|
|
24
|
+
if (at >= 0) {
|
|
25
|
+
const hits = Array.from({ length: word.length }, (_, k) => at + k);
|
|
26
|
+
return { score: at === 0 ? 100 : wordStart(label, at) ? 80 : 50, hits };
|
|
27
|
+
}
|
|
28
|
+
const elsewhere = rest.indexOf(word);
|
|
29
|
+
if (elsewhere >= 0)
|
|
30
|
+
return { score: wordStart(rest, elsewhere) ? 30 : 15, hits: [] };
|
|
31
|
+
const scattered = word.length > 1 ? inOrder(label, word) : null;
|
|
32
|
+
return scattered === null ? null : { score: 20, hits: scattered };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The entries that match `query`, best first, each with the label positions to
|
|
36
|
+
* highlight. Nothing typed keeps every entry in the order given; equal scores
|
|
37
|
+
* keep that order too, so the owner's ordering breaks ties.
|
|
38
|
+
*/
|
|
39
|
+
export function rankEntries(entries, query) {
|
|
40
|
+
const words = query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
41
|
+
if (words.length === 0)
|
|
42
|
+
return entries.map((item) => ({ item, score: 0, hits: [] }));
|
|
43
|
+
const ranked = [];
|
|
44
|
+
for (const item of entries) {
|
|
45
|
+
const label = item.label.toLowerCase();
|
|
46
|
+
const rest = [item.hint, item.group, ...(item.keywords ?? [])].filter(Boolean).join(" · ").toLowerCase();
|
|
47
|
+
let score = 0;
|
|
48
|
+
const hits = new Set();
|
|
49
|
+
let matched = true;
|
|
50
|
+
for (const word of words) {
|
|
51
|
+
const found = scoreWord(label, rest, word);
|
|
52
|
+
if (found === null) {
|
|
53
|
+
matched = false;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
score += found.score;
|
|
57
|
+
for (const h of found.hits)
|
|
58
|
+
hits.add(h);
|
|
59
|
+
}
|
|
60
|
+
// A short label that matches is a closer match than a long one.
|
|
61
|
+
if (matched)
|
|
62
|
+
ranked.push({ item, score: score - label.length / 100, hits: [...hits].sort((a, b) => a - b) });
|
|
63
|
+
}
|
|
64
|
+
return ranked.sort((a, b) => b.score - a.score);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=spotlight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spotlight.js","sourceRoot":"","sources":["../../src/lib/spotlight.ts"],"names":[],"mappings":"AAAA;;;;;;iFAMiF;AAejF,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,EAAU,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAE,CAAC,CAAC;AAEjG,uEAAuE;AACvE,SAAS,OAAO,CAAC,IAAY,EAAE,IAAY;IACvC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;QACpB,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAClC,IAAI,EAAE,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;QACxB,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACd,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,SAAS,SAAS,CAAC,KAAa,EAAE,IAAY,EAAE,IAAY;IACxD,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;QACV,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,EA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CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type TreeNode<T> = T & {
|
|
2
|
+
id: number;
|
|
3
|
+
children: TreeNode<T>[];
|
|
4
|
+
};
|
|
5
|
+
export type Place<T> = {
|
|
6
|
+
node: TreeNode<T>;
|
|
7
|
+
parent: TreeNode<T> | null;
|
|
8
|
+
siblings: TreeNode<T>[];
|
|
9
|
+
index: number;
|
|
10
|
+
};
|
|
11
|
+
export declare function locate<T>(tree: TreeNode<T>[], id: number, parent?: TreeNode<T> | null): Place<T> | undefined;
|
|
12
|
+
export declare function update<T>(tree: TreeNode<T>[], id: number, fn: (node: TreeNode<T>) => TreeNode<T>): TreeNode<T>[];
|
|
13
|
+
export declare function remove<T>(tree: TreeNode<T>[], id: number): TreeNode<T>[];
|
|
14
|
+
export declare function insert<T>(tree: TreeNode<T>[], parentId: number | null, afterId: number | null, node: TreeNode<T>): TreeNode<T>[];
|
|
15
|
+
export declare function flat<T>(tree: TreeNode<T>[]): TreeNode<T>[];
|
|
16
|
+
export declare const contains: <T>(node: TreeNode<T>, id: number) => boolean;
|
|
17
|
+
//# sourceMappingURL=tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/lib/tree.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAA;CAAE,CAAC;AACtE,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,C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
|
2
|
+
// of nested lists, outlines and block editors. Every function returns a new tree,
|
|
3
|
+
// so they suit optimistic UI state.
|
|
4
|
+
export function locate(tree, id, parent = null) {
|
|
5
|
+
for (const [index, node] of tree.entries()) {
|
|
6
|
+
if (node.id === id)
|
|
7
|
+
return { node, parent, siblings: tree, index };
|
|
8
|
+
const inside = locate(node.children, id, node);
|
|
9
|
+
if (inside)
|
|
10
|
+
return inside;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function update(tree, id, fn) {
|
|
14
|
+
return tree.map((node) => (node.id === id ? fn(node) : { ...node, children: update(node.children, id, fn) }));
|
|
15
|
+
}
|
|
16
|
+
export function remove(tree, id) {
|
|
17
|
+
return tree.filter((node) => node.id !== id).map((node) => ({ ...node, children: remove(node.children, id) }));
|
|
18
|
+
}
|
|
19
|
+
// Seats `node` under `parentId` (the top level when null), directly after `afterId`
|
|
20
|
+
// (first when null).
|
|
21
|
+
export function insert(tree, parentId, afterId, node) {
|
|
22
|
+
const seat = (siblings) => {
|
|
23
|
+
const at = afterId === null ? 0 : siblings.findIndex((s) => s.id === afterId) + 1;
|
|
24
|
+
return [...siblings.slice(0, at), node, ...siblings.slice(at)];
|
|
25
|
+
};
|
|
26
|
+
if (parentId === null)
|
|
27
|
+
return seat(tree);
|
|
28
|
+
return update(tree, parentId, (parent) => ({ ...parent, children: seat(parent.children) }));
|
|
29
|
+
}
|
|
30
|
+
// Every node in reading order.
|
|
31
|
+
export function flat(tree) {
|
|
32
|
+
return tree.flatMap((node) => [node, ...flat(node.children)]);
|
|
33
|
+
}
|
|
34
|
+
export const contains = (node, id) => node.children.some((child) => child.id === id || contains(child, id));
|
|
35
|
+
//# sourceMappingURL=tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/lib/tree.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,kFAAkF;AAClF,oCAAoC;AAKpC,MAAM,UAAU,MAAM,CA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U,EAAE,MAAM,MAAM,CAAC;AAG7C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmB,MAAM,MAAM,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,MAAM,UAAU,EAAE,CAAC,GAAG,MAAoB;IACtC,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AACjC,CAAC"}
|