@longhongguo/form-create-ant-design-vue 3.3.10 → 3.3.11

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longhongguo/form-create-ant-design-vue",
3
- "version": "3.3.10",
3
+ "version": "3.3.11",
4
4
  "description": "AntDesignVue版本低代码表单|FormCreate 是一个可以通过 JSON 生成具有动态渲染、数据收集、验证和提交功能的低代码表单生成组件。支持6个UI框架,适配移动端,并且支持生成任何 Vue 组件。内置20种常用表单组件和自定义组件,再复杂的表单都可以轻松搞定。",
5
5
  "main": "./dist/form-create.min.js",
6
6
  "module": "./dist/form-create.esm.js",
@@ -36,7 +36,15 @@ export default defineComponent({
36
36
  uploadImgCustomInsert: [String, Function],
37
37
  withCredentials: Boolean,
38
38
  // form-create 注入的 API
39
- formCreateInject: Object
39
+ formCreateInject: Object,
40
+ placeholder: {
41
+ type: String,
42
+ default: '请输入正文'
43
+ },
44
+ height: {
45
+ type: [String, Number],
46
+ default: 300
47
+ }
40
48
  },
41
49
  emits: ['update:modelValue'],
42
50
  watch: {
@@ -51,6 +59,31 @@ export default defineComponent({
51
59
  editorConfig() {
52
60
  const config = {}
53
61
 
62
+ // 设置 placeholder
63
+ if (this.placeholder) {
64
+ config.placeholder = this.placeholder
65
+ }
66
+
67
+ // 设置高度
68
+ if (this.height) {
69
+ // 如果是数字,转换为像素字符串;如果是字符串,直接使用
70
+ config.height = this.height
71
+ }
72
+
73
+ // 排除不需要的工具栏菜单项
74
+ // 移除:全屏、代码、表情、删除线、缩进、待办事项、引用、分割线、斜体
75
+ config.excludeMenus = [
76
+ 'fullScreen', // 全屏
77
+ 'code', // 代码
78
+ 'emoticon', // 表情
79
+ 'strikeThrough', // 删除线
80
+ 'indent', // 缩进
81
+ 'todo', // 待办事项
82
+ 'quote', // 引用
83
+ 'splitLine', // 分割线
84
+ 'italic' // 斜体
85
+ ]
86
+
54
87
  // 如果设置了 readOnly,配置只读模式
55
88
  if (this.readOnly) {
56
89
  // readOnly: true // 启用只读模式
@@ -61,6 +94,8 @@ export default defineComponent({
61
94
  // 禁用自动聚焦,避免在只读模式下获得焦点
62
95
  config.focus = false
63
96
  config.autoFocus = false
97
+ // 只读模式下隐藏 placeholder
98
+ delete config.placeholder
64
99
  }
65
100
 
66
101
  // 如果设置了 uploadImgServer,配置图片上传
@@ -105,6 +105,8 @@ export default {
105
105
  // 只读模式允许复制和点击链接,但禁止编辑
106
106
  if (ctx.prop.props) {
107
107
  ctx.prop.props.readOnly = true
108
+ // 预览模式和只读模式下隐藏 placeholder
109
+ delete ctx.prop.props.placeholder
108
110
  }
109
111
  } else if (
110
112
  ctx.rule.type === 'input' &&
@@ -118,6 +120,10 @@ export default {
118
120
  ctx.prop.props.autoSize = true
119
121
  // 移除 rows 属性,让 autoSize 完全控制高度
120
122
  delete ctx.prop.props.rows
123
+ // 预览模式和只读模式下隐藏 placeholder
124
+ delete ctx.prop.props.placeholder
125
+ // 预览模式和只读模式下隐藏字符计数
126
+ ctx.prop.props.showCount = false
121
127
  }
122
128
  } else if (ctx.rule.type === 'select') {
123
129
  // select 组件在预览模式下使用 disabled 实现只读效果
@@ -126,6 +132,8 @@ export default {
126
132
  // 强制设置 disabled = true,覆盖用户可能设置的 disabled: false
127
133
  if (ctx.prop.props) {
128
134
  ctx.prop.props.disabled = true
135
+ // 预览模式和只读模式下隐藏 placeholder
136
+ delete ctx.prop.props.placeholder
129
137
  // 如果原本设置了 readOnly,保留这个标记以便 CSS 识别
130
138
  if (isReadOnly) {
131
139
  // 可以在这里添加一个标记,但 Select 组件不支持 readOnly
@@ -137,6 +145,30 @@ export default {
137
145
  // 如果设置了 readOnly,直接使用组件的 readOnly 属性
138
146
  if (ctx.prop.props && isReadOnly) {
139
147
  ctx.prop.props.readOnly = true
148
+ // 预览模式和只读模式下隐藏 placeholder
149
+ delete ctx.prop.props.placeholder
150
+ // 预览模式和只读模式下隐藏字符计数
151
+ ctx.prop.props.showCount = false
152
+ } else if (ctx.prop.props && isPreviewMode) {
153
+ // 全局预览模式下也隐藏 placeholder
154
+ delete ctx.prop.props.placeholder
155
+ // 全局预览模式下隐藏字符计数
156
+ ctx.prop.props.showCount = false
157
+ }
158
+ } else if (
159
+ ctx.rule.type === 'datePicker' ||
160
+ ctx.rule.type === 'timePicker' ||
161
+ ctx.rule.type === 'timeRangePicker' ||
162
+ ctx.rule.type === 'rangePicker' ||
163
+ ctx.rule.type === 'cascader'
164
+ ) {
165
+ // 日期选择器、时间选择器、级联选择器等组件
166
+ // 预览模式和只读模式下隐藏 placeholder
167
+ if (ctx.prop.props) {
168
+ if (ctx.rule.type === 'cascader') {
169
+ ctx.prop.props.disabled = true
170
+ }
171
+ delete ctx.prop.props.placeholder
140
172
  }
141
173
  }
142
174
  }