mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-04 15:10:56 +08:00
fix(editor): unify Ace editor padding
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { configureAceEditorPadding } from '@/utils/aceEditor'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
describe('Ace editor configuration', () => {
|
||||
it('applies the shared content padding and scroll margin', () => {
|
||||
const setPadding = vi.fn()
|
||||
const setScrollMargin = vi.fn()
|
||||
const editor = {
|
||||
renderer: { setPadding, setScrollMargin },
|
||||
} as unknown as Parameters<typeof configureAceEditorPadding>[0]
|
||||
|
||||
configureAceEditorPadding(editor)
|
||||
|
||||
expect(setPadding).toHaveBeenCalledWith(12)
|
||||
expect(setScrollMargin).toHaveBeenCalledWith(8, 8, 0, 0)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { Ace } from 'ace-builds'
|
||||
|
||||
const ACE_EDITOR_PADDING = 12
|
||||
const ACE_EDITOR_SCROLL_MARGIN = { bottom: 8, left: 0, right: 0, top: 8 }
|
||||
|
||||
/** 让所有 Ace 编辑器的文本内容与普通输入框保持一致的内边距和滚动留白。 */
|
||||
export function configureAceEditorPadding(editor: Ace.Editor) {
|
||||
editor.renderer.setPadding(ACE_EDITOR_PADDING)
|
||||
editor.renderer.setScrollMargin(
|
||||
ACE_EDITOR_SCROLL_MARGIN.top,
|
||||
ACE_EDITOR_SCROLL_MARGIN.bottom,
|
||||
ACE_EDITOR_SCROLL_MARGIN.left,
|
||||
ACE_EDITOR_SCROLL_MARGIN.right,
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user