Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript support #2

Open
adaojunior opened this issue Mar 14, 2017 · 1 comment
Open

Typescript support #2

adaojunior opened this issue Mar 14, 2017 · 1 comment

Comments

@adaojunior
Copy link

First of all, this is an amazing library, I spent quite some time trying to find this exact package, I didn't want a full editor.

Also, could you support Typescript typings ?

So, thank very much.

@mpharoah
Copy link

mpharoah commented Apr 9, 2023

Here's a definitions file you can copy paste into your project for Typescript support:

declare module 'textarea-editor' {

	interface TAE_Prefix {
		value: string | ((text: string, line: number, ...args: any[] ) => string); // eslint-disable-line @typescript-eslint/no-explicit-any
		pattern: string;
		antipattern?: string | undefined;
	}

	interface TAE_Format {
		block?: boolean | undefined;
		multiline?: boolean | undefined;
		prefix: TAE_Prefix;
		suffix?: TAE_Prefix | undefined;
	}

	class TextAreaEditor {

		constructor( textarea: HTMLTextAreaElement );

		range() : [start: number, end: number];
		range( range: number[] ) : TextAreaEditor;
		public range( range?: [start: number, end: number] | undefined ) : [start: number, end: number] | TextAreaEditor;

		public insert( text: string ) : TextAreaEditor;
		public focus() : TextAreaEditor;
		public toggle( format: string | TAE_Format, ...args: unknown[] ) : TextAreaEditor;
		public format( name: string | TAE_Format, ...args: unknown[] ) : TextAreaEditor;
		public unformat( name: string | TAE_Format ) : TextAreaEditor;
		public hasFormat( name: string | TAE_Format ) : boolean;

	}

	export default TextAreaEditor;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants