后台编辑器组件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[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 组件 个人后台管理系统
后台编辑器组件VmEditor的更多相关文章
- dede5.7 GBK 在php5.4环境下 后台编辑器无法显示文章内容
问题的原因是:是htmlspecialchars,PHP 5.4后GBK编码下默认不支持中文,转换后内容为空,UTF-8编码没有任何问题. 解决方法如下: 在\include\ckeditor\c ...
- iwms后台编辑器无法粘贴word格式的解决方法
iwms后台编辑器用的是tiny_mce,默认会自动过滤word粘贴中的格式,以减小数据库的占用,但在word中辛苦做的字体和格式都不见了,可采用下方法关闭编辑器的自动清除格式功能. 编辑文件:\ti ...
- 让织梦CMS的后台编辑器支持优酷视频
最近做了一些视频教程传到优酷网站上,但我想引入这些视频教程到我的网站,在发表时我发现织梦CMS自带的编辑器又不直接支持优酷等视频网站的引用.所以为了方便教程的发布,特意在网站搜索到本篇教程,详细讲解如 ...
- dede后台编辑器更改
1.下载百度开发的UEditor编辑器(对应版本): 2. 解压下载的zip文件: 3.将解压后得到的文件夹拷贝到您网站目录下的include文件夹下并改名为ueditor: 4.将inc文件夹里边的 ...
- 基于bootstrap的文本编辑器组件:Summernote
Summernote官网地址 :https://summernote.org/ 这是官网的一个例子: <!DOCTYPE html> <html lang="en" ...
- 基于 React-draft-wysiwyg 实现的 react 富文本编辑器组件 开箱即用
工作中遇到了一个需要做图文详情 的富文本编辑的需求, 于是基于 React-draft-wysiwyg 实现了一个 纯组件, 目前支持 常规文本输入 外部链接图片 以及本地上传图片, 由于是纯组件, ...
- 将dedecms织梦后台编辑器ckeditor更换为kindeditor,并高亮显示代码
1.下载kindeditor,并解压到kindeditor目录,把kindeditor目录复制到dede的include目录下(ps:修改kindeditor-all-min.js.lang文件夹下z ...
- 120行代码打造.netcore生产力工具-小而美的后台异步组件
相信绝大部分开发者都接触过用户注册的流程,通常情况下大概的流程如下所示: 接收用户提交注册信息 持久化注册信息(数据库+redis) 发送注册成功短信(邮件) 写操作日志(可选) 伪代码如下: pub ...
- 后台系统组件:一丶bootstrap table
http://www.cnblogs.com/landeanfen/p/4976838.html (bootstrap table) http://www.cnblogs.com/landeanfen ...
随机推荐
- Teamviewer远程控制
设置无人值守的固定密码,不使用随机码进行远程控制访问 设置好密码之后,以后只要通过Teamviewer生成的固定ID,再加上你设置的密码就可以随时进行远程访问了,而不需要使用生成的随机码.
- Redis 5.0.3集群部署
参考文章 https://blog.csdn.net/yyTomson/article/details/85783753 https://www.cnblogs.com/zy-303/p/102731 ...
- 动态调用WebService(传对象返回接受对象)
基础属性//客户端代理服务命名空间,可以设置成需要的值. string ns = string.Format("WindowsForms"); private Assembly a ...
- declaration may not appear after executable statement in block
keil 编译时出现 declaration may not appear after executable statement in block,找到keil工程对应的函数 定义的地方出现在了赋值的 ...
- python列表生成式
在Python编程中,list列表应用的比较广泛,而列表生成式是一个非常强大但是使用很简单的功能. 比如要生成1到100的数组列表[1,2,3,4......,97,98,99,100],可以使用li ...
- 7.7 wordcnt.c 程序
wordcnt.c 程序 #include <stdio.h> #include <ctype.h> // 为isspace() 函数提供原型 #include <std ...
- Java定时器小实例
有时候,我们需要在Java中定义一个定时器来轮询操作,比如每隔一段时间查询.删除数据库中的某些数据等,下面记录一下一种简单实现方式 1,首先新建一个类,类中编写方法来实现业务操作 public cla ...
- Java代码片段——向文件末尾添加内容
BufferedWriter out = null; try { out = new BufferedWriter(new FileWriter(”filename”, true)); out.wri ...
- VS2017 ASP.NET MVC 5.0 开部署问题汇总
1[SqlException (0x80131904): 拒绝了对对象 '****' (数据库 '***',架构 'dbo')的 EXECUTE 权限.] “/”应用程序中的服务器错误. SQL 20 ...
- Ubuntu 16.04.3 LTS 安装 MongoDB
1.安装Ubuntu16.04 运行sudo apt-get install mongodb安装Mongodb 如果没有MongoDB库,则运行sudo apt-get update更新库. 2.运行 ...