docblocks-react-ui 0.5.0 → 0.6.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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # docblocks-react-ui
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8b0f589: Add a zoom bar to the PDF preview's fullscreen mode: a separate pill to the left of the page controls with the zoom in/out buttons (over the fitted scale, 25%-400% bounds), the scale indicator, the fit-width and the fit-height buttons (the page's width/height fills the viewport's width/height, the overflow scrolls). The fullscreen mode pages with the left/right arrow keys, locks the body's scroll while open (the wheel over the overlay no longer scrolls the page behind), and stands a fixed-width page indicator (a digit count change no longer shifts the page buttons). The preview chrome stands no text selection (the page indicator and the controls are not document content), so selecting the page numbers can no longer flag the block or pull up the format toolbar.
8
+ - 7f26c1a: Localize the empty-block command palette placeholder for Russian locales while preserving consumer overrides.
9
+ - 8f6a3d6: - Add first-class file blocks with consumer-owned file ids, live rename subscriptions, reader downloads, and PDF previews.
10
+ - Replace URL-based blob resolution with Blob+metadata stores and remove the legacy `blobResolver` prop.
11
+
12
+ ### Patch Changes
13
+
14
+ - 16e10af: Fix attachment insertion and deletion gestures: replace phrase-only slash blocks, keep removal and the trailing paragraph in one undo step, and seat the caret on a surviving text block.
15
+ - Updated dependencies [8f6a3d6]
16
+ - docblocks-core@0.3.0
17
+
3
18
  ## 0.5.0
4
19
 
5
20
  ### Minor Changes
package/README.md CHANGED
@@ -86,7 +86,7 @@ a bare `tsc`-only setup needs a one-line `declare module "*.css"` shim.
86
86
  Everything the editor needs from the consumer is injected as an
87
87
  `EditorProvider` prop; every prop except `doc` is optional. The only
88
88
  built-in default is the blob store (a shared in-memory stand — the
89
- uploads resolve as data urls for the JS session, cleared on reload); the
89
+ uploads stay in memory for the JS session, cleared on reload); the
90
90
  other props degrade gracefully over their absence (the external-form
91
91
  database block stands the not-connected placeholder and the `/database`
92
92
  slash command is hidden without a bridge; the `sync-embed` block stands
@@ -99,14 +99,13 @@ mention catalog). The full props list:
99
99
  | `provider?` | A core `SyncProvider` for the wire + presence. Without it the editor is a single-client document (local edits stand, nothing syncs). |
100
100
  | `blockRenderers?` | Per-type renderer overrides (see below). |
101
101
  | `blobStore?` | The blob bridge for image / pdf / file blocks (see below). |
102
- | `blobResolver?` | Legacy view-only resolver (key → src string). Wrapped as a store: no upload, subtype `image`. Prefer `blobStore`. |
103
102
  | `databaseBridge?` | The table operations behind external-form database blocks (see below). |
104
103
  | `syncEmbedResolver?` | `(ref) => Doc \| null` — resolves a `sync-embed` block's ref to the master doc (see below). |
105
104
  | `embedSandbox?` | `(src) => string \| null` — the embed iframe's `sandbox` policy. The default grants the same-origin (the embedded app's own storage / cookies stand, so the real apps boot); `null` stands no sandbox (a fully trusted embed). The opaque-origin restriction stands over this policy. |
106
- | `pdfPreview?` | A first-page preview component for `pdf`-subtype image blocks (see below). |
105
+ | `pdfPreview?` | A first-page preview component for PDF file blocks (and legacy PDF image blocks). |
107
106
  | `mentionProvider?` | The `@` mention picker's search catalog (see below). |
108
107
  | `rootBlockId?` | Render the entry list of this block instead of the document root (the subtree view). Must not change after mount. |
109
- | `commandPalettePlaceholder?` | The empty-block hint text (default `Type '/' for commands`). |
108
+ | `commandPalettePlaceholder?` | The empty-block hint override; the default is localized (en/ru). |
110
109
  | `accessLevel?` | The consumer's user access level (default `editor`): `viewer` forces the `published` mode (the current state is never rendered to a reader). |
111
110
  | `mode?` | The document mode (default `edit`): `view` is a read-only live document; `published` renders the `publishedDoc` snapshot read-only. |
112
111
  | `publishedDoc?` | The published snapshot (a hydrated core `Doc`; must not change after mount — remount over `key` for a new snapshot). The consumer owns the publish action and the snapshot storage. |
@@ -316,33 +315,45 @@ anonymous plaintext selection over the room — the 0.2.0 behavior).
316
315
 
317
316
  ### Blobs
318
317
 
