[go: nahoru, domu]

blob: 40a81eeb2751bad3f6ed39b8ece7b9143b2110ab [file] [log] [blame]
Jan Scheffler1fc99c52021-04-07 21:12:401// Copyright 2016 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Jack Franklina75ae7c2021-05-11 13:22:545import type * as Common from '../../core/common/common.js';
Tim van der Lippe877f04a2021-07-23 11:02:546import type * as TextUtils from '../../models/text_utils/text_utils.js';
Jan Scheffler1fc99c52021-04-07 21:12:407
Jack Franklina75ae7c2021-05-11 13:22:548import type {AnchorBehavior} from './GlassPane.js';
Tim van der Lippe877f04a2021-07-23 11:02:549import type {Suggestion} from './SuggestBox.js';
10import type {Widget} from './Widget.js';
Jan Scheffler1fc99c52021-04-07 21:12:4011
12export interface TextEditorFactory {
13 createEditor(options: Options): TextEditor;
14}
15
16export interface TextEditor extends Common.EventTarget.EventTarget {
17 widget(): Widget;
18 fullRange(): TextUtils.TextRange.TextRange;
19 selection(): TextUtils.TextRange.TextRange;
20 setSelection(selection: TextUtils.TextRange.TextRange): void;
21 text(textRange?: TextUtils.TextRange.TextRange): string;
22 textWithCurrentSuggestion(): string;
23 setText(text: string): void;
24 line(lineNumber: number): string;
25 newlineAndIndent(): void;
26 addKeyDownHandler(handler: (arg0: KeyboardEvent) => void): void;
27 configureAutocomplete(config: AutocompleteConfig|null): void;
28 clearAutocomplete(): void;
29 visualCoordinates(lineNumber: number, columnNumber: number): {
30 x: number,
31 y: number,
32 };
33 tokenAtTextPosition(lineNumber: number, columnNumber: number): {
34 startColumn: number,
35 endColumn: number,
36 type: string,
37 }|null;
38 setPlaceholder(placeholder: string): void;
39}
40
41// TODO(crbug.com/1167717): Make this a const enum again
42// eslint-disable-next-line rulesdir/const_enum
43export enum Events {
44 CursorChanged = 'CursorChanged',
45 TextChanged = 'TextChanged',
46 SuggestionChanged = 'SuggestionChanged',
47}
48
49export interface Options {
50 bracketMatchingSetting?: Common.Settings.Setting<boolean>;
51 devtoolsAccessibleName?: string;
52 lineNumbers: boolean;
53 lineWrapping: boolean;
54 mimeType?: string;
55 autoHeight?: boolean;
56 padBottom?: boolean;
57 maxHighlightLength?: number;
58 placeholder?: string;
59 lineWiseCopyCut?: boolean;
60 inputStyle?: string;
61}
62
63export interface AutocompleteConfig {
64 substituteRangeCallback?: ((arg0: number, arg1: number) => TextUtils.TextRange.TextRange | null);
65 tooltipCallback?: ((arg0: number, arg1: number) => Promise<Element|null>);
66 suggestionsCallback?:
67 ((arg0: TextUtils.TextRange.TextRange, arg1: TextUtils.TextRange.TextRange,
68 arg2?: boolean|undefined) => Promise<Suggestion[]>| null);
69 isWordChar?: ((arg0: string) => boolean);
70 anchorBehavior?: AnchorBehavior;
71}