@astra-kit/ui 0.0.0-stage → 0.0.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 +15 -0
- package/LICENSE.md +21 -0
- package/README.md +384 -2
- package/THIRD_PARTY_NOTICES.md +31 -0
- package/assets/fonts/geist-LICENSE.txt +93 -0
- package/assets/fonts/geist-latin-variable.woff2 +0 -0
- package/assets/fonts/ibm-plex-mono-latin-400.woff2 +0 -0
- package/assets/fonts/ibm-plex-mono-latin-500.woff2 +0 -0
- package/assets/fonts/ibmplexmono-LICENSE.txt +93 -0
- package/assets/fonts/inter-LICENSE.txt +93 -0
- package/assets/fonts/inter-latin-variable.woff2 +0 -0
- package/dist/adapters/unpic-image.d.ts +3 -0
- package/dist/adapters/unpic-image.js +98 -0
- package/dist/components/account-menu.d.ts +67 -0
- package/dist/components/account-menu.js +440 -0
- package/dist/components/action-button.d.ts +25 -0
- package/dist/components/action-button.js +264 -0
- package/dist/components/alert.d.ts +31 -0
- package/dist/components/alert.js +503 -0
- package/dist/components/animated-collapse.d.ts +19 -0
- package/dist/components/animated-collapse.js +170 -0
- package/dist/components/animated-count.d.ts +13 -0
- package/dist/components/animated-count.js +105 -0
- package/dist/components/animated-list-item.d.ts +25 -0
- package/dist/components/animated-list-item.js +134 -0
- package/dist/components/animated-theme-toggler.d.ts +12 -0
- package/dist/components/animated-theme-toggler.js +200 -0
- package/dist/components/avatar.d.ts +65 -0
- package/dist/components/avatar.js +463 -0
- package/dist/components/badge.d.ts +21 -0
- package/dist/components/badge.js +297 -0
- package/dist/components/button-interaction.d.ts +23 -0
- package/dist/components/button-interaction.js +22 -0
- package/dist/components/button-label.d.ts +8 -0
- package/dist/components/button-label.js +203 -0
- package/dist/components/button.d.ts +23 -0
- package/dist/components/button.js +145 -0
- package/dist/components/calendar.d.ts +47 -0
- package/dist/components/calendar.js +155 -0
- package/dist/components/card.d.ts +38 -0
- package/dist/components/card.js +904 -0
- package/dist/components/carousel.d.ts +71 -0
- package/dist/components/carousel.js +585 -0
- package/dist/components/checkbox.d.ts +15 -0
- package/dist/components/checkbox.js +324 -0
- package/dist/components/control-button.d.ts +16 -0
- package/dist/components/control-button.js +215 -0
- package/dist/components/data-table.d.ts +118 -0
- package/dist/components/data-table.js +895 -0
- package/dist/components/dialog-surface.d.ts +49 -0
- package/dist/components/dialog-surface.js +220 -0
- package/dist/components/dialog.d.ts +92 -0
- package/dist/components/dialog.js +320 -0
- package/dist/components/dropdown-menu.d.ts +57 -0
- package/dist/components/dropdown-menu.js +107 -0
- package/dist/components/field.d.ts +53 -0
- package/dist/components/field.js +710 -0
- package/dist/components/file-upload.d.ts +88 -0
- package/dist/components/file-upload.js +776 -0
- package/dist/components/filter-presets-bar.d.ts +73 -0
- package/dist/components/filter-presets-bar.js +510 -0
- package/dist/components/filter-query-bar.d.ts +21 -0
- package/dist/components/filter-query-bar.js +881 -0
- package/dist/components/filter-query-grammar.d.ts +188 -0
- package/dist/components/filter-query-grammar.js +875 -0
- package/dist/components/form.d.ts +29 -0
- package/dist/components/form.js +330 -0
- package/dist/components/highlighter.d.ts +15 -0
- package/dist/components/highlighter.js +152 -0
- package/dist/components/hover-card.d.ts +50 -0
- package/dist/components/hover-card.js +80 -0
- package/dist/components/input-group.d.ts +16 -0
- package/dist/components/input-group.js +277 -0
- package/dist/components/input.d.ts +17 -0
- package/dist/components/input.js +120 -0
- package/dist/components/label.d.ts +4 -0
- package/dist/components/label.js +43 -0
- package/dist/components/link.d.ts +9 -0
- package/dist/components/link.js +43 -0
- package/dist/components/morph-text.d.ts +14 -0
- package/dist/components/morph-text.js +210 -0
- package/dist/components/pagination.d.ts +59 -0
- package/dist/components/pagination.js +190 -0
- package/dist/components/popover.d.ts +17 -0
- package/dist/components/popover.js +40 -0
- package/dist/components/presence-swap.d.ts +22 -0
- package/dist/components/presence-swap.js +209 -0
- package/dist/components/primitives/alert-dialog.d.ts +68 -0
- package/dist/components/primitives/alert-dialog.js +629 -0
- package/dist/components/primitives/avatar.d.ts +46 -0
- package/dist/components/primitives/avatar.js +265 -0
- package/dist/components/primitives/calendar.d.ts +37 -0
- package/dist/components/primitives/calendar.js +1250 -0
- package/dist/components/primitives/carousel.d.ts +106 -0
- package/dist/components/primitives/carousel.js +928 -0
- package/dist/components/primitives/dialog.d.ts +62 -0
- package/dist/components/primitives/dialog.js +490 -0
- package/dist/components/primitives/dropdown-menu-items.d.ts +59 -0
- package/dist/components/primitives/dropdown-menu-items.js +265 -0
- package/dist/components/primitives/dropdown-menu.d.ts +64 -0
- package/dist/components/primitives/dropdown-menu.js +560 -0
- package/dist/components/primitives/hover-card.d.ts +50 -0
- package/dist/components/primitives/hover-card.js +507 -0
- package/dist/components/primitives/pagination.d.ts +65 -0
- package/dist/components/primitives/pagination.js +373 -0
- package/dist/components/primitives/popover.d.ts +22 -0
- package/dist/components/primitives/popover.js +213 -0
- package/dist/components/primitives/select.d.ts +37 -0
- package/dist/components/primitives/select.js +428 -0
- package/dist/components/primitives/tooltip.d.ts +30 -0
- package/dist/components/primitives/tooltip.js +277 -0
- package/dist/components/progress-ring.d.ts +20 -0
- package/dist/components/progress-ring.js +53 -0
- package/dist/components/radio-group.d.ts +34 -0
- package/dist/components/radio-group.js +392 -0
- package/dist/components/reaction-button.d.ts +30 -0
- package/dist/components/reaction-button.js +189 -0
- package/dist/components/rich-link-editor.d.ts +25 -0
- package/dist/components/rich-link-editor.js +320 -0
- package/dist/components/rich-markdown-content.d.ts +10 -0
- package/dist/components/rich-markdown-content.js +56 -0
- package/dist/components/rich-text-content.d.ts +19 -0
- package/dist/components/rich-text-content.js +26 -0
- package/dist/components/select.d.ts +55 -0
- package/dist/components/select.js +188 -0
- package/dist/components/separator.d.ts +3 -0
- package/dist/components/separator.js +48 -0
- package/dist/components/sheet.d.ts +19 -0
- package/dist/components/sheet.js +420 -0
- package/dist/components/sidebar-panel-context.d.ts +17 -0
- package/dist/components/sidebar-panel-context.js +14 -0
- package/dist/components/sidebar.d.ts +195 -0
- package/dist/components/sidebar.js +2041 -0
- package/dist/components/skeleton.d.ts +23 -0
- package/dist/components/skeleton.js +334 -0
- package/dist/components/split-button.d.ts +36 -0
- package/dist/components/split-button.js +306 -0
- package/dist/components/svgs/whatsappIcon.d.ts +3 -0
- package/dist/components/svgs/whatsappIcon.js +14 -0
- package/dist/components/switch.d.ts +13 -0
- package/dist/components/switch.js +444 -0
- package/dist/components/table.d.ts +10 -0
- package/dist/components/table.js +298 -0
- package/dist/components/tabs.d.ts +36 -0
- package/dist/components/tabs.js +636 -0
- package/dist/components/textarea.d.ts +16 -0
- package/dist/components/textarea.js +111 -0
- package/dist/components/themed-toaster.d.ts +7 -0
- package/dist/components/themed-toaster.js +86 -0
- package/dist/components/toaster.d.ts +12 -0
- package/dist/components/toaster.js +62 -0
- package/dist/components/tooltip.d.ts +43 -0
- package/dist/components/tooltip.js +65 -0
- package/dist/components/typing-animation.d.ts +34 -0
- package/dist/components/typing-animation.js +389 -0
- package/dist/constants/action-button.d.ts +20 -0
- package/dist/constants/action-button.js +17 -0
- package/dist/constants/alert.d.ts +16 -0
- package/dist/constants/alert.js +13 -0
- package/dist/constants/avatar.d.ts +38 -0
- package/dist/constants/avatar.js +32 -0
- package/dist/constants/badge.d.ts +6 -0
- package/dist/constants/badge.js +6 -0
- package/dist/constants/button.d.ts +16 -0
- package/dist/constants/button.js +16 -0
- package/dist/constants/calendar.d.ts +36 -0
- package/dist/constants/calendar.js +34 -0
- package/dist/constants/card.d.ts +23 -0
- package/dist/constants/card.js +20 -0
- package/dist/constants/carousel.d.ts +55 -0
- package/dist/constants/carousel.js +74 -0
- package/dist/constants/checkbox.d.ts +17 -0
- package/dist/constants/checkbox.js +17 -0
- package/dist/constants/dialog.d.ts +11 -0
- package/dist/constants/dialog.js +10 -0
- package/dist/constants/dropdown-menu.d.ts +10 -0
- package/dist/constants/dropdown-menu.js +37 -0
- package/dist/constants/field.d.ts +24 -0
- package/dist/constants/field.js +24 -0
- package/dist/constants/hover-card.d.ts +37 -0
- package/dist/constants/hover-card.js +85 -0
- package/dist/constants/morph-text.d.ts +13 -0
- package/dist/constants/morph-text.js +13 -0
- package/dist/constants/motion.d.ts +12 -0
- package/dist/constants/motion.js +12 -0
- package/dist/constants/pagination.d.ts +20 -0
- package/dist/constants/pagination.js +20 -0
- package/dist/constants/popover.d.ts +7 -0
- package/dist/constants/popover.js +33 -0
- package/dist/constants/radio-group.d.ts +10 -0
- package/dist/constants/radio-group.js +10 -0
- package/dist/constants/select.d.ts +7 -0
- package/dist/constants/select.js +34 -0
- package/dist/constants/sidebar.d.ts +9 -0
- package/dist/constants/sidebar.js +17 -0
- package/dist/constants/skeleton.d.ts +17 -0
- package/dist/constants/skeleton.js +17 -0
- package/dist/constants/split-button.d.ts +7 -0
- package/dist/constants/split-button.js +5 -0
- package/dist/constants/switch.d.ts +33 -0
- package/dist/constants/switch.js +41 -0
- package/dist/constants/tabs.d.ts +17 -0
- package/dist/constants/tabs.js +17 -0
- package/dist/constants/toast.d.ts +3 -0
- package/dist/constants/toast.js +3 -0
- package/dist/constants/tooltip.d.ts +13 -0
- package/dist/constants/tooltip.js +52 -0
- package/dist/hooks/use-horizontal-swipe.d.ts +23 -0
- package/dist/hooks/use-horizontal-swipe.js +80 -0
- package/dist/hooks/use-is-hydrated.d.ts +6 -0
- package/dist/hooks/use-is-hydrated.js +20 -0
- package/dist/hooks/use-mobile.d.ts +1 -0
- package/dist/hooks/use-mobile.js +19 -0
- package/dist/hooks/use-prefers-reduced-motion.d.ts +2 -0
- package/dist/hooks/use-prefers-reduced-motion.js +27 -0
- package/dist/hooks/use-rich-link-editor.d.ts +55 -0
- package/dist/hooks/use-rich-link-editor.js +515 -0
- package/dist/hooks/use-sidebar-persistence.d.ts +6 -0
- package/dist/hooks/use-sidebar-persistence.js +52 -0
- package/dist/hooks/use-today.d.ts +7 -0
- package/dist/hooks/use-today.js +50 -0
- package/dist/hooks/use-viewer-time-zone.d.ts +6 -0
- package/dist/hooks/use-viewer-time-zone.js +20 -0
- package/dist/hooks.d.ts +11 -0
- package/dist/hooks.js +11 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.js +69 -0
- package/dist/lib/browser-clipboard.d.ts +13 -0
- package/dist/lib/browser-clipboard.js +48 -0
- package/dist/lib/column-filter-value.d.ts +12 -0
- package/dist/lib/column-filter-value.js +52 -0
- package/dist/lib/file-acceptance.d.ts +43 -0
- package/dist/lib/file-acceptance.js +107 -0
- package/dist/lib/format-file-size.d.ts +16 -0
- package/dist/lib/format-file-size.js +34 -0
- package/dist/lib/fuzzy-search.d.ts +17 -0
- package/dist/lib/fuzzy-search.js +183 -0
- package/dist/lib/horizontal-swipe.d.ts +23 -0
- package/dist/lib/horizontal-swipe.js +29 -0
- package/dist/lib/image-dimensions.d.ts +2 -0
- package/dist/lib/image-dimensions.js +7 -0
- package/dist/lib/name-initials.d.ts +7 -0
- package/dist/lib/name-initials.js +11 -0
- package/dist/lib/rich-text/link-markdown-constants.d.ts +147 -0
- package/dist/lib/rich-text/link-markdown-constants.js +458 -0
- package/dist/lib/rich-text/link-markdown-types.d.ts +53 -0
- package/dist/lib/rich-text/link-markdown-types.js +1 -0
- package/dist/lib/rich-text/link-markdown.d.ts +193 -0
- package/dist/lib/rich-text/link-markdown.js +592 -0
- package/dist/lib/rich-text/rich-markdown.d.ts +41 -0
- package/dist/lib/rich-text/rich-markdown.js +105 -0
- package/dist/lib/rich-text/rich-text-editor-dom.d.ts +26 -0
- package/dist/lib/rich-text/rich-text-editor-dom.js +79 -0
- package/dist/lib/toast-layer.d.ts +24 -0
- package/dist/lib/toast-layer.js +76 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +2 -0
- package/dist/lib/year-month-filter.d.ts +16 -0
- package/dist/lib/year-month-filter.js +46 -0
- package/dist/motion/arc-floating-slot.d.ts +40 -0
- package/dist/motion/arc-floating-slot.js +177 -0
- package/dist/motion/arc-press.d.ts +6 -0
- package/dist/motion/arc-press.js +59 -0
- package/dist/motion/arc-swap.d.ts +22 -0
- package/dist/motion/arc-swap.js +49 -0
- package/dist/motion/arc-tokens.d.ts +53 -0
- package/dist/motion/arc-tokens.js +73 -0
- package/dist/motion/glide-indicator.d.ts +69 -0
- package/dist/motion/glide-indicator.js +309 -0
- package/dist/motion/glide-slot.d.ts +9 -0
- package/dist/motion/glide-slot.js +71 -0
- package/dist/motion/motion-slot.d.ts +12 -0
- package/dist/motion/motion-slot.js +376 -0
- package/dist/motion/overlay-warmth.d.ts +24 -0
- package/dist/motion/overlay-warmth.js +70 -0
- package/dist/motion/presence.d.ts +40 -0
- package/dist/motion/presence.js +101 -0
- package/dist/motion/surface-keyframes.d.ts +24 -0
- package/dist/motion/surface-keyframes.js +141 -0
- package/dist/motion/tokens.d.ts +81 -0
- package/dist/motion/tokens.js +67 -0
- package/dist/motion/use-attached-element.d.ts +7 -0
- package/dist/motion/use-attached-element.js +22 -0
- package/dist/motion/use-morph-width.d.ts +13 -0
- package/dist/motion/use-morph-width.js +59 -0
- package/dist/next.d.ts +14 -0
- package/dist/next.js +79 -0
- package/dist/providers/astra-ui-provider.d.ts +27 -0
- package/dist/providers/astra-ui-provider.js +100 -0
- package/dist/providers/native-provider.d.ts +4 -0
- package/dist/providers/native-provider.js +45 -0
- package/dist/sonner.d.ts +7 -0
- package/dist/sonner.js +8 -0
- package/dist/styles.css +2 -0
- package/dist/tanstack.d.ts +11 -0
- package/dist/tanstack.js +50 -0
- package/dist/theme.d.ts +3 -0
- package/dist/theme.js +1 -0
- package/dist/types/data-table.d.ts +27 -0
- package/dist/types/data-table.js +1 -0
- package/fonts.css +5 -0
- package/package.json +450 -4
- package/styles.css +4 -0
- package/theme.css +248 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for the rich-text link layer.
|
|
3
|
+
*/
|
|
4
|
+
import type { RICH_LINK_KIND, RICH_PREVIEW_LINK_SOURCE, RICH_TEXT_SEGMENT_TYPE } from "./link-markdown-constants.js";
|
|
5
|
+
/** A parsed piece of rendered content: either plain text or a link. */
|
|
6
|
+
export type RichTextSegment = {
|
|
7
|
+
text: string;
|
|
8
|
+
type: typeof RICH_TEXT_SEGMENT_TYPE.text;
|
|
9
|
+
} | {
|
|
10
|
+
text: string;
|
|
11
|
+
type: typeof RICH_TEXT_SEGMENT_TYPE.link;
|
|
12
|
+
url: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A link tracked by the editor over its plain-text content. Explicit links carry
|
|
16
|
+
* a target URL; suppressed links mark an auto-detected URL the author removed.
|
|
17
|
+
*/
|
|
18
|
+
export type RichLink = {
|
|
19
|
+
end: number;
|
|
20
|
+
id: string;
|
|
21
|
+
isSynced: boolean;
|
|
22
|
+
kind: typeof RICH_LINK_KIND.explicit;
|
|
23
|
+
start: number;
|
|
24
|
+
url: string;
|
|
25
|
+
} | {
|
|
26
|
+
end: number;
|
|
27
|
+
id: string;
|
|
28
|
+
kind: typeof RICH_LINK_KIND.suppressed;
|
|
29
|
+
start: number;
|
|
30
|
+
};
|
|
31
|
+
/** A segment of the editor preview: plain text or an interactive link. */
|
|
32
|
+
export type RichPreviewSegment = {
|
|
33
|
+
text: string;
|
|
34
|
+
type: typeof RICH_TEXT_SEGMENT_TYPE.text;
|
|
35
|
+
} | {
|
|
36
|
+
end: number;
|
|
37
|
+
id?: string;
|
|
38
|
+
key: string;
|
|
39
|
+
source: typeof RICH_PREVIEW_LINK_SOURCE.automatic | typeof RICH_PREVIEW_LINK_SOURCE.explicit;
|
|
40
|
+
start: number;
|
|
41
|
+
text: string;
|
|
42
|
+
type: typeof RICH_TEXT_SEGMENT_TYPE.link;
|
|
43
|
+
url: string;
|
|
44
|
+
};
|
|
45
|
+
/** The link variant of a preview segment, used when editing a link. */
|
|
46
|
+
export type ActiveRichPreviewLink = Extract<RichPreviewSegment, {
|
|
47
|
+
type: typeof RICH_TEXT_SEGMENT_TYPE.link;
|
|
48
|
+
}>;
|
|
49
|
+
/** A character offset range within the editor's plain-text content. */
|
|
50
|
+
export type RichTextSelectionRange = {
|
|
51
|
+
end: number;
|
|
52
|
+
start: number;
|
|
53
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for the rich-text link layer: URL normalization, markdown
|
|
3
|
+
* link (de)serialization, plain-text autolink parsing, and editor link
|
|
4
|
+
* bookkeeping. None of these touch the DOM, so they are unit-testable in
|
|
5
|
+
* isolation and shared by the renderer, the editor hook, and persistence.
|
|
6
|
+
*/
|
|
7
|
+
import { RICH_PREVIEW_LINK_SOURCE, RICH_TEXT_EDITOR_WORD_DIRECTION } from "./link-markdown-constants.js";
|
|
8
|
+
import type { RichLink, RichPreviewSegment, RichTextSegment, RichTextSelectionRange } from "./link-markdown-types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Normalizes a raw markdown URL into a safe absolute `http(s)` URL, or `null`
|
|
11
|
+
* when it is not a usable web link. Bare domains gain an `https://` prefix.
|
|
12
|
+
*
|
|
13
|
+
* A candidate that contains whitespace is returned as its parsed `href`, which
|
|
14
|
+
* percent-encodes those characters. The renderer's `LINK_PATTERN.markdown` URL
|
|
15
|
+
* group forbids whitespace, so persisting the raw candidate would serialize a
|
|
16
|
+
* `[text](url with space)` link that cannot be read back and renders as broken
|
|
17
|
+
* markdown. Whitespace-free candidates are returned verbatim to preserve their
|
|
18
|
+
* exact form (no trailing slash, stable synchronization checks).
|
|
19
|
+
*
|
|
20
|
+
* A scheme-less candidate that parses into userinfo (`john.doe@example.com`) is
|
|
21
|
+
* rejected: the `bareDomain` pattern allows `@` in its trailing class, so an
|
|
22
|
+
* email or literal slips through and prepending `https://` would yield
|
|
23
|
+
* `https://john.doe@example.com`, where the browser reads `john.doe` as
|
|
24
|
+
* credentials for `example.com`. That turns the value into a misleading
|
|
25
|
+
* outbound link, against the convention that email addresses are not linked.
|
|
26
|
+
* The check uses the parsed `username`/`password` rather than a naive `@` scan
|
|
27
|
+
* so a legitimate `@` past the authority (a path or query) still links.
|
|
28
|
+
*/
|
|
29
|
+
export declare function normalizeMarkdownUrl(rawUrl: string | null | undefined): string | null;
|
|
30
|
+
/**
|
|
31
|
+
* Extracts the top-level domain (the last dot-separated label of the host) from
|
|
32
|
+
* a bare or scheme-prefixed candidate, lowercased, or `null` when the candidate
|
|
33
|
+
* has no host label past a dot. The host ends at the first path, query,
|
|
34
|
+
* fragment, or port boundary so a path segment is never mistaken for the TLD.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getCandidateTopLevelDomain(candidate: string): string | null;
|
|
37
|
+
/**
|
|
38
|
+
* Normalizes a candidate for the automatic detection path. Scheme-prefixed URLs
|
|
39
|
+
* are trusted and normalized as-is; a scheme-less bare domain is only accepted
|
|
40
|
+
* when its TLD is a recognized public suffix, so prose abbreviations such as
|
|
41
|
+
* `EE.UU.` or `China.Por` stay plain text instead of resolving to bogus hosts.
|
|
42
|
+
* Explicit paste-as-link flows keep using `normalizeMarkdownUrl` directly and
|
|
43
|
+
* stay permissive.
|
|
44
|
+
*/
|
|
45
|
+
export declare function normalizeAutolinkUrl(candidate: string): string | null;
|
|
46
|
+
/** Strips the `http(s)://` prefix from a value for synchronization checks. */
|
|
47
|
+
export declare function removeLinkProtocolPrefix(value: string): string;
|
|
48
|
+
/** Whether a link's visible text matches its URL ignoring the protocol. */
|
|
49
|
+
export declare function isLinkSynchronized(text: string, url: string): boolean;
|
|
50
|
+
/** Returns the protocol prefix of a URL, defaulting to `https://`. */
|
|
51
|
+
export declare function getLinkProtocolPrefix(url: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* Rebuilds the URL of a synchronized link after its visible text changed, so a
|
|
54
|
+
* link whose label is the URL keeps tracking the edited text.
|
|
55
|
+
*/
|
|
56
|
+
export declare function getSynchronizedLinkUrl(text: string, currentUrl: string): string | null;
|
|
57
|
+
/** Whether the value contains only whitespace. */
|
|
58
|
+
export declare function isWhitespaceOnly(value: string): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Computes the range a word-wise deletion (Ctrl/Alt+Backspace/Delete) should
|
|
61
|
+
* remove from a collapsed caret, mirroring native word deletion.
|
|
62
|
+
*/
|
|
63
|
+
export declare function getWordDeletionRange(input: {
|
|
64
|
+
direction: typeof RICH_TEXT_EDITOR_WORD_DIRECTION.backward | typeof RICH_TEXT_EDITOR_WORD_DIRECTION.forward;
|
|
65
|
+
selectionRange: RichTextSelectionRange;
|
|
66
|
+
text: string;
|
|
67
|
+
}): RichTextSelectionRange;
|
|
68
|
+
/**
|
|
69
|
+
* Percent-encodes the parentheses a URL cannot keep literal inside a
|
|
70
|
+
* `[text](url)` target, so an explicit link whose URL contains an unmatched or
|
|
71
|
+
* nested `(`/`)` (for example `https://example.com/a)b`) serializes to markdown
|
|
72
|
+
* that `LINK_PATTERN.markdown` reads back as the same link instead of truncating
|
|
73
|
+
* the target at the stray paren and spilling the rest into plain text.
|
|
74
|
+
*
|
|
75
|
+
* The URL group only matches balanced single-level `(...)` pairs, so those are
|
|
76
|
+
* preserved verbatim (keeping links like `.../Foo_(bar)` intact); every other
|
|
77
|
+
* paren becomes `%28`/`%29`, which is decoded back to the literal character when
|
|
78
|
+
* the link is opened.
|
|
79
|
+
*/
|
|
80
|
+
export declare function escapeMarkdownLinkUrl(url: string): string;
|
|
81
|
+
/** Builds a `[text](url)` markdown link, escaping the label and the URL. */
|
|
82
|
+
export declare function buildMarkdownLinkFromSelection(text: string, url: string): string;
|
|
83
|
+
/** Escapes characters that would break a markdown link label. */
|
|
84
|
+
export declare function escapeMarkdownLinkText(text: string): string;
|
|
85
|
+
/** Reverses `escapeMarkdownLinkText`, restoring line breaks and literals. */
|
|
86
|
+
export declare function unescapeMarkdownLinkText(text: string): string;
|
|
87
|
+
/** Builds a stable React key for a preview link segment. */
|
|
88
|
+
export declare function buildPreviewLinkKey(segment: {
|
|
89
|
+
id?: string;
|
|
90
|
+
source: typeof RICH_PREVIEW_LINK_SOURCE.automatic | typeof RICH_PREVIEW_LINK_SOURCE.explicit;
|
|
91
|
+
start: number;
|
|
92
|
+
url: string;
|
|
93
|
+
}): string;
|
|
94
|
+
/** Creates a plain-text rendered segment. */
|
|
95
|
+
export declare function createTextSegment(text: string): RichTextSegment;
|
|
96
|
+
/** Creates a link rendered segment. */
|
|
97
|
+
export declare function createLinkSegment(text: string, url: string): RichTextSegment;
|
|
98
|
+
/** Creates a plain-text editor preview segment. */
|
|
99
|
+
export declare function createTextPreviewSegment(text: string): RichPreviewSegment;
|
|
100
|
+
/** Creates a link editor preview segment with a stable key. */
|
|
101
|
+
export declare function createLinkPreviewSegment(input: {
|
|
102
|
+
end: number;
|
|
103
|
+
id?: string;
|
|
104
|
+
source: typeof RICH_PREVIEW_LINK_SOURCE.automatic | typeof RICH_PREVIEW_LINK_SOURCE.explicit;
|
|
105
|
+
start: number;
|
|
106
|
+
text: string;
|
|
107
|
+
url: string;
|
|
108
|
+
}): RichPreviewSegment;
|
|
109
|
+
/** Splits a matched bare URL from any trailing sentence punctuation. */
|
|
110
|
+
export declare function splitBareUrlMatch(matchedUrl: string): {
|
|
111
|
+
trailingText: string;
|
|
112
|
+
urlText: string;
|
|
113
|
+
};
|
|
114
|
+
/** Whether two `[start, end)` ranges overlap. */
|
|
115
|
+
export declare function rangesOverlap(firstRange: {
|
|
116
|
+
end: number;
|
|
117
|
+
start: number;
|
|
118
|
+
}, secondRange: {
|
|
119
|
+
end: number;
|
|
120
|
+
start: number;
|
|
121
|
+
}): boolean;
|
|
122
|
+
/** Whether a matched bare URL is actually part of an email address. */
|
|
123
|
+
export declare function isBareUrlMatchInsideEmail(input: {
|
|
124
|
+
content: string;
|
|
125
|
+
matchedIndex: number;
|
|
126
|
+
matchedUrl: string;
|
|
127
|
+
}): boolean;
|
|
128
|
+
/** Parses plain text into rendered segments, auto-linking bare URLs. */
|
|
129
|
+
export declare function parseBareUrlSegments(content: string): RichTextSegment[];
|
|
130
|
+
/** Parses plain text into editor preview segments, auto-linking bare URLs. */
|
|
131
|
+
export declare function parseBareUrlPreviewSegments(content: string, offset: number, suppressedLinks: RichLink[]): RichPreviewSegment[];
|
|
132
|
+
/**
|
|
133
|
+
* Parses the editor's plain-text content plus its tracked links into preview
|
|
134
|
+
* segments, layering explicit links over auto-detected bare URLs.
|
|
135
|
+
*/
|
|
136
|
+
export declare function parsePreviewSegments(content: string, links: RichLink[]): RichPreviewSegment[];
|
|
137
|
+
/**
|
|
138
|
+
* Whether a markdown link whose URL is not a safe web link is a genuine
|
|
139
|
+
* suppressed autolink (`[some-url.com](#)`) produced by the editor, rather than
|
|
140
|
+
* literal text that merely looks like a markdown link (`[PDF](pendiente)`).
|
|
141
|
+
*
|
|
142
|
+
* Suppression only applies when the label itself is a normalizable URL, which
|
|
143
|
+
* mirrors `serializeEditorContent`. Any other `[text](url)` whose URL cannot be
|
|
144
|
+
* normalized is treated as authored plain text and preserved verbatim.
|
|
145
|
+
*/
|
|
146
|
+
export declare function isSuppressedAutolinkMarkdown(linkText: string, linkUrl: string): boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Parses persisted content (markdown links plus bare URLs) into rendered
|
|
149
|
+
* segments for read-only display.
|
|
150
|
+
*/
|
|
151
|
+
export declare function parseRichTextSegments(content: string): RichTextSegment[];
|
|
152
|
+
/**
|
|
153
|
+
* Converts persisted markdown into the editor's plain-text content plus the
|
|
154
|
+
* tracked links (explicit and suppressed) needed to re-render it for editing.
|
|
155
|
+
*/
|
|
156
|
+
export declare function deserializeMarkdownForEditor(content: string): {
|
|
157
|
+
content: string;
|
|
158
|
+
links: RichLink[];
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Serializes the editor's plain-text content plus tracked links back into
|
|
162
|
+
* persisted markdown, emitting `[text](url)` for explicit links and
|
|
163
|
+
* `[text](#)` for suppressed auto-detected URLs.
|
|
164
|
+
*/
|
|
165
|
+
export declare function serializeEditorContent(content: string, links: RichLink[]): string;
|
|
166
|
+
/**
|
|
167
|
+
* Computes the minimal changed range between two strings: the common prefix
|
|
168
|
+
* end (`start`), the changed-region ends in each string, and the length delta.
|
|
169
|
+
*/
|
|
170
|
+
export declare function getTextDiff(input: {
|
|
171
|
+
nextText: string;
|
|
172
|
+
previousText: string;
|
|
173
|
+
}): {
|
|
174
|
+
delta: number;
|
|
175
|
+
endInNextText: number;
|
|
176
|
+
endInPreviousText: number;
|
|
177
|
+
start: number;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Adjusts tracked link ranges after the editor's plain text changed, shifting,
|
|
181
|
+
* shrinking, or dropping links and keeping synchronized links in step with
|
|
182
|
+
* their visible text.
|
|
183
|
+
*
|
|
184
|
+
* A suppressed autolink is dropped once its visible text is no longer a
|
|
185
|
+
* normalizable URL, mirroring `isSuppressedAutolinkMarkdown`: with nothing left
|
|
186
|
+
* to suppress, the edited text serializes as plain text instead of `[text](#)`,
|
|
187
|
+
* which would otherwise be rendered back as literal markdown.
|
|
188
|
+
*/
|
|
189
|
+
export declare function getLinksAfterTextChange(input: {
|
|
190
|
+
links: RichLink[];
|
|
191
|
+
nextText: string;
|
|
192
|
+
previousText: string;
|
|
193
|
+
}): RichLink[];
|