Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions types/easymde-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,30 @@ EasyMDE.toggleItalic = (editor: EasyMDE) => {
console.log('SomeButtonOverride');
};

console.log(editor.options.blockStyles.bold);
console.log(editor.options.insertTexts.horizontalRule[0]);
console.log(editor.options.minHeight);
console.log(editor.options.parsingConfig.allowAtxHeaderWithoutSpace);
console.log(editor.options.previewClass);
console.log(editor.options.previewRender('Hello', document.body));
console.log(editor.options.shortcuts.cleanBlock);
console.log(editor.options.status);
console.log(editor.options.toolbar);

console.log(editor.options.uploadImage);
console.log(editor.options.imageMaxSize);
console.log(editor.options.imageAccept);
console.log(editor.options.imagePathAbsolute);
console.log(editor.options.imageCSRFName);
console.log(editor.options.imageCSRFHeader);
console.log(editor.options.imageTexts.sbInit);
console.log(editor.options.errorMessages.fileTooLarge);
console.log(editor.options.errorCallback('Something went oops!'));

console.log(editor.options.promptTexts.image);

console.log(editor.options.direction);

const editor2 = new EasyMDE({
autoDownloadFontAwesome: undefined,
previewClass: ['my-custom-class', 'some-other-class'],
Expand Down
29 changes: 29 additions & 0 deletions types/easymde.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ interface ArrayOneOrMore<T> extends Array<T> {
0: T;
}

type SetRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;

type ToolbarButton =
'bold'
| 'italic'
Expand All @@ -53,6 +55,32 @@ type ToolbarButton =
| 'fullscreen'
| 'guide';

interface InstanceOptions extends SetRequired<EasyMDE.Options, 'minHeight' |
'parsingConfig' |
'previewClass' |
'previewRender' |
'status' |
'toolbar' |
'uploadImage' |
'imageMaxSize' |
'imageAccept' |
'imagePathAbsolute' |
'imageCSRFName' |
'imageCSRFHeader' |
'errorCallback' |
'direction'> {
blockStyles: Required<EasyMDE.BlockStyleOptions>;
insertTexts: Required<EasyMDE.InsertTextOptions>;
shortcuts: {
[P in keyof EasyMDE.Shortcuts]-?: NonNullable<EasyMDE.Shortcuts[P]>;
};

imageTexts: Required<EasyMDE.ImageTextsOptions>;
errorMessages: Required<EasyMDE.ImageErrorTextsOptions>;

promptTexts: Required<EasyMDE.PromptTexts>;
}

declare namespace EasyMDE {

interface TimeFormatOptions {
Expand Down Expand Up @@ -245,6 +273,7 @@ declare class EasyMDE {
value(val: string): void;

codemirror: CodeMirror.Editor;
options: InstanceOptions;

cleanup(): void;

Expand Down