Version 5.0.0 of MediumEditor introduces a significantly simpler system for building custom extensions as well as extending existing buttons and extensions. As part of moving towards this extendable model, there were significant changes to the way options are passed to MediumEditor, as well as the extensions and buttons themselves.
In addition to extension related changes, there were several other potential breaking changes related to API methods, as well as utility helper methods.
For details on all the currently supported MediumEditor options, refer to the Medium Editor Options Wiki Page.
- Options controlling the toolbar are now passed as a
'toolbar'object inside the outer options object.buttons->toolbar.buttonstoolbarAlign->toolbar.aligndiffTop->toolbar.diffTopdiffLeft->toolbar.diffLeftstaticToolbar->toolbar.staticstickyToolbar->toolbar.stickyfirstButtonClass->toolbar.firstButtonClasslastButtonClass->toolbar.lastButtonClassupdateOnEmptySelection->toolbar.updateOnEmptySelectionstandardizeSelectionStart->toolbar.standardizeSelectionStart
- Options controlling the anchor input extension are now passed as a
'anchor'object inside the outer options object.anchorInputPlaceholder->anchor.placeholderTextcheckLinkFormat->anchor.linkValidationanchorButton&anchorButtonClass->anchor.customClassOptionanchorTarget->anchor.targetCheckboxanchorInputCheckboxLabel->anchor.targetCheckboxText
- Options controlling the anchor preview extension are now passed as a
'anchorPreview'object inside the outer options object.anchorPreviewHideDelay->anchorPreview.hideDelay
- Options controlling paste are now passed as a
'paste'object inside the outer options object.forcePlainText->paste.forcePlainTextcleanPastedHTML->paste.cleanPastedHTML
- Options controlling the placeholder extension are now passed as a
'placeholder'object inside the outer options object.placeholder->placeholder.text
- Disabling the toolbar extension is now done by setting the
toolbaroption tofalse
- Disabling the anchor preview extension is now done by setting the
anchorPreviewoption tofalse
- Disabling the placeholder extension is now done by setting the
placeholderoption tofalse
- The
onShowToolbarandonHideToolbaroptions are no longer supported. Instead, attach to the'showToolbar'and'hideToolbar'custom events viaMediumEditor.subscribe()
- The
firstHeader&secondHeaderoptions have been removed. Instead, any number of the 6 header types can be passed as button names into thetoolbar.buttonsoption array.- Example: Where before the code may have sent
firstHeader: 'h2'andsecondHeader: 'h3', it should now pass['bold', 'italic', 'quote', 'h2', 'h3']via thetoolbar.buttonsproperty of the MediumEditor options object.
- Example: Where before the code may have sent
- The
buttonLabelsoption no longer supports taking an object in that specifies custom labels for all buttons. Instead, pass an object into thetoolbar.buttonsoption array that contains a.nameproperty for the name of the button, a either acontentDefaultor acontentFAproperty that should be in the innerHTML of the button (for default offontawesomebuttonLabels respectively)
Extension.parentis no longer supported. All extensions will have a reference to the MediumEditor instance via their.baseproperty, unless the property already exists.
Extension.init()will no longer be passed any arguments. Previously,.init(instance)received an instance of MediumEditor as an argument, but this is not needed now that.basewill be populated before.init()is called.
Extension.deactivate()will no longer be called by MediumEditor..destroy()will be called instead when MediumEditor is destroyed.
- The
.optionsproperty of any built-in extensions or buttons has been removed. All of the properties should be retrieved and set from the prototype of the object itself.- Example: Instead of buttons using
this.options.action, they should now usethis.action. - Not all extensions had options before, or saved them via the
.optionsproperty.
- Example: Instead of buttons using
- The unique identifier used for MediumEditor elements will now remain unique and remain regardless of how many instances are created. After calling
.destroy()and.setup(), the id will remain the same. This id was used to generate unique element ids for things like the id attribute of the toolbar element ('medium-editor-toolbar-[ID]')
- The MediumEditor toolbar is now an extension, so
MediumEditor.toolbaris no longer a valid reference. UseMediumEditor.getExtensionByName('toolbar')instead.
- All of the
.staticsreferences have been removed as the new style of extensions and buttons has been introduced. The objects exposed via.staticshave also been changed, so code which uses them may require additonal changes.MediumEditor.statics.ButtonsData->MediumEditor.extensions.button.prototype.defaults(ideally this reference should no longer be needed)MediumEditor.statics.DefaultButton->MediumEditor.extensions.buttonMediumEditor.statics.AnchorExtension->MediumEditor.extensions.anchorMediumEditor.statics.FontSizeExtension->MediumEditor.extensions.fontSizeMediumEditor.statics.Toolbar->MediumEditor.extensions.toolbarMediumEditor.statics.AnchorPreview->MediumEditor.extensions.anchorPreview
MediumEditor.activate()has been replaced withMediumEditor.setup()
MediumEditor.deactivate()has been replaced withMediumEditor.destroy()
MediumEditor.createEvent()is no longer needed in order to fire custom events. It has been removed.
MediumEditor.hideToolbarDefaultActions()has been removed. Use thehideToolbarDefaultActions()method of the toolbar extension instead.
MediumEditor.setToolbarPosition()has been removed. Use thesetToolbarPosition()method of the toolbar extension instead.
MediumEditor.callExtensions()has been removed and is no longer supported.
MediumEditor.util.getSelectionRange()has been moved toMediumEditor.selection.getSelectionRange()MediumEditor.util.getSelectionStart()has been moved toMediumEditor.selection.getSelectionStart()MediumEditor.util.unwrapElement()has been removed. UseMediumEditor.util.unwrap()insteadMediumEditor.util.getSelectionData()has been removedMediumEditor.util.setObject()has been removedMediumEditor.util.getObject()has been removedMediumEditor.util.derives()has been removed. Objects that can be drived from (like extensions and buttons) will have a.extend()method for extending.MediumEditor.util.now()has been removed. UseDate.now()instead.MediumEditor.util.parentElementshas been renamedMediumEditor.util.blockContainerElementNames
MediumEditor.selection.getSelectionData()has been removed
- The
.clearfixclass has been removed, and.clearfixclass is no longer added to the toolbar element. - All references to
'medium'in CSS classes has been replaced with'medium-editor'- Example: The image element added by the image dragging extension will now have a
medium-editor-image-loadingclass on instead ofmedium-image-loading
- Example: The image element added by the image dragging extension will now have a
- The
data-medium-elementattribute on all MediumEditor elements has been renamed todata-medium-editor-element - Toolbar classes
sticky-toolbarandstatic-toolbarhave been renamedmedium-editor-sticky-toolbarandmedium-editor-static-toolbarrespectively
- The
getFocusedElement()method of the toolbar extension has been removed. UseMediumEditor.getFocusedElement()instead. - Keyboard Shortcuts are now controlled via the Keyboard Commands extension. The
.keyoption on buttons is not longer supported for mapping keyboard shortcuts.