copy/paste image in rich editor - image

I'm using Rich-faces editor in my application, while using the application through Firefox 4.0.1, I realized that i can copy/paste image into the editor. The pasted image is base64 encoded.
But the problem here is that image(along with the other contents of editor) gets hidden when the page is submitted, but available in the variable bound to that value of editor.
How to avoid the image and text in the editor from vanishing. If a small image is copied to the editor it's retained even after the form is submitted. Help please

Related

How to set the width of text editor when Source is chosen in CKEditor

I am using CKeditor as an editor on my website. The documentation describes how to set the width and height of the editor which works for me. What I can't figure out is how to set the width of the textbox area when the Source is being viewed.
Here is what the CKeditor looks like under when not viewing the Source:
CKEditor when not viewing Source
Here is what the CKeditor looks like when viewing the Source. The area highlighted in yellow shows the editor window when viewing the Source. Notice it doesn't take up the whole CKeditor window like it does when not viewing the Source:
CKeditor when viewing Source
I am trying to figure out how to make the editor window the same size whether viewing Source or not. Any help is greatly appreciated.

How to determine what page a PDF opens on?

I'm generating multi-page PDF reports using pentext, which uses Apache FOP. It all works fine, but when I open the resulting PDF (in macOS Preview), it always opens on the last page rather than the first. This makes me suspect there is some concept of "current page" that is saved as part of the document, which also means there should be some way of manipulating that so that reports open on the first page instead. Can anyone tell me how to set that using FOP?
Alternatively, is there some way of setting what page a PDF document opens on using some other tool that I can use to post-process it?

Copy from Lotus Rich Text Field and paste into Xpages Rich Text Field (CKEditor)

For 20 years I have been able to copy and paste rich text fields from one lotus document to another. But now if I try to copy rich text from a Lotus Document (or another application) into a Rich Text Field in an Xpage, I cannot! Why? Maybe I am doing something wrong.
If I open up the document in the form that is the datastore then I can paste in my rich text contents, and then edit them via the Xpage. But this should be functionality that is available in Xpages.
It is in the XPiNC.
Domino supports 2 ways of storing the contents of a 'Rich Text' item in a Notes Document.
Domino's Native Rich Text format
MIME / Html - Which is used throughout the internet and mail systems.
There is a setting on the Item Properties which determines what format
'Store contents as Mime/html'.
The XPages control only supports MIME / HTML.
When you load a document's Rich Text Item that is stored as the Native Rich Text Format, it converts it from Native to MIME / HTML upon loading the document so that it can be used with the XPages control.
This explains why pasting it into the document and then loading via XPages works, as you are pasting in the Native rich text, but it converts it when opening.
If you try to copy from Notes Client (Native Format) to XPages it will only support whatever format that CKEditor will accept for pasting and I don't think Domino Native Rich Text is one of them.
This is still the same whether using Xpinc or Web browser
If you are going to be doing anything fancy with XPages Rich Text it is worth learning about MIME and how it works as it will save you some headaches.

Firefox Extension that copies HTML link to current web page to clipboard and not just the URL

