react-smart-copy 1.17.1 → 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.
Files changed (146) hide show
  1. package/README.md +22 -3
  2. package/dist/capture.cjs +30 -153
  3. package/dist/capture.cjs.map +1 -1
  4. package/dist/capture.d.cts +2 -25
  5. package/dist/capture.d.ts +2 -25
  6. package/dist/capture.js +5 -128
  7. package/dist/capture.js.map +1 -1
  8. package/dist/chunks/clipboard-adapter-Cfz-rzw3.cjs +102 -0
  9. package/dist/chunks/clipboard-adapter-Cfz-rzw3.cjs.map +1 -0
  10. package/dist/chunks/clipboard-adapter-CtH4VELE.d.cts +43 -0
  11. package/dist/chunks/clipboard-adapter-DEXkXxwV.js +97 -0
  12. package/dist/chunks/clipboard-adapter-DEXkXxwV.js.map +1 -0
  13. package/dist/chunks/clipboard-adapter-Ds0irroN.d.ts +43 -0
  14. package/dist/chunks/contrast-C6CVklEI.cjs +842 -0
  15. package/dist/chunks/contrast-C6CVklEI.cjs.map +1 -0
  16. package/dist/chunks/contrast-DpK2JIVu.js +789 -0
  17. package/dist/chunks/contrast-DpK2JIVu.js.map +1 -0
  18. package/dist/chunks/copy-interceptor-C6NABy1l.d.ts +141 -0
  19. package/dist/chunks/copy-interceptor-CZWzGOkL.d.cts +141 -0
  20. package/dist/chunks/core-Cp2HSpaz.js +1035 -0
  21. package/dist/chunks/core-Cp2HSpaz.js.map +1 -0
  22. package/dist/chunks/core-DYf_Lhbe.cjs +1142 -0
  23. package/dist/chunks/core-DYf_Lhbe.cjs.map +1 -0
  24. package/dist/chunks/deadline-C29AlS_Q.js +46 -0
  25. package/dist/chunks/deadline-C29AlS_Q.js.map +1 -0
  26. package/dist/chunks/deadline-DkiB8ZHE.cjs +51 -0
  27. package/dist/chunks/deadline-DkiB8ZHE.cjs.map +1 -0
  28. package/dist/chunks/errors-9h8sdFFX.js +120 -0
  29. package/dist/chunks/errors-9h8sdFFX.js.map +1 -0
  30. package/dist/chunks/errors-BwOF6T_M.cjs +167 -0
  31. package/dist/chunks/errors-BwOF6T_M.cjs.map +1 -0
  32. package/dist/chunks/index-mr7sSAgP.d.ts +426 -0
  33. package/dist/chunks/index-vz0iW5V2.d.cts +426 -0
  34. package/dist/chunks/mime--LB7kdqG.cjs +153 -0
  35. package/dist/chunks/mime--LB7kdqG.cjs.map +1 -0
  36. package/dist/chunks/mime-aa-HA2dm.js +100 -0
  37. package/dist/chunks/mime-aa-HA2dm.js.map +1 -0
  38. package/dist/chunks/paste-adapter--SPL4PRE.d.cts +35 -0
  39. package/dist/chunks/paste-adapter-uahXnTYk.d.ts +35 -0
  40. package/dist/chunks/paste-reader-Bo01IMC_.cjs +289 -0
  41. package/dist/chunks/paste-reader-Bo01IMC_.cjs.map +1 -0
  42. package/dist/chunks/paste-reader-D9i7yMXF.js +224 -0
  43. package/dist/chunks/paste-reader-D9i7yMXF.js.map +1 -0
  44. package/dist/chunks/paste-reader-DcXnRWQr.d.cts +96 -0
  45. package/dist/chunks/paste-reader-DcXnRWQr.d.ts +96 -0
  46. package/dist/chunks/payload-CUymxwim.cjs +100 -0
  47. package/dist/chunks/payload-CUymxwim.cjs.map +1 -0
  48. package/dist/chunks/payload-CcwKJ_bU.d.cts +162 -0
  49. package/dist/chunks/payload-Cl_8hCI5.d.ts +162 -0
  50. package/dist/chunks/payload-DGw-JOo7.js +71 -0
  51. package/dist/chunks/payload-DGw-JOo7.js.map +1 -0
  52. package/dist/chunks/payload-DI5AorDz.js +103 -0
  53. package/dist/chunks/payload-DI5AorDz.js.map +1 -0
  54. package/dist/chunks/payload-J6GjHuh3.cjs +132 -0
  55. package/dist/chunks/payload-J6GjHuh3.cjs.map +1 -0
  56. package/dist/chunks/share-Bop47Znn.js +208 -0
  57. package/dist/chunks/share-Bop47Znn.js.map +1 -0
  58. package/dist/chunks/share-C0esXvRK.d.cts +115 -0
  59. package/dist/chunks/share-ayDz974N.cjs +231 -0
  60. package/dist/chunks/share-ayDz974N.cjs.map +1 -0
  61. package/dist/chunks/share-e7FenIr2.d.ts +115 -0
  62. package/dist/chunks/text-field-Ba8W3v4R.cjs +77 -0
  63. package/dist/chunks/text-field-Ba8W3v4R.cjs.map +1 -0
  64. package/dist/chunks/text-field-C0SGmvvR.d.cts +18 -0
  65. package/dist/chunks/text-field-C0SGmvvR.d.ts +18 -0
  66. package/dist/chunks/text-field-DUvrMMaK.js +66 -0
  67. package/dist/chunks/text-field-DUvrMMaK.js.map +1 -0
  68. package/dist/chunks/url-BcMYVCXQ.js +135 -0
  69. package/dist/chunks/url-BcMYVCXQ.js.map +1 -0
  70. package/dist/chunks/url-D4PGsRm8.cjs +164 -0
  71. package/dist/chunks/url-D4PGsRm8.cjs.map +1 -0
  72. package/dist/chunks/url-DWdElCT3.d.cts +43 -0
  73. package/dist/chunks/url-DWdElCT3.d.ts +43 -0
  74. package/dist/code.cjs +20 -109
  75. package/dist/code.cjs.map +1 -1
  76. package/dist/code.d.cts +4 -28
  77. package/dist/code.d.ts +4 -28
  78. package/dist/code.js +4 -93
  79. package/dist/code.js.map +1 -1
  80. package/dist/color.cjs +21 -893
  81. package/dist/color.cjs.map +1 -1
  82. package/dist/color.d.cts +4 -28
  83. package/dist/color.d.ts +4 -28
  84. package/dist/color.js +4 -876
  85. package/dist/color.js.map +1 -1
  86. package/dist/core.cjs +52 -1659
  87. package/dist/core.d.cts +8 -878
  88. package/dist/core.d.ts +8 -878
  89. package/dist/core.js +7 -1614
  90. package/dist/image.cjs +23 -91
  91. package/dist/image.cjs.map +1 -1
  92. package/dist/image.d.cts +1 -0
  93. package/dist/image.d.ts +1 -0
  94. package/dist/image.js +5 -73
  95. package/dist/image.js.map +1 -1
  96. package/dist/index.cjs +74 -2072
  97. package/dist/index.cjs.map +1 -1
  98. package/dist/index.d.cts +8 -978
  99. package/dist/index.d.ts +8 -978
  100. package/dist/index.js +7 -2005
  101. package/dist/index.js.map +1 -1
  102. package/dist/link.cjs +24 -338
  103. package/dist/link.cjs.map +1 -1
  104. package/dist/link.d.cts +5 -83
  105. package/dist/link.d.ts +5 -83
  106. package/dist/link.js +5 -319
  107. package/dist/link.js.map +1 -1
  108. package/dist/markdown.cjs +8 -97
  109. package/dist/markdown.cjs.map +1 -1
  110. package/dist/markdown.d.cts +3 -16
  111. package/dist/markdown.d.ts +3 -16
  112. package/dist/markdown.js +3 -92
  113. package/dist/markdown.js.map +1 -1
  114. package/dist/rich.cjs +26 -934
  115. package/dist/rich.cjs.map +1 -1
  116. package/dist/rich.d.cts +4 -90
  117. package/dist/rich.d.ts +4 -90
  118. package/dist/rich.js +4 -912
  119. package/dist/rich.js.map +1 -1
  120. package/dist/share.cjs +5 -640
  121. package/dist/share.d.cts +3 -248
  122. package/dist/share.d.ts +3 -248
  123. package/dist/share.js +1 -637
  124. package/dist/structured.cjs +13 -95
  125. package/dist/structured.cjs.map +1 -1
  126. package/dist/structured.d.cts +2 -11
  127. package/dist/structured.d.ts +2 -11
  128. package/dist/structured.js +4 -86
  129. package/dist/structured.js.map +1 -1
  130. package/dist/table.cjs +11 -39
  131. package/dist/table.cjs.map +1 -1
  132. package/dist/table.d.cts +2 -12
  133. package/dist/table.d.ts +2 -12
  134. package/dist/table.js +2 -30
  135. package/dist/table.js.map +1 -1
  136. package/dist/testing.cjs +10 -43
  137. package/dist/testing.cjs.map +1 -1
  138. package/dist/testing.d.cts +6 -181
  139. package/dist/testing.d.ts +6 -181
  140. package/dist/testing.js +3 -36
  141. package/dist/testing.js.map +1 -1
  142. package/package.json +20 -2
  143. package/dist/core.cjs.map +0 -1
  144. package/dist/core.js.map +0 -1
  145. package/dist/share.cjs.map +0 -1
  146. package/dist/share.js.map +0 -1
package/dist/rich.d.cts CHANGED
@@ -1,22 +1,7 @@
1
- //#region src/link/url.d.ts
2
- interface CleanLinkOptions {
3
- /**
4
- * Parameters to remove: exact names, names ending in `_` (a prefix, like
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
- //#region src/link/url.d.ts
2
- interface CleanLinkOptions {
3
- /**
4
- * Parameters to remove: exact names, names ending in `_` (a prefix, like
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