sdkjs-plugins icon indicating copy to clipboard operation
sdkjs-plugins copied to clipboard

PasteHtml method callback

Open lorenzoale opened this issue 2 years ago • 1 comments

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?

lorenzoale avatar Sep 15 '22 08:09 lorenzoale

@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 avatar Sep 29 '22 15:09 askonev