ui(client): add insertHtml for MduiPatchedTextArea

This commit is contained in:
CrescentLeaf
2026-01-24 00:11:19 +08:00
parent 01ece27e75
commit 9e3c1c554f
2 changed files with 10 additions and 1 deletions

View File

@@ -60,6 +60,9 @@ export default class MduiPatchedTextAreaElement extends HTMLElement {
this._lastValue = this.value || ''
this.dispatchEvent(new Event('change', { bubbles: true }))
}
// 消除 <br> 对 placeholder 的影响
if (this.value == '')
this.value = ''
})
this.inputDiv.addEventListener('paste', (e: ClipboardEvent) => {
e.preventDefault()
@@ -101,6 +104,11 @@ export default class MduiPatchedTextAreaElement extends HTMLElement {
set value(v) {
this.inputDiv && (this.inputDiv.textContent = v)
}
insertHtml(html: string) {
this.inputDiv?.focus()
document.execCommand('insertHTML', false, html)
}
}
customElements.define('mdui-patched-textarea', MduiPatchedTextAreaElement)