@ebl-vue/editor-full 2.31.11 → 2.31.12
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/dist/index.mjs +360 -319
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/Editor/Editor.vue +22 -6
- package/src/plugins/list/ListRenderer/ChecklistRenderer.ts +1 -1
- package/src/plugins/list/ListTabulator/index.ts +1 -1
- package/src/plugins/list/index.ts +118 -123
- package/src/plugins/list/styles/.cdx-list .css +168 -0
- package/src/plugins/list/utils/normalizeData.ts +0 -1
- package/src/plugins/list-bak/ListRenderer/ChecklistRenderer.ts +208 -0
- package/src/plugins/list-bak/ListRenderer/ListRenderer.ts +73 -0
- package/src/plugins/list-bak/ListRenderer/OrderedListRenderer.ts +123 -0
- package/src/plugins/list-bak/ListRenderer/UnorderedListRenderer.ts +123 -0
- package/src/plugins/list-bak/ListRenderer/index.ts +6 -0
- package/src/plugins/list-bak/ListTabulator/index.ts +1179 -0
- package/src/plugins/list-bak/index.ts +485 -0
- package/src/plugins/list-bak/styles/CssPrefix.ts +4 -0
- package/src/plugins/list-bak/styles/input.css +36 -0
- package/src/plugins/list-bak/styles/list.css +165 -0
- package/src/plugins/list-bak/types/Elements.ts +14 -0
- package/src/plugins/list-bak/types/ItemMeta.ts +40 -0
- package/src/plugins/list-bak/types/ListParams.ts +102 -0
- package/src/plugins/list-bak/types/ListRenderer.ts +6 -0
- package/src/plugins/list-bak/types/OlCounterType.ts +63 -0
- package/src/plugins/list-bak/types/index.ts +14 -0
- package/src/plugins/list-bak/utils/focusItem.ts +18 -0
- package/src/plugins/list-bak/utils/getChildItems.ts +40 -0
- package/src/plugins/list-bak/utils/getItemChildWrapper.ts +10 -0
- package/src/plugins/list-bak/utils/getItemContentElement.ts +10 -0
- package/src/plugins/list-bak/utils/getSiblings.ts +52 -0
- package/src/plugins/list-bak/utils/isLastItem.ts +9 -0
- package/src/plugins/list-bak/utils/itemHasSublist.ts +10 -0
- package/src/plugins/list-bak/utils/normalizeData.ts +84 -0
- package/src/plugins/list-bak/utils/removeChildWrapperIfEmpty.ts +31 -0
- package/src/plugins/list-bak/utils/renderToolboxInput.ts +105 -0
- package/src/plugins/list-bak/utils/stripNumbers.ts +7 -0
- package/src/plugins/list-bak/utils/type-guards.ts +8 -0
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
import type { API, BlockAPI, PasteConfig, ToolboxConfig } from '@ebl-vue/editorjs';
|
|
2
|
+
import type {
|
|
3
|
+
BlockToolConstructorOptions,
|
|
4
|
+
|
|
5
|
+
ToolConfig
|
|
6
|
+
} from '@editorjs/editorjs/types/tools';
|
|
7
|
+
|
|
8
|
+
|
|
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
|
+
|
|
14
|
+
import { type OlCounterType, OlCounterTypesMap } from './types/OlCounterType';
|
|
15
|
+
|
|
16
|
+
import { IconListBulleted, IconListNumbered, IconChecklist } from "../../icons";
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Build styles
|
|
22
|
+
*/
|
|
23
|
+
import './styles/list.css';
|
|
24
|
+
import './styles/input.css';
|
|
25
|
+
|
|
26
|
+
import normalizeData from './utils/normalizeData';
|
|
27
|
+
import type { PasteEvent } from './types';
|
|
28
|
+
import type { OrderedListItemMeta } from './types/ItemMeta';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Constructor Params for Editorjs List Tool, use to pass initial data and settings
|
|
32
|
+
*/
|
|
33
|
+
export type ListParams = BlockToolConstructorOptions<ListData | OldListData, ListConfig>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Default class of the component used in editor
|
|
37
|
+
*/
|
|
38
|
+
export default class EditorjsList {
|
|
39
|
+
defaultCounterTypes: OlCounterType[];
|
|
40
|
+
/**
|
|
41
|
+
* Notify core that read-only mode is supported
|
|
42
|
+
*/
|
|
43
|
+
public static get isReadOnlySupported(): boolean {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Allow to use native Enter behaviour
|
|
49
|
+
*/
|
|
50
|
+
public static get enableLineBreaks(): boolean {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Get Tool toolbox settings
|
|
56
|
+
* icon - Tool icon's SVG
|
|
57
|
+
* title - title to show in toolbox
|
|
58
|
+
*/
|
|
59
|
+
public static get toolbox(): ToolboxConfig {
|
|
60
|
+
return [
|
|
61
|
+
{
|
|
62
|
+
icon: IconListBulleted,
|
|
63
|
+
title: 'Unordered List',
|
|
64
|
+
data: {
|
|
65
|
+
style: 'unordered',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
icon: IconListNumbered,
|
|
70
|
+
title: 'Ordered List',
|
|
71
|
+
data: {
|
|
72
|
+
style: 'ordered',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
icon: IconChecklist,
|
|
77
|
+
title: 'Checklist',
|
|
78
|
+
data: {
|
|
79
|
+
style: 'checklist',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* On paste sanitzation config. Allow only tags that are allowed in the Tool.
|
|
87
|
+
* @returns - paste config object used in editor
|
|
88
|
+
*/
|
|
89
|
+
public static get pasteConfig(): PasteConfig {
|
|
90
|
+
return {
|
|
91
|
+
tags: ['OL', 'UL', 'LI'],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Convert from text to list with import and export list to text
|
|
97
|
+
*/
|
|
98
|
+
public static get conversionConfig(): {
|
|
99
|
+
/**
|
|
100
|
+
* Method that is responsible for conversion from data to string
|
|
101
|
+
* @param data - current list data
|
|
102
|
+
* @returns - contents string formed from list data
|
|
103
|
+
*/
|
|
104
|
+
export: (data: ListData) => string;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Method that is responsible for conversion from string to data
|
|
108
|
+
* @param content - contents string
|
|
109
|
+
* @returns - list data formed from contents string
|
|
110
|
+
*/
|
|
111
|
+
import: (content: string, config: ToolConfig<ListConfig>) => ListData;
|
|
112
|
+
} {
|
|
113
|
+
return {
|
|
114
|
+
export: (data) => {
|
|
115
|
+
return EditorjsList.joinRecursive(data);
|
|
116
|
+
},
|
|
117
|
+
import: (content, config) => {
|
|
118
|
+
return {
|
|
119
|
+
meta: {},
|
|
120
|
+
items: [
|
|
121
|
+
{
|
|
122
|
+
content,
|
|
123
|
+
meta: {},
|
|
124
|
+
items: [],
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
style: config?.defaultStyle !== undefined ? config.defaultStyle : 'unordered',
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Get list style name
|
|
135
|
+
*/
|
|
136
|
+
private get listStyle(): ListDataStyle {
|
|
137
|
+
return this.data.style || this.defaultListStyle;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Set list style
|
|
142
|
+
* @param style - new style to set
|
|
143
|
+
*/
|
|
144
|
+
private set listStyle(style: ListDataStyle) {
|
|
145
|
+
this.data.style = style;
|
|
146
|
+
|
|
147
|
+
this.changeTabulatorByStyle();
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Create new list element
|
|
151
|
+
*/
|
|
152
|
+
const newListElement = this.list!.render();
|
|
153
|
+
|
|
154
|
+
this.listElement?.replaceWith(newListElement);
|
|
155
|
+
|
|
156
|
+
this.listElement = newListElement;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The Editor.js API
|
|
161
|
+
*/
|
|
162
|
+
private api: API;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Is Ediotrjs List Tool read-only
|
|
166
|
+
*/
|
|
167
|
+
private readOnly: boolean;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Tool's configuration
|
|
171
|
+
*/
|
|
172
|
+
private config: ListConfig | undefined;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Default list style formes as passed default list style from config or 'ordered' as default
|
|
176
|
+
*/
|
|
177
|
+
private defaultListStyle?: ListConfig['defaultStyle'];
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Default Counter type of the ordered list
|
|
181
|
+
*/
|
|
182
|
+
//private defaultCounterTypes: OlCounterType[];
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Tool's data
|
|
186
|
+
*/
|
|
187
|
+
private data: ListData;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Editor block api
|
|
191
|
+
*/
|
|
192
|
+
private block: BlockAPI;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Class that is responsible for complete list rendering and saving
|
|
196
|
+
*/
|
|
197
|
+
private list: ListTabulator<ListRenderer> | undefined;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Main constant wrapper of the whole list
|
|
201
|
+
*/
|
|
202
|
+
private listElement: HTMLElement | undefined;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Render plugin`s main Element and fill it with saved data
|
|
206
|
+
* @param params - tool constructor options
|
|
207
|
+
* @param params.data - previously saved data
|
|
208
|
+
* @param params.config - user config for Tool
|
|
209
|
+
* @param params.api - Editor.js API
|
|
210
|
+
* @param params.readOnly - read-only mode flag
|
|
211
|
+
*/
|
|
212
|
+
constructor({ data, config, api, readOnly, block }: ListParams) {
|
|
213
|
+
this.api = api;
|
|
214
|
+
this.readOnly = readOnly;
|
|
215
|
+
this.config = config;
|
|
216
|
+
this.block = block;
|
|
217
|
+
debugger
|
|
218
|
+
/**
|
|
219
|
+
* Set the default list style from the config or presetted 'unordered'.
|
|
220
|
+
*/
|
|
221
|
+
this.defaultListStyle = this.config?.defaultStyle || 'unordered';
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Set the default counter types for the ordered list
|
|
225
|
+
*/
|
|
226
|
+
this.defaultCounterTypes = (this.config as ListConfig).counterTypes || Array.from(OlCounterTypesMap.values()) as OlCounterType[];
|
|
227
|
+
|
|
228
|
+
const initialData = {
|
|
229
|
+
style: this.defaultListStyle,
|
|
230
|
+
meta: {},
|
|
231
|
+
items: [],
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
this.data = Object.keys(data).length ? normalizeData(data) : initialData;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Assign default value of the property for the ordered list
|
|
238
|
+
*/
|
|
239
|
+
if (this.listStyle === 'ordered' && (this.data.meta as OrderedListItemMeta).counterType === undefined) {
|
|
240
|
+
(this.data.meta as OrderedListItemMeta).counterType = 'numeric';
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
this.changeTabulatorByStyle();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Convert from list to text for conversionConfig
|
|
248
|
+
* @param data - current data of the list
|
|
249
|
+
* @returns - string of the recursively merged contents of the items of the list
|
|
250
|
+
*/
|
|
251
|
+
private static joinRecursive(data: ListData | ListItem): string {
|
|
252
|
+
return data.items
|
|
253
|
+
.map(item => `${item.content} ${EditorjsList.joinRecursive(item)}`)
|
|
254
|
+
.join('');
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Function that is responsible for content rendering
|
|
259
|
+
* @returns rendered list wrapper with all contents
|
|
260
|
+
*/
|
|
261
|
+
public render(): HTMLElement {
|
|
262
|
+
this.listElement = this.list!.render();
|
|
263
|
+
|
|
264
|
+
return this.listElement;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Function that is responsible for content saving
|
|
269
|
+
* @returns formatted content used in editor
|
|
270
|
+
*/
|
|
271
|
+
public save(): ListData {
|
|
272
|
+
this.data = this.list!.save();
|
|
273
|
+
|
|
274
|
+
return this.data;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Function that is responsible for mergind two lists into one
|
|
279
|
+
* @param data - data of the next standing list, that should be merged with current
|
|
280
|
+
*/
|
|
281
|
+
public merge(data: ListData): void {
|
|
282
|
+
this.list!.merge(data);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Creates Block Tune allowing to change the list style
|
|
287
|
+
* @returns array of tune configs
|
|
288
|
+
*/
|
|
289
|
+
// public renderSettings(): MenuConfigItem[] {
|
|
290
|
+
// const defaultTunes: MenuConfigItem[] = [
|
|
291
|
+
// {
|
|
292
|
+
// label: this.api.i18n.t('Unordered'),
|
|
293
|
+
// icon: IconListBulleted,
|
|
294
|
+
// closeOnActivate: true,
|
|
295
|
+
// isActive: this.listStyle == 'unordered',
|
|
296
|
+
// onActivate: () => {
|
|
297
|
+
// this.listStyle = 'unordered';
|
|
298
|
+
// },
|
|
299
|
+
// },
|
|
300
|
+
// {
|
|
301
|
+
// label: this.api.i18n.t('Ordered'),
|
|
302
|
+
// icon: IconListNumbered,
|
|
303
|
+
// closeOnActivate: true,
|
|
304
|
+
// isActive: this.listStyle == 'ordered',
|
|
305
|
+
// onActivate: () => {
|
|
306
|
+
// this.listStyle = 'ordered';
|
|
307
|
+
// },
|
|
308
|
+
// },
|
|
309
|
+
// {
|
|
310
|
+
// label: this.api.i18n.t('Checklist'),
|
|
311
|
+
// icon: IconChecklist,
|
|
312
|
+
// closeOnActivate: true,
|
|
313
|
+
// isActive: this.listStyle == 'checklist',
|
|
314
|
+
// onActivate: () => {
|
|
315
|
+
// this.listStyle = 'checklist';
|
|
316
|
+
// },
|
|
317
|
+
// },
|
|
318
|
+
// ];
|
|
319
|
+
|
|
320
|
+
// if (this.listStyle === 'ordered') {
|
|
321
|
+
// const startWithElement = renderToolboxInput(
|
|
322
|
+
// (index: string) => this.changeStartWith(Number(index)),
|
|
323
|
+
// {
|
|
324
|
+
// value: String((this.data.meta as OrderedListItemMeta).start ?? 1),
|
|
325
|
+
// placeholder: '',
|
|
326
|
+
// attributes: {
|
|
327
|
+
// required: 'true',
|
|
328
|
+
// },
|
|
329
|
+
// sanitize: input => stripNumbers(input),
|
|
330
|
+
// });
|
|
331
|
+
|
|
332
|
+
// const orderedListTunes: MenuConfigItem[] = [
|
|
333
|
+
// {
|
|
334
|
+
// label: this.api.i18n.t('Start with'),
|
|
335
|
+
// icon: IconStartWith,
|
|
336
|
+
// children: {
|
|
337
|
+
// items: [
|
|
338
|
+
// {
|
|
339
|
+
// element: startWithElement,
|
|
340
|
+
// // @ts-expect-error ts(2820) can not use PopoverItem enum from editor.js types
|
|
341
|
+
// type: 'html',
|
|
342
|
+
// },
|
|
343
|
+
// ],
|
|
344
|
+
// },
|
|
345
|
+
// },
|
|
346
|
+
// ];
|
|
347
|
+
|
|
348
|
+
// const orderedListCountersTunes: MenuConfigItem = {
|
|
349
|
+
// label: this.api.i18n.t('Counter type'),
|
|
350
|
+
// icon: OlCounterIconsMap.get((this.data.meta as OrderedListItemMeta).counterType!),
|
|
351
|
+
// children: {
|
|
352
|
+
// items: [],
|
|
353
|
+
// },
|
|
354
|
+
// };
|
|
355
|
+
|
|
356
|
+
// /**
|
|
357
|
+
// * For each counter type in OlCounterType create toolbox item
|
|
358
|
+
// */
|
|
359
|
+
// OlCounterTypesMap.forEach((_, counterType: string) => {
|
|
360
|
+
// const counterTypeValue = OlCounterTypesMap.get(counterType)! as OlCounterType;
|
|
361
|
+
|
|
362
|
+
// if (!this.defaultCounterTypes.includes(counterTypeValue)) {
|
|
363
|
+
// return;
|
|
364
|
+
// }
|
|
365
|
+
|
|
366
|
+
// orderedListCountersTunes.children.items!.push({
|
|
367
|
+
// title: this.api.i18n.t(counterType),
|
|
368
|
+
// icon: OlCounterIconsMap.get(counterTypeValue),
|
|
369
|
+
// isActive: (this.data.meta as OrderedListItemMeta).counterType === OlCounterTypesMap.get(counterType),
|
|
370
|
+
// closeOnActivate: true,
|
|
371
|
+
// onActivate: () => {
|
|
372
|
+
// this.changeCounters(OlCounterTypesMap.get(counterType) as OlCounterType);
|
|
373
|
+
// },
|
|
374
|
+
// });
|
|
375
|
+
// });
|
|
376
|
+
|
|
377
|
+
// /**
|
|
378
|
+
// * Dont show Counter type tune if there is no valid counter types
|
|
379
|
+
// */
|
|
380
|
+
// if (orderedListCountersTunes.children.items!.length > 1) {
|
|
381
|
+
// orderedListTunes.push(orderedListCountersTunes);
|
|
382
|
+
// }
|
|
383
|
+
|
|
384
|
+
// // @ts-expect-error ts(2820) can not use PopoverItem enum from editor.js types
|
|
385
|
+
// defaultTunes.push({ type: 'separator' }, ...orderedListTunes);
|
|
386
|
+
// }
|
|
387
|
+
|
|
388
|
+
// return defaultTunes;
|
|
389
|
+
// }
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* On paste callback that is fired from Editor.
|
|
393
|
+
* @param event - event with pasted data
|
|
394
|
+
*/
|
|
395
|
+
public onPaste(event: PasteEvent): void {
|
|
396
|
+
const { tagName: tag } = event.detail.data;
|
|
397
|
+
|
|
398
|
+
switch (tag) {
|
|
399
|
+
case 'OL':
|
|
400
|
+
this.listStyle = 'ordered';
|
|
401
|
+
break;
|
|
402
|
+
case 'UL':
|
|
403
|
+
case 'LI':
|
|
404
|
+
this.listStyle = 'unordered';
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
this.list!.onPaste(event);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Handle UL, OL and LI tags paste and returns List data
|
|
412
|
+
* @param element - html element that contains whole list
|
|
413
|
+
*/
|
|
414
|
+
public pasteHandler(element: PasteEvent['detail']['data']): ListData {
|
|
415
|
+
const data = this.list!.pasteHandler(element);
|
|
416
|
+
|
|
417
|
+
return data;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Changes ordered list counterType property value
|
|
422
|
+
* @param counterType - new value of the counterType value
|
|
423
|
+
*/
|
|
424
|
+
// private changeCounters(counterType: OlCounterType): void {
|
|
425
|
+
// this.list?.changeCounters(counterType);
|
|
426
|
+
|
|
427
|
+
// (this.data.meta as OrderedListItemMeta).counterType = counterType;
|
|
428
|
+
// }
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Changes ordered list start property value
|
|
432
|
+
* @param index - new value of the start property
|
|
433
|
+
// */
|
|
434
|
+
// private changeStartWith(index: number): void {
|
|
435
|
+
// this.list?.changeStartWith(index);
|
|
436
|
+
|
|
437
|
+
// (this.data.meta as OrderedListItemMeta).start = index;
|
|
438
|
+
// }
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* This method allows changing tabulator respectfully to passed style
|
|
442
|
+
*/
|
|
443
|
+
private changeTabulatorByStyle(): void {
|
|
444
|
+
switch (this.listStyle) {
|
|
445
|
+
case 'ordered':
|
|
446
|
+
this.list = new ListTabulator<OrderedListRenderer>({
|
|
447
|
+
data: this.data,
|
|
448
|
+
readOnly: this.readOnly,
|
|
449
|
+
api: this.api,
|
|
450
|
+
config: this.config,
|
|
451
|
+
block: this.block,
|
|
452
|
+
},
|
|
453
|
+
new OrderedListRenderer(this.readOnly, this.config)
|
|
454
|
+
);
|
|
455
|
+
|
|
456
|
+
break;
|
|
457
|
+
|
|
458
|
+
case 'unordered':
|
|
459
|
+
this.list = new ListTabulator<UnorderedListRenderer>({
|
|
460
|
+
data: this.data,
|
|
461
|
+
readOnly: this.readOnly,
|
|
462
|
+
api: this.api,
|
|
463
|
+
config: this.config,
|
|
464
|
+
block: this.block,
|
|
465
|
+
},
|
|
466
|
+
new UnorderedListRenderer(this.readOnly, this.config)
|
|
467
|
+
);
|
|
468
|
+
|
|
469
|
+
break;
|
|
470
|
+
|
|
471
|
+
case 'checklist':
|
|
472
|
+
this.list = new ListTabulator<CheckListRenderer>({
|
|
473
|
+
data: this.data,
|
|
474
|
+
readOnly: this.readOnly,
|
|
475
|
+
api: this.api,
|
|
476
|
+
config: this.config,
|
|
477
|
+
block: this.block,
|
|
478
|
+
},
|
|
479
|
+
new CheckListRenderer(this.readOnly, this.config)
|
|
480
|
+
);
|
|
481
|
+
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
.cdx-list {
|
|
2
|
+
margin: 0;
|
|
3
|
+
padding: 0;
|
|
4
|
+
outline: none;
|
|
5
|
+
display: grid;
|
|
6
|
+
counter-reset: item;
|
|
7
|
+
gap: var(--spacing-s);
|
|
8
|
+
padding: var(--spacing-xs);
|
|
9
|
+
--spacing-s: 8px;
|
|
10
|
+
--spacing-xs: 6px;
|
|
11
|
+
--list-counter-type: numeric;
|
|
12
|
+
--radius-border: 5px;
|
|
13
|
+
--checkbox-background: #fff;
|
|
14
|
+
--color-border: #C9C9C9;
|
|
15
|
+
--color-bg-checked: #369FFF;
|
|
16
|
+
--line-height: 1.45em;
|
|
17
|
+
--color-bg-checked-hover: #0059AB;
|
|
18
|
+
--color-tick: #fff;
|
|
19
|
+
--size-checkbox: 1.2em;
|
|
20
|
+
}
|
|
21
|
+
.cdx-list ol{
|
|
22
|
+
padding-inline-start:0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.cdx-list__item {
|
|
26
|
+
line-height: var(--line-height);
|
|
27
|
+
display: grid;
|
|
28
|
+
grid-template-columns: auto 1fr;
|
|
29
|
+
grid-template-rows: auto auto;
|
|
30
|
+
grid-template-areas:
|
|
31
|
+
"checkbox content"
|
|
32
|
+
". child";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.cdx-list__item-children {
|
|
36
|
+
display: grid;
|
|
37
|
+
grid-area: child;
|
|
38
|
+
gap: var(--spacing-s);
|
|
39
|
+
padding-top: var(--spacing-s);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.cdx-list__item [contenteditable]{
|
|
43
|
+
outline: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.cdx-list__item-content {
|
|
47
|
+
word-break: break-word;
|
|
48
|
+
white-space: pre-wrap;
|
|
49
|
+
grid-area: content;
|
|
50
|
+
padding-left: var(--spacing-s);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.cdx-list__item::before {
|
|
54
|
+
counter-increment: item;
|
|
55
|
+
|
|
56
|
+
white-space: nowrap;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.cdx-list-ordered .cdx-list__item::before {
|
|
60
|
+
content: counters(item, ".", var(--list-counter-type)) ".";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.cdx-list-ordered {
|
|
64
|
+
counter-reset: item;
|
|
65
|
+
}
|
|
66
|
+
.cdx-list-unordered{
|
|
67
|
+
padding-inline-start:0;
|
|
68
|
+
}
|
|
69
|
+
.cdx-list-unordered .cdx-list__item::before {
|
|
70
|
+
content: "•";
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.cdx-list-checklist .cdx-list__item::before {
|
|
74
|
+
content: "";
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.cdx-list__settings .cdx-settings-button {
|
|
78
|
+
width: 50%;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.cdx-list__checkbox {
|
|
82
|
+
padding-top: calc((var(--line-height) - var(--size-checkbox)) / 2);
|
|
83
|
+
grid-area: checkbox;
|
|
84
|
+
width: var(--size-checkbox);
|
|
85
|
+
height: var(--size-checkbox);
|
|
86
|
+
display: flex;
|
|
87
|
+
cursor: pointer;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.cdx-list__checkbox svg {
|
|
91
|
+
opacity: 0;
|
|
92
|
+
height: var(--size-checkbox);
|
|
93
|
+
width: var(--size-checkbox);
|
|
94
|
+
left: -1px;
|
|
95
|
+
top: -1px;
|
|
96
|
+
position: absolute;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@media (hover: hover) {
|
|
100
|
+
.cdx-list__checkbox:not(.cdx-list__checkbox--no-hover):hover .cdx-list__checkbox-check svg {
|
|
101
|
+
opacity: 1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.cdx-list__checkbox--checked {
|
|
106
|
+
line-height: var(--line-height);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@media (hover: hover) {
|
|
110
|
+
.cdx-list__checkbox--checked:not(.cdx-list__checkbox--checked--no-hover):hover .cdx-checklist__checkbox-check {
|
|
111
|
+
background: var(--color-bg-checked-hover);
|
|
112
|
+
border-color: var(--color-bg-checked-hover);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.cdx-list__checkbox--checked .cdx-list__checkbox-check {
|
|
117
|
+
background: var(--color-bg-checked);
|
|
118
|
+
border-color: var(--color-bg-checked);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.cdx-list__checkbox--checked .cdx-list__checkbox-check svg {
|
|
122
|
+
opacity: 1;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.cdx-list__checkbox--checked .cdx-list__checkbox-check svg path {
|
|
126
|
+
stroke: var(--color-tick);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.cdx-list__checkbox--checked .cdx-list__checkbox-check::before {
|
|
130
|
+
opacity: 0;
|
|
131
|
+
visibility: visible;
|
|
132
|
+
transform: scale(2.5);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.cdx-list__checkbox-check {
|
|
136
|
+
cursor: pointer;
|
|
137
|
+
display: inline-block;
|
|
138
|
+
position: relative;
|
|
139
|
+
margin: 0 auto;
|
|
140
|
+
width: var(--size-checkbox);
|
|
141
|
+
height: var(--size-checkbox);
|
|
142
|
+
box-sizing: border-box;
|
|
143
|
+
border-radius: var(--radius-border);
|
|
144
|
+
border: 1px solid var(--color-border);
|
|
145
|
+
background: var(--checkbox-background);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.cdx-list__checkbox-check::before {
|
|
149
|
+
content: '';
|
|
150
|
+
position: absolute;
|
|
151
|
+
top: 0;
|
|
152
|
+
right: 0;
|
|
153
|
+
bottom: 0;
|
|
154
|
+
left: 0;
|
|
155
|
+
border-radius: 100%;
|
|
156
|
+
background-color: var(--color-bg-checked);
|
|
157
|
+
visibility: hidden;
|
|
158
|
+
pointer-events: none;
|
|
159
|
+
transform: scale(1);
|
|
160
|
+
transition: transform 400ms ease-out, opacity 400ms;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.cdx-list__checkbox-check--disabled {
|
|
164
|
+
pointer-events: none;
|
|
165
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type that represents the list item
|
|
3
|
+
*/
|
|
4
|
+
export type ItemElement = HTMLElement;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Type that represents children wrapper of the list item
|
|
8
|
+
*/
|
|
9
|
+
export type ItemChildWrapperElement = HTMLElement;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Type that represents content element of the item
|
|
13
|
+
*/
|
|
14
|
+
export type ItemContentElement = HTMLElement;
|