富文本样式修改 标签

vue3.xxx

:deep(.el-scrollbar__view){
  padding-bottom: 50px!important;
}

vue2.xxx

/deep/.vue-head{
}

>>>

::deep .vue-head{
}
content.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, function (match, capture) {         
  console.log(capture);
});
//upfile/2006/0115/1590997979404056911.jpg
//upfile/2006/0209/1591061098210007976.jpg
//upfile/2006/0209/1591061098200080612.jpg
if(res.matter.indexOf('img')!=-1){ //判断img是否存在
  var result = content.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, function (match,capture) {
  console.log(capture);
  return '<img src=' + app.host.substr(0,app.host.length-1) + capture+' style="max-width:100%;height:auto;display:block;margin:10px 0;"/>';
        });
        console.log(result);
 
}
//<p>看看文章里的图片上传后能不能加载出来</p><p><img src=host地址/upfile/2006/0115/1590997979404056911.jpg style="max-width:100%;height:auto;display:block;margin:10px 0;"/></p><p>多张图片多张图片多张图片多张图片多张图片多张图片多张图片多张图片</p><p>多张图片多张图片多张图片多张图片多张图片多张图片多张图片</p><p>多张图片多张图片多张图片多张图片多张图片多张图片</p><p>多张图片多张图片多张图片多张图片多张图片</p><p>多张图片多张图片多张图片</p><p><img src=host地址/upfile/2006/0209/1591061098210007976.jpg style="max-width:100%;height:auto;display:block;margin:10px 0;"/></p><p><img src=host地址/upfile/2006/0209/1591061098200080612.jpg style="max-width:100%;height:auto;display:block;margin:10px 0;"/></p><p><br/></p>

获取a标签href内容

<a.+?href=\"(.+?)\".*>(.+)</a>
单独href : <a.+?href=\"(.+?)\".*>
单独连接文字:>(.+)</a>

获取a标签内容

res.result.match(/<a\b[^>]+\bhref="([^"]*)"[^>]*>([\s\S]*?)<\/a>/g)
/*获取字符串a标签中的href方法*/
var str = document.querySeletor("a");
function getLinkUrl(str){
    var a = str;
    var arrLink = [];
    a.replace(/<a [^>]*href=['"]([^'"]+)[^>]*/gi,function(match,capture){
        arrLink.push(capture)
    });
    if (arrLink != null && arrLink.length > 0) {
        return arrLink;
    }
}
getLinkUrl(str)

获取 >请求

  item.replace(/>([\s\S]*?)<\/a>/gi, function (match, capture) {
            // console.log(match,capture)
            hreft.push(capture)
          });

获取href的内容

  item.replace(/<a\b[^>]+\bhref="([^"]*)"[^>]*>/gi, function (match, capture) {
            // console.log(match,capture)
            hrefl.push(capture)
          });

1.利用全局样式进行限制(在基础样式里添加)

img{
min-max:100%
}

2.利用正则表达式进行正则匹配

         //默认heigh属性置零
         richtext.replace(/<img([\s\w"-=\/\.:;]+)((?:(height="[^"]+")))/ig, '<img$1')
         //默认的width属性置零 
         .replace(/<img([\s\w"-=\/\.:;]+)((?:(width="[^"]+")))/ig, '<img$1')
         //将style属性置零
         .replace(/<img([\s\w"-=\/\.:;]+)((?:(style="[^"]+")))/ig, '<img$1')
         //将alt属性置零
         .replace(/<img([\s\w"-=\/\.:;]+)((?:(alt="[^"]+")))/ig, '<img$1')
         //设置属性
         .replace(/<img([\s\w"-=\/\.:;]+)/ig, '<img$1 style="width: 100%;"');
         //p标签的行内样式重置
         .replace(/<p([\s\w"=\/\.:;]+)((?:(style="[^"]+")))/ig, '<p')
         .replace(/<p>/ig, '<p style="font-size: 15Px; line-height: 25Px;">')
         //保留其他属性 对style进行覆盖
         replace(/<img([\s\w"-=\/\.:;]+)((?:(style="[^"]+")))/ig, '<img$1 style="max-width:100%;"')

3.对于vue还可以使用深度选择器

 <div class="rich-text" v-html="reiHtext"></div>
 
 <style>
	.rich-text>>> img {
	  width: 100%;
	}
</style>

方法1:

function setContent(str) {
str = str.replace(/<\/?[^>]*>/g,''); //去除HTML tag
str.value = str.replace(/[ | ]*\n/g,'\n'); //去除行尾空白
str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
return str;
}

方法1优化:

function removeHTMLTag(str) {
    str = str.replace(/<\/?[^>]*>/g,''); //去除HTML tag
    str = str.replace(/[ | ]*\n/g,'\n'); //去除行尾空白
    str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
    str=str.replace(/&nbsp;/ig,'');//去掉&nbsp;
    return str;
}

方法2:

//去除html标签
function deleteHtmlTag(str){
 str = str.replace(/<[^>]+>|&[^>]+;/g,"").trim();//去掉所有的html标签和&nbsp;之类的特殊符合
 return str;
}

方法3:

description.replace(/<(?!img).*?>/g, "");  
 
//如果保留img,p标签,则为:
description.replace(/<(?!img|p|/p).*?>/g, ""); 
如有错误,欢迎指出。

参考:https://blog.csdn.net/M82_A1/article/details/90412673

1.全局css 写入 插入后生效
2.正则匹配 修改 (加壳 修改)
3.使用富文wxParse-master

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
本在线编辑器由Itmouse编写 http://www.itmouse.com.cn 请使用时如果有问题请联系[email protected] 环境: vs2008 .net 3.5 window xp IE 6.0 IE 7.0 vs2005在测试环境中呈现及上传功能可能会出现错误,但发布到IIS后一切正常 使用:在工具箱中添加本控件后和其它控件一样使用。如果对添加工具箱控件不熟者,请自己去查看相关信息 功能: 字体、字号、背景色、文字颜色、加粗、下划线、斜体、删除线、下标、上标、左对齐,右对齐、居中,剪取、复制、粘贴、删除、撤消、恢复、编号列表、项目列表、添加缩进、减少缩进、清除格式、全选、取消全选、对象绝对对齐、对象上移一层,对象下移一层、上传图片、上传Falsh、上传文件、插入表格及表格修改、插入HTML标签、添加链接、段开链接 控件属事及事件 属性: EditMode:编辑器模式,默认为Design (Design-编辑模式 Html-代码模式) EditingAreaWidth:编辑区宽度,默认为600px EditingAreaHeight:编辑区高度,默认为300px Text:编辑内容 DisableFileUpload:是否关闭文件上传功能,默认为false(true-关闭文件上传功能 false-不关闭文件上传功能) ImageFileType:图片文件上传类型列表,格式见属性说明 FileType:普通文件上传类型列表,格式见属性说明 ImageFileSavePath:图片文件上传目录,格式见属性说明 FileSavePath:普通文件上传目录,格式见属性说明 EditorStyle:编辑器外观样式选择,目前只实现了officeXP样式 事件: Submit:点击控件中的保存按钮时的触发的事件 事件方法中的e中可以取到控件编辑的内容 如: protected void ItmouseEditor1_Submit1(object sender, itmouse.com.cn.ItmouseEditor.SubmitEventArgs e) { Response.Write(e.Text); }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

web修理工

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值