mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-05 05:45:46 -05:00
import indent with tab into file editor
This commit is contained in:
@@ -61,6 +61,26 @@ it('runs the latest save handler for Mod-s', () => {
|
||||
expect(latest).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it('indents with Tab and outdents with Shift-Tab', () => {
|
||||
const { container } = render(
|
||||
<CodemirrorEditor initialContent='alpha' mode='text/plain' onContentSaved={vi.fn()} />
|
||||
);
|
||||
const view = viewOf(container);
|
||||
const content = container.querySelector('.cm-content')!;
|
||||
|
||||
act(() => view.dispatch({ selection: { anchor: 0 } }));
|
||||
|
||||
act(() => {
|
||||
content.dispatchEvent(new KeyboardEvent('keydown', { key: 'Tab', bubbles: true }));
|
||||
});
|
||||
expect(view.state.doc.toString()).toBe(' alpha');
|
||||
|
||||
act(() => {
|
||||
content.dispatchEvent(new KeyboardEvent('keydown', { key: 'Tab', shiftKey: true, bubbles: true }));
|
||||
});
|
||||
expect(view.state.doc.toString()).toBe('alpha');
|
||||
});
|
||||
|
||||
it('renders the search and replace panel with theme controls', () => {
|
||||
const { container } = render(<CodemirrorEditor mode='text/plain' onContentSaved={vi.fn()} />);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React, { useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
||||
import { basicSetup } from 'codemirror';
|
||||
import { indentWithTab } from '@codemirror/commands';
|
||||
import { Compartment, EditorState, Prec } from '@codemirror/state';
|
||||
import { HighlightStyle, indentUnit, syntaxHighlighting } from '@codemirror/language';
|
||||
import { EditorView, keymap, type Panel, type ViewUpdate } from '@codemirror/view';
|
||||
@@ -978,6 +979,7 @@ const createEditorState = (
|
||||
},
|
||||
])
|
||||
),
|
||||
keymap.of([indentWithTab]),
|
||||
languageCompartment.of(resolveCodemirrorLanguage(mode)),
|
||||
EditorView.updateListener.of((update) => {
|
||||
if (update.docChanged) {
|
||||
|
||||
Reference in New Issue
Block a user