react-native-wordpress-editor
Version:
React Native Wrapper for WordPress Rich Text Editor. The WordPress-Editor is the text editor used in the official WordPress mobile apps to create and edit pages & posts
26 lines (19 loc) • 693 B
JavaScript
function Util () {}
/* Tag building */
Util.buildOpeningTag = function(tagName) {
return '<' + tagName + '>';
};
Util.buildClosingTag = function(tagName) {
return '</' + tagName + '>';
};
Util.wrapHTMLInTag = function(html, tagName) {
return Util.buildOpeningTag(tagName) + html + Util.buildClosingTag(tagName);
};
/* Selection */
Util.rangeIsAtStartOfParent = function(range) {
return (range.startContainer.previousSibling == null && range.startOffset == 0);
};
Util.rangeIsAtEndOfParent = function(range) {
return ((range.startContainer.nextSibling == null || range.startContainer.nextSibling == "<br>")
&& range.endOffset == range.endContainer.length);
};