zydx-plus 1.33.384 → 1.33.385
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/package.json +1 -1
- package/src/components/editor2/src/editor.vue +180 -7
- package/src/components/editor2/src/image-size.js +23 -0
- package/src/components/editor2/src/img/center.png +0 -0
- package/src/components/editor2/src/img/left.png +0 -0
- package/src/components/editor2/src/img/right.png +0 -0
- package/src/index.js +1 -1
package/package.json
CHANGED
|
@@ -23,6 +23,45 @@
|
|
|
23
23
|
<div :style="{'border': (borderShow)? '1px solid #ccc': '0'}" v-if="editorShow">
|
|
24
24
|
<editor-content @paste.native.capture.prevent="preventPaste" ref="editorRef" class="editor" :editor="editor"
|
|
25
25
|
:style="heightStyleCont"/>
|
|
26
|
+
<bubble-menu
|
|
27
|
+
:editor="editor"
|
|
28
|
+
:tippy-options="{ duration: 100}"
|
|
29
|
+
:shouldShow="shouldShowFn"
|
|
30
|
+
v-if="editor"
|
|
31
|
+
v-show="showBubble"
|
|
32
|
+
>
|
|
33
|
+
<div class="bubbleMenu">
|
|
34
|
+
<div class="line">
|
|
35
|
+
<div class="label">图片缩放:</div>
|
|
36
|
+
<div class="percent">
|
|
37
|
+
<div class="symbol">%</div>
|
|
38
|
+
<input type="number" v-model="imgSizeVal" @input="changePercent" onfocus="this.select()" placeholder="10-100">
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
<div class="line">
|
|
42
|
+
<div class="label">图片位置:</div>
|
|
43
|
+
<div class="alignmentMode">
|
|
44
|
+
<div @click="changeAlign('left')">
|
|
45
|
+
<div class="imgBgc" :class="{imgBgcAction: editor.isActive({ textAlign: 'left' })}">
|
|
46
|
+
<img :src="alignmentModeLeft">
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
<div class="segmentation"></div>
|
|
50
|
+
<div @click="changeAlign('center')">
|
|
51
|
+
<div class="imgBgc" :class="{imgBgcAction: editor.isActive({ textAlign: 'center' })}">
|
|
52
|
+
<img :src="alignmentModeCenter">
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
<div class="segmentation"></div>
|
|
56
|
+
<div @click="changeAlign('right')">
|
|
57
|
+
<div class="imgBgc" :class="{imgBgcAction: editor.isActive({ textAlign: 'right' })}">
|
|
58
|
+
<img :src="alignmentModeRight">
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</bubble-menu>
|
|
26
65
|
</div>
|
|
27
66
|
<div v-if="voiceShows" class="speak"
|
|
28
67
|
@mousedown.stop="mousedown"
|
|
@@ -101,7 +140,7 @@
|
|
|
101
140
|
<script>
|
|
102
141
|
import Recorder from 'js-audio-recorder'
|
|
103
142
|
import {html2json, json2html} from '../../utils/html2json.js'
|
|
104
|
-
import {Editor, EditorContent} from '@tiptap/vue-3'
|
|
143
|
+
import {Editor, EditorContent, BubbleMenu} from '@tiptap/vue-3'
|
|
105
144
|
import StarterKit from '@tiptap/starter-kit'
|
|
106
145
|
import Image from '@tiptap/extension-image'
|
|
107
146
|
import TextAlign from '@tiptap/extension-text-align'
|
|
@@ -111,23 +150,32 @@ import textStyle from '@tiptap/extension-text-style'
|
|
|
111
150
|
import {sid} from "./sign-id";
|
|
112
151
|
import {FontSize} from "./font-size";
|
|
113
152
|
import {titleId} from "./title-id";
|
|
153
|
+
import {CustomImage} from "./image-size";
|
|
114
154
|
import {Contenteditable} from "./contenteditable";
|
|
115
155
|
import svgs from "./level";
|
|
116
156
|
import Mess from '../../tipBox/index'
|
|
157
|
+
import alignmentModeCenter from './img/center.png'
|
|
158
|
+
import alignmentModeLeft from './img/left.png'
|
|
159
|
+
import alignmentModeRight from './img/right.png'
|
|
117
160
|
|
|
118
161
|
export default {
|
|
119
162
|
name: 'zydx-xiao-editor',
|
|
120
163
|
components: {
|
|
121
164
|
EditorContent,
|
|
165
|
+
BubbleMenu,
|
|
122
166
|
svgs
|
|
123
167
|
},
|
|
124
168
|
data() {
|
|
125
169
|
return {
|
|
170
|
+
alignmentModeLeft: alignmentModeLeft,
|
|
171
|
+
alignmentModeCenter: alignmentModeCenter,
|
|
172
|
+
alignmentModeRight: alignmentModeRight,
|
|
126
173
|
uploadAttData: [],
|
|
127
174
|
editor: null,
|
|
128
175
|
heightStyle: {},
|
|
129
176
|
heightStyleCont: {},
|
|
130
177
|
voiceStatus: false,
|
|
178
|
+
showBubble: true,
|
|
131
179
|
recorder: null,
|
|
132
180
|
ws: null,
|
|
133
181
|
audioContext: null,
|
|
@@ -144,7 +192,11 @@ export default {
|
|
|
144
192
|
y: 0,
|
|
145
193
|
speech: {},
|
|
146
194
|
limits: false,
|
|
147
|
-
voiceShows: false
|
|
195
|
+
voiceShows: false,
|
|
196
|
+
lock: true,
|
|
197
|
+
editorRef: null,
|
|
198
|
+
imgSizeVal: '',
|
|
199
|
+
currentImgDom: {},
|
|
148
200
|
}
|
|
149
201
|
},
|
|
150
202
|
beforeUnmount() {
|
|
@@ -292,6 +344,7 @@ export default {
|
|
|
292
344
|
textStyle,
|
|
293
345
|
FontSize,
|
|
294
346
|
titleId,
|
|
347
|
+
CustomImage,
|
|
295
348
|
Contenteditable,
|
|
296
349
|
Color.configure({
|
|
297
350
|
types: ['textStyle'],
|
|
@@ -305,7 +358,7 @@ export default {
|
|
|
305
358
|
Image.configure({
|
|
306
359
|
inline: true,
|
|
307
360
|
HTMLAttributes: {
|
|
308
|
-
class:
|
|
361
|
+
class: `editor-img`,
|
|
309
362
|
}
|
|
310
363
|
}),
|
|
311
364
|
],
|
|
@@ -320,12 +373,12 @@ export default {
|
|
|
320
373
|
_this.close()
|
|
321
374
|
},
|
|
322
375
|
// 获取焦点
|
|
323
|
-
onFocus: () => {
|
|
324
|
-
|
|
376
|
+
onFocus: (e) => {
|
|
377
|
+
this.limits = true
|
|
325
378
|
},
|
|
326
379
|
})
|
|
327
380
|
document.addEventListener('keydown', function (e) {
|
|
328
|
-
|
|
381
|
+
if (e.keyCode === 8 || e.keyCode === 46) {
|
|
329
382
|
const sid = _this.editor.state.selection.$anchor.parent.attrs.sid
|
|
330
383
|
if (sid === 'prohibit') {
|
|
331
384
|
_this.editor.setEditable(false);
|
|
@@ -356,6 +409,36 @@ export default {
|
|
|
356
409
|
})
|
|
357
410
|
},
|
|
358
411
|
methods: {
|
|
412
|
+
// 下面三个方法是改变图片大小的方法
|
|
413
|
+
changeAlign(tag) {
|
|
414
|
+
this.editor.chain().setTextAlign(tag).run()
|
|
415
|
+
},
|
|
416
|
+
changePercent(e) {
|
|
417
|
+
if(parseInt(e.target.value) > 100) {
|
|
418
|
+
this.imgSizeVal = 100
|
|
419
|
+
this.editor.chain().setImageWidth('100%').run()
|
|
420
|
+
} else if(parseInt(e.target.value) < 10) {
|
|
421
|
+
} else {
|
|
422
|
+
if(this.lock) {
|
|
423
|
+
this.lock = false
|
|
424
|
+
setTimeout(() => {
|
|
425
|
+
this.editor.chain().setImageWidth(e.target.value + '%').focus().run()
|
|
426
|
+
this.lock = true
|
|
427
|
+
}, 500)
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
shouldShowFn({ editor, view, state, oldState, from, to }) {
|
|
432
|
+
this.$nextTick(() => {
|
|
433
|
+
this.showBubble = editor.isActive('image')
|
|
434
|
+
if(editor.isActive('image')) {
|
|
435
|
+
this.imgSizeVal = parseInt(this.editor.getAttributes('image').width)
|
|
436
|
+
} else {
|
|
437
|
+
this.imgSizeVal = ''
|
|
438
|
+
}
|
|
439
|
+
})
|
|
440
|
+
return editor.isActive('image')
|
|
441
|
+
},
|
|
359
442
|
speechDown(e) {
|
|
360
443
|
this.speech = {
|
|
361
444
|
x: e.clientX - e.offsetX,
|
|
@@ -636,13 +719,27 @@ export default {
|
|
|
636
719
|
imgHtml(data) { // 插入图片
|
|
637
720
|
const url = this.uploadImage.url + data
|
|
638
721
|
const cla = this.randomId()
|
|
639
|
-
const html = `<p class="imgCont ${cla}"><img src="${url}" alt="" /></p>`
|
|
722
|
+
const html = `<p class="imgCont ${cla}"><img src="${url}" alt="" width=""/></p>`
|
|
640
723
|
this.editor.chain().focus().insertContentAt(this.selection(), html).run()
|
|
641
724
|
if (this.selection() <= 6 && this.selection() > 2) this.selectionClass2(cla)
|
|
642
725
|
if (this.selectionClass(cla)) {
|
|
643
726
|
this.editor.chain().focus().insertContentAt(this.selection(), '<p></p>').run()
|
|
644
727
|
}
|
|
645
728
|
},
|
|
729
|
+
// selectImg(cla) {
|
|
730
|
+
// this.$nextTick(() => {
|
|
731
|
+
// const images = this.$refs.editorRef.rootEl.querySelectorAll('img');
|
|
732
|
+
// const claDom = this.$refs.editorRef.rootEl.getElementsByClassName(cla);
|
|
733
|
+
// claDom[0].insertAdjacentHTML('beforeend', `<p class="tips ${cla}" style="color: red">新的段落</p>`)
|
|
734
|
+
// images.forEach(img => {
|
|
735
|
+
// img.addEventListener('mouseenter', this.handleImageClick);
|
|
736
|
+
// img.addEventListener('mouseleave', this.handleImageClick);
|
|
737
|
+
// });
|
|
738
|
+
// });
|
|
739
|
+
// },
|
|
740
|
+
// handleImageClick(text) {
|
|
741
|
+
// console.log('mouseenter==>>>>',text)
|
|
742
|
+
// },
|
|
646
743
|
insertContent(v) {
|
|
647
744
|
for (let i = 0; i < v.length; i++) {
|
|
648
745
|
let html = json2html(v[i])
|
|
@@ -759,6 +856,18 @@ export default {
|
|
|
759
856
|
</script>
|
|
760
857
|
|
|
761
858
|
<style scoped>
|
|
859
|
+
:deep(.w_100) {
|
|
860
|
+
width: 100% !important;
|
|
861
|
+
}
|
|
862
|
+
:deep(.w_75 ){
|
|
863
|
+
width: 75% !important;
|
|
864
|
+
}
|
|
865
|
+
:deep(.w_50 ){
|
|
866
|
+
width: 50% !important;
|
|
867
|
+
}
|
|
868
|
+
:deep(.w_25 ){
|
|
869
|
+
width: 25% !important;
|
|
870
|
+
}
|
|
762
871
|
:deep(p[data-sid="prohibit"]) {
|
|
763
872
|
-webkit-user-select: none;
|
|
764
873
|
-moz-user-select: none;
|
|
@@ -988,4 +1097,68 @@ export default {
|
|
|
988
1097
|
line-height: 14px !important;
|
|
989
1098
|
}
|
|
990
1099
|
}
|
|
1100
|
+
.bubbleMenu {
|
|
1101
|
+
position: relative;
|
|
1102
|
+
padding: 15px;
|
|
1103
|
+
background-color: #fff;
|
|
1104
|
+
border-radius: 5px;
|
|
1105
|
+
box-shadow: 0 1px 6px #d2d2d2;
|
|
1106
|
+
}
|
|
1107
|
+
.line {
|
|
1108
|
+
display: flex;
|
|
1109
|
+
align-items: center;
|
|
1110
|
+
padding-bottom: 10px;
|
|
1111
|
+
}
|
|
1112
|
+
.line:last-child {
|
|
1113
|
+
padding-bottom: 0
|
|
1114
|
+
}
|
|
1115
|
+
.percent {
|
|
1116
|
+
position: relative;
|
|
1117
|
+
}
|
|
1118
|
+
.percent input{
|
|
1119
|
+
border-radius: 4px;
|
|
1120
|
+
width: 68px;
|
|
1121
|
+
}
|
|
1122
|
+
.percent input::-webkit-outer-spin-button,
|
|
1123
|
+
.percent input::-webkit-inner-spin-button {
|
|
1124
|
+
-webkit-appearance: none !important;
|
|
1125
|
+
}
|
|
1126
|
+
.percent input[type='number']{
|
|
1127
|
+
-moz-appearance: textfield;
|
|
1128
|
+
box-shadow: none;
|
|
1129
|
+
border: 1px solid #8c939d;
|
|
1130
|
+
padding: 5px 15px 5px 5px;
|
|
1131
|
+
}
|
|
1132
|
+
.symbol {
|
|
1133
|
+
position: absolute;
|
|
1134
|
+
right: 5px;
|
|
1135
|
+
top: 5px
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
.alignmentMode {
|
|
1139
|
+
display: flex;
|
|
1140
|
+
justify-content: center;
|
|
1141
|
+
align-items: center;
|
|
1142
|
+
}
|
|
1143
|
+
.segmentation {
|
|
1144
|
+
height: 13px;
|
|
1145
|
+
width: 1px;
|
|
1146
|
+
margin: 0 5px;
|
|
1147
|
+
background-color: #565656;
|
|
1148
|
+
}
|
|
1149
|
+
.imgBgc {
|
|
1150
|
+
border-radius: 3px;
|
|
1151
|
+
width: 20px;
|
|
1152
|
+
height: 20px;
|
|
1153
|
+
background-color: #CCCCCC;
|
|
1154
|
+
}
|
|
1155
|
+
.imgBgcAction {
|
|
1156
|
+
background-color: #2A82E4;
|
|
1157
|
+
}
|
|
1158
|
+
.imgBgc > img {
|
|
1159
|
+
padding: 1px;
|
|
1160
|
+
width: 100%;
|
|
1161
|
+
height: 100%;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
991
1164
|
</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Image from '@tiptap/extension-image'
|
|
2
|
+
|
|
3
|
+
export const CustomImage = Image.extend({
|
|
4
|
+
addCommands() {
|
|
5
|
+
return {
|
|
6
|
+
setImageWidth: width => ({commands}) => {
|
|
7
|
+
return commands.updateAttributes('image', {width: width})
|
|
8
|
+
},
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
addAttributes() {
|
|
12
|
+
return {
|
|
13
|
+
width: {
|
|
14
|
+
default: '',
|
|
15
|
+
renderHTML: attributes => {
|
|
16
|
+
return {
|
|
17
|
+
style: `width: ${attributes.width}`,
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
})
|
|
Binary file
|
|
Binary file
|
|
Binary file
|