react-smart-copy 1.6.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -1
- package/dist/core.cjs +317 -12
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +133 -0
- package/dist/core.d.ts +133 -0
- package/dist/core.js +314 -13
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +347 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +159 -1
- package/dist/index.d.ts +159 -1
- package/dist/index.js +343 -13
- package/dist/index.js.map +1 -1
- package/package.json +9 -4
package/dist/index.d.cts
CHANGED
|
@@ -428,6 +428,139 @@ export declare function canRetryState(state: CopyState, maxRetries?: number): bo
|
|
|
428
428
|
/** Framework-agnostic copy state machine. */
|
|
429
429
|
export declare function createCopyMachine(options?: CopyMachineOptionsSource): CopyMachine;
|
|
430
430
|
//#endregion
|
|
431
|
+
//#region src/core/copy-interceptor.d.ts
|
|
432
|
+
/**
|
|
433
|
+
* Native copy interception: rewrite, redact or block what lands on the
|
|
434
|
+
* clipboard when the user copies (Ctrl/Cmd+C, context menu) or cuts inside a
|
|
435
|
+
* scope.
|
|
436
|
+
*
|
|
437
|
+
* Writes go through `event.clipboardData` synchronously, so no permission
|
|
438
|
+
* prompt, no secure-context requirement, and it works in every browser. The
|
|
439
|
+
* price is that only strings can be written, which the types enforce.
|
|
440
|
+
*
|
|
441
|
+
* Not a security boundary: users can still screenshot, use dev tools or
|
|
442
|
+
* disable script. Treat redaction as a guard against accidents.
|
|
443
|
+
*/
|
|
444
|
+
export type InterceptedCopyKind = 'copy' | 'cut';
|
|
445
|
+
export declare const DEFAULT_INTERCEPTED_EVENTS: readonly InterceptedCopyKind[];
|
|
446
|
+
/** The writable slice of `DataTransfer` during a `copy`/`cut` event. */
|
|
447
|
+
export interface ClipboardDataLike {
|
|
448
|
+
setData(format: string, data: string): void;
|
|
449
|
+
clearData?(format?: string): void;
|
|
450
|
+
}
|
|
451
|
+
/** Structural `ClipboardEvent`: DOM and React clipboard events both satisfy it. */
|
|
452
|
+
export interface CopyEventLike {
|
|
453
|
+
readonly type: string;
|
|
454
|
+
readonly target: EventTarget | null;
|
|
455
|
+
readonly clipboardData: ClipboardDataLike | null;
|
|
456
|
+
readonly defaultPrevented: boolean;
|
|
457
|
+
preventDefault(): void;
|
|
458
|
+
}
|
|
459
|
+
/** What the user selected when they copied. */
|
|
460
|
+
export interface CopySelection {
|
|
461
|
+
readonly kind: InterceptedCopyKind;
|
|
462
|
+
/** What the browser would put on the clipboard as `text/plain`. */
|
|
463
|
+
readonly text: string;
|
|
464
|
+
/** Serialised HTML of the selection; `null` inside text inputs. */
|
|
465
|
+
readonly html: string | null;
|
|
466
|
+
/** A detached clone of the selected nodes, safe to mutate; `null` inside text inputs. */
|
|
467
|
+
readonly fragment: DocumentFragment | null;
|
|
468
|
+
/** The `<input>`/`<textarea>` the selection lives in, if any. */
|
|
469
|
+
readonly field: HTMLInputElement | HTMLTextAreaElement | null;
|
|
470
|
+
/** Whether a `cut` would remove the selection (form field or contenteditable). */
|
|
471
|
+
readonly editable: boolean;
|
|
472
|
+
}
|
|
473
|
+
/** A multi payload whose items are all strings; the only kind `setData` accepts. */
|
|
474
|
+
export interface SyncMultiPayload {
|
|
475
|
+
readonly kind: 'multi';
|
|
476
|
+
readonly items: readonly {
|
|
477
|
+
readonly mimeType: string;
|
|
478
|
+
readonly data: string;
|
|
479
|
+
}[];
|
|
480
|
+
}
|
|
481
|
+
/** Payloads writable synchronously during a copy event. Images need the async clipboard. */
|
|
482
|
+
export type SyncCopyPayload = TextPayload | HtmlPayload | JsonPayload | SyncMultiPayload;
|
|
483
|
+
/**
|
|
484
|
+
* What a transform returns:
|
|
485
|
+
* - a string or payload: write that instead of the selection
|
|
486
|
+
* - `false`: block the copy (nothing reaches the clipboard; a cut deletes nothing)
|
|
487
|
+
* - `null` / `undefined`: leave the browser's default copy untouched
|
|
488
|
+
*
|
|
489
|
+
* Must be synchronous: the clipboard closes when the event handler returns.
|
|
490
|
+
*/
|
|
491
|
+
export type CopyInterceptDecision = string | SyncCopyPayload | false | null | undefined;
|
|
492
|
+
export type CopyInterceptTransform = (selection: CopySelection) => CopyInterceptDecision;
|
|
493
|
+
/**
|
|
494
|
+
* When the transform throws or returns something unwritable:
|
|
495
|
+
* - `'block'` (default): nothing is copied. Safe for redaction.
|
|
496
|
+
* - `'native'`: the browser's default copy proceeds unmodified.
|
|
497
|
+
*/
|
|
498
|
+
export type CopyInterceptFailureMode = 'block' | 'native';
|
|
499
|
+
export interface CopyInterceptOptions {
|
|
500
|
+
readonly transform: CopyInterceptTransform;
|
|
501
|
+
readonly failureMode?: CopyInterceptFailureMode;
|
|
502
|
+
}
|
|
503
|
+
export type CopyInterceptPassReason =
|
|
504
|
+
/** Not a `copy`/`cut` event. */
|
|
505
|
+
'unsupported-event' |
|
|
506
|
+
/** Another handler already called `preventDefault()`. */
|
|
507
|
+
'already-handled' |
|
|
508
|
+
/** Nothing readable was selected. */
|
|
509
|
+
'no-selection' |
|
|
510
|
+
/** The transform returned `null`/`undefined`. */
|
|
511
|
+
'declined';
|
|
512
|
+
export type CopyInterceptOutcome = {
|
|
513
|
+
readonly status: 'passed';
|
|
514
|
+
readonly reason: CopyInterceptPassReason;
|
|
515
|
+
readonly selection: CopySelection | null;
|
|
516
|
+
} | {
|
|
517
|
+
readonly status: 'written';
|
|
518
|
+
readonly selection: CopySelection;
|
|
519
|
+
readonly payload: SyncCopyPayload;
|
|
520
|
+
/** For an editable `cut`: whether the selection was removed. Always `false` for `copy`. */
|
|
521
|
+
readonly deleted: boolean;
|
|
522
|
+
} | {
|
|
523
|
+
readonly status: 'blocked';
|
|
524
|
+
readonly selection: CopySelection;
|
|
525
|
+
} | {
|
|
526
|
+
readonly status: 'failed';
|
|
527
|
+
readonly selection: CopySelection;
|
|
528
|
+
readonly error: CopyError;
|
|
529
|
+
/** What actually happened to the copy. */
|
|
530
|
+
readonly fallback: CopyInterceptFailureMode;
|
|
531
|
+
};
|
|
532
|
+
/** Reads the selection behind a copy event, or `null` if nothing readable is selected. */
|
|
533
|
+
export declare function readCopySelection(event: CopyEventLike): CopySelection | null;
|
|
534
|
+
/**
|
|
535
|
+
* Applies a transform to one `copy`/`cut` event. Use directly from an
|
|
536
|
+
* `onCopy` handler, or let {@link registerCopyInterceptor} scope it.
|
|
537
|
+
*/
|
|
538
|
+
export declare function interceptCopyEvent(event: CopyEventLike, options: CopyInterceptOptions): CopyInterceptOutcome;
|
|
539
|
+
export interface CopyInterceptorOptions extends CopyInterceptOptions {
|
|
540
|
+
/**
|
|
541
|
+
* When one selection touches several scopes, exactly one handles it: the
|
|
542
|
+
* highest `priority`, then the innermost, then the first in the document.
|
|
543
|
+
* The winner sees the *whole* selection. Give redaction scopes a higher
|
|
544
|
+
* priority so text copied across them is always masked. Default `0`.
|
|
545
|
+
*/
|
|
546
|
+
readonly priority?: number;
|
|
547
|
+
/** Which events to intercept. Default: both `copy` and `cut`. */
|
|
548
|
+
readonly events?: readonly InterceptedCopyKind[];
|
|
549
|
+
/** Every outcome for selections inside this scope, including `passed`. */
|
|
550
|
+
readonly onIntercept?: (outcome: CopyInterceptOutcome) => void;
|
|
551
|
+
/** Called when the transform failed; the outcome's `fallback` says what happened to the copy. */
|
|
552
|
+
readonly onError?: (error: CopyError) => void;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Intercepts native copies and cuts whose selection touches `root`. Returns
|
|
556
|
+
* an unsubscribe function. Pass a getter to always read the latest options.
|
|
557
|
+
*
|
|
558
|
+
* One listener per document serves every scope, so overlapping scopes
|
|
559
|
+
* resolve deterministically (see `priority`) regardless of registration order.
|
|
560
|
+
* Handlers that call `preventDefault()` first (e.g. a React `onCopy`) win.
|
|
561
|
+
*/
|
|
562
|
+
export declare function registerCopyInterceptor(root: Element, options: CopyInterceptorOptions | (() => CopyInterceptorOptions)): () => void;
|
|
563
|
+
//#endregion
|
|
431
564
|
//#region src/core/paste-adapter.d.ts
|
|
432
565
|
/** Minimal structural view of `navigator.clipboard` for reading. */
|
|
433
566
|
interface PasteClipboardLike {
|
|
@@ -612,6 +745,31 @@ interface UseCopyResult {
|
|
|
612
745
|
*/
|
|
613
746
|
export declare function useCopy(options?: UseCopyOptions): UseCopyResult;
|
|
614
747
|
//#endregion
|
|
748
|
+
//#region src/react/useCopyInterceptor.d.ts
|
|
749
|
+
interface UseCopyInterceptorOptions extends CopyInterceptorOptions {
|
|
750
|
+
/** Set `false` to stop intercepting without unmounting. Default `true`. */
|
|
751
|
+
readonly enabled?: boolean;
|
|
752
|
+
}
|
|
753
|
+
interface UseCopyInterceptorResult<T extends Element> {
|
|
754
|
+
/** Attach to the element whose content you want to control. */
|
|
755
|
+
readonly ref: RefCallback<T>;
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Rewrites, redacts or blocks native copies (Ctrl/Cmd+C, context menu) and
|
|
759
|
+
* cuts whose selection touches the referenced element.
|
|
760
|
+
*
|
|
761
|
+
* ```tsx
|
|
762
|
+
* const { ref } = useCopyInterceptor<HTMLElement>({
|
|
763
|
+
* transform: ({ text }) => `${text}\n\nSource: ${location.href}`,
|
|
764
|
+
* });
|
|
765
|
+
* return <article ref={ref}>…</article>;
|
|
766
|
+
* ```
|
|
767
|
+
*
|
|
768
|
+
* The transform runs synchronously inside the event and always sees the
|
|
769
|
+
* latest props; changing it never re-subscribes. SSR-safe.
|
|
770
|
+
*/
|
|
771
|
+
export declare function useCopyInterceptor<T extends Element = HTMLElement>(options: UseCopyInterceptorOptions): UseCopyInterceptorResult<T>;
|
|
772
|
+
//#endregion
|
|
615
773
|
//#region src/react/useRevealOnInteraction.d.ts
|
|
616
774
|
/** Why the target is currently revealed, in priority order. */
|
|
617
775
|
type RevealReason = 'forced' | 'focus' | 'hover' | 'touch' | 'no-hover-device';
|
|
@@ -979,5 +1137,5 @@ export declare const PasteField: {
|
|
|
979
1137
|
readonly Preview: import("react").ForwardRefExoticComponent<PasteFieldPreviewProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
980
1138
|
};
|
|
981
1139
|
//#endregion
|
|
982
|
-
export type { BrowserPasteAdapterOptions, ClipboardItemLike, CopyFieldContextValue, CopyFieldLabelProps, CopyFieldMessages, CopyFieldRootProps, CopyFieldTriggerProps, CopyFieldTriggerRenderProps, CopyFieldValueProps, CopyGroupProps, DataTransferItemLike, DataTransferLike, LiveRegionProps, OperationContext, PasteAccept, PasteAcceptShorthand, PasteAdapter, PasteClipboardLike, PasteDropTargetProps, PasteEnvironment, PasteFieldContextValue, PasteFieldLabelProps, PasteFieldMessages, PasteFieldPreviewProps, PasteFieldPreviewRenderProps, PasteFieldRootProps, PasteFieldStatusProps, PasteFieldTriggerProps, PasteFieldTriggerRenderProps, PasteFieldZoneProps, PasteItem, PasteLimits, PasteReadOptions, PasteReadResult, PasteResult, PasteSource, PasteTargetProps, ResolvedPasteReadOptions, RevealReason, RevealTargetProps, UseCopyOptions, UseCopyResult, UseDisplayStatusOptions, UsePasteDisplayStatusOptions, UsePasteOptions, UsePasteResult, UseRevealOnInteractionOptions, UseRevealOnInteractionResult };
|
|
1140
|
+
export type { BrowserPasteAdapterOptions, ClipboardItemLike, CopyFieldContextValue, CopyFieldLabelProps, CopyFieldMessages, CopyFieldRootProps, CopyFieldTriggerProps, CopyFieldTriggerRenderProps, CopyFieldValueProps, CopyGroupProps, DataTransferItemLike, DataTransferLike, LiveRegionProps, OperationContext, PasteAccept, PasteAcceptShorthand, PasteAdapter, PasteClipboardLike, PasteDropTargetProps, PasteEnvironment, PasteFieldContextValue, PasteFieldLabelProps, PasteFieldMessages, PasteFieldPreviewProps, PasteFieldPreviewRenderProps, PasteFieldRootProps, PasteFieldStatusProps, PasteFieldTriggerProps, PasteFieldTriggerRenderProps, PasteFieldZoneProps, PasteItem, PasteLimits, PasteReadOptions, PasteReadResult, PasteResult, PasteSource, PasteTargetProps, ResolvedPasteReadOptions, RevealReason, RevealTargetProps, UseCopyInterceptorOptions, UseCopyInterceptorResult, UseCopyOptions, UseCopyResult, UseDisplayStatusOptions, UsePasteDisplayStatusOptions, UsePasteOptions, UsePasteResult, UseRevealOnInteractionOptions, UseRevealOnInteractionResult };
|
|
983
1141
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -428,6 +428,139 @@ export declare function canRetryState(state: CopyState, maxRetries?: number): bo
|
|
|
428
428
|
/** Framework-agnostic copy state machine. */
|
|
429
429
|
export declare function createCopyMachine(options?: CopyMachineOptionsSource): CopyMachine;
|
|
430
430
|
//#endregion
|
|
431
|
+
//#region src/core/copy-interceptor.d.ts
|
|
432
|
+
/**
|
|
433
|
+
* Native copy interception: rewrite, redact or block what lands on the
|
|
434
|
+
* clipboard when the user copies (Ctrl/Cmd+C, context menu) or cuts inside a
|
|
435
|
+
* scope.
|
|
436
|
+
*
|
|
437
|
+
* Writes go through `event.clipboardData` synchronously, so no permission
|
|
438
|
+
* prompt, no secure-context requirement, and it works in every browser. The
|
|
439
|
+
* price is that only strings can be written, which the types enforce.
|
|
440
|
+
*
|
|
441
|
+
* Not a security boundary: users can still screenshot, use dev tools or
|
|
442
|
+
* disable script. Treat redaction as a guard against accidents.
|
|
443
|
+
*/
|
|
444
|
+
export type InterceptedCopyKind = 'copy' | 'cut';
|
|
445
|
+
export declare const DEFAULT_INTERCEPTED_EVENTS: readonly InterceptedCopyKind[];
|
|
446
|
+
/** The writable slice of `DataTransfer` during a `copy`/`cut` event. */
|
|
447
|
+
export interface ClipboardDataLike {
|
|
448
|
+
setData(format: string, data: string): void;
|
|
449
|
+
clearData?(format?: string): void;
|
|
450
|
+
}
|
|
451
|
+
/** Structural `ClipboardEvent`: DOM and React clipboard events both satisfy it. */
|
|
452
|
+
export interface CopyEventLike {
|
|
453
|
+
readonly type: string;
|
|
454
|
+
readonly target: EventTarget | null;
|
|
455
|
+
readonly clipboardData: ClipboardDataLike | null;
|
|
456
|
+
readonly defaultPrevented: boolean;
|
|
457
|
+
preventDefault(): void;
|
|
458
|
+
}
|
|
459
|
+
/** What the user selected when they copied. */
|
|
460
|
+
export interface CopySelection {
|
|
461
|
+
readonly kind: InterceptedCopyKind;
|
|
462
|
+
/** What the browser would put on the clipboard as `text/plain`. */
|
|
463
|
+
readonly text: string;
|
|
464
|
+
/** Serialised HTML of the selection; `null` inside text inputs. */
|
|
465
|
+
readonly html: string | null;
|
|
466
|
+
/** A detached clone of the selected nodes, safe to mutate; `null` inside text inputs. */
|
|
467
|
+
readonly fragment: DocumentFragment | null;
|
|
468
|
+
/** The `<input>`/`<textarea>` the selection lives in, if any. */
|
|
469
|
+
readonly field: HTMLInputElement | HTMLTextAreaElement | null;
|
|
470
|
+
/** Whether a `cut` would remove the selection (form field or contenteditable). */
|
|
471
|
+
readonly editable: boolean;
|
|
472
|
+
}
|
|
473
|
+
/** A multi payload whose items are all strings; the only kind `setData` accepts. */
|
|
474
|
+
export interface SyncMultiPayload {
|
|
475
|
+
readonly kind: 'multi';
|
|
476
|
+
readonly items: readonly {
|
|
477
|
+
readonly mimeType: string;
|
|
478
|
+
readonly data: string;
|
|
479
|
+
}[];
|
|
480
|
+
}
|
|
481
|
+
/** Payloads writable synchronously during a copy event. Images need the async clipboard. */
|
|
482
|
+
export type SyncCopyPayload = TextPayload | HtmlPayload | JsonPayload | SyncMultiPayload;
|
|
483
|
+
/**
|
|
484
|
+
* What a transform returns:
|
|
485
|
+
* - a string or payload: write that instead of the selection
|
|
486
|
+
* - `false`: block the copy (nothing reaches the clipboard; a cut deletes nothing)
|
|
487
|
+
* - `null` / `undefined`: leave the browser's default copy untouched
|
|
488
|
+
*
|
|
489
|
+
* Must be synchronous: the clipboard closes when the event handler returns.
|
|
490
|
+
*/
|
|
491
|
+
export type CopyInterceptDecision = string | SyncCopyPayload | false | null | undefined;
|
|
492
|
+
export type CopyInterceptTransform = (selection: CopySelection) => CopyInterceptDecision;
|
|
493
|
+
/**
|
|
494
|
+
* When the transform throws or returns something unwritable:
|
|
495
|
+
* - `'block'` (default): nothing is copied. Safe for redaction.
|
|
496
|
+
* - `'native'`: the browser's default copy proceeds unmodified.
|
|
497
|
+
*/
|
|
498
|
+
export type CopyInterceptFailureMode = 'block' | 'native';
|
|
499
|
+
export interface CopyInterceptOptions {
|
|
500
|
+
readonly transform: CopyInterceptTransform;
|
|
501
|
+
readonly failureMode?: CopyInterceptFailureMode;
|
|
502
|
+
}
|
|
503
|
+
export type CopyInterceptPassReason =
|
|
504
|
+
/** Not a `copy`/`cut` event. */
|
|
505
|
+
'unsupported-event' |
|
|
506
|
+
/** Another handler already called `preventDefault()`. */
|
|
507
|
+
'already-handled' |
|
|
508
|
+
/** Nothing readable was selected. */
|
|
509
|
+
'no-selection' |
|
|
510
|
+
/** The transform returned `null`/`undefined`. */
|
|
511
|
+
'declined';
|
|
512
|
+
export type CopyInterceptOutcome = {
|
|
513
|
+
readonly status: 'passed';
|
|
514
|
+
readonly reason: CopyInterceptPassReason;
|
|
515
|
+
readonly selection: CopySelection | null;
|
|
516
|
+
} | {
|
|
517
|
+
readonly status: 'written';
|
|
518
|
+
readonly selection: CopySelection;
|
|
519
|
+
readonly payload: SyncCopyPayload;
|
|
520
|
+
/** For an editable `cut`: whether the selection was removed. Always `false` for `copy`. */
|
|
521
|
+
readonly deleted: boolean;
|
|
522
|
+
} | {
|
|
523
|
+
readonly status: 'blocked';
|
|
524
|
+
readonly selection: CopySelection;
|
|
525
|
+
} | {
|
|
526
|
+
readonly status: 'failed';
|
|
527
|
+
readonly selection: CopySelection;
|
|
528
|
+
readonly error: CopyError;
|
|
529
|
+
/** What actually happened to the copy. */
|
|
530
|
+
readonly fallback: CopyInterceptFailureMode;
|
|
531
|
+
};
|
|
532
|
+
/** Reads the selection behind a copy event, or `null` if nothing readable is selected. */
|
|
533
|
+
export declare function readCopySelection(event: CopyEventLike): CopySelection | null;
|
|
534
|
+
/**
|
|
535
|
+
* Applies a transform to one `copy`/`cut` event. Use directly from an
|
|
536
|
+
* `onCopy` handler, or let {@link registerCopyInterceptor} scope it.
|
|
537
|
+
*/
|
|
538
|
+
export declare function interceptCopyEvent(event: CopyEventLike, options: CopyInterceptOptions): CopyInterceptOutcome;
|
|
539
|
+
export interface CopyInterceptorOptions extends CopyInterceptOptions {
|
|
540
|
+
/**
|
|
541
|
+
* When one selection touches several scopes, exactly one handles it: the
|
|
542
|
+
* highest `priority`, then the innermost, then the first in the document.
|
|
543
|
+
* The winner sees the *whole* selection. Give redaction scopes a higher
|
|
544
|
+
* priority so text copied across them is always masked. Default `0`.
|
|
545
|
+
*/
|
|
546
|
+
readonly priority?: number;
|
|
547
|
+
/** Which events to intercept. Default: both `copy` and `cut`. */
|
|
548
|
+
readonly events?: readonly InterceptedCopyKind[];
|
|
549
|
+
/** Every outcome for selections inside this scope, including `passed`. */
|
|
550
|
+
readonly onIntercept?: (outcome: CopyInterceptOutcome) => void;
|
|
551
|
+
/** Called when the transform failed; the outcome's `fallback` says what happened to the copy. */
|
|
552
|
+
readonly onError?: (error: CopyError) => void;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Intercepts native copies and cuts whose selection touches `root`. Returns
|
|
556
|
+
* an unsubscribe function. Pass a getter to always read the latest options.
|
|
557
|
+
*
|
|
558
|
+
* One listener per document serves every scope, so overlapping scopes
|
|
559
|
+
* resolve deterministically (see `priority`) regardless of registration order.
|
|
560
|
+
* Handlers that call `preventDefault()` first (e.g. a React `onCopy`) win.
|
|
561
|
+
*/
|
|
562
|
+
export declare function registerCopyInterceptor(root: Element, options: CopyInterceptorOptions | (() => CopyInterceptorOptions)): () => void;
|
|
563
|
+
//#endregion
|
|
431
564
|
//#region src/core/paste-adapter.d.ts
|
|
432
565
|
/** Minimal structural view of `navigator.clipboard` for reading. */
|
|
433
566
|
interface PasteClipboardLike {
|
|
@@ -612,6 +745,31 @@ interface UseCopyResult {
|
|
|
612
745
|
*/
|
|
613
746
|
export declare function useCopy(options?: UseCopyOptions): UseCopyResult;
|
|
614
747
|
//#endregion
|
|
748
|
+
//#region src/react/useCopyInterceptor.d.ts
|
|
749
|
+
interface UseCopyInterceptorOptions extends CopyInterceptorOptions {
|
|
750
|
+
/** Set `false` to stop intercepting without unmounting. Default `true`. */
|
|
751
|
+
readonly enabled?: boolean;
|
|
752
|
+
}
|
|
753
|
+
interface UseCopyInterceptorResult<T extends Element> {
|
|
754
|
+
/** Attach to the element whose content you want to control. */
|
|
755
|
+
readonly ref: RefCallback<T>;
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Rewrites, redacts or blocks native copies (Ctrl/Cmd+C, context menu) and
|
|
759
|
+
* cuts whose selection touches the referenced element.
|
|
760
|
+
*
|
|
761
|
+
* ```tsx
|
|
762
|
+
* const { ref } = useCopyInterceptor<HTMLElement>({
|
|
763
|
+
* transform: ({ text }) => `${text}\n\nSource: ${location.href}`,
|
|
764
|
+
* });
|
|
765
|
+
* return <article ref={ref}>…</article>;
|
|
766
|
+
* ```
|
|
767
|
+
*
|
|
768
|
+
* The transform runs synchronously inside the event and always sees the
|
|
769
|
+
* latest props; changing it never re-subscribes. SSR-safe.
|
|
770
|
+
*/
|
|
771
|
+
export declare function useCopyInterceptor<T extends Element = HTMLElement>(options: UseCopyInterceptorOptions): UseCopyInterceptorResult<T>;
|
|
772
|
+
//#endregion
|
|
615
773
|
//#region src/react/useRevealOnInteraction.d.ts
|
|
616
774
|
/** Why the target is currently revealed, in priority order. */
|
|
617
775
|
type RevealReason = 'forced' | 'focus' | 'hover' | 'touch' | 'no-hover-device';
|
|
@@ -979,5 +1137,5 @@ export declare const PasteField: {
|
|
|
979
1137
|
readonly Preview: import("react").ForwardRefExoticComponent<PasteFieldPreviewProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
980
1138
|
};
|
|
981
1139
|
//#endregion
|
|
982
|
-
export type { BrowserPasteAdapterOptions, ClipboardItemLike, CopyFieldContextValue, CopyFieldLabelProps, CopyFieldMessages, CopyFieldRootProps, CopyFieldTriggerProps, CopyFieldTriggerRenderProps, CopyFieldValueProps, CopyGroupProps, DataTransferItemLike, DataTransferLike, LiveRegionProps, OperationContext, PasteAccept, PasteAcceptShorthand, PasteAdapter, PasteClipboardLike, PasteDropTargetProps, PasteEnvironment, PasteFieldContextValue, PasteFieldLabelProps, PasteFieldMessages, PasteFieldPreviewProps, PasteFieldPreviewRenderProps, PasteFieldRootProps, PasteFieldStatusProps, PasteFieldTriggerProps, PasteFieldTriggerRenderProps, PasteFieldZoneProps, PasteItem, PasteLimits, PasteReadOptions, PasteReadResult, PasteResult, PasteSource, PasteTargetProps, ResolvedPasteReadOptions, RevealReason, RevealTargetProps, UseCopyOptions, UseCopyResult, UseDisplayStatusOptions, UsePasteDisplayStatusOptions, UsePasteOptions, UsePasteResult, UseRevealOnInteractionOptions, UseRevealOnInteractionResult };
|
|
1140
|
+
export type { BrowserPasteAdapterOptions, ClipboardItemLike, CopyFieldContextValue, CopyFieldLabelProps, CopyFieldMessages, CopyFieldRootProps, CopyFieldTriggerProps, CopyFieldTriggerRenderProps, CopyFieldValueProps, CopyGroupProps, DataTransferItemLike, DataTransferLike, LiveRegionProps, OperationContext, PasteAccept, PasteAcceptShorthand, PasteAdapter, PasteClipboardLike, PasteDropTargetProps, PasteEnvironment, PasteFieldContextValue, PasteFieldLabelProps, PasteFieldMessages, PasteFieldPreviewProps, PasteFieldPreviewRenderProps, PasteFieldRootProps, PasteFieldStatusProps, PasteFieldTriggerProps, PasteFieldTriggerRenderProps, PasteFieldZoneProps, PasteItem, PasteLimits, PasteReadOptions, PasteReadResult, PasteResult, PasteSource, PasteTargetProps, ResolvedPasteReadOptions, RevealReason, RevealTargetProps, UseCopyInterceptorOptions, UseCopyInterceptorResult, UseCopyOptions, UseCopyResult, UseDisplayStatusOptions, UsePasteDisplayStatusOptions, UsePasteOptions, UsePasteResult, UseRevealOnInteractionOptions, UseRevealOnInteractionResult };
|
|
983
1141
|
//# sourceMappingURL=index.d.ts.map
|