@lambo-design/wang-editor 2.0.0-beta.4 → 2.0.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/index.vue +11 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambo-design/wang-editor",
3
- "version": "2.0.0-beta.4",
3
+ "version": "2.0.0-beta.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
@@ -10,8 +10,8 @@
10
10
  "registry": "https://registry.npmjs.org/"
11
11
  },
12
12
  "devDependencies": {
13
- "@lambo-design/core": "^4.7.1-beta.175",
14
- "@lambo-design/shared": "^1.0.0-beta.334"
13
+ "@lambo-design/shared": "^1.0.0-beta.346",
14
+ "@lambo-design/core": "^4.7.1-beta.176"
15
15
  },
16
16
  "dependencies": {
17
17
  "@wangeditor/editor": "5.1.23",
package/src/index.vue CHANGED
@@ -165,11 +165,19 @@ export default {
165
165
  handleChange(editor) {
166
166
  const html = editor.getHtml();
167
167
  const text = editor.getText();
168
+
169
+ // 判断是否为空内容
170
+ const isEmpty = html === '<p><br></p>' || html.trim() === '';
171
+
172
+ // 如果为空,返回空字符串;否则返回原始 HTML 或文本
173
+ const finalValue = isEmpty ? '' : (this.valueType === 'html' ? html : text);
174
+
168
175
  if (this.cache) {
169
- localStorage.editorCache = html;
176
+ localStorage.editorCache = finalValue;
170
177
  }
171
- this.$emit('input', this.valueType === 'html' ? html : text);
172
- this.$emit('on-change', html, text);
178
+
179
+ this.$emit('input', finalValue);
180
+ this.$emit('on-change', finalValue, text);
173
181
  },
174
182
  onCreated(editor) {
175
183
  this.editor = Object.seal(editor) // 一定要用 Object.seal() ,否则会报错