react-smart-copy 1.17.2 → 1.18.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/README.md +9 -3
- package/dist/capture.cjs +30 -153
- package/dist/capture.cjs.map +1 -1
- package/dist/capture.d.cts +2 -25
- package/dist/capture.d.ts +2 -25
- package/dist/capture.js +5 -128
- package/dist/capture.js.map +1 -1
- package/dist/chunks/clipboard-adapter-Cfz-rzw3.cjs +102 -0
- package/dist/chunks/clipboard-adapter-Cfz-rzw3.cjs.map +1 -0
- package/dist/chunks/clipboard-adapter-CtH4VELE.d.cts +43 -0
- package/dist/chunks/clipboard-adapter-DEXkXxwV.js +97 -0
- package/dist/chunks/clipboard-adapter-DEXkXxwV.js.map +1 -0
- package/dist/chunks/clipboard-adapter-Ds0irroN.d.ts +43 -0
- package/dist/chunks/contrast-C6CVklEI.cjs +842 -0
- package/dist/chunks/contrast-C6CVklEI.cjs.map +1 -0
- package/dist/chunks/contrast-DpK2JIVu.js +789 -0
- package/dist/chunks/contrast-DpK2JIVu.js.map +1 -0
- package/dist/chunks/copy-interceptor-C6NABy1l.d.ts +141 -0
- package/dist/chunks/copy-interceptor-CZWzGOkL.d.cts +141 -0
- package/dist/chunks/core-Cp2HSpaz.js +1035 -0
- package/dist/chunks/core-Cp2HSpaz.js.map +1 -0
- package/dist/chunks/core-DYf_Lhbe.cjs +1142 -0
- package/dist/chunks/core-DYf_Lhbe.cjs.map +1 -0
- package/dist/chunks/deadline-C29AlS_Q.js +46 -0
- package/dist/chunks/deadline-C29AlS_Q.js.map +1 -0
- package/dist/chunks/deadline-DkiB8ZHE.cjs +51 -0
- package/dist/chunks/deadline-DkiB8ZHE.cjs.map +1 -0
- package/dist/chunks/errors-9h8sdFFX.js +120 -0
- package/dist/chunks/errors-9h8sdFFX.js.map +1 -0
- package/dist/chunks/errors-BwOF6T_M.cjs +167 -0
- package/dist/chunks/errors-BwOF6T_M.cjs.map +1 -0
- package/dist/chunks/index-mr7sSAgP.d.ts +426 -0
- package/dist/chunks/index-vz0iW5V2.d.cts +426 -0
- package/dist/chunks/mime--LB7kdqG.cjs +153 -0
- package/dist/chunks/mime--LB7kdqG.cjs.map +1 -0
- package/dist/chunks/mime-aa-HA2dm.js +100 -0
- package/dist/chunks/mime-aa-HA2dm.js.map +1 -0
- package/dist/chunks/paste-adapter--SPL4PRE.d.cts +35 -0
- package/dist/chunks/paste-adapter-uahXnTYk.d.ts +35 -0
- package/dist/chunks/paste-reader-Bo01IMC_.cjs +289 -0
- package/dist/chunks/paste-reader-Bo01IMC_.cjs.map +1 -0
- package/dist/chunks/paste-reader-D9i7yMXF.js +224 -0
- package/dist/chunks/paste-reader-D9i7yMXF.js.map +1 -0
- package/dist/chunks/paste-reader-DcXnRWQr.d.cts +96 -0
- package/dist/chunks/paste-reader-DcXnRWQr.d.ts +96 -0
- package/dist/chunks/payload-CUymxwim.cjs +100 -0
- package/dist/chunks/payload-CUymxwim.cjs.map +1 -0
- package/dist/chunks/payload-CcwKJ_bU.d.cts +162 -0
- package/dist/chunks/payload-Cl_8hCI5.d.ts +162 -0
- package/dist/chunks/payload-DGw-JOo7.js +71 -0
- package/dist/chunks/payload-DGw-JOo7.js.map +1 -0
- package/dist/chunks/payload-DI5AorDz.js +103 -0
- package/dist/chunks/payload-DI5AorDz.js.map +1 -0
- package/dist/chunks/payload-J6GjHuh3.cjs +132 -0
- package/dist/chunks/payload-J6GjHuh3.cjs.map +1 -0
- package/dist/chunks/share-Bop47Znn.js +208 -0
- package/dist/chunks/share-Bop47Znn.js.map +1 -0
- package/dist/chunks/share-C0esXvRK.d.cts +115 -0
- package/dist/chunks/share-ayDz974N.cjs +231 -0
- package/dist/chunks/share-ayDz974N.cjs.map +1 -0
- package/dist/chunks/share-e7FenIr2.d.ts +115 -0
- package/dist/chunks/text-field-Ba8W3v4R.cjs +77 -0
- package/dist/chunks/text-field-Ba8W3v4R.cjs.map +1 -0
- package/dist/chunks/text-field-C0SGmvvR.d.cts +18 -0
- package/dist/chunks/text-field-C0SGmvvR.d.ts +18 -0
- package/dist/chunks/text-field-DUvrMMaK.js +66 -0
- package/dist/chunks/text-field-DUvrMMaK.js.map +1 -0
- package/dist/chunks/url-BcMYVCXQ.js +135 -0
- package/dist/chunks/url-BcMYVCXQ.js.map +1 -0
- package/dist/chunks/url-D4PGsRm8.cjs +164 -0
- package/dist/chunks/url-D4PGsRm8.cjs.map +1 -0
- package/dist/chunks/url-DWdElCT3.d.cts +43 -0
- package/dist/chunks/url-DWdElCT3.d.ts +43 -0
- package/dist/code.cjs +20 -112
- package/dist/code.cjs.map +1 -1
- package/dist/code.d.cts +4 -28
- package/dist/code.d.ts +4 -28
- package/dist/code.js +3 -95
- package/dist/code.js.map +1 -1
- package/dist/color.cjs +21 -893
- package/dist/color.cjs.map +1 -1
- package/dist/color.d.cts +4 -28
- package/dist/color.d.ts +4 -28
- package/dist/color.js +4 -876
- package/dist/color.js.map +1 -1
- package/dist/core.cjs +52 -1659
- package/dist/core.d.cts +8 -878
- package/dist/core.d.ts +8 -878
- package/dist/core.js +7 -1614
- package/dist/image.cjs +23 -94
- package/dist/image.cjs.map +1 -1
- package/dist/image.d.cts +1 -0
- package/dist/image.d.ts +1 -0
- package/dist/image.js +3 -74
- package/dist/image.js.map +1 -1
- package/dist/index.cjs +74 -2072
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -978
- package/dist/index.d.ts +8 -978
- package/dist/index.js +7 -2005
- package/dist/index.js.map +1 -1
- package/dist/link.cjs +24 -338
- package/dist/link.cjs.map +1 -1
- package/dist/link.d.cts +5 -83
- package/dist/link.d.ts +5 -83
- package/dist/link.js +5 -319
- package/dist/link.js.map +1 -1
- package/dist/markdown.cjs +8 -97
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.d.cts +3 -16
- package/dist/markdown.d.ts +3 -16
- package/dist/markdown.js +3 -92
- package/dist/markdown.js.map +1 -1
- package/dist/rich.cjs +26 -934
- package/dist/rich.cjs.map +1 -1
- package/dist/rich.d.cts +4 -90
- package/dist/rich.d.ts +4 -90
- package/dist/rich.js +4 -912
- package/dist/rich.js.map +1 -1
- package/dist/share.cjs +5 -640
- package/dist/share.d.cts +3 -248
- package/dist/share.d.ts +3 -248
- package/dist/share.js +1 -637
- package/dist/structured.cjs +13 -95
- package/dist/structured.cjs.map +1 -1
- package/dist/structured.d.cts +2 -11
- package/dist/structured.d.ts +2 -11
- package/dist/structured.js +4 -86
- package/dist/structured.js.map +1 -1
- package/dist/table.cjs +11 -39
- package/dist/table.cjs.map +1 -1
- package/dist/table.d.cts +2 -12
- package/dist/table.d.ts +2 -12
- package/dist/table.js +2 -30
- package/dist/table.js.map +1 -1
- package/dist/testing.cjs +10 -43
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +6 -181
- package/dist/testing.d.ts +6 -181
- package/dist/testing.js +3 -36
- package/dist/testing.js.map +1 -1
- package/package.json +20 -2
- package/dist/core.cjs.map +0 -1
- package/dist/core.js.map +0 -1
- package/dist/share.cjs.map +0 -1
- package/dist/share.js.map +0 -1
package/dist/rich.d.cts
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* `utm_`), or regular expressions tested against the name. Default {@link TRACKING_PARAMETERS}.
|
|
6
|
-
*/
|
|
7
|
-
readonly params?: readonly (string | RegExp)[];
|
|
8
|
-
/** Parameters never removed, even when `params` matches them. */
|
|
9
|
-
readonly keep?: readonly string[];
|
|
10
|
-
}
|
|
11
|
-
interface LinkUrlOptions {
|
|
12
|
-
/** Resolves relative links. Default: the page's address in a browser; required elsewhere for relative links. */
|
|
13
|
-
readonly base?: string | URL;
|
|
14
|
-
/** Allowed schemes, with the colon. Default {@link DEFAULT_LINK_PROTOCOLS}. */
|
|
15
|
-
readonly protocols?: readonly string[];
|
|
16
|
-
/** Remove tracking parameters: `true` for {@link TRACKING_PARAMETERS}, or your own list. Default `false`. */
|
|
17
|
-
readonly clean?: boolean | CleanLinkOptions;
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
1
|
+
|
|
2
|
+
import { o as HtmlPayload } from "./chunks/payload-CcwKJ_bU.cjs";
|
|
3
|
+
import { c as CopyInterceptTransform } from "./chunks/copy-interceptor-CZWzGOkL.cjs";
|
|
4
|
+
import { r as LinkUrlOptions } from "./chunks/url-DWdElCT3.cjs";
|
|
20
5
|
//#region src/rich/style.d.ts
|
|
21
6
|
/** Where styles come from: `getComputedStyle` for a live element, the `style` attribute otherwise. */
|
|
22
7
|
interface StyleSource {
|
|
@@ -109,77 +94,6 @@ type RichSource = Element | DocumentFragment | Range | string;
|
|
|
109
94
|
*/
|
|
110
95
|
export declare function prepareRich(source: RichSource, options?: RichOptions): RichResult;
|
|
111
96
|
//#endregion
|
|
112
|
-
//#region src/core/payload.d.ts
|
|
113
|
-
interface TextPayload {
|
|
114
|
-
readonly kind: 'text';
|
|
115
|
-
readonly value: string;
|
|
116
|
-
}
|
|
117
|
-
interface HtmlPayload {
|
|
118
|
-
readonly kind: 'html';
|
|
119
|
-
readonly html: string;
|
|
120
|
-
/** Required plain-text fallback for targets that don't understand HTML. */
|
|
121
|
-
readonly text: string;
|
|
122
|
-
}
|
|
123
|
-
interface JsonPayload {
|
|
124
|
-
readonly kind: 'json';
|
|
125
|
-
readonly value: unknown;
|
|
126
|
-
/** `true` = 2-space indent, a number = that indent, falsy = compact. */
|
|
127
|
-
readonly pretty?: boolean | number;
|
|
128
|
-
}
|
|
129
|
-
//#endregion
|
|
130
|
-
//#region src/core/copy-interceptor.d.ts
|
|
131
|
-
/**
|
|
132
|
-
* Native copy interception: rewrite, redact or block what lands on the
|
|
133
|
-
* clipboard when the user copies (Ctrl/Cmd+C, context menu) or cuts inside a
|
|
134
|
-
* scope.
|
|
135
|
-
*
|
|
136
|
-
* Writes go through `event.clipboardData` synchronously, so no permission
|
|
137
|
-
* prompt, no secure-context requirement, and it works in every browser. The
|
|
138
|
-
* price is that only strings can be written, which the types enforce.
|
|
139
|
-
*
|
|
140
|
-
* Not a security boundary: users can still screenshot, use dev tools or
|
|
141
|
-
* disable script. Treat redaction as a guard against accidents.
|
|
142
|
-
*/
|
|
143
|
-
type InterceptedCopyKind = 'copy' | 'cut';
|
|
144
|
-
/** What the user selected when they copied. */
|
|
145
|
-
interface CopySelection {
|
|
146
|
-
readonly kind: InterceptedCopyKind;
|
|
147
|
-
/** What the browser would put on the clipboard as `text/plain`. */
|
|
148
|
-
readonly text: string;
|
|
149
|
-
/** Serialised HTML of the selection; `null` inside text inputs. */
|
|
150
|
-
readonly html: string | null;
|
|
151
|
-
/** A detached clone of the selected nodes, safe to mutate; `null` inside text inputs. */
|
|
152
|
-
readonly fragment: DocumentFragment | null;
|
|
153
|
-
/** The `<input>`/`<textarea>` the selection lives in, if any. */
|
|
154
|
-
readonly field: HTMLInputElement | HTMLTextAreaElement | null;
|
|
155
|
-
/** Whether a `cut` would remove the selection (form field or contenteditable). */
|
|
156
|
-
readonly editable: boolean;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* A multi payload whose items are all strings; the only kind `setData` accepts.
|
|
160
|
-
* Web custom formats (`web …`) are skipped: only the async Clipboard API writes them.
|
|
161
|
-
*/
|
|
162
|
-
interface SyncMultiPayload {
|
|
163
|
-
readonly kind: 'multi';
|
|
164
|
-
readonly items: readonly {
|
|
165
|
-
readonly mimeType: string;
|
|
166
|
-
readonly data: string;
|
|
167
|
-
readonly optional?: boolean;
|
|
168
|
-
}[];
|
|
169
|
-
}
|
|
170
|
-
/** Payloads writable synchronously during a copy event. Images need the async clipboard. */
|
|
171
|
-
type SyncCopyPayload = TextPayload | HtmlPayload | JsonPayload | SyncMultiPayload;
|
|
172
|
-
/**
|
|
173
|
-
* What a transform returns:
|
|
174
|
-
* - a string or payload: write that instead of the selection
|
|
175
|
-
* - `false`: block the copy (nothing reaches the clipboard; a cut deletes nothing)
|
|
176
|
-
* - `null` / `undefined`: leave the browser's default copy untouched
|
|
177
|
-
*
|
|
178
|
-
* Must be synchronous: the clipboard closes when the event handler returns.
|
|
179
|
-
*/
|
|
180
|
-
type CopyInterceptDecision = string | SyncCopyPayload | false | null | undefined;
|
|
181
|
-
type CopyInterceptTransform = (selection: CopySelection) => CopyInterceptDecision;
|
|
182
|
-
//#endregion
|
|
183
97
|
//#region src/rich/payload.d.ts
|
|
184
98
|
/**
|
|
185
99
|
* Content to copy as portable rich text: the sanitized HTML, and its plain text for
|
package/dist/rich.d.ts
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* `utm_`), or regular expressions tested against the name. Default {@link TRACKING_PARAMETERS}.
|
|
6
|
-
*/
|
|
7
|
-
readonly params?: readonly (string | RegExp)[];
|
|
8
|
-
/** Parameters never removed, even when `params` matches them. */
|
|
9
|
-
readonly keep?: readonly string[];
|
|
10
|
-
}
|
|
11
|
-
interface LinkUrlOptions {
|
|
12
|
-
/** Resolves relative links. Default: the page's address in a browser; required elsewhere for relative links. */
|
|
13
|
-
readonly base?: string | URL;
|
|
14
|
-
/** Allowed schemes, with the colon. Default {@link DEFAULT_LINK_PROTOCOLS}. */
|
|
15
|
-
readonly protocols?: readonly string[];
|
|
16
|
-
/** Remove tracking parameters: `true` for {@link TRACKING_PARAMETERS}, or your own list. Default `false`. */
|
|
17
|
-
readonly clean?: boolean | CleanLinkOptions;
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
1
|
+
|
|
2
|
+
import { o as HtmlPayload } from "./chunks/payload-Cl_8hCI5.js";
|
|
3
|
+
import { c as CopyInterceptTransform } from "./chunks/copy-interceptor-C6NABy1l.js";
|
|
4
|
+
import { r as LinkUrlOptions } from "./chunks/url-DWdElCT3.js";
|
|
20
5
|
//#region src/rich/style.d.ts
|
|
21
6
|
/** Where styles come from: `getComputedStyle` for a live element, the `style` attribute otherwise. */
|
|
22
7
|
interface StyleSource {
|
|
@@ -109,77 +94,6 @@ type RichSource = Element | DocumentFragment | Range | string;
|
|
|
109
94
|
*/
|
|
110
95
|
export declare function prepareRich(source: RichSource, options?: RichOptions): RichResult;
|
|
111
96
|
//#endregion
|
|
112
|
-
//#region src/core/payload.d.ts
|
|
113
|
-
interface TextPayload {
|
|
114
|
-
readonly kind: 'text';
|
|
115
|
-
readonly value: string;
|
|
116
|
-
}
|
|
117
|
-
interface HtmlPayload {
|
|
118
|
-
readonly kind: 'html';
|
|
119
|
-
readonly html: string;
|
|
120
|
-
/** Required plain-text fallback for targets that don't understand HTML. */
|
|
121
|
-
readonly text: string;
|
|
122
|
-
}
|
|
123
|
-
interface JsonPayload {
|
|
124
|
-
readonly kind: 'json';
|
|
125
|
-
readonly value: unknown;
|
|
126
|
-
/** `true` = 2-space indent, a number = that indent, falsy = compact. */
|
|
127
|
-
readonly pretty?: boolean | number;
|
|
128
|
-
}
|
|
129
|
-
//#endregion
|
|
130
|
-
//#region src/core/copy-interceptor.d.ts
|
|
131
|
-
/**
|
|
132
|
-
* Native copy interception: rewrite, redact or block what lands on the
|
|
133
|
-
* clipboard when the user copies (Ctrl/Cmd+C, context menu) or cuts inside a
|
|
134
|
-
* scope.
|
|
135
|
-
*
|
|
136
|
-
* Writes go through `event.clipboardData` synchronously, so no permission
|
|
137
|
-
* prompt, no secure-context requirement, and it works in every browser. The
|
|
138
|
-
* price is that only strings can be written, which the types enforce.
|
|
139
|
-
*
|
|
140
|
-
* Not a security boundary: users can still screenshot, use dev tools or
|
|
141
|
-
* disable script. Treat redaction as a guard against accidents.
|
|
142
|
-
*/
|
|
143
|
-
type InterceptedCopyKind = 'copy' | 'cut';
|
|
144
|
-
/** What the user selected when they copied. */
|
|
145
|
-
interface CopySelection {
|
|
146
|
-
readonly kind: InterceptedCopyKind;
|
|
147
|
-
/** What the browser would put on the clipboard as `text/plain`. */
|
|
148
|
-
readonly text: string;
|
|
149
|
-
/** Serialised HTML of the selection; `null` inside text inputs. */
|
|
150
|
-
readonly html: string | null;
|
|
151
|
-
/** A detached clone of the selected nodes, safe to mutate; `null` inside text inputs. */
|
|
152
|
-
readonly fragment: DocumentFragment | null;
|
|
153
|
-
/** The `<input>`/`<textarea>` the selection lives in, if any. */
|
|
154
|
-
readonly field: HTMLInputElement | HTMLTextAreaElement | null;
|
|
155
|
-
/** Whether a `cut` would remove the selection (form field or contenteditable). */
|
|
156
|
-
readonly editable: boolean;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* A multi payload whose items are all strings; the only kind `setData` accepts.
|
|
160
|
-
* Web custom formats (`web …`) are skipped: only the async Clipboard API writes them.
|
|
161
|
-
*/
|
|
162
|
-
interface SyncMultiPayload {
|
|
163
|
-
readonly kind: 'multi';
|
|
164
|
-
readonly items: readonly {
|
|
165
|
-
readonly mimeType: string;
|
|
166
|
-
readonly data: string;
|
|
167
|
-
readonly optional?: boolean;
|
|
168
|
-
}[];
|
|
169
|
-
}
|
|
170
|
-
/** Payloads writable synchronously during a copy event. Images need the async clipboard. */
|
|
171
|
-
type SyncCopyPayload = TextPayload | HtmlPayload | JsonPayload | SyncMultiPayload;
|
|
172
|
-
/**
|
|
173
|
-
* What a transform returns:
|
|
174
|
-
* - a string or payload: write that instead of the selection
|
|
175
|
-
* - `false`: block the copy (nothing reaches the clipboard; a cut deletes nothing)
|
|
176
|
-
* - `null` / `undefined`: leave the browser's default copy untouched
|
|
177
|
-
*
|
|
178
|
-
* Must be synchronous: the clipboard closes when the event handler returns.
|
|
179
|
-
*/
|
|
180
|
-
type CopyInterceptDecision = string | SyncCopyPayload | false | null | undefined;
|
|
181
|
-
type CopyInterceptTransform = (selection: CopySelection) => CopyInterceptDecision;
|
|
182
|
-
//#endregion
|
|
183
97
|
//#region src/rich/payload.d.ts
|
|
184
98
|
/**
|
|
185
99
|
* Content to copy as portable rich text: the sanitized HTML, and its plain text for
|