Skip to content

Commit 353720d

Browse files
committed
打字机执行时。字体 字号一起闪动,影响视觉效果
打字机执行时。字体 字号一起闪动,影响视觉效果
1 parent 48a6a2b commit 353720d

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

src/components/menus/toolbar/base/font-family.vue

+13-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
:text="t('base.fontFamily.text')"
44
menu-type="select"
55
hide-text
6-
:select-value="editor?.getAttributes('textStyle').fontFamily || null"
6+
:select-value="
7+
isTypeRunning
8+
? null
9+
: editor?.getAttributes('textStyle').fontFamily || null
10+
"
711
:style="{ width: $toolbar.mode !== 'classic' ? '144px' : '90px' }"
812
filterable
913
@menu-click="setFontFamily"
@@ -44,6 +48,14 @@ const options = inject('options')
4448
const $toolbar = useState('toolbar', options)
4549
const $recent = useState('recent', options)
4650
51+
import { getTypewriterRunState } from '@/extensions/type-writer'
52+
let isTypeRunning = $ref(false)
53+
watch(
54+
() => getTypewriterRunState(),
55+
(newValue: boolean) => {
56+
isTypeRunning = newValue
57+
},
58+
)
4759
const usedFonts = $ref<string[]>([])
4860
// https://www.cnblogs.com/gaidalou/p/8479452.html
4961
const fontDetect = (font?: string) => {

src/components/menus/toolbar/base/font-size.vue

+13-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
hide-text
77
style="width: 80px"
88
:select-options="fontSizes"
9-
:select-value="editor?.getAttributes('textStyle').fontSize || '14px'"
9+
:select-value="
10+
isTypeRunning
11+
? null
12+
: editor?.getAttributes('textStyle').fontSize || '14px'
13+
"
1014
v-bind="$attrs"
1115
:placeholder="t('base.fontSize.text')"
1216
filterable
@@ -43,7 +47,14 @@ const $toolbar = useState('toolbar', options)
4347
const disableItem = (name: string) => {
4448
return options.value.toolbar?.disableMenuItems.includes(name)
4549
}
46-
50+
import { getTypewriterRunState } from '@/extensions/type-writer'
51+
let isTypeRunning = $ref(false)
52+
watch(
53+
() => getTypewriterRunState(),
54+
(newValue: boolean) => {
55+
isTypeRunning = newValue
56+
},
57+
)
4758
const fontSizes = [
4859
{ label: t('base.fontSize.default'), value: '14px', order: 4 },
4960
{ label: t('base.fontSize.42pt'), value: '42pt', order: 20 }, // 56

src/extensions/type-writer.ts

+4
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,7 @@ export default Extension.create({
219219
}
220220
},
221221
})
222+
223+
export const getTypewriterRunState = () => {
224+
return typewriterState.value.isRunning
225+
}

0 commit comments

Comments
 (0)