|
|
#1 |
|
Junior Member
Join Date: Nov 2006
Posts: 19
|
Hello, is it possible to force text that's in the clipboard to be pasted as "plain-text" in the HTMLEditor?
The common situation is: 1) Copy text from IE/Other browser 2) The text in the clipboard is in HTML/Rich text format with formattings etc 3) When pasted in the HTML edit control, all formattings are kept, therefore the pasted result may look bad because of missing CSS etc. Any ideas? Thanks in advance, Mikael |
|
|
|
|
|
#2 |
|
Junior Member
Join Date: Nov 2006
Posts: 19
|
Just to clearify a bit.. The problem is that I cannot catch the OnPaste event before the actual content is pasted. If I could, I think I could "recreate" the clipboard content as text or something like that.
Regards, Mikael |
|
|
|
|
|
#3 |
|
Developer
Join Date: Aug 2006
Posts: 140
|
|
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Nov 2006
Posts: 19
|
Thanks for the reply SergeV,
Any ideas where I can found documentation/examples for this? Thanks, Mikael |
|
|
|
|
|
#5 |
|
Developer
Join Date: Aug 2006
Posts: 140
|
|
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Nov 2006
Posts: 19
|
Thanks a lot SergeV,
After a few hours struggling with the method I finally managed to solve it. Regards, Mikael |
|
|
|
|
|
#7 |
|
Developer
Join Date: Aug 2006
Posts: 140
|
|
|
|
|
|
|
#8 |
|
Main Developer
Join Date: May 2006
Posts: 805
|
Stojo303, could you post some source code? Would help other people too.
|
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Nov 2006
Posts: 19
|
Sure, but I can only publish the very basics of my code:
The FilterDataObject method looks like the code below. Comments will follow after the code block: var Dataobject: TDOText; Formats: IEnumFORMATETC; TempFormat: TFormatEtc; ss: string; Found: boolean; begin Result := S_FALSE; pDO.EnumFormatEtc(DATADIR_GET, Formats); Found := False; while (not Found) and (Formats.Next(1, TempFormat, nil) = S_OK) do begin if TempFormat.cfFormat = CF_TEXT then begin ss := GetTextData(pDO, TempFormat); Dataobject := TDOText.Create(nil); Dataobject.Text := ss; ppDORet := Dataobject; found := true; Result := S_OK; end; end; end; The most code should be pretty straightforward. The method "GetTextData" just extracts the textual contents for the specific format to a string. TDOText is a class I have written which basicly just implements the IDataObject interface. (It is derived from TInterfacedObject). I cannot publish that class since it's "owned" by my company. Anyway, I hope the code above helps a bit. Regards, Mikael |
|
|
|
|
|
#10 |
|
Developer
Join Date: Jan 1970
Posts: 1,295
|
Cool
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|