The Situation
I need to automate the copying of a HTML link to the current page that
is viewed in the current Firefox Tab into other WYSIWYG editors. This
is not the same as copying just the plain-text of the URL, nor is it
the same as pasting just the plain-text of the web pages title. This
is also not the same thing as navigating to some other web page that
has the HTML link to the page of interest, selecting the text with the
mouse cursor, and typing CTRL-C to copy it into the current operating
systems clipboard (both Linux and Windows, should not make any
difference). Only the update to the clipboard is to be automated; the
pasting from the clipboard into the target application will be done
manually.
The desired use case is as follows:
The user browses to any web page from within Firefox.
The user types some user-specified key sequence that is not
in conflict with standard Firefox built-in key bindings.
Firefox will then do only part of what Copy Link Bookmarklet
does: Instead of opening up a new separate window/tab and
constructing and rendering the HTML for the link, and then
requiring the user to waste motion in selecting and copying the
link into the clipboard, the extension will then format the HTML
itself and copy that into the clipboard directly.
The user then selects any of the targets described below and
types CTRL-V to paste the formatted text.
The user then sees the link as a link in that target area, and does
not see anything literal like http://...
For example, if the webpage browsed to was http://www.google.com, and
the user clicked the user-defined key sequence, and if the user pasted
it into some Google Document, what they would see in that document is
not http://www.google.com nor would they see Google, but instead
would see what you would see when you read this in StackOverflow in a
web browser: Google
Now, there are Firefox extensions and bookmarklets that come close,
but they all involve no net reduction in mouse motion and/or key press
overhead, which is the most time-wasting aspect of this frequently
occuring use case. My searches for an existing extension turned
up nothing that exactly meets my needs (see Research section
below). Therefore, I think I may need to roll my own extension (or
modify an existing one), unless someone can point me to an existing
extension that provides this functionality.
The extension I have in mind should work in Firefox version 11 or
greater running on either Linux or any version of Windows. Only
Firefox and a suitable Firefox extension should be needed, and not any
other special software.
Targets of the paste should be:
GMail compose text areas
Google Documents
Microsoft Word documents
Microsoft Outlook compose text areas.
Any other WYSIWYG editor such as the Blogger post editor.
Notepad (in which case it is the web page title that is pasted only
and not the URL, or both the web page title and URL as separate
plaintext; either way).
About user-specified key bindings: If there was an extension already
that did the above but without providing the ability to bind a
keybinding to it, then I would expect to be able to use the keyconfig
extension extension to handle that aspect. Actually, that might
even be preferable; I don't know yet.
Research
Below are approaches I investigated that came close to what I want,
but did not exactly meet the need:
Hacking on Copy Link Bookmarklet won't work because, from what I can tell, there is no way to update the OS's clipboard from a bookmarklet, hence why I think that a Firefox extension is required.
In a Firefox extension, how can I copy rich text / links to the clipboard?
3 FireFox Addons to Easier Copy Links and Anchor Texts -- None of the extensions listed do what I want because they force you to use the right mouse button and navigate down one or two levels of context menu, which is wasted motion.
Copy Link Text (CoLT) -- CoLT also supports copying a hyperlink and it’s associated text as a rich-text formatted link, however it does not include a default keybinding. It looks like someone else is attempting to tie keyconfig to CoLT, which might be an option as a solution.
Copy URL Plus -- Looks like it has the copy-to-clipboard logic, but doesn't look like it has been maintained since Firefox 1.x timeframe.
I am answering my own question:
The CTRL-SHIFT-F11 binding will silently stop working if both keysnail and keyconfig are installed into the same Firefox browser. The fix for me was to simply uninstall keysnail as I don't use it.
I did not actually need to write my own Firefox extension, but I did
need to scrape out a bit of code that copies the richtext link from
the Copy Link Text (CoLT) extension and apply it directly as a
binding into the keyconfig extension as follows:
Install the keyconfig extension.
Restart Firefox.
After Firefox loads up, type CTRL-SHIFT-F12 to bring up the keyconfig configuration menu.
On the bottom of the page, click on the Add a new key button.
In the Name field, type in some suitable name such as Copy Rich Text Link to Current Page.
Type in the following chunk of Javascript code (This code I carved
out of the objCoLT.CopyBoth function inside the content/colt.js
file inside the Copy Link Text (CoLT) extension):
var url = content.document.location.href;
var text = content.document.title;
// Use the users selection instead of the title if text is selected:
var selection = document.commandDispatcher.focusedWindow.getSelection().toString();
if (selection != "")
{
text = selection;
}
var richText = "" + text + "";
var xfer = Components.classes["#mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
xfer.addDataFlavor("text/html");
var htmlString = Components.classes["#mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
htmlString.data = richText;
xfer.setTransferData("text/html", htmlString, richText.length * 2);
var clipboard = Components.classes["#mozilla.org/widget/clipboard;1"].getService(Components.interfaces.nsIClipboard);
clipboard.setData(xfer, null, Components.interfaces.nsIClipboard.kGlobalClipboard);
Click Ok.
Back in the main Keyconfig dialog, <disabled> should be shown in the text field to the left of the Apply button.
Click in that text field, and type the keybinding you want to associate with it, such as CTRL-SHIFT-F11.
Click the Apply button.
Click the Close button to close the Keyconfig configuration dialog box.
To test this out, proceed as follows:
In Firefox, navigate to some arbitrary page.
Type in CTRL-SHIFT-F11 (or whatever keybinding you chose above).
Notice that no dialog boxes popup; that is intentional.
Open up Google Documents, and Create a new document.
Click in the new document, and type CTRL-V.
You should see the HTML/rich-text form of the link pasted in.
Click on the link and then click on the URL to the left of Change.
The browser should open up the original page corresponding to that URL.
I have been able to copy URL as HTML with the following bookmark:
javascript: navigator.clipboard.write([new ClipboardItem({ ["text/html"]: new Blob([`${document.title}`], { type: "text/html" }) })]);
Unfortunately in firefox the Clipboard write API still requires to set thedom.events.asyncClipboard.clipboardItem to true in about:config.
Several extensions exist that offer copying of title and URL but few seem to support Rich Text creation. The key is that the copied text needs to be formatted in html with a href and it needs to be copied as a text/html type.
The extension I went with in the end is CopyTabTitleUrl. (GitHub) It supports both requirements and also has a keybind feature along with a toolbar button that can also function as a single-click copy.
Set the Format option to:
${title}
Then Activate Extended Mode and make sure to check the "Copy in text/html format" option in Other. After that, using the format copy, the result can be correctly pasted into Office applications. And Stack Exchange evidently as the links above were created by the add-on.
Note that the Edge implementation of URL copying seems to be somewhat different still. With a default plaintext paste, Edge will just paste in the URL while this approach will of course paste unformatted HTML. But it's close enough.

Cannot paste an image from clipboard to MS Word

I have an asp.net/C# web application. I have an image steaming .aspx page to render images. I have to copy an image to client's clipboard. So I first load the image in a hidden image box and copy it to clipboard by using javascript command
ctrlRange.execCommand('Copy');
Image does copies to clipboard. It can be pasted in MSPaint. But it cannot paste in MS word. When try to paste it appear as small white box. Requirement is to paste image on MS word.
Thanks
Issue seems to be with "Word paste" doing an additional web request, where as paint or Paste special doesn't do the second request. if the pasting content(image) is behind some sort of authentication (ex.forms authentication), the second request done by Word fails resulting in failing to paste the image properly.
This is related with,
Internet Options -> General -> Browsing history ->Settings->Check for never versions of stored pages. When it's set to automatic, things work as expected even in Word and this fails with the setting "Every time I visit the web-page"

Resources