From 1d396157c9d9879ffe16a88b69a5a77611ca5a39 Mon Sep 17 00:00:00 2001 From: yutent Date: Wed, 18 Oct 2023 19:44:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96meditor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/meditor/index.js | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/meditor/index.js b/src/meditor/index.js index cdf2be4..a264fbe 100644 --- a/src/meditor/index.js +++ b/src/meditor/index.js @@ -54,8 +54,10 @@ class MEditor extends Component { } } }, + placeholder: '', readonly: false, - disabled: false + disabled: false, + autofocus: false } static styles = [ @@ -156,7 +158,7 @@ class MEditor extends Component { padding: 5px 8px; line-height: 1.5; border: 0; - font-size: 14px; + font-size: var(--wc-meditor-font-size, 14px); font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; color: var(--color-dark-1); background: none; @@ -225,14 +227,10 @@ class MEditor extends Component { left: 0; top: 0; z-index: 99; - width: 80px; height: 0; - padding: 5px 0; - line-height: 25px; background: #fff; - box-shadow: 0 0 8px rgba(0, 0, 0, 0.2); - font-size: 13px; opacity: 0; + box-shadow: 0 0 8px rgba(0, 0, 0, 0.2); transition: all ease-in-out 0.2s; &.fadein { @@ -244,6 +242,8 @@ class MEditor extends Component { } .font-layer { + width: 120px; + padding: 5px 0; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; span { @@ -521,6 +521,10 @@ class MEditor extends Component { } } + focus() { + this.$refs.editor?.focus() + } + /** * 往文本框中插入内容 * @param {String} val [要插入的文本] @@ -832,6 +836,8 @@ class MEditor extends Component { ref="editor" class="editor" spellcheck="false" + placeholder=${this.placeholder} + autofocus=${this.autofocus} :readOnly=${this.readOnly} :disabled=${this.disabled} @click=${this.#hideLayers} @@ -850,12 +856,12 @@ class MEditor extends Component { ref="header" @click=${this.#setHeaderLevel} > - H1 - H2 - H3 - H4 - H5 - H6 + 一级标题 + 二级标题 + 三级标题 + 四级标题 + 五级标题 + 六级标题 ` : ''} ${hasTable