@skbkontur/markdown 1.9.1 → 1.10.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/package.json +1 -1
- package/src/Markdown/MarkdownActions.js +4 -1
- package/src/Markdown/MarkdownHelpers/MarkdownFormatButton.d.ts +2 -1
- package/src/Markdown/MarkdownHelpers/MarkdownFormatButton.js +5 -5
- package/src/Markdown/MarkdownHelpers/types.d.ts +9 -0
- package/src/Markdown/MarkdownHelpers/types.js +1 -0
- package/src/Markdown/MarkdownMention.js +5 -5
- package/src/Markdown/constants.d.ts +3 -2
- package/src/Markdown/constants.js +3 -2
- package/src/MarkdownIcons/DocIcon.d.ts +2 -0
- package/src/MarkdownIcons/DocIcon.js +5 -0
- package/src/MarkdownViewer/Helpers/MarkdownLink.js +2 -1
- package/src/MarkdownViewer/MarkdownViewer.js +2 -2
- package/src/MarkdownViewer/MarkdownViewer.styles.d.ts +2 -0
- package/src/MarkdownViewer/MarkdownViewer.styles.js +6 -4
- package/src/Markdown/MarkdownHelpers/MarkdownButton.d.ts +0 -10
- package/src/Markdown/MarkdownHelpers/MarkdownButton.js +0 -10
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { Dropdown } from '@skbkontur/react-ui';
|
|
13
13
|
import React from 'react';
|
|
14
|
+
import { COMMONMARK_HELP_URL } from './constants';
|
|
14
15
|
import { ActionsWrapper, ButtonsWrapper, MarkdownDropdown, MarkdownMenuItem, MarkdownActionsWrapper, } from './Markdown.styled';
|
|
15
16
|
import { MarkdownCombination } from './MarkdownHelpers/MarkdownCombination';
|
|
16
17
|
import { MarkdownFormatButton } from './MarkdownHelpers/MarkdownFormatButton';
|
|
@@ -19,6 +20,7 @@ import { markdownHelpHeaders, markdownHelpLists, markdownHelpOther, markdownHelp
|
|
|
19
20
|
import { ViewMode } from './types';
|
|
20
21
|
import { AttachPaperclip } from '../MarkdownIcons/AttachPaperclip';
|
|
21
22
|
import { Collapse } from '../MarkdownIcons/Collapse';
|
|
23
|
+
import { DocIcon } from '../MarkdownIcons/DocIcon';
|
|
22
24
|
import { Expand } from '../MarkdownIcons/Expand';
|
|
23
25
|
import { EyeOpen } from '../MarkdownIcons/EyeOpen';
|
|
24
26
|
import { ToolPencil } from '../MarkdownIcons/ToolPencil';
|
|
@@ -34,7 +36,8 @@ export var MarkdownActions = function (_a) {
|
|
|
34
36
|
markdownHelpText.map(function (helper, idx) { return (React.createElement(MarkdownFormatButton, { key: idx, disabled: isPreviewMode, format: helper.format, hintText: helper.node, icon: helper.icon, text: helper.text, onClick: function (event) { return handleMarkdownItemClick(event, helper.format); } })); }),
|
|
35
37
|
markdownHelpLists.map(function (helper, idx) { return (React.createElement(MarkdownFormatButton, { key: idx, disabled: isPreviewMode, format: helper.format, hintText: helper.node, icon: helper.icon, text: helper.text, onClick: function (event) { return handleMarkdownItemClick(event, helper.format); } })); }),
|
|
36
38
|
markdownHelpOther.map(function (helper, idx) { return (React.createElement(MarkdownFormatButton, { key: idx, disabled: isPreviewMode, format: helper.format, hintText: helper.node, icon: helper.icon, text: helper.text, onClick: function (event) { return handleMarkdownItemClick(event, helper.format); } })); }),
|
|
37
|
-
hasFilesApi && (React.createElement(MarkdownFormatButton, { hintText: "\u041F\u0440\u0438\u043A\u0440\u0435\u043F\u0438\u0442\u044C \u0444\u0430\u0439\u043B", disabled: isPreviewMode, isLoading: loadingFile, icon: React.createElement(AttachPaperclip, null), text: "\u041F\u0440\u0438\u043A\u0440\u0435\u043F\u0438\u0442\u044C \u0444\u0430\u0439\u043B", onClick: onOpenFileDialog }))
|
|
39
|
+
hasFilesApi && (React.createElement(MarkdownFormatButton, { hintText: "\u041F\u0440\u0438\u043A\u0440\u0435\u043F\u0438\u0442\u044C \u0444\u0430\u0439\u043B", disabled: isPreviewMode, isLoading: loadingFile, icon: React.createElement(AttachPaperclip, null), text: "\u041F\u0440\u0438\u043A\u0440\u0435\u043F\u0438\u0442\u044C \u0444\u0430\u0439\u043B", onClick: onOpenFileDialog })),
|
|
40
|
+
React.createElement(MarkdownFormatButton, { 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 })),
|
|
38
41
|
React.createElement(ActionsWrapper, null,
|
|
39
42
|
renderViewModeButton(),
|
|
40
43
|
React.createElement(MarkdownFormatButton, { hintText: fullscreen ? 'Свернуть' : 'Развернуть', icon: fullscreen ? React.createElement(Collapse, null) : React.createElement(Expand, null), text: fullscreen ? 'Свернуть' : 'Развернуть', onClick: onClickFullscreen })))));
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import { MarkdownButtonProps } from './
|
|
2
|
+
import { MarkdownButtonProps } from './types';
|
|
3
3
|
import { MarkdownFormat } from '../MarkdownFormat';
|
|
4
4
|
interface Props extends MarkdownButtonProps {
|
|
5
5
|
format?: MarkdownFormat;
|
|
6
|
+
href?: string;
|
|
6
7
|
}
|
|
7
8
|
export declare const MarkdownFormatButton: FC<Props>;
|
|
8
9
|
export {};
|
|
@@ -3,9 +3,9 @@ import React from 'react';
|
|
|
3
3
|
import { MarkdownCombination } from './MarkdownCombination';
|
|
4
4
|
import { MarkdownButtonIcon, MarkdownButtonWrapper, VisuallyHidden } from '../Markdown.styled';
|
|
5
5
|
export var MarkdownFormatButton = function (_a) {
|
|
6
|
-
var icon = _a.icon, hintText = _a.hintText, onClick = _a.onClick, format = _a.format, disabled = _a.disabled, text = _a.text;
|
|
7
|
-
|
|
8
|
-
React.createElement(
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
var icon = _a.icon, hintText = _a.hintText, onClick = _a.onClick, format = _a.format, disabled = _a.disabled, text = _a.text, href = _a.href;
|
|
7
|
+
var button = (React.createElement(MarkdownButtonWrapper, { borderless: true, disabled: disabled, onClick: onClick },
|
|
8
|
+
React.createElement(MarkdownButtonIcon, null, icon),
|
|
9
|
+
React.createElement(VisuallyHidden, null, text)));
|
|
10
|
+
return (React.createElement(Hint, { manual: disabled, text: format ? React.createElement(MarkdownCombination, { format: format, text: hintText }) : hintText, pos: "top center", maxWidth: 360 }, href ? (React.createElement("a", { href: href, tabIndex: -1, target: "_blank", rel: "noopener noreferrer nofollow" }, button)) : (button)));
|
|
11
11
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -39,18 +39,18 @@ import { Menu } from '@skbkontur/react-ui/internal/Menu';
|
|
|
39
39
|
import { ZIndex } from '@skbkontur/react-ui/internal/ZIndex';
|
|
40
40
|
import React, { useEffect, useRef, useState } from 'react';
|
|
41
41
|
import { createPortal } from 'react-dom';
|
|
42
|
-
import {
|
|
42
|
+
import { MARKDOWN_RENDER_CONTAINER, INPUT_DEBOUNCE_TIME } from './constants';
|
|
43
43
|
import { getMarkdownMentionStyle, MentionMenuItem, UserDescriptions, UserWrapper, Avatar } from './Markdown.styled';
|
|
44
44
|
import { getAvatarUrl, useMenuKeyListener } from './MarkdownHelpers/markdownMentionHelpers';
|
|
45
45
|
export var MarkdownMention = function (_a) {
|
|
46
46
|
var value = _a.value, onUserSelect = _a.onUserSelect, x = _a.x, y = _a.y, getUsersApi = _a.getUsersApi;
|
|
47
47
|
var _b = useState(), users = _b[0], setUsers = _b[1];
|
|
48
48
|
var menuRef = useRef(null);
|
|
49
|
-
var markdownMentionsRef = useRef(document.getElementById(
|
|
50
|
-
var timerRef = useRef(
|
|
49
|
+
var markdownMentionsRef = useRef(document.getElementById(MARKDOWN_RENDER_CONTAINER));
|
|
50
|
+
var timerRef = useRef(INPUT_DEBOUNCE_TIME);
|
|
51
51
|
if (!markdownMentionsRef.current) {
|
|
52
52
|
var container = document.createElement('div');
|
|
53
|
-
container.id =
|
|
53
|
+
container.id = MARKDOWN_RENDER_CONTAINER;
|
|
54
54
|
document.body.appendChild(container);
|
|
55
55
|
markdownMentionsRef.current = container;
|
|
56
56
|
}
|
|
@@ -69,7 +69,7 @@ export var MarkdownMention = function (_a) {
|
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
}); };
|
|
72
|
-
timerRef.current = window.setTimeout(function () { return void load_1(); },
|
|
72
|
+
timerRef.current = window.setTimeout(function () { return void load_1(); }, INPUT_DEBOUNCE_TIME);
|
|
73
73
|
}
|
|
74
74
|
catch (e) {
|
|
75
75
|
Toast.push('Ошибка в получении списка пользователей');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const MENTION_WRAPPER_ID_POSTFIX = "_MentionWrapper";
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
2
|
+
export declare const INPUT_DEBOUNCE_TIME = 500;
|
|
3
|
+
export declare const MARKDOWN_RENDER_CONTAINER = "markdownRenderContainer";
|
|
4
|
+
export declare const COMMONMARK_HELP_URL = "https://commonmark.org/help/";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export var MENTION_WRAPPER_ID_POSTFIX = '_MentionWrapper';
|
|
2
|
-
export var
|
|
3
|
-
export var
|
|
2
|
+
export var INPUT_DEBOUNCE_TIME = 500;
|
|
3
|
+
export var MARKDOWN_RENDER_CONTAINER = 'markdownRenderContainer';
|
|
4
|
+
export var COMMONMARK_HELP_URL = 'https://commonmark.org/help/';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var DocIcon = function () { return (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" },
|
|
3
|
+
React.createElement("path", { d: "M8.25 10.5C8.25 10.9142 7.91422 11.25 7.5 11.25C7.08579 11.25 6.75 10.9142 6.75 10.5C6.75 10.0858 7.08579 9.75 7.5 9.75C7.91422 9.75 8.25 10.0858 8.25 10.5Z", fill: "currentColor" }),
|
|
4
|
+
React.createElement("path", { d: "M6.01202 5.83809C6.01202 5.1921 6.62173 4.57056 7.50193 4.57056C8.38213 4.57056 8.99184 5.1921 8.99184 5.83809C8.99184 6.31522 8.67149 6.76725 8.14079 6.98297C7.53085 7.2309 7.00193 7.71814 7.00193 8.4894C7.00193 8.76554 7.22579 8.9894 7.50193 8.9894C7.77807 8.9894 8.00193 8.76554 8.00193 8.4894C8.00193 8.2739 8.12418 8.06918 8.51735 7.90936C9.35886 7.5673 9.99184 6.78904 9.99184 5.83809C9.99184 4.53171 8.81972 3.57056 7.50193 3.57056C6.18414 3.57056 5.01202 4.53171 5.01202 5.83809C5.01202 6.11423 5.23588 6.33809 5.51202 6.33809C5.78817 6.33809 6.01202 6.11423 6.01202 5.83809Z", fill: "currentColor" }),
|
|
5
|
+
React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M1 7.5C1 3.91015 3.91015 1 7.5 1C11.0899 1 14 3.91015 14 7.5C14 11.0899 11.0899 14 7.5 14C3.91015 14 1 11.0899 1 7.5ZM7.5 2C4.46243 2 2 4.46243 2 7.5C2 10.5376 4.46243 13 7.5 13C10.5376 13 13 10.5376 13 7.5C13 4.46243 10.5376 2 7.5 2Z", fill: "currentColor" }))); };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { Href } from '../MarkdownViewer.styles';
|
|
2
3
|
export var MarkdownLink = function (_a) {
|
|
3
4
|
var href = _a.href, children = _a.children, target = _a.target;
|
|
4
|
-
return (React.createElement(
|
|
5
|
+
return (React.createElement(Href, { href: href, target: target !== null && target !== void 0 ? target : '_blank', rel: "noopener noreferrer" }, children));
|
|
5
6
|
};
|
|
@@ -7,7 +7,7 @@ import remarkBreaks from 'remark-breaks';
|
|
|
7
7
|
import gfm from 'remark-gfm';
|
|
8
8
|
import { MarkdownImage } from './Helpers/MarkdownImage';
|
|
9
9
|
import { MarkdownLink } from './Helpers/MarkdownLink';
|
|
10
|
-
import { BlockQuote, FileButtonWrapper, getListStyle, ListItem, Paragraph, VisuallyHidden, Wrapper, } from './MarkdownViewer.styles';
|
|
10
|
+
import { BlockQuote, FileButtonWrapper, FileName, getListStyle, ListItem, Paragraph, VisuallyHidden, Wrapper, } from './MarkdownViewer.styles';
|
|
11
11
|
import { useFileLogic } from '../Markdown/Files/Files.logic';
|
|
12
12
|
import { AttachPaperclip } from '../MarkdownIcons/AttachPaperclip';
|
|
13
13
|
import { ThemeProvider } from '../styles/styled-components';
|
|
@@ -45,7 +45,7 @@ export var MarkdownViewer = function (_a) {
|
|
|
45
45
|
var id_1 = href.replace(fileApiUrl, '');
|
|
46
46
|
return (React.createElement(FileButtonWrapper, null,
|
|
47
47
|
React.createElement(Button, { use: "link", icon: React.createElement(AttachPaperclip, null), onClick: function () { return downloadFile(id_1); } },
|
|
48
|
-
children,
|
|
48
|
+
React.createElement(FileName, null, children),
|
|
49
49
|
React.createElement(VisuallyHidden, null,
|
|
50
50
|
"\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0444\u0430\u0439\u043B $",
|
|
51
51
|
children))));
|
|
@@ -4,6 +4,8 @@ export declare const ListItem: import("styled-components").StyledComponent<"li",
|
|
|
4
4
|
export declare const Paragraph: import("styled-components").StyledComponent<"p", import("../..").MarkdownTheme, {}, never>;
|
|
5
5
|
export declare const BlockQuote: import("styled-components").StyledComponent<"blockquote", import("../..").MarkdownTheme, {}, never>;
|
|
6
6
|
export declare const FileButtonWrapper: import("styled-components").StyledComponent<"div", import("../..").MarkdownTheme, {}, never>;
|
|
7
|
+
export declare const Href: import("styled-components").StyledComponent<"a", import("../..").MarkdownTheme, {}, never>;
|
|
8
|
+
export declare const FileName: import("styled-components").StyledComponent<"span", import("../..").MarkdownTheme, {}, never>;
|
|
7
9
|
export declare const ImgHref: import("styled-components").StyledComponent<"a", import("../..").MarkdownTheme, {}, never>;
|
|
8
10
|
export declare function getListStyle(depth: boolean): CSSProperties;
|
|
9
11
|
export declare const VisuallyHidden: import("styled-components").StyledComponent<"span", import("../..").MarkdownTheme, {}, never>;
|
|
@@ -7,10 +7,12 @@ export var Wrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTe
|
|
|
7
7
|
export var ListItem = styled.li(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n list-style: none;\n margin-inline-start: -20px;\n"], ["\n list-style: none;\n margin-inline-start: -20px;\n"])));
|
|
8
8
|
export var Paragraph = styled.p(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n margin: 0;\n"], ["\n margin: 0;\n"])));
|
|
9
9
|
export var BlockQuote = styled.blockquote(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n margin: 0;\n padding-left: 8px;\n border-left: 4px solid ", ";\n"], ["\n margin: 0;\n padding-left: 8px;\n border-left: 4px solid ", ";\n"])), function (p) { var _a, _b; return (_b = (_a = p.theme) === null || _a === void 0 ? void 0 : _a.colors) === null || _b === void 0 ? void 0 : _b.grayDefault; });
|
|
10
|
-
export var FileButtonWrapper = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: flex;\n"], ["\n display: flex;\n"])));
|
|
11
|
-
export var
|
|
10
|
+
export var FileButtonWrapper = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: flex;\n white-space: pre-wrap;\n"], ["\n display: flex;\n white-space: pre-wrap;\n"])));
|
|
11
|
+
export var Href = styled.a(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n white-space: pre-wrap;\n"], ["\n white-space: pre-wrap;\n"])));
|
|
12
|
+
export var FileName = styled.span(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n white-space: pre-wrap;\n"], ["\n white-space: pre-wrap;\n"])));
|
|
13
|
+
export var ImgHref = styled.a(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n text-decoration: none !important;\n border: none !important;\n"], ["\n text-decoration: none !important;\n border: none !important;\n"])));
|
|
12
14
|
export function getListStyle(depth) {
|
|
13
15
|
return depth ? { marginTop: 4 } : { marginBottom: 16 };
|
|
14
16
|
}
|
|
15
|
-
export var VisuallyHidden = styled.span(
|
|
16
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
17
|
+
export var VisuallyHidden = styled.span(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n border: 0;\n"], ["\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n border: 0;\n"])));
|
|
18
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { FC, ReactNode, SyntheticEvent } from 'react';
|
|
2
|
-
export interface MarkdownButtonProps {
|
|
3
|
-
hintText: ReactNode;
|
|
4
|
-
icon: ReactNode;
|
|
5
|
-
onClick: (event: SyntheticEvent) => void;
|
|
6
|
-
text: string;
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
isLoading?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare const MarkdownButton: FC<MarkdownButtonProps>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Hint } from '@skbkontur/react-ui';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { MarkdownButtonWrapper, VisuallyHidden } from '../Markdown.styled';
|
|
4
|
-
export var MarkdownButton = function (_a) {
|
|
5
|
-
var icon = _a.icon, hintText = _a.hintText, onClick = _a.onClick, isLoading = _a.isLoading, disabled = _a.disabled, text = _a.text;
|
|
6
|
-
return (React.createElement(Hint, { pos: "top center", manual: disabled, text: hintText, maxWidth: 300 },
|
|
7
|
-
React.createElement(MarkdownButtonWrapper, { borderless: true, loading: isLoading, disabled: disabled, onClick: onClick },
|
|
8
|
-
icon,
|
|
9
|
-
React.createElement(VisuallyHidden, null, text))));
|
|
10
|
-
};
|