starfish-form-custom 1.0.44 → 1.0.45

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.
@@ -1,14 +1,10 @@
1
- import { _ as _export_sfc, g as getFormConfig, f as fieldProps, a as __unplugin_components_1 } from './main-c6aa3683.mjs';
2
1
  import { ElTooltip } from 'element-plus/es';
3
2
  import 'element-plus/es/components/base/style/css';
4
3
  import 'element-plus/es/components/tooltip/style/css';
5
- import { defineComponent, ref, watch, onUnmounted, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, createCommentVNode, toDisplayString, createBlock, withCtx, createVNode, pushScopeId, popScopeId } from 'vue';
6
- import { EditorContent, useEditor } from '@tiptap/vue-3';
7
- import StarterKit from '@tiptap/starter-kit';
8
- import Code from '@tiptap/extension-code';
9
- import Blockquote from '@tiptap/extension-blockquote';
10
- import HorizontalRule from '@tiptap/extension-horizontal-rule';
11
- import CodeBlock from '@tiptap/extension-code-block';
4
+ import { defineComponent, ref, computed, watch, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, createCommentVNode, toDisplayString, createBlock, withCtx, withModifiers, createVNode } from 'vue';
5
+ import { QuillEditor } from '@vueup/vue-quill';
6
+ import '@vueup/vue-quill/dist/vue-quill.snow.css';
7
+ import { _ as _export_sfc, g as getFormConfig, f as fieldProps, u as useWatch } from './main-c9f94a75.mjs';
12
8
  import 'element-plus/es/components/icon/style/css';
13
9
  import 'element-plus/es/components/input/style/css';
14
10
  import 'element-plus/es/components/checkbox/style/css';
@@ -52,94 +48,40 @@ const _sfc_main = defineComponent({
52
48
  ...fieldProps
53
49
  },
54
50
  components: {
55
- EditorContent,
56
- MenuBar: __unplugin_components_1
51
+ QuillEditor
57
52
  },
58
53
  setup(props) {
59
- const internalContent = ref(props.data[props.item.data.fieldName] || props.item.data.defaultValue || "");
60
- const editor = useEditor({
61
- content: internalContent.value,
62
- extensions: [
63
- StarterKit.configure({
64
- codeBlock: {
65
- HTMLAttributes: {
66
- class: "code-block"
67
- }
68
- }
69
- }),
70
- Code.configure({
71
- HTMLAttributes: {
72
- class: "inline-code"
73
- }
74
- }),
75
- CodeBlock.configure({
76
- HTMLAttributes: {
77
- class: "code-block"
78
- }
79
- }),
80
- Blockquote.configure({
81
- HTMLAttributes: {
82
- class: "blockquote"
83
- }
84
- }),
85
- HorizontalRule
86
- ],
87
- editable: !props.readonly,
88
- editorProps: {
89
- attributes: {
90
- class: "prose focus:outline-none max-w-none",
91
- style: "min-height: 200px; border: 1px solid #DCDFE6; padding: 8px 12px; background-color: #fff;"
92
- }
93
- },
94
- // 3. 只在失焦时更新到表单数据
95
- onBlur: ({ editor: editorInstance }) => {
96
- const html = editorInstance.getHTML();
97
- console.log("\u5BCC\u6587\u672C\u5931\u7126\uFF0C\u66F4\u65B0\u8868\u5355\u6570\u636E");
98
- internalContent.value = html;
99
- props.data[props.item.data.fieldName] = html;
100
- }
101
- // 4. 移除 onUpdate 回调,避免实时更新
102
- });
103
- watch(
104
- () => props.data[props.item.data.fieldName],
105
- (newValue) => {
106
- if (!editor.value || editor.value.isDestroyed)
107
- return;
108
- if (newValue !== internalContent.value) {
109
- console.log("\u5916\u90E8\u6570\u636E\u53D8\u5316\uFF0C\u66F4\u65B0\u7F16\u8F91\u5668");
110
- internalContent.value = newValue || "";
111
- editor.value.commands.setContent(newValue || "", false);
112
- }
113
- },
114
- { immediate: true }
54
+ useWatch(props);
55
+ const quillEditorRef = ref();
56
+ const content = ref(props.data[props.item.data.fieldName] || props.item.data.default || "");
57
+ const isReadonly = computed(
58
+ () => props.readonly || props.item.data.state === "readonly"
115
59
  );
116
- watch(() => props.readonly, (newVal) => {
117
- if (editor.value) {
118
- editor.value.setEditable(!newVal);
119
- }
120
- });
121
- onUnmounted(() => {
122
- if (editor.value) {
123
- editor.value.destroy();
60
+ const handleContentChange = (value) => {
61
+ content.value = value;
62
+ props.data[props.item.data.fieldName] = value;
63
+ };
64
+ watch(() => props.data[props.item.data.fieldName], (newValue) => {
65
+ if (newValue !== content.value) {
66
+ content.value = newValue || "";
124
67
  }
125
68
  });
126
69
  return {
127
- editor
70
+ content,
71
+ quillEditorRef,
72
+ handleContentChange,
73
+ isReadonly
128
74
  };
129
75
  }
130
76
  });
131
- const _withScopeId = (n) => (pushScopeId("data-v-715a995e"), n = n(), popScopeId(), n);
132
77
  const _hoisted_1 = ["data-control-type", "data-id"];
133
78
  const _hoisted_2 = {
134
79
  key: 0,
135
80
  class: "item_require"
136
81
  };
137
- const _hoisted_3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", { class: "tip iconfontui icon-tishi" }, null, -1));
138
- const _hoisted_4 = { class: "rich-text-editor" };
139
82
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
140
83
  const _component_el_tooltip = ElTooltip;
141
- const _component_MenuBar = __unplugin_components_1;
142
- const _component_EditorContent = resolveComponent("EditorContent");
84
+ const _component_QuillEditor = resolveComponent("QuillEditor");
143
85
  return openBlock(), createElementBlock("div", {
144
86
  class: normalizeClass(["starfish-formitem", { formCover: _ctx.drag, "starfish-vertical": _ctx.labelalign != "top", [_ctx.item.data.csslist?.join(" ")]: !!_ctx.item.data.csslist }]),
145
87
  "data-control-type": _ctx.item.ControlType,
@@ -158,9 +100,9 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
158
100
  content: _ctx.item.data.tip,
159
101
  placement: "top"
160
102
  }, {
161
- default: withCtx(() => [
162
- _hoisted_3
163
- ]),
103
+ default: withCtx(() => [..._cache[1] || (_cache[1] = [
104
+ createElementVNode("span", { class: "tip iconfontui icon-tishi" }, null, -1)
105
+ ])]),
164
106
  _: 1
165
107
  }, 8, ["content"])) : createCommentVNode("", true)
166
108
  ], 6),
