<template>
<div class="wrap">
<div class="vm-editor">
<div class="wm-editor-menu">
<div class="vm-editor-button">
<span class="button">
<img src="../assets/images/img_icon.png" @click="change" alt="" srcset="">
</span>
<div class="vm-editor-dropdown" v-show="showInput">
<div class="add-img">
Add Image
<input type="file" accept="image/gif, image/jpeg, image/png" ref="file" @change="handleFileChange">
</div>
</div>
</div>
</div>
<div class="vm-editor-content" contenteditable="true" v-html="html" @input="onDivInput($event)" @focus="lock=true" @blur="lock=false"></div>
</div>
</div> </template> <script>
export default {
props: ['data'],
data() {
return {
html: this.data,
lock: false,
showInput: false
}
},
watch: {
'data'() {
if (!this.lock) {
this.html = this.data;
}
}
},
mounted() { },
methods: {
onDivInput: function(e) {
// this.html = e.target.innerHTML;
this.$emit('upload', e.target.innerHTML)
},
handleFileChange: function(e) {
this.showInput = false
var dom = this.$refs.file.files[0]
console.log(dom)
if(!dom){
return false;
}
var size = Math.floor(dom.size / 1024);
if (size > 10240) {
// 这里可以加个文件大小控制
this.$alert('请选择小于10M图片', '提示', {
confirmButtonText: '确定'
});
return false
}
var _this = this;
var params = new FormData();
params.append('file', dom);
this.$postImg('/upload/image',params).then(res => {
if(res.code == 0) {
document.execCommand('insertImage', false, res.data)
}else{ }
}).catch(err => {
console.log(err)
})
},
change: function() {
this.showInput = !this.showInput
}
}
}
</script> <style scoped>
.wrap .vm-editor{
background-color: #fff;
border-radius: 4px;
border: 1px solid #eeeff1;
min-width: 100px;
width: 95%;
overflow: hidden;
}
.wrap .vm-editor-content{
outline: 0;
height: calc(100% - 40px);
height: 160px;
text-align: left;
padding: 15px;
font-size: 16px;
overflow-y: scroll;
}
.wrap .wm-editor-menu{
width: 100%;
box-sizing: border-box;
display: flex;
height: 40px;
align-items: center;
padding: 0 15px;
background-color: #fafbfc;
border-bottom: 1px solid #eeeff1;
position: relative;
}
.wrap .vm-editor-button{
position: relative;
border-radius: 4px;
outline: 0;
cursor: pointer;
background-color: transparent;
border: none;
display: flex;
justify-content: center;
align-items: center;
margin: 0 5px;
padding: 0;
}
.vm-editor-button:first-child{
margin-left:0
}
.wrap .vm-editor-button span.button:hover{
background-color:#eee
}
.wrap .button{
width: 24px;
height: 24px;
display: flex;
justify-content: center;
align-items: center;
}
.wrap .button img{
width: 16px;
height: 16px;
}
.wrap .vm-editor-dropdown{
position: absolute;
background: #fff;
left: 0;
top: 25px;
border-radius: 4px;
border: 1px solid #eeeff1;
box-shadow: 0 0 4px rgba(0,0,0,.05);
}
.wrap .add-img{
width: 100px;
height: 30px;
line-height: 30px;
font-size: 14px;
text-align: center;
position: relative;
cursor: pointer;
}
.wrap .add-img input{
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
opacity: 0;
} /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
::-webkit-scrollbar
{
width: 4px;
height: 4px;
background-color: #F5F5F5;
} /*定义滚动条轨道 内阴影+圆角*/
::-webkit-scrollbar-track
{
border-radius: 3px;
background-color: #FFF;
} /*定义滑块 内阴影+圆角*/
::-webkit-scrollbar-thumb
{
border-radius: 3px;
background-color: #eeeff1;
}
</style>

VmEditor 组件 个人后台管理系统

<template>
<div class="wrap">
<div class="vm-editor">
<div class="wm-editor-menu">
<div class="vm-editor-button">
<span class="button">
<img src="../assets/images/img_icon.png" @click="change" alt="" srcset="">
</span>
<div class="vm-editor-dropdown" v-show="showInput">
<div class="add-img">
Add Image
<input type="file" accept="image/gif, image/jpeg, image/png" ref="file" @change="handleFileChange">
</div>
</div>
</div>
</div>
<div class="vm-editor-content" contenteditable="true" v-html="html" @input="onDivInput($event)" @focus="lock=true" @blur="lock=false"></div>
</div>
</div>
 
