<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. Ubuntu下查看SD卡设备名的几个方法

    Ubuntu下使用SD卡查询SD卡的设备文件名:sudo fdisk -leg:Disk /dev/sdb:14.9 GiB,15931539456 字节,31116288 个扇区单元:扇区 / 1 ...

  2. win7和linux下利用命令查看文件md5、sha1、sha256

    win7 certutil -hashfile <filename> MD5 certutil -hashfile <filename> SHA1 certutil -hash ...

  3. 未来-区块链-Aliyun:阿里云IoT - 所知不止于感知

    ylbtech-未来-区块链-Aliyun:阿里云IoT - 所知不止于感知 1.返回顶部 1. 基础产品接入 设备接入 设备管理 数据分析 应用开发 网络管理 边缘计算 设备认证 安全运营 AliO ...

  4. python selenium 爬取淘宝

    # -*- coding:utf-8 -*- # author : yesehngbao # time:2018/3/29 import re import pymongo from lxml imp ...

  5. IDEA右侧 Maven oracle依赖包有红色波浪线

    1\下载 ojdbc14-10.2.0.4.0.jar http://www.java2s.com/Code/Jar/o/Downloadojdbc14102040jar.htm 2.将ojdbc14 ...

  6. SQL 生日得到年龄

    CREATE FUNCTION ufn_hr_getagefrombirthday ( @birthday DATE, @now DATE =NULL ) ) BEGIN IF (@now IS NU ...

  7. Windows下通过pip安装PyTorch 0.4.0 import报错

    问题:通过pip安装PyTorch 0.4.0成功,但是import时报错. import torch  File "D:\Python\Python36\lib\site-packages ...

  8. spring事务[转]

    https://www.cnblogs.com/cnmenglang/p/6410848.html 先了解事务的7种传播属性: PROPAGATION_REQUIRED -- 支持当前事务,如果当前没 ...

  9. VMare Workstation 12 安装 AsteriskNow freePBX

    一.准备工作 VMware 12 安装好的电脑 AsteriskNow iso文件  官网地址 https://www.asterisk.org/downloads 本人提供相关分享:https:// ...

  10. 三、CSS样式——文本

    CSS文本 概念:CSS文本属性可定义文本外观 通过文本属性,可以改变文本的颜色.字符间距.对齐文本.装饰文本.对文本缩进 属性 描述 color 文本颜色 direction 文本方向 line-h ...