You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

easymde.d.ts 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. // This file is based on https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/simplemde/index.d.ts,
  2. // which is written by Scalesoft <https://github.com/Scalesoft> and licensed under the MIT license:
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in all
  12. // copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. // SOFTWARE.
  21. /// <reference types="codemirror"/>
  22. declare namespace EasyMDE {
  23. interface AutoSaveOptions {
  24. enabled?: boolean;
  25. delay?: number;
  26. uniqueId: string;
  27. }
  28. interface BlockStyleOptions {
  29. bold?: string;
  30. code?: string;
  31. italic?: string;
  32. }
  33. interface InsertTextOptions {
  34. horizontalRule?: ReadonlyArray<string>;
  35. image?: ReadonlyArray<string>;
  36. link?: ReadonlyArray<string>;
  37. table?: ReadonlyArray<string>;
  38. }
  39. interface ParsingOptions {
  40. allowAtxHeaderWithoutSpace?: boolean;
  41. strikethrough?: boolean;
  42. underscoresBreakWords?: boolean;
  43. }
  44. interface RenderingOptions {
  45. singleLineBreaks?: boolean;
  46. codeSyntaxHighlighting: boolean;
  47. }
  48. interface Shortcuts {
  49. [action: string]: string | undefined | null;
  50. toggleBlockquote?: string | null;
  51. toggleBold?: string | null;
  52. cleanBlock?: string | null;
  53. toggleHeadingSmaller?: string | null;
  54. toggleItalic?: string | null;
  55. drawLink?: string | null;
  56. toggleUnorderedList?: string | null;
  57. togglePreview?: string | null;
  58. toggleCodeBlock?: string | null;
  59. drawImage?: string | null;
  60. toggleOrderedList?: string | null;
  61. toggleHeadingBigger?: string | null;
  62. toggleSideBySide?: string | null;
  63. toggleFullScreen?: string | null;
  64. }
  65. interface StatusBarItem {
  66. className: string;
  67. defaultValue: (element: HTMLElement) => void;
  68. onUpdate: (element: HTMLElement) => void;
  69. }
  70. interface ToolbarIcon {
  71. name: string;
  72. action: string | ((editor: EasyMDE) => void);
  73. className: string;
  74. title: string;
  75. noDisable?: boolean;
  76. noMobile?: boolean;
  77. }
  78. interface Options {
  79. autoDownloadFontAwesome?: boolean;
  80. autofocus?: boolean;
  81. autosave?: AutoSaveOptions;
  82. blockStyles?: BlockStyleOptions;
  83. element?: HTMLElement;
  84. forceSync?: boolean;
  85. hideIcons?: ReadonlyArray<string>;
  86. indentWithTabs?: boolean;
  87. initialValue?: string;
  88. insertTexts?: InsertTextOptions;
  89. lineWrapping?: boolean;
  90. parsingConfig?: ParsingOptions;
  91. placeholder?: string;
  92. previewRender?: (markdownPlaintext: string, previewElement: HTMLElement) => string;
  93. promptURLs?: boolean;
  94. renderingConfig?: RenderingOptions;
  95. shortcuts?: Shortcuts;
  96. showIcons?: ReadonlyArray<string>;
  97. spellChecker?: boolean;
  98. status?: boolean | ReadonlyArray<string | StatusBarItem>;
  99. styleSelectedText?: boolean;
  100. tabSize?: number;
  101. toolbar?: boolean | ReadonlyArray<string | ToolbarIcon>;
  102. toolbarTips?: boolean;
  103. onToggleFullScreen?: (goingIntoFullScreen: boolean) => void;
  104. theme?: string;
  105. }
  106. }
  107. declare class EasyMDE {
  108. constructor(options?: EasyMDE.Options);
  109. value(): string;
  110. value(val: string): void;
  111. codemirror: CodeMirror.Editor;
  112. toTextArea(): void;
  113. isPreviewActive(): boolean;
  114. isSideBySideActive(): boolean;
  115. isFullscreenActive(): boolean;
  116. clearAutosavedValue(): void;
  117. static toggleBold: (editor: EasyMDE) => void;
  118. static toggleItalic: (editor: EasyMDE) => void;
  119. static toggleStrikethrough: (editor: EasyMDE) => void;
  120. static toggleHeadingSmaller: (editor: EasyMDE) => void;
  121. static toggleHeadingBigger: (editor: EasyMDE) => void;
  122. static toggleHeading1: (editor: EasyMDE) => void;
  123. static toggleHeading2: (editor: EasyMDE) => void;
  124. static toggleHeading3: (editor: EasyMDE) => void;
  125. static toggleCodeBlock: (editor: EasyMDE) => void;
  126. static toggleBlockquote: (editor: EasyMDE) => void;
  127. static toggleUnorderedList: (editor: EasyMDE) => void;
  128. static toggleOrderedList: (editor: EasyMDE) => void;
  129. static cleanBlock: (editor: EasyMDE) => void;
  130. static drawLink: (editor: EasyMDE) => void;
  131. static drawImage: (editor: EasyMDE) => void;
  132. static drawTable: (editor: EasyMDE) => void;
  133. static drawHorizontalRule: (editor: EasyMDE) => void;
  134. static togglePreview: (editor: EasyMDE) => void;
  135. static toggleSideBySide: (editor: EasyMDE) => void;
  136. static toggleFullScreen: (editor: EasyMDE) => void;
  137. static undo: (editor: EasyMDE) => void;
  138. static redo: (editor: EasyMDE) => void;
  139. }
  140. export as namespace EasyMDE;
  141. export = EasyMDE;