</template>
<script>
export default {
props: ['data'],
data() {
return {
html: this.data,
lock: false,
showInput: false
}
},
watch: {
'data'() {
if (!this.lock) {
this.html = this.data;
}
}
},
mounted() {
 
},
methods: {
onDivInput: function(e) {
// this.html = e.target.innerHTML;
this.$emit('upload', e.target.innerHTML)
},
handleFileChange: function(e) {
this.showInput = false
var dom = this.$refs.file.files[]
console.log(dom)
if(!dom){
return false;
}
var size = Math.floor(dom.size / );
if (size > ) {
// 这里可以加个文件大小控制
this.$alert('请选择小于10M图片', '提示', {
confirmButtonText: '确定'
});
return false
}
var _this = this;
var params = new FormData();
params.append('file', dom);
this.$postImg('/upload/image',params).then(res => {
if(res.code == ) {
document.execCommand('insertImage', false, res.data)
}else{
 
}
}).catch(err => {
console.log(err)
})
},
change: function() {
this.showInput = !this.showInput
}
}
}
</script>
<style scoped>
.wrap .vm-editor{
background-color: #fff;
border-radius: 4px;
border: 1px solid #eeeff1;
min-width: 100px;
width: 95%;
overflow: hidden;
}
.wrap .vm-editor-content{
outline: ;
height: calc(100% - 40px);
height: 160px;
text-align: left;
padding: 15px;
font-size: 16px;
overflow-y: scroll;
}
.wrap .wm-editor-menu{
width: 100%;
box-sizing: border-box;
display: flex;
height: 40px;
align-items: center;
padding: 15px;
background-color: #fafbfc;
border-bottom: 1px solid #eeeff1;
position: relative;
}
.wrap .vm-editor-button{
position: relative;
border-radius: 4px;
outline: ;
cursor: pointer;
background-color: transparent;
border: none;
display: flex;
justify-content: center;
align-items: center;
margin: 5px;
padding: ;
}
.vm-editor-button:first-child{
margin-left:
}
.wrap .vm-editor-button span.button:hover{
background-color:#eee
}
.wrap .button{
width: 24px;
height: 24px;
display: flex;
justify-content: center;
align-items: center;
}
.wrap .button img{
width: 16px;
height: 16px;
}
.wrap .vm-editor-dropdown{
position: absolute;
background: #fff;
left: ;
top: 25px;
border-radius: 4px;
border: 1px solid #eeeff1;
box-shadow: 4px rgba(,,,.05);
}
.wrap .add-img{
width: 100px;
height: 30px;
line-height: 30px;
font-size: 14px;
text-align: center;
position: relative;
cursor: pointer;
}
.wrap .add-img input{
width: 100%;
height: 100%;
position: absolute;
left: ;
top: ;
opacity: ;
}
/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
::-webkit-scrollbar
{
width: 4px;
height: 4px;
background-color: #F5F5F5;
}
 
/*定义滚动条轨道 内阴影+圆角*/
::-webkit-scrollbar-track
{
border-radius: 3px;
background-color: #FFF;
}
 
/*定义滑块 内阴影+圆角*/
::-webkit-scrollbar-thumb
{
border-radius: 3px;
background-color: #eeeff1;
}
</style>

