draftmirror
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -88,8 +88,32 @@ var SelectionContext = require('../models/selectionContext'); | ||
/** | ||
* Remove the selected content | ||
* @param {EditorState} editorState | ||
* @param {Selection} selection | ||
*/ | ||
function remove(editorState, selection) { | ||
return editorState.applyTransform(function (editor) { | ||
editor.tr.deleteSelection().apply(); | ||
}); | ||
} | ||
/** | ||
* Remove the selected content | ||
* @param {EditorState} editorState | ||
* @param {String} text | ||
*/ | ||
function replaceWithText(editorState, text) { | ||
return editorState.applyTransform(function (editor) { | ||
editor.tr.typeText(text).apply(); | ||
}); | ||
} | ||
module.exports = { | ||
nodeAtSelection: nodeAtSelection, | ||
contextAtSelection: contextAtSelection, | ||
removeAt: removeAt, | ||
getText: getText, | ||
getParentText: getParentText | ||
nodeAtSelection: nodeAtSelection, | ||
contextAtSelection: contextAtSelection, | ||
removeAt: removeAt, | ||
getText: getText, | ||
getParentText: getParentText, | ||
remove: remove, | ||
replaceWithText: replaceWithText | ||
}; |
{ | ||
"name": "draftmirror", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "React component for ProseMirror providing a Draft.js like API", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
70009
1766