@ebl-vue/editor-full 2.31.25 → 2.31.31
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.d.ts +1 -28
- package/dist/index.mjs +549 -728
- package/package.json +3 -3
- package/types/index.d.ts +5 -1
- package/.postcssrc.yml +0 -33
- package/dist/index.mjs.map +0 -1
- package/postcss.config.js +0 -15
- package/src/components/Editor/Editor.vue +0 -293
- package/src/components/Editor/EditorRender.vue +0 -274
- package/src/components/index.ts +0 -29
- package/src/constants/index.ts +0 -1
- package/src/i18n/zh-cn.ts +0 -158
- package/src/icons/index.ts +0 -93
- package/src/index.ts +0 -22
- package/src/installer.ts +0 -21
- package/src/plugins/alert/index.css +0 -150
- package/src/plugins/alert/index.ts +0 -456
- package/src/plugins/block-alignment/index.css +0 -9
- package/src/plugins/block-alignment/index.ts +0 -117
- package/src/plugins/block-alignment/readme.md +0 -1
- package/src/plugins/code/LICENSE +0 -21
- package/src/plugins/code/index.css +0 -214
- package/src/plugins/code/index.ts +0 -621
- package/src/plugins/code/utils/string.ts +0 -34
- package/src/plugins/color-picker/index.ts +0 -130
- package/src/plugins/color-picker/styles.css +0 -27
- package/src/plugins/delimiter/index.css +0 -14
- package/src/plugins/delimiter/index.ts +0 -121
- package/src/plugins/drag-drop/index.css +0 -19
- package/src/plugins/drag-drop/index.ts +0 -151
- package/src/plugins/drag-drop/readme.md +0 -1
- package/src/plugins/header/H1.ts +0 -404
- package/src/plugins/header/H2.ts +0 -403
- package/src/plugins/header/H3.ts +0 -404
- package/src/plugins/header/H4.ts +0 -404
- package/src/plugins/header/H5.ts +0 -403
- package/src/plugins/header/H6.ts +0 -404
- package/src/plugins/header/index.css +0 -20
- package/src/plugins/header/index.ts +0 -15
- package/src/plugins/header/types.d.ts +0 -46
- package/src/plugins/imageResizeCrop/ImageTune.ts +0 -916
- package/src/plugins/imageResizeCrop/index.css +0 -230
- package/src/plugins/imageResizeCrop/index.ts +0 -5
- package/src/plugins/imageResizeCrop/types.d.ts +0 -23
- package/src/plugins/imageTool/index.css +0 -156
- package/src/plugins/imageTool/index.ts +0 -538
- package/src/plugins/imageTool/types/codexteam__ajax.d.ts +0 -89
- package/src/plugins/imageTool/types/types.ts +0 -236
- package/src/plugins/imageTool/ui.ts +0 -313
- package/src/plugins/imageTool/uploader.ts +0 -272
- package/src/plugins/imageTool/utils/dom.ts +0 -24
- package/src/plugins/imageTool/utils/index.ts +0 -73
- package/src/plugins/imageTool/utils/isPromise.ts +0 -10
- package/src/plugins/indent/index.css +0 -86
- package/src/plugins/indent/index.ts +0 -695
- package/src/plugins/inline-code/index.css +0 -11
- package/src/plugins/inline-code/index.ts +0 -202
- package/src/plugins/list/ListRenderer/ChecklistRenderer.ts +0 -208
- package/src/plugins/list/ListRenderer/ListRenderer.ts +0 -73
- package/src/plugins/list/ListRenderer/OrderedListRenderer.ts +0 -123
- package/src/plugins/list/ListRenderer/UnorderedListRenderer.ts +0 -123
- package/src/plugins/list/ListRenderer/index.ts +0 -6
- package/src/plugins/list/ListTabulator/index.ts +0 -1179
- package/src/plugins/list/index.ts +0 -480
- package/src/plugins/list/styles/CssPrefix.ts +0 -4
- package/src/plugins/list/styles/input.css +0 -36
- package/src/plugins/list/styles/list.css +0 -165
- package/src/plugins/list/types/Elements.ts +0 -14
- package/src/plugins/list/types/ItemMeta.ts +0 -40
- package/src/plugins/list/types/ListParams.ts +0 -102
- package/src/plugins/list/types/ListRenderer.ts +0 -6
- package/src/plugins/list/types/OlCounterType.ts +0 -63
- package/src/plugins/list/types/index.ts +0 -14
- package/src/plugins/list/utils/focusItem.ts +0 -18
- package/src/plugins/list/utils/getChildItems.ts +0 -40
- package/src/plugins/list/utils/getItemChildWrapper.ts +0 -10
- package/src/plugins/list/utils/getItemContentElement.ts +0 -10
- package/src/plugins/list/utils/getSiblings.ts +0 -52
- package/src/plugins/list/utils/isLastItem.ts +0 -9
- package/src/plugins/list/utils/itemHasSublist.ts +0 -10
- package/src/plugins/list/utils/normalizeData.ts +0 -83
- package/src/plugins/list/utils/removeChildWrapperIfEmpty.ts +0 -31
- package/src/plugins/list/utils/renderToolboxInput.ts +0 -105
- package/src/plugins/list/utils/stripNumbers.ts +0 -7
- package/src/plugins/list/utils/type-guards.ts +0 -8
- package/src/plugins/marker/index.css +0 -4
- package/src/plugins/marker/index.ts +0 -199
- package/src/plugins/outline/index.css +0 -52
- package/src/plugins/outline/index.ts +0 -63
- package/src/plugins/paragraph/index.css +0 -23
- package/src/plugins/paragraph/index.ts +0 -381
- package/src/plugins/paragraph/types/icons.d.ts +0 -4
- package/src/plugins/paragraph/utils/makeFragment.ts +0 -17
- package/src/plugins/quote/index.css +0 -26
- package/src/plugins/quote/index.ts +0 -203
- package/src/plugins/table/index.ts +0 -4
- package/src/plugins/table/plugin.ts +0 -254
- package/src/plugins/table/style.css +0 -388
- package/src/plugins/table/table.ts +0 -1195
- package/src/plugins/table/toolbox.ts +0 -166
- package/src/plugins/table/utils/dom.ts +0 -130
- package/src/plugins/table/utils/popover.ts +0 -185
- package/src/plugins/table/utils/throttled.ts +0 -22
- package/src/plugins/underline/index.css +0 -3
- package/src/plugins/underline/index.ts +0 -214
- package/src/plugins/undo/index.ts +0 -524
- package/src/plugins/undo/observer.ts +0 -101
- package/src/style.css +0 -114
- package/src/types.ts +0 -3
- package/src/utils/AxiosService.ts +0 -87
- package/src/utils/index.ts +0 -15
- package/src/utils/install.ts +0 -19
- package/tsconfig.json +0 -37
- package/vite.config.ts +0 -81
|
@@ -1,456 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Alert block for the Editor.js.
|
|
3
|
-
*
|
|
4
|
-
* @author Vishal Telangre
|
|
5
|
-
* @license MIT
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Build styles
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import type { API,BlockTool,BlockToolConstructorOptions } from "@ebl-vue/editorjs/types";
|
|
13
|
-
import './index.css';
|
|
14
|
-
import type { HTMLPasteEvent } from '@ebl-vue/editorjs';
|
|
15
|
-
import { IconToolboxAlert as ToolboxIcon,IconAlignLeft as AlignLeftIcon,IconAlignCenter as AlignCenterIcon,IconAlignRight as AlignRightIcon } from "../../icons";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @class Alert
|
|
20
|
-
* @classdesc Alert Tool for Editor.js
|
|
21
|
-
* @property {AlertData} data - Alert Tool`s input and output data
|
|
22
|
-
* @property {object} api - Editor.js API instance
|
|
23
|
-
*
|
|
24
|
-
* @typedef {object} AlertData
|
|
25
|
-
* @description Alert Tool`s input and output data
|
|
26
|
-
* @property {string} type - Alert type
|
|
27
|
-
* @property {string} alignType - Alert align type
|
|
28
|
-
* @property {string} message - Alert message
|
|
29
|
-
*
|
|
30
|
-
* @typedef {object} AlertConfig
|
|
31
|
-
* @description Alert Tool`s initial configuration
|
|
32
|
-
* @property {string} defaultType - default Alert type
|
|
33
|
-
* @property {string} defaultAlignType - default align Alert type
|
|
34
|
-
* @property {string} messagePlaceholder - placeholder to show in Alert`s message input
|
|
35
|
-
*/
|
|
36
|
-
export default class Alert implements BlockTool{
|
|
37
|
-
/**
|
|
38
|
-
* Get Toolbox settings
|
|
39
|
-
*
|
|
40
|
-
* @public
|
|
41
|
-
* @returns {string}
|
|
42
|
-
*/
|
|
43
|
-
static get toolbox() {
|
|
44
|
-
return {
|
|
45
|
-
icon: ToolboxIcon,
|
|
46
|
-
title: 'Alert',
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Allow to press Enter inside the Alert block
|
|
52
|
-
* @public
|
|
53
|
-
* @returns {boolean}
|
|
54
|
-
*/
|
|
55
|
-
static get enableLineBreaks() {
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Default Alert type
|
|
61
|
-
*
|
|
62
|
-
* @public
|
|
63
|
-
* @returns {string}
|
|
64
|
-
*/
|
|
65
|
-
static get DEFAULT_TYPE() {
|
|
66
|
-
return 'info';
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Default Alert align type
|
|
71
|
-
*
|
|
72
|
-
* @public
|
|
73
|
-
* @returns {string}
|
|
74
|
-
*/
|
|
75
|
-
static get DEFAULT_ALIGN_TYPE() {
|
|
76
|
-
return 'left';
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Default placeholder for Alert message
|
|
81
|
-
*
|
|
82
|
-
* @public
|
|
83
|
-
* @returns {string}
|
|
84
|
-
*/
|
|
85
|
-
static get DEFAULT_MESSAGE_PLACEHOLDER() {
|
|
86
|
-
return 'Type here...';
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Supported Alert types
|
|
91
|
-
*
|
|
92
|
-
* @public
|
|
93
|
-
* @returns {array}
|
|
94
|
-
*/
|
|
95
|
-
static get ALERT_TYPES() {
|
|
96
|
-
return [
|
|
97
|
-
'primary',
|
|
98
|
-
'secondary',
|
|
99
|
-
'info',
|
|
100
|
-
'success',
|
|
101
|
-
'warning',
|
|
102
|
-
'danger',
|
|
103
|
-
'light',
|
|
104
|
-
'dark',
|
|
105
|
-
];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Supported Align types
|
|
110
|
-
*
|
|
111
|
-
* @public
|
|
112
|
-
* @returns {array}
|
|
113
|
-
*/
|
|
114
|
-
static get ALIGN_TYPES() {
|
|
115
|
-
return ['left', 'center', 'right'];
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Alert Tool`s styles
|
|
120
|
-
*
|
|
121
|
-
* @returns {Object}
|
|
122
|
-
*/
|
|
123
|
-
get CSS() {
|
|
124
|
-
return {
|
|
125
|
-
wrapper: 'cdx-alert',
|
|
126
|
-
wrapperForType: (type:string) => `cdx-alert-${type}`,
|
|
127
|
-
wrapperForAlignType: (alignType:string) => `cdx-alert-align-${alignType}`,
|
|
128
|
-
message: 'cdx-alert__message',
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
private alertTypes: string[];
|
|
132
|
-
private defaultType: string;
|
|
133
|
-
private defaultAlign: string;
|
|
134
|
-
private messagePlaceholder: string;
|
|
135
|
-
private data: any;
|
|
136
|
-
private api: API;
|
|
137
|
-
private container: any;
|
|
138
|
-
private readOnly: boolean;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Render plugin`s main Element and fill it with saved data
|
|
142
|
-
*
|
|
143
|
-
* @param {AlertData} data — previously saved data
|
|
144
|
-
* @param {AlertConfig} config — user config for Tool
|
|
145
|
-
* @param {Object} api - Editor.js API
|
|
146
|
-
* @param {boolean} readOnly - read only mode flag
|
|
147
|
-
*/
|
|
148
|
-
constructor({ data, config, api, readOnly }:BlockToolConstructorOptions) {
|
|
149
|
-
this.api = api;
|
|
150
|
-
|
|
151
|
-
this.alertTypes = config.alertTypes || Alert.ALERT_TYPES;
|
|
152
|
-
this.defaultType = config.defaultType || Alert.DEFAULT_TYPE;
|
|
153
|
-
this.defaultAlign = config.defaultAlign || Alert.DEFAULT_ALIGN_TYPE;
|
|
154
|
-
this.messagePlaceholder =
|
|
155
|
-
this.api.i18n.t(config.messagePlaceholder || Alert.DEFAULT_MESSAGE_PLACEHOLDER);
|
|
156
|
-
|
|
157
|
-
this.data = {
|
|
158
|
-
type: this.alertTypes.includes(data.type)
|
|
159
|
-
? data.type
|
|
160
|
-
: this.defaultType,
|
|
161
|
-
align: Alert.ALIGN_TYPES.includes(data.align)
|
|
162
|
-
? data.align
|
|
163
|
-
: this.defaultAlign,
|
|
164
|
-
message: data.message || '',
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
this.container = undefined;
|
|
168
|
-
|
|
169
|
-
this.readOnly = readOnly;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Returns true to notify the core that read-only mode is supported
|
|
174
|
-
*
|
|
175
|
-
* @return {boolean}
|
|
176
|
-
*/
|
|
177
|
-
static get isReadOnlySupported() {
|
|
178
|
-
return true;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Create Alert Tool container
|
|
183
|
-
*
|
|
184
|
-
* @returns {Element}
|
|
185
|
-
*/
|
|
186
|
-
render() {
|
|
187
|
-
const containerClasses = [
|
|
188
|
-
this.CSS.wrapper,
|
|
189
|
-
this.CSS.wrapperForType(this.data.type),
|
|
190
|
-
this.CSS.wrapperForAlignType(this.data.align),
|
|
191
|
-
];
|
|
192
|
-
|
|
193
|
-
this.container = this._make('div', containerClasses);
|
|
194
|
-
|
|
195
|
-
const messageEl = this._make('div', [this.CSS.message], {
|
|
196
|
-
contentEditable: !this.readOnly,
|
|
197
|
-
innerHTML: this.data.message,
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
messageEl.dataset.placeholder = this.messagePlaceholder;
|
|
201
|
-
|
|
202
|
-
this.container.appendChild(messageEl);
|
|
203
|
-
|
|
204
|
-
return this.container;
|
|
205
|
-
}
|
|
206
|
-
_getSettingIconStyle(type: string) {
|
|
207
|
-
let classname = "";
|
|
208
|
-
switch (type) {
|
|
209
|
-
case 'primary':
|
|
210
|
-
classname = "cdx-alert-primary";
|
|
211
|
-
break;
|
|
212
|
-
case 'secondary':
|
|
213
|
-
classname = "cdx-alert-secondary";
|
|
214
|
-
break;
|
|
215
|
-
case 'info':
|
|
216
|
-
classname = "cdx-alert-info";
|
|
217
|
-
break;
|
|
218
|
-
case 'success':
|
|
219
|
-
classname = "cdx-alert-success";
|
|
220
|
-
break;
|
|
221
|
-
case 'warning':
|
|
222
|
-
classname = "cdx-alert-warning";
|
|
223
|
-
break;
|
|
224
|
-
case 'danger':
|
|
225
|
-
classname = "cdx-alert-danger";
|
|
226
|
-
break;
|
|
227
|
-
case 'light':
|
|
228
|
-
classname = "cdx-alert-light";
|
|
229
|
-
break;
|
|
230
|
-
case 'dark':
|
|
231
|
-
classname = "cdx-alert-dark";
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
const iconWrap = this._make('div', ['cdx-alert_setting__icon',classname], {});
|
|
235
|
-
return iconWrap;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Create Block's settings block
|
|
240
|
-
*
|
|
241
|
-
* @returns {array}
|
|
242
|
-
*/
|
|
243
|
-
renderSettings() {
|
|
244
|
-
const wrapper = document.createElement('div');
|
|
245
|
-
const alertWrapper = document.createElement('div');
|
|
246
|
-
const alignWrapper= document.createElement('div');
|
|
247
|
-
alertWrapper.classList.add('cdx-alert_setting__icon_wrapper');
|
|
248
|
-
alignWrapper.classList.add('cdx-alert_setting__icon_wrapper');
|
|
249
|
-
alignWrapper.classList.add("cdx-alert_setting__icon_wrapper_align");
|
|
250
|
-
|
|
251
|
-
this.alertTypes.map((type) => {
|
|
252
|
-
let button = this._getSettingIconStyle(type);
|
|
253
|
-
button.setAttribute('data-type', type);
|
|
254
|
-
|
|
255
|
-
this.api.tooltip.onHover(button, this.api.i18n.t(`alert-${type}`), {
|
|
256
|
-
placement: 'top',
|
|
257
|
-
});
|
|
258
|
-
button.innerText = "A";
|
|
259
|
-
alertWrapper.appendChild(button);
|
|
260
|
-
return button;
|
|
261
|
-
}).forEach((button, index, buttons) => {
|
|
262
|
-
const type: string = button.getAttribute('data-type') || "";
|
|
263
|
-
button.addEventListener('click', () => {
|
|
264
|
-
this._changeAlertType(type);
|
|
265
|
-
buttons.forEach((el, index) => {
|
|
266
|
-
const elType= el.getAttribute('data-type');
|
|
267
|
-
el.classList.toggle("cdx-alert_setting__icon_active", elType === this.data.type);
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
Alert.ALIGN_TYPES.map((align) => {
|
|
276
|
-
let button;
|
|
277
|
-
if (align === "left") {
|
|
278
|
-
button = document.createElement("div");
|
|
279
|
-
button.classList.add("cdx-alert_setting__icon");
|
|
280
|
-
button.innerHTML = AlignLeftIcon;
|
|
281
|
-
}
|
|
282
|
-
if (align === "right") {
|
|
283
|
-
button = document.createElement("div");
|
|
284
|
-
button.classList.add("cdx-alert_setting__icon");
|
|
285
|
-
button.innerHTML = AlignRightIcon;
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
if (align === "center") {
|
|
289
|
-
button = document.createElement("div");
|
|
290
|
-
button.classList.add("cdx-alert_setting__icon");
|
|
291
|
-
button.innerHTML = AlignCenterIcon;
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
button?.setAttribute("data-align", align);
|
|
297
|
-
this.api.tooltip.onHover(button!, this.api.i18n.t(`align-${align}`), {
|
|
298
|
-
placement: 'top',
|
|
299
|
-
});
|
|
300
|
-
alignWrapper.appendChild(button!);
|
|
301
|
-
return button;
|
|
302
|
-
}).forEach((button, index, buttons) => {
|
|
303
|
-
const align: string = button!.getAttribute('data-align') || "";
|
|
304
|
-
button!.addEventListener('click', () => {
|
|
305
|
-
this._changeAlignType(align);
|
|
306
|
-
buttons.forEach((el, index) => {
|
|
307
|
-
const elAlign = el?.getAttribute('data-align');
|
|
308
|
-
el?.classList.toggle("cdx-alert_setting__icon_active", elAlign === this.data.align);
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
wrapper.appendChild(alertWrapper);
|
|
314
|
-
wrapper.appendChild(alignWrapper);
|
|
315
|
-
return wrapper;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Helper for formatting Alert Type / Align Type
|
|
320
|
-
*
|
|
321
|
-
* @param {string} type - Alert type or Align type
|
|
322
|
-
* @returns {string}
|
|
323
|
-
*/
|
|
324
|
-
_getFormattedName(name: string) {
|
|
325
|
-
return this.api.i18n.t(name.charAt(0).toUpperCase() + name.slice(1));
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* Helper for changing style of Alert block with the selected Alert type
|
|
330
|
-
*
|
|
331
|
-
* @param {string} newType - new Alert type to be applied to the block
|
|
332
|
-
* @private
|
|
333
|
-
*/
|
|
334
|
-
_changeAlertType(newType: string) {
|
|
335
|
-
// Save new type
|
|
336
|
-
this.data.type = newType;
|
|
337
|
-
|
|
338
|
-
this.alertTypes.forEach((type) => {
|
|
339
|
-
const alertClass = this.CSS.wrapperForType(type);
|
|
340
|
-
|
|
341
|
-
// Remove the old Alert type class
|
|
342
|
-
this.container.classList.remove(alertClass);
|
|
343
|
-
|
|
344
|
-
if (newType === type) {
|
|
345
|
-
// Add an Alert class for the selected Alert type
|
|
346
|
-
this.container.classList.add(alertClass);
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* Helper for changing align of Alert block with the selected Align type
|
|
353
|
-
*
|
|
354
|
-
* @param {string} newAlign - new align type to be applied to the block
|
|
355
|
-
* @private
|
|
356
|
-
*/
|
|
357
|
-
_changeAlignType(newAlign: string) {
|
|
358
|
-
// Save new type
|
|
359
|
-
this.data.align = newAlign;
|
|
360
|
-
|
|
361
|
-
Alert.ALIGN_TYPES.forEach((align) => {
|
|
362
|
-
const alignClass = this.CSS.wrapperForAlignType(align);
|
|
363
|
-
|
|
364
|
-
// Remove the old Alert type class
|
|
365
|
-
this.container.classList.remove(alignClass);
|
|
366
|
-
|
|
367
|
-
if (newAlign === align) {
|
|
368
|
-
// Add an Alert class for the selected Alert type
|
|
369
|
-
this.container.classList.add(alignClass);
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Extract Alert data from Alert Tool element
|
|
376
|
-
*
|
|
377
|
-
* @param {HTMLDivElement} alertElement - element to save
|
|
378
|
-
* @returns {AlertData}
|
|
379
|
-
*/
|
|
380
|
-
save(alertElement: HTMLElement) {
|
|
381
|
-
const messageEl = alertElement.querySelector(`.${this.CSS.message}`);
|
|
382
|
-
|
|
383
|
-
const data = { ...this.data, message: messageEl?.innerHTML || '' };
|
|
384
|
-
console.log('save', data);
|
|
385
|
-
return data;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* Helper for making Elements with attributes
|
|
390
|
-
*
|
|
391
|
-
* @param {string} tagName - new Element tag name
|
|
392
|
-
* @param {array|string} classNames - list or name of CSS classname(s)
|
|
393
|
-
* @param {Object} attributes - any attributes
|
|
394
|
-
* @returns {Element}
|
|
395
|
-
* @private
|
|
396
|
-
*/
|
|
397
|
-
_make(tagName:string, classNames:string[]|string|null, attributes:Record<string, any> = {}) {
|
|
398
|
-
let el: HTMLElement = document.createElement(tagName);
|
|
399
|
-
|
|
400
|
-
if (Array.isArray(classNames)) {
|
|
401
|
-
el.classList.add(...classNames);
|
|
402
|
-
} else if (classNames) {
|
|
403
|
-
el.classList.add(classNames);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
for (let attrName in attributes) {
|
|
407
|
-
el[attrName] = attributes[attrName];
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
return el;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Fill Alert's message with the pasted content
|
|
415
|
-
*
|
|
416
|
-
* @param {PasteEvent} event - event with pasted content
|
|
417
|
-
*/
|
|
418
|
-
onPaste(event:HTMLPasteEvent) {
|
|
419
|
-
const { data } = event.detail;
|
|
420
|
-
|
|
421
|
-
this.data = {
|
|
422
|
-
type: this.defaultType,
|
|
423
|
-
message: data.innerHTML || '',
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* Allow Alert to be converted to/from other blocks
|
|
429
|
-
*/
|
|
430
|
-
static get conversionConfig() {
|
|
431
|
-
return {
|
|
432
|
-
// export Alert's message for other blocks
|
|
433
|
-
export: (data:any) => data.message,
|
|
434
|
-
// fill Alert's message from other block's export string
|
|
435
|
-
import: (string:string) => {
|
|
436
|
-
return {
|
|
437
|
-
message: string,
|
|
438
|
-
type: this.DEFAULT_TYPE,
|
|
439
|
-
alignType: this.DEFAULT_ALIGN_TYPE,
|
|
440
|
-
};
|
|
441
|
-
},
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* Sanitizer config for Alert Tool saved data
|
|
447
|
-
* @returns {Object}
|
|
448
|
-
*/
|
|
449
|
-
static get sanitize() {
|
|
450
|
-
return {
|
|
451
|
-
message: true,
|
|
452
|
-
type: false,
|
|
453
|
-
alignType: false,
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import "./index.css"
|
|
2
|
-
import type { API, BlockTune, ToolConfig } from "@ebl-vue/editorjs/types";
|
|
3
|
-
import { IconAlignLeft,IconAlignCenter,IconAlignRight } from "../../icons";
|
|
4
|
-
|
|
5
|
-
interface ConstructorArgs {
|
|
6
|
-
data: AlignmentData;
|
|
7
|
-
config?: ToolConfig;
|
|
8
|
-
api: API;
|
|
9
|
-
block?: any;
|
|
10
|
-
}
|
|
11
|
-
export interface AlignmentData {
|
|
12
|
-
text?: string;
|
|
13
|
-
alignment: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default class BlockAlignment implements BlockTune{
|
|
17
|
-
private settings: ToolConfig;
|
|
18
|
-
private block: any;
|
|
19
|
-
private api: API;
|
|
20
|
-
private data: AlignmentData;
|
|
21
|
-
private alignmentSettings: any[];
|
|
22
|
-
private _CSS: any;
|
|
23
|
-
private wrapper: HTMLElement | undefined;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
static get DEFAULT_ALIGNMENT() {
|
|
27
|
-
return 'left';
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static get isTune() {
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
getAlignment() {
|
|
35
|
-
if (!!this.settings?.blocks && this.settings.blocks.hasOwnProperty(this.block.name)) {
|
|
36
|
-
return this.settings.blocks[this.block.name]
|
|
37
|
-
}
|
|
38
|
-
if (!!this.settings?.default) {
|
|
39
|
-
return this.settings.default
|
|
40
|
-
}
|
|
41
|
-
return BlockAlignment.DEFAULT_ALIGNMENT
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
constructor({ api, data, config, block }: ConstructorArgs) {
|
|
45
|
-
this.api = api;
|
|
46
|
-
this.block = block;
|
|
47
|
-
|
|
48
|
-
this.settings = config;
|
|
49
|
-
this.data = data || { alignment: this.getAlignment() }
|
|
50
|
-
this.alignmentSettings = [
|
|
51
|
-
{
|
|
52
|
-
name: 'left',
|
|
53
|
-
icon: IconAlignLeft
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: 'center',
|
|
57
|
-
icon: IconAlignCenter
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: 'right',
|
|
61
|
-
icon: IconAlignRight
|
|
62
|
-
}
|
|
63
|
-
];
|
|
64
|
-
this._CSS = {
|
|
65
|
-
alignment: {
|
|
66
|
-
left: 'ce-tune-alignment--left',
|
|
67
|
-
center: 'ce-tune-alignment--center',
|
|
68
|
-
right: 'ce-tune-alignment--right',
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
wrap(blockContent: HTMLElement) {
|
|
75
|
-
this.wrapper = document.createElement("div");
|
|
76
|
-
this.wrapper!.classList.toggle(this._CSS.alignment[this.data.alignment])
|
|
77
|
-
this.wrapper!.append(blockContent)
|
|
78
|
-
return this.wrapper
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
render() {
|
|
83
|
-
const wrapper = document.createElement("div");
|
|
84
|
-
this.alignmentSettings.map(align => {
|
|
85
|
-
const button = document.createElement('button');
|
|
86
|
-
button.classList.add(this.api.styles.settingsButton);
|
|
87
|
-
button.innerHTML = align.icon;
|
|
88
|
-
button.type = 'button';
|
|
89
|
-
|
|
90
|
-
button.classList.toggle(this.api.styles.settingsButtonActive, align.name === this.data.alignment);
|
|
91
|
-
const buttonTooltip = this.api.i18n.t(align.name + " align");
|
|
92
|
-
this.api.tooltip.onHover(button, buttonTooltip, {
|
|
93
|
-
placement: 'top',
|
|
94
|
-
});
|
|
95
|
-
wrapper.appendChild(button);
|
|
96
|
-
return button
|
|
97
|
-
}).forEach((element, index, elements) => {
|
|
98
|
-
element.addEventListener('click', () => {
|
|
99
|
-
this.data = {
|
|
100
|
-
alignment: this.alignmentSettings[index].name
|
|
101
|
-
}
|
|
102
|
-
elements.forEach((el, i) => {
|
|
103
|
-
const { name } = this.alignmentSettings[i];
|
|
104
|
-
el.classList.toggle(this.api.styles.settingsButtonActive, name === this.data.alignment);
|
|
105
|
-
this.wrapper!.classList.toggle(this._CSS.alignment[name], name === this.data.alignment)
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
return wrapper;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
save() {
|
|
114
|
-
return this.data;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# 通用的对齐插件
|
package/src/plugins/code/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 CodeX
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|