Javascript : get content from clipboard with formatting - clipboard

I have a requirement to customise(filter) copied content(from any source) before pasting into my content editable div.
I am using javasctipt window.clipboardData.getData("Text") to get copied content from clipboard. However this method returns only the plain text. I want to get the copied content as is without loosing its formatting. How can I do it? window.clipboardData.getData("Html") doesn't seems to be working. I am using Internet Explorer 11.

you can try with this
var $temp = $("<input>");
$("body").append($temp);
$temp.val($( this ).attr('name')).select();
document.execCommand("copy");
$temp.remove();
and paste

Related

CKEditor : copy and paste email address that contains IMG tags

I having issue in copy and paste in CKEditor. Copied value contains img tag -
Post : "<img/* /src=/images/star.png"
When you copy and paste normally it works, but in my application there is link called as "Copy Email Address" on some post and then paste in ckeditor its pasting as an image.
Is there a way to tell CKEditor to treat this as plain text and dont execute html tags ? Do I need to change onPaste or beforePaste methods in ckeditor.js file.?
I really wanted to paste this as normal text. Is it possible ?

quickreport exporttortf doc without textbox

I use psqrfilters to export a quickreport in .doc using exporttortf. It work´s fine, but all the text in doc is inside a textbox.
Is there a configuration to save it without a textbox ?
ExportToRTF(QuickRep1,'c:\test.doc') ;

Get CKEditor contents without updating the textarea

Fairly new to CKEditor here. I'm aware that you need to call the updateElement() method for CKEditor to send the current editor content to the related textarea element. From there, you can call the getData() function to get the content. (Although I don't understand why there are two steps to get the editor content, instead of one.)
However, I want to get the current content directly from the editor, without changing the related textarea content. Is there a CKEditor method to achieve that, or is it a case of using jQuery to find the editor content?
The getData method will return the raw HTML from the editor.

How can i get Plain text from Ajax Editor?

I need to get both plain text as well as html text from Ajax Editor. I'm able to get the html text and not able to retrieve plain text. i'm not supposed to eliminate html tags from the editor to retrieve plain text.
Is there any property, which gives plain text from ajax editor?
Sample code from my app:
i'm able to get rich html text like this:
string desc = QuestionAndAnswerEditor.Content;
Same way i want plain text.
Please help me.
Use HTML.Encode for getting encoded text. and html.decode ..

How to extract website information using XPath inside firefox extension?

I have made a firefox extension which loads a web page using xmlhttprequest.
My extension has it's own window opened alongside the main Firefox.
The idea of my extension is to load a webpage in memory, modify it and publish in newly opened tab in firefox.
The webpage has a div with id "Content". And that's the div i want to modify. I have been using XPath alot in greaseMonkey scripts and so i wanted to use it in my extension, however, i have a problem. It seems it doesn't work as i would want. I always get the result of 0.
var pageContents = result.responseText; //webpage which was loaded via xmlhttprequest
var localDiv = document.createElement("div"); //div to keep webpage data
localDiv.innerHTML = pageContents;
// trying to evaluate and get the div i need
var rList = document.evaluate('//div[#id="content"]', localDiv, null XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
The result is always 0 as i said. Now i have created the local div to store website data because i cannot parse the text using XPath. And document in this case is my extensions XUL document/window.
I did expect it to work, but i was wrong.
I know how to extract the div using string.indexOf(str) and then slice(..). However, thats very slow and is not handy, because i need to modify the contents. Change the background, borders of the many forms inside this div. And for this job, i have not seen a better method than evaluating XPath to get all the nodes i need.
So main question is, how to use XPath to parse loaded web page in firefox extension?
Thank you
Why not load the page in a tab, then modify it in place, like Greasemonkey does?
As for your code, you don't say where it executes (i.e. what is document.location?), but assuming it runs in a XUL window, it makes no sense -- document.createElement will not create an HTML element (but a XUL div element, which has no special meaning), innerHTML shouldn't work for such element, etc.

Resources