docblocks-react-ui 0.16.0 → 0.17.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.17.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 05bd9d1: A protocol-relative link opens in a new tab with `noopener,noreferrer` (the
8
+ `web` class — it was treated as a relative path before), and the address
9
+ popover stores the typed protocol-relative form as an explicit `https://`
10
+ URL. The link popover parks the editor root's focus on the commit's effect,
11
+ so a fast gesture right after the close is not lost.
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [348f4ad]
16
+ - docblocks-core@0.8.0
17
+
3
18
  ## 0.16.0
4
19
 
5
20
  ### Minor Changes
package/README.md CHANGED
@@ -652,6 +652,39 @@ or the removed state yourself — the `label` is the display snapshot. The
652
652
  value is read per render into the provider context: pass a stable reference.
653
653
  A nested provider that supplies none inherits the enclosing one.
654
654
 
655
+ ### Links
656
+
657
+ The `link` mark's href stands one of four classes (the exported
658
+ `linkHrefKindOf` — the classifier the validator, the renderer, and the
659
+ click's open all stand on):
660
+
661
+ | Class | Example | The click's open |
662
+ | ---------- | ------------------------------------------------ | ------------------------------------ |
663
+ | `web` | `https://example.com/page`, `//example.com/page` | a new tab (`noopener,noreferrer`) |
664
+ | `mailto` | `mailto:help@example.com` | the same tab (the mail client) |
665
+ | `tel` | `tel:+79161234567` | the same tab (the dialer) |
666
+ | `relative` | `/docs/page`, `#section`, `./page` | the same tab (the page's navigation) |
667
+
668
+ The protocol-relative form is an absolute URL of the reader's scheme — the
669
+ `web` class, never a relative path. Any other scheme is rejected by the
670
+ writer (`InvalidMarkError` over the semantic API) and renders as plain text
671
+ over the lenient read.
672
+
673
+ Editing: the format toolbar's link button and mod+k over a text selection
674
+ open the address popover. A typed address resolves by form — a bare domain
675
+ stands `https://`, a bare email the `mailto:` form, a phone number the
676
+ `tel:` form, the protocol-relative form the explicit `https://`; an
677
+ existing uniform link prefills the input, and an invalid address stands the
678
+ error without a write. A commit is one `setMark` (one undo step), the
679
+ remove one `unsetMark`.
680
+
681
+ A plain click on a link opens it (a press-drag keeps the selection; the
682
+ modified and middle clicks keep the browser's native stand). A right-click
683
+ on a link opens the link menu — open, copy the address, edit, remove; the
684
+ read-only modes (`view` / `published`) stand the open and the copy only. A
685
+ plain-text paste links the bare URLs and the email addresses it carries
686
+ (the code blocks keep their raw text); typed text stands plain.
687
+
655
688
  ### Canvas
656
689
 
657
690
  `view: "canvas"` renders the page miniature plus the document's
@@ -23092,8 +23092,10 @@ function removeLink(doc, target) {
23092
23092
  //#region src/editing/link/resolve.ts
23093
23093
  /** The link popover's input's resolution (the smart scheme's inference):
23094
23094
  * the explicit scheme (the `mailto:` / the `tel:` / the web's URL's form)
23095
- * passes over the core's gate as-is; the leading `/` / `#` / `.` stands
23096
- * the relative's form; the email's form (the `@` without the whitespace)
23095
+ * passes over the core's gate as-is; the protocol-relative form (the
23096
+ * leading slash / backslash pair) stands the explicit `https://`'s stand
23097
+ * (the stored href is self-describing — the reader's scheme never decides
23098
+ * it); the leading `/` / `#` / `.` stands the relative's form; the email's form (the `@` without the whitespace)
23097
23099
  * stands the `mailto:`; the phone's form (the digits + the separators, no
23098
23100
  * letters) stands the `tel:`; the bare's form (a domain / a path's text)
23099
23101
  * stands the `https://`'s prefix. `null` stands the rejection (the
@@ -23101,6 +23103,9 @@ function removeLink(doc, target) {
23101
23103
  /** The explicit scheme's prefix (the `mailto:` / the `tel:` / the web's
23102
23104
  * URL's discriminator — the scheme's case-insensitive stand). */
23103
23105
  const SCHEME_PREFIX = /^[a-z][a-z0-9+.-]*:/i;
23106
+ /** The protocol-relative form (the browser's special-scheme's slash /
23107
+ * backslash equivalence — an absolute URL over the reader's scheme). */
23108
+ const PROTOCOL_RELATIVE = /^[/\\]{2}/;
23104
23109
  /** The phone's form: 5–20 characters of digits and the phone's separators
23105
23110
  * (no letters) — the versions' / the dates' tokens stand the https's
23106
23111
  * form over it (the digits' minimum is checked over the call). */
@@ -23112,6 +23117,10 @@ function resolveLinkHref(input) {
23112
23117
  const value = input.trim();
23113
23118
  if (value === "") return null;
23114
23119
  if (SCHEME_PREFIX.test(value)) return isSafeLinkHref(value) ? value : null;
23120
+ if (PROTOCOL_RELATIVE.test(value)) {
23121
+ const web = `https://${value.slice(2)}`;
23122
+ return isSafeLinkHref(web) ? web : null;
23123
+ }
23115
23124
  if (value.startsWith("/") || value.startsWith("#") || value.startsWith(".")) return isSafeLinkHref(value) ? value : null;
23116
23125
  if (value.includes("@") && !/\s/.test(value)) {
23117
23126
  const href = `mailto:${value}`;
@@ -23347,15 +23356,19 @@ function useLinkPopover(rootRef) {
23347
23356
  const suppressTransientSelection = () => {
23348
23357
  selectionRef.reseatUntil.current = Date.now() + LINK_RESEAT_WINDOW_MS;
23349
23358
  };
23359
+ const parkFocusRef = useRef(false);
23350
23360
  const closeAll = useCallback(() => {
23351
23361
  setPopover(null);
23352
23362
  setMenu(null);
23353
23363
  suppressTransientSelection();
23354
- requestAnimationFrame(() => {
23355
- const active = document.activeElement;
23356
- if (active === null || active === document.body) rootRef.current?.focus();
23357
- });
23364
+ parkFocusRef.current = true;
23358
23365
  }, [rootRef, selectionRef]);
23366
+ useEffect(() => {
23367
+ if (!parkFocusRef.current) return;
23368
+ parkFocusRef.current = false;
23369
+ const active = document.activeElement;
23370
+ if (active === null || active === document.body) rootRef.current?.focus();
23371
+ });
23359
23372
  const open = useCallback((anchor, opts) => {
23360
23373
  setMenu(null);
23361
23374
  const view = selectionRef.view;
package/dist/index.d.mts CHANGED
@@ -371,7 +371,7 @@ declare function AlertDescription({ className, ...props }: React$1.ComponentProp
371
371
  //#endregion
372
372
  //#region src/shared/ui/Badge.d.ts
373
373
  declare const badgeVariants: (props?: ({
374
- variant?: "default" | "destructive" | "outline" | "secondary" | "custom" | null | undefined;
374
+ variant?: "default" | "destructive" | "custom" | "secondary" | "outline" | null | undefined;
375
375
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
376
376
  declare function Badge({ className, variant, asChild, ...props }: React$1.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
377
377
  asChild?: boolean;
@@ -382,7 +382,7 @@ declare function BareSelect({ className, children, ...props }: React$1.Component
382
382
  //#endregion
383
383
  //#region src/shared/ui/Button.d.ts
384
384
  declare const buttonVariants: (props?: ({
385
- variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
385
+ variant?: "link" | "default" | "destructive" | "secondary" | "outline" | "ghost" | null | undefined;
386
386
  size?: "default" | "icon" | "sm" | "lg" | "xl" | null | undefined;
387
387
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
388
388
  declare function Button({ className, variant, size, asChild, type, ...props }: React$1.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as DropdownMenuSubContent, $t as Eye, A as SelectGroup, At as Skeleton, B as Input, Bt as useBlock, C as FilterBuilder, Ct as isBridgeError, D as ScrollArea, Dt as parseCellValue, E as SegmentSelector, Et as conditionMatches, F as SelectSeparator, Ft as CardFooter, G as DropdownMenuItem, Gt as useSelection, H as DropdownMenuCheckboxItem, Ht as useMeta, I as SelectTrigger, It as CardHeader, J as DropdownMenuRadioGroup, Jt as DocblocksI18nProvider, K as DropdownMenuLabel, Kt as useSelectionView, L as SelectValue, Lt as CardTitle, M as SelectLabel, Mt as CardAction, N as SelectScrollDownButton, Nt as CardContent, O as Select, Ot as TEXT_TYPES, P as SelectScrollUpButton, Pt as CardDescription, Q as DropdownMenuSub, Qt as Pen, R as Label, Rt as Badge, S as newMutationContext, St as BridgeError, T as filterIsComplete, Tt as toBridgeError, U as DropdownMenuContent, Ut as usePresence, V as DropdownMenu, Vt as useDoc, W as DropdownMenuGroup, Wt as usePresenceSharing, X as DropdownMenuSeparator, Xt as renderRuns, Y as DropdownMenuRadioItem, Z as DropdownMenuShortcut, _ as mapFrontmatter, _t as BASELINE_CAPABILITIES, a as DEFAULT_EMBED_SANDBOX, at as PopoverContent, b as useDatabaseTable, bt as validateProtocolDescriptor, c as SHAPE_FONT_OPTIONS, ct as PopoverTitle, d as FORMAT_PALETTE, dt as Button, et as DropdownMenuSubTrigger, ft as buttonVariants, g as mdToBlocks, gt as AlertTitle, h as insertNative, ht as AlertDescription, i as useEditorContext, it as PopoverAnchor, j as SelectItem, jt as Card, k as SelectContent, kt as columnAnnotation, l as SHAPE_FONT_STACKS, lt as PopoverTrigger, m as htmlToBlocks, mt as Alert, n as useCoverAverageColor, nn as createMemoryBlobStore, nt as Separator, ot as PopoverDescription, p as markToggleAction, pt as BareSelect, q as DropdownMenuPortal, qt as useText, r as EditorProvider, rt as Popover, st as PopoverHeader, t as Editor, tn as BookOpen, tt as DropdownMenuTrigger, ut as Checkbox, v as parseFrontmatter, vt as PROTOCOL_VERSION, w as emptyFilter, wt as isBridgeErrorCode, x as cellValueEqual, xt as BRIDGE_ERROR_CODES, y as GridBody, yt as isDatabaseBridge, z as InlineEditInput, zt as badgeVariants } from "./Editor-BrENM2MV.mjs";
1
+ import { $ as DropdownMenuSubContent, $t as Eye, A as SelectGroup, At as Skeleton, B as Input, Bt as useBlock, C as FilterBuilder, Ct as isBridgeError, D as ScrollArea, Dt as parseCellValue, E as SegmentSelector, Et as conditionMatches, F as SelectSeparator, Ft as CardFooter, G as DropdownMenuItem, Gt as useSelection, H as DropdownMenuCheckboxItem, Ht as useMeta, I as SelectTrigger, It as CardHeader, J as DropdownMenuRadioGroup, Jt as DocblocksI18nProvider, K as DropdownMenuLabel, Kt as useSelectionView, L as SelectValue, Lt as CardTitle, M as SelectLabel, Mt as CardAction, N as SelectScrollDownButton, Nt as CardContent, O as Select, Ot as TEXT_TYPES, P as SelectScrollUpButton, Pt as CardDescription, Q as DropdownMenuSub, Qt as Pen, R as Label, Rt as Badge, S as newMutationContext, St as BridgeError, T as filterIsComplete, Tt as toBridgeError, U as DropdownMenuContent, Ut as usePresence, V as DropdownMenu, Vt as useDoc, W as DropdownMenuGroup, Wt as usePresenceSharing, X as DropdownMenuSeparator, Xt as renderRuns, Y as DropdownMenuRadioItem, Z as DropdownMenuShortcut, _ as mapFrontmatter, _t as BASELINE_CAPABILITIES, a as DEFAULT_EMBED_SANDBOX, at as PopoverContent, b as useDatabaseTable, bt as validateProtocolDescriptor, c as SHAPE_FONT_OPTIONS, ct as PopoverTitle, d as FORMAT_PALETTE, dt as Button, et as DropdownMenuSubTrigger, ft as buttonVariants, g as mdToBlocks, gt as AlertTitle, h as insertNative, ht as AlertDescription, i as useEditorContext, it as PopoverAnchor, j as SelectItem, jt as Card, k as SelectContent, kt as columnAnnotation, l as SHAPE_FONT_STACKS, lt as PopoverTrigger, m as htmlToBlocks, mt as Alert, n as useCoverAverageColor, nn as createMemoryBlobStore, nt as Separator, ot as PopoverDescription, p as markToggleAction, pt as BareSelect, q as DropdownMenuPortal, qt as useText, r as EditorProvider, rt as Popover, st as PopoverHeader, t as Editor, tn as BookOpen, tt as DropdownMenuTrigger, ut as Checkbox, v as parseFrontmatter, vt as PROTOCOL_VERSION, w as emptyFilter, wt as isBridgeErrorCode, x as cellValueEqual, xt as BRIDGE_ERROR_CODES, y as GridBody, yt as isDatabaseBridge, z as InlineEditInput, zt as badgeVariants } from "./Editor-CbHCJZ6R.mjs";
2
2
  import { a as preventDefault, s as cn } from "./constants-D8PSgkwi.mjs";
3
3
  import { useCallback, useEffect, useRef, useState } from "react";
4
4
  import { useTranslation } from "react-i18next";
@@ -1,4 +1,4 @@
1
- import { $t as Eye, At as Skeleton, E as SegmentSelector, Yt as INLINE_CODE_CLASS, Zt as RotateCcw, dt as Button, en as CodeXml, f as textOf, gt as AlertTitle, ht as AlertDescription, i as useEditorContext, mt as Alert, o as childrenSlot, s as CodeHeader, u as TextBlock } from "../Editor-BrENM2MV.mjs";
1
+ import { $t as Eye, At as Skeleton, E as SegmentSelector, Yt as INLINE_CODE_CLASS, Zt as RotateCcw, dt as Button, en as CodeXml, f as textOf, gt as AlertTitle, ht as AlertDescription, i as useEditorContext, mt as Alert, o as childrenSlot, s as CodeHeader, u as TextBlock } from "../Editor-CbHCJZ6R.mjs";
2
2
  import { a as preventDefault, d as Minus, f as LoaderCircle, l as TriangleAlert, r as clamp, u as Plus } from "../constants-D8PSgkwi.mjs";
3
3
  import { t as Maximize } from "../Maximize-BBHnCDWL.mjs";
4
4
  import { useEffect, useRef, useState } from "react";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docblocks-react-ui",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "React rendering + editing layer for docblocks: hooks, block renderers, caret/selection, keyboard, clipboard.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "access": "public"
35
35
  },
36
36
  "peerDependencies": {
37
- "docblocks-core": "^0.7.0",
37
+ "docblocks-core": "^0.8.0",
38
38
  "framer-motion": "^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
39
39
  "mermaid": "^12.0.0",
40
40
  "pdfjs-dist": "^6.0.0",