From 29ea0fd5d04dbaac800f211e0ac7701de0a7f3f4 Mon Sep 17 00:00:00 2001 From: zxl <763096477@qq.com> Date: 星期一, 15 九月 2025 15:18:08 +0800 Subject: [PATCH] 新需求 --- src/components/Editor/index.vue | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 deletions(-) diff --git a/src/components/Editor/index.vue b/src/components/Editor/index.vue index 692d899..913999c 100644 --- a/src/components/Editor/index.vue +++ b/src/components/Editor/index.vue @@ -157,6 +157,17 @@ init() { const editor = this.$refs.editor; this.Quill = new Quill(editor, this.options); + // 鏂板锛氱紪杈戝尯鍩熺偣鍑昏仛鐒﹂�昏緫 + const qlEditor = editor.querySelector('.ql-editor'); + if (qlEditor && !this.readOnly) { + qlEditor.addEventListener('click', () => { + this.Quill.focus(); // 鐐瑰嚮鏃跺己鍒惰仛鐒� + }); + if (!this.currentValue) { + qlEditor.classList.add('ql-blank'); // 绌哄唴瀹规椂鏄剧ず鍗犱綅绗� + } + } + // 濡傛灉璁剧疆浜嗕笂浼犲湴鍧�鍒欒嚜瀹氫箟鍥剧墖涓婁紶浜嬩欢 if (this.type == 'url') { let toolbar = this.Quill.getModule("toolbar"); @@ -224,7 +235,23 @@ </script> <style> -.editor, +.editor { + position: relative; + line-height: normal !important; +} +.ql-editor { + min-height: inherit !important; /* 缁ф壙鐖跺鍣ㄧ殑min-height */ + height: 100% !important; /* 鍗犳弧鐖跺鍣ㄩ珮搴� */ + cursor: text; /* 鏄剧ず鏂囨湰鍏夋爣锛屾彁绀哄彲鐐瑰嚮 */ + padding: 12px 15px; /* 鎵╁ぇ鐐瑰嚮鑼冨洿 */ + box-sizing: border-box; /* 鍐呰竟璺濅笉瓒呭嚭瀹瑰櫒 */ +} +.ql-editor.ql-blank::before { + content: attr(data-placeholder); + color: rgba(0, 0, 0, 0.3); + font-style: italic; + pointer-events: none; /* 涓嶅奖鍝嶇偣鍑讳簨浠� */ +} .ql-toolbar { white-space: pre-wrap !important; line-height: normal !important; -- Gitblit v1.8.0