@skbkontur/markdown 2.7.0-alpha.6 → 2.7.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/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/Markdown/Markdown.d.ts +2 -2
- package/src/Markdown/MarkdownActions/MarkdownActions.d.ts +2 -2
- package/src/Markdown/MarkdownActions/MarkdownActions.js +6 -6
- package/src/Markdown/MarkdownEditor.d.ts +2 -2
- package/src/Markdown/MarkdownHelpers/markdownHelpers.d.ts +2 -2
- package/src/Markdown/MarkdownHelpers/markdownHelpers.js +1 -1
- package/src/Markdown/MarkdownHelpers/markdownListEnterHelpers.d.ts +1 -1
- package/src/Markdown/types.d.ts +11 -2
- package/src/Markdown/types.js +10 -0
package/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export { Markdown, MarkdownProps } from './src/Markdown/Markdown';
|
|
|
2
2
|
export { MarkdownCombination } from './src/MarkdownCombination/MarkdownCombination';
|
|
3
3
|
export { markdownHelpItems, markdownHelpFiles, markdownHelpLists, markdownHelpOther, } from './src/Markdown/MarkdownHelpItems';
|
|
4
4
|
export { MarkdownViewer } from './src/MarkdownViewer/MarkdownViewer';
|
|
5
|
-
export { MarkdownApi, RefItem, User, Token, HorizontalPaddings, ViewMode, ActionsOptions, AIMethod, AIApi,
|
|
5
|
+
export { MarkdownApi, RefItem, User, Token, HorizontalPaddings, ViewMode, ActionsOptions, ActionsOptionsKeys, AIMethod, AIApi, } from '././src/Markdown/types';
|
|
6
6
|
export { ThemeMode, ColorScheme } from './src/styles/types';
|
|
7
7
|
export { MarkdownTheme, MarkdownThemeProvider, MarkdownThemeConsumer, MarkdownThemeContext } from './src/styles/theme';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
2
|
import { MarkdownEditorProps } from './MarkdownEditor';
|
|
3
|
-
import { ActionsOptions,
|
|
3
|
+
import { ActionsOptions, ActionsOptionsKeys, HorizontalPaddings, MarkdownApi, ViewMode } from './types';
|
|
4
4
|
export interface MarkdownProps extends MarkdownEditorProps {
|
|
5
5
|
/** Методы апи для загрузки/скачивания файлов, меншена, ИИ */
|
|
6
6
|
api?: MarkdownApi;
|
|
@@ -15,7 +15,7 @@ export interface MarkdownProps extends MarkdownEditorProps {
|
|
|
15
15
|
/** Колбек, срабатывает на изменение режима редактирования или просмотра */
|
|
16
16
|
onChangeViewMode?: (mode: ViewMode) => void;
|
|
17
17
|
/** Колбек для отправки метрик */
|
|
18
|
-
onTrackEvent?: (category:
|
|
18
|
+
onTrackEvent?: (category: ActionsOptionsKeys, action: 'click' | 'hotkey', label?: string) => void;
|
|
19
19
|
/** Padding markdownActions (кнопки помощи форматирования текста), включает режим panel */
|
|
20
20
|
panelHorizontalPadding?: number;
|
|
21
21
|
/** Url для профиля сотрудника */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Textarea } from '@skbkontur/react-ui';
|
|
2
2
|
import { FC, RefObject } from 'react';
|
|
3
3
|
import { EmojiData } from '../Emoji/Emoji.logic';
|
|
4
|
-
import { AIApi, ActionsOptions,
|
|
4
|
+
import { AIApi, ActionsOptions, ActionsOptionsKeys, HorizontalPaddings, Nullable, ViewMode } from '../types';
|
|
5
5
|
interface Props {
|
|
6
6
|
horizontalPaddings: HorizontalPaddings;
|
|
7
7
|
onChangeViewMode: (viewMode: ViewMode) => void;
|
|
@@ -20,7 +20,7 @@ interface Props {
|
|
|
20
20
|
isFocused?: boolean;
|
|
21
21
|
isSplitViewAvailable?: boolean;
|
|
22
22
|
loadingFile?: boolean;
|
|
23
|
-
onTrackEvent?: (category:
|
|
23
|
+
onTrackEvent?: (category: ActionsOptionsKeys, action: 'click' | 'hotkey', label?: string) => void;
|
|
24
24
|
selectionEnd?: Nullable<number>;
|
|
25
25
|
selectionStart?: Nullable<number>;
|
|
26
26
|
width?: Nullable<number | string>;
|
|
@@ -17,7 +17,7 @@ import { MarkdownFormatButton } from '../MarkdownHelpers/MarkdownFormatButton';
|
|
|
17
17
|
import { setMarkdown } from '../MarkdownHelpers/markdownHelpers';
|
|
18
18
|
import { markdownHelpHeaders, markdownHelpLists, markdownHelpOther, markdownHelpText } from '../MarkdownHelpItems';
|
|
19
19
|
import { MarkdownTids } from '../MarkdownTids';
|
|
20
|
-
import { ViewMode } from '../types';
|
|
20
|
+
import { ViewMode, MarkdownOtherActions, } from '../types';
|
|
21
21
|
export const MarkdownActions = ({ textAreaRef, selectionStart, selectionEnd, loadingFile, onOpenFileDialog, onClickFullscreen, fullscreen, viewMode, onChangeViewMode, horizontalPaddings, hasFilesApi, width, showActionHints, showShortKeys, hideOptions, onTrackEvent, onSelectEmoji, isSplitViewAvailable, disableFullscreen, AIApi, }) => {
|
|
22
22
|
const isPreviewMode = viewMode === ViewMode.Preview;
|
|
23
23
|
return (React.createElement(MarkdownActionsWrapper, { ...horizontalPaddings, width: width, fullscreen: fullscreen },
|
|
@@ -44,13 +44,13 @@ export const MarkdownActions = ({ textAreaRef, selectionStart, selectionEnd, loa
|
|
|
44
44
|
handleTrackClick(MarkdownFormat.file);
|
|
45
45
|
onOpenFileDialog();
|
|
46
46
|
} })),
|
|
47
|
-
!hideOptions?.emoji && (React.createElement(EmojiDropdown, { showActionHint: showActionHints, showShortKey: showShortKeys, isPreviewMode: isPreviewMode, onTrackEvent: () => handleTrackClick(
|
|
48
|
-
!hideOptions?.AI && !!AIApi && (React.createElement(AIActionsDropdown, { showActionHint: showActionHints, textareaRef: textAreaRef, isPreviewMode: isPreviewMode, api: AIApi, onTrackEvent: label => handleTrackClick(
|
|
47
|
+
!hideOptions?.emoji && (React.createElement(EmojiDropdown, { showActionHint: showActionHints, showShortKey: showShortKeys, isPreviewMode: isPreviewMode, onTrackEvent: () => handleTrackClick(MarkdownOtherActions.Emoji), onSelect: onSelectEmoji })),
|
|
48
|
+
!hideOptions?.AI && !!AIApi && (React.createElement(AIActionsDropdown, { showActionHint: showActionHints, textareaRef: textAreaRef, isPreviewMode: isPreviewMode, api: AIApi, onTrackEvent: label => handleTrackClick(MarkdownOtherActions.AI, label) }))),
|
|
49
49
|
React.createElement(ActionsRightWrapper, null,
|
|
50
|
-
!hideOptions?.help && (React.createElement(MarkdownFormatButton, { showActionHint: showActionHints, dataTid: MarkdownTids.Help, hintText: "\u0414\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430\u0446\u0438\u044F Markdown", icon: React.createElement(DocIcon, null), text: "\u0414\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430\u0446\u0438\u044F Markdown", href: COMMONMARK_HELP_URL, onClick: () => handleTrackClick(
|
|
50
|
+
!hideOptions?.help && (React.createElement(MarkdownFormatButton, { showActionHint: showActionHints, dataTid: MarkdownTids.Help, hintText: "\u0414\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430\u0446\u0438\u044F Markdown", icon: React.createElement(DocIcon, null), text: "\u0414\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430\u0446\u0438\u044F Markdown", href: COMMONMARK_HELP_URL, onClick: () => handleTrackClick(MarkdownOtherActions.Help) })),
|
|
51
51
|
!hideOptions?.viewMode && renderViewModeButton(),
|
|
52
52
|
!hideOptions?.screenMode && !disableFullscreen && (React.createElement(MarkdownFormatButton, { showActionHint: showActionHints, dataTid: MarkdownTids.FullscreenToggle, hintText: fullscreen ? 'Свернуть' : 'Развернуть', icon: fullscreen ? React.createElement(Collapse, null) : React.createElement(Expand, null), text: fullscreen ? 'Свернуть' : ' Развернуть', onClick: () => {
|
|
53
|
-
handleTrackClick(
|
|
53
|
+
handleTrackClick(MarkdownOtherActions.ScreenMode);
|
|
54
54
|
onClickFullscreen();
|
|
55
55
|
} }))))));
|
|
56
56
|
function renderViewModeButton() {
|
|
@@ -77,7 +77,7 @@ export const MarkdownActions = ({ textAreaRef, selectionStart, selectionEnd, loa
|
|
|
77
77
|
return hideOptions?.[format];
|
|
78
78
|
}
|
|
79
79
|
function handleChangeViewMode(mode) {
|
|
80
|
-
handleTrackClick(
|
|
80
|
+
handleTrackClick(MarkdownOtherActions.ViewMode, mode);
|
|
81
81
|
onChangeViewMode(mode);
|
|
82
82
|
}
|
|
83
83
|
function handleTrackClick(category, label) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Textarea, TextareaProps } from '@skbkontur/react-ui';
|
|
2
2
|
import { ValidationInfo, RenderErrorMessage } from '@skbkontur/react-ui-validations';
|
|
3
3
|
import { FC, RefObject } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { ActionsOptionsKeys, Nullable } from './types';
|
|
5
5
|
export interface MarkdownEditorProps extends Omit<TextareaProps, 'rows' | 'maxRows' | 'disableAnimations' | 'extraRow'> {
|
|
6
6
|
disableAnimations?: boolean;
|
|
7
7
|
extraRow?: boolean;
|
|
8
8
|
maxRows?: number;
|
|
9
|
-
onTrackEvent?: (category:
|
|
9
|
+
onTrackEvent?: (category: ActionsOptionsKeys, action: 'click' | 'hotkey', label?: string) => void;
|
|
10
10
|
/** Рендер сообщения валидации react-ui-validations */
|
|
11
11
|
renderMessage?: Nullable<RenderErrorMessage>;
|
|
12
12
|
rows?: number;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Textarea } from '@skbkontur/react-ui';
|
|
2
2
|
import { KeyboardEvent as ReactKeyboardEvent, RefObject } from 'react';
|
|
3
3
|
import { MarkdownFormat } from '../MarkdownFormat';
|
|
4
|
-
import {
|
|
4
|
+
import { ActionsOptionsKeys, Nullable, RefItem } from '../types';
|
|
5
5
|
export { handleMarkdownListEnter } from './markdownListEnterHelpers';
|
|
6
6
|
export declare function setMarkdown(textareaNode: HTMLTextAreaElement, text: string, format: MarkdownFormat, selectionStart: number, selectionEnd?: number | null): void;
|
|
7
7
|
export declare function setMarkdownFiles(file: RefItem, textarea: Textarea, format: MarkdownFormat, cursorPosition?: number | null, fileApiUrl?: string): void;
|
|
8
8
|
export declare function setMarkdownPastedHtml(text: string, textareaNode: HTMLTextAreaElement): void;
|
|
9
9
|
export declare function setTextareaCursor(format: MarkdownFormat, prevCommentPartLength: number, nextCommentPartLength: number, textareaNode: HTMLTextAreaElement, selectionEnd: number): void;
|
|
10
|
-
export declare function createMarkdownHelpKeyDownHandler(text: string, ref?: RefObject<Textarea> | null, callback?: (event: ReactKeyboardEvent<HTMLTextAreaElement>) => void, onTrackHotkey?: (category:
|
|
10
|
+
export declare function createMarkdownHelpKeyDownHandler(text: string, ref?: RefObject<Textarea> | null, callback?: (event: ReactKeyboardEvent<HTMLTextAreaElement>) => void, onTrackHotkey?: (category: ActionsOptionsKeys, label?: string) => void): (event: ReactKeyboardEvent<HTMLTextAreaElement>) => void;
|
|
11
11
|
export declare const usePasteFromClipboard: (textarea: Nullable<Textarea>, uploadFileApi?: ((file: File) => Promise<RefItem>) | undefined, downloadFileApi?: ((id: string) => Promise<File>) | undefined, fileApiUrl?: string) => void;
|
|
@@ -77,7 +77,7 @@ export function createMarkdownHelpKeyDownHandler(text, ref, callback, onTrackHot
|
|
|
77
77
|
onTrackHotkey?.(format);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
handleMarkdownListEnter(event, textareaNode,
|
|
80
|
+
handleMarkdownListEnter(event, textareaNode, format => onTrackHotkey?.(format, 'continueList'));
|
|
81
81
|
callback?.(event);
|
|
82
82
|
};
|
|
83
83
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { KeyboardEvent as ReactKeyboardEvent } from 'react';
|
|
2
2
|
import { MarkdownFormat } from '../MarkdownFormat';
|
|
3
|
-
export declare function handleMarkdownListEnter(event: ReactKeyboardEvent<HTMLTextAreaElement>, textareaNode: HTMLTextAreaElement, onTrackEvent?: (
|
|
3
|
+
export declare function handleMarkdownListEnter(event: ReactKeyboardEvent<HTMLTextAreaElement>, textareaNode: HTMLTextAreaElement, onTrackEvent?: (format: MarkdownFormat) => void): boolean | void;
|
package/src/Markdown/types.d.ts
CHANGED
|
@@ -5,6 +5,15 @@ export declare enum ViewMode {
|
|
|
5
5
|
Edit = "Edit",
|
|
6
6
|
Split = "Split"
|
|
7
7
|
}
|
|
8
|
+
export declare enum MarkdownOtherActions {
|
|
9
|
+
Heading = "heading",
|
|
10
|
+
Emoji = "emoji",
|
|
11
|
+
ViewMode = "viewMode",
|
|
12
|
+
ScreenMode = "screenMode",
|
|
13
|
+
Help = "help",
|
|
14
|
+
AllActions = "allActions",
|
|
15
|
+
AI = "AI"
|
|
16
|
+
}
|
|
8
17
|
export interface Token {
|
|
9
18
|
positions: number[];
|
|
10
19
|
value: string;
|
|
@@ -51,5 +60,5 @@ export interface TestCase<V, E> {
|
|
|
51
60
|
values: V;
|
|
52
61
|
}
|
|
53
62
|
export type ReactUIThemeType = Partial<typeof THEME_2022>;
|
|
54
|
-
export type ActionsOptions = Partial<Record<MarkdownFormat |
|
|
55
|
-
export type
|
|
63
|
+
export type ActionsOptions = Partial<Record<MarkdownFormat | MarkdownOtherActions, boolean>>;
|
|
64
|
+
export type ActionsOptionsKeys = keyof ActionsOptions;
|
package/src/Markdown/types.js
CHANGED
|
@@ -4,3 +4,13 @@ export var ViewMode;
|
|
|
4
4
|
ViewMode["Edit"] = "Edit";
|
|
5
5
|
ViewMode["Split"] = "Split";
|
|
6
6
|
})(ViewMode || (ViewMode = {}));
|
|
7
|
+
export var MarkdownOtherActions;
|
|
8
|
+
(function (MarkdownOtherActions) {
|
|
9
|
+
MarkdownOtherActions["Heading"] = "heading";
|
|
10
|
+
MarkdownOtherActions["Emoji"] = "emoji";
|
|
11
|
+
MarkdownOtherActions["ViewMode"] = "viewMode";
|
|
12
|
+
MarkdownOtherActions["ScreenMode"] = "screenMode";
|
|
13
|
+
MarkdownOtherActions["Help"] = "help";
|
|
14
|
+
MarkdownOtherActions["AllActions"] = "allActions";
|
|
15
|
+
MarkdownOtherActions["AI"] = "AI";
|
|
16
|
+
})(MarkdownOtherActions || (MarkdownOtherActions = {}));
|