@@ -168,19 +110,24 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
168
110
  class: "control",
169
111
  style: normalizeStyle({ marginLeft: _ctx.labelalign != "top" ? _ctx.labelWidth + "px" : "" })
170
112
  }, [
171
- createElementVNode("div", _hoisted_4, [
172
- _ctx.editor && !_ctx.readonly ? (openBlock(), createBlock(_component_MenuBar, {
173
- key: 0,
174
- editor: _ctx.editor
175
- }, null, 8, ["editor"])) : createCommentVNode("", true),
176
- createVNode(_component_EditorContent, {
177
- editor: _ctx.editor,
113
+ createElementVNode("div", {
114
+ class: "rich-text-editor",
115
+ onClick: _cache[0] || (_cache[0] = withModifiers(() => {
116
+ }, ["stop"]))
117
+ }, [
118
+ createVNode(_component_QuillEditor, {
119
+ ref: "quillEditorRef",
120
+ theme: "snow",
121
+ content: _ctx.content,
122
+ "onUpdate:content": _ctx.handleContentChange,
123
+ toolbar: "full",
124
+ "read-only": _ctx.isReadonly,
178
125
  class: "editor-content"
179
- }, null, 8, ["editor"])
126
+ }, null, 8, ["content", "onUpdate:content", "read-only"])
180
127
  ])
181
128
  ], 4)
182
129
  ], 10, _hoisted_1);
183
130
  }
184
- const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-715a995e"]]);
131
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-44f321dd"]]);
185
132
 
186
133
  export { index as default };
@@ -6,7 +6,7 @@ import 'element-plus/es/components/button/style/css';
6
6
  import 'element-plus/es/components/main/style/css';
7
7
  import 'element-plus/es/components/tooltip/style/css';
8
8
  import { defineComponent, ref, onMounted, watch, nextTick, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, toDisplayString, createCommentVNode, createBlock, withCtx, createVNode, createTextVNode } from 'vue';
