draftmirror
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -72,5 +72,15 @@ var React = require('react'); | ||
* Update keymaps | ||
* todo: update on componentWillReceiveProps | ||
*/ | ||
updateKeymaps: function(newProps) { | ||
updateKeymaps: function(newProps, forceUpdate) { | ||
if (!forceUpdate && Immutable.is(newProps.keymaps, this.props.keymaps)) { | ||
return; | ||
} | ||
// Unbind old ones | ||
Immutable.List(this.props.keymaps) | ||
.forEach(function(keymap) { | ||
keymap.unbindToEditor(this.editor); | ||
}, this); | ||
// Bind new ones | ||
Immutable.List(newProps.keymaps) | ||
@@ -83,6 +93,6 @@ .forEach(function(keymap) { | ||
/** | ||
* Updateinput rules | ||
* Update input rules | ||
*/ | ||
updateInputRules: function(newProps) { | ||
if (Immutable.is(newProps.inputRules, this.props.inputRules)) { | ||
updateInputRules: function(newProps, forceUpdate) { | ||
if (!forceUpdate && Immutable.is(newProps.inputRules, this.props.inputRules)) { | ||
return; | ||
@@ -128,4 +138,4 @@ } | ||
this.updateKeymaps(newProps); | ||
this.updateInputRules(newProps); | ||
this.updateKeymaps(newProps, true); | ||
this.updateInputRules(newProps, true); | ||
}, | ||
@@ -157,2 +167,3 @@ | ||
this.updateKeymaps(newProps); | ||
this.updateInputRules(newProps); | ||
@@ -159,0 +170,0 @@ |
@@ -27,2 +27,10 @@ var Immutable = require('immutable'); | ||
/** | ||
* Unbind a keymap from an editor | ||
* @param {ProseMirror} editor | ||
*/ | ||
Keymap.prototype.unbindToEditor = function(editor) { | ||
editor.removeKeymap(this.getMap()); | ||
}; | ||
/** | ||
* Add a set of keys | ||
@@ -29,0 +37,0 @@ * @param {Object} keys |
@@ -48,6 +48,6 @@ var is = require('is'); | ||
*/ | ||
function insertTab(editor, apply) { | ||
function insertTab(defaultIndent, editor, apply) { | ||
return insertInCode(editor, function(node) { | ||
var nodeText = node.textContent; | ||
return detectIndent(nodeText).indent || ' '; | ||
return detectIndent(nodeText).indent || defaultIndent; | ||
}, apply); | ||
@@ -60,7 +60,9 @@ } | ||
*/ | ||
function createKeymap(priority) { | ||
function createKeymap(priority, defaultIndent) { | ||
defaultIndent = defaultIndent || ' '; | ||
return Keymap.create({ | ||
'Enter': commands.newlineInCode, | ||
'Shift-Enter': insertNewLine, | ||
'Tab': insertTab | ||
'Tab': insertTab.bind(null, defaultIndent) | ||
}, priority); | ||
@@ -67,0 +69,0 @@ } |
{ | ||
"name": "draftmirror", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "React component for ProseMirror providing a Draft.js like API", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
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
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
92794
2424