319
- The document holds only an opaque blob key (`image.src`); the bytes live
320
- where the consumer stored them. `BlobStore` (the `blobStore` prop) is the
321
- only path key → url and file → key, in both directions:
318
+ File-backed blocks hold only consumer-owned ids: `file.attrs.fileId` for
319
+ attachments and PDFs, and `image.attrs.src` for inline images. Bytes, names,
320
+ and MIME types never enter the document. `BlobStore` is the only bridge
321
+ between those ids and the stored objects:
322
322
 
323
323
  ```ts
324
+ interface BlobMeta {
325
+ name: string;
326
+ mimeType: string;
327
+ }
328
+
324
329
  interface BlobStore {
325
- resolve(key: string): Promise<{
326
- url: string;
327
- meta: { subtype: "image" | "pdf" | "file"; name?: string; type?: string; size?: number };
328
- }>;
329
- upload(file: File | Blob, meta?: Partial<BlobMeta>): Promise<string>;
330
- remove?(key: string): Promise<void>; // optional gc
330
+ get(fileId: string): Promise<{ blob: Blob; meta: BlobMeta }>;
331
+ upload(file: File): Promise<string>;
332
+ rename(fileId: string, name: string): Promise<BlobMeta>;
333
+ subscribe(fileId: string, onChange: () => void): () => void;
334
+ remove?(fileId: string): Promise<void>;
331
335
  }
332
336
  ```
333
337
 
334
- - `resolve` rejects an unknown key — the block stands its structural
335
- placeholder card until the promise resolves.
336
- - The UI renders from `meta.subtype` and never guesses: `image` is an
337
- `<img>`, `pdf` the first-page preview (the `./pdf` subpath, or the native
338
- iframe without it), `file` the download card. The consumer decides the
339
- subtype on both directions (`upload` may override the mime-derived
340
- default via `meta.subtype`).
341
- - Without `blobStore` / `blobResolver`, the editor uses a shared
342
- in-memory store (uploads stand data urls for the JS session, cleared on
343
- reload), so the upload path works out of the box. `createMemoryBlobStore`
344
- and `blobSubtypeOf` are exported for consumers who want the same
345
- behavior under their own prop.
338
+ - `get` rejects an unknown id; the block renders a placeholder while loading
339
+ or when the id is unavailable. The library creates an object URL for the
340
+ returned blob and revokes it on replacement or unmount.
341
+ - The file picker accepts arbitrary files. New `image/*` uploads create an
342
+ `image` block; other MIME types, including `application/pdf`, create a
343
+ `file` block. PDF files render through `pdfPreview` or the sandboxed native
344
+ iframe; other files render a card with file and download icons.
345
+ - `meta.name` is the authoritative display and suggested download name.
346
+ Editors rename through `rename(fileId, name)`; the document JSON does not
347
+ change and document undo/redo does not revert storage renames. The store
348
+ notifies `subscribe` listeners after rename or replacement, so every open
349
+ view reloads the current blob and metadata. A rejection keeps the previous
350
+ name and displays an inline error. Read-only modes hide rename and keep
351
+ download available.
352
+ - Consumers can also update S3 `Content-Disposition` in `rename` when direct
353
+ storage URLs outside the library must carry the same filename.
354
+ - Without `blobStore`, the editor uses a shared in-memory store, cleared on
355
+ page reload. `createMemoryBlobStore` is exported for consumers that want the
356
+ same behavior in their own store composition.
346
357
 
347
358
  ### Database
348
359
 
@@ -518,8 +529,8 @@ const blockRenderers: BlockRendererMap = {
518
529
 
519
530
  ### PDF preview
520
531
 
521
- `pdfPreview` is a component that renders a `pdf`-subtype image block's
522
- resolved blob as a client-side first-page preview. The `./pdf` subpath
532
+ `pdfPreview` is a component that renders a PDF file block's bytes as a
533
+ client-side first-page preview. The `./pdf` subpath
523
534
  provides one over `pdfjs-dist` (a required peer):
524
535
 
525
536
  ```tsx
@@ -530,11 +541,11 @@ import { PdfFirstPage } from "docblocks-react-ui/pdf";
530
541
  </EditorProvider>;
531
542
  ```
532
543
 
533
- The renderer receives `{ id, url, name }` (`id` is the block id, `url` the
534
- resolved blob url, `name` the blob's display name) and should stamp
535
- `data-block-id={id} data-block-type="image"` on its rendered root, like the
536
- other block renderers. Without the prop a `pdf`-subtype block stands the
537
- native iframe viewer; a failed preview render falls back to it, so the
544
+ The renderer receives `{ id, blockType, url, name }`: the block id, `file` for
545
+ new PDF blocks or `image` for legacy ones, the library-owned object URL, and
546
+ the store's authoritative name. It stamps `data-block-id={id}` and
547
+ `data-block-type={blockType}` on its root. Without the prop a PDF block stands
548
+ the native iframe viewer; a failed preview render falls back to it, so the
538
549
  document always stays viewable.
539
550
 
540
551
  ### Mentions