starfish-form-custom 1.0.34 → 1.0.36

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/dist/style.css CHANGED
@@ -13,7 +13,7 @@
13
13
  display: flex;
14
14
  align-items: center;
15
15
  }
16
- .menu-item[data-v-083dc03b] {
16
+ .menu-item[data-v-6c37ffa3] {
17
17
  display: flex;
18
18
  align-items: center;
19
19
  justify-content: center;
@@ -23,33 +23,33 @@
23
23
  border: 1px solid #ddd;
24
24
  border-radius: 4px;
25
25
  cursor: pointer;
26
- transition: all 0.2s ease;
26
+ transition: all 0.2s ease;
27
+ font-style: normal;
27
28
  }
28
- .menu-item[data-v-083dc03b]:hover {
29
+ .menu-item[data-v-6c37ffa3]:hover {
29
30
  background-color: #f0f0f0;
30
31
  border-color: #999;
31
32
  }
32
- .menu-item.is-active[data-v-083dc03b] {
33
+ .menu-item.is-active[data-v-6c37ffa3] {
33
34
  background-color: #e0e0e0;
34
35
  border-color: #666;
35
36
  }
36
- .remix[data-v-083dc03b] {
37
- width: 16px;
38
- height: 16px;
37
+ .menu-icon[data-v-6c37ffa3] {
38
+ font-size: 16px;
39
+ color: #333;
39
40
  }
40
41
 
41
- .editor__header[data-v-45d3fb0a] {
42
+ .editor__header[data-v-714af93c] {
42
43
  display: flex;
43
44
  align-items: center;
44
45
  gap: 4px;
45
46
  padding: 8px 12px;
46
47
  border: 1px solid #DCDFE6;
47
48
  border-bottom: none;
48
- border-radius: 4px 4px 0 0;
49
49
  background-color: #f8f9fa;
50
50
  flex-wrap: wrap;
51
51
  }
52
- .divider[data-v-45d3fb0a] {
52
+ .divider[data-v-714af93c] {
53
53
  width: 1px;
54
54
  height: 20px;
55
55
  background-color: #DCDFE6;
@@ -468,18 +468,18 @@
468
468
  min-height: 60px;
469
469
  height: 100%;
470
470
  }
471
- .rich-text-editor[data-v-544977e4] {
471
+ .rich-text-editor[data-v-7adb62dc] {
472
472
  min-height: 200px;
473
473
  }
474
- [data-v-544977e4] .editor-content {
474
+ [data-v-7adb62dc] .editor-content {
475
475
  min-height: 200px;
476
476
  }
477
- [data-v-544977e4] .ProseMirror {
477
+ [data-v-7adb62dc] .ProseMirror {
478
478
  min-height: 180px;
479
479
  outline: none;
480
480
  padding: 12px;
481
481
  }
482
- [data-v-544977e4] .ProseMirror p.is-editor-empty:first-child::before {
482
+ [data-v-7adb62dc] .ProseMirror p.is-editor-empty:first-child::before {
483
483
  color: #adb5bd;
484
484
  content: attr(data-placeholder);
485
485
  float: left;
@@ -488,7 +488,7 @@
488
488
  }
489
489
 
490
490
  /* 行内代码样式 */
491
- [data-v-544977e4] .ProseMirror .inline-code {
491
+ [data-v-7adb62dc] .ProseMirror .inline-code {
492
492
  background-color: #f3f4f6;
493
493
  color: #e53e3e;
494
494
  padding: 2px 6px;
@@ -499,7 +499,7 @@
499
499
  }
500
500
 
501
501
  /* 代码块样式 */
502
- [data-v-544977e4] .ProseMirror code {
502
+ [data-v-7adb62dc] .ProseMirror code {
503
503
  background-color: #1f2937;
504
504
  color: #f9fafb;
505
505
  padding: 16px;
@@ -514,7 +514,7 @@
514
514
 
515
515
 
516
516
  /* 引用块样式 */
517
- [data-v-544977e4] .ProseMirror blockquote {
517
+ [data-v-7adb62dc] .ProseMirror blockquote {
518
518
  border-left: 4px solid #3b82f6;
519
519
  background-color: #f8fafc;
520
520
  padding: 12px 16px;
@@ -525,29 +525,29 @@
525
525
  }
526
526
 
527
527
  /* 水平分割线样式 */
528
- [data-v-544977e4] .ProseMirror hr {
528
+ [data-v-7adb62dc] .ProseMirror hr {
529
529
  border: none;
530
530
  border-top: 2px solid #e5e7eb;
531
531
  margin: 24px 0;
532
532
  }
533
533
 
534
534
  /* 列表样式 */
535
- [data-v-544977e4] .ProseMirror ul,[data-v-544977e4] .ProseMirror ol {
535
+ [data-v-7adb62dc] .ProseMirror ul,[data-v-7adb62dc] .ProseMirror ol {
536
536
  padding-left: 24px;
537
537
  margin: 12px 0;
538
538
  }
539
- [data-v-544977e4] .ProseMirror li {
539
+ [data-v-7adb62dc] .ProseMirror li {
540
540
  margin: 4px 0;
541
541
  }
542
542
 
543
543
  /* 标题样式 */
544
- [data-v-544977e4] .ProseMirror h1 {
544
+ [data-v-7adb62dc] .ProseMirror h1 {
545
545
  font-size: 1.875em;
546
546
  font-weight: bold;
547
547
  margin: 24px 0 16px 0;
548
548
  color: #111827;
549
549
  }
550
- [data-v-544977e4] .ProseMirror h2 {
550
+ [data-v-7adb62dc] .ProseMirror h2 {
551
551
  font-size: 1.5em;
552
552
  font-weight: bold;
553
553
  margin: 20px 0 12px 0;
@@ -18,7 +18,6 @@ declare const _sfc_main: DefineComponent<{
18
18
  default: null;
19
19
  };
20
20
  }, {
21
- remixiconUrl: string;
22
21
  chineseTitle: ComputedRef<string>;
23
22
  }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
24
23
  icon: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starfish-form-custom",
3
- "version": "1.0.34",
3
+ "version": "1.0.36",
4
4
  "main": "dist/starfish-form.mjs",
5
5
  "style": "dist/style.css",
6
6
  "module": "dist/starfish-form.mjs",
@@ -131,7 +131,6 @@ export default defineComponent({
131
131
  padding: 8px 12px;
132
132
  border: 1px solid #DCDFE6;
133
133
  border-bottom: none;
134
- border-radius: 4px 4px 0 0;
135
134
  background-color: #f8f9fa;
136
135
  flex-wrap: wrap;
137
136
  }
@@ -9,16 +9,13 @@
9
9
  :class="{ 'is-active': isActive && isActive() }"
10
10
  @click="action"
11
11
  >
12
- <svg class="remix">
13
- <use :xlink:href="`${remixiconUrl}#ri-${icon}`" />
14
- </svg>
12
+ <i :class="`ri-${icon}`" class="menu-icon"></i>
15
13
  </button>
16
14
  </el-tooltip>
17
15
  </template>
18
16
 
19
17
  <script lang="ts">
20
18
  import { defineComponent, computed } from 'vue'
21
- import remixiconUrl from 'remixicon/fonts/remixicon.symbol.svg'
22
19
 
23
20
  export default defineComponent({
24
21
  name: 'MenuItem',
@@ -41,7 +38,6 @@ export default defineComponent({
41
38
  }
42
39
  },
43
40
  setup(props) {
44
- // 英文标题到中文的映射
45
41
  const titleMap: Record<string, string> = {
46
42
  'Bold': '粗体',
47
43
  'Italic': '斜体',
@@ -64,7 +60,6 @@ export default defineComponent({
64
60
  })
65
61
 
66
62
  return {
67
- remixiconUrl,
68
63
  chineseTitle
69
64
  }
70
65
  }
@@ -83,6 +78,7 @@ export default defineComponent({
83
78
  border-radius: 4px;
84
79
  cursor: pointer;
85
80
  transition: all 0.2s ease;
81
+ font-style: normal;
86
82
  }
87
83
 
88
84
  .menu-item:hover {
@@ -95,8 +91,8 @@ export default defineComponent({
95
91
  border-color: #666;
96
92
  }
97
93
 
98
- .remix {
99
- width: 16px;
100
- height: 16px;
94
+ .menu-icon {
95
+ font-size: 16px;
96
+ color: #333;
101
97
  }
102
98
  </style>
@@ -10,7 +10,7 @@
10
10
  <div class="control" :style="{marginLeft: labelalign != 'top'?labelWidth + 'px': ''}">
11
11
  <div class="rich-text-editor">
12
12
  <!-- 使用 MenuBar 组件 -->
13
- <MenuBar v-if="editor && !readonly" :editor="editor" />
13
+ <MenuBar v-if="!readonly" :editor="editor" />
14
14
  <editor-content :editor="editor" class="editor-content" />
15
15
  </div>
16
16
  </div>
@@ -43,6 +43,9 @@ export default defineComponent({
43
43
  MenuBar
44
44
  },
45
45
  setup(props) {
46
+ useWatch(props);
47
+ const isInternalUpdate = ref(false);
48
+ const lastContent = ref('');
46
49
  const editor = useEditor({
47
50
  content: props.data[props.item.data.fieldName] || props.item.data.defaultValue || '',
48
51
  extensions: [
@@ -74,25 +77,34 @@ export default defineComponent({
74
77
  editorProps: {
75
78
  attributes: {
76
79
  class: 'prose focus:outline-none max-w-none',
77
- style: 'min-height: 200px; border: 1px solid #DCDFE6; border-radius: 4px; padding: 8px 12px;'
80
+ style: 'min-height: 200px; border: 1px solid #DCDFE6; padding: 8px 12px; background-color: #fff;'
78
81
  }
79
82
  },
80
83
  onUpdate: ({ editor }) => {
81
84
  const html = editor.getHTML();
82
- props.data[props.item.data.fieldName] = html;
85
+
86
+ // 只有当内容真正变化时才更新数据
87
+ if (html !== lastContent.value) {
88
+ isInternalUpdate.value = true;
89
+ lastContent.value = html;
90
+ props.data[props.item.data.fieldName] = html;
91
+
92
+ // 使用 setTimeout 确保在下一个事件循环中重置标记
93
+ setTimeout(() => {
94
+ isInternalUpdate.value = false;
95
+ }, 0);
96
+ }
83
97
  },
84
98
  onBlur: ({ editor }) => {
85
99
  const html = editor.getHTML();
86
- props.data[props.item.data.fieldName] = html;
87
- }
88
- });
89
-
90
- useWatch(props);
91
-
92
- // 监听数据变化
93
- watch(() => props.item.data.defaultValue, (newVal) => {
94
- if (editor.value && newVal) {
95
- editor.value.commands.setContent(newVal, false);
100
+ if (html !== lastContent.value) {
101
+ isInternalUpdate.value = true;
102
+ lastContent.value = html;
103
+ props.data[props.item.data.fieldName] = html;
104
+ setTimeout(() => {
105
+ isInternalUpdate.value = false;
106
+ }, 0);
107
+ }
96
108
  }
97
109
  });
98
110
 
@@ -103,6 +115,13 @@ export default defineComponent({
103
115
  }
104
116
  });
105
117
 
118
+ // 初始化 lastContent
119
+ onMounted(() => {
120
+ if (editor.value) {
121
+ lastContent.value = editor.value.getHTML();
122
+ }
123
+ });
124
+
106
125
  onUnmounted(() => {
107
126
  if (editor.value) {
108
127
  editor.value.destroy();