@ebl-vue/editor-full 2.31.35 → 2.31.36
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/dist/index.d.ts +3 -7
- package/dist/index.mjs +183 -182
- package/dist/index.mjs.map +1 -0
- package/package.json +1 -1
- package/postcss.config.js +15 -0
- package/src/components/Editor/Editor.vue +293 -0
- package/src/components/index.ts +27 -0
- package/src/constants/index.ts +1 -0
- package/src/i18n/zh-cn.ts +160 -0
- package/src/icons/index.ts +93 -0
- package/src/index.ts +21 -0
- package/src/installer.ts +21 -0
- package/src/plugins/alert/index.ts +455 -0
- package/src/plugins/block-alignment/index.ts +117 -0
- package/src/plugins/block-alignment/readme.md +1 -0
- package/src/plugins/code/LICENSE +21 -0
- package/src/plugins/code/index.ts +619 -0
- package/src/plugins/code/utils/string.ts +34 -0
- package/src/plugins/color-picker/index.ts +132 -0
- package/src/plugins/delimiter/index.ts +121 -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 +404 -0
- package/src/plugins/header/H2.ts +403 -0
- package/src/plugins/header/H3.ts +404 -0
- package/src/plugins/header/H4.ts +404 -0
- package/src/plugins/header/H5.ts +403 -0
- package/src/plugins/header/H6.ts +404 -0
- package/src/plugins/header/index.ts +15 -0
- package/src/plugins/header/types.d.ts +46 -0
- package/src/plugins/imageResizeCrop/ImageTune.ts +635 -0
- package/src/plugins/imageResizeCrop/index.css +230 -0
- package/src/plugins/imageResizeCrop/index.ts +5 -0
- package/src/plugins/imageResizeCrop/types.d.ts +23 -0
- package/src/plugins/imageTool/index.ts +510 -0
- package/src/plugins/imageTool/types/codexteam__ajax.d.ts +89 -0
- package/src/plugins/imageTool/types/types.ts +236 -0
- package/src/plugins/imageTool/ui.ts +313 -0
- package/src/plugins/imageTool/uploader.ts +287 -0
- package/src/plugins/imageTool/utils/dom.ts +24 -0
- package/src/plugins/imageTool/utils/index.ts +73 -0
- package/src/plugins/imageTool/utils/isPromise.ts +10 -0
- package/src/plugins/indent/index.ts +695 -0
- package/src/plugins/inline-code/index.ts +203 -0
- package/src/plugins/list/ListRenderer/ChecklistRenderer.ts +208 -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 +488 -0
- package/src/plugins/list/styles/CssPrefix.ts +4 -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 +83 -0
- package/src/plugins/list/utils/removeChildWrapperIfEmpty.ts +31 -0
- package/src/plugins/list/utils/renderToolboxInput.ts +113 -0
- package/src/plugins/list/utils/stripNumbers.ts +7 -0
- package/src/plugins/list/utils/type-guards.ts +8 -0
- package/src/plugins/marker/index.ts +199 -0
- package/src/plugins/outline/index.ts +62 -0
- package/src/plugins/outline/outline.css +52 -0
- package/src/plugins/paragraph/index.ts +384 -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.ts +203 -0
- package/src/plugins/table/index.ts +4 -0
- package/src/plugins/table/plugin.ts +255 -0
- package/src/plugins/table/table.ts +1202 -0
- package/src/plugins/table/toolbox.ts +166 -0
- package/src/plugins/table/utils/dom.ts +130 -0
- package/src/plugins/table/utils/popover.ts +185 -0
- package/src/plugins/table/utils/throttled.ts +22 -0
- package/src/plugins/underline/index.ts +214 -0
- package/src/plugins/undo/index.ts +526 -0
- package/src/plugins/undo/observer.ts +101 -0
- package/src/plugins/undo/vanilla-caret-js.ts +102 -0
- package/src/style.css +139 -0
- package/src/types.ts +3 -0
- package/src/utils/AxiosService.ts +87 -0
- package/src/utils/index.ts +15 -0
- package/src/utils/install.ts +19 -0
- package/tsconfig.json +37 -0
- package/vite.config.ts +81 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import Table from './table';
|
|
2
|
+
import * as $ from './utils/dom';
|
|
3
|
+
|
|
4
|
+
import { IconTable, IconTableWithHeadings, IconTableWithoutHeadings } from '../../icons';
|
|
5
|
+
import type { BlockTool, BlockToolConstructorOptions,PasteEvent } from '@ebl-vue/editorjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {object} TableData - configuration that the user can set for the table
|
|
9
|
+
* @property {number} rows - number of rows in the table
|
|
10
|
+
* @property {number} cols - number of columns in the table
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {object} Tune - setting for the table
|
|
14
|
+
* @property {string} name - tune name
|
|
15
|
+
* @property {HTMLElement} icon - icon for the tune
|
|
16
|
+
* @property {boolean} isActive - default state of the tune
|
|
17
|
+
* @property {void} setTune - set tune state to the table data
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {object} TableConfig - object with the data transferred to form a table
|
|
21
|
+
* @property {boolean} withHeading - setting to use cells of the first row as headings
|
|
22
|
+
* @property {string[][]} content - two-dimensional array which contains table content
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {object} TableConstructor
|
|
26
|
+
* @property {TableConfig} data — previously saved data
|
|
27
|
+
* @property {TableConfig} config - user config for Tool
|
|
28
|
+
* @property {object} api - Editor.js API
|
|
29
|
+
* @property {boolean} readOnly - read-only mode flag
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* @typedef {import('@ebl-vue/editorjs').PasteEvent} PasteEvent
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Table block for Editor.js
|
|
38
|
+
*/
|
|
39
|
+
export default class TableBlock implements BlockTool {
|
|
40
|
+
private api: any;
|
|
41
|
+
private data: any;
|
|
42
|
+
private config: any;
|
|
43
|
+
private container: any;
|
|
44
|
+
//private block: any;
|
|
45
|
+
private readOnly: any;
|
|
46
|
+
private table: any;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Notify core that read-only mode is supported
|
|
50
|
+
*
|
|
51
|
+
* @returns {boolean}
|
|
52
|
+
*/
|
|
53
|
+
static get isReadOnlySupported() {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Allow to press Enter inside the CodeTool textarea
|
|
59
|
+
*
|
|
60
|
+
* @returns {boolean}
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
static get enableLineBreaks() {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Render plugin`s main Element and fill it with saved data
|
|
69
|
+
*
|
|
70
|
+
* @param {TableConstructor} init
|
|
71
|
+
*/
|
|
72
|
+
constructor({ data, config, api, readOnly, block }: BlockToolConstructorOptions) {
|
|
73
|
+
this.api = api;
|
|
74
|
+
this.readOnly = readOnly;
|
|
75
|
+
this.config = config;
|
|
76
|
+
this.data = {
|
|
77
|
+
withHeadings: this.getConfig('withHeadings', undefined, data),
|
|
78
|
+
stretched: this.getConfig('stretched', undefined, data),
|
|
79
|
+
content: data && data.content ? data.content : [],
|
|
80
|
+
colWidth: data && data.colWidth ? data.colWidth : []
|
|
81
|
+
};
|
|
82
|
+
this.table = null;
|
|
83
|
+
//this.block = block;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get Tool toolbox settings
|
|
88
|
+
* icon - Tool icon's SVG
|
|
89
|
+
* title - title to show in toolbox
|
|
90
|
+
*
|
|
91
|
+
* @returns {{icon: string, title: string}}
|
|
92
|
+
*/
|
|
93
|
+
static get toolbox() {
|
|
94
|
+
return {
|
|
95
|
+
icon: IconTable,
|
|
96
|
+
title: 'Table'
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Return Tool's view
|
|
102
|
+
*
|
|
103
|
+
* @returns {HTMLDivElement}
|
|
104
|
+
*/
|
|
105
|
+
render() {
|
|
106
|
+
/** creating table */
|
|
107
|
+
this.table = new Table(this.readOnly, this.api, this.data, this.config);
|
|
108
|
+
|
|
109
|
+
/** creating container around table */
|
|
110
|
+
this.container = $.make('div', this.api.styles.block);
|
|
111
|
+
|
|
112
|
+
this.container.appendChild(this.table.getWrapper());
|
|
113
|
+
|
|
114
|
+
this.table.setHeadingsSetting(this.data.withHeadings);
|
|
115
|
+
|
|
116
|
+
return this.container;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Returns plugin settings
|
|
121
|
+
*
|
|
122
|
+
* @returns {Array}
|
|
123
|
+
*/
|
|
124
|
+
renderSettings() {
|
|
125
|
+
return [
|
|
126
|
+
{
|
|
127
|
+
label: this.api.i18n.t('With headings'),
|
|
128
|
+
icon: IconTableWithHeadings,
|
|
129
|
+
isActive: this.data.withHeadings,
|
|
130
|
+
closeOnActivate: true,
|
|
131
|
+
toggle: true,
|
|
132
|
+
hint: {
|
|
133
|
+
title: this.api.i18n.t('With headings')
|
|
134
|
+
},
|
|
135
|
+
onActivate: () => {
|
|
136
|
+
this.data.withHeadings = true;
|
|
137
|
+
this.table.setHeadingsSetting(this.data.withHeadings);
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
label: this.api.i18n.t('Without headings'),
|
|
141
|
+
icon: IconTableWithoutHeadings,
|
|
142
|
+
isActive: !this.data.withHeadings,
|
|
143
|
+
closeOnActivate: true,
|
|
144
|
+
toggle: true,
|
|
145
|
+
hint: {
|
|
146
|
+
title: this.api.i18n.t('Without headings')
|
|
147
|
+
},
|
|
148
|
+
onActivate: () => {
|
|
149
|
+
this.data.withHeadings = false;
|
|
150
|
+
this.table.setHeadingsSetting(this.data.withHeadings);
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
// {
|
|
154
|
+
// label: this.data.stretched ? this.api.i18n.t('Collapse') : this.api.i18n.t('Stretch'),
|
|
155
|
+
// icon: this.data.stretched ? IconCollapse : IconStretch,
|
|
156
|
+
// closeOnActivate: true,
|
|
157
|
+
// toggle: true,
|
|
158
|
+
// onActivate: () => {
|
|
159
|
+
// this.data.stretched = !this.data.stretched;
|
|
160
|
+
// this.block.stretched = this.data.stretched;
|
|
161
|
+
// }
|
|
162
|
+
// }
|
|
163
|
+
];
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Extract table data from the view
|
|
167
|
+
*
|
|
168
|
+
* @returns {TableData} - saved data
|
|
169
|
+
*/
|
|
170
|
+
save() {
|
|
171
|
+
const tableContent = this.table.getData();
|
|
172
|
+
|
|
173
|
+
const result = {
|
|
174
|
+
withHeadings: this.data.withHeadings,
|
|
175
|
+
stretched: this.data.stretched,
|
|
176
|
+
content: tableContent,
|
|
177
|
+
colWidth: this.table.colWidthArr
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Plugin destroyer
|
|
185
|
+
*
|
|
186
|
+
* @returns {void}
|
|
187
|
+
*/
|
|
188
|
+
destroy() {
|
|
189
|
+
this.table.destroy();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* A helper to get config value.
|
|
194
|
+
*
|
|
195
|
+
* @param {string} configName - the key to get from the config.
|
|
196
|
+
* @param {any} defaultValue - default value if config doesn't have passed key
|
|
197
|
+
* @param {object} savedData - previously saved data. If passed, the key will be got from there, otherwise from the config
|
|
198
|
+
* @returns {any} - config value.
|
|
199
|
+
*/
|
|
200
|
+
getConfig(configName: string, defaultValue = undefined, savedData = undefined) {
|
|
201
|
+
const data = this.data || savedData;
|
|
202
|
+
|
|
203
|
+
if (data) {
|
|
204
|
+
return data[configName] ? data[configName] : defaultValue;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return this.config && this.config[configName] ? this.config[configName] : defaultValue;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Table onPaste configuration
|
|
212
|
+
*
|
|
213
|
+
* @public
|
|
214
|
+
*/
|
|
215
|
+
static get pasteConfig() {
|
|
216
|
+
return { tags: ['TABLE', 'TR', 'TH', 'TD'] };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* On paste callback that is fired from Editor
|
|
221
|
+
*
|
|
222
|
+
* @param {PasteEvent} event - event with pasted data
|
|
223
|
+
*/
|
|
224
|
+
onPaste(event: PasteEvent) {
|
|
225
|
+
if ('data' in event.detail) {
|
|
226
|
+
const table = event.detail.data as HTMLElement;
|
|
227
|
+
|
|
228
|
+
/** Check if the first row is a header */
|
|
229
|
+
const firstRowHeading = table.querySelector(':scope > thead, tr:first-of-type th');
|
|
230
|
+
|
|
231
|
+
/** Get all rows from the table */
|
|
232
|
+
const rows = Array.from(table.querySelectorAll('tr'));
|
|
233
|
+
|
|
234
|
+
/** Generate a content matrix */
|
|
235
|
+
const content = rows.map((row) => {
|
|
236
|
+
/** Get cells from row */
|
|
237
|
+
const cells = Array.from(row.querySelectorAll('th, td'))
|
|
238
|
+
|
|
239
|
+
/** Return cells content */
|
|
240
|
+
return cells.map((cell) => cell.innerHTML);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
/** Update Tool's data */
|
|
244
|
+
this.data = {
|
|
245
|
+
withHeadings: firstRowHeading !== null,
|
|
246
|
+
content
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
/** Update table block */
|
|
250
|
+
if (this.table.wrapper) {
|
|
251
|
+
this.table.wrapper.replaceWith(this.render());
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|