@ebl-vue/editor-full 1.0.13 → 1.1.1
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 -0
- package/dist/index.mjs +665 -543
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
- package/src/components/Editor/Editor.vue +16 -5
- package/src/plugins/imageResizeCrop/ImageTune.ts +900 -0
- package/src/plugins/imageResizeCrop/index.css +234 -0
- package/src/plugins/imageResizeCrop/index.ts +5 -0
- package/src/plugins/imageResizeCrop/types.d.ts +23 -0
- package/src/plugins/imageTool/index.css +1 -1
- package/src/plugins/imageTool/index.ts +30 -11
- package/src/plugins/imageTool/types/types.ts +2 -0
- package/src/plugins/imageTool/ui.ts +3 -2
- package/src/plugins/imageTool/uploader.ts +137 -103
- package/src/plugins/imageTool/utils/index.ts +73 -0
- package/src/utils/AxiosService.ts +87 -0
- package/types/index.d.ts +1 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
.cdx-image-tool-tune--floatLeft .cdx-block,
|
|
2
|
+
.cdx-image-tool-tune--center .cdx-block,
|
|
3
|
+
.cdx-image-tool-tune--floatRight .cdx-block,
|
|
4
|
+
.cdx-image-tool-tune--floatLeft .image-tool__image,
|
|
5
|
+
.cdx-image-tool-tune--center .image-tool__image,
|
|
6
|
+
.cdx-image-tool-tune--floatRight .image-tool__image,
|
|
7
|
+
.cdx-image-tool-tune--floatLeft .cdx-block,
|
|
8
|
+
.cdx-image-tool-tune--center .cdx-block,
|
|
9
|
+
.cdx-image-tool-tune--floatRight .cdx-block {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
align-items: center;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:root {
|
|
16
|
+
--primary: #2492F5;
|
|
17
|
+
--primary-content: #E9F4FE;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.cdx-settings-button--active {
|
|
21
|
+
background: var(--primary-content);
|
|
22
|
+
color: var(--primary);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.cdx-settings-button:hover {
|
|
26
|
+
background: var(--primary-content);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.cdx-image-tool-tune--center {
|
|
30
|
+
display: flex;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@media all and (min-width: 470px) {
|
|
35
|
+
.codex-editor:not(.read-only)
|
|
36
|
+
.cdx-image-tool-tune--floatLeft.ce-block__content,
|
|
37
|
+
.codex-editor:not(.read-only)
|
|
38
|
+
.cdx-image-tool-tune--floatRight.ce-block__content {
|
|
39
|
+
min-height: 20px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.cdx-image-tool-tune--floatLeft.ce-block__content .image-tool__image,
|
|
43
|
+
.cdx-image-tool-tune--floatRight.ce-block__content .image-tool__image {
|
|
44
|
+
margin-top: 40px;
|
|
45
|
+
}
|
|
46
|
+
.cdx-image-tool-tune--floatLeft.ce-block__content .image-tool__image {
|
|
47
|
+
margin-left: 20px;
|
|
48
|
+
}
|
|
49
|
+
.cdx-image-tool-tune--floatRight.ce-block__content .image-tool__image {
|
|
50
|
+
margin-right: 20px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.cdx-image-tool-tune--floatLeft.ce-block__content .cdx-input,
|
|
54
|
+
.cdx-image-tool-tune--floatRight.ce-block__content .cdx-input {
|
|
55
|
+
width: calc(100% - 20px);
|
|
56
|
+
}
|
|
57
|
+
.cdx-image-tool-tune--floatLeft.ce-block__content .cdx-input {
|
|
58
|
+
margin-left: 20px;
|
|
59
|
+
}
|
|
60
|
+
.cdx-image-tool-tune--floatRight.ce-block__content .cdx-input {
|
|
61
|
+
margin-right: 20px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.cdx-image-tool-tune--floatLeft .cdx-block {
|
|
65
|
+
float: left;
|
|
66
|
+
margin-right: 10px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.cdx-image-tool-tune--floatRight .cdx-block {
|
|
70
|
+
float: right;
|
|
71
|
+
margin-left: 10px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.cdx-image-tool-tune--sizeSmall .cdx-block {
|
|
75
|
+
max-width: 25% !important;
|
|
76
|
+
}
|
|
77
|
+
.cdx-image-tool-tune--sizeMiddle .cdx-block {
|
|
78
|
+
max-width: 50% !important;
|
|
79
|
+
}
|
|
80
|
+
.cdx-image-tool-tune--sizeLarge .cdx-block {
|
|
81
|
+
max-width: 75% !important;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.cdx-image-tool-tune--sizeLarge img {
|
|
86
|
+
object-fit: cover;
|
|
87
|
+
max-width: 100%;
|
|
88
|
+
}
|
|
89
|
+
.cdx-image-tool-tune--sizeSmall img {
|
|
90
|
+
object-fit: cover;
|
|
91
|
+
max-width: 100%;
|
|
92
|
+
}
|
|
93
|
+
.cdx-image-tool-tune--sizeMiddle img {
|
|
94
|
+
object-fit: cover;
|
|
95
|
+
max-width: 100%;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.codex-editor.read-only .cdx-input.image-tool__caption:empty,
|
|
99
|
+
.read-only > .codex-editor .cdx-input.image-tool__caption:empty {
|
|
100
|
+
display: none;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.cdx-image-tool-tune--resize .cdx-block {
|
|
104
|
+
position: relative;
|
|
105
|
+
overflow: visible;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.cdx-image-tool-tune--resize .cdx-block .resizable {
|
|
109
|
+
display: none;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.cdx-image-tool-tune--resize .image-tool__image-picture {
|
|
113
|
+
width: 100% !important;
|
|
114
|
+
}
|
|
115
|
+
.cdx-image-tool-tune--resize .cdx-block:hover .resizable {
|
|
116
|
+
display: block;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.cdx-image-tool-tune--resize .cdx-block .resizable .resizers .resizer {
|
|
120
|
+
width: 12px;
|
|
121
|
+
height: 12px;
|
|
122
|
+
border-radius: 50%;
|
|
123
|
+
background: var(--primary-content);
|
|
124
|
+
border: 3px solid var(--primary);
|
|
125
|
+
position: absolute;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.cdx-image-tool-tune--resize .cdx-block .resizable .resizers .resizer.top-left {
|
|
129
|
+
left: -5px;
|
|
130
|
+
top: -5px;
|
|
131
|
+
cursor: nwse-resize;
|
|
132
|
+
/*resizer cursor*/
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.cdx-image-tool-tune--resize
|
|
136
|
+
.cdx-block
|
|
137
|
+
.resizable
|
|
138
|
+
.resizers
|
|
139
|
+
.resizer.top-right {
|
|
140
|
+
right: -5px;
|
|
141
|
+
top: -5px;
|
|
142
|
+
cursor: nesw-resize;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.cdx-image-tool-tune--resize
|
|
146
|
+
.cdx-block
|
|
147
|
+
.resizable
|
|
148
|
+
.resizers
|
|
149
|
+
.resizer.bottom-left {
|
|
150
|
+
left: -5px;
|
|
151
|
+
bottom: -5px;
|
|
152
|
+
cursor: nesw-resize;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.cdx-image-tool-tune--resize
|
|
156
|
+
.cdx-block
|
|
157
|
+
.resizable
|
|
158
|
+
.resizers
|
|
159
|
+
.resizer.bottom-right {
|
|
160
|
+
right: -5px;
|
|
161
|
+
bottom: -5px;
|
|
162
|
+
cursor: nwse-resize;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.cdx-image-tool-tune--crop:hover,
|
|
166
|
+
.cdx-image-tool-tune--crop.isCropping,
|
|
167
|
+
.cdx-image-tool-tune--resize:hover {
|
|
168
|
+
z-index: 2;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.cdx-image-tool-tune--crop .image-tool__image {
|
|
172
|
+
position: relative;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.cdx-image-tool-tune--crop .isCropping .image-tool__image {
|
|
176
|
+
min-height: 600px;
|
|
177
|
+
min-width: 100%;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.cdx-image-tool-tune--crop .image-tool__image .crop-btn,
|
|
181
|
+
.cdx-image-tool-tune--crop .image-tool__image .crop-save {
|
|
182
|
+
position: absolute;
|
|
183
|
+
top: 0;
|
|
184
|
+
left: 0;
|
|
185
|
+
padding: 7px;
|
|
186
|
+
background: var(--primary);
|
|
187
|
+
color: var(--primary-content);
|
|
188
|
+
text-align: center;
|
|
189
|
+
line-height: 20px;
|
|
190
|
+
cursor: pointer;
|
|
191
|
+
display: none;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.cdx-image-tool-tune--crop .image-tool__image:hover .crop-btn,
|
|
195
|
+
.cdx-image-tool-tune--crop .image-tool__image:hover .crop-save {
|
|
196
|
+
display: block;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.cdx-image-tool-tune--crop .image-tool__image img.isCropped {
|
|
200
|
+
position: absolute;
|
|
201
|
+
min-width: unset;
|
|
202
|
+
max-width: unset;
|
|
203
|
+
min-height: unset;
|
|
204
|
+
max-height: unset;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.cdx-image-tool-tune--crop .cdx-block.image-tool.isCropping {
|
|
208
|
+
min-width: unset !important;
|
|
209
|
+
max-width: unset !important;
|
|
210
|
+
min-height: unset !important;
|
|
211
|
+
max-height: unset !important;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.ce-block {
|
|
215
|
+
margin: 0.8em 0;
|
|
216
|
+
}
|
|
217
|
+
.ce-toolbar {
|
|
218
|
+
z-index: 3;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.image-tool__caption {
|
|
222
|
+
background-color: white;
|
|
223
|
+
}
|
|
224
|
+
.image-tool {
|
|
225
|
+
position: relative;
|
|
226
|
+
z-index: 1;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.cdx-image-tool-tune {
|
|
230
|
+
display: flex;
|
|
231
|
+
justify-content: flex-start;
|
|
232
|
+
gap: 4px;
|
|
233
|
+
width: 100%;
|
|
234
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare module '*.css' {
|
|
2
|
+
const content: unknown;
|
|
3
|
+
export default content;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare module '@editorjs/editorjs' {
|
|
7
|
+
export interface API {
|
|
8
|
+
i18n: {
|
|
9
|
+
t(key: string): string;
|
|
10
|
+
};
|
|
11
|
+
tooltip: {
|
|
12
|
+
onHover(element: HTMLElement, text: string): void;
|
|
13
|
+
};
|
|
14
|
+
readOnly: {
|
|
15
|
+
isEnabled: boolean;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface BlockAPI {
|
|
20
|
+
holder: HTMLElement;
|
|
21
|
+
dispatchChange(): void;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -74,6 +74,9 @@ export default class ImageTool implements BlockTool {
|
|
|
74
74
|
*/
|
|
75
75
|
private _data: ImageToolData;
|
|
76
76
|
|
|
77
|
+
private userStore:any;
|
|
78
|
+
|
|
79
|
+
|
|
77
80
|
/**
|
|
78
81
|
* Caption enabled state
|
|
79
82
|
* Null when user has not toggled the caption tune
|
|
@@ -93,6 +96,8 @@ export default class ImageTool implements BlockTool {
|
|
|
93
96
|
constructor({ data, config, api, readOnly, block }: ImageToolConstructorOptions) {
|
|
94
97
|
this.api = api;
|
|
95
98
|
this.block = block;
|
|
99
|
+
this.userStore=config?.userStore;
|
|
100
|
+
|
|
96
101
|
/**
|
|
97
102
|
* Tool's initial config
|
|
98
103
|
*/
|
|
@@ -107,7 +112,9 @@ export default class ImageTool implements BlockTool {
|
|
|
107
112
|
uploader: config.uploader,
|
|
108
113
|
actions: config.actions,
|
|
109
114
|
features: config.features || {},
|
|
115
|
+
userStore: config.userStore,
|
|
110
116
|
};
|
|
117
|
+
|
|
111
118
|
|
|
112
119
|
/**
|
|
113
120
|
* Module for file uploading
|
|
@@ -129,6 +136,9 @@ export default class ImageTool implements BlockTool {
|
|
|
129
136
|
onPreview: (src: string) => {
|
|
130
137
|
this.ui.showPreloader(src);
|
|
131
138
|
},
|
|
139
|
+
noSelectedFile:()=>{
|
|
140
|
+
this.noSelectedFile();
|
|
141
|
+
}
|
|
132
142
|
});
|
|
133
143
|
},
|
|
134
144
|
readOnly,
|
|
@@ -149,6 +159,12 @@ export default class ImageTool implements BlockTool {
|
|
|
149
159
|
this.data = data;
|
|
150
160
|
}
|
|
151
161
|
|
|
162
|
+
private noSelectedFile(): void {
|
|
163
|
+
this.api.blocks.delete(this.api.blocks.getCurrentBlockIndex());
|
|
164
|
+
}
|
|
165
|
+
private deleteCurrentBlock() {
|
|
166
|
+
this.api.blocks.delete(this.api.blocks.getCurrentBlockIndex());
|
|
167
|
+
}
|
|
152
168
|
/**
|
|
153
169
|
* Notify core that read-only mode is supported
|
|
154
170
|
*/
|
|
@@ -328,9 +344,9 @@ export default class ImageTool implements BlockTool {
|
|
|
328
344
|
/**
|
|
329
345
|
* Paste URL of image into the Editor
|
|
330
346
|
*/
|
|
331
|
-
patterns: {
|
|
332
|
-
|
|
333
|
-
},
|
|
347
|
+
// patterns: {
|
|
348
|
+
// image: /https?:\/\/\S+\.(gif|jpe?g|png|webp)(\?[a-z0-9=]*)?$/i,
|
|
349
|
+
// },
|
|
334
350
|
|
|
335
351
|
/**
|
|
336
352
|
* Drag n drop file from into the Editor
|
|
@@ -365,12 +381,12 @@ export default class ImageTool implements BlockTool {
|
|
|
365
381
|
this.uploadUrl(image.src);
|
|
366
382
|
break;
|
|
367
383
|
}
|
|
368
|
-
case 'pattern': {
|
|
369
|
-
|
|
384
|
+
// case 'pattern': {
|
|
385
|
+
// const url = (event.detail as PatternPasteEventDetail).data;
|
|
370
386
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}
|
|
387
|
+
// this.uploadUrl(url);
|
|
388
|
+
// break;
|
|
389
|
+
// }
|
|
374
390
|
case 'file': {
|
|
375
391
|
const file = (event.detail as FilePasteEventDetail).file;
|
|
376
392
|
|
|
@@ -444,13 +460,16 @@ export default class ImageTool implements BlockTool {
|
|
|
444
460
|
*/
|
|
445
461
|
private uploadingFailed(errorText: string): void {
|
|
446
462
|
console.log('Image Tool: uploading failed because of', errorText);
|
|
447
|
-
|
|
448
|
-
|
|
463
|
+
let errorMessage = this.api.i18n.t('Couldn’t upload image. Please try another.');
|
|
464
|
+
if (errorText) {
|
|
465
|
+
errorMessage = this.api.i18n.t(errorText);
|
|
466
|
+
}
|
|
449
467
|
this.api.notifier.show({
|
|
450
|
-
message:
|
|
468
|
+
message: errorMessage,
|
|
451
469
|
style: 'error',
|
|
452
470
|
});
|
|
453
471
|
this.ui.hidePreloader();
|
|
472
|
+
this.deleteCurrentBlock();
|
|
454
473
|
}
|
|
455
474
|
|
|
456
475
|
/**
|
|
@@ -10,6 +10,7 @@ export interface UploadOptions {
|
|
|
10
10
|
* @returns void
|
|
11
11
|
*/
|
|
12
12
|
onPreview: (src: string) => void;
|
|
13
|
+
noSelectedFile:()=>void;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -134,6 +135,7 @@ export type FeaturesConfig = {
|
|
|
134
135
|
* @description Config supported by Tool
|
|
135
136
|
*/
|
|
136
137
|
export interface ImageConfig {
|
|
138
|
+
userStore?: any;
|
|
137
139
|
/**
|
|
138
140
|
* Endpoints for upload, whether using file or URL.
|
|
139
141
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IconPicture } from '
|
|
1
|
+
import { IconPicture } from '../../icons';
|
|
2
2
|
import { make } from './utils/dom';
|
|
3
3
|
import type { API } from '@editorjs/editorjs';
|
|
4
4
|
import type { ImageConfig } from './types/types';
|
|
@@ -178,8 +178,9 @@ export default class Ui {
|
|
|
178
178
|
public showPreloader(src: string): void {
|
|
179
179
|
this.nodes.imagePreloader.style.backgroundImage = `url(${src})`;
|
|
180
180
|
|
|
181
|
-
this.toggleStatus(UiState.Uploading);
|
|
181
|
+
//this.toggleStatus(UiState.Uploading);
|
|
182
182
|
}
|
|
183
|
+
|
|
183
184
|
|
|
184
185
|
/**
|
|
185
186
|
* Hide uploading preloader
|