Skip to content

Html header simplification test.#191

Merged
pyscripter merged 1 commit intoTurboPack:masterfrom
MShark67:HTMLExport
Feb 28, 2022
Merged

Html header simplification test.#191
pyscripter merged 1 commit intoTurboPack:masterfrom
MShark67:HTMLExport

Conversation

@MShark67
Copy link
Contributor

No description provided.

@MShark67
Copy link
Contributor Author

MShark67 commented Feb 28, 2022

This one works in my tests, but so did the other one. Maybe it will help! And I was wrong about the offsets, they were correct.

@pyscripter pyscripter merged commit 67f0a45 into TurboPack:master Feb 28, 2022
@pyscripter
Copy link
Contributor

Still the same issues. Why did you say that " the "offset" section of the clipboard format is totally wrong (the StartHTML, EndHTML, and start and end fragment numbers.)" They look correct to me, but if they are not that needs fixing.

@pyscripter
Copy link
Contributor

Also the reference to the documentation should be changed to:
https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767917(v=vs.85)

The older link does not work.

@MShark67
Copy link
Contributor Author

The offsets are correct. I was wrong about that completely and mentioned it in the pull request note. Any idea what may not be working in your tests? Did it used to work for you? I don't think I changed any of the actual functionality. Is there a commit I can look at where it worked before? I'd like to solve this mystery ;)

@pyscripter
Copy link
Contributor

I have no idea. I think it never worked with Gmail and Thunderbird. On the other hand it works well with Office applications. Can you post a small compiled app with Synedit to check whether it works here?

@MShark67
Copy link
Contributor Author

MShark67 commented Mar 1, 2022

Aha! I've just tested on a Windows 10 machine and html pasting works in Office apps, but not in gmail! On my Win 11 machine they all work perfectly. I have no idea why, but at least now I've seen it fail and can try to find out why. I'll report back when I have something.

@pyscripter
Copy link
Contributor

pyscripter commented Mar 1, 2022

I am on Windows 11 and still fails on two machines.

@MShark67
Copy link
Contributor Author

MShark67 commented Mar 1, 2022

Darn it lol. Well at least I've seen it fail now. What browser do you use for gmail? Any thoughts on something to try?

@MShark67
Copy link
Contributor Author

MShark67 commented Mar 1, 2022

And on a humorous note... now it fails three times faster than before!

@pyscripter
Copy link
Contributor

I have tried on Edge.
I have no idea, but I would double check the offsets first and then use some kind of clipboard monitor.
I debugged TSynEditDataObject.GetData with Thunderbird and it does ask for the HTML format first and I assume for some reason is rejected and it then asks for the unicode format.

Excel appears to be asking for the HTML format twice!

@MShark67
Copy link
Contributor Author

MShark67 commented Mar 1, 2022

Just compared VSCode's clipboard info to ours. Interesting! I may have a fix soon.

@pyscripter
Copy link
Contributor

By the way what did you use to introspect the clipboard?

@MShark67
Copy link
Contributor Author

MShark67 commented Mar 1, 2022

I'm just pulling the text back out using the code below. I've found several differences between what VSCode does and what we do now. I've got it sorted and now just doing cleanup and testing before a pr.

function TSynEditHelper.GetClipboardAsHTML: String;
var
  CF_HTML: Word;
  Data: THandle;
  Ptr: Pointer;
  Error: DWORD;
  Size: NativeUInt;
  utf8: UTF8String;
begin
  Result := '';
  CF_HTML := RegisterClipboardFormat('HTML Format');
  Clipboard.Open;
  try
    Data := Clipboard.GetAsHandle(CF_HTML);
    if Data = 0 then
     raise Exception.Create('HTML data not found on clipboard');
    Ptr := GlobalLock(Data);
    if not Assigned(Ptr) then begin
      Error := GetLastError;
      raise Exception.Create('GlobalLock failed: ' + SysErrorMessage(Error));
    end;
    try
      Size := GlobalSize(Data);
      if Size = 0 then begin
        Error := GetLastError;
        raise Exception.Create('GlobalSize failed: ' + SysErrorMessage(Error));
      end;
      SetString(utf8, PAnsiChar(Ptr), Size - 1);
      Result := String(utf8);
    finally
      GlobalUnlock(Data);
    end;
  finally
    Clipboard.Close;
  end;
end;

@MShark67 MShark67 deleted the HTMLExport branch March 2, 2022 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments