medium-editor
Advanced tools
Comparing version 4.12.1 to 4.12.2
{ | ||
"name": "medium-editor", | ||
"version": "4.12.1", | ||
"version": "4.12.2", | ||
"homepage": "http://yabwe.github.io/medium-editor/", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -0,1 +1,6 @@ | ||
4.12.2 / 2015-06-10 | ||
================== | ||
* Fix broken keyboard shortcuts | ||
4.12.1 / 2015-06-02 | ||
@@ -2,0 +7,0 @@ ================== |
{ | ||
"name": "medium-editor", | ||
"version": "4.12.1", | ||
"version": "4.12.2", | ||
"author": "Davi Ferreira <hi@daviferreira.com>", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
@@ -91,4 +91,18 @@ # MediumEditor | ||
## Initialization options | ||
##### Integrating with various frameworks | ||
People have contributed wrappers around MediumEditor for integrating with different frameworks and tech stacks. Take a look at the list of existing [Wrappers and Integrations](https://github.com/yabwe/medium-editor/wiki/Wrappers-and-Integration) that have already been written for MediumEditor! | ||
## MediumEditor Options | ||
View the [MediumEditor Options documentation](https://github.com/yabwe/medium-editor/wiki/Options) on the Wiki for details on all the various options for MediumEditor. | ||
Options to customize medium-editor are passed as the second argument to the [MediumEditor constructor](https://github.com/yabwe/medium-editor/wiki/MediumEditor-Object-API#mediumeditorelements-options). Example: | ||
```js | ||
var editor = new MediumEditor('.editor', { | ||
// options go here | ||
}); | ||
``` | ||
### Core options | ||
@@ -286,22 +300,45 @@ * __allowMultiParagraphSelection__: enables the toolbar when selecting multiple paragraphs/block elements. Default: true | ||
## Extra buttons | ||
Medium Editor, by default, will show only the buttons listed above to avoid a huge toolbar. There are a few extra buttons you can use: | ||
## Buttons | ||
By default, MediumEditor supports buttons for most of the commands for `document.execCommand()` that are well-supported across all its supported browsers. | ||
### Default buttons. | ||
MediumEditor, by default, will show only the buttons listed here to avoid a huge toolbar: | ||
* __bold__ | ||
* __italic__ | ||
* __underline__ | ||
* __anchor__ _(built-in support for collecting a url via the anchor extension)_ | ||
* __header1__ | ||
* __header2__ | ||
* __quote__ | ||
### All buttons. | ||
These are all the built-in buttons supported by MediumEditor. | ||
* __bold__ | ||
* __italic__ | ||
* __underline__ | ||
* __strikethrough__ | ||
* __subscript__ | ||
* __superscript__ | ||
* __subscript__ | ||
* __strikethrough__ | ||
* __anchor__ | ||
* __image__ (this simply converts selected text to an image tag) | ||
* __quote__ | ||
* __pre__ | ||
* __orderedlist__ | ||
* __unorderedlist__ | ||
* __orderedlist__ | ||
* __pre__ | ||
* __indent__ (moves the selected text up one level) | ||
* __outdent__ (moves the selected text down one level) | ||
* __justifyLeft__ | ||
* __justifyFull__ | ||
* __justifyCenter__ | ||
* __justifyRight__ | ||
* __image__ (this simply converts selected text to an image tag) | ||
* __indent__ (moves the selected text up one level) | ||
* __outdent__ (moves the selected text down one level) | ||
* __justifyFull__ | ||
* __header1__ | ||
* __header2__ | ||
* __removeFormat__ (clears inline style formatting, preserves blocks) | ||
## Themes | ||
@@ -313,32 +350,44 @@ | ||
### Core Methods | ||
View the [MediumEditor Object API documentation](https://github.com/yabwe/medium-editor/wiki/MediumEditor-Object-API) on the Wiki for details on all the methods supported on the MediumEditor object. | ||
### Initialization methods | ||
* __MediumEditor(elements, options)__: Creates an instance of MediumEditor | ||
* __.destroy()__: tears down the editor if already setup, removing all DOM elements and event handlers | ||
* __.setup()__: rebuilds the editor if it has already been destroyed, recreating DOM elements and attaching event handlers | ||
* __.serialize()__: returns a JSON object with elements contents | ||
* __.execAction(action, opts)__: executes an built-in action via `document.execCommand` | ||
* __.createLink(opts)__: creates a link via the native `document.execCommand('createLink')` command | ||
### Event Methods | ||
* __.on(target, event, listener, useCapture)__: attach a listener to a DOM event which will be detached when MediumEditor is deactivated | ||
* __.off(target, event, listener, useCapture)__: detach a listener to a DOM event that was attached via `on()` | ||
* __.subscribe(event, listener)__: attaches a listener to a custom medium-editor event | ||
* __.unsubscribe(event, listener)__: detaches a listener from a custom medium-editor event | ||
* __.trigger(name, data, editable)__: manually triggers a custom medium-editor event | ||
### Selection Methods | ||
* __.checkSelection()__: manually trigger an update of the toolbar and extensions based on the current selection | ||
* __.exportSelection()__: return a data representation of the selected text, which can be applied via `importSelection()` | ||
* __.importSelection(selectionState)__: restore the selection using a data representation of previously selected text (ie value returned by `exportSelection()`) | ||
* __.getFocusedElement()__: returns an element if any contenteditable element monitored by MediumEditor currently has focused | ||
* __.getSelectionParentElement(range)__: get the parent contenteditable element that contains the current selection | ||
* __.restoreSelection()__: restore the selection to what was selected when `saveSelection()` was called | ||
* __.saveSelection()__: internally store the set of selected text | ||
* __.restoreSelection()__: restore the selection to what was selected when `saveSelection()` was called | ||
* __.selectAllContents()__: expands the selection to contain all text within the focused contenteditable | ||
* __.selectElement(element)__: change selection to be a specific element and update the toolbar to reflect the selection | ||
* __.stopSelectionUpdates()__: stop the toolbar from updating to reflect the state of the selected text | ||
* __.startSelectionUpdates()__: put the toolbar back into its normal updating state | ||
### Editor Action Methods | ||
* __.cleanPaste(text)__: convert text to plaintext and replace current selection with result | ||
* __.createLink(opts)__: creates a link via the native `document.execCommand('createLink')` command | ||
* __.execAction(action, opts)__: executes an built-in action via `document.execCommand` | ||
* __.pasteHTML(html, options)__: replace the current selection with html | ||
* __.queryCommandState(action)__: wrapper around the browser's built in `document.queryCommandState(action)` for checking whether a specific action has already been applied to the selection. | ||
### Helper Methods | ||
* __.on(target, event, listener, useCapture)__: attach a listener to a DOM event which will be detached when MediumEditor is deactivated | ||
* __.off(target, event, listener, useCapture)__: detach a listener to a DOM event that was attached via `on()` | ||
* __.delay(fn)__: delay any function from being executed by the amount of time passed as the `delay` option | ||
* __.getSelectionParentElement(range)__: get the parent contenteditable element that contains the current selection | ||
* __.getExtensionByName(name)__: get a reference to an extension with the specified name | ||
* __.getFocusedElement()__: returns an element if any contenteditable element monitored by MediumEditor currently has focused | ||
* __.selectElement(element)__: change selection to be a specific element and update the toolbar to reflect the selection | ||
* __.exportSelection()__: return a data representation of the selected text, which can be applied via `importSelection()` | ||
* __.importSelection(selectionState)__: restore the selection using a data representation of previously selected text (ie value returned by `exportSelection()`) | ||
* __.serialize()__: returns a JSON object with elements contents | ||
## Capturing DOM changes | ||
For observing any changes on contentEditable, use the custom 'editableInput' event exposed via the `subscribe()` method: | ||
For observing any changes on contentEditable, use the custom `'editableInput'` event exposed via the `subscribe()` method: | ||
@@ -345,0 +394,0 @@ ```js |
@@ -38,3 +38,3 @@ /*global MediumEditor, describe, it, expect, spyOn, | ||
anchorExtension = editor.getExtensionByName('anchor'), | ||
code = 'k'.charCodeAt(0); | ||
code = 'K'.charCodeAt(0); | ||
@@ -41,0 +41,0 @@ selectElementContentsAndFire(editor.elements[0]); |
@@ -65,3 +65,3 @@ /*global MediumEditor, describe, it, expect, spyOn, AnchorForm, | ||
var editor = this.newMediumEditor('.editor'), | ||
code = 'b'.charCodeAt(0); | ||
code = 'B'.charCodeAt(0); | ||
selectElementContentsAndFire(editor.elements[0]); | ||
@@ -80,3 +80,3 @@ jasmine.clock().tick(1); | ||
var editor = this.newMediumEditor('.editor'), | ||
code = 'b'.charCodeAt(0); | ||
code = 'B'.charCodeAt(0); | ||
selectElementContentsAndFire(editor.elements[0]); | ||
@@ -83,0 +83,0 @@ jasmine.clock().tick(1); |
@@ -764,3 +764,2 @@ /*global Util, ButtonsData, Selection, Extension, | ||
// NOT DOCUMENTED - exposed as extension helper and for backwards compatability | ||
checkSelection: function () { | ||
@@ -767,0 +766,0 @@ if (this.toolbar) { |
@@ -18,3 +18,3 @@ var ButtonsData; | ||
contentFA: '<i class="fa fa-bold"></i>', | ||
key: 'b' | ||
key: 'B' | ||
}, | ||
@@ -33,3 +33,3 @@ 'italic': { | ||
contentFA: '<i class="fa fa-italic"></i>', | ||
key: 'i' | ||
key: 'I' | ||
}, | ||
@@ -48,3 +48,3 @@ 'underline': { | ||
contentFA: '<i class="fa fa-underline"></i>', | ||
key: 'u' | ||
key: 'U' | ||
}, | ||
@@ -51,0 +51,0 @@ 'strikethrough': { |
@@ -50,3 +50,3 @@ var AnchorForm; | ||
contentFA: '<i class="fa fa-link"></i>', | ||
key: 'k', | ||
key: 'K', | ||
@@ -53,0 +53,0 @@ // Called when the button the toolbar is clicked |
@@ -14,3 +14,3 @@ /*global MediumEditor */ | ||
// grunt-bump looks for this: | ||
'version': '4.12.1' | ||
'version': '4.12.2' | ||
}).version.split('.')); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1355020
480
108
17683
1