timdown / rangyinputs Goto Github PK
View Code? Open in Web Editor NEWRangy Inputs
License: MIT License
Rangy Inputs
License: MIT License
I tried to set the focus to an input element and used insertText ( with behavior as carettoend) to add a character the same text field. As per the document, I assume that the cursor position will be updated and it was visible though. For next insert, I tried to fetch the caret position (updated) using getSelection after setting focus() and proceed with next insertion. Every time it returns 0 and the insertion happens at 0th position only.
Do you have any plan to extend support for contenteditable
DIVs? That would be super awesome ๐
I love this library and it works great in across all browsers, except I found an IE 9 bug in surroundSelectedText()
. I am testing with IE 9.0.8112.16421 in Windows 7; the version shipped in the modern.ie Windows 7 IE 9 virtual machine.
If I have the following text in a <textarea> let's wrap this text OK?
and I select this text
from left-to-right with the mouse, I get let's wrap <strong></strong>this text OK?
with the following function call.
function stabButtonWrapSimple(event) {
var tag = event.data.tag;
// Drupal.settings.stab.textareaId is the id including # of the element.
$(Drupal.settings.stab.textareaId).focus();
// Wrap tag around selected text.
$(Drupal.settings.stab.textareaId).surroundSelectedText("<" + tag + ">", "</" + tag + ">");
}
Is this something you would / could address? I am using this code in production and haven't been able to find a workaround.
Please add this library to cdnjs.
Firstly, thanks this awesome tool helping my day.
Here is a bug report, hopes it can help others.
In IE 8, the return object of $().getSelection().text
is buggy.
I found out the reason.
The reason is the new-line symbol in IE8 is \r\n
and IE11 or FF or Chrome is \n
This makes setSelection()
and getSelection()
buggy.
/*
<textarea id="area"> a
b</textarea>
*/
$("#area").setSelection(1,3);
$("#area").getSelection();
Thanks.
@timdown
I would like to use your library in a project that I'm working on. Could you please add a License to the project?
Textarea scrolls down when I do .insertText or .surroundText
As I wrote on stackoverflow: http://stackoverflow.com/q/41609647/4477899 other inputs field in the page don't work, I found it really strange.
Thank you in advance for any advice, best regards.
With the minified JS, if you put the cursor in a <textarea>
, and don't select anything, then issue $('textarea').extractSelectedText()
in the browser console, it deletes the character before the cursor, as if you pressed backspace.
The -src.js
file doesn't behave this way. The version of both files is allegedly 1.2.0.
We use rangyinputs in a Chrome extension, and many times the line
getBody().appendChild(testTextArea);
throws
Cannot read property 'appendChild' of undefined
Probably in pages where they don't have a proper "body".
Demo not working to me, your Jquery link seems to be down
Use dispatchEvent('input')
when text is manipulated in the textarea so other plugins can detect this.
Would be useful to have this published as an NPM module. It's convenient when using webpack and not having to rely on bower.
I think it would be great to get this plugin listed on Bower, it works really well and I think others could benefit from it. I would be glad to help get it listed.
http://bower.io/docs/creating-packages/
As title, I tried to use this plugin before document.ready and got
TypeError: $(...).getSelection is not a function
It would be nice if the Start argument in insertText() and related functions was optional and defaulted to .getSelection()['start']
So one would not have to do
$('#foo').insertText('Bar', $('#foo').getSelection()['start']);
but simply
$('#foo').insertText('Bar');
to insert at current caret position.
I'm using this lovely little library to try to replace CodeMirror in the Ghost Editor with a plain textarea and I stumbled across the fact that making changes to a textarea with rangyinputs doesn't work with the browsers internal undo/redo.
I know that this is far from a simple problem to solve, and I'm also aware that you probably know far more about it than I do, seeing as researching the problem turned up this ๐
As the answer to the question "can this be solved?" is "sort of", I was wondering if having support in rangyinputs would be welcomed either by default, or via an option?
I am using editor and i want to be replace button in editor menu. so that i have problem that selection text paste as |%selected_text%|
Like that selected Text is that Dhaval
replaced by : |%Dhaval%|
remove this character second time replacement to selected text Dhaval remove this character.
http://jsfiddle.net/varsadadj/7gcr6/
please give me right solution for this issue. for a long time i have this problem in my application.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.