Commit 37465db3 by zhangquan

保存封装前代码

1 parent f3b24ee3
<template>
<div class="upload-wrap">
<label v-if="name" class="label" for="">{{name}}</label>
<div class="add-img" :style="defaultStyle">
<i class="el-icon-plus add"></i>
<p>上传照片</p>
</div>
</div>
</template>
<script>
export default {
name: 'Upload',
props: {
name: {
type: String,
default: ''
},
url: {
type: String,
default: ''
},
key: {
type: String,
default: ''
},
defaultStyle: {
type: Object,
default: ()=>{
return {}
}
}
},
data() {
return {
}
},
methods: {
}
}
</script>
<style lang="scss" scoped>
.upload-wrap{
cursor: pointer;
.label{
display: inline-block;
vertical-align: top;
width: 154px;
height: 20px;
font-size: 14px;
color: #333333;
text-align: right;
line-height: 20px;
box-sizing: border-box;
}
.add-img{
box-sizing: border-box;
width: 104px;
height: 104px;
background: #0000000a;
border: 1px dashed #00000026;
border-radius: 4px;
display: inline-flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: #666666;
.add {
font-size: 18px;
}
p {
height: 32px;
line-height: 32px;
}
}
}
</style>
\ No newline at end of file \ No newline at end of file
...@@ -7,7 +7,7 @@ class Label extends Parchment.Embed { ...@@ -7,7 +7,7 @@ class Label extends Parchment.Embed {
const node = super.create(value); const node = super.create(value);
node.innerText = value; node.innerText = value;
node.contentEditable = 'false'; node.contentEditable = 'false';
this._addRemovalButton(node); // this._addRemovalButton(node);
return node; return node;
} }
...@@ -16,7 +16,6 @@ class Label extends Parchment.Embed { ...@@ -16,7 +16,6 @@ class Label extends Parchment.Embed {
} }
static _addRemovalButton(node) { static _addRemovalButton(node) {
console.log(123)
const button = document.createElement('button'); const button = document.createElement('button');
button.innerText = 'x'; button.innerText = 'x';
button.onclick = () => node.remove(); button.onclick = () => node.remove();
...@@ -25,7 +24,7 @@ class Label extends Parchment.Embed { ...@@ -25,7 +24,7 @@ class Label extends Parchment.Embed {
// Extra span forces the cursor to the end of the label, otherwise it appears inside the removal button // Extra span forces the cursor to the end of the label, otherwise it appears inside the removal button
const span = document.createElement('span'); const span = document.createElement('span');
span.innerText = ' '; span.innerText = '';
node.appendChild(span); node.appendChild(span);
} }
} }
......
...@@ -12,15 +12,16 @@ ...@@ -12,15 +12,16 @@
<FoldFrame name="合同介绍区域"> <FoldFrame name="合同介绍区域">
<div class="bar-content"> <div class="bar-content">
<label for="" class="content-label">标题和介绍:</label> <label for="" class="content-label">标题和介绍:</label>
<quill-editor ref="myQuillEditor" class="quill" v-model="serviceContent" :options="editorOption"></quill-editor> <div class="editor">
<div> <quill-editor ref="myQuillEditor" class="quill" v-model="serviceContent" :options="editorOption"></quill-editor>
<i class="el-icon-circle-plus"></i>购买条件 <div class="extend-bar">
<i class="el-icon-circle-plus extend-icon" @click="insertContent">购买条件</i>
</div>
</div> </div>
</div> </div>
</FoldFrame> </FoldFrame>
</div> </div>
<div class="preview-area"> <div class="preview-area">
<el-button @click="insertContent">dasdsa</el-button>
<div v-html="serviceContent"></div> <div v-html="serviceContent"></div>
</div> </div>
...@@ -60,11 +61,6 @@ export default { ...@@ -60,11 +61,6 @@ export default {
// ['clean'] // ['clean']
// ['link', 'image'] // ['link', 'image']
], ],
// handlers: {
// label:()=>{
// this.insertContent()
// }
// }
} }
} }
}, },
...@@ -76,30 +72,9 @@ export default { ...@@ -76,30 +72,9 @@ export default {
methods: { methods: {
insertContent(){ insertContent(){
// // 文本内容
// const text = 'hello'
// // 获取编辑器对象
// let quill = this.$refs.myQuillEditor.quill;
// // 获取编辑器光标位置
// let index = quill.selection.savedRange.index;
// // 插入文本至光标位置,
// // quill.insertText(index, text);
// // quill.clipboard.dangerouslyPasteHTML(index, `<span>&nbsp;</span><span style="color: '#26a2ff'">${text}</span><span>&nbsp;</span>`);
// quill.clipboard.dangerouslyPasteHTML(5, '&nbsp;<b>World</b>');
// // 重新计算index
// index+=text.length
// // 移动光标至文本后面
// quill.setSelection(index);
let quill = this.$refs.myQuillEditor.quill; let quill = this.$refs.myQuillEditor.quill;
let length = quill.selection.savedRange.index; let length = quill.selection.savedRange.index;
quill.insertEmbed(length, 'label', 132); quill.insertEmbed(length, 'label', 132);
// 调整光标到最后
quill.setSelection(length + 1); quill.setSelection(length + 1);
} }
...@@ -128,6 +103,42 @@ export default { ...@@ -128,6 +103,42 @@ export default {
text-align: right; text-align: right;
line-height: 20px; line-height: 20px;
} }
.editor{
display: inline-block;
background-color: #fff;
.quill{
background-color: #fff;
display: inline-block;
border-color: #E5E5E5;
/deep/ .ql-toolbar.ql-snow, /deep/ .ql-container.ql-snow{
border-color: #E5E5E5;
}
/deep/ .ql-label{
color: #26a2ff;
}
}
.extend-bar{
width: 100%;
height: 40px;
padding: 0 20px;
line-height: 40px;
margin-top: -1px;
background: #FAFBFE;
border: 1px solid #E5E5E5;
box-sizing: border-box;
border-radius: 0 0 4px 4px;
border-top: none;
.extend-icon{
cursor: pointer;
&::before{
// font-size: 16px;
margin-right: 5px;
}
font-size: 14px;
color: #666;
}
}
}
.upload-wrap{ .upload-wrap{
display: inline-block; display: inline-block;
} }
...@@ -139,10 +150,6 @@ export default { ...@@ -139,10 +150,6 @@ export default {
vertical-align: bottom; vertical-align: bottom;
margin-left: 10px; margin-left: 10px;
} }
.quill{
background-color: #fff;
display: inline-block;
}
} }
} }
} }
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
}, },
data() { data() {
return { return {
isExpansion: false isExpansion: true
} }
}, },
methods: { methods: {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!