asma-ui-richeditor 0.5.0 → 0.6.1
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/dist/asma-ui-richeditor.es.js +2217 -2073
- package/dist/src/rich-input/components/FontSizeSelect.d.ts +0 -1
- package/dist/src/rich-input/components/Toolbar.d.ts +3 -1
- package/dist/src/rich-input/components/ToolbarOverflowItem.d.ts +3 -1
- package/dist/src/rich-input/components/useTranslations.d.ts +22 -0
- package/dist/src/rich-input/hooks/useListboxTriggerKeyboard.hook.d.ts +37 -0
- package/dist/src/rich-input/hooks/useToggleMenuVisibility.hook.d.ts +1 -0
- package/dist/src/rich-input/interfaces/types.d.ts +4 -2
- package/dist/style.css +1 -2
- package/dist/tailwind.config.d.ts +1 -0
- package/package.json +4 -6
- package/dist/src/rich-input/components/CustomMenuItem.d.ts +0 -3
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Editor } from '@tiptap/react';
|
|
2
2
|
import { RefObject } from 'react';
|
|
3
3
|
import { ILocale } from '../interfaces/types';
|
|
4
|
-
export declare const Toolbar: ({ editor, onClose, error, focused, openLinkDialog, openEmojiPicker, locale, emojiButtonRef, }: {
|
|
4
|
+
export declare const Toolbar: ({ editor, onClose, error, focused, openLinkDialog, openEmojiPicker, linkDialogOpen, emojiPickerOpen, locale, emojiButtonRef, }: {
|
|
5
5
|
editor: Editor;
|
|
6
6
|
onClose: () => void;
|
|
7
7
|
error?: boolean;
|
|
8
8
|
focused: boolean;
|
|
9
9
|
openLinkDialog: () => void;
|
|
10
10
|
openEmojiPicker: () => void;
|
|
11
|
+
linkDialogOpen: boolean;
|
|
12
|
+
emojiPickerOpen: boolean;
|
|
11
13
|
locale?: ILocale;
|
|
12
14
|
emojiButtonRef?: RefObject<HTMLSpanElement>;
|
|
13
15
|
}) => import("node_modules/@types/react").JSX.Element;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
/** One entry of the toolbar's overflow ("more") menu. */
|
|
3
|
-
export declare const ToolbarOverflowItem: ({ title, selected, disabled, onSelect, children, }: {
|
|
3
|
+
export declare const ToolbarOverflowItem: ({ title, id, selected, disabled, active, onSelect, children, }: {
|
|
4
4
|
title: string;
|
|
5
|
+
id: string;
|
|
5
6
|
selected?: boolean;
|
|
6
7
|
disabled?: boolean;
|
|
8
|
+
active?: boolean;
|
|
7
9
|
onSelect: () => void;
|
|
8
10
|
children: ReactNode;
|
|
9
11
|
}) => import("node_modules/@types/react").JSX.Element;
|
|
@@ -12,6 +12,17 @@ export declare function useTranslations(locale?: ILocale): {
|
|
|
12
12
|
bullet_list: string;
|
|
13
13
|
font_size: string;
|
|
14
14
|
empty_selection_link: string;
|
|
15
|
+
show_formatting: string;
|
|
16
|
+
hide_formatting: string;
|
|
17
|
+
upload_image: string;
|
|
18
|
+
rich_text_editor: string;
|
|
19
|
+
add_link: string;
|
|
20
|
+
cancel: string;
|
|
21
|
+
link_url: string;
|
|
22
|
+
small: string;
|
|
23
|
+
normal: string;
|
|
24
|
+
large: string;
|
|
25
|
+
huge: string;
|
|
15
26
|
} | {
|
|
16
27
|
emojis: string;
|
|
17
28
|
heading1: string;
|
|
@@ -25,4 +36,15 @@ export declare function useTranslations(locale?: ILocale): {
|
|
|
25
36
|
bullet_list: string;
|
|
26
37
|
font_size: string;
|
|
27
38
|
empty_selection_link: string;
|
|
39
|
+
show_formatting: string;
|
|
40
|
+
hide_formatting: string;
|
|
41
|
+
upload_image: string;
|
|
42
|
+
rich_text_editor: string;
|
|
43
|
+
add_link: string;
|
|
44
|
+
cancel: string;
|
|
45
|
+
link_url: string;
|
|
46
|
+
small: string;
|
|
47
|
+
normal: string;
|
|
48
|
+
large: string;
|
|
49
|
+
huge: string;
|
|
28
50
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { KeyboardEvent as ReactKeyboardEvent } from 'react';
|
|
2
|
+
interface UseListboxTriggerKeyboardOptions {
|
|
3
|
+
/** Whether the popup listbox is currently open. */
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
/** Number of options in the listbox. */
|
|
6
|
+
itemCount: number;
|
|
7
|
+
/** Active index to start from when the listbox opens (e.g. the selected option). */
|
|
8
|
+
getInitialActiveIndex: () => number;
|
|
9
|
+
/** Open the listbox anchored to the given trigger element. */
|
|
10
|
+
onOpen: (element: HTMLElement) => void;
|
|
11
|
+
/** Close the listbox. */
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
/** Activate the option at `index`; `close` says whether the listbox should close afterwards. */
|
|
14
|
+
onSelect: (index: number, options: {
|
|
15
|
+
close: boolean;
|
|
16
|
+
}) => void;
|
|
17
|
+
/**
|
|
18
|
+
* When opening with ArrowUp/Down, also move the active option by the arrow direction (default `true`).
|
|
19
|
+
* Set `false` for action menus that should always open on the first option regardless of arrow key.
|
|
20
|
+
*/
|
|
21
|
+
moveActiveIndexOnOpen?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Keyboard contract for a button that opens a single-select listbox popup (WAI-ARIA combobox + listbox):
|
|
25
|
+
* ArrowUp/Down open+move, Home/End jump, Enter selects & closes, Space selects & keeps open (refocusing
|
|
26
|
+
* the trigger), Escape/Tab close. Tracks the roving `activeIndex` exposed via `aria-activedescendant`, and
|
|
27
|
+
* `keyboardActive` so the active-option highlight only shows during keyboard use.
|
|
28
|
+
*
|
|
29
|
+
* Shared by the rich-text toolbar's font-size select and overflow ("more") menu so both behave identically.
|
|
30
|
+
*/
|
|
31
|
+
export declare const useListboxTriggerKeyboard: ({ isOpen, itemCount, getInitialActiveIndex, onOpen, onClose, onSelect, moveActiveIndexOnOpen, }: UseListboxTriggerKeyboardOptions) => {
|
|
32
|
+
activeIndex: number;
|
|
33
|
+
keyboardActive: boolean;
|
|
34
|
+
openFromPointer: (element: HTMLElement) => void;
|
|
35
|
+
handleKeyDown: (event: ReactKeyboardEvent<HTMLButtonElement>) => void;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -2,5 +2,6 @@ export declare const useToggleMenuVisibility: () => {
|
|
|
2
2
|
open: boolean;
|
|
3
3
|
handleClose: () => void;
|
|
4
4
|
handleOpen: (event: React.MouseEvent<HTMLElement | SVGSVGElement>) => void;
|
|
5
|
+
openFromElement: (element: HTMLElement) => void;
|
|
5
6
|
anchorEl: HTMLElement | SVGSVGElement | null;
|
|
6
7
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ChipProps } from '@mui/material';
|
|
2
1
|
import { Editor, UseEditorOptions } from '@tiptap/react';
|
|
3
2
|
import { YoutubeOptions } from '@tiptap/extension-youtube';
|
|
4
3
|
import { RefObject } from 'react';
|
|
5
4
|
import { ImageOptions } from '@tiptap/extension-image';
|
|
5
|
+
import { StyledChipProps } from 'asma-ui-core';
|
|
6
6
|
export interface CustomCSSProperties extends React.CSSProperties {
|
|
7
7
|
'--max-scrollable-height'?: string;
|
|
8
8
|
}
|
|
@@ -18,6 +18,8 @@ export interface IRichInput extends UseEditorOptions {
|
|
|
18
18
|
* border once the editor is focused or has content (Figma DS "Rich text editor", node 20571-30699).
|
|
19
19
|
*/
|
|
20
20
|
label?: string;
|
|
21
|
+
/** Accessible name for the editable editor host. Takes precedence over `label`. */
|
|
22
|
+
'aria-label'?: string;
|
|
21
23
|
title?: string;
|
|
22
24
|
placeholder?: string;
|
|
23
25
|
/**
|
|
@@ -40,7 +42,7 @@ export interface IRichInput extends UseEditorOptions {
|
|
|
40
42
|
maxScrollableHeight?: number;
|
|
41
43
|
toolbarDefaultVisible?: boolean;
|
|
42
44
|
locale?: ILocale;
|
|
43
|
-
attachments?: (
|
|
45
|
+
attachments?: (StyledChipProps & {
|
|
44
46
|
key: string;
|
|
45
47
|
dataTest: string;
|
|
46
48
|
})[];
|