优化markd解析换行;优化单选复选的子节点过滤
parent
a4bfa07649
commit
c7e8da83e9
|
@ -26,17 +26,21 @@ export default class CheckboxGroup {
|
||||||
|
|
||||||
_updateChildrenStat(checkAll) {
|
_updateChildrenStat(checkAll) {
|
||||||
Array.from(this.children).forEach(it => {
|
Array.from(this.children).forEach(it => {
|
||||||
if (it.tagName === 'WC-CHECKBOX' && it.root) {
|
if (it.tagName === 'WC-CHECKBOX') {
|
||||||
if (checkAll) {
|
if (it.root) {
|
||||||
it.disabled = this.disabled
|
if (checkAll) {
|
||||||
it.readOnly = this.readOnly
|
it.disabled = this.disabled
|
||||||
}
|
it.readOnly = this.readOnly
|
||||||
|
}
|
||||||
|
|
||||||
if (this.value.includes(it.value)) {
|
if (this.value.includes(it.value)) {
|
||||||
it.checked = true
|
it.checked = true
|
||||||
} else {
|
} else {
|
||||||
it.checked = false
|
it.checked = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
it.remove()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,13 +167,17 @@ export default class Dropdown {
|
||||||
|
|
||||||
_updateChildrenStat() {
|
_updateChildrenStat() {
|
||||||
Array.from(this.children).forEach(it => {
|
Array.from(this.children).forEach(it => {
|
||||||
if (it.tagName === 'WC-OPTION' && it.root) {
|
if (it.tagName === 'WC-OPTION') {
|
||||||
if (it.value === this.props.value) {
|
if (it.root) {
|
||||||
it.setAttribute('active', '')
|
if (it.value === this.props.value) {
|
||||||
this.__INPUT__.value = it.label || it.textContent
|
it.setAttribute('active', '')
|
||||||
} else {
|
this.__INPUT__.value = it.label || it.textContent
|
||||||
it.removeAttribute('active')
|
} else {
|
||||||
|
it.removeAttribute('active')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
it.remove()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,17 +26,21 @@ export default class RadioGroup {
|
||||||
|
|
||||||
_updateChildrenStat(checkAll) {
|
_updateChildrenStat(checkAll) {
|
||||||
Array.from(this.children).forEach(it => {
|
Array.from(this.children).forEach(it => {
|
||||||
if (it.tagName === 'WC-RADIO' && it.root) {
|
if (it.tagName === 'WC-RADIO') {
|
||||||
if (checkAll) {
|
if (it.root) {
|
||||||
it.disabled = this.disabled
|
if (checkAll) {
|
||||||
it.readOnly = this.readOnly
|
it.disabled = this.disabled
|
||||||
}
|
it.readOnly = this.readOnly
|
||||||
|
}
|
||||||
|
|
||||||
if (it.value === this.props.value) {
|
if (it.value === this.props.value) {
|
||||||
it.checked = true
|
it.checked = true
|
||||||
} else {
|
} else {
|
||||||
it.checked = false
|
it.checked = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
it.remove()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,11 @@ const INLINE = {
|
||||||
qlist: /((<blockquote class="md\-quote">)*?)([\+\-\*]|\d+\.) (.*)/ // 引用中的列表
|
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 = {
|
const Helper = {
|
||||||
// 是否分割线
|
// 是否分割线
|
||||||
isHr(str) {
|
isHr(str) {
|
||||||
|
@ -165,20 +170,20 @@ function fixed(str) {
|
||||||
.replace(/\u2424/g, '\n')
|
.replace(/\u2424/g, '\n')
|
||||||
.replace(TAG_RE, (m, name, attr) => {
|
.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) => {
|
.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) => {
|
.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 + '```'
|
return '```' + lang + rollback + '```'
|
||||||
})
|
})
|
||||||
.replace(BLOCK_RE, (m, tag, attr, txt) => {
|
.replace(BLOCK_RE, (m, tag, attr, txt) => {
|
||||||
return `<${tag + attr.replace(/(⨨☇)+/g, ' ')}>${txt
|
return `<${tag + attr.replace(ATTR_BR_EXP, ' ')}>${txt
|
||||||
.replace(/⨨⤶/g, '\n')
|
.replace(NODE_BR_EXP, '\n')
|
||||||
.replace(/(⨨☇)+/g, ' ')}</${tag}>`
|
.replace(ATTR_BR_EXP, ' ')}</${tag}>`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue