@skbkontur/markdown 1.7.0 → 1.9.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/Markdown.styled.d.ts +9 -9
- package/src/Markdown/Markdown.styled.js +28 -10
- package/src/Markdown/MarkdownHelpItems.d.ts +4 -1
- package/src/Markdown/MarkdownHelpItems.js +12 -10
- package/src/Markdown/MarkdownHelpers/MarkdownCombination.js +13 -6
- package/src/Markdown/MarkdownHelpers/MarkdownFormatButton.js +1 -1
- package/src/Markdown/MarkdownHelpers/markdownHelpers.js +4 -4
package/package.json
CHANGED
|
@@ -711,12 +711,12 @@ export declare const getMarkdownReactUiTheme: (theme: MarkdownTheme, reactUiThem
|
|
|
711
711
|
menuItemLineHeightSmall?: string | undefined;
|
|
712
712
|
menuItemLineHeightMedium?: string | undefined;
|
|
713
713
|
menuItemLineHeightLarge?: string | undefined;
|
|
714
|
-
menuItemFontSize
|
|
714
|
+
menuItemFontSize?: string | undefined;
|
|
715
715
|
menuItemFontSizeSmall?: string | undefined;
|
|
716
716
|
menuItemFontSizeMedium?: string | undefined;
|
|
717
717
|
menuItemFontSizeLarge?: string | undefined;
|
|
718
|
-
menuItemPaddingX
|
|
719
|
-
menuItemPaddingY
|
|
718
|
+
menuItemPaddingX?: string | undefined;
|
|
719
|
+
menuItemPaddingY?: string | undefined;
|
|
720
720
|
menuItemPaddingXSmall?: string | undefined;
|
|
721
721
|
menuItemPaddingYSmall?: string | undefined;
|
|
722
722
|
menuItemPaddingXMedium?: string | undefined;
|
|
@@ -957,12 +957,12 @@ export declare const getMarkdownReactUiTheme: (theme: MarkdownTheme, reactUiThem
|
|
|
957
957
|
checkboxLineHeightSmall?: string | undefined;
|
|
958
958
|
checkboxLineHeightMedium?: string | undefined;
|
|
959
959
|
checkboxLineHeightLarge?: string | undefined;
|
|
960
|
-
checkboxBoxSize
|
|
960
|
+
checkboxBoxSize?: string | undefined;
|
|
961
961
|
checkboxBoxSizeSmall?: string | undefined;
|
|
962
962
|
checkboxBoxSizeMedium?: string | undefined;
|
|
963
963
|
checkboxBoxSizeLarge?: string | undefined;
|
|
964
964
|
checkboxCaptionGap?: string | undefined;
|
|
965
|
-
checkboxPaddingY
|
|
965
|
+
checkboxPaddingY?: string | undefined;
|
|
966
966
|
checkboxPaddingYSmall?: string | undefined;
|
|
967
967
|
checkboxPaddingYMedium?: string | undefined;
|
|
968
968
|
checkboxPaddingYLarge?: string | undefined;
|
|
@@ -1087,20 +1087,20 @@ export declare const getMarkdownReactUiTheme: (theme: MarkdownTheme, reactUiThem
|
|
|
1087
1087
|
radioCircleOffsetY?: string | undefined;
|
|
1088
1088
|
radioCheckedDisabledBulletBg?: string | undefined;
|
|
1089
1089
|
radioGroupLegacyItemGap?: string | undefined;
|
|
1090
|
-
tabFontSize
|
|
1090
|
+
tabFontSize?: string | undefined;
|
|
1091
1091
|
tabFontSizeSmall?: string | undefined;
|
|
1092
1092
|
tabFontSizeMedium?: string | undefined;
|
|
1093
1093
|
tabFontSizeLarge?: string | undefined;
|
|
1094
|
-
tabLineHeight
|
|
1094
|
+
tabLineHeight?: string | undefined;
|
|
1095
1095
|
tabLineHeightSmall?: string | undefined;
|
|
1096
1096
|
tabLineHeightMedium?: string | undefined;
|
|
1097
1097
|
tabLineHeightLarge?: string | undefined;
|
|
1098
|
-
tabPaddingX
|
|
1098
|
+
tabPaddingX?: string | undefined;
|
|
1099
1099
|
tabPaddingXSmall?: string | undefined;
|
|
1100
1100
|
tabPaddingXMedium?: string | undefined;
|
|
1101
1101
|
tabPaddingXLarge?: string | undefined;
|
|
1102
1102
|
tabsMarginX?: string | undefined;
|
|
1103
|
-
tabPaddingY
|
|
1103
|
+
tabPaddingY?: string | undefined;
|
|
1104
1104
|
tabPaddingYSmall?: string | undefined;
|
|
1105
1105
|
tabPaddingYMedium?: string | undefined;
|
|
1106
1106
|
tabPaddingYLarge?: string | undefined;
|
|
@@ -51,26 +51,44 @@ export var getMarkdownMentionStyle = function (x, y) { return ({
|
|
|
51
51
|
export var UserDescriptions = styled.div(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n white-space: pre-line;\n overflow-wrap: break-word;\n word-wrap: break-word;\n word-break: break-word;\n overflow: hidden;\n margin-top: 4px;\n"], ["\n white-space: pre-line;\n overflow-wrap: break-word;\n word-wrap: break-word;\n word-break: break-word;\n overflow: hidden;\n margin-top: 4px;\n"])));
|
|
52
52
|
export var MentionMenuItem = styled(MenuItem)(templateObject_19 || (templateObject_19 = __makeTemplateObject(["\n padding: 4px 28px;\n"], ["\n padding: 4px 28px;\n"])));
|
|
53
53
|
export var VisuallyHidden = styled.span(templateObject_20 || (templateObject_20 = __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"])));
|
|
54
|
+
var extendThemeConfigWithSized = function (config) {
|
|
55
|
+
var finalConfig = {};
|
|
56
|
+
var configKeys = Object.keys(config);
|
|
57
|
+
configKeys.forEach(function (key) {
|
|
58
|
+
if (key !== 'prototype') {
|
|
59
|
+
finalConfig["".concat(key, "Small")] = config[key];
|
|
60
|
+
finalConfig["".concat(key, "Medium")] = config[key];
|
|
61
|
+
finalConfig["".concat(key, "Large")] = config[key];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return finalConfig;
|
|
65
|
+
};
|
|
54
66
|
export var getMarkdownReactUiTheme = function (theme, reactUiTheme, panelHorizontalPadding, fullScreenTextareaPadding, borderless) {
|
|
55
67
|
var elementsFontSize = theme.elementsFontSize, elementsLineHeight = theme.elementsLineHeight, themeMode = theme.themeMode, colors = theme.colors;
|
|
56
|
-
return ThemeFactory.create(__assign(__assign(__assign(
|
|
57
|
-
|
|
68
|
+
return ThemeFactory.create(__assign(__assign(__assign(__assign(__assign({}, extendThemeConfigWithSized({
|
|
69
|
+
tabFontSize: elementsFontSize,
|
|
70
|
+
tabPaddingY: '0',
|
|
71
|
+
tabPaddingX: '6px',
|
|
72
|
+
tabLineHeight: elementsLineHeight,
|
|
73
|
+
checkboxPaddingY: '0',
|
|
74
|
+
checkboxBoxSize: elementsFontSize,
|
|
75
|
+
menuItemFontSize: elementsFontSize,
|
|
76
|
+
menuItemPaddingY: '4px',
|
|
77
|
+
menuItemPaddingX: '28px',
|
|
78
|
+
})), { tabColorHover: 'transparent', tabColorFocus: 'transparent', tabBorderWidth: '0', selectBorderWidth: '0', btnDefaultBg: 'transparent', btnDefaultActiveBorderColor: 'transparent', btnDisabledBg: 'transparent', btnDisabledBorderColor: 'transparent', btnDisabledTextColor: colors.disabledButton, btnDefaultHoverBg: themeMode === 'light' ? reactUiTheme === null || reactUiTheme === void 0 ? void 0 : reactUiTheme.btnDefaultHoverBg : reactUiTheme === null || reactUiTheme === void 0 ? void 0 : reactUiTheme.btnDisabledBg, btnFontSizeSmall: elementsFontSize, checkboxBg: 'transparent', checkboxHoverBg: 'transparent', checkboxCheckedBg: 'transparent', checkboxShadow: "0 0 0 1px ".concat(colors.grayDefault), checkboxShadowHover: "0 0 0 1px ".concat(colors.grayDefault), checkboxCheckedHoverShadow: "0 0 0 1px ".concat(colors.grayDefault), checkboxCheckedShadow: "0 0 0 1px ".concat(colors.grayDefault), checkboxCheckedActiveShadow: "0 0 0 1px ".concat(colors.grayDefault), checkboxShadowActive: "0 0 0 1px ".concat(colors.grayDefault), checkboxCheckedColor: colors.grayDefault, hintFontSize: elementsFontSize, hintColor: themeMode === 'light' ? colors.white : colors.grayDefault, selectPaddingXSmall: '8px', selectLineHeightSmall: '24px', dropdownBorderWidth: '0' }), (panelHorizontalPadding &&
|
|
79
|
+
extendThemeConfigWithSized({
|
|
58
80
|
textareaPaddingX: "".concat(panelHorizontalPadding, "px"),
|
|
59
|
-
})), (borderless &&
|
|
81
|
+
}))), (borderless &&
|
|
60
82
|
{
|
|
61
83
|
textareaBorderColor: 'transparent',
|
|
62
84
|
textareaBorderColorFocus: 'transparent',
|
|
63
85
|
textareaBorderTopColor: 'transparent',
|
|
64
86
|
textareaShadow: 'none',
|
|
65
87
|
})), (fullScreenTextareaPadding &&
|
|
66
|
-
{
|
|
88
|
+
__assign({ textareaBorderColor: 'transparent', textareaBorderColorFocus: 'transparent', textareaBorderTopColor: 'transparent', textareaShadow: 'none' }, extendThemeConfigWithSized({
|
|
67
89
|
textareaMinHeight: '85vh',
|
|
68
|
-
textareaBorderColor: 'transparent',
|
|
69
|
-
textareaBorderColorFocus: 'transparent',
|
|
70
|
-
textareaBorderTopColor: 'transparent',
|
|
71
|
-
textareaShadow: 'none',
|
|
72
90
|
textareaPaddingX: "".concat(fullScreenTextareaPadding, "px"),
|
|
73
|
-
textareaPaddingY:
|
|
74
|
-
})), reactUiTheme);
|
|
91
|
+
textareaPaddingY: '0',
|
|
92
|
+
})))), reactUiTheme);
|
|
75
93
|
};
|
|
76
94
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19, templateObject_20;
|
|
@@ -4,7 +4,10 @@ import { RefItem } from './types';
|
|
|
4
4
|
export declare const eventKeyCodeToMarkdownFormat: {
|
|
5
5
|
[key: number]: MarkdownFormat;
|
|
6
6
|
};
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const markdownFormatToShortKeyLong: Partial<{
|
|
8
|
+
[key in MarkdownFormat]: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const markdownFormatToShortKeyShort: Partial<{
|
|
8
11
|
[key in MarkdownFormat]: string;
|
|
9
12
|
}>;
|
|
10
13
|
export interface MarkdownHelpItem {
|
|
@@ -7,7 +7,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
7
7
|
}
|
|
8
8
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
9
|
};
|
|
10
|
-
var _a;
|
|
10
|
+
var _a, _b;
|
|
11
11
|
import React from 'react';
|
|
12
12
|
import { MarkdownSymbolWrapper } from './Markdown.styled';
|
|
13
13
|
import { MarkdownFormat } from './MarkdownFormat';
|
|
@@ -27,30 +27,32 @@ export var eventKeyCodeToMarkdownFormat = {
|
|
|
27
27
|
52: MarkdownFormat.h4,
|
|
28
28
|
66: MarkdownFormat.bold,
|
|
29
29
|
73: MarkdownFormat.italic,
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
83: MarkdownFormat.crossed,
|
|
31
|
+
75: MarkdownFormat.ref,
|
|
32
32
|
76: MarkdownFormat.list,
|
|
33
33
|
68: MarkdownFormat.checkedList,
|
|
34
34
|
78: MarkdownFormat.numberedList,
|
|
35
|
-
|
|
35
|
+
67: MarkdownFormat.codeBlock,
|
|
36
36
|
81: MarkdownFormat.quote,
|
|
37
37
|
80: MarkdownFormat.image,
|
|
38
38
|
};
|
|
39
|
-
export var
|
|
39
|
+
export var markdownFormatToShortKeyLong = (_a = {},
|
|
40
40
|
_a[MarkdownFormat.h2] = '2',
|
|
41
41
|
_a[MarkdownFormat.h3] = '3',
|
|
42
42
|
_a[MarkdownFormat.h4] = '4',
|
|
43
|
-
_a[MarkdownFormat.
|
|
44
|
-
_a[MarkdownFormat.italic] = 'I',
|
|
45
|
-
_a[MarkdownFormat.crossed] = 'R',
|
|
46
|
-
_a[MarkdownFormat.ref] = 'U',
|
|
43
|
+
_a[MarkdownFormat.crossed] = 'S',
|
|
47
44
|
_a[MarkdownFormat.list] = 'L',
|
|
48
45
|
_a[MarkdownFormat.checkedList] = 'D',
|
|
49
46
|
_a[MarkdownFormat.numberedList] = 'N',
|
|
50
|
-
_a[MarkdownFormat.codeBlock] = '
|
|
47
|
+
_a[MarkdownFormat.codeBlock] = 'C',
|
|
51
48
|
_a[MarkdownFormat.quote] = 'Q',
|
|
52
49
|
_a[MarkdownFormat.image] = 'P',
|
|
53
50
|
_a);
|
|
51
|
+
export var markdownFormatToShortKeyShort = (_b = {},
|
|
52
|
+
_b[MarkdownFormat.bold] = 'B',
|
|
53
|
+
_b[MarkdownFormat.italic] = 'I',
|
|
54
|
+
_b[MarkdownFormat.ref] = 'K',
|
|
55
|
+
_b);
|
|
54
56
|
function reverseString(text) {
|
|
55
57
|
return text.split('').reverse().join('');
|
|
56
58
|
}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { HintContentWrapper } from '../Markdown.styled';
|
|
3
|
-
import {
|
|
3
|
+
import { markdownFormatToShortKeyLong, markdownFormatToShortKeyShort } from '../MarkdownHelpItems';
|
|
4
4
|
import { isMacintosh } from '../utils/isMacintosh';
|
|
5
5
|
export var MarkdownCombination = function (_a) {
|
|
6
6
|
var format = _a.format, text = _a.text;
|
|
7
|
-
var
|
|
7
|
+
var shortKeyLong = markdownFormatToShortKeyLong[format];
|
|
8
|
+
var shortKeyShort = markdownFormatToShortKeyShort[format];
|
|
9
|
+
var shortKey = shortKeyLong || shortKeyShort;
|
|
8
10
|
return (React.createElement(HintContentWrapper, null,
|
|
9
11
|
React.createElement("span", null, text),
|
|
10
|
-
!!shortKey && (
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
!!shortKey && renderHint()));
|
|
13
|
+
function renderHint() {
|
|
14
|
+
var ctrlKey = isMacintosh() ? '⌘' : 'CTRL';
|
|
15
|
+
var extraKey = shortKeyLong ? '+SHIFT' : '';
|
|
16
|
+
return (React.createElement("span", null,
|
|
17
|
+
ctrlKey,
|
|
18
|
+
extraKey,
|
|
13
19
|
"+",
|
|
14
|
-
|
|
20
|
+
shortKey));
|
|
21
|
+
}
|
|
15
22
|
};
|
|
@@ -4,7 +4,7 @@ import { MarkdownCombination } from './MarkdownCombination';
|
|
|
4
4
|
import { MarkdownButtonIcon, MarkdownButtonWrapper, VisuallyHidden } from '../Markdown.styled';
|
|
5
5
|
export var MarkdownFormatButton = function (_a) {
|
|
6
6
|
var icon = _a.icon, hintText = _a.hintText, onClick = _a.onClick, format = _a.format, disabled = _a.disabled, text = _a.text;
|
|
7
|
-
return (React.createElement(Hint, { manual: disabled, text: format ? React.createElement(MarkdownCombination, { format: format, text: hintText }) : hintText, pos: "top center", maxWidth:
|
|
7
|
+
return (React.createElement(Hint, { manual: disabled, text: format ? React.createElement(MarkdownCombination, { format: format, text: hintText }) : hintText, pos: "top center", maxWidth: 360 },
|
|
8
8
|
React.createElement(MarkdownButtonWrapper, { borderless: true, disabled: disabled, onClick: onClick },
|
|
9
9
|
React.createElement(MarkdownButtonIcon, null, icon),
|
|
10
10
|
React.createElement(VisuallyHidden, null, text))));
|
|
@@ -2,7 +2,7 @@ import { useEffect } from 'react';
|
|
|
2
2
|
import { getPastedHtml } from './markdownTextareaHelpers';
|
|
3
3
|
import { useFileLogic } from '../Files/Files.logic';
|
|
4
4
|
import { MarkdownFormat } from '../MarkdownFormat';
|
|
5
|
-
import { checkSpaceSymbol, eventKeyCodeToMarkdownFormat, markdownHelpFiles, markdownHelpItems, } from '../MarkdownHelpItems';
|
|
5
|
+
import { checkSpaceSymbol, eventKeyCodeToMarkdownFormat, markdownFormatToShortKeyLong, markdownHelpFiles, markdownHelpItems, } from '../MarkdownHelpItems';
|
|
6
6
|
var italic = MarkdownFormat.italic, bold = MarkdownFormat.bold, crossed = MarkdownFormat.crossed, codeBlock = MarkdownFormat.codeBlock, ref = MarkdownFormat.ref, file = MarkdownFormat.file, image = MarkdownFormat.image;
|
|
7
7
|
var betweenTextFormats = [italic, bold, crossed, codeBlock, file, image];
|
|
8
8
|
var specialFormats = [ref];
|
|
@@ -59,12 +59,12 @@ export function setTextareaCursor(format, prevCommentPartLength, nextCommentPart
|
|
|
59
59
|
}
|
|
60
60
|
export function createMarkdownHelpKeyDownHandler(text, ref, callback) {
|
|
61
61
|
return function (event) {
|
|
62
|
-
if (!(ref === null || ref === void 0 ? void 0 : ref.current))
|
|
62
|
+
if (!(ref === null || ref === void 0 ? void 0 : ref.current))
|
|
63
63
|
return;
|
|
64
|
-
}
|
|
65
64
|
var textareaNode = ref.current.node;
|
|
66
65
|
var format = eventKeyCodeToMarkdownFormat[event.keyCode];
|
|
67
|
-
|
|
66
|
+
var isLong = markdownFormatToShortKeyLong[format];
|
|
67
|
+
if ((event.metaKey || event.ctrlKey) && (isLong ? event.shiftKey : true) && format) {
|
|
68
68
|
var markdownHelpItem = markdownHelpItems.find(function (item) { return item.format === format; });
|
|
69
69
|
if (markdownHelpItem && textareaNode) {
|
|
70
70
|
event.stopPropagation();
|