编辑器增加toolbar支持

master
yutent 2024-08-28 16:20:00 +08:00
parent 87c7877a81
commit f76af9ff8f
1 changed files with 18 additions and 1 deletions

View File

@ -96,6 +96,21 @@ class Editor extends Component {
observer(v) { observer(v) {
this.#updateStat() this.#updateStat()
} }
},
toolbar: {
type: String,
default: null,
attribute: false,
observer(v) {
if (v === null) {
this.#toolbar = [...TOOLBAR]
} else {
this.#toolbar = v
.split(',')
.filter(it => it)
.map(it => it.trim())
}
}
} }
} }
@ -373,6 +388,8 @@ class Editor extends Component {
#gridx = 0 #gridx = 0
#gridy = 0 #gridy = 0
#toolbar = [...TOOLBAR]
#select = null #select = null
get value() { get value() {
@ -653,7 +670,7 @@ class Editor extends Component {
return html` return html`
<div class="editor"> <div class="editor">
<section class="toolbar" @click=${this.#toolbarClick}> <section class="toolbar" @click=${this.#toolbarClick}>
${TOOLBAR.map( ${this.#toolbar.map(
it => html` it => html`
<span data-act=${it}> <span data-act=${it}>
<svg class="icon" viewBox="0 0 1024 1024"> <svg class="icon" viewBox="0 0 1024 1024">