@ebl-vue/editor-full 1.0.8
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/.postcssrc.yml +33 -0
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +2565 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +55 -0
- package/postcss.config.js +15 -0
- package/src/components/Editor/Editor.vue +209 -0
- package/src/components/index.ts +27 -0
- package/src/constants/index.ts +1 -0
- package/src/i18n/zh-cn.ts +151 -0
- package/src/icons/index.ts +78 -0
- package/src/index.ts +11 -0
- package/src/installer.ts +22 -0
- package/src/plugins/alert/index.css +150 -0
- package/src/plugins/alert/index.ts +463 -0
- package/src/plugins/block-alignment/index.css +9 -0
- package/src/plugins/block-alignment/index.ts +116 -0
- package/src/plugins/block-alignment/readme.md +1 -0
- package/src/plugins/code/LICENSE +21 -0
- package/src/plugins/code/index.css +120 -0
- package/src/plugins/code/index.ts +530 -0
- package/src/plugins/code/utils/string.ts +34 -0
- package/src/plugins/color-picker/index.ts +138 -0
- package/src/plugins/color-picker/styles.css +27 -0
- package/src/plugins/delimiter/index.css +14 -0
- package/src/plugins/delimiter/index.ts +122 -0
- package/src/plugins/drag-drop/index.css +19 -0
- package/src/plugins/drag-drop/index.ts +151 -0
- package/src/plugins/drag-drop/readme.md +1 -0
- package/src/plugins/header/H1.ts +405 -0
- package/src/plugins/header/H2.ts +403 -0
- package/src/plugins/header/H3.ts +404 -0
- package/src/plugins/header/H4.ts +405 -0
- package/src/plugins/header/H5.ts +405 -0
- package/src/plugins/header/H6.ts +406 -0
- package/src/plugins/header/index.css +20 -0
- package/src/plugins/header/index.ts +15 -0
- package/src/plugins/header/types.d.ts +46 -0
- package/src/plugins/indent/index.css +86 -0
- package/src/plugins/indent/index.ts +697 -0
- package/src/plugins/inline-code/index.css +11 -0
- package/src/plugins/inline-code/index.ts +205 -0
- package/src/plugins/list/ListRenderer/ChecklistRenderer.ts +211 -0
- package/src/plugins/list/ListRenderer/ListRenderer.ts +73 -0
- package/src/plugins/list/ListRenderer/OrderedListRenderer.ts +123 -0
- package/src/plugins/list/ListRenderer/UnorderedListRenderer.ts +123 -0
- package/src/plugins/list/ListRenderer/index.ts +6 -0
- package/src/plugins/list/ListTabulator/index.ts +1179 -0
- package/src/plugins/list/index.ts +502 -0
- package/src/plugins/list/styles/CssPrefix.ts +4 -0
- package/src/plugins/list/styles/icons/index.ts +10 -0
- package/src/plugins/list/styles/input.css +36 -0
- package/src/plugins/list/styles/list.css +165 -0
- package/src/plugins/list/types/Elements.ts +14 -0
- package/src/plugins/list/types/ItemMeta.ts +40 -0
- package/src/plugins/list/types/ListParams.ts +102 -0
- package/src/plugins/list/types/ListRenderer.ts +6 -0
- package/src/plugins/list/types/OlCounterType.ts +63 -0
- package/src/plugins/list/types/index.ts +14 -0
- package/src/plugins/list/utils/focusItem.ts +18 -0
- package/src/plugins/list/utils/getChildItems.ts +40 -0
- package/src/plugins/list/utils/getItemChildWrapper.ts +10 -0
- package/src/plugins/list/utils/getItemContentElement.ts +10 -0
- package/src/plugins/list/utils/getSiblings.ts +52 -0
- package/src/plugins/list/utils/isLastItem.ts +9 -0
- package/src/plugins/list/utils/itemHasSublist.ts +10 -0
- package/src/plugins/list/utils/normalizeData.ts +84 -0
- package/src/plugins/list/utils/removeChildWrapperIfEmpty.ts +31 -0
- package/src/plugins/list/utils/renderToolboxInput.ts +105 -0
- package/src/plugins/list/utils/stripNumbers.ts +7 -0
- package/src/plugins/list/utils/type-guards.ts +8 -0
- package/src/plugins/list.md +15 -0
- package/src/plugins/marker/index.css +4 -0
- package/src/plugins/marker/index.ts +187 -0
- package/src/plugins/paragraph/index.css +23 -0
- package/src/plugins/paragraph/index.ts +380 -0
- package/src/plugins/paragraph/types/icons.d.ts +4 -0
- package/src/plugins/paragraph/utils/makeFragment.ts +17 -0
- package/src/plugins/quote/index.css +26 -0
- package/src/plugins/quote/index.ts +206 -0
- package/src/plugins/table/index.ts +4 -0
- package/src/plugins/table/plugin.ts +254 -0
- package/src/plugins/table/style.css +388 -0
- package/src/plugins/table/table.ts +1192 -0
- package/src/plugins/table/toolbox.ts +165 -0
- package/src/plugins/table/utils/dom.ts +128 -0
- package/src/plugins/table/utils/popover.ts +172 -0
- package/src/plugins/table/utils/throttled.ts +22 -0
- package/src/plugins/underline/index.css +3 -0
- package/src/plugins/underline/index.ts +216 -0
- package/src/plugins/undo/index.ts +509 -0
- package/src/plugins/undo/observer.ts +101 -0
- package/src/style.css +89 -0
- package/src/utils/index.ts +15 -0
- package/src/utils/install.ts +19 -0
- package/tsconfig.json +37 -0
- package/types/index.d.ts +13 -0
- package/types/plugins/index.d.ts +0 -0
- package/vite.config.ts +79 -0
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
import type { API, BlockAPI, PasteConfig, ToolboxConfig } from '@ebl-vue/editorjs';
|
|
2
|
+
import type {
|
|
3
|
+
BlockToolConstructorOptions,
|
|
4
|
+
MenuConfigItem,
|
|
5
|
+
ToolConfig
|
|
6
|
+
} from '@editorjs/editorjs/types/tools';
|
|
7
|
+
|
|
8
|
+
import { IconStartWith } from './styles/icons/index.js';
|
|
9
|
+
import type { ListConfig, ListData, ListDataStyle, ListItem, OldListData } from './types/ListParams';
|
|
10
|
+
import ListTabulator from './ListTabulator';
|
|
11
|
+
import { CheckListRenderer, OrderedListRenderer, UnorderedListRenderer } from './ListRenderer';
|
|
12
|
+
import type { ListRenderer } from './types/ListRenderer';
|
|
13
|
+
import { renderToolboxInput } from './utils/renderToolboxInput';
|
|
14
|
+
import { OlCounterIconsMap, type OlCounterType, OlCounterTypesMap } from './types/OlCounterType';
|
|
15
|
+
|
|
16
|
+
const IconListBulleted = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
17
|
+
<line x1="9" y1="7" x2="19" y2="7" stroke="black" stroke-width="2" stroke-linecap="round"/>
|
|
18
|
+
<line x1="9" y1="12" x2="19" y2="12" stroke="black" stroke-width="2" stroke-linecap="round"/>
|
|
19
|
+
<line x1="9" y1="17" x2="19" y2="17" stroke="black" stroke-width="2" stroke-linecap="round"/>
|
|
20
|
+
<path d="M5.00001 17H4.99002" stroke="black" stroke-width="2" stroke-linecap="round"/>
|
|
21
|
+
<path d="M5.00001 12H4.99002" stroke="black" stroke-width="2" stroke-linecap="round"/>
|
|
22
|
+
<path d="M5.00001 7H4.99002" stroke="black" stroke-width="2" stroke-linecap="round"/>
|
|
23
|
+
</svg>
|
|
24
|
+
`;
|
|
25
|
+
const IconListNumbered = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
26
|
+
<line x1="12" y1="7" x2="19" y2="7" stroke="black" stroke-width="2" stroke-linecap="round"/>
|
|
27
|
+
<line x1="12" y1="12" x2="19" y2="12" stroke="black" stroke-width="2" stroke-linecap="round"/>
|
|
28
|
+
<line x1="12" y1="17" x2="19" y2="17" stroke="black" stroke-width="2" stroke-linecap="round"/>
|
|
29
|
+
<path d="M7.79999 14L7.79999 7.2135C7.79999 7.12872 7.7011 7.0824 7.63597 7.13668L4.79999 9.5" stroke="black" stroke-width="2" stroke-linecap="round"/>
|
|
30
|
+
</svg>
|
|
31
|
+
`;
|
|
32
|
+
const IconChecklist = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
33
|
+
<path d="M9.2 12L11.0586 13.8586C11.1367 13.9367 11.2633 13.9367 11.3414 13.8586L14.7 10.5" stroke="black" stroke-width="2" stroke-linecap="round"/>
|
|
34
|
+
<rect x="5" y="5" width="14" height="14" rx="4" stroke="black" stroke-width="2"/>
|
|
35
|
+
</svg>
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Build styles
|
|
40
|
+
*/
|
|
41
|
+
import './styles/list.css';
|
|
42
|
+
import './styles/input.css';
|
|
43
|
+
import stripNumbers from './utils/stripNumbers';
|
|
44
|
+
import normalizeData from './utils/normalizeData';
|
|
45
|
+
import type { PasteEvent } from './types';
|
|
46
|
+
import type { OrderedListItemMeta } from './types/ItemMeta';
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Constructor Params for Editorjs List Tool, use to pass initial data and settings
|
|
50
|
+
*/
|
|
51
|
+
export type ListParams = BlockToolConstructorOptions<ListData | OldListData, ListConfig>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Default class of the component used in editor
|
|
55
|
+
*/
|
|
56
|
+
export default class EditorjsList {
|
|
57
|
+
/**
|
|
58
|
+
* Notify core that read-only mode is supported
|
|
59
|
+
*/
|
|
60
|
+
public static get isReadOnlySupported(): boolean {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Allow to use native Enter behaviour
|
|
66
|
+
*/
|
|
67
|
+
public static get enableLineBreaks(): boolean {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get Tool toolbox settings
|
|
73
|
+
* icon - Tool icon's SVG
|
|
74
|
+
* title - title to show in toolbox
|
|
75
|
+
*/
|
|
76
|
+
public static get toolbox(): ToolboxConfig {
|
|
77
|
+
return [
|
|
78
|
+
{
|
|
79
|
+
icon: IconListBulleted,
|
|
80
|
+
title: 'Unordered List',
|
|
81
|
+
data: {
|
|
82
|
+
style: 'unordered',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
icon: IconListNumbered,
|
|
87
|
+
title: 'Ordered List',
|
|
88
|
+
data: {
|
|
89
|
+
style: 'ordered',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
icon: IconChecklist,
|
|
94
|
+
title: 'Checklist',
|
|
95
|
+
data: {
|
|
96
|
+
style: 'checklist',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* On paste sanitzation config. Allow only tags that are allowed in the Tool.
|
|
104
|
+
* @returns - paste config object used in editor
|
|
105
|
+
*/
|
|
106
|
+
public static get pasteConfig(): PasteConfig {
|
|
107
|
+
return {
|
|
108
|
+
tags: ['OL', 'UL', 'LI'],
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Convert from text to list with import and export list to text
|
|
114
|
+
*/
|
|
115
|
+
public static get conversionConfig(): {
|
|
116
|
+
/**
|
|
117
|
+
* Method that is responsible for conversion from data to string
|
|
118
|
+
* @param data - current list data
|
|
119
|
+
* @returns - contents string formed from list data
|
|
120
|
+
*/
|
|
121
|
+
export: (data: ListData) => string;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Method that is responsible for conversion from string to data
|
|
125
|
+
* @param content - contents string
|
|
126
|
+
* @returns - list data formed from contents string
|
|
127
|
+
*/
|
|
128
|
+
import: (content: string, config: ToolConfig<ListConfig>) => ListData;
|
|
129
|
+
} {
|
|
130
|
+
return {
|
|
131
|
+
export: (data) => {
|
|
132
|
+
return EditorjsList.joinRecursive(data);
|
|
133
|
+
},
|
|
134
|
+
import: (content, config) => {
|
|
135
|
+
return {
|
|
136
|
+
meta: {},
|
|
137
|
+
items: [
|
|
138
|
+
{
|
|
139
|
+
content,
|
|
140
|
+
meta: {},
|
|
141
|
+
items: [],
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
style: config?.defaultStyle !== undefined ? config.defaultStyle : 'unordered',
|
|
145
|
+
};
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Get list style name
|
|
152
|
+
*/
|
|
153
|
+
private get listStyle(): ListDataStyle {
|
|
154
|
+
return this.data.style || this.defaultListStyle;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Set list style
|
|
159
|
+
* @param style - new style to set
|
|
160
|
+
*/
|
|
161
|
+
private set listStyle(style: ListDataStyle) {
|
|
162
|
+
this.data.style = style;
|
|
163
|
+
|
|
164
|
+
this.changeTabulatorByStyle();
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Create new list element
|
|
168
|
+
*/
|
|
169
|
+
const newListElement = this.list!.render();
|
|
170
|
+
|
|
171
|
+
this.listElement?.replaceWith(newListElement);
|
|
172
|
+
|
|
173
|
+
this.listElement = newListElement;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* The Editor.js API
|
|
178
|
+
*/
|
|
179
|
+
private api: API;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Is Ediotrjs List Tool read-only
|
|
183
|
+
*/
|
|
184
|
+
private readOnly: boolean;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Tool's configuration
|
|
188
|
+
*/
|
|
189
|
+
private config: ListConfig | undefined;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Default list style formes as passed default list style from config or 'ordered' as default
|
|
193
|
+
*/
|
|
194
|
+
private defaultListStyle?: ListConfig['defaultStyle'];
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Default Counter type of the ordered list
|
|
198
|
+
*/
|
|
199
|
+
private defaultCounterTypes: OlCounterType[];
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Tool's data
|
|
203
|
+
*/
|
|
204
|
+
private data: ListData;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Editor block api
|
|
208
|
+
*/
|
|
209
|
+
private block: BlockAPI;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Class that is responsible for complete list rendering and saving
|
|
213
|
+
*/
|
|
214
|
+
private list: ListTabulator<ListRenderer> | undefined;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Main constant wrapper of the whole list
|
|
218
|
+
*/
|
|
219
|
+
private listElement: HTMLElement | undefined;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Render plugin`s main Element and fill it with saved data
|
|
223
|
+
* @param params - tool constructor options
|
|
224
|
+
* @param params.data - previously saved data
|
|
225
|
+
* @param params.config - user config for Tool
|
|
226
|
+
* @param params.api - Editor.js API
|
|
227
|
+
* @param params.readOnly - read-only mode flag
|
|
228
|
+
*/
|
|
229
|
+
constructor({ data, config, api, readOnly, block }: ListParams) {
|
|
230
|
+
this.api = api;
|
|
231
|
+
this.readOnly = readOnly;
|
|
232
|
+
this.config = config;
|
|
233
|
+
this.block = block;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Set the default list style from the config or presetted 'unordered'.
|
|
237
|
+
*/
|
|
238
|
+
this.defaultListStyle = this.config?.defaultStyle || 'unordered';
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Set the default counter types for the ordered list
|
|
242
|
+
*/
|
|
243
|
+
this.defaultCounterTypes = (this.config as ListConfig).counterTypes || Array.from(OlCounterTypesMap.values()) as OlCounterType[];
|
|
244
|
+
|
|
245
|
+
const initialData = {
|
|
246
|
+
style: this.defaultListStyle,
|
|
247
|
+
meta: {},
|
|
248
|
+
items: [],
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
this.data = Object.keys(data).length ? normalizeData(data) : initialData;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Assign default value of the property for the ordered list
|
|
255
|
+
*/
|
|
256
|
+
if (this.listStyle === 'ordered' && (this.data.meta as OrderedListItemMeta).counterType === undefined) {
|
|
257
|
+
(this.data.meta as OrderedListItemMeta).counterType = 'numeric';
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
this.changeTabulatorByStyle();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Convert from list to text for conversionConfig
|
|
265
|
+
* @param data - current data of the list
|
|
266
|
+
* @returns - string of the recursively merged contents of the items of the list
|
|
267
|
+
*/
|
|
268
|
+
private static joinRecursive(data: ListData | ListItem): string {
|
|
269
|
+
return data.items
|
|
270
|
+
.map(item => `${item.content} ${EditorjsList.joinRecursive(item)}`)
|
|
271
|
+
.join('');
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Function that is responsible for content rendering
|
|
276
|
+
* @returns rendered list wrapper with all contents
|
|
277
|
+
*/
|
|
278
|
+
public render(): HTMLElement {
|
|
279
|
+
this.listElement = this.list!.render();
|
|
280
|
+
|
|
281
|
+
return this.listElement;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Function that is responsible for content saving
|
|
286
|
+
* @returns formatted content used in editor
|
|
287
|
+
*/
|
|
288
|
+
public save(): ListData {
|
|
289
|
+
this.data = this.list!.save();
|
|
290
|
+
|
|
291
|
+
return this.data;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Function that is responsible for mergind two lists into one
|
|
296
|
+
* @param data - data of the next standing list, that should be merged with current
|
|
297
|
+
*/
|
|
298
|
+
public merge(data: ListData): void {
|
|
299
|
+
this.list!.merge(data);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Creates Block Tune allowing to change the list style
|
|
304
|
+
* @returns array of tune configs
|
|
305
|
+
*/
|
|
306
|
+
// public renderSettings(): MenuConfigItem[] {
|
|
307
|
+
// const defaultTunes: MenuConfigItem[] = [
|
|
308
|
+
// {
|
|
309
|
+
// label: this.api.i18n.t('Unordered'),
|
|
310
|
+
// icon: IconListBulleted,
|
|
311
|
+
// closeOnActivate: true,
|
|
312
|
+
// isActive: this.listStyle == 'unordered',
|
|
313
|
+
// onActivate: () => {
|
|
314
|
+
// this.listStyle = 'unordered';
|
|
315
|
+
// },
|
|
316
|
+
// },
|
|
317
|
+
// {
|
|
318
|
+
// label: this.api.i18n.t('Ordered'),
|
|
319
|
+
// icon: IconListNumbered,
|
|
320
|
+
// closeOnActivate: true,
|
|
321
|
+
// isActive: this.listStyle == 'ordered',
|
|
322
|
+
// onActivate: () => {
|
|
323
|
+
// this.listStyle = 'ordered';
|
|
324
|
+
// },
|
|
325
|
+
// },
|
|
326
|
+
// {
|
|
327
|
+
// label: this.api.i18n.t('Checklist'),
|
|
328
|
+
// icon: IconChecklist,
|
|
329
|
+
// closeOnActivate: true,
|
|
330
|
+
// isActive: this.listStyle == 'checklist',
|
|
331
|
+
// onActivate: () => {
|
|
332
|
+
// this.listStyle = 'checklist';
|
|
333
|
+
// },
|
|
334
|
+
// },
|
|
335
|
+
// ];
|
|
336
|
+
|
|
337
|
+
// if (this.listStyle === 'ordered') {
|
|
338
|
+
// const startWithElement = renderToolboxInput(
|
|
339
|
+
// (index: string) => this.changeStartWith(Number(index)),
|
|
340
|
+
// {
|
|
341
|
+
// value: String((this.data.meta as OrderedListItemMeta).start ?? 1),
|
|
342
|
+
// placeholder: '',
|
|
343
|
+
// attributes: {
|
|
344
|
+
// required: 'true',
|
|
345
|
+
// },
|
|
346
|
+
// sanitize: input => stripNumbers(input),
|
|
347
|
+
// });
|
|
348
|
+
|
|
349
|
+
// const orderedListTunes: MenuConfigItem[] = [
|
|
350
|
+
// {
|
|
351
|
+
// label: this.api.i18n.t('Start with'),
|
|
352
|
+
// icon: IconStartWith,
|
|
353
|
+
// children: {
|
|
354
|
+
// items: [
|
|
355
|
+
// {
|
|
356
|
+
// element: startWithElement,
|
|
357
|
+
// // @ts-expect-error ts(2820) can not use PopoverItem enum from editor.js types
|
|
358
|
+
// type: 'html',
|
|
359
|
+
// },
|
|
360
|
+
// ],
|
|
361
|
+
// },
|
|
362
|
+
// },
|
|
363
|
+
// ];
|
|
364
|
+
|
|
365
|
+
// const orderedListCountersTunes: MenuConfigItem = {
|
|
366
|
+
// label: this.api.i18n.t('Counter type'),
|
|
367
|
+
// icon: OlCounterIconsMap.get((this.data.meta as OrderedListItemMeta).counterType!),
|
|
368
|
+
// children: {
|
|
369
|
+
// items: [],
|
|
370
|
+
// },
|
|
371
|
+
// };
|
|
372
|
+
|
|
373
|
+
// /**
|
|
374
|
+
// * For each counter type in OlCounterType create toolbox item
|
|
375
|
+
// */
|
|
376
|
+
// OlCounterTypesMap.forEach((_, counterType: string) => {
|
|
377
|
+
// const counterTypeValue = OlCounterTypesMap.get(counterType)! as OlCounterType;
|
|
378
|
+
|
|
379
|
+
// if (!this.defaultCounterTypes.includes(counterTypeValue)) {
|
|
380
|
+
// return;
|
|
381
|
+
// }
|
|
382
|
+
|
|
383
|
+
// orderedListCountersTunes.children.items!.push({
|
|
384
|
+
// title: this.api.i18n.t(counterType),
|
|
385
|
+
// icon: OlCounterIconsMap.get(counterTypeValue),
|
|
386
|
+
// isActive: (this.data.meta as OrderedListItemMeta).counterType === OlCounterTypesMap.get(counterType),
|
|
387
|
+
// closeOnActivate: true,
|
|
388
|
+
// onActivate: () => {
|
|
389
|
+
// this.changeCounters(OlCounterTypesMap.get(counterType) as OlCounterType);
|
|
390
|
+
// },
|
|
391
|
+
// });
|
|
392
|
+
// });
|
|
393
|
+
|
|
394
|
+
// /**
|
|
395
|
+
// * Dont show Counter type tune if there is no valid counter types
|
|
396
|
+
// */
|
|
397
|
+
// if (orderedListCountersTunes.children.items!.length > 1) {
|
|
398
|
+
// orderedListTunes.push(orderedListCountersTunes);
|
|
399
|
+
// }
|
|
400
|
+
|
|
401
|
+
// // @ts-expect-error ts(2820) can not use PopoverItem enum from editor.js types
|
|
402
|
+
// defaultTunes.push({ type: 'separator' }, ...orderedListTunes);
|
|
403
|
+
// }
|
|
404
|
+
|
|
405
|
+
// return defaultTunes;
|
|
406
|
+
// }
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* On paste callback that is fired from Editor.
|
|
410
|
+
* @param event - event with pasted data
|
|
411
|
+
*/
|
|
412
|
+
public onPaste(event: PasteEvent): void {
|
|
413
|
+
const { tagName: tag } = event.detail.data;
|
|
414
|
+
|
|
415
|
+
switch (tag) {
|
|
416
|
+
case 'OL':
|
|
417
|
+
this.listStyle = 'ordered';
|
|
418
|
+
break;
|
|
419
|
+
case 'UL':
|
|
420
|
+
case 'LI':
|
|
421
|
+
this.listStyle = 'unordered';
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
this.list!.onPaste(event);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Handle UL, OL and LI tags paste and returns List data
|
|
429
|
+
* @param element - html element that contains whole list
|
|
430
|
+
*/
|
|
431
|
+
public pasteHandler(element: PasteEvent['detail']['data']): ListData {
|
|
432
|
+
const data = this.list!.pasteHandler(element);
|
|
433
|
+
|
|
434
|
+
return data;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Changes ordered list counterType property value
|
|
439
|
+
* @param counterType - new value of the counterType value
|
|
440
|
+
*/
|
|
441
|
+
private changeCounters(counterType: OlCounterType): void {
|
|
442
|
+
this.list?.changeCounters(counterType);
|
|
443
|
+
|
|
444
|
+
(this.data.meta as OrderedListItemMeta).counterType = counterType;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Changes ordered list start property value
|
|
449
|
+
* @param index - new value of the start property
|
|
450
|
+
*/
|
|
451
|
+
private changeStartWith(index: number): void {
|
|
452
|
+
this.list?.changeStartWith(index);
|
|
453
|
+
|
|
454
|
+
(this.data.meta as OrderedListItemMeta).start = index;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* This method allows changing tabulator respectfully to passed style
|
|
459
|
+
*/
|
|
460
|
+
private changeTabulatorByStyle(): void {
|
|
461
|
+
switch (this.listStyle) {
|
|
462
|
+
case 'ordered':
|
|
463
|
+
this.list = new ListTabulator<OrderedListRenderer>({
|
|
464
|
+
data: this.data,
|
|
465
|
+
readOnly: this.readOnly,
|
|
466
|
+
api: this.api,
|
|
467
|
+
config: this.config,
|
|
468
|
+
block: this.block,
|
|
469
|
+
},
|
|
470
|
+
new OrderedListRenderer(this.readOnly, this.config)
|
|
471
|
+
);
|
|
472
|
+
|
|
473
|
+
break;
|
|
474
|
+
|
|
475
|
+
case 'unordered':
|
|
476
|
+
this.list = new ListTabulator<UnorderedListRenderer>({
|
|
477
|
+
data: this.data,
|
|
478
|
+
readOnly: this.readOnly,
|
|
479
|
+
api: this.api,
|
|
480
|
+
config: this.config,
|
|
481
|
+
block: this.block,
|
|
482
|
+
},
|
|
483
|
+
new UnorderedListRenderer(this.readOnly, this.config)
|
|
484
|
+
);
|
|
485
|
+
|
|
486
|
+
break;
|
|
487
|
+
|
|
488
|
+
case 'checklist':
|
|
489
|
+
this.list = new ListTabulator<CheckListRenderer>({
|
|
490
|
+
data: this.data,
|
|
491
|
+
readOnly: this.readOnly,
|
|
492
|
+
api: this.api,
|
|
493
|
+
config: this.config,
|
|
494
|
+
block: this.block,
|
|
495
|
+
},
|
|
496
|
+
new CheckListRenderer(this.readOnly, this.config)
|
|
497
|
+
);
|
|
498
|
+
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file exports icons needed for Editorjs List plugin, but this icons are not released yet
|
|
3
|
+
* @todo remove this file and use icons from codex-team/icons package, when version with this icons will be released
|
|
4
|
+
*/
|
|
5
|
+
export const IconNumber = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10 14.2L10 7.4135C10 7.32872 9.90111 7.28241 9.83598 7.33668L7 9.7" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M13.2087 14.2H13.2" stroke="black" stroke-width="1.6" stroke-linecap="round"/></svg>';
|
|
6
|
+
export const IconLowerRoman = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13.2087 14.2H13.2" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M10 14.2L10 9.5" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M10 7.01L10 7" stroke="black" stroke-width="1.8" stroke-linecap="round"/></svg>';
|
|
7
|
+
export const IconUpperRoman = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13.2087 14.2H13.2" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M10 14.2L10 7.2" stroke="black" stroke-width="1.6" stroke-linecap="round"/></svg>';
|
|
8
|
+
export const IconUpperAlpha = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M16.0087 14.2H16" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M7 14.2L7.78865 12M13 14.2L12.1377 12M7.78865 12C7.78865 12 9.68362 7 10 7C10.3065 7 12.1377 12 12.1377 12M7.78865 12L12.1377 12" stroke="black" stroke-width="1.6" stroke-linecap="round"/></svg>';
|
|
9
|
+
export const IconLowerAlpha = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14.2087 14.2H14.2" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M11.5 14.5C11.5 14.5 11 13.281 11 12.5M7 9.5C7 9.5 7.5 8.5 9 8.5C10.5 8.5 11 9.5 11 10.5L11 11.5M11 11.5L11 12.5M11 11.5C11 11.5 7 11 7 13C7 15.3031 11 15 11 12.5" stroke="black" stroke-width="1.6" stroke-linecap="round"/></svg>';
|
|
10
|
+
export const IconStartWith = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8 14.2L8 7.4135C8 7.32872 7.90111 7.28241 7.83598 7.33668L5 9.7" stroke="black" stroke-width="1.6" stroke-linecap="round"/><path d="M14 13L16.4167 10.7778M16.4167 10.7778L14 8.5M16.4167 10.7778H11.6562" stroke="black" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
.cdx-list-start-with-field {
|
|
2
|
+
background: #F8F8F8;
|
|
3
|
+
border: 1px solid rgba(226,226,229,0.20);
|
|
4
|
+
border-radius: 6px;
|
|
5
|
+
padding: 2px;
|
|
6
|
+
display: grid;
|
|
7
|
+
grid-template-columns: auto auto 1fr;
|
|
8
|
+
grid-template-rows: auto;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.cdx-list-start-with-field--invalid {
|
|
12
|
+
background: #FFECED;
|
|
13
|
+
border: 1px solid #E13F3F;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.cdx-list-start-with-field--invalid .cdx-list-start-with-field__input {
|
|
17
|
+
color: #E13F3F;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.cdx-list-start-with-field__input {
|
|
21
|
+
font-size: 14px;
|
|
22
|
+
outline: none;
|
|
23
|
+
font-weight: 500;
|
|
24
|
+
font-family: inherit;
|
|
25
|
+
border: 0;
|
|
26
|
+
background: transparent;
|
|
27
|
+
margin: 0;
|
|
28
|
+
padding: 0;
|
|
29
|
+
line-height: 22px;
|
|
30
|
+
min-width: calc(100% - var(--toolbox-buttons-size) - var(--icon-margin-right));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.cdx-list-start-with-field__input::placeholder {
|
|
34
|
+
color: var(--grayText);
|
|
35
|
+
font-weight: 500;
|
|
36
|
+
}
|