diff --git a/Models/Editor.js b/Models/Editor.js new file mode 100644 index 0000000..9ffd623 --- /dev/null +++ b/Models/Editor.js @@ -0,0 +1,28 @@ +(function (jsOMS) + { + "use strict"; + + jsOMS.Modules.Editor.Editor = function (editor) + { + + }; + + jsOMS.Modules.Editor.prototype.getSelectedText = function() + { + var text = ''; + var activeEl = document.activeElement; + var activeElTagName = activeEl ? activeEl.tagName.toLowerCase() : null; + if ( + (activeElTagName === 'textarea' || activeElTagName === 'input') && + /^(?:text|search|password|tel|url)$/i.test(activeEl.type) && + (typeof activeEl.selectionStart === 'number') + ) { + text = activeEl.value.slice(activeEl.selectionStart, activeEl.selectionEnd); + } else if (window.getSelection) { + text = window.getSelection().toString(); + } + return text; + }; + + }(window.jsOMS = window.jsOMS || {}) +); \ No newline at end of file