更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -1,8 +1,3 @@
|
||||
/**
|
||||
* 富文本表格操作与行内样式/属性注入工具
|
||||
* 注入 border="1"、cellpadding="8"、cellspacing="0" 以及 style 属性
|
||||
* 保证在 H5、App-plus 原生 editor、小程序以及 rich-text 中均能拥有清晰的表格边框与样式
|
||||
*/
|
||||
|
||||
const TABLE_STYLE = 'border-collapse: collapse; width: 100%; border: 1px solid #dcdfe6; margin: 12px 0; table-layout: auto;'
|
||||
const TABLE_CLASS = 'rich-table note-rich-editor-table'
|
||||
@@ -10,15 +5,10 @@ const TR_STYLE = 'border-bottom: 1px solid #ebeef5;'
|
||||
const TH_STYLE = 'border: 1px solid #dcdfe6; background-color: #f5f7fa; color: #303133; font-weight: 600; padding: 8px 12px; font-size: 14px; text-align: left; min-width: 44px; word-break: break-word;'
|
||||
const TD_STYLE = 'border: 1px solid #dcdfe6; background-color: #ffffff; color: #303133; padding: 8px 12px; font-size: 14px; vertical-align: top; word-break: break-word; min-width: 44px;'
|
||||
|
||||
/**
|
||||
* 给 HTML 字符串中的所有 table/tr/th/td 注入高优先级的行内样式与原生 HTML 边框属性
|
||||
* (双重保障,即使 Quill 或原生组件重置了部分 CSS,border="1" 仍能强制渲染出边框)
|
||||
*/
|
||||
export function injectTableInlineStyles(html) {
|
||||
if (!html || typeof html !== 'string') return ''
|
||||
let res = html
|
||||
|
||||
// 注入 table 属性与样式
|
||||
res = res.replace(/<table(\s+[^>]*)?>/gi, (match, attrs = '') => {
|
||||
let cleanAttrs = attrs
|
||||
cleanAttrs = cleanAttrs.replace(/\s+(border|cellspacing|cellpadding)\s*=\s*["'][^"']*["']/gi, '')
|
||||
@@ -35,7 +25,6 @@ export function injectTableInlineStyles(html) {
|
||||
return `<table border="1" cellpadding="8" cellspacing="0"${cleanAttrs}>`
|
||||
})
|
||||
|
||||
// 使用 class 定位表体,避免小程序端不支持 tbody 标签选择器
|
||||
res = res.replace(/<tbody(\s+[^>]*)?>/gi, (match, attrs = '') => {
|
||||
if (/class\s*=\s*["']/i.test(attrs)) {
|
||||
return `<tbody${attrs.replace(/class\s*=\s*["']([^"']*)["']/i, (m, value) => `class="${value} rich-table__body"`)}>`
|
||||
@@ -43,7 +32,6 @@ export function injectTableInlineStyles(html) {
|
||||
return `<tbody class="rich-table__body"${attrs}>`
|
||||
})
|
||||
|
||||
// 注入 tr 样式
|
||||
res = res.replace(/<tr(\s+[^>]*)?>/gi, (match, attrs = '') => {
|
||||
if (/style\s*=\s*["']/i.test(attrs)) {
|
||||
return `<tr${attrs.replace(/style\s*=\s*["']([^"']*)["']/i, (m, s) => `style="${s}; ${TR_STYLE}"`)}>`
|
||||
@@ -51,7 +39,6 @@ export function injectTableInlineStyles(html) {
|
||||
return `<tr style="${TR_STYLE}"${attrs}>`
|
||||
})
|
||||
|
||||
// 注入 th 属性与样式
|
||||
res = res.replace(/<th(\s+[^>]*)?>/gi, (match, attrs = '') => {
|
||||
let cleanAttrs = attrs.replace(/\s+border\s*=\s*["'][^"']*["']/gi, '')
|
||||
if (/style\s*=\s*["']/i.test(cleanAttrs)) {
|
||||
@@ -62,7 +49,6 @@ export function injectTableInlineStyles(html) {
|
||||
return `<th border="1"${cleanAttrs}>`
|
||||
})
|
||||
|
||||
// 注入 td 属性与样式
|
||||
res = res.replace(/<td(\s+[^>]*)?>/gi, (match, attrs = '') => {
|
||||
let cleanAttrs = attrs.replace(/\s+border\s*=\s*["'][^"']*["']/gi, '')
|
||||
if (/style\s*=\s*["']/i.test(cleanAttrs)) {
|
||||
|
||||
Reference in new issue
Block a user