Skip to content

Commit 3174512

Browse files
committed
Add button type
1 parent fab37c4 commit 3174512

File tree

2 files changed

+58
-5
lines changed

2 files changed

+58
-5
lines changed

index.d.ts

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { on } from "cluster";
2-
31
// Type definitions for medium-editor 5.0.0
42
// Project: https://yabwe.github.io/medium-editor
53
// Definitions by: Ashinze Ekene <https://github.com/ashinzekene>
@@ -25,7 +23,7 @@ declare class MediumEditor implements Partial<IMediumEditor> {
2523
static version: MediumEditor.VersionObject
2624

2725
static Extension: {
28-
extend(extension: Partial<MediumEditor.Extension>)
26+
extend(extension: Partial<MediumEditor.Extension>): void
2927
}
3028
}
3129

@@ -745,7 +743,6 @@ declare namespace MediumEditor {
745743
/**
746744
* The set of buttons to display on the toolbar.
747745
* Default: `['bold', 'italic', 'underline', 'anchor', 'h2', 'h3', 'quote']`
748-
* TODO: Check if there a button list type can be created
749746
*/
750747
buttons: string[]
751748
/**
@@ -928,4 +925,60 @@ declare namespace MediumEditor {
928925
subscribe: IMediumEditor["subscribe"]
929926
trigger: IMediumEditor["trigger"]
930927
}
928+
929+
export interface Button {
930+
/**
931+
* If the name of an extension appears in the toolbar.buttons option,
932+
* the MediumEditortoolbar will attempt to call this getButton() method on
933+
* the extension. The HTMLElement returned by this method will be appended to the toolbar
934+
*/
935+
getButton(): HTMLElement|Element
936+
/**
937+
* By default, the action argument to pass to `MediumEditor.execAction()` when the button is clicked.
938+
* The value of this will also be set as the value of the `data-action`
939+
* attribute which will be set on the button
940+
*/
941+
action: string
942+
/**
943+
* The value to add as both the `aria-label` and `title` attributes of the button
944+
*/
945+
aria: string
946+
/**
947+
* Array of element tag names that would indicate that this button has already been applied.
948+
* If this action has already been applied, the button will be displayed as 'active' in the toolbar
949+
*/
950+
tagNames: string[]
951+
/**
952+
* A pair of css property & value(s) that indicate that this button has already been applied.
953+
* If this action has already been applied, the button will be displayed as 'active' in the toolbar
954+
*/
955+
style: {prop: string, value: string|number}
956+
/**
957+
* Enables/disables whether this button should use the built-in `document.queryCommandState()`
958+
* method to determine whether the action has already been applied
959+
*/
960+
useQueryState: boolean
961+
/**
962+
* Default innerHTML to put inside the button
963+
*/
964+
contentDefault: string
965+
/**
966+
* The innerHTML to use for the content of the button if the `buttonLabels`
967+
* option for MediumEditor is set to `'fontawesome'`
968+
*/
969+
contentFA: string
970+
/**
971+
* An array of classNames (strings) to be added to the button
972+
*/
973+
classList: string[]
974+
/**
975+
* A set of key-value pairs to add to the button as custom attributes.
976+
*/
977+
attrs: Object
978+
/**
979+
* The event listener called when the button is clicked.
980+
* The default built-in button will call `this.execAction(action)` when the button is clicked
981+
*/
982+
handleClick(e: Event): void
983+
}
931984
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
],
1919
"description": "Medium.com WYSIWYG editor clone.",
2020
"main": "dist/js/medium-editor.js",
21-
"types": ".index.d.ts",
21+
"types": "./index.d.ts",
2222
"repository": {
2323
"type": "git",
2424
"url": "https://github.com/yabwe/medium-editor"

0 commit comments

Comments
 (0)