@gravity-ui/markdown-editor 14.7.0 → 14.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/README.md +16 -14
- package/build/cjs/bundle/MarkdownEditorView.d.ts +27 -0
- package/build/cjs/bundle/MarkdownEditorView.js +19 -2
- package/build/cjs/bundle/config/action-names.d.ts +1 -1
- package/build/cjs/bundle/config/action-names.js +50 -27
- package/build/cjs/bundle/config/index.d.ts +3 -0
- package/build/cjs/bundle/config/index.js +3 -0
- package/build/cjs/bundle/config/markup.js +3 -0
- package/build/cjs/bundle/config/wysiwyg.d.ts +3 -0
- package/build/cjs/bundle/toolbar/utils.d.ts +17 -0
- package/build/cjs/bundle/toolbar/utils.js +64 -0
- package/build/cjs/extensions/markdown/Link/paste-plugin.js +21 -5
- package/build/cjs/i18n/menubar/en.json +1 -0
- package/build/cjs/i18n/menubar/index.d.ts +2 -1
- package/build/cjs/i18n/menubar/ru.json +1 -0
- package/build/cjs/markup/codemirror/create.js +24 -11
- package/build/cjs/markup/codemirror/smart-reindent/index.d.ts +4 -0
- package/build/cjs/markup/codemirror/smart-reindent/index.js +42 -0
- package/build/cjs/markup/codemirror/smart-reindent/utils.d.ts +15 -0
- package/build/cjs/markup/codemirror/smart-reindent/utils.js +59 -0
- package/build/cjs/modules/toolbars/constants.d.ts +13 -0
- package/build/cjs/modules/toolbars/constants.js +18 -0
- package/build/cjs/modules/toolbars/items.d.ts +127 -0
- package/build/cjs/modules/toolbars/items.js +736 -0
- package/build/cjs/modules/toolbars/presets.d.ts +6 -0
- package/build/cjs/modules/toolbars/presets.js +465 -0
- package/build/cjs/modules/toolbars/types.d.ts +62 -0
- package/build/cjs/modules/toolbars/types.js +2 -0
- package/build/cjs/toolbar/types.d.ts +8 -0
- package/build/cjs/toolbar/types.js +2 -0
- package/build/cjs/version.js +1 -1
- package/build/esm/bundle/MarkdownEditorView.d.ts +27 -0
- package/build/esm/bundle/MarkdownEditorView.js +19 -2
- package/build/esm/bundle/config/action-names.d.ts +1 -1
- package/build/esm/bundle/config/action-names.js +50 -27
- package/build/esm/bundle/config/index.d.ts +3 -0
- package/build/esm/bundle/config/index.js +3 -0
- package/build/esm/bundle/config/markup.js +3 -0
- package/build/esm/bundle/config/wysiwyg.d.ts +3 -0
- package/build/esm/bundle/toolbar/utils.d.ts +17 -0
- package/build/esm/bundle/toolbar/utils.js +59 -0
- package/build/esm/extensions/markdown/Link/paste-plugin.js +21 -5
- package/build/esm/i18n/menubar/en.json +1 -0
- package/build/esm/i18n/menubar/index.d.ts +2 -1
- package/build/esm/i18n/menubar/ru.json +1 -0
- package/build/esm/markup/codemirror/create.js +24 -11
- package/build/esm/markup/codemirror/smart-reindent/index.d.ts +4 -0
- package/build/esm/markup/codemirror/smart-reindent/index.js +38 -0
- package/build/esm/markup/codemirror/smart-reindent/utils.d.ts +15 -0
- package/build/esm/markup/codemirror/smart-reindent/utils.js +55 -0
- package/build/esm/modules/toolbars/constants.d.ts +13 -0
- package/build/esm/modules/toolbars/constants.js +15 -0
- package/build/esm/modules/toolbars/items.d.ts +127 -0
- package/build/esm/modules/toolbars/items.js +730 -0
- package/build/esm/modules/toolbars/presets.d.ts +6 -0
- package/build/esm/modules/toolbars/presets.js +462 -0
- package/build/esm/modules/toolbars/types.d.ts +62 -0
- package/build/esm/modules/toolbars/types.js +1 -0
- package/build/esm/toolbar/types.d.ts +8 -0
- package/build/esm/toolbar/types.js +2 -0
- package/build/esm/version.js +1 -1
- package/package.json +10 -2
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ToolbarsPreset } from './types';
|
|
2
|
+
export declare const zero: ToolbarsPreset;
|
|
3
|
+
export declare const commonmark: ToolbarsPreset;
|
|
4
|
+
export declare const defaultPreset: ToolbarsPreset;
|
|
5
|
+
export declare const yfm: ToolbarsPreset;
|
|
6
|
+
export declare const full: ToolbarsPreset;
|
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.full = exports.yfm = exports.defaultPreset = exports.commonmark = exports.zero = void 0;
|
|
4
|
+
const action_names_1 = require("../../bundle/config/action-names");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
const items_1 = require("./items");
|
|
7
|
+
// presets
|
|
8
|
+
exports.zero = {
|
|
9
|
+
items: {
|
|
10
|
+
[action_names_1.ActionName.undo]: {
|
|
11
|
+
view: items_1.undoItemView,
|
|
12
|
+
wysiwyg: items_1.undoItemWysiwyg,
|
|
13
|
+
markup: items_1.undoItemMarkup,
|
|
14
|
+
},
|
|
15
|
+
[action_names_1.ActionName.redo]: {
|
|
16
|
+
view: items_1.redoItemView,
|
|
17
|
+
wysiwyg: items_1.redoItemWysiwyg,
|
|
18
|
+
markup: items_1.redoItemMarkup,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
orders: {
|
|
22
|
+
[constants_1.ToolbarName.wysiwygMain]: [[action_names_1.ActionName.undo, action_names_1.ActionName.redo]],
|
|
23
|
+
[constants_1.ToolbarName.markupMain]: [[action_names_1.ActionName.undo, action_names_1.ActionName.redo]],
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
exports.commonmark = {
|
|
27
|
+
items: Object.assign(Object.assign({}, exports.zero.items), { [action_names_1.ActionName.bold]: {
|
|
28
|
+
view: items_1.boldItemView,
|
|
29
|
+
wysiwyg: items_1.boldItemWysiwyg,
|
|
30
|
+
markup: items_1.boldItemMarkup,
|
|
31
|
+
}, [action_names_1.ActionName.italic]: {
|
|
32
|
+
view: items_1.italicItemView,
|
|
33
|
+
wysiwyg: items_1.italicItemWysiwyg,
|
|
34
|
+
markup: items_1.italicItemMarkup,
|
|
35
|
+
}, [constants_1.ListName.heading]: {
|
|
36
|
+
view: items_1.headingListItemView,
|
|
37
|
+
}, [action_names_1.ActionName.paragraph]: {
|
|
38
|
+
view: items_1.paragraphItemView,
|
|
39
|
+
wysiwyg: items_1.paragraphItemWisywig,
|
|
40
|
+
markup: items_1.paragraphItemMarkup,
|
|
41
|
+
}, [action_names_1.ActionName.heading1]: {
|
|
42
|
+
view: items_1.heading1ItemView,
|
|
43
|
+
wysiwyg: items_1.heading1ItemWysiwyg,
|
|
44
|
+
markup: items_1.heading1ItemMarkup,
|
|
45
|
+
}, [action_names_1.ActionName.heading2]: {
|
|
46
|
+
view: items_1.heading2ItemView,
|
|
47
|
+
wysiwyg: items_1.heading2ItemWysiwyg,
|
|
48
|
+
markup: items_1.heading2ItemMarkup,
|
|
49
|
+
}, [action_names_1.ActionName.heading3]: {
|
|
50
|
+
view: items_1.heading3ItemView,
|
|
51
|
+
wysiwyg: items_1.heading3ItemWysiwyg,
|
|
52
|
+
markup: items_1.heading3ItemMarkup,
|
|
53
|
+
}, [action_names_1.ActionName.heading4]: {
|
|
54
|
+
view: items_1.heading4ItemView,
|
|
55
|
+
wysiwyg: items_1.heading4ItemWysiwyg,
|
|
56
|
+
markup: items_1.heading4ItemMarkup,
|
|
57
|
+
}, [action_names_1.ActionName.heading5]: {
|
|
58
|
+
view: items_1.heading5ItemView,
|
|
59
|
+
wysiwyg: items_1.heading5ItemWysiwyg,
|
|
60
|
+
markup: items_1.heading5ItemMarkup,
|
|
61
|
+
}, [action_names_1.ActionName.heading6]: {
|
|
62
|
+
view: items_1.heading6ItemView,
|
|
63
|
+
wysiwyg: items_1.heading6ItemWysiwyg,
|
|
64
|
+
markup: items_1.heading6ItemMarkup,
|
|
65
|
+
}, [constants_1.ListName.lists]: {
|
|
66
|
+
view: items_1.listsListItemView,
|
|
67
|
+
}, [action_names_1.ActionName.bulletList]: {
|
|
68
|
+
view: items_1.bulletListItemView,
|
|
69
|
+
wysiwyg: items_1.bulletListItemWysiwyg,
|
|
70
|
+
markup: items_1.bulletListItemMarkup,
|
|
71
|
+
}, [action_names_1.ActionName.orderedList]: {
|
|
72
|
+
view: items_1.orderedListItemView,
|
|
73
|
+
wysiwyg: items_1.orderedListItemWysiwyg,
|
|
74
|
+
markup: items_1.orderedListItemMarkup,
|
|
75
|
+
}, [action_names_1.ActionName.sinkListItem]: {
|
|
76
|
+
view: items_1.sinkListItemView,
|
|
77
|
+
wysiwyg: items_1.sinkListItemWysiwyg,
|
|
78
|
+
markup: items_1.sinkListItemMarkup,
|
|
79
|
+
}, [action_names_1.ActionName.liftListItem]: {
|
|
80
|
+
view: items_1.liftListItemView,
|
|
81
|
+
wysiwyg: items_1.liftListItemWysiwyg,
|
|
82
|
+
markup: items_1.liftListItemMarkup,
|
|
83
|
+
}, [action_names_1.ActionName.link]: {
|
|
84
|
+
view: items_1.linkItemView,
|
|
85
|
+
wysiwyg: items_1.linkItemWysiwyg,
|
|
86
|
+
markup: items_1.linkItemMarkup,
|
|
87
|
+
}, [action_names_1.ActionName.quote]: {
|
|
88
|
+
view: items_1.quoteItemView,
|
|
89
|
+
wysiwyg: items_1.quoteItemWysiwyg,
|
|
90
|
+
markup: items_1.quoteItemMarkup,
|
|
91
|
+
}, [constants_1.ListName.code]: {
|
|
92
|
+
view: items_1.codeBlocksListItemView,
|
|
93
|
+
}, [action_names_1.ActionName.codeInline]: {
|
|
94
|
+
view: items_1.codeItemView,
|
|
95
|
+
wysiwyg: items_1.codeItemWysiwyg,
|
|
96
|
+
markup: items_1.codeItemMarkup,
|
|
97
|
+
}, [action_names_1.ActionName.codeBlock]: {
|
|
98
|
+
view: items_1.codeBlockItemView,
|
|
99
|
+
wysiwyg: items_1.codeBlockItemWysiwyg,
|
|
100
|
+
markup: items_1.codeBlockItemMarkup,
|
|
101
|
+
}, [action_names_1.ActionName.horizontalRule]: {
|
|
102
|
+
view: items_1.hruleItemView,
|
|
103
|
+
wysiwyg: items_1.hruleItemWysiwyg,
|
|
104
|
+
markup: items_1.hruleItemMarkup,
|
|
105
|
+
} }),
|
|
106
|
+
orders: {
|
|
107
|
+
[constants_1.ToolbarName.wysiwygMain]: [
|
|
108
|
+
[action_names_1.ActionName.undo, action_names_1.ActionName.redo],
|
|
109
|
+
[action_names_1.ActionName.bold, action_names_1.ActionName.italic],
|
|
110
|
+
[
|
|
111
|
+
{
|
|
112
|
+
id: constants_1.ListName.heading,
|
|
113
|
+
items: [
|
|
114
|
+
action_names_1.ActionName.paragraph,
|
|
115
|
+
action_names_1.ActionName.heading1,
|
|
116
|
+
action_names_1.ActionName.heading2,
|
|
117
|
+
action_names_1.ActionName.heading3,
|
|
118
|
+
action_names_1.ActionName.heading4,
|
|
119
|
+
action_names_1.ActionName.heading5,
|
|
120
|
+
action_names_1.ActionName.heading6,
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: constants_1.ListName.lists,
|
|
125
|
+
items: [
|
|
126
|
+
action_names_1.ActionName.bulletList,
|
|
127
|
+
action_names_1.ActionName.orderedList,
|
|
128
|
+
action_names_1.ActionName.sinkListItem,
|
|
129
|
+
action_names_1.ActionName.liftListItem,
|
|
130
|
+
],
|
|
131
|
+
},
|
|
132
|
+
action_names_1.ActionName.link,
|
|
133
|
+
action_names_1.ActionName.quote,
|
|
134
|
+
{
|
|
135
|
+
id: constants_1.ListName.code,
|
|
136
|
+
items: [action_names_1.ActionName.codeInline, action_names_1.ActionName.codeBlock],
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
],
|
|
140
|
+
[constants_1.ToolbarName.markupMain]: [
|
|
141
|
+
[action_names_1.ActionName.undo, action_names_1.ActionName.redo],
|
|
142
|
+
[action_names_1.ActionName.bold, action_names_1.ActionName.italic],
|
|
143
|
+
[
|
|
144
|
+
{
|
|
145
|
+
id: constants_1.ListName.heading,
|
|
146
|
+
items: [
|
|
147
|
+
action_names_1.ActionName.paragraph,
|
|
148
|
+
action_names_1.ActionName.heading1,
|
|
149
|
+
action_names_1.ActionName.heading2,
|
|
150
|
+
action_names_1.ActionName.heading3,
|
|
151
|
+
action_names_1.ActionName.heading4,
|
|
152
|
+
action_names_1.ActionName.heading5,
|
|
153
|
+
action_names_1.ActionName.heading6,
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
id: constants_1.ListName.lists,
|
|
158
|
+
items: [
|
|
159
|
+
action_names_1.ActionName.bulletList,
|
|
160
|
+
action_names_1.ActionName.orderedList,
|
|
161
|
+
action_names_1.ActionName.sinkListItem,
|
|
162
|
+
action_names_1.ActionName.liftListItem,
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
action_names_1.ActionName.link,
|
|
166
|
+
action_names_1.ActionName.quote,
|
|
167
|
+
{
|
|
168
|
+
id: constants_1.ListName.code,
|
|
169
|
+
items: [action_names_1.ActionName.codeInline, action_names_1.ActionName.codeBlock],
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
],
|
|
173
|
+
[constants_1.ToolbarName.wysiwygHidden]: [[action_names_1.ActionName.horizontalRule]],
|
|
174
|
+
[constants_1.ToolbarName.markupHidden]: [[action_names_1.ActionName.horizontalRule]],
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
exports.defaultPreset = {
|
|
178
|
+
items: Object.assign(Object.assign({}, exports.commonmark.items), { [action_names_1.ActionName.strike]: {
|
|
179
|
+
view: items_1.strikethroughItemView,
|
|
180
|
+
wysiwyg: items_1.sinkListItemWysiwyg,
|
|
181
|
+
markup: items_1.strikethroughItemMarkup,
|
|
182
|
+
} }),
|
|
183
|
+
orders: {
|
|
184
|
+
[constants_1.ToolbarName.wysiwygMain]: [
|
|
185
|
+
[action_names_1.ActionName.undo, action_names_1.ActionName.redo],
|
|
186
|
+
[action_names_1.ActionName.bold, action_names_1.ActionName.italic, action_names_1.ActionName.strike],
|
|
187
|
+
[
|
|
188
|
+
{
|
|
189
|
+
id: constants_1.ListName.heading,
|
|
190
|
+
items: [
|
|
191
|
+
action_names_1.ActionName.paragraph,
|
|
192
|
+
action_names_1.ActionName.heading1,
|
|
193
|
+
action_names_1.ActionName.heading2,
|
|
194
|
+
action_names_1.ActionName.heading3,
|
|
195
|
+
action_names_1.ActionName.heading4,
|
|
196
|
+
action_names_1.ActionName.heading5,
|
|
197
|
+
action_names_1.ActionName.heading6,
|
|
198
|
+
],
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
id: constants_1.ListName.lists,
|
|
202
|
+
items: [
|
|
203
|
+
action_names_1.ActionName.bulletList,
|
|
204
|
+
action_names_1.ActionName.orderedList,
|
|
205
|
+
action_names_1.ActionName.sinkListItem,
|
|
206
|
+
action_names_1.ActionName.liftListItem,
|
|
207
|
+
],
|
|
208
|
+
},
|
|
209
|
+
action_names_1.ActionName.link,
|
|
210
|
+
action_names_1.ActionName.quote,
|
|
211
|
+
{
|
|
212
|
+
id: constants_1.ListName.code,
|
|
213
|
+
items: [action_names_1.ActionName.codeInline, action_names_1.ActionName.codeBlock],
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
],
|
|
217
|
+
[constants_1.ToolbarName.markupMain]: [
|
|
218
|
+
[action_names_1.ActionName.undo, action_names_1.ActionName.redo],
|
|
219
|
+
[action_names_1.ActionName.bold, action_names_1.ActionName.italic, action_names_1.ActionName.strike],
|
|
220
|
+
[
|
|
221
|
+
{
|
|
222
|
+
id: constants_1.ListName.heading,
|
|
223
|
+
items: [
|
|
224
|
+
action_names_1.ActionName.paragraph,
|
|
225
|
+
action_names_1.ActionName.heading1,
|
|
226
|
+
action_names_1.ActionName.heading2,
|
|
227
|
+
action_names_1.ActionName.heading3,
|
|
228
|
+
action_names_1.ActionName.heading4,
|
|
229
|
+
action_names_1.ActionName.heading5,
|
|
230
|
+
action_names_1.ActionName.heading6,
|
|
231
|
+
],
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
id: constants_1.ListName.lists,
|
|
235
|
+
items: [
|
|
236
|
+
action_names_1.ActionName.bulletList,
|
|
237
|
+
action_names_1.ActionName.orderedList,
|
|
238
|
+
action_names_1.ActionName.sinkListItem,
|
|
239
|
+
action_names_1.ActionName.liftListItem,
|
|
240
|
+
],
|
|
241
|
+
},
|
|
242
|
+
action_names_1.ActionName.link,
|
|
243
|
+
action_names_1.ActionName.quote,
|
|
244
|
+
{
|
|
245
|
+
id: constants_1.ListName.code,
|
|
246
|
+
items: [action_names_1.ActionName.codeInline, action_names_1.ActionName.codeBlock],
|
|
247
|
+
},
|
|
248
|
+
],
|
|
249
|
+
],
|
|
250
|
+
[constants_1.ToolbarName.wysiwygHidden]: [[action_names_1.ActionName.horizontalRule]],
|
|
251
|
+
[constants_1.ToolbarName.markupHidden]: [[action_names_1.ActionName.horizontalRule]],
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
exports.yfm = {
|
|
255
|
+
items: Object.assign(Object.assign({}, exports.defaultPreset.items), { [action_names_1.ActionName.underline]: {
|
|
256
|
+
view: items_1.underlineItemView,
|
|
257
|
+
wysiwyg: items_1.underlineItemWysiwyg,
|
|
258
|
+
markup: items_1.underlineItemMarkup,
|
|
259
|
+
}, [action_names_1.ActionName.mono]: {
|
|
260
|
+
view: items_1.monospaceItemView,
|
|
261
|
+
wysiwyg: items_1.monospaceItemWysiwyg,
|
|
262
|
+
markup: items_1.monospaceItemMarkup,
|
|
263
|
+
}, [action_names_1.ActionName.note]: {
|
|
264
|
+
view: items_1.noteItemView,
|
|
265
|
+
wysiwyg: items_1.noteItemWysiwyg,
|
|
266
|
+
markup: items_1.noteItemMarkup,
|
|
267
|
+
}, [action_names_1.ActionName.cut]: {
|
|
268
|
+
view: items_1.cutItemView,
|
|
269
|
+
wysiwyg: items_1.cutItemWysiwyg,
|
|
270
|
+
markup: items_1.cutItemMarkup,
|
|
271
|
+
}, [action_names_1.ActionName.image]: {
|
|
272
|
+
view: items_1.imageItemView,
|
|
273
|
+
wysiwyg: items_1.imageItemWysiwyg,
|
|
274
|
+
}, [action_names_1.ActionName.imagePopup]: {
|
|
275
|
+
view: items_1.imagePopupItemView,
|
|
276
|
+
markup: items_1.imageItemMarkup,
|
|
277
|
+
}, [action_names_1.ActionName.file]: {
|
|
278
|
+
view: items_1.fileItemView,
|
|
279
|
+
wysiwyg: items_1.fileItemWysiwyg,
|
|
280
|
+
}, [action_names_1.ActionName.filePopup]: {
|
|
281
|
+
view: items_1.filePopupItemView,
|
|
282
|
+
markup: items_1.fileItemMarkup,
|
|
283
|
+
}, [action_names_1.ActionName.table]: {
|
|
284
|
+
view: items_1.tableItemView,
|
|
285
|
+
wysiwyg: items_1.tableItemWysiwyg,
|
|
286
|
+
markup: items_1.tableItemMarkup,
|
|
287
|
+
}, [action_names_1.ActionName.checkbox]: {
|
|
288
|
+
view: items_1.checkboxItemView,
|
|
289
|
+
wysiwyg: items_1.checkboxItemWysiwyg,
|
|
290
|
+
markup: items_1.checkboxItemMarkup,
|
|
291
|
+
}, [action_names_1.ActionName.tabs]: {
|
|
292
|
+
view: items_1.tableItemView,
|
|
293
|
+
wysiwyg: items_1.tableItemWysiwyg,
|
|
294
|
+
markup: items_1.tableItemMarkup,
|
|
295
|
+
} }),
|
|
296
|
+
orders: {
|
|
297
|
+
[constants_1.ToolbarName.wysiwygMain]: [
|
|
298
|
+
[action_names_1.ActionName.undo, action_names_1.ActionName.redo],
|
|
299
|
+
[action_names_1.ActionName.bold, action_names_1.ActionName.italic, action_names_1.ActionName.underline, action_names_1.ActionName.strike, action_names_1.ActionName.mono],
|
|
300
|
+
[
|
|
301
|
+
{
|
|
302
|
+
id: constants_1.ListName.heading,
|
|
303
|
+
items: [
|
|
304
|
+
action_names_1.ActionName.paragraph,
|
|
305
|
+
action_names_1.ActionName.heading1,
|
|
306
|
+
action_names_1.ActionName.heading2,
|
|
307
|
+
action_names_1.ActionName.heading3,
|
|
308
|
+
action_names_1.ActionName.heading4,
|
|
309
|
+
action_names_1.ActionName.heading5,
|
|
310
|
+
action_names_1.ActionName.heading6,
|
|
311
|
+
],
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
id: constants_1.ListName.lists,
|
|
315
|
+
items: [
|
|
316
|
+
action_names_1.ActionName.bulletList,
|
|
317
|
+
action_names_1.ActionName.orderedList,
|
|
318
|
+
action_names_1.ActionName.sinkListItem,
|
|
319
|
+
action_names_1.ActionName.liftListItem,
|
|
320
|
+
],
|
|
321
|
+
},
|
|
322
|
+
action_names_1.ActionName.link,
|
|
323
|
+
action_names_1.ActionName.note,
|
|
324
|
+
action_names_1.ActionName.cut,
|
|
325
|
+
action_names_1.ActionName.quote,
|
|
326
|
+
{
|
|
327
|
+
id: constants_1.ListName.code,
|
|
328
|
+
items: [action_names_1.ActionName.codeInline, action_names_1.ActionName.codeBlock],
|
|
329
|
+
},
|
|
330
|
+
],
|
|
331
|
+
[action_names_1.ActionName.image, action_names_1.ActionName.file, action_names_1.ActionName.table, action_names_1.ActionName.checkbox],
|
|
332
|
+
],
|
|
333
|
+
[constants_1.ToolbarName.markupMain]: [
|
|
334
|
+
[action_names_1.ActionName.undo, action_names_1.ActionName.redo],
|
|
335
|
+
[action_names_1.ActionName.bold, action_names_1.ActionName.italic, action_names_1.ActionName.underline, action_names_1.ActionName.strike, action_names_1.ActionName.mono],
|
|
336
|
+
[
|
|
337
|
+
{
|
|
338
|
+
id: constants_1.ListName.heading,
|
|
339
|
+
items: [
|
|
340
|
+
action_names_1.ActionName.paragraph,
|
|
341
|
+
action_names_1.ActionName.heading1,
|
|
342
|
+
action_names_1.ActionName.heading2,
|
|
343
|
+
action_names_1.ActionName.heading3,
|
|
344
|
+
action_names_1.ActionName.heading4,
|
|
345
|
+
action_names_1.ActionName.heading5,
|
|
346
|
+
action_names_1.ActionName.heading6,
|
|
347
|
+
],
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
id: constants_1.ListName.lists,
|
|
351
|
+
items: [
|
|
352
|
+
action_names_1.ActionName.bulletList,
|
|
353
|
+
action_names_1.ActionName.orderedList,
|
|
354
|
+
action_names_1.ActionName.sinkListItem,
|
|
355
|
+
action_names_1.ActionName.liftListItem,
|
|
356
|
+
],
|
|
357
|
+
},
|
|
358
|
+
action_names_1.ActionName.link,
|
|
359
|
+
action_names_1.ActionName.note,
|
|
360
|
+
action_names_1.ActionName.cut,
|
|
361
|
+
action_names_1.ActionName.quote,
|
|
362
|
+
{
|
|
363
|
+
id: constants_1.ListName.code,
|
|
364
|
+
items: [action_names_1.ActionName.codeInline, action_names_1.ActionName.codeBlock],
|
|
365
|
+
},
|
|
366
|
+
],
|
|
367
|
+
[action_names_1.ActionName.imagePopup, action_names_1.ActionName.filePopup, action_names_1.ActionName.table, action_names_1.ActionName.checkbox],
|
|
368
|
+
],
|
|
369
|
+
[constants_1.ToolbarName.wysiwygHidden]: [[action_names_1.ActionName.horizontalRule, action_names_1.ActionName.tabs]],
|
|
370
|
+
[constants_1.ToolbarName.markupHidden]: [[action_names_1.ActionName.horizontalRule, action_names_1.ActionName.tabs]],
|
|
371
|
+
},
|
|
372
|
+
};
|
|
373
|
+
exports.full = {
|
|
374
|
+
items: Object.assign(Object.assign({}, exports.yfm.items), { [action_names_1.ActionName.mark]: {
|
|
375
|
+
view: items_1.markedItemView,
|
|
376
|
+
wysiwyg: items_1.markedItemWysiwyg,
|
|
377
|
+
markup: items_1.markedItemMarkup,
|
|
378
|
+
}, [action_names_1.ActionName.colorify]: {
|
|
379
|
+
view: items_1.colorifyItemView,
|
|
380
|
+
wysiwyg: items_1.colorifyItemWysiwyg,
|
|
381
|
+
markup: items_1.colorifyItemMarkup,
|
|
382
|
+
}, [action_names_1.ActionName.emoji]: {
|
|
383
|
+
view: items_1.emojiItemView,
|
|
384
|
+
wysiwyg: items_1.emojiItemWysiwyg,
|
|
385
|
+
markup: items_1.emojiItemMarkup,
|
|
386
|
+
} }),
|
|
387
|
+
orders: {
|
|
388
|
+
[constants_1.ToolbarName.wysiwygMain]: [
|
|
389
|
+
[action_names_1.ActionName.undo, action_names_1.ActionName.redo],
|
|
390
|
+
[action_names_1.ActionName.bold, action_names_1.ActionName.italic, action_names_1.ActionName.underline, action_names_1.ActionName.strike, action_names_1.ActionName.mono, action_names_1.ActionName.mark],
|
|
391
|
+
[
|
|
392
|
+
{
|
|
393
|
+
id: constants_1.ListName.heading,
|
|
394
|
+
items: [
|
|
395
|
+
action_names_1.ActionName.paragraph,
|
|
396
|
+
action_names_1.ActionName.heading1,
|
|
397
|
+
action_names_1.ActionName.heading2,
|
|
398
|
+
action_names_1.ActionName.heading3,
|
|
399
|
+
action_names_1.ActionName.heading4,
|
|
400
|
+
action_names_1.ActionName.heading5,
|
|
401
|
+
action_names_1.ActionName.heading6,
|
|
402
|
+
],
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
id: constants_1.ListName.lists,
|
|
406
|
+
items: [
|
|
407
|
+
action_names_1.ActionName.bulletList,
|
|
408
|
+
action_names_1.ActionName.orderedList,
|
|
409
|
+
action_names_1.ActionName.sinkListItem,
|
|
410
|
+
action_names_1.ActionName.liftListItem,
|
|
411
|
+
],
|
|
412
|
+
},
|
|
413
|
+
action_names_1.ActionName.colorify,
|
|
414
|
+
action_names_1.ActionName.link,
|
|
415
|
+
action_names_1.ActionName.note,
|
|
416
|
+
action_names_1.ActionName.cut,
|
|
417
|
+
action_names_1.ActionName.quote,
|
|
418
|
+
{
|
|
419
|
+
id: constants_1.ListName.code,
|
|
420
|
+
items: [action_names_1.ActionName.codeInline, action_names_1.ActionName.codeBlock],
|
|
421
|
+
},
|
|
422
|
+
],
|
|
423
|
+
[action_names_1.ActionName.image, action_names_1.ActionName.file, action_names_1.ActionName.table, action_names_1.ActionName.checkbox],
|
|
424
|
+
],
|
|
425
|
+
[constants_1.ToolbarName.markupMain]: [
|
|
426
|
+
[action_names_1.ActionName.undo, action_names_1.ActionName.redo],
|
|
427
|
+
[action_names_1.ActionName.bold, action_names_1.ActionName.italic, action_names_1.ActionName.underline, action_names_1.ActionName.strike, action_names_1.ActionName.mono, action_names_1.ActionName.mark],
|
|
428
|
+
[
|
|
429
|
+
{
|
|
430
|
+
id: constants_1.ListName.heading,
|
|
431
|
+
items: [
|
|
432
|
+
action_names_1.ActionName.paragraph,
|
|
433
|
+
action_names_1.ActionName.heading1,
|
|
434
|
+
action_names_1.ActionName.heading2,
|
|
435
|
+
action_names_1.ActionName.heading3,
|
|
436
|
+
action_names_1.ActionName.heading4,
|
|
437
|
+
action_names_1.ActionName.heading5,
|
|
438
|
+
action_names_1.ActionName.heading6,
|
|
439
|
+
],
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
id: constants_1.ListName.lists,
|
|
443
|
+
items: [
|
|
444
|
+
action_names_1.ActionName.bulletList,
|
|
445
|
+
action_names_1.ActionName.orderedList,
|
|
446
|
+
action_names_1.ActionName.sinkListItem,
|
|
447
|
+
action_names_1.ActionName.liftListItem,
|
|
448
|
+
],
|
|
449
|
+
},
|
|
450
|
+
action_names_1.ActionName.colorify,
|
|
451
|
+
action_names_1.ActionName.link,
|
|
452
|
+
action_names_1.ActionName.note,
|
|
453
|
+
action_names_1.ActionName.cut,
|
|
454
|
+
action_names_1.ActionName.quote,
|
|
455
|
+
{
|
|
456
|
+
id: constants_1.ListName.code,
|
|
457
|
+
items: [action_names_1.ActionName.codeInline, action_names_1.ActionName.codeBlock],
|
|
458
|
+
},
|
|
459
|
+
],
|
|
460
|
+
[action_names_1.ActionName.imagePopup, action_names_1.ActionName.filePopup, action_names_1.ActionName.table, action_names_1.ActionName.checkbox],
|
|
461
|
+
],
|
|
462
|
+
[constants_1.ToolbarName.wysiwygHidden]: [[action_names_1.ActionName.horizontalRule, action_names_1.ActionName.emoji, action_names_1.ActionName.tabs]],
|
|
463
|
+
[constants_1.ToolbarName.markupHidden]: [[action_names_1.ActionName.horizontalRule, action_names_1.ActionName.emoji, action_names_1.ActionName.tabs]],
|
|
464
|
+
},
|
|
465
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
import type { HotkeyProps } from '@gravity-ui/uikit';
|
|
3
|
+
import type { EditorState } from 'prosemirror-state';
|
|
4
|
+
import type { ActionStorage } from '../../core';
|
|
5
|
+
import type { CodeEditor } from '../../markup';
|
|
6
|
+
import type { ToolbarBaseProps, ToolbarDataType, ToolbarIconData } from '../../toolbar';
|
|
7
|
+
export declare type ToolbarItemId = string & {};
|
|
8
|
+
export declare type ToolbarListId = string & {};
|
|
9
|
+
export interface ToolbarList {
|
|
10
|
+
id: ToolbarListId;
|
|
11
|
+
items: ToolbarItemId[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The default value for the `type` property is `ToolbarDataType.SingleButton`.
|
|
15
|
+
*/
|
|
16
|
+
export declare type ToolbarItemView<T extends ToolbarDataType = ToolbarDataType.SingleButton> = {
|
|
17
|
+
className?: string;
|
|
18
|
+
hint?: string | (() => string);
|
|
19
|
+
hotkey?: HotkeyProps['value'];
|
|
20
|
+
type?: ToolbarDataType;
|
|
21
|
+
doNotActivateList?: boolean;
|
|
22
|
+
} & (T extends ToolbarDataType.SingleButton ? {
|
|
23
|
+
icon: ToolbarIconData;
|
|
24
|
+
title: string | (() => string);
|
|
25
|
+
} : T extends ToolbarDataType.ListButton ? {
|
|
26
|
+
withArrow?: boolean;
|
|
27
|
+
icon: ToolbarIconData;
|
|
28
|
+
title: string | (() => string);
|
|
29
|
+
} : {});
|
|
30
|
+
export interface EditorActions<E> {
|
|
31
|
+
exec(editor: E): void;
|
|
32
|
+
isActive(editor: E): boolean;
|
|
33
|
+
isEnable(editor: E): boolean;
|
|
34
|
+
}
|
|
35
|
+
declare type ToolbarItemEditor<T, E> = Partial<EditorActions<E>> & {
|
|
36
|
+
hintWhenDisabled?: boolean | string | (() => string);
|
|
37
|
+
condition?: ((state: EditorState) => void) | 'enabled';
|
|
38
|
+
} & (T extends ToolbarDataType.ButtonPopup ? {
|
|
39
|
+
renderPopup: (props: ToolbarBaseProps<E> & {
|
|
40
|
+
hide: () => void;
|
|
41
|
+
anchorRef: RefObject<HTMLElement>;
|
|
42
|
+
}) => React.ReactNode;
|
|
43
|
+
} : T extends ToolbarDataType.ReactComponent ? {
|
|
44
|
+
width: number;
|
|
45
|
+
component: React.ComponentType<ToolbarBaseProps<E>>;
|
|
46
|
+
} : {});
|
|
47
|
+
export declare type ToolbarItemWysiwyg<T extends ToolbarDataType = ToolbarDataType.SingleButton> = ToolbarItemEditor<T, ActionStorage>;
|
|
48
|
+
export declare type ToolbarItemMarkup<T extends ToolbarDataType = ToolbarDataType.SingleButton> = ToolbarItemEditor<T, CodeEditor>;
|
|
49
|
+
export declare type ToolbarItem<T extends ToolbarDataType> = {
|
|
50
|
+
view: ToolbarItemView<T>;
|
|
51
|
+
wysiwyg?: ToolbarItemWysiwyg<T>;
|
|
52
|
+
markup?: ToolbarItemMarkup<T>;
|
|
53
|
+
};
|
|
54
|
+
export declare type ToolbarsItems = Record<ToolbarItemId, ToolbarItem<ToolbarDataType>>;
|
|
55
|
+
export declare type ToolbarId = string;
|
|
56
|
+
export declare type ToolbarOrders = (ToolbarList | ToolbarItemId)[][];
|
|
57
|
+
export declare type ToolbarsOrders = Record<ToolbarId, ToolbarOrders>;
|
|
58
|
+
export interface ToolbarsPreset {
|
|
59
|
+
items: ToolbarsItems;
|
|
60
|
+
orders: ToolbarsOrders;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
@@ -38,7 +38,9 @@ export declare enum ToolbarDataType {
|
|
|
38
38
|
SingleButton = "s-button",
|
|
39
39
|
ListButton = "list-b",
|
|
40
40
|
ButtonPopup = "b-popup",
|
|
41
|
+
/** @deprecated Use ReactComponent type instead */
|
|
41
42
|
ReactNode = "r-node",
|
|
43
|
+
/** @deprecated Use ReactComponent type instead */
|
|
42
44
|
ReactNodeFn = "r-node-fn",
|
|
43
45
|
ReactComponent = "r-component"
|
|
44
46
|
}
|
|
@@ -73,12 +75,18 @@ export declare type ToolbarButtonPopupData<E> = ToolbarItemData<E> & {
|
|
|
73
75
|
export declare type ToolbarListButtonItemData<E> = ToolbarItemData<E> & {
|
|
74
76
|
doNotActivateList?: boolean;
|
|
75
77
|
};
|
|
78
|
+
/**
|
|
79
|
+
* @deprecated Use ReactComponent type instead
|
|
80
|
+
* */
|
|
76
81
|
export declare type ToolbarReactNodeData = {
|
|
77
82
|
id: string;
|
|
78
83
|
type: ToolbarDataType.ReactNode;
|
|
79
84
|
width: number;
|
|
80
85
|
content: React.ReactNode;
|
|
81
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated Use ReactComponent type instead
|
|
89
|
+
* */
|
|
82
90
|
export declare type ToolbarReactNodeFnData<E> = {
|
|
83
91
|
id: string;
|
|
84
92
|
type: ToolbarDataType.ReactNodeFn;
|
|
@@ -6,7 +6,9 @@ var ToolbarDataType;
|
|
|
6
6
|
ToolbarDataType["SingleButton"] = "s-button";
|
|
7
7
|
ToolbarDataType["ListButton"] = "list-b";
|
|
8
8
|
ToolbarDataType["ButtonPopup"] = "b-popup";
|
|
9
|
+
/** @deprecated Use ReactComponent type instead */
|
|
9
10
|
ToolbarDataType["ReactNode"] = "r-node";
|
|
11
|
+
/** @deprecated Use ReactComponent type instead */
|
|
10
12
|
ToolbarDataType["ReactNodeFn"] = "r-node-fn";
|
|
11
13
|
ToolbarDataType["ReactComponent"] = "r-component";
|
|
12
14
|
})(ToolbarDataType = exports.ToolbarDataType || (exports.ToolbarDataType = {}));
|
package/build/cjs/version.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
/** During build process, the current version will be injected here */
|
|
5
|
-
exports.VERSION = typeof '14.
|
|
5
|
+
exports.VERSION = typeof '14.9.0' !== 'undefined' ? '14.9.0' : 'unknown';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ToasterPublicMethods } from '@gravity-ui/uikit';
|
|
3
3
|
import { ClassNameProps } from '../classname';
|
|
4
|
+
import type { ToolbarsPreset } from '../modules/toolbars/types';
|
|
4
5
|
import type { Editor } from './Editor';
|
|
5
6
|
import { MToolbarData, MToolbarItemData, WToolbarData, WToolbarItemData } from './config';
|
|
6
7
|
import '../styles/styles.css';
|
|
@@ -9,9 +10,22 @@ export declare const cnEditorComponent: import("@bem-react/classname").ClassName
|
|
|
9
10
|
export declare type MarkdownEditorViewProps = ClassNameProps & {
|
|
10
11
|
editor?: Editor;
|
|
11
12
|
autofocus?: boolean;
|
|
13
|
+
toolbarsPreset?: ToolbarsPreset;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated use `toolbarsPreset` instead
|
|
16
|
+
*/
|
|
12
17
|
markupToolbarConfig?: MToolbarData;
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated use `toolbarsPreset` instead
|
|
20
|
+
*/
|
|
13
21
|
wysiwygToolbarConfig?: WToolbarData;
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated use `toolbarsPreset` instead
|
|
24
|
+
*/
|
|
14
25
|
markupHiddenActionsConfig?: MToolbarItemData[];
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated use `toolbarsPreset` instead
|
|
28
|
+
*/
|
|
15
29
|
wysiwygHiddenActionsConfig?: WToolbarItemData[];
|
|
16
30
|
/** @default true */
|
|
17
31
|
settingsVisible?: boolean;
|
|
@@ -23,9 +37,22 @@ export declare type MarkdownEditorViewProps = ClassNameProps & {
|
|
|
23
37
|
export declare const MarkdownEditorView: React.ForwardRefExoticComponent<ClassNameProps & {
|
|
24
38
|
editor?: Editor | undefined;
|
|
25
39
|
autofocus?: boolean | undefined;
|
|
40
|
+
toolbarsPreset?: ToolbarsPreset | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated use `toolbarsPreset` instead
|
|
43
|
+
*/
|
|
26
44
|
markupToolbarConfig?: MToolbarData | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated use `toolbarsPreset` instead
|
|
47
|
+
*/
|
|
27
48
|
wysiwygToolbarConfig?: WToolbarData | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated use `toolbarsPreset` instead
|
|
51
|
+
*/
|
|
28
52
|
markupHiddenActionsConfig?: MToolbarItemData[] | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* @deprecated use `toolbarsPreset` instead
|
|
55
|
+
*/
|
|
29
56
|
wysiwygHiddenActionsConfig?: WToolbarItemData[] | undefined;
|
|
30
57
|
/** @default true */
|
|
31
58
|
settingsVisible?: boolean | undefined;
|
|
@@ -10,10 +10,10 @@ import { HorizontalDrag } from './HorizontalDrag';
|
|
|
10
10
|
import { MarkupEditorView } from './MarkupEditorView';
|
|
11
11
|
import { SplitModeView } from './SplitModeView';
|
|
12
12
|
import { WysiwygEditorView } from './WysiwygEditorView';
|
|
13
|
-
import { mHiddenDataByPreset, mToolbarConfigByPreset, wHiddenDataByPreset, wToolbarConfigByPreset, } from './config';
|
|
14
13
|
import { useMarkdownEditorContext } from './context';
|
|
15
14
|
import { EditorSettings } from './settings';
|
|
16
15
|
import { stickyCn } from './sticky';
|
|
16
|
+
import { getToolbarsConfigs } from './toolbar/utils';
|
|
17
17
|
import '../styles/styles.css';
|
|
18
18
|
import './MarkdownEditorView.css'; // eslint-disable-line import/order
|
|
19
19
|
export const cnEditorComponent = cn('editor-component');
|
|
@@ -30,7 +30,24 @@ export const MarkdownEditorView = React.forwardRef((props, ref) => {
|
|
|
30
30
|
const editor = ((_a = props.editor) !== null && _a !== void 0 ? _a : context);
|
|
31
31
|
if (!editor)
|
|
32
32
|
throw new Error('[MarkdownEditorView]: an instance of the editor must be passed through the props or context');
|
|
33
|
-
const { autofocus, className, settingsVisible = true,
|
|
33
|
+
const { autofocus, className, settingsVisible = true, toolbarsPreset, toaster, stickyToolbar, wysiwygToolbarConfig: initialWysiwygToolbarConfig, markupToolbarConfig: initialMarkupToolbarConfig, wysiwygHiddenActionsConfig: initialWysiwygHiddenActionsConfig, markupHiddenActionsConfig: initialMarkupHiddenActionsConfig, enableSubmitInPreview = true, hidePreviewAfterSubmit = false, } = props;
|
|
34
|
+
const { wysiwygToolbarConfig, markupToolbarConfig, wysiwygHiddenActionsConfig, markupHiddenActionsConfig, } = useMemo(() => getToolbarsConfigs({
|
|
35
|
+
toolbarsPreset,
|
|
36
|
+
props: {
|
|
37
|
+
wysiwygToolbarConfig: initialWysiwygToolbarConfig,
|
|
38
|
+
markupToolbarConfig: initialMarkupToolbarConfig,
|
|
39
|
+
wysiwygHiddenActionsConfig: initialWysiwygHiddenActionsConfig,
|
|
40
|
+
markupHiddenActionsConfig: initialMarkupHiddenActionsConfig,
|
|
41
|
+
},
|
|
42
|
+
preset: editor.preset,
|
|
43
|
+
}), [
|
|
44
|
+
toolbarsPreset,
|
|
45
|
+
initialWysiwygToolbarConfig,
|
|
46
|
+
initialMarkupToolbarConfig,
|
|
47
|
+
initialWysiwygHiddenActionsConfig,
|
|
48
|
+
initialMarkupHiddenActionsConfig,
|
|
49
|
+
editor.preset,
|
|
50
|
+
]);
|
|
34
51
|
const rerender = useUpdate();
|
|
35
52
|
React.useLayoutEffect(() => {
|
|
36
53
|
editor.on('rerender', rerender);
|