优化markd解析换行;优化单选复选的子节点过滤
parent
a4bfa07649
commit
c7e8da83e9
|
@ -26,7 +26,8 @@ export default class CheckboxGroup {
|
|||
|
||||
_updateChildrenStat(checkAll) {
|
||||
Array.from(this.children).forEach(it => {
|
||||
if (it.tagName === 'WC-CHECKBOX' && it.root) {
|
||||
if (it.tagName === 'WC-CHECKBOX') {
|
||||
if (it.root) {
|
||||
if (checkAll) {
|
||||
it.disabled = this.disabled
|
||||
it.readOnly = this.readOnly
|
||||
|
@ -38,6 +39,9 @@ export default class CheckboxGroup {
|
|||
it.checked = false
|
||||
}
|
||||
}
|
||||
} else {
|
||||
it.remove()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -167,7 +167,8 @@ export default class Dropdown {
|
|||
|
||||
_updateChildrenStat() {
|
||||
Array.from(this.children).forEach(it => {
|
||||
if (it.tagName === 'WC-OPTION' && it.root) {
|
||||
if (it.tagName === 'WC-OPTION') {
|
||||
if (it.root) {
|
||||
if (it.value === this.props.value) {
|
||||
it.setAttribute('active', '')
|
||||
this.__INPUT__.value = it.label || it.textContent
|
||||
|
@ -175,6 +176,9 @@ export default class Dropdown {
|
|||
it.removeAttribute('active')
|
||||
}
|
||||
}
|
||||
} else {
|
||||
it.remove()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,8 @@ export default class RadioGroup {
|
|||
|
||||
_updateChildrenStat(checkAll) {
|
||||
Array.from(this.children).forEach(it => {
|
||||
if (it.tagName === 'WC-RADIO' && it.root) {
|
||||
if (it.tagName === 'WC-RADIO') {
|
||||
if (it.root) {
|
||||
if (checkAll) {
|
||||
it.disabled = this.disabled
|
||||
it.readOnly = this.readOnly
|
||||
|
@ -38,6 +39,9 @@ export default class RadioGroup {
|
|||
it.checked = false
|
||||
}
|
||||
}
|
||||
} else {
|
||||
it.remove()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,11 @@ const INLINE = {
|
|||
qlist: /((<blockquote class="md\-quote">)*?)([\+\-\*]|\d+\.) (.*)/ // 引用中的列表
|
||||
}
|
||||
|
||||
const ATTR_BR_SYMBOL = '⨨☇'
|
||||
const NODE_BR_SYMBOL = '⨨⤶'
|
||||
const ATTR_BR_EXP = new RegExp(ATTR_BR_SYMBOL, 'g')
|
||||
const NODE_BR_EXP = new RegExp(NODE_BR_SYMBOL, 'g')
|
||||
|
||||
const Helper = {
|
||||
// 是否分割线
|
||||
isHr(str) {
|
||||
|
@ -165,20 +170,20 @@ function fixed(str) {
|
|||
.replace(/\u2424/g, '\n')
|
||||
.replace(TAG_RE, (m, name, attr) => {
|
||||
// 标签内的换行, 转为一组特殊字符, 方便后面还原
|
||||
return `<${name + attr.replace(/\n/g, '⨨☇')}>`
|
||||
return `<${name + attr.replace(/\n/g, ATTR_BR_SYMBOL)}>`
|
||||
})
|
||||
.replace(BLOCK_RE, (m, tag, attr, txt) => {
|
||||
return `<${tag + attr}>${txt.replace(/\n/g, '⨨⤶')}</${tag}>`
|
||||
return `<${tag + attr}>${txt.replace(/\n/g, NODE_BR_SYMBOL)}</${tag}>`
|
||||
})
|
||||
.replace(CODEBLOCK_RE, (m, lang, txt) => {
|
||||
// 还原换行
|
||||
let rollback = txt.replace(/⨨⤶/g, '\n').replace(/⨨☇/g, '\n')
|
||||
let rollback = txt.replace(NODE_BR_EXP, '\n').replace(ATTR_BR_EXP, '\n')
|
||||
return '```' + lang + rollback + '```'
|
||||
})
|
||||
.replace(BLOCK_RE, (m, tag, attr, txt) => {
|
||||
return `<${tag + attr.replace(/(⨨☇)+/g, ' ')}>${txt
|
||||
.replace(/⨨⤶/g, '\n')
|
||||
.replace(/(⨨☇)+/g, ' ')}</${tag}>`
|
||||
return `<${tag + attr.replace(ATTR_BR_EXP, ' ')}>${txt
|
||||
.replace(NODE_BR_EXP, '\n')
|
||||
.replace(ATTR_BR_EXP, ' ')}</${tag}>`
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue