@apolitical/component-library 5.2.2 → 5.3.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.
@@ -1,6 +1,7 @@
1
1
  import { Dispatch } from 'react';
2
2
  import { Point } from 'slate';
3
3
  import { IListMemberData } from '../../../../../discussion';
4
+ import type { IEnrichedUrlData } from '../../../../../navigation';
4
5
  import { ReportError, IMentionPopOver } from './../../rich-text-editor.types';
5
6
  declare const RichTextEditorContext: import("react").Context<{
6
7
  /** The id of the editor */
@@ -19,8 +20,12 @@ declare const RichTextEditorContext: import("react").Context<{
19
20
  lastAnchor: Point | null;
20
21
  /** Whether the editor is inside a modal, used to handle portals for focus trap */
21
22
  isInOverlay?: string | false | undefined;
23
+ /** The data for the first link, to be displayed in the EnrichedUrl component. `undefined` is not set, `false` will not show the enriched url. (For cases where the user has manually removed it.) */
24
+ enrichedUrl?: IEnrichedUrlData | false | undefined;
22
25
  /** An optional function to call when a mention is inserted */
23
26
  onMention?: ((value?: IListMemberData) => void) | undefined;
27
+ /** The function to get metadata about a link */
28
+ getLinkPreview?: ((url: string) => Promise<IEnrichedUrlData>) | undefined;
24
29
  /** The function to update the state */
25
30
  dispatch: Dispatch<any>;
26
31
  /** The function to report an error */
@@ -1,3 +1,4 @@
1
1
  import { BaseEditor } from 'slate';
2
2
  export declare const getSelectedText: (editor: BaseEditor) => string | null;
3
3
  export declare const getAllText: (editor: BaseEditor) => string;
4
+ export declare const firstLinkData: (editor: BaseEditor) => string | null;
@@ -12,8 +12,8 @@ export default function transform<T extends InputNodeTypes>(node: MdastNode, opt
12
12
  position?: any;
13
13
  ordered?: boolean | undefined;
14
14
  checked?: any;
15
- depth?: 1 | 2 | 3 | 4 | 5 | 6 | undefined;
16
15
  lang?: string | undefined;
16
+ depth?: 1 | 2 | 3 | 4 | 5 | 6 | undefined;
17
17
  spread?: any;
18
18
  indent?: any;
19
19
  text: string | undefined;
@@ -1,3 +1,4 @@
1
+ export * from './with-link-removal-listener';
1
2
  export * from './with-linlines';
2
3
  export * from './with-mentions';
3
4
  export * from './without-empty-links';
@@ -0,0 +1 @@
1
+ export { default as withLinkRemovalListener } from './with-link-removal-listener';
@@ -0,0 +1,6 @@
1
+ import { BaseEditor } from 'slate';
2
+ import { HistoryEditor } from 'slate-history';
3
+ import { ReactEditor } from 'slate-react';
4
+ import { ReportError } from './../../rich-text-editor.types';
5
+ declare const withLinkRemovalListener: (editor: BaseEditor & ReactEditor & HistoryEditor, reportError: ReportError) => BaseEditor & ReactEditor & HistoryEditor;
6
+ export default withLinkRemovalListener;
@@ -1,43 +1,3 @@
1
- import type { IMentions, IListMemberData } from '../../../discussion/discussion';
2
- import { ListMembers, ReportError, ClickMentionFallback } from './rich-text-editor.types';
3
- interface Props {
4
- /** The id of the rich text editor */
5
- id?: string;
6
- /** The default value of the rich text editor */
7
- value?: string;
8
- /** The placeholder text of the rich text editor */
9
- placeholder?: string;
10
- /** The maximum length of the rich text editor */
11
- maxLength?: number;
12
- /** Information about the rich text editor */
13
- meta?: {
14
- /** Whether the rich text editor is inside a modal */
15
- isInOverlay?: false | 'string';
16
- };
17
- /** Optional functions */
18
- functions?: {
19
- /** An optional function to get a filtered list of members when the user starts typing a mention */
20
- listMembers?: ListMembers;
21
- /** An optional function to call when the user clicks the mention fallback, e.g. to show an invite modal */
22
- clickMentionFallback?: ClickMentionFallback;
23
- /** An optional event handler, called when the rich text editor is changed */
24
- onChange?: (value: string) => void;
25
- /** An optional function to call when a mention is inserted */
26
- onMention?: (value?: IListMemberData) => void;
27
- /** An optional event handler, called when the rich text editor reports an error */
28
- reportError?: ReportError;
29
- };
30
- /** Optional autoFocus */
31
- autoFocus?: boolean;
32
- /** Optional aria invalid */
33
- 'aria-invalid'?: boolean;
34
- /** Optional aria error message */
35
- 'aria-errormessage'?: string;
36
- /** Optional data for the editor */
37
- data?: {
38
- /** Optional mentions */
39
- mentions?: IMentions;
40
- };
41
- }
42
- declare const RichTextEditor: ({ id, value, placeholder, maxLength, meta, functions, autoFocus, data, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
1
+ import { IRTEProps } from './rich-text-editor.types';
2
+ declare const RichTextEditor: ({ id, value, placeholder, maxLength, meta, functions, autoFocus, data, ...props }: IRTEProps) => import("react/jsx-runtime").JSX.Element;
43
3
  export default RichTextEditor;
@@ -1,6 +1,69 @@
1
- import { BaseElement, BaseText, Descendant, Range } from 'slate';
2
- import type { IListMemberData } from '../../../discussion';
1
+ import { BaseElement, BaseText, Descendant, Point, Range } from 'slate';
2
+ import type { IListMemberData, IMentions } from '../../../discussion';
3
3
  import type { MemberDetailsProps } from '../../../user';
4
+ import type { IEnrichedUrlData } from '../../../navigation';
5
+ export interface IRTEProps {
6
+ /** The id of the rich text editor */
7
+ id?: string;
8
+ /** The default value of the rich text editor */
9
+ value?: string;
10
+ /** The placeholder text of the rich text editor */
11
+ placeholder?: string;
12
+ /** The maximum length of the rich text editor */
13
+ maxLength?: number;
14
+ /** Information about the rich text editor */
15
+ meta?: {
16
+ /** Whether the rich text editor is inside a modal */
17
+ isInOverlay?: false | 'string';
18
+ };
19
+ /** Optional functions */
20
+ functions?: {
21
+ /** An optional function to get a filtered list of members when the user starts typing a mention */
22
+ listMembers?: ListMembers;
23
+ /** An optional function to call when the user clicks the mention fallback, e.g. to show an invite modal */
24
+ clickMentionFallback?: ClickMentionFallback;
25
+ /** An optional function to get a preview of a link */
26
+ getLinkPreview?: (url: string) => Promise<IEnrichedUrlData>;
27
+ /** An optional event handler, called when the rich text editor is changed */
28
+ onChange?: (value: string) => void;
29
+ /** An optional function to call when a mention is inserted */
30
+ onMention?: (value?: IListMemberData) => void;
31
+ /** An optional event handler, called when the rich text editor reports an error */
32
+ reportError?: ReportError;
33
+ };
34
+ /** Optional autoFocus */
35
+ autoFocus?: boolean;
36
+ /** Optional aria invalid */
37
+ 'aria-invalid'?: boolean;
38
+ /** Optional aria error message */
39
+ 'aria-errormessage'?: string;
40
+ /** Optional data for the editor */
41
+ data?: {
42
+ /** Optional mentions */
43
+ mentions?: IMentions;
44
+ /** Optional data about the first link, to be displayed in the EnrichedUrl component */
45
+ link?: IEnrichedUrlData;
46
+ };
47
+ }
48
+ export interface IRTEInitialState {
49
+ editorKey: string | null;
50
+ originalValue: string | null;
51
+ initialValue: Descendant[] | null;
52
+ tabbableOption: string;
53
+ openTooltip: string | null;
54
+ showLinkEditor: boolean;
55
+ mentionPopover: IMentionPopOver;
56
+ lastAnchor: Point | null;
57
+ stringValue: string;
58
+ lastKey: string | null;
59
+ hasInteracted: boolean;
60
+ hasLoaded: boolean;
61
+ enrichedUrl: IEnrichedUrlData | false | undefined;
62
+ }
63
+ export interface IRTEReducer {
64
+ type: keyof IRTEInitialState;
65
+ value: any;
66
+ }
4
67
  export declare enum Formatting {
5
68
  blockquote = "block_quote",
6
69
  bold = "bold",
package/helpers/intl.d.ts CHANGED
@@ -286,6 +286,9 @@ export declare const checkIntlPathExists: (path: string, language?: {
286
286
  richTextEditor_link_edit: string;
287
287
  richTextEditor_link_remove: string;
288
288
  richTextEditor_link_button: string;
289
+ richTextEditor_link_enrichedUrl_aria: string;
290
+ richTextEditor_link_enrichedUrl_aria_fallback: string;
291
+ richTextEditor_link_enrichedUrl_aria_live: string;
289
292
  richTextEditor_ol_list: string;
290
293
  richTextEditor_ul_list: string;
291
294
  richTextEditor_block_quote: string;