@docs.plus/extension-hyperlink 1.5.2 → 2.1.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 +572 -0
- package/LICENSE +21 -0
- package/README.md +135 -385
- package/dist/index.cjs +22 -712
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +392 -0
- package/dist/index.d.ts +392 -9
- package/dist/index.js +22 -707
- package/dist/index.js.map +1 -1
- package/dist/styles.css +362 -0
- package/package.json +85 -33
- package/dist/helpers/autoHyperlink.d.ts +0 -8
- package/dist/helpers/clickHandler.d.ts +0 -11
- package/dist/helpers/editHyperlink.d.ts +0 -9
- package/dist/helpers/pasteHandler.d.ts +0 -9
- package/dist/helpers/tippyHelper.d.ts +0 -29
- package/dist/hyperlink.d.ts +0 -77
- package/dist/index.umd.js +0 -713
- package/dist/index.umd.js.map +0 -1
- package/dist/modals/editeHyperlink.d.ts +0 -11
- package/dist/modals/icons.d.ts +0 -9
- package/dist/modals/previewHyperlink.d.ts +0 -11
- package/dist/modals/setHyperlink.d.ts +0 -14
- package/src/helpers/autoHyperlink.ts +0 -167
- package/src/helpers/clickHandler.ts +0 -80
- package/src/helpers/editHyperlink.ts +0 -59
- package/src/helpers/pasteHandler.ts +0 -46
- package/src/helpers/tippyHelper.ts +0 -136
- package/src/hyperlink.ts +0 -277
- package/src/index.ts +0 -17
- package/src/modals/editeHyperlink.ts +0 -99
- package/src/modals/icons.ts +0 -46
- package/src/modals/previewHyperlink.ts +0 -85
- package/src/modals/setHyperlink.ts +0 -97
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import { Editor, Mark } from '@tiptap/core';
|
|
2
|
+
import { MarkType } from '@tiptap/pm/model';
|
|
3
|
+
import { Placement } from '@floating-ui/dom';
|
|
4
|
+
export { registerCustomProtocol } from 'linkifyjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Canonicalize a user-supplied href so stored marks point somewhere
|
|
8
|
+
* absolute (bare `google.com` would otherwise resolve against
|
|
9
|
+
* `document.baseURI` at render time). See docs/url-handling.md for
|
|
10
|
+
* the full pipeline order.
|
|
11
|
+
*/
|
|
12
|
+
declare const normalizeHref: (raw: string, defaultProtocol?: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Shape `findLinks` produces (linkifyjs match + our synthetic
|
|
15
|
+
* special-scheme / phone entries). Loosened so linkifyjs types don't
|
|
16
|
+
* leak across the public boundary.
|
|
17
|
+
*/
|
|
18
|
+
type LinkifyMatchLike = {
|
|
19
|
+
type: string;
|
|
20
|
+
value: string;
|
|
21
|
+
href: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Blocked schemes: `javascript:`/`vbscript:` (script), `data:`, `file:`, `blob:`.
|
|
26
|
+
* Twin of hypermultimedia's copy — preflight diffs them byte-for-byte.
|
|
27
|
+
*/
|
|
28
|
+
declare const DANGEROUS_SCHEME_RE: RegExp;
|
|
29
|
+
/**
|
|
30
|
+
* Single XSS gate used at every read/write boundary. Returns `false`
|
|
31
|
+
* for nullish/empty hrefs and any scheme matched by
|
|
32
|
+
* {@link DANGEROUS_SCHEME_RE}. See docs/security.md.
|
|
33
|
+
*/
|
|
34
|
+
declare const isSafeHref: (href: string | null | undefined) => href is string;
|
|
35
|
+
type ValidateURLOptions = {
|
|
36
|
+
customValidator?: (url: string) => boolean;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Shape-validate a URL: web schemes with a plausible host, app schemes from
|
|
40
|
+
* the `getSpecialUrlInfo` catalog, and bare E.164 phones. Rejects schemes
|
|
41
|
+
* matched by {@link DANGEROUS_SCHEME_RE}. See docs/url-handling.md.
|
|
42
|
+
*/
|
|
43
|
+
declare const validateURL: (url: string, options?: ValidateURLOptions) => boolean;
|
|
44
|
+
|
|
45
|
+
/** Discriminated input to {@link URLDecisions.forWrite}. */
|
|
46
|
+
type WriteInput = {
|
|
47
|
+
kind: 'text';
|
|
48
|
+
text: string;
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'href';
|
|
51
|
+
href: string;
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'match';
|
|
54
|
+
match: LinkifyMatchLike;
|
|
55
|
+
};
|
|
56
|
+
type WriteResult = {
|
|
57
|
+
/** Canonical, gated, write-safe href ready to set on the mark. */
|
|
58
|
+
href: string;
|
|
59
|
+
/** Source offset; `0` for `href`/`match` inputs. */
|
|
60
|
+
start: number;
|
|
61
|
+
end: number;
|
|
62
|
+
};
|
|
63
|
+
type ReadDecision = {
|
|
64
|
+
/** Passes the full gate (`isSafeHref` + `isAllowedUri`) — required before any `window.open`. */
|
|
65
|
+
navigable: boolean;
|
|
66
|
+
};
|
|
67
|
+
type WriteOptions = {
|
|
68
|
+
/** Per-call override of the controller's `validate`. */
|
|
69
|
+
validate?: (url: string) => boolean;
|
|
70
|
+
};
|
|
71
|
+
interface URLDecisions {
|
|
72
|
+
/** Resolve a write candidate to its canonical, gated href(s). Returns `[]` when nothing passes. */
|
|
73
|
+
forWrite(input: WriteInput, opts?: WriteOptions): WriteResult[];
|
|
74
|
+
/** Read-side gate for render + navigation. */
|
|
75
|
+
forRead(href: string | null | undefined): ReadDecision;
|
|
76
|
+
/**
|
|
77
|
+
* Pure shape check — skips the gate stack on purpose. That keeps a tightened
|
|
78
|
+
* `isAllowedUri` policy out of autolink's "is the existing link still
|
|
79
|
+
* link-shaped?" cleanup pass.
|
|
80
|
+
*/
|
|
81
|
+
detect(text: string): boolean;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface LinkContext {
|
|
85
|
+
type: MarkType;
|
|
86
|
+
editor: Editor;
|
|
87
|
+
/** One URL Decisions pipeline per editor (cached on `storage.context`). */
|
|
88
|
+
urls: URLDecisions;
|
|
89
|
+
options: HyperlinkOptions;
|
|
90
|
+
validate?: (url: string) => boolean;
|
|
91
|
+
/** Preview popover factory, or `null` when the host opted out. */
|
|
92
|
+
previewPopover: ((options: PreviewHyperlinkOptions) => HTMLElement | null) | null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
type SetHyperlinkAttributes = {
|
|
96
|
+
href: string;
|
|
97
|
+
target?: string | null;
|
|
98
|
+
title?: string | null;
|
|
99
|
+
image?: string | null;
|
|
100
|
+
} & Record<string, unknown>;
|
|
101
|
+
type EditHyperlinkAttributes = {
|
|
102
|
+
newText?: string;
|
|
103
|
+
newURL?: string;
|
|
104
|
+
title?: string;
|
|
105
|
+
image?: string;
|
|
106
|
+
};
|
|
107
|
+
interface HyperlinkPublicCommands<ReturnType> {
|
|
108
|
+
/** Write the hyperlink mark; returns `false` when `href` is missing or fails the gate. See docs/api.md → Commands. */
|
|
109
|
+
setHyperlink: (attributes: SetHyperlinkAttributes) => ReturnType;
|
|
110
|
+
unsetHyperlink: () => ReturnType;
|
|
111
|
+
/** Toggle; same gates as `setHyperlink`. */
|
|
112
|
+
toggleHyperlink: (attributes: SetHyperlinkAttributes) => ReturnType;
|
|
113
|
+
/** Open the create popover (configured `popovers.createHyperlink` or the prebuilt fallback); no-op only when the factory returns `null`. See docs/api.md → Commands. */
|
|
114
|
+
openCreateHyperlinkPopover: (attributes?: Partial<HyperlinkAttributes>) => ReturnType;
|
|
115
|
+
editHyperlinkText: (text: string) => ReturnType;
|
|
116
|
+
editHyperlinkHref: (href: string) => ReturnType;
|
|
117
|
+
editHyperlink: (attributes?: EditHyperlinkAttributes) => ReturnType;
|
|
118
|
+
/** Migration alias for `setHyperlink` (drop-in `@tiptap/extension-link` compat). */
|
|
119
|
+
setLink: (attributes: SetHyperlinkAttributes) => ReturnType;
|
|
120
|
+
/** Migration alias for `unsetHyperlink`. */
|
|
121
|
+
unsetLink: () => ReturnType;
|
|
122
|
+
/** Migration alias for `toggleHyperlink`. */
|
|
123
|
+
toggleLink: (attributes: SetHyperlinkAttributes) => ReturnType;
|
|
124
|
+
}
|
|
125
|
+
declare module '@tiptap/core' {
|
|
126
|
+
interface Commands<ReturnType> {
|
|
127
|
+
hyperlink: HyperlinkPublicCommands<ReturnType>;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface LinkProtocolOptions {
|
|
132
|
+
scheme: string;
|
|
133
|
+
optionalSlashes?: boolean;
|
|
134
|
+
}
|
|
135
|
+
/** Context for the user `isAllowedUri` hook; mirrors `@tiptap/extension-link`. */
|
|
136
|
+
type IsAllowedUriContext = {
|
|
137
|
+
/** Built-in safety gate (`isSafeHref`). */
|
|
138
|
+
defaultValidate: (uri: string) => boolean;
|
|
139
|
+
/** Protocols registered via the `protocols` option. */
|
|
140
|
+
protocols: Array<LinkProtocolOptions | string>;
|
|
141
|
+
defaultProtocol: string;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* `Extra` extends the built-ins with consumer-typed fields; it defaults to
|
|
145
|
+
* `Record<string, unknown>` to keep the v2 open index signature. Example: docs/api.md → TypeScript.
|
|
146
|
+
*/
|
|
147
|
+
type HyperlinkAttributes<Extra extends Record<string, unknown> = Record<string, unknown>> = {
|
|
148
|
+
href: string | null;
|
|
149
|
+
target: string | null;
|
|
150
|
+
rel: string | null;
|
|
151
|
+
class: string | null;
|
|
152
|
+
title: string | null;
|
|
153
|
+
image: string | null;
|
|
154
|
+
} & Extra;
|
|
155
|
+
type PreviewHyperlinkOptions = {
|
|
156
|
+
editor: Editor;
|
|
157
|
+
link: HTMLAnchorElement;
|
|
158
|
+
nodePos: number;
|
|
159
|
+
attrs: HyperlinkAttributes;
|
|
160
|
+
validate?: (url: string) => boolean;
|
|
161
|
+
/** Composed XSS + `isAllowedUri` gate; BYO popovers must call this before any `window.open`. */
|
|
162
|
+
isAllowedUri?: (uri: string) => boolean;
|
|
163
|
+
};
|
|
164
|
+
type CreateHyperlinkOptions = {
|
|
165
|
+
editor: Editor;
|
|
166
|
+
extensionName: string;
|
|
167
|
+
attributes: Partial<HyperlinkAttributes>;
|
|
168
|
+
validate?: (url: string) => boolean;
|
|
169
|
+
};
|
|
170
|
+
type EditHyperlinkOptions = {
|
|
171
|
+
editor: Editor;
|
|
172
|
+
link: HTMLAnchorElement;
|
|
173
|
+
/** Optional mark position; lets edit/back recover from ProseMirror replacing duplicate link DOM. */
|
|
174
|
+
nodePos?: number;
|
|
175
|
+
validate?: (url: string) => boolean;
|
|
176
|
+
/** Composed XSS + `isAllowedUri` gate to preserve preview policy across edit/back. */
|
|
177
|
+
isAllowedUri?: (uri: string) => boolean;
|
|
178
|
+
/** Override the default Back behaviour. Default re-opens the preview popover via `openPreviewHyperlink`. */
|
|
179
|
+
onBack?: () => void;
|
|
180
|
+
/** Mark name; defaults to `HYPERLINK_MARK_NAME`. */
|
|
181
|
+
markName?: string;
|
|
182
|
+
};
|
|
183
|
+
interface HyperlinkOptions {
|
|
184
|
+
autolink: boolean;
|
|
185
|
+
protocols: Array<LinkProtocolOptions | string>;
|
|
186
|
+
openOnClick: boolean;
|
|
187
|
+
linkOnPaste: boolean;
|
|
188
|
+
HTMLAttributes: Partial<HyperlinkAttributes>;
|
|
189
|
+
popovers: {
|
|
190
|
+
previewHyperlink?: ((options: PreviewHyperlinkOptions) => HTMLElement | null) | null;
|
|
191
|
+
editHyperlink?: ((options: EditHyperlinkOptions) => HTMLElement | null) | null;
|
|
192
|
+
createHyperlink?: ((options: CreateHyperlinkOptions) => HTMLElement | null) | null;
|
|
193
|
+
};
|
|
194
|
+
validate?: (url: string) => boolean;
|
|
195
|
+
/** Scheme used by `normalizeHref` to promote bare domains. Default `'https'`. See docs/api.md → Options. */
|
|
196
|
+
defaultProtocol: string;
|
|
197
|
+
/** URI policy hook — runs AFTER `isSafeHref`, BEFORE the mark is written. Mirrors `@tiptap/extension-link`. */
|
|
198
|
+
isAllowedUri?: (uri: string, ctx: IsAllowedUriContext) => boolean;
|
|
199
|
+
/** Per-link autolink veto. Return `false` to skip autolinking a specific URI (manual `setHyperlink` still works). */
|
|
200
|
+
shouldAutoLink?: (uri: string) => boolean;
|
|
201
|
+
/** Click inside a link selects the whole mark range (editable mode only). Mirrors `@tiptap/extension-link`. */
|
|
202
|
+
enableClickSelection: boolean;
|
|
203
|
+
/** ArrowRight at the right edge of a link drops a stored link mark. Mirrors `@tiptap/extension-link`. */
|
|
204
|
+
exitable: boolean;
|
|
205
|
+
}
|
|
206
|
+
/** Extension storage; one slot per editor instance. */
|
|
207
|
+
interface HyperlinkStorage {
|
|
208
|
+
/**
|
|
209
|
+
* Cached `LinkContext`; populated on first access so all four `add*`
|
|
210
|
+
* hooks share one URL Decisions pipeline instead of allocating per hook.
|
|
211
|
+
*/
|
|
212
|
+
context: LinkContext | null;
|
|
213
|
+
}
|
|
214
|
+
declare const Hyperlink: Mark<HyperlinkOptions, HyperlinkStorage>;
|
|
215
|
+
|
|
216
|
+
type PopoverKind = 'preview' | 'edit' | 'create' | (string & {});
|
|
217
|
+
type VirtualCoordinates = {
|
|
218
|
+
getBoundingClientRect: () => {
|
|
219
|
+
x: number;
|
|
220
|
+
y: number;
|
|
221
|
+
width: number;
|
|
222
|
+
height: number;
|
|
223
|
+
};
|
|
224
|
+
contextElement?: HTMLElement;
|
|
225
|
+
};
|
|
226
|
+
interface ManagedPopover {
|
|
227
|
+
hide: () => void;
|
|
228
|
+
destroy: () => void;
|
|
229
|
+
updateReference: (referenceElement?: HTMLElement, coordinates?: VirtualCoordinates) => void;
|
|
230
|
+
}
|
|
231
|
+
type AdoptMetadata = {
|
|
232
|
+
element: HTMLElement;
|
|
233
|
+
referenceElement: HTMLElement | null;
|
|
234
|
+
};
|
|
235
|
+
type ControllerState = {
|
|
236
|
+
kind: 'idle';
|
|
237
|
+
} | ({
|
|
238
|
+
kind: 'mounted';
|
|
239
|
+
popoverKind: PopoverKind;
|
|
240
|
+
} & AdoptMetadata);
|
|
241
|
+
interface PopoverController {
|
|
242
|
+
adopt(popover: ManagedPopover, kind: PopoverKind, metadata: AdoptMetadata): () => void;
|
|
243
|
+
close(): void;
|
|
244
|
+
reposition(referenceElement?: HTMLElement, coordinates?: VirtualCoordinates): void;
|
|
245
|
+
getState(): ControllerState;
|
|
246
|
+
subscribe(listener: (state: ControllerState) => void): () => void;
|
|
247
|
+
}
|
|
248
|
+
declare function getDefaultController(): PopoverController;
|
|
249
|
+
|
|
250
|
+
type PopoverAnchor = {
|
|
251
|
+
referenceElement: HTMLElement;
|
|
252
|
+
coordinates?: never;
|
|
253
|
+
} | {
|
|
254
|
+
referenceElement?: never;
|
|
255
|
+
coordinates: VirtualCoordinates;
|
|
256
|
+
};
|
|
257
|
+
type PopoverShellOptions = {
|
|
258
|
+
content: HTMLElement;
|
|
259
|
+
placement?: Placement;
|
|
260
|
+
offset?: number;
|
|
261
|
+
showArrow?: boolean;
|
|
262
|
+
className?: string;
|
|
263
|
+
zIndex?: number;
|
|
264
|
+
/**
|
|
265
|
+
* ARIA has no popover role — the shell carries its content's role
|
|
266
|
+
* (`toolbar`, `dialog`, …) and stays role-less when omitted.
|
|
267
|
+
*/
|
|
268
|
+
role?: string;
|
|
269
|
+
/** Same ARIA axis as `role` — shell-level so BYO content inherits the accessible name. */
|
|
270
|
+
ariaLabel?: string;
|
|
271
|
+
/**
|
|
272
|
+
* Nodes that must not light-dismiss (toggle triggers). When set, only these
|
|
273
|
+
* are ignored — not `referenceElement` — so a larger position surface (e.g.
|
|
274
|
+
* a toolbar bar) can still dismiss on sibling clicks. When omitted, the
|
|
275
|
+
* HTMLElement `referenceElement` is ignored instead.
|
|
276
|
+
*/
|
|
277
|
+
ignoreOutsideClickOn?: HTMLElement | HTMLElement[];
|
|
278
|
+
/**
|
|
279
|
+
* When false, `shift` only moves on the main axis so end-aligned menus
|
|
280
|
+
* (e.g. toolbar overflow) stay pinned to the reference’s end edge.
|
|
281
|
+
* @default true
|
|
282
|
+
*/
|
|
283
|
+
crossAxisShift?: boolean;
|
|
284
|
+
onShow?: () => void;
|
|
285
|
+
onHide?: () => void;
|
|
286
|
+
};
|
|
287
|
+
type PopoverOptions = PopoverAnchor & PopoverShellOptions;
|
|
288
|
+
/**
|
|
289
|
+
* One-shot once opened: hiding releases the controller's ownership and nothing
|
|
290
|
+
* re-adopts, so `show()` will not reopen it. Build a new popover instead — a
|
|
291
|
+
* re-shown one would sit outside the single-popover invariant, invisible to
|
|
292
|
+
* `close()` and never evicted by the next `adopt()`.
|
|
293
|
+
*/
|
|
294
|
+
interface Popover {
|
|
295
|
+
element: HTMLElement;
|
|
296
|
+
/** No-op once the popover has been hidden or destroyed. */
|
|
297
|
+
show: () => void;
|
|
298
|
+
/** Terminal once shown. Before the first `show()` it no-ops and keeps ownership. */
|
|
299
|
+
hide: () => void;
|
|
300
|
+
destroy: () => void;
|
|
301
|
+
isVisible: () => boolean;
|
|
302
|
+
setContent: (content: HTMLElement) => void;
|
|
303
|
+
updateReference: (referenceElement?: HTMLElement, coordinates?: VirtualCoordinates) => void;
|
|
304
|
+
}
|
|
305
|
+
declare const DEFAULT_OFFSET = 8;
|
|
306
|
+
declare function createPopover(options: PopoverOptions): Popover;
|
|
307
|
+
|
|
308
|
+
interface BuildPreviewOptionsFromAnchorArgs {
|
|
309
|
+
editor: Editor;
|
|
310
|
+
link: HTMLAnchorElement;
|
|
311
|
+
/** Prefer this ProseMirror position before falling back to DOM similarity. */
|
|
312
|
+
nodePos?: number;
|
|
313
|
+
validate?: (url: string) => boolean;
|
|
314
|
+
/** Preserve the host's composed navigation gate when rebuilding preview from edit/back. */
|
|
315
|
+
isAllowedUri?: (uri: string) => boolean;
|
|
316
|
+
/** Mark name to look up; defaults to `'hyperlink'`. Override only if the schema mark was renamed. */
|
|
317
|
+
markName?: string;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Exists so the edit popover's Back button and BYO `editHyperlink` factories
|
|
321
|
+
* share one `posAtDOM → mark.attrs` lookup. The DOM `link.href` property is
|
|
322
|
+
* never the raw-href fallback — it resolves relative hrefs against
|
|
323
|
+
* `document.baseURI`, leaking the host origin into a stored attribute.
|
|
324
|
+
*/
|
|
325
|
+
declare function buildPreviewOptionsFromAnchor({ editor, link, nodePos: preferredNodePos, validate, isAllowedUri, markName }: BuildPreviewOptionsFromAnchorArgs): PreviewHyperlinkOptions;
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Open the create-hyperlink popover anchored to the current selection.
|
|
329
|
+
* Returns `false` when the host opted out (factory returned `null`).
|
|
330
|
+
*/
|
|
331
|
+
declare function openCreateHyperlink(editor: Editor, attributes?: Partial<HyperlinkAttributes>): boolean;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Open the edit popover anchored to a hyperlink. The prebuilt popover's
|
|
335
|
+
* Back button closes over `opts`, so no extra wiring is needed to
|
|
336
|
+
* return to the preview.
|
|
337
|
+
*/
|
|
338
|
+
declare function openEditHyperlink(opts: EditHyperlinkOptions): void;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Returns `false` when the host opted out (factory returned `null`, e.g. a
|
|
342
|
+
* mobile bottom sheet). The click handler gates caret placement on it —
|
|
343
|
+
* `.focus()` on an opting-out host makes iOS Safari scroll the editor.
|
|
344
|
+
*/
|
|
345
|
+
declare function openPreviewHyperlink(opts: PreviewHyperlinkOptions): boolean;
|
|
346
|
+
|
|
347
|
+
declare function createHyperlinkPopover(options: CreateHyperlinkOptions): HTMLElement;
|
|
348
|
+
|
|
349
|
+
declare function editHyperlinkPopover(options: EditHyperlinkOptions): HTMLElement;
|
|
350
|
+
|
|
351
|
+
declare function previewHyperlinkPopover(options: PreviewHyperlinkOptions): HTMLElement;
|
|
352
|
+
|
|
353
|
+
declare function hideTooltip(): void;
|
|
354
|
+
/** Returns a detach function for surfaces that re-render in place. */
|
|
355
|
+
declare function attachTooltip(target: HTMLElement, label: string): () => void;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Required `window.open` features. Without this arg the opened tab can
|
|
359
|
+
* read `window.opener` and the Referer leaks. Re-exported so popovers pin it.
|
|
360
|
+
*/
|
|
361
|
+
declare const SAFE_WINDOW_FEATURES: "noopener,noreferrer";
|
|
362
|
+
|
|
363
|
+
declare const copyToClipboard: (text: string, callback?: (success: boolean) => void) => Promise<boolean>;
|
|
364
|
+
|
|
365
|
+
declare const createHTMLElement: <K extends keyof HTMLElementTagNameMap>(type: K, props?: Partial<HTMLElementTagNameMap[K]>) => HTMLElementTagNameMap[K];
|
|
366
|
+
|
|
367
|
+
interface IconProps {
|
|
368
|
+
size?: number;
|
|
369
|
+
fill?: string;
|
|
370
|
+
}
|
|
371
|
+
declare const Copy: ({ size, fill }?: IconProps) => string;
|
|
372
|
+
declare const LinkOff: ({ size, fill }?: IconProps) => string;
|
|
373
|
+
declare const Pencil: ({ size, fill }?: IconProps) => string;
|
|
374
|
+
|
|
375
|
+
/** Catalog of app schemes and well-known domains. Source: https://github.com/bhagyas/app-urls */
|
|
376
|
+
/**
|
|
377
|
+
* Type-only union for consumer icon maps (`Partial<Record<SpecialUrlType, …>>`).
|
|
378
|
+
* Zero runtime bytes. Naming convention is in this package's AGENTS.md.
|
|
379
|
+
*/
|
|
380
|
+
type SpecialUrlType = 'email' | 'phone' | 'sms' | 'facetime' | 'facetime-audio' | 'whatsapp' | 'telegram' | 'discord' | 'skype' | 'slack' | 'twitter' | 'facebook' | 'instagram' | 'linkedin' | 'snapchat' | 'reddit' | 'tiktok' | 'zoom' | 'teams' | 'webex' | 'meet' | 'calendar' | 'reminders' | 'contacts' | 'maps' | 'music' | 'apple-tv' | 'notes' | 'photos' | 'shortcuts' | 'app-store' | 'github' | 'gitlab' | 'vscode' | 'notion' | 'obsidian' | 'figma' | 'youtube' | 'spotify' | 'netflix' | 'twitch' | 'amazon' | 'uber' | 'lyft';
|
|
381
|
+
type SpecialUrlInfo = {
|
|
382
|
+
type: SpecialUrlType;
|
|
383
|
+
title: string;
|
|
384
|
+
category: 'communication' | 'social' | 'productivity' | 'entertainment' | 'shopping' | 'development' | 'apple' | 'other';
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* Classify `url` against the catalog. `null` means a plain web URL (favicon).
|
|
388
|
+
* Icon mapping is the consumer's job; this package stays brand-neutral.
|
|
389
|
+
*/
|
|
390
|
+
declare const getSpecialUrlInfo: (url: string) => SpecialUrlInfo | null;
|
|
391
|
+
|
|
392
|
+
export { type AdoptMetadata, type BuildPreviewOptionsFromAnchorArgs, type ControllerState, Copy, type CreateHyperlinkOptions, DANGEROUS_SCHEME_RE, DEFAULT_OFFSET, type EditHyperlinkAttributes, type EditHyperlinkOptions, Hyperlink, type HyperlinkAttributes, type HyperlinkOptions, type HyperlinkPublicCommands, type HyperlinkStorage, type IconProps, type IsAllowedUriContext, LinkOff, type LinkProtocolOptions, type LinkifyMatchLike, Pencil, type Popover, type PopoverController, type PopoverKind, type PopoverOptions, type PreviewHyperlinkOptions, SAFE_WINDOW_FEATURES, type SetHyperlinkAttributes, type SpecialUrlInfo, type SpecialUrlType, type ValidateURLOptions, type VirtualCoordinates, attachTooltip, buildPreviewOptionsFromAnchor, copyToClipboard, createHTMLElement, createHyperlinkPopover, createPopover, Hyperlink as default, editHyperlinkPopover, getDefaultController, getSpecialUrlInfo, hideTooltip, isSafeHref, normalizeHref, openCreateHyperlink, openEditHyperlink, openPreviewHyperlink, previewHyperlinkPopover, validateURL };
|