paste

How can you intercept pasting into a NSTextView to remove unsupported formatting?

主宰稳场 提交于 2019-12-19 00:08:25
问题 I'm trying to create a simple NSTextView-based window for simple WYSIWYG editing. However, I only want to allow certain types of formatting (e.g. Bold, Italic, Underline and a single heading type but no colors or different fonts.) The issue is if I simply use NSTextView, someone can create or copy formatted text in another program, then simply paste it into that view and all that formatting goes with it, allowing things I'm not allowing, such as different fonts, colors, etc. At best, I want

Is it possible to get pasted text without using the setTimeout() function?

ぐ巨炮叔叔 提交于 2019-12-18 16:46:34
问题 I found out that when pasting text (i.e. Hello ) by using the mouse, the following function will throw an empty popup: $('input:text').onpaste = function() { alert($('input:text').val()); }); The thing is, when the onpaste event is being fired, the text is not yet actually pasted to the input field (at least that's my guess). So changing the function to: $('input:text').onpaste = function() { setTimeout(function() { alert($('input:text').val() }, 100); } gives a correct result by showing a

Is it possible to get pasted text without using the setTimeout() function?

烂漫一生 提交于 2019-12-18 16:46:09
问题 I found out that when pasting text (i.e. Hello ) by using the mouse, the following function will throw an empty popup: $('input:text').onpaste = function() { alert($('input:text').val()); }); The thing is, when the onpaste event is being fired, the text is not yet actually pasted to the input field (at least that's my guess). So changing the function to: $('input:text').onpaste = function() { setTimeout(function() { alert($('input:text').val() }, 100); } gives a correct result by showing a

In chrome, using the window.Clipboard object, is there a way to capture pasted text?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 13:16:39
问题 You can capture an image. I am trying to figure out how to capture text. I'm guessing there isn't, for security reasons, but I wanted to make sure. Also is there a reference for this stuff? window.Clipboard object isn't part of the v8 engine, it's a part of the chrome browser and I can't find official documentation for it. 回答1: In the code you linked there is a pasteHandler function with the following: // Get the items from the clipboard var items = e.clipboardData.items; if (items) { // Loop

“display:none” content copied to clipboard, visible when pasted

荒凉一梦 提交于 2019-12-18 13:09:49
问题 I'm having a problem with non-displayed HTML elements being copied to the clipboard, and then displayed when the content is pasted into MS Word, Outlook, etc. For example: <p>Hello</p> <p style="display: none;">I'm Hidden</p> <p>World</p> If I view that HTML in a browser, copy the text to my clipboard, then paste into Outlook, the middle paragraph remains hidden. Good news. However, in this example: <p>Hello</p> <input type="text" value="I'm not hidden" style="display: none;" /> <p>World</p>

How do I get auto-conversion of Part [[ double-brackets ]] on paste?

倾然丶 夕夏残阳落幕 提交于 2019-12-18 03:38:44
问题 A pet peeve of mine is the use of double square brackets for Part rather than the single character \[LeftDoubleBracket] and \[RightDoubleBracket] . I would like to have these automatically replaced when pasting plain-text code (from StackOverflow for example) into a Mathematica Notebook. I have been unable to configure this. Can it be done with ImportAutoReplacements or another automatic method (preferred), or will I need use a method like the "Paste Tabular Data Palette" referenced here?

NSTextField: exposing its Copy and Paste methods

北城以北 提交于 2019-12-17 20:55:52
问题 I am trying to access the copy, cut, and paste methods of a NSTextField instance in its window delegate so I can customize these methods. I find that unlike tableViews and textViews, the textfield's copy, paste and cut actions are not responsive in the delegate. My understanding is that all text controls share the window's field editor yet this does not seem to be the case. I thought perhaps the TextField's field editor was not being shared with the window delegate, however I did some testing

How to skip a paste() argument when its value is NA in R

折月煮酒 提交于 2019-12-17 19:45:51
问题 I have a data frame with the columns city, state, and country . I want to create a string that concatenates: "City, State, Country". However, one of my cities doesn't have a State (has a NA instead). I want the string for that city to be "City, Country". Here is the code that creates the wrong string: # define City, State, Country city <- c("Austin", "Knoxville", "Salk Lake City", "Prague") state <- c("Texas", "Tennessee", "Utah", NA) country <- c("United States", "United States", "United

How to read clipboard data in cross browser? [duplicate]

こ雲淡風輕ζ 提交于 2019-12-17 19:38:29
问题 This question already has answers here : Closed 8 years ago . Possible Duplicates: Copy / Put text on the clipboard with FireFox, Safari and Chrome How to Copy to Clipboard in JavaScript? Hi , scenario: I copied some content (either from notepad or word) and want to paste it in my iframe. On before pasting i want to manipulate the clipboard content. In IE i can do it with window.clipboardData.getData("Text"); How to read the clipboard data in other browsers (FF/chrome and safari) 回答1: You'll

Clean Microsoft Word Pasted Text using JavaScript

孤人 提交于 2019-12-17 17:30:32
问题 I am using a 'contenteditable' <div/> and enabling PASTE. It is amazing the amount of markup code that gets pasted in from a clipboard copy from Microsoft Word. I am battling this, and have gotten about 1/2 way there using Prototypes' stripTags() function ( which unfortunately does not seem to enable me to keep some tags ). However, even after that, I wind up with a mind-blowing amount of unneeded markup code. So my question is, is there some function (using JavaScript), or approach I can use