9
- import { _ as _export_sfc, b as _, g as getFormConfig, f as fieldProps, u as useWatch } from './main-c6aa3683.mjs';
9
+ import { _ as _export_sfc, a as _, g as getFormConfig, f as fieldProps, u as useWatch } from './main-c9f94a75.mjs';
10
10
  import JSONEditor from 'jsoneditor';
11
11
  import 'element-plus/es/components/icon/style/css';
12
12
  import 'element-plus/es/components/input/style/css';
@@ -130,21 +130,14 @@ const _hoisted_1 = {
130
130
  key: 0,
131
131
  class: "item_require"
132
132
  };
133
- const _hoisted_2 = /* @__PURE__ */ createElementVNode("span", { class: "tip iconfontui icon-tishi" }, null, -1);
134
- const _hoisted_3 = {
133
+ const _hoisted_2 = {
135
134
  id: "jsoneditor",
136
135
  ref: "jsoneditor"
137
136
  };
138
- const _hoisted_4 = /* @__PURE__ */ createElementVNode("i", { class: "iconfontui icon-quanping" }, null, -1);
139
- const _hoisted_5 = [
140
- _hoisted_4
141
- ];
142
- const _hoisted_6 = {
137
+ const _hoisted_3 = {
143
138
  ref: "JsonViewerDialogDom",
144
139
  style: { "height": "calc(100% - 24px)" }
145
140
  };
146
- const _hoisted_7 = /* @__PURE__ */ createTextVNode("\u4FDD\u5B58");
147
- const _hoisted_8 = /* @__PURE__ */ createTextVNode("\u5173\u95ED");
148
141
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
149
142
  const _component_el_tooltip = ElTooltip;
150
143
  const _component_el_main = ElMain;
@@ -172,9 +165,9 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
172
165
  content: _ctx.item.data.tip,
173
166
  placement: "top"
174
167
  }, {
175
- default: withCtx(() => [
176
- _hoisted_2
177
- ]),
168
+ default: withCtx(() => [..._cache[1] || (_cache[1] = [
169
+ createElementVNode("span", { class: "tip iconfontui icon-tishi" }, null, -1)
170
+ ])]),
178
171
  _: 1
179
172
  }, 8, ["content"])) : createCommentVNode("", true)
180
173
  ], 6),
@@ -182,11 +175,13 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
182
175
  class: "control",
183
176
  style: normalizeStyle({ marginLeft: _ctx.labelalign != "top" ? _ctx.labelWidth + "px" : "" })
184
177
  }, [
185
- createElementVNode("div", _hoisted_3, [
178
+ createElementVNode("div", _hoisted_2, [
186
179
  createElementVNode("div", {
187
180
  class: "fullScreen",
188
181
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.showCustomDialog && _ctx.showCustomDialog(...args))
189
- }, _hoisted_5)
182
+ }, [..._cache[2] || (_cache[2] = [
183
+ createElementVNode("i", { class: "iconfontui icon-quanping" }, null, -1)
184
+ ])])
190
185
  ], 512)
191
186
  ], 4),
192
187
  createVNode(_component_CustomDialog, {
@@ -200,7 +195,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
200
195
  default: withCtx(() => [
201
196
  createVNode(_component_el_main, { class: "my-pageMain" }, {
202
197
  default: withCtx(() => [
203
- createElementVNode("div", _hoisted_6, null, 512)
198
+ createElementVNode("div", _hoisted_3, null, 512)
204
199
  ]),
205
200
  _: 1
206
201
  }),
@@ -213,15 +208,15 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
213
208
  type: "primary",
214
209
  onClick: _ctx.saveJson
215
210
  }, {
216
- default: withCtx(() => [
217
- _hoisted_7
218
- ]),
211
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [
212
+ createTextVNode("\u4FDD\u5B58", -1)
213
+ ])]),
219
214
  _: 1
220
215
  }, 8, ["onClick"]),
221
216
  createVNode(_component_el_button, { onClick: _ctx.closeDialog }, {
222
- default: withCtx(() => [
223
- _hoisted_8
224
- ]),
217
+ default: withCtx(() => [..._cache[4] || (_cache[4] = [
218
+ createTextVNode("\u5173\u95ED", -1)
219
+ ])]),
225
220
  _: 1
226
221
  }, 8, ["onClick"])
227
222
  ]),