后台编辑器组件VmEditor的更多相关文章

  1. dede5.7 GBK 在php5.4环境下 后台编辑器无法显示文章内容

    问题的原因是:是htmlspecialchars,PHP 5.4后GBK编码下默认不支持中文,转换后内容为空,UTF-8编码没有任何问题.   解决方法如下: 在\include\ckeditor\c ...

  2. iwms后台编辑器无法粘贴word格式的解决方法

    iwms后台编辑器用的是tiny_mce,默认会自动过滤word粘贴中的格式,以减小数据库的占用,但在word中辛苦做的字体和格式都不见了,可采用下方法关闭编辑器的自动清除格式功能. 编辑文件:\ti ...

  3. 让织梦CMS的后台编辑器支持优酷视频

    最近做了一些视频教程传到优酷网站上,但我想引入这些视频教程到我的网站,在发表时我发现织梦CMS自带的编辑器又不直接支持优酷等视频网站的引用.所以为了方便教程的发布,特意在网站搜索到本篇教程,详细讲解如 ...

  4. dede后台编辑器更改

    1.下载百度开发的UEditor编辑器(对应版本): 2. 解压下载的zip文件: 3.将解压后得到的文件夹拷贝到您网站目录下的include文件夹下并改名为ueditor: 4.将inc文件夹里边的 ...

  5. 基于bootstrap的文本编辑器组件:Summernote

    Summernote官网地址 :https://summernote.org/ 这是官网的一个例子: <!DOCTYPE html> <html lang="en" ...

  6. 基于 React-draft-wysiwyg 实现的 react 富文本编辑器组件 开箱即用

    工作中遇到了一个需要做图文详情 的富文本编辑的需求, 于是基于 React-draft-wysiwyg 实现了一个 纯组件, 目前支持 常规文本输入 外部链接图片 以及本地上传图片, 由于是纯组件, ...

  7. 将dedecms织梦后台编辑器ckeditor更换为kindeditor,并高亮显示代码

    1.下载kindeditor,并解压到kindeditor目录,把kindeditor目录复制到dede的include目录下(ps:修改kindeditor-all-min.js.lang文件夹下z ...

  8. 120行代码打造.netcore生产力工具-小而美的后台异步组件

    相信绝大部分开发者都接触过用户注册的流程,通常情况下大概的流程如下所示: 接收用户提交注册信息 持久化注册信息(数据库+redis) 发送注册成功短信(邮件) 写操作日志(可选) 伪代码如下: pub ...

  9. 后台系统组件:一丶bootstrap table

    http://www.cnblogs.com/landeanfen/p/4976838.html (bootstrap table) http://www.cnblogs.com/landeanfen ...

随机推荐

  1. NetCore部署到Linux服务器+Supervisor的步骤及过程中踩过的坑

    本文作备忘使用 服务器配置: 下面是所有操作的具体步骤: 1.安装nginx   参考 1.1 添加源:默认情况Centos7中没有Nginx源,最近Nginx官网提供了Centos的源地址. sud ...

  2. 模板语言 自定义函数simple_tag

    模板语言自带的一些处理函数:通过管道符来处理 帮助方法:{{ item.event_start|date:"Y-m-d H:i:s"}}  转换成日期时间型{{ bio|trunc ...

  3. Linux shell 重定向学习笔记

    在了解重定向之前,我们先来看看linux 的文件描述符. linux文件描述符:可以理解为linux跟踪打开文件,而分配的一个数字,这个数字有点类似c语言操作文件时候的句柄,通过句柄就可以实现文件的读 ...

  4. Convert.ChangeType不能处理Nullable类型的解决办法(转)

    https://www.cnblogs.com/patrickyu/p/3211115.html 在做一个ORMapping功能的时候发现,Convert.ChangeType不能处理nullable ...

  5. C#中基于GDI+(Graphics)图像处理系列

    https://blog.csdn.net/lhtzbj12/article/details/54024821

  6. python 中增加css样式的三种方式

    增加css样式的三种方式: <!DOCTYPE html> <html lang="en"> <head> <meta charset=& ...

  7. 填坑:Java 中的日期转换

    我们之前讨论过时间,在Java 中有一些方法会出现横线?比如Date 过期方法. 参考文章:知识点:java一些方法会有横线?以Date 过期方法为例 Java中的日期和时间处理方法 Date类(官方 ...

  8. 软件测试:lab1.Junit and Eclemma

    软件测试:lab1.Junit and Eclemma Task: Install Junit(4.12), Hamcrest(1.3) with Eclipse Install Eclemma wi ...

  9. linux最小化安装后的初始化

    Linux 最小化安装以后 linux会缺失很多功能,需要我们预先安装一些软件服务,例如mysql(mariadb),gcc等等. 但是最小化的mysql甚至不提供ifconfig,也没有wget命令 ...

  10. MyBatis学习总结-MyBatis快速入门的系列教程

    MyBatis学习总结-MyBatis快速入门的系列教程 [MyBatis]MyBatis 使用教程 [MyBatis]MyBatis XML配置 [MyBatis]MyBatis XML映射文件 [ ...