mirror of
https://github.com/Karaka-Management/oms-Editor.git
synced 2026-01-24 15:28:41 +00:00
Creating first function for editor
This commit is contained in:
parent
51d8f85724
commit
c7ff36a006
28
Models/Editor.js
Normal file
28
Models/Editor.js
Normal file
|
|
@ -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 || {})
|
||||
);
|
||||
Loading…
Reference in New Issue
Block a user