starfish-form-custom 1.0.43 → 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,214 +0,0 @@
1
- import { _ as _export_sfc, g as getFormConfig, f as fieldProps, a as __unplugin_components_1 } from './main-08a90f8a.mjs';
2
- import { ElTooltip } from 'element-plus/es';
3
- import 'element-plus/es/components/base/style/css';
4
- import 'element-plus/es/components/tooltip/style/css';
5
- import { defineComponent, ref, watch, onMounted, nextTick, onUnmounted, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, createCommentVNode, toDisplayString, createBlock, withCtx, pushScopeId, popScopeId } from 'vue';
6
- import { Editor } 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';
12
- import 'element-plus/es/components/icon/style/css';
13
- import 'element-plus/es/components/input/style/css';
14
- import 'element-plus/es/components/checkbox/style/css';
15
- import '@element-plus/icons-vue';
16
- import 'element-plus/es/components/loading/style/css';
17
- import 'element-plus/es/components/dropdown/style/css';
18
- import 'element-plus/es/components/dropdown-menu/style/css';
19
- import 'element-plus/es/components/dropdown-item/style/css';
20
- import 'element-plus/es/components/collapse/style/css';
21
- import 'element-plus/es/components/collapse-item/style/css';
22
- import 'element-plus/es/components/row/style/css';
23
- import 'element-plus/es/components/button/style/css';
24
- import 'element-plus/es/components/col/style/css';
25
- import 'element-plus/es/components/select/style/css';
26
- import 'element-plus/es/components/option/style/css';
27
- import 'element-plus/es/components/input-number/style/css';
28
- import 'element-plus/es/components/radio-group/style/css';
29
- import 'element-plus/es/components/radio-button/style/css';
30
- import 'element-plus/es/components/checkbox-group/style/css';
31
- import 'element-plus/es/components/color-picker/style/css';
32
- import 'element-plus/es/components/date-picker/style/css';
33
- import 'element-plus/es/components/radio/style/css';
34
- import 'element-plus/es/components/slider/style/css';
35
- import 'element-plus/es/components/switch/style/css';
36
- import 'element-plus/es/components/time-select/style/css';
37
- import 'element-plus/es/components/divider/style/css';
38
- import 'element-plus/es/components/alert/style/css';
39
- import 'element-plus/es/components/tabs/style/css';
40
- import 'element-plus/es/components/tab-pane/style/css';
41
- import 'element-plus/es/components/form-item/style/css';
42
- import 'element-plus';
43
-
44
- /* unplugin-vue-components disabled */const index_vue_vue_type_style_index_0_scoped_true_lang = '';
45
-
46
- const _sfc_main = defineComponent({
47
- ControlType: "RichText",
48
- nameCn: "\u5BCC\u6587\u672C",
49
- icon: "icon-textEdit",
50
- formConfig: getFormConfig("RichText", [{ fieldName: "state", component: "Radio" }]),
51
- props: {
52
- ...fieldProps
53
- },
54
- components: {
55
- MenuBar: __unplugin_components_1
56
- },
57
- setup(props) {
58
- const editorRef = ref(null);
59
- const editorContainer = ref(null);
60
- let isUpdatingFromExternal = false;
61
- const initEditor = () => {
62
- if (editorRef.value) {
63
- editorRef.value.destroy();
64
- }
65
- const initialContent = props.data[props.item.data.fieldName] || props.item.data.defaultValue || "";
66
- editorRef.value = new Editor({
67
- element: editorContainer.value,
68
- content: initialContent,
69
- extensions: [
70
- StarterKit.configure({
71
- codeBlock: {
72
- HTMLAttributes: {
73
- class: "code-block"
74
- }
75
- }
76
- }),
77
- Code.configure({
78
- HTMLAttributes: {
79
- class: "inline-code"
80
- }
81
- }),
82
- CodeBlock.configure({
83
- HTMLAttributes: {
84
- class: "code-block"
85
- }
86
- }),
87
- Blockquote.configure({
88
- HTMLAttributes: {
89
- class: "blockquote"
90
- }
91
- }),
92
- HorizontalRule
93
- ],
94
- editable: !props.readonly,
95
- editorProps: {
96
- attributes: {
97
- class: "prose focus:outline-none max-w-none",
98
- style: "min-height: 200px; border: 1px solid #DCDFE6; padding: 8px 12px; background-color: #fff;"
99
- }
100
- },
101
- onUpdate: ({ editor }) => {
102
- if (isUpdatingFromExternal)
103
- return;
104
- const html = editor.getHTML();
105
- console.log("\u5BCC\u6587\u672C\u5185\u5BB9\u66F4\u65B0:", html.substring(0, 50) + "...");
106
- props.data[props.item.data.fieldName] = html;
107
- },
108
- onBlur: ({ editor }) => {
109
- const html = editor.getHTML();
110
- props.data[props.item.data.fieldName] = html;
111
- }
112
- });
113
- };
114
- watch(
115
- () => props.data[props.item.data.fieldName],
116
- (newValue) => {
117
- if (!editorRef.value || editorRef.value.isDestroyed)
118
- return;
119
- const currentHtml = editorRef.value.getHTML();
120
- if (currentHtml !== newValue) {
121
- console.log("\u5916\u90E8\u6570\u636E\u53D8\u5316\uFF0C\u66F4\u65B0\u7F16\u8F91\u5668");
122
- isUpdatingFromExternal = true;
123
- try {
124
- editorRef.value.commands.setContent(newValue || "", false);
125
- } catch (error) {
126
- console.error("\u66F4\u65B0\u7F16\u8F91\u5668\u5185\u5BB9\u5931\u8D25:", error);
127
- } finally {
128
- setTimeout(() => {
129
- isUpdatingFromExternal = false;
130
- }, 10);
131
- }
132
- }
133
- },
134
- { immediate: true }
135
- );
136
- watch(() => props.readonly, (newVal) => {
137
- if (editorRef.value && !editorRef.value.isDestroyed) {
138
- editorRef.value.setEditable(!newVal);
139
- }
140
- });
141
- onMounted(() => {
142
- nextTick(() => {
143
- initEditor();
144
- });
145
- });
146
- onUnmounted(() => {
147
- console.log("\u5BCC\u6587\u672C\u9500\u6BC1");
148
- if (editorRef.value) {
149
- editorRef.value.destroy();
150
- editorRef.value = null;
151
- }
152
- });
153
- return {
154
- editor: editorRef,
155
- editorContainer
156
- };
157
- }
158
- });
159
- const _withScopeId = (n) => (pushScopeId("data-v-09f76164"), n = n(), popScopeId(), n);
160
- const _hoisted_1 = ["data-control-type", "data-id"];
161
- const _hoisted_2 = {
162
- key: 0,
163
- class: "item_require"
164
- };
165
- const _hoisted_3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", { class: "tip iconfontui icon-tishi" }, null, -1));
166
- const _hoisted_4 = { class: "rich-text-editor" };
167
- const _hoisted_5 = {
168
- ref: "editorContainer",
169
- class: "editor-content"
170
- };
171
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
172
- const _component_el_tooltip = ElTooltip;
173
- const _component_MenuBar = __unplugin_components_1;
174
- return openBlock(), createElementBlock("div", {
175
- class: normalizeClass(["starfish-formitem", { formCover: _ctx.drag, "starfish-vertical": _ctx.labelalign != "top", [_ctx.item.data.csslist?.join(" ")]: !!_ctx.item.data.csslist }]),
176
- "data-control-type": _ctx.item.ControlType,
177
- "data-id": _ctx.item.id
178
- }, [
179
- createElementVNode("div", {
180
- class: normalizeClass(["label", "label_" + _ctx.labelalign]),
181
- style: normalizeStyle({ width: _ctx.labelWidth + "px" })
182
- }, [
183
- _ctx.item.data.required && !_ctx.readonly && _ctx.item.data.state !== "readonly" ? (openBlock(), createElementBlock("span", _hoisted_2, "*")) : createCommentVNode("", true),
184
- createElementVNode("label", null, toDisplayString(_ctx.item.data.label) + toDisplayString(_ctx.suffix), 1),
185
- _ctx.item.data.tip ? (openBlock(), createBlock(_component_el_tooltip, {
186
- key: 1,
187
- class: "item",
188
- effect: "dark",
189
- content: _ctx.item.data.tip,
190
- placement: "top"
191
- }, {
192
- default: withCtx(() => [
193
- _hoisted_3
194
- ]),
195
- _: 1
196
- }, 8, ["content"])) : createCommentVNode("", true)
197
- ], 6),
198
- createElementVNode("div", {
199
- class: "control",
200
- style: normalizeStyle({ marginLeft: _ctx.labelalign != "top" ? _ctx.labelWidth + "px" : "" })
201
- }, [
202
- createElementVNode("div", _hoisted_4, [
203
- _ctx.editor && !_ctx.readonly ? (openBlock(), createBlock(_component_MenuBar, {
204
- key: 0,
205
- editor: _ctx.editor
206
- }, null, 8, ["editor"])) : createCommentVNode("", true),
207
- createElementVNode("div", _hoisted_5, null, 512)
208
- ])
209
- ], 4)
210
- ], 10, _hoisted_1);
211
- }
212
- const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-09f76164"]]);
213
-
214
- export { index as default };
@@ -1,85 +0,0 @@
1
- import type { Ref } from '@vue/reactivity';
2
- import type { DefineComponent, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from '@vue/runtime-core';
3
- declare const _sfc_main: DefineComponent<{
4
- item: {
5
- type: ObjectConstructor;
6
- default: () => {};
7
- };
8
- data: {
9
- type: ObjectConstructor;
10
- default: () => {};
11
- };
12
- drag: {
13
- type: BooleanConstructor;
14
- default: boolean;
15
- };
16
- labelalign: {
17
- type: StringConstructor;
18
- default: string;
19
- };
20
- labelWidth: {
21
- type: NumberConstructor;
22
- };
23
- size: {
24
- type: StringConstructor;
25
- };
26
- isForm: {
27
- type: BooleanConstructor;
28
- default: boolean;
29
- };
30
- }, {
31
- rules: {
32
- funcName: {
33
- required: boolean;
34
- message: string;
35
- trigger: string;
36
- }[];
37
- };
38
- actionRef: Ref<any>;
39
- action: any;
40
- currentAction: any;
41
- getField(methods: string): any;
42
- onAction(type?: string | undefined): void;
43
- onEditAction(key: any, type: string): void;
44
- handleAction(item: any): void;
45
- onSave(): void;
46
- onCancel(): void;
47
- copyAction(item: any): void;
48
- deleteAction(item: any): void;
49
- addAction(type?: string | undefined): void;
50
- onConfirm(): void;
51
- }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
52
- item: {
53
- type: ObjectConstructor;
54
- default: () => {};
55
- };
56
- data: {
57
- type: ObjectConstructor;
58
- default: () => {};
59
- };
60
- drag: {
61
- type: BooleanConstructor;
62
- default: boolean;
63
- };
64
- labelalign: {
65
- type: StringConstructor;
66
- default: string;
67
- };
68
- labelWidth: {
69
- type: NumberConstructor;
70
- };
71
- size: {
72
- type: StringConstructor;
73
- };
74
- isForm: {
75
- type: BooleanConstructor;
76
- default: boolean;
77
- };
78
- }>>, {
79
- data: Record<string, any>;
80
- drag: boolean;
81
- item: Record<string, any>;
82
- labelalign: string;
83
- isForm: boolean;
84
- }>;
85
- export default _sfc_main;
@@ -1,34 +0,0 @@
1
- import type { DefineComponent, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from '@vue/runtime-core';
2
- import { PropType } from 'vue';
3
- declare const _sfc_main: DefineComponent<{
4
- editor: {
5
- type: PropType<any>;
6
- required: true;
7
- };
8
- }, {
9
- items: ({
10
- icon: string;
11
- title: string;
12
- action: () => any;
13
- isActive: () => any;
14
- type?: undefined;
15
- } | {
16
- type: string;
17
- icon?: undefined;
18
- title?: undefined;
19
- action?: undefined;
20
- isActive?: undefined;
21
- } | {
22
- icon: string;
23
- title: string;
24
- action: () => any;
25
- isActive?: undefined;
26
- type?: undefined;
27
- })[];
28
- }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
29
- editor: {
30
- type: PropType<any>;
31
- required: true;
32
- };
33
- }>>, {}>;
34
- export default _sfc_main;
@@ -1,42 +0,0 @@
1
- import type { ComputedRef } from '@vue/reactivity';
2
- import type { DefineComponent, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from '@vue/runtime-core';
3
- declare const _sfc_main: DefineComponent<{
4
- icon: {
5
- type: StringConstructor;
6
- required: true;
7
- };
8
- title: {
9
- type: StringConstructor;
10
- required: true;
11
- };
12
- action: {
13
- type: FunctionConstructor;
14
- required: true;
15
- };
16
- isActive: {
17
- type: FunctionConstructor;
18
- default: null;
19
- };
20
- }, {
21
- chineseTitle: ComputedRef<string>;
22
- }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
23
- icon: {
24
- type: StringConstructor;
25
- required: true;
26
- };
27
- title: {
28
- type: StringConstructor;
29
- required: true;
30
- };
31
- action: {
32
- type: FunctionConstructor;
33
- required: true;
34
- };
35
- isActive: {
36
- type: FunctionConstructor;
37
- default: null;
38
- };
39
- }>>, {
40
- isActive: Function;
41
- }>;
42
- export default _sfc_main;
@@ -1,144 +0,0 @@
1
- <template>
2
- <div class="editor__header">
3
- <template v-for="(item, index) in items" :key="index">
4
- <div v-if="item.type === 'divider'" class="divider" />
5
- <MenuItem v-else :icon="item.icon" :title="item.title" :action="item.action" :is-active="item.isActive" />
6
- </template>
7
- </div>
8
- </template>
9
-
10
- <script lang="ts">
11
- import { defineComponent, PropType } from 'vue'
12
- import MenuItem from './MenuItem.vue'
13
-
14
- export default defineComponent({
15
- name: 'MenuBar',
16
- components: {
17
- MenuItem
18
- },
19
- props: {
20
- editor: {
21
- type: Object as PropType<any>,
22
- required: true
23
- }
24
- },
25
- setup(props) {
26
- const items = [
27
- {
28
- icon: 'bold',
29
- title: 'Bold',
30
- action: () => props.editor.chain().focus().toggleBold().run(),
31
- isActive: () => props.editor.isActive('bold'),
32
- },
33
- {
34
- icon: 'italic',
35
- title: 'Italic',
36
- action: () => props.editor.chain().focus().toggleItalic().run(),
37
- isActive: () => props.editor.isActive('italic'),
38
- },
39
- {
40
- icon: 'strikethrough',
41
- title: 'Strike',
42
- action: () => props.editor.chain().focus().toggleStrike().run(),
43
- isActive: () => props.editor.isActive('strike'),
44
- },
45
- {
46
- icon: 'code-view',
47
- title: 'Code',
48
- action: () => props.editor.chain().focus().toggleCode().run(),
49
- isActive: () => props.editor.isActive('code'),
50
- },
51
- {
52
- type: 'divider',
53
- },
54
- {
55
- icon: 'h-1',
56
- title: 'Heading 1',
57
- action: () => props.editor.chain().focus().toggleHeading({ level: 1 }).run(),
58
- isActive: () => props.editor.isActive('heading', { level: 1 }),
59
- },
60
- {
61
- icon: 'h-2',
62
- title: 'Heading 2',
63
- action: () => props.editor.chain().focus().toggleHeading({ level: 2 }).run(),
64
- isActive: () => props.editor.isActive('heading', { level: 2 }),
65
- },
66
- {
67
- icon: 'paragraph',
68
- title: 'Paragraph',
69
- action: () => props.editor.chain().focus().setParagraph().run(),
70
- isActive: () => props.editor.isActive('paragraph'),
71
- },
72
- {
73
- icon: 'list-unordered',
74
- title: 'Bullet list',
75
- action: () => props.editor.chain().focus().toggleBulletList().run(),
76
- isActive: () => props.editor.isActive('bulletList'),
77
- },
78
- {
79
- icon: 'list-ordered',
80
- title: 'Ordered list',
81
- action: () => props.editor.chain().focus().toggleOrderedList().run(),
82
- isActive: () => props.editor.isActive('orderedList'),
83
- },
84
- {
85
- icon: 'code-box-line',
86
- title: 'Code block',
87
- action: () => props.editor.chain().focus().toggleCodeBlock().run(),
88
- isActive: () => props.editor.isActive('codeBlock'),
89
- },
90
- {
91
- type: 'divider',
92
- },
93
- {
94
- icon: 'double-quotes-l',
95
- title: 'Blockquote',
96
- action: () => props.editor.chain().focus().toggleBlockquote().run(),
97
- isActive: () => props.editor.isActive('blockquote'),
98
- },
99
- {
100
- icon: 'separator',
101
- title: 'Horizontal rule',
102
- action: () => props.editor.chain().focus().setHorizontalRule().run(),
103
- },
104
- {
105
- type: 'divider',
106
- },
107
- {
108
- icon: 'arrow-go-back-line',
109
- title: 'Undo',
110
- action: () => props.editor.chain().focus().undo().run(),
111
- },
112
- {
113
- icon: 'arrow-go-forward-line',
114
- title: 'Redo',
115
- action: () => props.editor.chain().focus().redo().run(),
116
- },
117
- ]
118
-
119
- return {
120
- items
121
- }
122
- }
123
- })
124
- </script>
125
-
126
- <style scoped>
127
- .editor__header {
128
- display: flex;
129
- align-items: center;
130
- gap: 4px;
131
- padding: 8px 12px;
132
- border: 1px solid #DCDFE6;
133
- border-bottom: none;
134
- background-color: #f8f9fa;
135
- flex-wrap: wrap;
136
- }
137
-
138
- .divider {
139
- width: 1px;
140
- height: 20px;
141
- background-color: #DCDFE6;
142
- margin: 0 4px;
143
- }
144
- </style>
@@ -1,98 +0,0 @@
1
- <template>
2
- <el-tooltip
3
- effect="dark"
4
- :content="chineseTitle"
5
- placement="top"
6
- >
7
- <button
8
- class="menu-item"
9
- :class="{ 'is-active': isActive && isActive() }"
10
- @click.stop="action"
11
- >
12
- <i :class="`ri-${icon}`" class="menu-icon"></i>
13
- </button>
14
- </el-tooltip>
15
- </template>
16
-
17
- <script lang="ts">
18
- import { defineComponent, computed } from 'vue'
19
-
20
- export default defineComponent({
21
- name: 'MenuItem',
22
- props: {
23
- icon: {
24
- type: String,
25
- required: true
26
- },
27
- title: {
28
- type: String,
29
- required: true
30
- },
31
- action: {
32
- type: Function,
33
- required: true
34
- },
35
- isActive: {
36
- type: Function,
37
- default: null
38
- }
39
- },
40
- setup(props) {
41
- const titleMap: Record<string, string> = {
42
- 'Bold': '粗体',
43
- 'Italic': '斜体',
44
- 'Strike': '删除线',
45
- 'Code': '行内代码',
46
- 'Heading 1': '标题 1',
47
- 'Heading 2': '标题 2',
48
- 'Paragraph': '段落',
49
- 'Bullet list': '无序列表',
50
- 'Ordered list': '有序列表',
51
- 'Code block': '代码块',
52
- 'Blockquote': '引用块',
53
- 'Horizontal rule': '水平分割线',
54
- 'Undo': '撤销',
55
- 'Redo': '重做'
56
- }
57
-
58
- const chineseTitle = computed(() => {
59
- return titleMap[props.title] || props.title
60
- })
61
-
62
- return {
63
- chineseTitle
64
- }
65
- }
66
- })
67
- </script>
68
-
69
- <style scoped>
70
- .menu-item {
71
- display: flex;
72
- align-items: center;
73
- justify-content: center;
74
- width: 32px;
75
- height: 32px;
76
- background: white;
77
- border: 1px solid #ddd;
78
- border-radius: 4px;
79
- cursor: pointer;
80
- transition: all 0.2s ease;
81
- font-style: normal;
82
- }
83
-
84
- .menu-item:hover {
85
- background-color: #f0f0f0;
86
- border-color: #999;
87
- }
88
-
89
- .menu-item.is-active {
90
- background-color: #e0e0e0;
91
- border-color: #666;
92
- }
93
-
94
- .menu-icon {
95
- font-size: 16px;
96
- color: #333;
97
- }
98
- </style>