@cloud-ru/ds-markdown 1.0.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/CHANGELOG.md +8 -0
- package/LICENSE +201 -0
- package/README.md +273 -0
- package/dist/cjs/components/Markdown/CodeBlock.d.ts +9 -0
- package/dist/cjs/components/Markdown/CodeBlock.js +58 -0
- package/dist/cjs/components/Markdown/Markdown.d.ts +2 -0
- package/dist/cjs/components/Markdown/Markdown.js +25 -0
- package/dist/cjs/components/Markdown/index.d.ts +1 -0
- package/dist/cjs/components/Markdown/index.js +17 -0
- package/dist/cjs/components/Markdown/styles.module.css +205 -0
- package/dist/cjs/components/MarkdownEditor/MarkdownEditor.d.ts +2 -0
- package/dist/cjs/components/MarkdownEditor/MarkdownEditor.js +176 -0
- package/dist/cjs/components/MarkdownEditor/index.d.ts +1 -0
- package/dist/cjs/components/MarkdownEditor/index.js +17 -0
- package/dist/cjs/components/MarkdownEditor/styles.module.css +273 -0
- package/dist/cjs/components/Toolbar/Toolbar.d.ts +9 -0
- package/dist/cjs/components/Toolbar/Toolbar.js +173 -0
- package/dist/cjs/components/Toolbar/constants.d.ts +13 -0
- package/dist/cjs/components/Toolbar/constants.js +40 -0
- package/dist/cjs/components/Toolbar/hooks/index.d.ts +2 -0
- package/dist/cjs/components/Toolbar/hooks/index.js +18 -0
- package/dist/cjs/components/Toolbar/hooks/useToolbarHotkeys.d.ts +21 -0
- package/dist/cjs/components/Toolbar/hooks/useToolbarHotkeys.js +59 -0
- package/dist/cjs/components/Toolbar/hooks/useToolbarOverflow.d.ts +14 -0
- package/dist/cjs/components/Toolbar/hooks/useToolbarOverflow.js +87 -0
- package/dist/cjs/components/Toolbar/index.d.ts +2 -0
- package/dist/cjs/components/Toolbar/index.js +20 -0
- package/dist/cjs/components/Toolbar/styles.module.css +17 -0
- package/dist/cjs/components/index.d.ts +2 -0
- package/dist/cjs/components/index.js +20 -0
- package/dist/cjs/constants.d.ts +65 -0
- package/dist/cjs/constants.js +67 -0
- package/dist/cjs/helperComponents/ButtonHeading/ButtonHeading.d.ts +6 -0
- package/dist/cjs/helperComponents/ButtonHeading/ButtonHeading.js +61 -0
- package/dist/cjs/helperComponents/ButtonHeading/index.d.ts +1 -0
- package/dist/cjs/helperComponents/ButtonHeading/index.js +17 -0
- package/dist/cjs/helperComponents/ButtonHeading/styles.module.css +3 -0
- package/dist/cjs/helperComponents/Buttons/Buttons.d.ts +10 -0
- package/dist/cjs/helperComponents/Buttons/Buttons.js +21 -0
- package/dist/cjs/helperComponents/Buttons/index.d.ts +1 -0
- package/dist/cjs/helperComponents/Buttons/index.js +17 -0
- package/dist/cjs/helperComponents/Buttons/styles.module.css +17 -0
- package/dist/cjs/helperComponents/Modals/CustomizeTableModal.d.ts +8 -0
- package/dist/cjs/helperComponents/Modals/CustomizeTableModal.js +39 -0
- package/dist/cjs/helperComponents/Modals/ImageModal.d.ts +7 -0
- package/dist/cjs/helperComponents/Modals/ImageModal.js +44 -0
- package/dist/cjs/helperComponents/Modals/LinkModal.d.ts +13 -0
- package/dist/cjs/helperComponents/Modals/LinkModal.js +42 -0
- package/dist/cjs/helperComponents/Modals/index.d.ts +3 -0
- package/dist/cjs/helperComponents/Modals/index.js +19 -0
- package/dist/cjs/helperComponents/Modals/styles.module.css +17 -0
- package/dist/cjs/helperComponents/PrivateButton/PrivateButton.d.ts +17 -0
- package/dist/cjs/helperComponents/PrivateButton/PrivateButton.js +27 -0
- package/dist/cjs/helperComponents/PrivateButton/index.d.ts +1 -0
- package/dist/cjs/helperComponents/PrivateButton/index.js +17 -0
- package/dist/cjs/helperComponents/PrivateButton/styles.module.css +140 -0
- package/dist/cjs/helperComponents/TableSelectItem/TableSelectItem.d.ts +11 -0
- package/dist/cjs/helperComponents/TableSelectItem/TableSelectItem.js +12 -0
- package/dist/cjs/helperComponents/TableSelectItem/index.d.ts +1 -0
- package/dist/cjs/helperComponents/TableSelectItem/index.js +17 -0
- package/dist/cjs/helperComponents/TableSelectItem/styles.module.css +101 -0
- package/dist/cjs/helperComponents/TableSelectSettingsGrid/TableSelectSettingsGrid.d.ts +4 -0
- package/dist/cjs/helperComponents/TableSelectSettingsGrid/TableSelectSettingsGrid.js +27 -0
- package/dist/cjs/helperComponents/TableSelectSettingsGrid/index.d.ts +1 -0
- package/dist/cjs/helperComponents/TableSelectSettingsGrid/index.js +17 -0
- package/dist/cjs/helperComponents/TableSelectSettingsGrid/styles.module.css +54 -0
- package/dist/cjs/helperComponents/index.d.ts +6 -0
- package/dist/cjs/helperComponents/index.js +22 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/locale/index.d.ts +199 -0
- package/dist/cjs/locale/index.js +104 -0
- package/dist/cjs/lowlight.d.ts +14 -0
- package/dist/cjs/lowlight.js +35 -0
- package/dist/cjs/mixins.css +0 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/rawMarkdownCommands.d.ts +16 -0
- package/dist/cjs/rawMarkdownCommands.js +145 -0
- package/dist/cjs/style.css +875 -0
- package/dist/cjs/styles/syntax.module.css +47 -0
- package/dist/cjs/toolbarApi.d.ts +33 -0
- package/dist/cjs/toolbarApi.js +100 -0
- package/dist/cjs/types.d.ts +52 -0
- package/dist/cjs/types.js +2 -0
- package/dist/esm/components/Markdown/CodeBlock.d.ts +9 -0
- package/dist/esm/components/Markdown/CodeBlock.js +52 -0
- package/dist/esm/components/Markdown/Markdown.d.ts +2 -0
- package/dist/esm/components/Markdown/Markdown.js +19 -0
- package/dist/esm/components/Markdown/index.d.ts +1 -0
- package/dist/esm/components/Markdown/index.js +1 -0
- package/dist/esm/components/Markdown/styles.module.css +205 -0
- package/dist/esm/components/MarkdownEditor/MarkdownEditor.d.ts +2 -0
- package/dist/esm/components/MarkdownEditor/MarkdownEditor.js +170 -0
- package/dist/esm/components/MarkdownEditor/index.d.ts +1 -0
- package/dist/esm/components/MarkdownEditor/index.js +1 -0
- package/dist/esm/components/MarkdownEditor/styles.module.css +273 -0
- package/dist/esm/components/Toolbar/Toolbar.d.ts +9 -0
- package/dist/esm/components/Toolbar/Toolbar.js +167 -0
- package/dist/esm/components/Toolbar/constants.d.ts +13 -0
- package/dist/esm/components/Toolbar/constants.js +37 -0
- package/dist/esm/components/Toolbar/hooks/index.d.ts +2 -0
- package/dist/esm/components/Toolbar/hooks/index.js +2 -0
- package/dist/esm/components/Toolbar/hooks/useToolbarHotkeys.d.ts +21 -0
- package/dist/esm/components/Toolbar/hooks/useToolbarHotkeys.js +56 -0
- package/dist/esm/components/Toolbar/hooks/useToolbarOverflow.d.ts +14 -0
- package/dist/esm/components/Toolbar/hooks/useToolbarOverflow.js +84 -0
- package/dist/esm/components/Toolbar/index.d.ts +2 -0
- package/dist/esm/components/Toolbar/index.js +2 -0
- package/dist/esm/components/Toolbar/styles.module.css +17 -0
- package/dist/esm/components/index.d.ts +2 -0
- package/dist/esm/components/index.js +4 -0
- package/dist/esm/constants.d.ts +65 -0
- package/dist/esm/constants.js +61 -0
- package/dist/esm/helperComponents/ButtonHeading/ButtonHeading.d.ts +6 -0
- package/dist/esm/helperComponents/ButtonHeading/ButtonHeading.js +55 -0
- package/dist/esm/helperComponents/ButtonHeading/index.d.ts +1 -0
- package/dist/esm/helperComponents/ButtonHeading/index.js +1 -0
- package/dist/esm/helperComponents/ButtonHeading/styles.module.css +3 -0
- package/dist/esm/helperComponents/Buttons/Buttons.d.ts +10 -0
- package/dist/esm/helperComponents/Buttons/Buttons.js +13 -0
- package/dist/esm/helperComponents/Buttons/index.d.ts +1 -0
- package/dist/esm/helperComponents/Buttons/index.js +1 -0
- package/dist/esm/helperComponents/Buttons/styles.module.css +17 -0
- package/dist/esm/helperComponents/Modals/CustomizeTableModal.d.ts +8 -0
- package/dist/esm/helperComponents/Modals/CustomizeTableModal.js +33 -0
- package/dist/esm/helperComponents/Modals/ImageModal.d.ts +7 -0
- package/dist/esm/helperComponents/Modals/ImageModal.js +38 -0
- package/dist/esm/helperComponents/Modals/LinkModal.d.ts +13 -0
- package/dist/esm/helperComponents/Modals/LinkModal.js +36 -0
- package/dist/esm/helperComponents/Modals/index.d.ts +3 -0
- package/dist/esm/helperComponents/Modals/index.js +3 -0
- package/dist/esm/helperComponents/Modals/styles.module.css +17 -0
- package/dist/esm/helperComponents/PrivateButton/PrivateButton.d.ts +17 -0
- package/dist/esm/helperComponents/PrivateButton/PrivateButton.js +21 -0
- package/dist/esm/helperComponents/PrivateButton/index.d.ts +1 -0
- package/dist/esm/helperComponents/PrivateButton/index.js +1 -0
- package/dist/esm/helperComponents/PrivateButton/styles.module.css +140 -0
- package/dist/esm/helperComponents/TableSelectItem/TableSelectItem.d.ts +11 -0
- package/dist/esm/helperComponents/TableSelectItem/TableSelectItem.js +6 -0
- package/dist/esm/helperComponents/TableSelectItem/index.d.ts +1 -0
- package/dist/esm/helperComponents/TableSelectItem/index.js +1 -0
- package/dist/esm/helperComponents/TableSelectItem/styles.module.css +101 -0
- package/dist/esm/helperComponents/TableSelectSettingsGrid/TableSelectSettingsGrid.d.ts +4 -0
- package/dist/esm/helperComponents/TableSelectSettingsGrid/TableSelectSettingsGrid.js +21 -0
- package/dist/esm/helperComponents/TableSelectSettingsGrid/index.d.ts +1 -0
- package/dist/esm/helperComponents/TableSelectSettingsGrid/index.js +1 -0
- package/dist/esm/helperComponents/TableSelectSettingsGrid/styles.module.css +54 -0
- package/dist/esm/helperComponents/index.d.ts +6 -0
- package/dist/esm/helperComponents/index.js +6 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/locale/index.d.ts +199 -0
- package/dist/esm/locale/index.js +101 -0
- package/dist/esm/lowlight.d.ts +14 -0
- package/dist/esm/lowlight.js +29 -0
- package/dist/esm/mixins.css +0 -0
- package/dist/esm/rawMarkdownCommands.d.ts +16 -0
- package/dist/esm/rawMarkdownCommands.js +135 -0
- package/dist/esm/style.css +875 -0
- package/dist/esm/styles/syntax.module.css +47 -0
- package/dist/esm/toolbarApi.d.ts +33 -0
- package/dist/esm/toolbarApi.js +96 -0
- package/dist/esm/types.d.ts +52 -0
- package/dist/esm/types.js +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/package.json +84 -0
- package/src/components/Markdown/CodeBlock.tsx +96 -0
- package/src/components/Markdown/Markdown.tsx +47 -0
- package/src/components/Markdown/index.ts +1 -0
- package/src/components/Markdown/styles.module.scss +105 -0
- package/src/components/MarkdownEditor/MarkdownEditor.tsx +322 -0
- package/src/components/MarkdownEditor/index.ts +1 -0
- package/src/components/MarkdownEditor/styles.module.scss +201 -0
- package/src/components/Toolbar/Toolbar.tsx +292 -0
- package/src/components/Toolbar/constants.tsx +63 -0
- package/src/components/Toolbar/hooks/index.ts +2 -0
- package/src/components/Toolbar/hooks/useToolbarHotkeys.ts +74 -0
- package/src/components/Toolbar/hooks/useToolbarOverflow.ts +102 -0
- package/src/components/Toolbar/index.ts +2 -0
- package/src/components/Toolbar/styles.module.scss +29 -0
- package/src/components/index.ts +4 -0
- package/src/constants.ts +67 -0
- package/src/helperComponents/ButtonHeading/ButtonHeading.tsx +100 -0
- package/src/helperComponents/ButtonHeading/index.ts +1 -0
- package/src/helperComponents/ButtonHeading/styles.module.scss +5 -0
- package/src/helperComponents/Buttons/Buttons.tsx +30 -0
- package/src/helperComponents/Buttons/index.ts +1 -0
- package/src/helperComponents/Buttons/styles.module.scss +26 -0
- package/src/helperComponents/Modals/CustomizeTableModal.tsx +82 -0
- package/src/helperComponents/Modals/ImageModal.tsx +84 -0
- package/src/helperComponents/Modals/LinkModal.tsx +92 -0
- package/src/helperComponents/Modals/index.ts +3 -0
- package/src/helperComponents/Modals/styles.module.scss +21 -0
- package/src/helperComponents/PrivateButton/PrivateButton.tsx +88 -0
- package/src/helperComponents/PrivateButton/index.ts +1 -0
- package/src/helperComponents/PrivateButton/styles.module.scss +77 -0
- package/src/helperComponents/TableSelectItem/TableSelectItem.tsx +43 -0
- package/src/helperComponents/TableSelectItem/index.ts +1 -0
- package/src/helperComponents/TableSelectItem/styles.module.scss +26 -0
- package/src/helperComponents/TableSelectSettingsGrid/TableSelectSettingsGrid.tsx +48 -0
- package/src/helperComponents/TableSelectSettingsGrid/index.ts +1 -0
- package/src/helperComponents/TableSelectSettingsGrid/styles.module.scss +65 -0
- package/src/helperComponents/index.ts +6 -0
- package/src/index.ts +4 -0
- package/src/locale/index.ts +105 -0
- package/src/lowlight.ts +30 -0
- package/src/mixins.scss +123 -0
- package/src/rawMarkdownCommands.ts +179 -0
- package/src/styles/syntax.module.scss +54 -0
- package/src/toolbarApi.ts +152 -0
- package/src/types.ts +56 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
declare const MARKDOWN_MESSAGES: {
|
|
2
|
+
readonly 'en-GB': {
|
|
3
|
+
readonly toolbar: {
|
|
4
|
+
readonly heading: "Heading";
|
|
5
|
+
readonly bold: "Bold";
|
|
6
|
+
readonly italic: "Italic";
|
|
7
|
+
readonly strikethrough: "Strikethrough";
|
|
8
|
+
readonly link: "Link";
|
|
9
|
+
readonly inlineCode: "Inline code";
|
|
10
|
+
readonly bulletList: "Bullet list";
|
|
11
|
+
readonly orderedList: "Ordered list";
|
|
12
|
+
readonly blockQuote: "Block quote";
|
|
13
|
+
readonly blockCode: "Block code";
|
|
14
|
+
readonly table: "Table";
|
|
15
|
+
readonly image: "Image";
|
|
16
|
+
readonly more: "More";
|
|
17
|
+
};
|
|
18
|
+
readonly clear: "Clear";
|
|
19
|
+
readonly copy: "Copy";
|
|
20
|
+
readonly copied: "Copied";
|
|
21
|
+
readonly add: "Add";
|
|
22
|
+
readonly cancel: "Cancel";
|
|
23
|
+
readonly link: {
|
|
24
|
+
readonly title: "Add link";
|
|
25
|
+
readonly titleField: {
|
|
26
|
+
readonly label: "Text";
|
|
27
|
+
readonly placeholder: "Link text";
|
|
28
|
+
};
|
|
29
|
+
readonly urlField: {
|
|
30
|
+
readonly label: "URL";
|
|
31
|
+
readonly placeholder: "https://";
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
readonly image: {
|
|
35
|
+
readonly title: "Add image";
|
|
36
|
+
readonly url: "URL";
|
|
37
|
+
readonly alt: "Alt text";
|
|
38
|
+
readonly placeholder: "https://";
|
|
39
|
+
};
|
|
40
|
+
readonly table: {
|
|
41
|
+
readonly pickSize: "Pick size";
|
|
42
|
+
readonly insert: "Insert {{rows}} × {{cols}} table";
|
|
43
|
+
readonly column: "Column {{index}}";
|
|
44
|
+
readonly customize: "Customize table";
|
|
45
|
+
readonly columns: "Columns";
|
|
46
|
+
readonly rows: "Rows";
|
|
47
|
+
};
|
|
48
|
+
readonly linkText: "link text";
|
|
49
|
+
};
|
|
50
|
+
readonly 'ru-RU': {
|
|
51
|
+
readonly toolbar: {
|
|
52
|
+
readonly heading: "Заголовок";
|
|
53
|
+
readonly bold: "Жирный";
|
|
54
|
+
readonly italic: "Курсив";
|
|
55
|
+
readonly strikethrough: "Зачёркнутый";
|
|
56
|
+
readonly link: "Ссылка";
|
|
57
|
+
readonly inlineCode: "Строчный код";
|
|
58
|
+
readonly bulletList: "Маркированный список";
|
|
59
|
+
readonly orderedList: "Нумерованный список";
|
|
60
|
+
readonly blockQuote: "Цитата";
|
|
61
|
+
readonly blockCode: "Блок кода";
|
|
62
|
+
readonly table: "Таблица";
|
|
63
|
+
readonly image: "Картинка";
|
|
64
|
+
readonly more: "Ещё";
|
|
65
|
+
};
|
|
66
|
+
readonly clear: "Очистить";
|
|
67
|
+
readonly copy: "Скопировать";
|
|
68
|
+
readonly copied: "Скопировано";
|
|
69
|
+
readonly add: "Добавить";
|
|
70
|
+
readonly cancel: "Отмена";
|
|
71
|
+
readonly link: {
|
|
72
|
+
readonly title: "Добавить ссылку";
|
|
73
|
+
readonly titleField: {
|
|
74
|
+
readonly label: "Текст";
|
|
75
|
+
readonly placeholder: "Текст ссылки";
|
|
76
|
+
};
|
|
77
|
+
readonly urlField: {
|
|
78
|
+
readonly label: "URL";
|
|
79
|
+
readonly placeholder: "https://";
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
readonly image: {
|
|
83
|
+
readonly title: "Добавить изображение";
|
|
84
|
+
readonly url: "URL";
|
|
85
|
+
readonly alt: "Альтернативный текст";
|
|
86
|
+
readonly placeholder: "https://";
|
|
87
|
+
};
|
|
88
|
+
readonly table: {
|
|
89
|
+
readonly pickSize: "Выберите размер";
|
|
90
|
+
readonly insert: "Вставить таблицу {{rows}} × {{cols}}";
|
|
91
|
+
readonly column: "Колонка {{index}}";
|
|
92
|
+
readonly customize: "Настроить таблицу";
|
|
93
|
+
readonly columns: "Столбцы";
|
|
94
|
+
readonly rows: "Строки";
|
|
95
|
+
};
|
|
96
|
+
readonly linkText: "текст ссылки";
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
export type MarkdownMessages = (typeof MARKDOWN_MESSAGES)['en-GB'];
|
|
100
|
+
/** locale компонента Markdown: `markdownLocale.useTranslations()` в коде, `markdownLocale.extend(...)` в сервисе. */
|
|
101
|
+
export declare const markdownLocale: import("@cloud-ru/ds-locale").DefinedLocale<{
|
|
102
|
+
readonly 'en-GB': {
|
|
103
|
+
readonly toolbar: {
|
|
104
|
+
readonly heading: "Heading";
|
|
105
|
+
readonly bold: "Bold";
|
|
106
|
+
readonly italic: "Italic";
|
|
107
|
+
readonly strikethrough: "Strikethrough";
|
|
108
|
+
readonly link: "Link";
|
|
109
|
+
readonly inlineCode: "Inline code";
|
|
110
|
+
readonly bulletList: "Bullet list";
|
|
111
|
+
readonly orderedList: "Ordered list";
|
|
112
|
+
readonly blockQuote: "Block quote";
|
|
113
|
+
readonly blockCode: "Block code";
|
|
114
|
+
readonly table: "Table";
|
|
115
|
+
readonly image: "Image";
|
|
116
|
+
readonly more: "More";
|
|
117
|
+
};
|
|
118
|
+
readonly clear: "Clear";
|
|
119
|
+
readonly copy: "Copy";
|
|
120
|
+
readonly copied: "Copied";
|
|
121
|
+
readonly add: "Add";
|
|
122
|
+
readonly cancel: "Cancel";
|
|
123
|
+
readonly link: {
|
|
124
|
+
readonly title: "Add link";
|
|
125
|
+
readonly titleField: {
|
|
126
|
+
readonly label: "Text";
|
|
127
|
+
readonly placeholder: "Link text";
|
|
128
|
+
};
|
|
129
|
+
readonly urlField: {
|
|
130
|
+
readonly label: "URL";
|
|
131
|
+
readonly placeholder: "https://";
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
readonly image: {
|
|
135
|
+
readonly title: "Add image";
|
|
136
|
+
readonly url: "URL";
|
|
137
|
+
readonly alt: "Alt text";
|
|
138
|
+
readonly placeholder: "https://";
|
|
139
|
+
};
|
|
140
|
+
readonly table: {
|
|
141
|
+
readonly pickSize: "Pick size";
|
|
142
|
+
readonly insert: "Insert {{rows}} × {{cols}} table";
|
|
143
|
+
readonly column: "Column {{index}}";
|
|
144
|
+
readonly customize: "Customize table";
|
|
145
|
+
readonly columns: "Columns";
|
|
146
|
+
readonly rows: "Rows";
|
|
147
|
+
};
|
|
148
|
+
readonly linkText: "link text";
|
|
149
|
+
};
|
|
150
|
+
readonly 'ru-RU': {
|
|
151
|
+
readonly toolbar: {
|
|
152
|
+
readonly heading: "Заголовок";
|
|
153
|
+
readonly bold: "Жирный";
|
|
154
|
+
readonly italic: "Курсив";
|
|
155
|
+
readonly strikethrough: "Зачёркнутый";
|
|
156
|
+
readonly link: "Ссылка";
|
|
157
|
+
readonly inlineCode: "Строчный код";
|
|
158
|
+
readonly bulletList: "Маркированный список";
|
|
159
|
+
readonly orderedList: "Нумерованный список";
|
|
160
|
+
readonly blockQuote: "Цитата";
|
|
161
|
+
readonly blockCode: "Блок кода";
|
|
162
|
+
readonly table: "Таблица";
|
|
163
|
+
readonly image: "Картинка";
|
|
164
|
+
readonly more: "Ещё";
|
|
165
|
+
};
|
|
166
|
+
readonly clear: "Очистить";
|
|
167
|
+
readonly copy: "Скопировать";
|
|
168
|
+
readonly copied: "Скопировано";
|
|
169
|
+
readonly add: "Добавить";
|
|
170
|
+
readonly cancel: "Отмена";
|
|
171
|
+
readonly link: {
|
|
172
|
+
readonly title: "Добавить ссылку";
|
|
173
|
+
readonly titleField: {
|
|
174
|
+
readonly label: "Текст";
|
|
175
|
+
readonly placeholder: "Текст ссылки";
|
|
176
|
+
};
|
|
177
|
+
readonly urlField: {
|
|
178
|
+
readonly label: "URL";
|
|
179
|
+
readonly placeholder: "https://";
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
readonly image: {
|
|
183
|
+
readonly title: "Добавить изображение";
|
|
184
|
+
readonly url: "URL";
|
|
185
|
+
readonly alt: "Альтернативный текст";
|
|
186
|
+
readonly placeholder: "https://";
|
|
187
|
+
};
|
|
188
|
+
readonly table: {
|
|
189
|
+
readonly pickSize: "Выберите размер";
|
|
190
|
+
readonly insert: "Вставить таблицу {{rows}} × {{cols}}";
|
|
191
|
+
readonly column: "Колонка {{index}}";
|
|
192
|
+
readonly customize: "Настроить таблицу";
|
|
193
|
+
readonly columns: "Столбцы";
|
|
194
|
+
readonly rows: "Строки";
|
|
195
|
+
};
|
|
196
|
+
readonly linkText: "текст ссылки";
|
|
197
|
+
};
|
|
198
|
+
}, "@cloud-ru/ds-markdown">;
|
|
199
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.markdownLocale = void 0;
|
|
4
|
+
const locale_1 = require("@cloud-ru/ds-locale");
|
|
5
|
+
const MARKDOWN_MESSAGES = (0, locale_1.defineMessages)({
|
|
6
|
+
'en-GB': {
|
|
7
|
+
toolbar: {
|
|
8
|
+
heading: 'Heading',
|
|
9
|
+
bold: 'Bold',
|
|
10
|
+
italic: 'Italic',
|
|
11
|
+
strikethrough: 'Strikethrough',
|
|
12
|
+
link: 'Link',
|
|
13
|
+
inlineCode: 'Inline code',
|
|
14
|
+
bulletList: 'Bullet list',
|
|
15
|
+
orderedList: 'Ordered list',
|
|
16
|
+
blockQuote: 'Block quote',
|
|
17
|
+
blockCode: 'Block code',
|
|
18
|
+
table: 'Table',
|
|
19
|
+
image: 'Image',
|
|
20
|
+
more: 'More',
|
|
21
|
+
},
|
|
22
|
+
clear: 'Clear',
|
|
23
|
+
copy: 'Copy',
|
|
24
|
+
copied: 'Copied',
|
|
25
|
+
add: 'Add',
|
|
26
|
+
cancel: 'Cancel',
|
|
27
|
+
link: {
|
|
28
|
+
title: 'Add link',
|
|
29
|
+
titleField: {
|
|
30
|
+
label: 'Text',
|
|
31
|
+
placeholder: 'Link text',
|
|
32
|
+
},
|
|
33
|
+
urlField: {
|
|
34
|
+
label: 'URL',
|
|
35
|
+
placeholder: 'https://',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
image: {
|
|
39
|
+
title: 'Add image',
|
|
40
|
+
url: 'URL',
|
|
41
|
+
alt: 'Alt text',
|
|
42
|
+
placeholder: 'https://',
|
|
43
|
+
},
|
|
44
|
+
table: {
|
|
45
|
+
pickSize: 'Pick size',
|
|
46
|
+
insert: 'Insert {{rows}} × {{cols}} table',
|
|
47
|
+
column: 'Column {{index}}',
|
|
48
|
+
customize: 'Customize table',
|
|
49
|
+
columns: 'Columns',
|
|
50
|
+
rows: 'Rows',
|
|
51
|
+
},
|
|
52
|
+
linkText: 'link text',
|
|
53
|
+
},
|
|
54
|
+
'ru-RU': {
|
|
55
|
+
toolbar: {
|
|
56
|
+
heading: 'Заголовок',
|
|
57
|
+
bold: 'Жирный',
|
|
58
|
+
italic: 'Курсив',
|
|
59
|
+
strikethrough: 'Зачёркнутый',
|
|
60
|
+
link: 'Ссылка',
|
|
61
|
+
inlineCode: 'Строчный код',
|
|
62
|
+
bulletList: 'Маркированный список',
|
|
63
|
+
orderedList: 'Нумерованный список',
|
|
64
|
+
blockQuote: 'Цитата',
|
|
65
|
+
blockCode: 'Блок кода',
|
|
66
|
+
table: 'Таблица',
|
|
67
|
+
image: 'Картинка',
|
|
68
|
+
more: 'Ещё',
|
|
69
|
+
},
|
|
70
|
+
clear: 'Очистить',
|
|
71
|
+
copy: 'Скопировать',
|
|
72
|
+
copied: 'Скопировано',
|
|
73
|
+
add: 'Добавить',
|
|
74
|
+
cancel: 'Отмена',
|
|
75
|
+
link: {
|
|
76
|
+
title: 'Добавить ссылку',
|
|
77
|
+
titleField: {
|
|
78
|
+
label: 'Текст',
|
|
79
|
+
placeholder: 'Текст ссылки',
|
|
80
|
+
},
|
|
81
|
+
urlField: {
|
|
82
|
+
label: 'URL',
|
|
83
|
+
placeholder: 'https://',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
image: {
|
|
87
|
+
title: 'Добавить изображение',
|
|
88
|
+
url: 'URL',
|
|
89
|
+
alt: 'Альтернативный текст',
|
|
90
|
+
placeholder: 'https://',
|
|
91
|
+
},
|
|
92
|
+
table: {
|
|
93
|
+
pickSize: 'Выберите размер',
|
|
94
|
+
insert: 'Вставить таблицу {{rows}} × {{cols}}',
|
|
95
|
+
column: 'Колонка {{index}}',
|
|
96
|
+
customize: 'Настроить таблицу',
|
|
97
|
+
columns: 'Столбцы',
|
|
98
|
+
rows: 'Строки',
|
|
99
|
+
},
|
|
100
|
+
linkText: 'текст ссылки',
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
/** locale компонента Markdown: `markdownLocale.useTranslations()` в коде, `markdownLocale.extend(...)` в сервисе. */
|
|
104
|
+
exports.markdownLocale = (0, locale_1.defineLocale)('@cloud-ru/ds-markdown', MARKDOWN_MESSAGES);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const lowlight: {
|
|
2
|
+
highlight: (language: string, value: string, options?: Readonly<import("lowlight").Options> | null | undefined) => import("hast").Root;
|
|
3
|
+
highlightAuto: (value: string, options?: Readonly<import("lowlight").AutoOptions> | null | undefined) => import("hast").Root;
|
|
4
|
+
listLanguages: () => Array<string>;
|
|
5
|
+
register: {
|
|
6
|
+
(grammars: Readonly<Record<string, import("highlight.js").LanguageFn>>): undefined;
|
|
7
|
+
(name: string, grammar: import("highlight.js").LanguageFn): undefined;
|
|
8
|
+
};
|
|
9
|
+
registerAlias: {
|
|
10
|
+
(aliases: Readonly<Record<string, ReadonlyArray<string> | string>>): undefined;
|
|
11
|
+
(language: string, alias: ReadonlyArray<string> | string): undefined;
|
|
12
|
+
};
|
|
13
|
+
registered: (aliasOrName: string) => boolean;
|
|
14
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.lowlight = void 0;
|
|
7
|
+
const bash_1 = __importDefault(require("highlight.js/lib/languages/bash"));
|
|
8
|
+
const css_1 = __importDefault(require("highlight.js/lib/languages/css"));
|
|
9
|
+
const diff_1 = __importDefault(require("highlight.js/lib/languages/diff"));
|
|
10
|
+
const go_1 = __importDefault(require("highlight.js/lib/languages/go"));
|
|
11
|
+
const javascript_1 = __importDefault(require("highlight.js/lib/languages/javascript"));
|
|
12
|
+
const json_1 = __importDefault(require("highlight.js/lib/languages/json"));
|
|
13
|
+
const markdown_1 = __importDefault(require("highlight.js/lib/languages/markdown"));
|
|
14
|
+
const python_1 = __importDefault(require("highlight.js/lib/languages/python"));
|
|
15
|
+
const scss_1 = __importDefault(require("highlight.js/lib/languages/scss"));
|
|
16
|
+
const shell_1 = __importDefault(require("highlight.js/lib/languages/shell"));
|
|
17
|
+
const typescript_1 = __importDefault(require("highlight.js/lib/languages/typescript"));
|
|
18
|
+
const xml_1 = __importDefault(require("highlight.js/lib/languages/xml"));
|
|
19
|
+
const yaml_1 = __importDefault(require("highlight.js/lib/languages/yaml"));
|
|
20
|
+
const lowlight_1 = require("lowlight");
|
|
21
|
+
exports.lowlight = (0, lowlight_1.createLowlight)({
|
|
22
|
+
bash: bash_1.default,
|
|
23
|
+
css: css_1.default,
|
|
24
|
+
diff: diff_1.default,
|
|
25
|
+
go: go_1.default,
|
|
26
|
+
javascript: javascript_1.default,
|
|
27
|
+
json: json_1.default,
|
|
28
|
+
markdown: markdown_1.default,
|
|
29
|
+
python: python_1.default,
|
|
30
|
+
scss: scss_1.default,
|
|
31
|
+
shell: shell_1.default,
|
|
32
|
+
typescript: typescript_1.default,
|
|
33
|
+
xml: xml_1.default,
|
|
34
|
+
yaml: yaml_1.default,
|
|
35
|
+
});
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HeadingLevel, ToolbarItemId } from './types';
|
|
2
|
+
export type RawEdit = {
|
|
3
|
+
text: string;
|
|
4
|
+
selStart: number;
|
|
5
|
+
selEnd: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function buildMarkdownTable(rows: number, cols: number, columnLabel: (index: number) => string): string;
|
|
8
|
+
/** Инлайн-toggle (bold/italic/strike/inline-code) или `null`, если id не инлайновый. */
|
|
9
|
+
export declare function applyInlineToggle(id: ToolbarItemId, value: string, start: number, end: number): RawEdit | null;
|
|
10
|
+
/** Блочный toggle (bullet/ordered/quote/block-code) или `null`, если id не блочный. */
|
|
11
|
+
export declare function applyBlockToggle(id: ToolbarItemId, value: string, start: number, end: number): RawEdit | null;
|
|
12
|
+
export declare function applyHeading(value: string, start: number, end: number, level: HeadingLevel): RawEdit;
|
|
13
|
+
export declare function applyParagraph(value: string, start: number, end: number): RawEdit;
|
|
14
|
+
export declare function applyLink(value: string, start: number, end: number, href: string, title: string, defaultText: string): RawEdit;
|
|
15
|
+
export declare function applyImage(value: string, start: number, end: number, src: string, alt: string): RawEdit;
|
|
16
|
+
export declare function applyTable(value: string, start: number, end: number, rows: number, cols: number, columnLabel: (index: number) => string): RawEdit;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildMarkdownTable = buildMarkdownTable;
|
|
4
|
+
exports.applyInlineToggle = applyInlineToggle;
|
|
5
|
+
exports.applyBlockToggle = applyBlockToggle;
|
|
6
|
+
exports.applyHeading = applyHeading;
|
|
7
|
+
exports.applyParagraph = applyParagraph;
|
|
8
|
+
exports.applyLink = applyLink;
|
|
9
|
+
exports.applyImage = applyImage;
|
|
10
|
+
exports.applyTable = applyTable;
|
|
11
|
+
const constants_1 = require("./constants");
|
|
12
|
+
// Инлайн-обёртки (toggle): **bold**, *italic*, ~~strike~~, `code`.
|
|
13
|
+
const INLINE_MARKER = {
|
|
14
|
+
[constants_1.TOOLBAR_ITEM.Bold]: '**',
|
|
15
|
+
[constants_1.TOOLBAR_ITEM.Italic]: '*',
|
|
16
|
+
[constants_1.TOOLBAR_ITEM.Strikethrough]: '~~',
|
|
17
|
+
[constants_1.TOOLBAR_ITEM.InlineCode]: '`',
|
|
18
|
+
};
|
|
19
|
+
// Любой ведущий блок-маркер строки (heading/quote/bullet/ordered) — снимается при смене типа блока.
|
|
20
|
+
const BLOCK_MARKER_RE = /^(#{1,6}\s+|>\s+|[-*+]\s+|\d+\.\s+)/;
|
|
21
|
+
function getLineBounds(value, start, end) {
|
|
22
|
+
const lineStart = value.lastIndexOf('\n', start - 1) + 1;
|
|
23
|
+
let lineEnd = value.indexOf('\n', end);
|
|
24
|
+
if (lineEnd === -1)
|
|
25
|
+
lineEnd = value.length;
|
|
26
|
+
return { lineStart, lineEnd };
|
|
27
|
+
}
|
|
28
|
+
function wrapInline(value, start, end, marker) {
|
|
29
|
+
const selected = value.slice(start, end);
|
|
30
|
+
const before = value.slice(Math.max(0, start - marker.length), start);
|
|
31
|
+
const after = value.slice(end, end + marker.length);
|
|
32
|
+
// Уже обёрнуто — снимаем обёртку (toggle off).
|
|
33
|
+
if (start >= marker.length && before === marker && after === marker) {
|
|
34
|
+
const text = value.slice(0, start - marker.length) + selected + value.slice(end + marker.length);
|
|
35
|
+
return { text, selStart: start - marker.length, selEnd: end - marker.length };
|
|
36
|
+
}
|
|
37
|
+
const text = value.slice(0, start) + marker + selected + marker + value.slice(end);
|
|
38
|
+
return { text, selStart: start + marker.length, selEnd: end + marker.length };
|
|
39
|
+
}
|
|
40
|
+
function transformLines(value, start, end, transform) {
|
|
41
|
+
const { lineStart, lineEnd } = getLineBounds(value, start, end);
|
|
42
|
+
const block = value.slice(lineStart, lineEnd);
|
|
43
|
+
const next = transform(block.split('\n')).join('\n');
|
|
44
|
+
const text = value.slice(0, lineStart) + next + value.slice(lineEnd);
|
|
45
|
+
return { text, selStart: lineStart, selEnd: lineStart + next.length };
|
|
46
|
+
}
|
|
47
|
+
function toggleLinePrefix(value, start, end, prefix) {
|
|
48
|
+
const escaped = prefix.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
49
|
+
const ownRe = new RegExp(`^${escaped}`);
|
|
50
|
+
return transformLines(value, start, end, lines => {
|
|
51
|
+
const allPrefixed = lines.every(line => ownRe.test(line));
|
|
52
|
+
if (allPrefixed)
|
|
53
|
+
return lines.map(line => line.replace(ownRe, ''));
|
|
54
|
+
return lines.map(line => prefix + line.replace(BLOCK_MARKER_RE, ''));
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function toggleOrderedList(value, start, end) {
|
|
58
|
+
const orderedRe = /^\d+\.\s+/;
|
|
59
|
+
return transformLines(value, start, end, lines => {
|
|
60
|
+
const allPrefixed = lines.every(line => orderedRe.test(line));
|
|
61
|
+
if (allPrefixed)
|
|
62
|
+
return lines.map(line => line.replace(orderedRe, ''));
|
|
63
|
+
return lines.map((line, index) => `${index + 1}. ${line.replace(BLOCK_MARKER_RE, '')}`);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function setHeading(value, start, end, level) {
|
|
67
|
+
const marker = `${'#'.repeat(level)} `;
|
|
68
|
+
const sameLevelRe = new RegExp(`^#{${level}}\\s+`);
|
|
69
|
+
return transformLines(value, start, end, lines => {
|
|
70
|
+
const allSame = lines.every(line => sameLevelRe.test(line));
|
|
71
|
+
// Повторный выбор того же уровня снимает заголовок (toggle).
|
|
72
|
+
if (allSame)
|
|
73
|
+
return lines.map(line => line.replace(sameLevelRe, ''));
|
|
74
|
+
return lines.map(line => marker + line.replace(BLOCK_MARKER_RE, ''));
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function setParagraph(value, start, end) {
|
|
78
|
+
return transformLines(value, start, end, lines => lines.map(line => line.replace(/^#{1,6}\s+/, '')));
|
|
79
|
+
}
|
|
80
|
+
function fenceBlock(value, start, end) {
|
|
81
|
+
const { lineStart, lineEnd } = getLineBounds(value, start, end);
|
|
82
|
+
const block = value.slice(lineStart, lineEnd);
|
|
83
|
+
const fenced = `\`\`\`\n${block}\n\`\`\``;
|
|
84
|
+
const text = value.slice(0, lineStart) + fenced + value.slice(lineEnd);
|
|
85
|
+
// Выделяем тело между fence'ами.
|
|
86
|
+
const innerStart = lineStart + 4;
|
|
87
|
+
return { text, selStart: innerStart, selEnd: innerStart + block.length };
|
|
88
|
+
}
|
|
89
|
+
function replaceSelection(value, start, end, insert, selStart, selEnd) {
|
|
90
|
+
const text = value.slice(0, start) + insert + value.slice(end);
|
|
91
|
+
return { text, selStart, selEnd };
|
|
92
|
+
}
|
|
93
|
+
function buildMarkdownTable(rows, cols, columnLabel) {
|
|
94
|
+
const header = `| ${Array.from({ length: cols }, (_, i) => columnLabel(i + 1)).join(' | ')} |`;
|
|
95
|
+
const divider = `| ${Array.from({ length: cols }, () => '---').join(' | ')} |`;
|
|
96
|
+
const bodyRow = `| ${Array.from({ length: cols }, () => ' ').join(' | ')} |`;
|
|
97
|
+
const body = Array.from({ length: rows }, () => bodyRow);
|
|
98
|
+
return [header, divider, ...body].join('\n');
|
|
99
|
+
}
|
|
100
|
+
/** Инлайн-toggle (bold/italic/strike/inline-code) или `null`, если id не инлайновый. */
|
|
101
|
+
function applyInlineToggle(id, value, start, end) {
|
|
102
|
+
const marker = INLINE_MARKER[id];
|
|
103
|
+
return marker ? wrapInline(value, start, end, marker) : null;
|
|
104
|
+
}
|
|
105
|
+
/** Блочный toggle (bullet/ordered/quote/block-code) или `null`, если id не блочный. */
|
|
106
|
+
function applyBlockToggle(id, value, start, end) {
|
|
107
|
+
switch (id) {
|
|
108
|
+
case constants_1.TOOLBAR_ITEM.BulletList:
|
|
109
|
+
return toggleLinePrefix(value, start, end, '- ');
|
|
110
|
+
case constants_1.TOOLBAR_ITEM.OrderedList:
|
|
111
|
+
return toggleOrderedList(value, start, end);
|
|
112
|
+
case constants_1.TOOLBAR_ITEM.BlockQuote:
|
|
113
|
+
return toggleLinePrefix(value, start, end, '> ');
|
|
114
|
+
case constants_1.TOOLBAR_ITEM.BlockCode:
|
|
115
|
+
return fenceBlock(value, start, end);
|
|
116
|
+
default:
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function applyHeading(value, start, end, level) {
|
|
121
|
+
return setHeading(value, start, end, level);
|
|
122
|
+
}
|
|
123
|
+
function applyParagraph(value, start, end) {
|
|
124
|
+
return setParagraph(value, start, end);
|
|
125
|
+
}
|
|
126
|
+
function applyLink(value, start, end, href, title, defaultText) {
|
|
127
|
+
const selected = title || value.slice(start, end) || defaultText;
|
|
128
|
+
const insert = `[${selected}](${href})`;
|
|
129
|
+
// Выделяем подпись ссылки внутри скобок.
|
|
130
|
+
return replaceSelection(value, start, end, insert, start + 1, start + 1 + selected.length);
|
|
131
|
+
}
|
|
132
|
+
function applyImage(value, start, end, src, alt) {
|
|
133
|
+
const insert = ``;
|
|
134
|
+
const cursor = start + insert.length;
|
|
135
|
+
return replaceSelection(value, start, end, insert, cursor, cursor);
|
|
136
|
+
}
|
|
137
|
+
function applyTable(value, start, end, rows, cols, columnLabel) {
|
|
138
|
+
const table = buildMarkdownTable(rows, cols, columnLabel);
|
|
139
|
+
// Таблица — отдельный блок: добавляем переводы строк по краям, если рядом непустой текст.
|
|
140
|
+
const prefix = start > 0 && value[start - 1] !== '\n' ? '\n\n' : '';
|
|
141
|
+
const suffix = end < value.length && value[end] !== '\n' ? '\n\n' : '';
|
|
142
|
+
const insert = prefix + table + suffix;
|
|
143
|
+
const cursor = start + insert.length;
|
|
144
|
+
return replaceSelection(value, start, end, insert, cursor, cursor);
|
|
145
|
+
}
|