@apolitical/component-library 4.1.10-ac.1 → 4.1.10-beta.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/constants/index.d.ts +1 -0
- package/constants/regex.d.ts +1 -0
- package/form/components/rich-text-editor/components/context/context.d.ts +3 -1
- package/form/components/rich-text-editor/components/editor/index.d.ts +1 -0
- package/form/components/rich-text-editor/components/editor/mention-popover/index.d.ts +1 -0
- package/form/components/rich-text-editor/components/editor/mention-popover/mention-popover.d.ts +2 -0
- package/form/components/rich-text-editor/helpers/ast-types/ast-types.d.ts +4 -1
- package/form/components/rich-text-editor/helpers/index.d.ts +1 -0
- package/form/components/rich-text-editor/helpers/mentions/index.d.ts +2 -0
- package/form/components/rich-text-editor/helpers/mentions/insert-mention.d.ts +5 -0
- package/form/components/rich-text-editor/helpers/mentions/should-show-mentions-popover.d.ts +5 -0
- package/form/components/rich-text-editor/plugins/index.d.ts +1 -0
- package/form/components/rich-text-editor/plugins/with-mentions/index.d.ts +1 -0
- package/form/components/rich-text-editor/plugins/with-mentions/with-mentions.d.ts +6 -0
- package/form/components/rich-text-editor/rich-text-editor.const.d.ts +1 -0
- package/form/components/rich-text-editor/rich-text-editor.d.ts +10 -2
- package/form/components/rich-text-editor/rich-text-editor.types.d.ts +25 -2
- package/general/index.d.ts +1 -0
- package/general/popover/index.d.ts +1 -0
- package/general/popover/popover.d.ts +11 -0
- package/helpers/intl.d.ts +0 -2
- package/index.js +49 -49
- package/index.mjs +5937 -5788
- package/package.json +1 -1
- package/style.css +1 -1
- package/styles/variables/colors/theme/_discussion.scss +1 -0
- package/styles/variables/colors/theme/_form.scss +1 -0
- package/styles/variables/colors/theme/_general.scss +3 -0
- package/user/member/member.d.ts +9 -2
- package/discussion/components/post/components/share-link/index.d.ts +0 -1
- package/discussion/components/post/components/share-link/share-link.d.ts +0 -6
package/constants/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const UUID_V4_REGEX: RegExp;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dispatch } from 'react';
|
|
2
2
|
import { Point } from 'slate';
|
|
3
|
-
import { ReportError } from './../../rich-text-editor.types';
|
|
3
|
+
import { ReportError, IMentionPopOver } from './../../rich-text-editor.types';
|
|
4
4
|
declare const RichTextEditorContext: import("react").Context<{
|
|
5
5
|
/** The id of the editor */
|
|
6
6
|
id: string;
|
|
@@ -12,6 +12,8 @@ declare const RichTextEditorContext: import("react").Context<{
|
|
|
12
12
|
openTooltip: string | null;
|
|
13
13
|
/** Whether the link editor is open */
|
|
14
14
|
showLinkEditor: boolean;
|
|
15
|
+
/** The data for the mention popover, including if it's showing, the selected user for the popover, and the possible users */
|
|
16
|
+
mentionPopover: IMentionPopOver;
|
|
15
17
|
/** The last anchor point (used for Slate to know where the cursor is) */
|
|
16
18
|
lastAnchor: Point | null;
|
|
17
19
|
/** The function to update the state */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as MentionPopover } from './mention-popover';
|
|
@@ -7,6 +7,7 @@ export interface NodeTypes {
|
|
|
7
7
|
[Formatting.ul]: string;
|
|
8
8
|
[Formatting.ol]: string;
|
|
9
9
|
[Formatting.li]: string;
|
|
10
|
+
[Formatting.mention]: string;
|
|
10
11
|
[Formatting.heading]: {
|
|
11
12
|
1: string;
|
|
12
13
|
2: string;
|
|
@@ -28,6 +29,7 @@ export declare enum MdastNodes {
|
|
|
28
29
|
list = "list",
|
|
29
30
|
listItem = "listItem",
|
|
30
31
|
link = "link",
|
|
32
|
+
mention = "mention",
|
|
31
33
|
image = "image",
|
|
32
34
|
blockquote = "blockquote",
|
|
33
35
|
code = "code",
|
|
@@ -39,7 +41,7 @@ export declare enum MdastNodes {
|
|
|
39
41
|
thematicBreak = "thematicBreak",
|
|
40
42
|
text = "text"
|
|
41
43
|
}
|
|
42
|
-
export type MdastNodeType = MdastNodes.paragraph | MdastNodes.heading | MdastNodes.list | MdastNodes.listItem | MdastNodes.link | MdastNodes.image | MdastNodes.blockquote | MdastNodes.code | MdastNodes.html | MdastNodes.emphasis | MdastNodes.strong | MdastNodes.delete | MdastNodes.inlineCode | MdastNodes.thematicBreak | MdastNodes.text;
|
|
44
|
+
export type MdastNodeType = MdastNodes.paragraph | MdastNodes.heading | MdastNodes.list | MdastNodes.listItem | MdastNodes.link | MdastNodes.mention | MdastNodes.image | MdastNodes.blockquote | MdastNodes.code | MdastNodes.html | MdastNodes.emphasis | MdastNodes.strong | MdastNodes.delete | MdastNodes.inlineCode | MdastNodes.thematicBreak | MdastNodes.text;
|
|
43
45
|
export declare const defaultNodeTypes: NodeTypes;
|
|
44
46
|
export interface LeafType {
|
|
45
47
|
text: string;
|
|
@@ -53,6 +55,7 @@ export interface BlockType {
|
|
|
53
55
|
type: string;
|
|
54
56
|
parentType?: string;
|
|
55
57
|
link?: string;
|
|
58
|
+
mention?: string;
|
|
56
59
|
caption?: string;
|
|
57
60
|
language?: string;
|
|
58
61
|
break?: boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Dispatch } from 'react';
|
|
2
|
+
import { BaseEditor } from 'slate';
|
|
3
|
+
import { IMentionPopOver } from './../../rich-text-editor.types';
|
|
4
|
+
declare const insertMention: (editor: BaseEditor, mentionPopover: IMentionPopOver, dispatch: Dispatch<any>) => void;
|
|
5
|
+
export default insertMention;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Dispatch } from 'react';
|
|
2
|
+
import { BaseEditor } from 'slate';
|
|
3
|
+
import { type GetUsers } from './../../rich-text-editor.types';
|
|
4
|
+
declare const shouldShowMentionsPopover: (editor: BaseEditor, isShowing: boolean, getUsers: GetUsers | undefined, dispatch: Dispatch<any>) => Promise<void>;
|
|
5
|
+
export default shouldShowMentionsPopover;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as withMentions } from './with-mentions';
|
|
@@ -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 withMentions: (editor: BaseEditor & ReactEditor & HistoryEditor, reportError: ReportError) => BaseEditor & ReactEditor & HistoryEditor;
|
|
6
|
+
export default withMentions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mentionIdentifier = "MENTION: ";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IMentions } from '../../../discussion/discussion';
|
|
2
|
+
import { GetUsers, ReportError } from './rich-text-editor.types';
|
|
2
3
|
interface Props {
|
|
3
4
|
/** The id of the rich text editor */
|
|
4
5
|
id?: string;
|
|
@@ -10,6 +11,8 @@ interface Props {
|
|
|
10
11
|
maxLength?: number;
|
|
11
12
|
/** Optional functions */
|
|
12
13
|
functions?: {
|
|
14
|
+
/** An optional function to get a filtered list of members when the user starts typing a mention */
|
|
15
|
+
getUsers?: GetUsers;
|
|
13
16
|
/** An optional event handler, called when the rich text editor is changed */
|
|
14
17
|
onChange?: (value: string) => void;
|
|
15
18
|
/** An optional event handler, called when the rich text editor reports an error */
|
|
@@ -21,6 +24,11 @@ interface Props {
|
|
|
21
24
|
'aria-invalid'?: boolean;
|
|
22
25
|
/** Optional aria error message */
|
|
23
26
|
'aria-errormessage'?: string;
|
|
27
|
+
/** Optional data for the editor */
|
|
28
|
+
data?: {
|
|
29
|
+
/** Optional mentions */
|
|
30
|
+
mentions?: IMentions;
|
|
31
|
+
};
|
|
24
32
|
}
|
|
25
|
-
declare const RichTextEditor: ({ id, value, placeholder, maxLength, functions, autoFocus, ...props }: Props) => import("react/jsx-runtime").JSX.Element | null;
|
|
33
|
+
declare const RichTextEditor: ({ id, value, placeholder, maxLength, functions, autoFocus, data, ...props }: Props) => import("react/jsx-runtime").JSX.Element | null;
|
|
26
34
|
export default RichTextEditor;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { BaseElement, BaseText, Descendant } from 'slate';
|
|
1
|
+
import { BaseElement, BaseText, Descendant, Range } from 'slate';
|
|
2
|
+
import type { MemberDetailsProps } from '../../../user';
|
|
2
3
|
export declare enum Formatting {
|
|
3
4
|
blockquote = "block_quote",
|
|
4
5
|
bold = "bold",
|
|
@@ -10,6 +11,7 @@ export declare enum Formatting {
|
|
|
10
11
|
italic = "italic",
|
|
11
12
|
li = "list_item",
|
|
12
13
|
link = "link",
|
|
14
|
+
mention = "mention",
|
|
13
15
|
ol = "ol_list",
|
|
14
16
|
paragraph = "paragraph",
|
|
15
17
|
ul = "ul_list",
|
|
@@ -26,10 +28,15 @@ export interface BaseProps {
|
|
|
26
28
|
className?: string;
|
|
27
29
|
[key: string]: unknown;
|
|
28
30
|
}
|
|
29
|
-
export type BlockOptionType = Formatting.blockquote | Formatting.link | Formatting.li | Formatting.ol | Formatting.ul | Formatting.paragraph | Formatting.span;
|
|
31
|
+
export type BlockOptionType = Formatting.blockquote | Formatting.link | Formatting.li | Formatting.mention | Formatting.ol | Formatting.ul | Formatting.paragraph | Formatting.span;
|
|
30
32
|
export interface TypeElement extends BaseElement {
|
|
31
33
|
type: BlockOptionType;
|
|
32
34
|
}
|
|
35
|
+
export interface MentionElement extends BaseElement {
|
|
36
|
+
type: Formatting.mention;
|
|
37
|
+
id: string;
|
|
38
|
+
name?: string;
|
|
39
|
+
}
|
|
33
40
|
export type MarkOptionType = Formatting.bold | Formatting.italic | Formatting.strikethrough;
|
|
34
41
|
export interface TypeText extends BaseText {
|
|
35
42
|
[Formatting.bold]?: boolean;
|
|
@@ -46,3 +53,19 @@ export type LinkElement = {
|
|
|
46
53
|
children: Descendant[];
|
|
47
54
|
};
|
|
48
55
|
export type ReportError = (error: string) => void;
|
|
56
|
+
export interface IMention {
|
|
57
|
+
id: string;
|
|
58
|
+
creator?: boolean;
|
|
59
|
+
role?: string;
|
|
60
|
+
createdAt?: string;
|
|
61
|
+
updatedAt?: string;
|
|
62
|
+
userId?: string;
|
|
63
|
+
user: MemberDetailsProps;
|
|
64
|
+
}
|
|
65
|
+
export type GetUsers = (search: string) => Promise<IMention[]>;
|
|
66
|
+
export interface IMentionPopOver {
|
|
67
|
+
show: boolean;
|
|
68
|
+
selectedUser: number;
|
|
69
|
+
possibleUsers: IMention[];
|
|
70
|
+
position: Range | null;
|
|
71
|
+
}
|
package/general/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Popover } from './popover';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Additional className */
|
|
4
|
+
className?: string;
|
|
5
|
+
/** The content of the popover */
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/** Optional keydown event */
|
|
8
|
+
onKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: ({ className, children }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default _default;
|
package/helpers/intl.d.ts
CHANGED
|
@@ -146,8 +146,6 @@ export declare const checkIntlPathExists: (path: string, language?: {
|
|
|
146
146
|
discussion_responses_empty: string;
|
|
147
147
|
discussion_responses_empty_answer: string;
|
|
148
148
|
discussion_responses_placeholder: string;
|
|
149
|
-
discussion_share_copy_link: string;
|
|
150
|
-
discussion_share_copy_link_success: string;
|
|
151
149
|
discussion_thread_show: string;
|
|
152
150
|
discussion_thread_hide: string;
|
|
153
151
|
discussion_thread_loadMore: string;
|