@ebl-vue/editor-full 1.0.13 → 1.1.2
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 +712 -584
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
- package/src/components/Editor/Editor.vue +52 -24
- package/src/index.ts +8 -2
- 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 +6 -1
- package/types/plugins/index.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ebl-vue/editor-full",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "lrj525@sina.com",
|
|
6
6
|
"description": "结构化编辑器",
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
"url": "ssh://git@git.jianguodata.com:9082/lirujin/ebl-vue.git"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@codexteam/ajax": "^4.2.0",
|
|
43
42
|
"@editorjs/caret": "^1.0.3",
|
|
44
43
|
"@editorjs/dom": "^1.0.1",
|
|
45
44
|
"axios": "^1.13.2",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="ebl-editor" id="holder">
|
|
3
|
-
<div class="ce-block__content ebl-editor-title-wrap">
|
|
3
|
+
<!-- <div class="ce-block__content ebl-editor-title-wrap">
|
|
4
4
|
<input type="text" v-model="title" placeholder="请输入标题" class="ebl-editor-title-input"></input>
|
|
5
|
-
</div>
|
|
6
|
-
<div class="ce-block__content ebl-editor-time-wrap">
|
|
5
|
+
</div> -->
|
|
6
|
+
<!-- <div class="ce-block__content ebl-editor-time-wrap">
|
|
7
7
|
<span class="ebl-editor-time">最后修改时间:{{ lastUpdateTime }}</span>
|
|
8
|
-
</div>
|
|
9
|
-
<button @click="
|
|
8
|
+
</div> -->
|
|
9
|
+
<button @click="validate">保存</button>
|
|
10
10
|
|
|
11
11
|
</div>
|
|
12
12
|
</template>
|
|
@@ -42,9 +42,7 @@ import Underline from "../../plugins/underline";
|
|
|
42
42
|
import InlineCode from "../../plugins/inline-code";
|
|
43
43
|
import Table from '../../plugins/table';
|
|
44
44
|
import ImageTool from "../../plugins/imageTool";
|
|
45
|
-
import
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
import {ImageToolTune } from "../../plugins/imageResizeCrop";
|
|
48
46
|
|
|
49
47
|
const EblEditorSettings: IEblEditorSettings | undefined = inject("EblEditorSettings");
|
|
50
48
|
|
|
@@ -60,17 +58,14 @@ let emits = defineEmits(["onReady", "onChange"]);
|
|
|
60
58
|
interface Props {
|
|
61
59
|
readOnly: boolean,
|
|
62
60
|
placeholder: string,
|
|
63
|
-
title: string,
|
|
64
|
-
lastUpdateTime: string,
|
|
65
61
|
data: OutputData,
|
|
66
|
-
locale:any
|
|
62
|
+
locale: any,
|
|
63
|
+
userStore:any
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
const props = withDefaults(defineProps<Props>(), {
|
|
70
67
|
readOnly: false,
|
|
71
68
|
placeholder: "Enter something",
|
|
72
|
-
title: "",
|
|
73
|
-
lastUpdateTime: "",
|
|
74
69
|
data: ()=>({
|
|
75
70
|
blocks: []
|
|
76
71
|
}),
|
|
@@ -78,8 +73,9 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
78
73
|
});
|
|
79
74
|
|
|
80
75
|
|
|
81
|
-
|
|
76
|
+
|
|
82
77
|
let editor: EditorJS | null = null;
|
|
78
|
+
const tunes = ['indent', 'blockAlignment'];
|
|
83
79
|
onMounted(() => {
|
|
84
80
|
const editorData=toRaw(props.data);
|
|
85
81
|
editor = new EditorJS({
|
|
@@ -87,7 +83,7 @@ onMounted(() => {
|
|
|
87
83
|
autofocus: true,
|
|
88
84
|
defaultBlock: 'paragraph',
|
|
89
85
|
placeholder: props.placeholder,
|
|
90
|
-
tunes:
|
|
86
|
+
tunes: tunes,
|
|
91
87
|
tools: {
|
|
92
88
|
inlineCode: InlineCode,
|
|
93
89
|
underline: Underline,
|
|
@@ -167,7 +163,10 @@ onMounted(() => {
|
|
|
167
163
|
image: {
|
|
168
164
|
class: ImageTool,
|
|
169
165
|
inlineToolbar: true,
|
|
166
|
+
tunes: tunes.concat(['imageResize']),
|
|
170
167
|
config: {
|
|
168
|
+
types:".png,.jpeg,.jpg,.gif,.webp",
|
|
169
|
+
userStore: props.userStore,
|
|
171
170
|
endpoints: {
|
|
172
171
|
byFile: EblEditorSettings?.fileUploadEndpoint,
|
|
173
172
|
byUrl: EblEditorSettings?.urlUploadEndpoint
|
|
@@ -182,6 +181,14 @@ onMounted(() => {
|
|
|
182
181
|
|
|
183
182
|
}
|
|
184
183
|
},
|
|
184
|
+
imageResize: {
|
|
185
|
+
class: ImageToolTune ,
|
|
186
|
+
config: {
|
|
187
|
+
resize: true,
|
|
188
|
+
crop: false
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
|
|
185
192
|
|
|
186
193
|
|
|
187
194
|
},
|
|
@@ -217,17 +224,38 @@ onUnmounted(() => {
|
|
|
217
224
|
}
|
|
218
225
|
});
|
|
219
226
|
|
|
227
|
+
/**
|
|
228
|
+
* 验证是否为空 */
|
|
229
|
+
function validate() {
|
|
230
|
+
return new Promise((resolve, reject) => {
|
|
231
|
+
if (editor !== null) {
|
|
232
|
+
editor.save().then((outputData: OutputData) => {
|
|
233
|
+
if (outputData.blocks.length > 0) {
|
|
234
|
+
return resolve(true);
|
|
220
235
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
236
|
+
}
|
|
237
|
+
return resolve(false);
|
|
238
|
+
});
|
|
239
|
+
} else {
|
|
240
|
+
return resolve(false);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
function getData() {
|
|
245
|
+
return new Promise((resolve, reject) => {
|
|
246
|
+
if (editor !== null) {
|
|
247
|
+
editor.save().then((outputData: OutputData) => {
|
|
248
|
+
return resolve(outputData);
|
|
249
|
+
});
|
|
250
|
+
} else {
|
|
251
|
+
return resolve(null);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
230
254
|
}
|
|
231
255
|
|
|
256
|
+
defineExpose({
|
|
257
|
+
validate,
|
|
258
|
+
getData,
|
|
259
|
+
});
|
|
232
260
|
</script>
|
|
233
261
|
<style scoped></style>
|
package/src/index.ts
CHANGED
|
@@ -4,9 +4,15 @@ import './style.css'
|
|
|
4
4
|
import { createInstaller } from './installer'
|
|
5
5
|
import Components from './components';
|
|
6
6
|
import zhCn from './i18n/zh-cn';
|
|
7
|
+
import type { OutputData } from '@ebl-vue/editorjs';
|
|
8
|
+
import Editor from './components/Editor/Editor.vue';
|
|
7
9
|
const installer = createInstaller(Components)
|
|
8
10
|
export const install = installer.install
|
|
9
11
|
export const version = installer.version
|
|
10
12
|
export default installer;
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
zhCn,
|
|
16
|
+
Editor as EblEditor
|
|
17
|
+
};
|
|
18
|
+
export type { OutputData };
|