【升级】mp-html from 2.4.1 to 2.5.0
parent
039f05ce23
commit
7fc548e161
|
@ -5,7 +5,7 @@
|
|||
navbar="inner"
|
||||
>
|
||||
<!-- 覆盖头部导航栏背景颜色 -->
|
||||
<div class="page-bg" :style="{ height: sys_navBar + 'px' }"></div>
|
||||
<view class="page-bg" :style="{ height: sys_navBar + 'px' }"></view>
|
||||
<!-- 聊天区域 -->
|
||||
<MessageList ref="messageListRef">
|
||||
<template #bottom>
|
||||
|
|
|
@ -186,6 +186,9 @@
|
|||
可通过 [issue](https://github.com/jin-yufeng/mp-html/issues/new/choose) 、插件问答或发送邮件到 [mp_html@126.com](mailto:mp_html@126.com) 提问,不建议在评论区提问(不方便回复)
|
||||
提问请严格按照 [issue 模板](https://github.com/jin-yufeng/mp-html/issues/new/choose) ,描述清楚使用环境、`html` 内容或可复现的 `demo` 项目以及复现方式,对于 **描述不清**、**无法复现** 或重复的问题将不予回复
|
||||
|
||||
欢迎加入 `QQ` 交流群:`699734691`
|
||||
欢迎加入 `QQ` 交流群:
|
||||
群1(已满):`699734691`
|
||||
群2(已满):`778239129`
|
||||
群3:`960265313`
|
||||
|
||||
查看 [问题反馈](https://jin-yufeng.gitee.io/mp-html/#/question/feedback) 了解更多
|
||||
|
|
|
@ -1,3 +1,32 @@
|
|||
## v2.5.0(2024-04-22)
|
||||
1. `U` `play` 事件增加返回 `src` 等信息 [详细](https://github.com/jin-yufeng/mp-html/issues/526)
|
||||
2. `U` `preview-img` 属性支持设置为 `all` 开启 `base64` 图片预览 [详细](https://github.com/jin-yufeng/mp-html/issues/536)
|
||||
3. `U` `editable` 插件增加简易模式(点击文字直接编辑)
|
||||
4. `U` `latex` 插件支持块级公式 [详细](https://github.com/jin-yufeng/mp-html/issues/582)
|
||||
5. `F` 修复了表格部分情况下背景丢失的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/587)
|
||||
6. `F` 修复了部分 `svg` 无法显示的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/591)
|
||||
7. `F` 修复了 `h5` 和 `app` 端部分情况下样式无法识别的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/518)
|
||||
8. `F` 修复了 `latex` 插件部分情况下显示不正确的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/580)
|
||||
9. `F` 修复了 `editable` 插件表格无法删除的问题
|
||||
10. `F` 修复了 `editable` 插件 `vue3` `h5` 端点击图片报错的问题
|
||||
11. `F` 修复了 `editable` 插件点击表格没有菜单栏的问题
|
||||
## v2.4.3(2024-01-21)
|
||||
1. `A` 增加 [card](https://jin-yufeng.gitee.io/mp-html/#/advanced/plugin#card) 插件 [详细](https://github.com/jin-yufeng/mp-html/pull/533) by [@whoooami](https://github.com/whoooami)
|
||||
2. `F` 修复了 `svg` 中包含 `foreignobject` 可能不显示的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/523)
|
||||
3. `F` 修复了合并单元格的表格部分情况下显示不正确的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/561)
|
||||
4. `F` 修复了 `img` 标签设置 `object-fit` 无效的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/567)
|
||||
5. `F` 修复了 `latex` 插件公式会换行的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/540)
|
||||
6. `F` 修复了 `editable` 和 `audio` 插件共用时点击 `audio` 无法编辑的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/529) by [@whoooami](https://github.com/whoooami)
|
||||
7. `F` 修复了微信小程序部分情况下图片会报错 `replace of undefined` 的问题
|
||||
8. `F` 修复了快手小程序图片不显示的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/571)
|
||||
## v2.4.2(2023-05-14)
|
||||
1. `A` `editable` 插件支持修改文字颜色 [详细](https://github.com/jin-yufeng/mp-html/issues/254)
|
||||
2. `F` 修复了 `svg` 中有 `style` 不生效的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/505)
|
||||
3. `F` 修复了使用旧版编译器可能报错 `Bad attr nodes` 的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/472)
|
||||
4. `F` 修复了 `app` 端可能出现无法读取 `lazyLoad` 的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/513)
|
||||
5. `F` 修复了 `editable` 插件在点击换图时未拼接 `domain` 的问题 [详细](https://github.com/jin-yufeng/mp-html/pull/497) by [@TwoKe945](https://github.com/TwoKe945)
|
||||
6. `F` 修复了 `latex` 插件部分情况下不显示的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/515)
|
||||
7. `F` 修复了 `editable` 插件点击音视频时其他标签框不消失的问题
|
||||
## v2.4.1(2022-12-25)
|
||||
1. `F` 修复了没有图片时 `ready` 事件可能不触发的问题
|
||||
2. `F` 修复了加载过程中可能出现 `Root label not found` 错误的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/470)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
<script>
|
||||
/**
|
||||
* mp-html v2.4.1
|
||||
* mp-html v2.5.0
|
||||
* @description 富文本组件
|
||||
* @tutorial https://github.com/jin-yufeng/mp-html
|
||||
* @property {String} container-style 容器的样式
|
||||
|
|
|
@ -10,13 +10,16 @@
|
|||
<!-- #endif -->
|
||||
<!-- #ifndef H5 || (APP-PLUS && VUE2) -->
|
||||
<!-- 表格中的图片,使用 rich-text 防止大小不正确 -->
|
||||
<rich-text v-if="n.name==='img'&&n.t" :style="'display:'+n.t" :nodes="'<img class=\'_img\' style=\''+n.attrs.style+'\' src=\''+n.attrs.src+'\'>'" :data-i="i" @tap.stop="imgTap" />
|
||||
<rich-text v-if="n.name==='img'&&n.t" :style="'display:'+n.t" :nodes="[{attrs:{style:n.attrs.style||'',src:n.attrs.src},name:'img'}]" :data-i="i" @tap.stop="imgTap" />
|
||||
<!-- #endif -->
|
||||
<!-- #ifndef H5 || APP-PLUS -->
|
||||
<image v-else-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl[i]===-1?'display:none;':'')+'width:'+(ctrl[i]||1)+'px;height:1px;'+n.attrs.style" :src="n.attrs.src" :mode="!n.h?'widthFix':(!n.w?'heightFix':'')" :lazy-load="opts[0]" :webp="n.webp" :show-menu-by-longpress="opts[3]&&!n.attrs.ignore" :image-menu-prevent="!opts[3]||n.attrs.ignore" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" />
|
||||
<!-- #ifndef H5 || APP-PLUS || MP-KUAISHOU -->
|
||||
<image v-else-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl[i]===-1?'display:none;':'')+'width:'+(ctrl[i]||1)+'px;height:1px;'+n.attrs.style" :src="n.attrs.src" :mode="!n.h?'widthFix':(!n.w?'heightFix':(n.m||'scaleToFill'))" :lazy-load="opts[0]" :webp="n.webp" :show-menu-by-longpress="opts[3]&&!n.attrs.ignore" :image-menu-prevent="!opts[3]||n.attrs.ignore" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" />
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef MP-KUAISHOU -->
|
||||
<image v-else-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl[i]===-1?'display:none;':'')+n.attrs.style" :src="n.attrs.src" :lazy-load="opts[0]" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap"></image>
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef APP-PLUS && VUE3 -->
|
||||
<image v-else-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl[i]===-1?'display:none;':'')+'width:'+(ctrl[i]||1)+'px;'+n.attrs.style" :src="n.attrs.src||(ctrl.load?n.attrs['data-src']:'')" :mode="!n.h?'widthFix':(!n.w?'heightFix':'')" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" />
|
||||
<image v-else-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl[i]===-1?'display:none;':'')+'width:'+(ctrl[i]||1)+'px;'+n.attrs.style" :src="n.attrs.src||(ctrl.load?n.attrs['data-src']:'')" :mode="!n.h?'widthFix':(!n.w?'heightFix':(n.m||''))" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" />
|
||||
<!-- #endif -->
|
||||
<!-- 文本 -->
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
|
@ -67,7 +70,7 @@
|
|||
<rich-text v-else-if="!n.c&&!handler.isInline(n.name, n.attrs.style)" :id="n.attrs.id" :style="n.f" :user-select="opts[4]" :nodes="[n]" />
|
||||
<!-- #endif -->
|
||||
<!-- #ifndef H5 || ((MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE2) -->
|
||||
<rich-text v-else-if="!n.c" :id="n.attrs.id" :style="n.f+';display:inline'" :preview="false" :selectable="opts[4]" :user-select="opts[4]" :nodes="[n]" />
|
||||
<rich-text v-else-if="!n.c" :id="n.attrs.id" :style="'display:inline;'+n.f" :preview="false" :selectable="opts[4]" :user-select="opts[4]" :nodes="[n]" />
|
||||
<!-- #endif -->
|
||||
<!-- 继续递归 -->
|
||||
<view v-else-if="n.c===2" :id="n.attrs.id" :class="'_block _'+n.name+' '+n.attrs.class" :style="n.f+';'+n.attrs.style">
|
||||
|
@ -184,7 +187,15 @@ export default {
|
|||
* @param {Event} e
|
||||
*/
|
||||
play (e) {
|
||||
this.root.$emit('play')
|
||||
const i = e.currentTarget.dataset.i
|
||||
const node = this.childs[i]
|
||||
this.root.$emit('play', {
|
||||
source: node.name,
|
||||
attrs: {
|
||||
...node.attrs,
|
||||
src: node.src[this.ctrl[i] || 0]
|
||||
}
|
||||
})
|
||||
// #ifndef APP-PLUS
|
||||
if (this.root.pauseVideo) {
|
||||
let flag = false
|
||||
|
@ -299,7 +310,7 @@ export default {
|
|||
* @description 检查是否所有图片加载完毕
|
||||
*/
|
||||
checkReady () {
|
||||
if (!this.root.lazyLoad) {
|
||||
if (this.root && !this.root.lazyLoad) {
|
||||
this.root._unloadimgs -= 1
|
||||
if (!this.root._unloadimgs) {
|
||||
setTimeout(() => {
|
||||
|
|
|
@ -71,7 +71,8 @@ const config = {
|
|||
viewbox: 'viewBox',
|
||||
attributename: 'attributeName',
|
||||
repeatcount: 'repeatCount',
|
||||
repeatdur: 'repeatDur'
|
||||
repeatdur: 'repeatDur',
|
||||
foreignobject: 'foreignObject'
|
||||
}
|
||||
}
|
||||
const tagSelector={}
|
||||
|
@ -321,6 +322,7 @@ Parser.prototype.onTagName = function (name) {
|
|||
this.tagName = this.xml ? name : name.toLowerCase()
|
||||
if (this.tagName === 'svg') {
|
||||
this.xml = (this.xml || 0) + 1 // svg 标签内大小写敏感
|
||||
config.ignoreTags.style = undefined // svg 标签内 style 可用
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -331,6 +333,12 @@ Parser.prototype.onTagName = function (name) {
|
|||
*/
|
||||
Parser.prototype.onAttrName = function (name) {
|
||||
name = this.xml ? name : name.toLowerCase()
|
||||
// #ifdef (VUE3 && (H5 || APP-PLUS)) || APP-PLUS-NVUE
|
||||
if (name.includes('?') || name.includes(';')) {
|
||||
this.attrName = undefined
|
||||
return
|
||||
}
|
||||
// #endif
|
||||
if (name.substr(0, 5) === 'data-') {
|
||||
if (name === 'data-src' && !this.attrs.src) {
|
||||
// data-src 自动转为 src
|
||||
|
@ -457,7 +465,7 @@ Parser.prototype.onOpenTag = function (selfClose) {
|
|||
node.webp = 'T'
|
||||
}
|
||||
// data url 图片如果没有设置 original-src 默认为不可预览的小图片
|
||||
if (attrs.src.includes('data:') && !attrs['original-src']) {
|
||||
if (attrs.src.includes('data:') && this.options.previewImg !== 'all' && !attrs['original-src']) {
|
||||
attrs.ignore = 'T'
|
||||
}
|
||||
if (!attrs.ignore || node.webp || attrs.src.includes('cloud://')) {
|
||||
|
@ -551,6 +559,13 @@ Parser.prototype.onOpenTag = function (selfClose) {
|
|||
if (!isNaN(parseInt(styleObj.height)) && (!styleObj.height.includes('%') || (parent && (parent.attrs.style || '').includes('height')))) {
|
||||
node.h = 'T'
|
||||
}
|
||||
if (node.w && node.h && styleObj['object-fit']) {
|
||||
if (styleObj['object-fit'] === 'contain') {
|
||||
node.m = 'aspectFit'
|
||||
} else if (styleObj['object-fit'] === 'cover') {
|
||||
node.m = 'aspectFill'
|
||||
}
|
||||
}
|
||||
} else if (node.name === 'svg') {
|
||||
siblings.push(node)
|
||||
this.stack.push(node)
|
||||
|
@ -677,11 +692,19 @@ Parser.prototype.popNode = function () {
|
|||
return
|
||||
}
|
||||
const name = config.svgDict[node.name] || node.name
|
||||
if (name === 'foreignObject') {
|
||||
for (const child of (node.children || [])) {
|
||||
if (child.attrs && !child.attrs.xmlns) {
|
||||
child.attrs.xmlns = 'http://www.w3.org/1999/xhtml'
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
src += '<' + name
|
||||
for (const item in node.attrs) {
|
||||
const val = node.attrs[item]
|
||||
if (val) {
|
||||
src += ` ${config.svgDict[item] || item}="${val}"`
|
||||
src += ` ${config.svgDict[item] || item}="${val.replace(/"/g, '')}"`
|
||||
}
|
||||
}
|
||||
if (!node.children) {
|
||||
|
@ -703,6 +726,7 @@ Parser.prototype.popNode = function () {
|
|||
node.children = undefined
|
||||
// #endif
|
||||
this.xml = false
|
||||
config.ignoreTags.style = true
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -839,6 +863,10 @@ Parser.prototype.popNode = function () {
|
|||
if (node.flag && node.c) {
|
||||
// 有 colspan 或 rowspan 且含有链接的表格通过 grid 布局实现
|
||||
styleObj.display = 'grid'
|
||||
if (styleObj['border-collapse'] === 'collapse') {
|
||||
styleObj['border-collapse'] = undefined
|
||||
spacing = 0
|
||||
}
|
||||
if (spacing) {
|
||||
styleObj['grid-gap'] = spacing + 'px'
|
||||
styleObj.padding = spacing + 'px'
|
||||
|
@ -856,6 +884,23 @@ Parser.prototype.popNode = function () {
|
|||
for (let i = 0; i < nodes.length; i++) {
|
||||
if (nodes[i].name === 'tr') {
|
||||
trList.push(nodes[i])
|
||||
} else if (nodes[i].name === 'colgroup') {
|
||||
let colI = 1
|
||||
for (const col of (nodes[i].children || [])) {
|
||||
if (col.name === 'col') {
|
||||
const style = col.attrs.style || ''
|
||||
const start = style.indexOf('width') ? style.indexOf(';width') : 0
|
||||
// 提取出宽度
|
||||
if (start !== -1) {
|
||||
let end = style.indexOf(';', start + 6)
|
||||
if (end === -1) {
|
||||
end = style.length
|
||||
}
|
||||
width[colI] = style.substring(start ? start + 7 : 6, end)
|
||||
}
|
||||
colI += 1
|
||||
}
|
||||
}
|
||||
} else {
|
||||
traversal(nodes[i].children || [])
|
||||
}
|
||||
|
@ -982,11 +1027,26 @@ Parser.prototype.popNode = function () {
|
|||
node.children = [table]
|
||||
attrs = table.attrs
|
||||
}
|
||||
} else if ((node.name === 'tbody' || node.name === 'tr') && node.flag && node.c) {
|
||||
node.flag = undefined;
|
||||
(function traversal (nodes) {
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
if (nodes[i].name === 'td') {
|
||||
// 颜色样式设置给单元格避免丢失
|
||||
for (const style of ['color', 'background', 'background-color']) {
|
||||
if (styleObj[style]) {
|
||||
nodes[i].attrs.style = style + ':' + styleObj[style] + ';' + (nodes[i].attrs.style || '')
|
||||
}
|
||||
}
|
||||
} else {
|
||||
traversal(nodes[i].children || [])
|
||||
}
|
||||
}
|
||||
})(children)
|
||||
} else if ((node.name === 'td' || node.name === 'th') && (attrs.colspan || attrs.rowspan)) {
|
||||
for (let i = this.stack.length; i--;) {
|
||||
if (this.stack[i].name === 'table') {
|
||||
if (this.stack[i].name === 'table' || this.stack[i].name === 'tbody' || this.stack[i].name === 'tr') {
|
||||
this.stack[i].flag = 1 // 指示含有合并单元格
|
||||
break
|
||||
}
|
||||
}
|
||||
} else if (node.name === 'ruby') {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "mp-html",
|
||||
"displayName": "mp-html 富文本组件【全端支持,支持编辑、latex等扩展】",
|
||||
"version": "v2.4.1",
|
||||
"version": "v2.5.0",
|
||||
"description": "一个强大的富文本组件,高效轻量,功能丰富",
|
||||
"keywords": [
|
||||
"富文本",
|
||||
|
|
Loading…
Reference in New Issue