@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,101 @@
|
|
|
1
|
+
import { defineLocale, defineMessages } from '@cloud-ru/ds-locale';
|
|
2
|
+
const MARKDOWN_MESSAGES = defineMessages({
|
|
3
|
+
'en-GB': {
|
|
4
|
+
toolbar: {
|
|
5
|
+
heading: 'Heading',
|
|
6
|
+
bold: 'Bold',
|
|
7
|
+
italic: 'Italic',
|
|
8
|
+
strikethrough: 'Strikethrough',
|
|
9
|
+
link: 'Link',
|
|
10
|
+
inlineCode: 'Inline code',
|
|
11
|
+
bulletList: 'Bullet list',
|
|
12
|
+
orderedList: 'Ordered list',
|
|
13
|
+
blockQuote: 'Block quote',
|
|
14
|
+
blockCode: 'Block code',
|
|
15
|
+
table: 'Table',
|
|
16
|
+
image: 'Image',
|
|
17
|
+
more: 'More',
|
|
18
|
+
},
|
|
19
|
+
clear: 'Clear',
|
|
20
|
+
copy: 'Copy',
|
|
21
|
+
copied: 'Copied',
|
|
22
|
+
add: 'Add',
|
|
23
|
+
cancel: 'Cancel',
|
|
24
|
+
link: {
|
|
25
|
+
title: 'Add link',
|
|
26
|
+
titleField: {
|
|
27
|
+
label: 'Text',
|
|
28
|
+
placeholder: 'Link text',
|
|
29
|
+
},
|
|
30
|
+
urlField: {
|
|
31
|
+
label: 'URL',
|
|
32
|
+
placeholder: 'https://',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
image: {
|
|
36
|
+
title: 'Add image',
|
|
37
|
+
url: 'URL',
|
|
38
|
+
alt: 'Alt text',
|
|
39
|
+
placeholder: 'https://',
|
|
40
|
+
},
|
|
41
|
+
table: {
|
|
42
|
+
pickSize: 'Pick size',
|
|
43
|
+
insert: 'Insert {{rows}} × {{cols}} table',
|
|
44
|
+
column: 'Column {{index}}',
|
|
45
|
+
customize: 'Customize table',
|
|
46
|
+
columns: 'Columns',
|
|
47
|
+
rows: 'Rows',
|
|
48
|
+
},
|
|
49
|
+
linkText: 'link text',
|
|
50
|
+
},
|
|
51
|
+
'ru-RU': {
|
|
52
|
+
toolbar: {
|
|
53
|
+
heading: 'Заголовок',
|
|
54
|
+
bold: 'Жирный',
|
|
55
|
+
italic: 'Курсив',
|
|
56
|
+
strikethrough: 'Зачёркнутый',
|
|
57
|
+
link: 'Ссылка',
|
|
58
|
+
inlineCode: 'Строчный код',
|
|
59
|
+
bulletList: 'Маркированный список',
|
|
60
|
+
orderedList: 'Нумерованный список',
|
|
61
|
+
blockQuote: 'Цитата',
|
|
62
|
+
blockCode: 'Блок кода',
|
|
63
|
+
table: 'Таблица',
|
|
64
|
+
image: 'Картинка',
|
|
65
|
+
more: 'Ещё',
|
|
66
|
+
},
|
|
67
|
+
clear: 'Очистить',
|
|
68
|
+
copy: 'Скопировать',
|
|
69
|
+
copied: 'Скопировано',
|
|
70
|
+
add: 'Добавить',
|
|
71
|
+
cancel: 'Отмена',
|
|
72
|
+
link: {
|
|
73
|
+
title: 'Добавить ссылку',
|
|
74
|
+
titleField: {
|
|
75
|
+
label: 'Текст',
|
|
76
|
+
placeholder: 'Текст ссылки',
|
|
77
|
+
},
|
|
78
|
+
urlField: {
|
|
79
|
+
label: 'URL',
|
|
80
|
+
placeholder: 'https://',
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
image: {
|
|
84
|
+
title: 'Добавить изображение',
|
|
85
|
+
url: 'URL',
|
|
86
|
+
alt: 'Альтернативный текст',
|
|
87
|
+
placeholder: 'https://',
|
|
88
|
+
},
|
|
89
|
+
table: {
|
|
90
|
+
pickSize: 'Выберите размер',
|
|
91
|
+
insert: 'Вставить таблицу {{rows}} × {{cols}}',
|
|
92
|
+
column: 'Колонка {{index}}',
|
|
93
|
+
customize: 'Настроить таблицу',
|
|
94
|
+
columns: 'Столбцы',
|
|
95
|
+
rows: 'Строки',
|
|
96
|
+
},
|
|
97
|
+
linkText: 'текст ссылки',
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
/** locale компонента Markdown: `markdownLocale.useTranslations()` в коде, `markdownLocale.extend(...)` в сервисе. */
|
|
101
|
+
export const markdownLocale = 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,29 @@
|
|
|
1
|
+
import bash from 'highlight.js/lib/languages/bash';
|
|
2
|
+
import css from 'highlight.js/lib/languages/css';
|
|
3
|
+
import diff from 'highlight.js/lib/languages/diff';
|
|
4
|
+
import go from 'highlight.js/lib/languages/go';
|
|
5
|
+
import javascript from 'highlight.js/lib/languages/javascript';
|
|
6
|
+
import json from 'highlight.js/lib/languages/json';
|
|
7
|
+
import markdown from 'highlight.js/lib/languages/markdown';
|
|
8
|
+
import python from 'highlight.js/lib/languages/python';
|
|
9
|
+
import scss from 'highlight.js/lib/languages/scss';
|
|
10
|
+
import shell from 'highlight.js/lib/languages/shell';
|
|
11
|
+
import typescript from 'highlight.js/lib/languages/typescript';
|
|
12
|
+
import xml from 'highlight.js/lib/languages/xml';
|
|
13
|
+
import yaml from 'highlight.js/lib/languages/yaml';
|
|
14
|
+
import { createLowlight } from 'lowlight';
|
|
15
|
+
export const lowlight = createLowlight({
|
|
16
|
+
bash,
|
|
17
|
+
css,
|
|
18
|
+
diff,
|
|
19
|
+
go,
|
|
20
|
+
javascript,
|
|
21
|
+
json,
|
|
22
|
+
markdown,
|
|
23
|
+
python,
|
|
24
|
+
scss,
|
|
25
|
+
shell,
|
|
26
|
+
typescript,
|
|
27
|
+
xml,
|
|
28
|
+
yaml,
|
|
29
|
+
});
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HeadingLevel, ToolbarItemId } from './types.js';
|
|
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,135 @@
|
|
|
1
|
+
import { TOOLBAR_ITEM } from './constants.js';
|
|
2
|
+
// Инлайн-обёртки (toggle): **bold**, *italic*, ~~strike~~, `code`.
|
|
3
|
+
const INLINE_MARKER = {
|
|
4
|
+
[TOOLBAR_ITEM.Bold]: '**',
|
|
5
|
+
[TOOLBAR_ITEM.Italic]: '*',
|
|
6
|
+
[TOOLBAR_ITEM.Strikethrough]: '~~',
|
|
7
|
+
[TOOLBAR_ITEM.InlineCode]: '`',
|
|
8
|
+
};
|
|
9
|
+
// Любой ведущий блок-маркер строки (heading/quote/bullet/ordered) — снимается при смене типа блока.
|
|
10
|
+
const BLOCK_MARKER_RE = /^(#{1,6}\s+|>\s+|[-*+]\s+|\d+\.\s+)/;
|
|
11
|
+
function getLineBounds(value, start, end) {
|
|
12
|
+
const lineStart = value.lastIndexOf('\n', start - 1) + 1;
|
|
13
|
+
let lineEnd = value.indexOf('\n', end);
|
|
14
|
+
if (lineEnd === -1)
|
|
15
|
+
lineEnd = value.length;
|
|
16
|
+
return { lineStart, lineEnd };
|
|
17
|
+
}
|
|
18
|
+
function wrapInline(value, start, end, marker) {
|
|
19
|
+
const selected = value.slice(start, end);
|
|
20
|
+
const before = value.slice(Math.max(0, start - marker.length), start);
|
|
21
|
+
const after = value.slice(end, end + marker.length);
|
|
22
|
+
// Уже обёрнуто — снимаем обёртку (toggle off).
|
|
23
|
+
if (start >= marker.length && before === marker && after === marker) {
|
|
24
|
+
const text = value.slice(0, start - marker.length) + selected + value.slice(end + marker.length);
|
|
25
|
+
return { text, selStart: start - marker.length, selEnd: end - marker.length };
|
|
26
|
+
}
|
|
27
|
+
const text = value.slice(0, start) + marker + selected + marker + value.slice(end);
|
|
28
|
+
return { text, selStart: start + marker.length, selEnd: end + marker.length };
|
|
29
|
+
}
|
|
30
|
+
function transformLines(value, start, end, transform) {
|
|
31
|
+
const { lineStart, lineEnd } = getLineBounds(value, start, end);
|
|
32
|
+
const block = value.slice(lineStart, lineEnd);
|
|
33
|
+
const next = transform(block.split('\n')).join('\n');
|
|
34
|
+
const text = value.slice(0, lineStart) + next + value.slice(lineEnd);
|
|
35
|
+
return { text, selStart: lineStart, selEnd: lineStart + next.length };
|
|
36
|
+
}
|
|
37
|
+
function toggleLinePrefix(value, start, end, prefix) {
|
|
38
|
+
const escaped = prefix.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
39
|
+
const ownRe = new RegExp(`^${escaped}`);
|
|
40
|
+
return transformLines(value, start, end, lines => {
|
|
41
|
+
const allPrefixed = lines.every(line => ownRe.test(line));
|
|
42
|
+
if (allPrefixed)
|
|
43
|
+
return lines.map(line => line.replace(ownRe, ''));
|
|
44
|
+
return lines.map(line => prefix + line.replace(BLOCK_MARKER_RE, ''));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function toggleOrderedList(value, start, end) {
|
|
48
|
+
const orderedRe = /^\d+\.\s+/;
|
|
49
|
+
return transformLines(value, start, end, lines => {
|
|
50
|
+
const allPrefixed = lines.every(line => orderedRe.test(line));
|
|
51
|
+
if (allPrefixed)
|
|
52
|
+
return lines.map(line => line.replace(orderedRe, ''));
|
|
53
|
+
return lines.map((line, index) => `${index + 1}. ${line.replace(BLOCK_MARKER_RE, '')}`);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function setHeading(value, start, end, level) {
|
|
57
|
+
const marker = `${'#'.repeat(level)} `;
|
|
58
|
+
const sameLevelRe = new RegExp(`^#{${level}}\\s+`);
|
|
59
|
+
return transformLines(value, start, end, lines => {
|
|
60
|
+
const allSame = lines.every(line => sameLevelRe.test(line));
|
|
61
|
+
// Повторный выбор того же уровня снимает заголовок (toggle).
|
|
62
|
+
if (allSame)
|
|
63
|
+
return lines.map(line => line.replace(sameLevelRe, ''));
|
|
64
|
+
return lines.map(line => marker + line.replace(BLOCK_MARKER_RE, ''));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function setParagraph(value, start, end) {
|
|
68
|
+
return transformLines(value, start, end, lines => lines.map(line => line.replace(/^#{1,6}\s+/, '')));
|
|
69
|
+
}
|
|
70
|
+
function fenceBlock(value, start, end) {
|
|
71
|
+
const { lineStart, lineEnd } = getLineBounds(value, start, end);
|
|
72
|
+
const block = value.slice(lineStart, lineEnd);
|
|
73
|
+
const fenced = `\`\`\`\n${block}\n\`\`\``;
|
|
74
|
+
const text = value.slice(0, lineStart) + fenced + value.slice(lineEnd);
|
|
75
|
+
// Выделяем тело между fence'ами.
|
|
76
|
+
const innerStart = lineStart + 4;
|
|
77
|
+
return { text, selStart: innerStart, selEnd: innerStart + block.length };
|
|
78
|
+
}
|
|
79
|
+
function replaceSelection(value, start, end, insert, selStart, selEnd) {
|
|
80
|
+
const text = value.slice(0, start) + insert + value.slice(end);
|
|
81
|
+
return { text, selStart, selEnd };
|
|
82
|
+
}
|
|
83
|
+
export function buildMarkdownTable(rows, cols, columnLabel) {
|
|
84
|
+
const header = `| ${Array.from({ length: cols }, (_, i) => columnLabel(i + 1)).join(' | ')} |`;
|
|
85
|
+
const divider = `| ${Array.from({ length: cols }, () => '---').join(' | ')} |`;
|
|
86
|
+
const bodyRow = `| ${Array.from({ length: cols }, () => ' ').join(' | ')} |`;
|
|
87
|
+
const body = Array.from({ length: rows }, () => bodyRow);
|
|
88
|
+
return [header, divider, ...body].join('\n');
|
|
89
|
+
}
|
|
90
|
+
/** Инлайн-toggle (bold/italic/strike/inline-code) или `null`, если id не инлайновый. */
|
|
91
|
+
export function applyInlineToggle(id, value, start, end) {
|
|
92
|
+
const marker = INLINE_MARKER[id];
|
|
93
|
+
return marker ? wrapInline(value, start, end, marker) : null;
|
|
94
|
+
}
|
|
95
|
+
/** Блочный toggle (bullet/ordered/quote/block-code) или `null`, если id не блочный. */
|
|
96
|
+
export function applyBlockToggle(id, value, start, end) {
|
|
97
|
+
switch (id) {
|
|
98
|
+
case TOOLBAR_ITEM.BulletList:
|
|
99
|
+
return toggleLinePrefix(value, start, end, '- ');
|
|
100
|
+
case TOOLBAR_ITEM.OrderedList:
|
|
101
|
+
return toggleOrderedList(value, start, end);
|
|
102
|
+
case TOOLBAR_ITEM.BlockQuote:
|
|
103
|
+
return toggleLinePrefix(value, start, end, '> ');
|
|
104
|
+
case TOOLBAR_ITEM.BlockCode:
|
|
105
|
+
return fenceBlock(value, start, end);
|
|
106
|
+
default:
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export function applyHeading(value, start, end, level) {
|
|
111
|
+
return setHeading(value, start, end, level);
|
|
112
|
+
}
|
|
113
|
+
export function applyParagraph(value, start, end) {
|
|
114
|
+
return setParagraph(value, start, end);
|
|
115
|
+
}
|
|
116
|
+
export function applyLink(value, start, end, href, title, defaultText) {
|
|
117
|
+
const selected = title || value.slice(start, end) || defaultText;
|
|
118
|
+
const insert = `[${selected}](${href})`;
|
|
119
|
+
// Выделяем подпись ссылки внутри скобок.
|
|
120
|
+
return replaceSelection(value, start, end, insert, start + 1, start + 1 + selected.length);
|
|
121
|
+
}
|
|
122
|
+
export function applyImage(value, start, end, src, alt) {
|
|
123
|
+
const insert = ``;
|
|
124
|
+
const cursor = start + insert.length;
|
|
125
|
+
return replaceSelection(value, start, end, insert, cursor, cursor);
|
|
126
|
+
}
|
|
127
|
+
export function applyTable(value, start, end, rows, cols, columnLabel) {
|
|
128
|
+
const table = buildMarkdownTable(rows, cols, columnLabel);
|
|
129
|
+
// Таблица — отдельный блок: добавляем переводы строк по краям, если рядом непустой текст.
|
|
130
|
+
const prefix = start > 0 && value[start - 1] !== '\n' ? '\n\n' : '';
|
|
131
|
+
const suffix = end < value.length && value[end] !== '\n' ? '\n\n' : '';
|
|
132
|
+
const insert = prefix + table + suffix;
|
|
133
|
+
const cursor = start + insert.length;
|
|
134
|
+
return replaceSelection(value, start, end, insert, cursor, cursor);
|
|
135
|
+
}
|