From d53e7f7d5b438fb3c3cad622013a2c5cdb8ee0af Mon Sep 17 00:00:00 2001 From: yutent Date: Wed, 20 Sep 2023 10:34:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96=E5=AF=8C=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E7=9A=84=E5=B7=A5=E5=85=B7=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/editor/index.js | 25 ++++--------------------- src/meditor/index.js | 32 ++++++++------------------------ 2 files changed, 12 insertions(+), 45 deletions(-) diff --git a/src/editor/index.js b/src/editor/index.js index 6fa826e..045a68a 100644 --- a/src/editor/index.js +++ b/src/editor/index.js @@ -37,7 +37,7 @@ const ACTTION = { unordered: 'insertUnorderedList' } -const DEFAULT_TOOLS = [ +const TOOLBAR = [ 'font', 'color', 'bold', @@ -52,7 +52,8 @@ const DEFAULT_TOOLS = [ 'right', 'link', 'image', - 'fullscreen' + 'fullscreen', + 'copy' ] const COLORS = [ @@ -87,18 +88,6 @@ class Editor extends Component { static watches = ['value'] static props = { - toolbar: { - type: String, - default: '', - attribute: false, - observer(v) { - if (v === null) { - this.#toolbar = [...DEFAULT_TOOLS] - } else if (v) { - this.#toolbar = v.split(',').map(it => it.trim()) - } - } - }, readonly: { type: Boolean, observer(v) { @@ -407,7 +396,6 @@ class Editor extends Component { ` ] - #toolbar = [] #value = '' #cache = { bar: 0, y: 0 } #gridx = 0 @@ -794,15 +782,10 @@ class Editor extends Component { } render() { - toolbar = [ - ...(this.#toolbar.length ? this.#toolbar : DEFAULT_TOOLS), - 'copy' - ] - return html`
- ${toolbar.map( + ${TOOLBAR.map( it => html` diff --git a/src/meditor/index.js b/src/meditor/index.js index d4aec4b..661f251 100644 --- a/src/meditor/index.js +++ b/src/meditor/index.js @@ -98,18 +98,8 @@ class MEditor extends Component { } }, value: 'str!', - readonly: { - type: Boolean, - observer(v) { - this.#updateStat() - } - }, - disabled: { - type: Boolean, - observer(v) { - this.#updateStat() - } - } + readonly: false, + disabled: false } static styles = [ @@ -472,18 +462,6 @@ class MEditor extends Component { thumb.style.height = bar + 'px' } - #updateStat() { - if (this.$refs.editor) { - if (this.readOnly || this.disabled) { - this.$refs.editor.removeAttribute('contenteditable') - } else { - this.$refs.editor.setAttribute('contenteditable', '') - } - } else { - nextTick(_ => this.#updateStat()) - } - } - #fetchScroll(moveY) { let { bar } = this.#cache let { outer, thumb, inner } = this.$refs @@ -741,9 +719,15 @@ class MEditor extends Component {