Chrome - Copy/Paste - Maintains Styling When Pasted Into Word - javascript

When I copy and paste from my app into word, it maintains the css styles.
This is only an issue from chrome.
Is there a workaround for this?
For both Ctr+C and from Context menu?

You can press CTRL + T immediately after pasting in Word to keep only text.
The default paste options in Word can also be configured to keep only text.

Related

Using the vscode-regex plugin?

I've installed the vscode-regex plugin and I'm now attempting to get it to work. I have the following javascript and text document side by side in VSCode:
However I'm not getting any matches in the email.txt document. I tried the keyboard commant ctrl + alt + m, but still no love. Any ideas?
The instructions of the VS-Code Regex Preview Plugin look straightforward: Just open the test and the sample in side-by-side view, hit the hotkey Ctrl+Alt+M (⌥⌘M).
Unfortunately, I run into the same and could not get it working initially.
The solution: I've used the hotkey, then click the grey link: Test Regex...
Actually, the link and the hotkey do the same. However, the hotkey only works after the matching has been triggered by the link or clicking the actual regex pattern (as mentioned by Mark) first.

Copy webpage as it is rendered, regardless of underlaying source

So I have this webpage that I want to copy to a word document. It's an installation guide and we want to use that but add comments relating to how we installed the program in our environment.
Simple problem. Just copy and paste, right? Wrong.
Problem is, this specific webpage is built up of <div ..> tags, where a couple of checkboxes enable/disable them relating to your choices. So I check the box that marks an installation in Linux, and all div tags relating to that installation option are shown.
Example from the source:
<div class="forWindows forAIX forLinux forZLinux forPLinux forSolaris">...</div>
<div class="forJTS"> ... </div>
<div class="forCCM"> ... </div>
This means, that whenever I copy and paste a part of the webpage I get all the content, regardless of what I actually see on the screen. What I want is to just copy the webpage as I see it on the screen.
I've tried to copy from Internet Explorer and Firefox both to MS Word and to a basic text editor with the same results.
I want the result to be text so I can edit it, so screenshots or exporting to PDF won't work.
I could save the source HTML, remove the tags that dont apply and open the local html file, except that it's quite alot of work. Also the page seems to rely heavily on scripts on the serverside, so I guess that may cause some issues.
Ideally I'd like to preserve the formatting as it is shown aswell.
To reproduce the issue:
Go to the IBM's interactive guide for installing Rational Team Concert.
Select any choices, but to verify step 5-6 below, choose Linux as OS.
Click "Get your interactions"
Copy/paste a part of the webpage and compare the pasted version with what is seen in the browser.
Go to Step 3, "set up the database" in the guide. Copy all the content between "What to do next" in the previous step to the end of the heading in step 3. All in all, about 6 lines.
Paste in a texteditor, you should now see text that only relates to zOS and IBMi operating systems.
It seems that the behaviour on copy and pasting is undefined. Some browsers will copy ignoring the styling that hides stuff and others will copy including styles (ie some will include hidden text and others will not).
A rough summary of browsers seems to be:
IE - copies hidden text on IE8 and presumably older, no idea about newer.
FF - newer versions will not copy hidden text, older versions it seems will. Unknown where the cutoff is but it seems to be somewhere between version 3 and version 14. :)
Chrome - my current version (19.0.1084.52) will copy just the visible text. Untested on any other version.
I would simply screenshot the page and use a simple graphics editing program to crop the image and add annotations.
To screenshot a page, press Print screen (probably shorted as PrtScn on your keyboard). That copies the screenshot into memory.
Now, in your graphics editing program or even word processor, click paste (or press ctrl-v). The screenshot will appear. Crop and add annotations as per your desire.
Write a bookmarklet that concatenates #text nodes together but only when the parent element has a computed-style where display != none and visiblity != hidden.

Firefox contenteditable image selected after drop - can't remove selection

If you drag-and-drop around an image in Firefox in a contenteditable area, sometimes the images will end up being selected like this:
Fiddle here: http://jsfiddle.net/zupa/qg5Qh/
You may need to drag-drop it a few times, I have this bug in like 20+% of the time.
I am using Firefox 13.0.1 on Windows 7
How to remove that selection? Any help is appreciated.
Ps:
It is not available as a range via document.getselection().getRangeAt(..)
Firefox does NOT add any HTML attributes, still if I hit save (custom CMS), and reload the page in contenteditable mode, the selection comes back. Seems to be an annoying bug.
It does it reliably when the image is within a word that is marked by Firefox as a spelling error. For example, here's your jsFiddle with the image moved into the middle of the word "Lorem": http://jsfiddle.net/timdown/qg5Qh/1/
It seems to be something to do with the styling applied to misspelled words. Add the word "Lorem" to the browser's dictionary and the image styling goes away.
You could switch spellchecking off using the spellcheck attribute. From what I can gather, you have to do this at the <body> level in Firefox because it doesn't seem to work on single contenteditable elements as it does for textareas.
Demo: http://jsfiddle.net/timdown/qg5Qh/2/

How to remove the Pop up message coming from FCKEditor when we paste text from a word file

I am using FCK Editor and when I try to paste some code from word in the editor, I get some pop up messages as follows:-
1)"Because of your browser security settings,the editor is not able to access your clipboard data directly. You are required to paste it again in this window.
Please paste inside the following box using the keyboard (Ctrl+V) and hit OK."
2) "The text you want to paste seems to be copied from Word. Do you want to clean it before pasting?"
These two messages are displayed on two different machines.
I don't want both these popups. I want to allow user to paste text from word without these popups
Please provide me a solution to resolve this issue, so that I can paste text from word files also.
Thanks in advance.
These pop-ups are there for a reason. Getting content from the clipboard is rightly generally impossible in JavaScript so browser-based rich text editors have to work round this as best they can. I know that CKEditor (FCKeditor's replacement) uses a trick that redirects a user paste to an offscreen element, which gives the editor access to pasted content before it's inserted into the editor; I think this trick may not be implemented in FCKeditor, so you may want to consider trying CKEditor.
Try this add-on for Firefox
https://addons.mozilla.org/en-US/firefox/addon/allowclipboard-helper/
Reference: http://support.mozilla.org/questions/754412‎

CKEditor force paste from word?

I have a application using the CK editor, where users typically paste content from word.
When the paste from word function is used, then the content is cleaned properly. The problem is with users not using paste from word, then the HTML gets into a state that our application can't clean.
Has anyone found out a way of either forcing using paste from word for word content or automatically apply the logic used when paste from word, even if paste is directly into editor?
I would not like to completely turn off paste into the editor directly, rather I'd like to detect a word paste and then clean the data (as paste from word), or disallowing a paste from word but allowing normal text paste.
I'm using version 3.0.1 CK editor
Figured out that this was included in version 3.1 of CK Editor, then all paste in to normal edit window is passed through the word clean up function.

Categories