Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PasteHtml method callback #175

Open
lorenzoale opened this issue Sep 15, 2022 · 1 comment
Open

PasteHtml method callback #175

lorenzoale opened this issue Sep 15, 2022 · 1 comment
Assignees
Labels
confirmed-bug Issues with confirmed bugs

Comments

@lorenzoale
Copy link

lorenzoale commented Sep 15, 2022

Do you want to request a feature or report a bug?
Question

What is the current behavior?
Hello,
I have a question about the plugin method "pasteHTML" and the moment at which the callback is executed. It seems that the callback is called before the paste is finished.
I did a little video, it needs to be heavy images to have this behaviour, it attached an html with the two images i pasted.
In the video I create two content controls: one called "First part" and another called "Second part".
In between the two I write some text and call the plugin to make several pasteHtmls. The plugin is doing the following:
1- paste a fixed html ("Plugin amethods for OLE objects" text),
2- paste html with another content (containing images or something that takes time, in the video some text and 2 images which are the same),
3- move the cursor to the end of the document,
4- paste again text and images (as in 1 and 2).
Here is the code:

window.Asc.plugin.executeMethod("PasteHtml",
		["<p><b>Plugin amethods for OLE objects</b></p>"],
		function(){
			window.Asc.plugin.executeMethod("PasteHtml",
			[htmlContentSent],
			function (){
				window.Asc.plugin.executeMethod (
					"MoveCursorToEnd",
					[true],
					function(){
						window.Asc.plugin.executeMethod("PasteHtml",
							["<p><b>Plugin bmethods for OLE objects</b></p>"],
							function(){
								window.Asc.plugin.executeMethod("PasteHtml",
									[htmlContentSent]
								);
							}
						);
						}

				);
			});

		}
);

However we can see that it makes the first paste (step 1) where it should (between First part and Second part). But the paste with images (step 2), is done at the end of the document already, after moving the cursor which is not correct because the cursor moved afterwards (at step 3).
I can avoid this problem with a timeout, but I wonder if there is a better way to get the end of the pastHtml.
Thanks in advance.

pasteHtmlTest

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

What is the expected behavior?

Which versions of sdkjs-plugins, and which browser / OS are affected by this issue? Did this work in previous versions of sdkjs-plugins?

@askonev
Copy link
Member

askonev commented Sep 29, 2022

@lorenzoale Yes, the solution at this point is to use a timer. I think this behavior is a bug, so I have created a bug on our internal tracker #59213

@askonev askonev added the confirmed-bug Issues with confirmed bugs label Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs
Projects
None yet
Development

No branches or pull requests

2 participants