Skip to content

Commit cdd1260

Browse files
authored
Editor.toggleMarkup accepts string or Markup (#783)
1 parent ae74ce9 commit cdd1260

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/js/editor/editor.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,13 +1058,15 @@ export default class Editor implements EditorOptions {
10581058
* Hooks added using #beforeToggleMarkup will be run before toggling,
10591059
* and if any of them returns literal false, toggling the markup will be canceled
10601060
* and no change will be applied.
1061-
* @param {String} markup e.g. "b", "em", "a"
1062-
* @param {Object} attributes e.g. `{ href: "https://bdg.com" }`
1061+
* @param markup e.g. "b", "em", "a"
1062+
* @param attributes e.g. `{ href: "https://bdg.com" }`
10631063
* @public
10641064
* @see PostEditor#toggleMarkup
10651065
*/
1066-
toggleMarkup(markupTag: string, attributes: Dict<string> = {}) {
1067-
const markup = this.builder.createMarkup(markupTag, attributes)
1066+
toggleMarkup(markupOrString: Markup | string, attributes: Dict<string> = {}) {
1067+
const markup =
1068+
typeof markupOrString === 'string' ? this.builder.createMarkup(markupOrString, attributes) : markupOrString
1069+
10681070
const { range } = this
10691071
const willAdd = !this.detectMarkupInRange(range, markup.tagName)
10701072
const shouldCancel = this._runBeforeHooks('toggleMarkup', { markup, range, willAdd })

0 commit comments

Comments
 (0)