how to get cell object under mouse?
Hello @softboy99
Do I understand it right that there’s the same request? How to get current paragraph of .docx document under cursor?
If so, please avoid duplicating your requests. If I misunderstood the situation, please clarify it.
Hi,
not all the same. when you use plugin to insert content/fields to to the docx, you need to get the target object with api. the mouse position may occure at any postion of the docx
Do you need to move the cursor to specific position or detect its current position? Probably this method might be useful: MoveCursorToPos
If I misunderstood the entire scenario, please provide us with details.
we are developong plugin to drag drop content to cursor position with code, so we need know the object under cursor,so that can refrence the object in plugin code
Hello @softboy99
As far as I understand, you have posted the same request in different thread where the possible solution was provided:How can i find the current cursor position - #9 by Constantine
Additionally, probably this sample might be useful for drag&drop scenario: sdkjs-plugins/connector/example_drop at develop · ONLYOFFICE/sdkjs-plugins · GitHub
If I misunderstood your request, please provide us with details.
Hi,
Thanks for your answer? is there any demo code about how to dragdrop in vue?:
Hello @softboy99
Drag’n’Drop should work out-of-the-box in scenario of dropping in the frame of the editor. Could you please specify the exact issue scenario? If it’s possible, please record a video file.
If I misunderstood the request, please clarify it.
Hi,
can we attach this event in the plugin?
is it an event or method? your documentation are so confusable
Please describe the entire scenario. Are you using self-written plugin (left side of your screenshot) and planning to drag’n’drop data from it to the editor? It’s not clear how you are trying to implement mail merge feature in this scenario.
What exactly is being dragged? Some sort of content controls? and what should happen after dropping? Simple text insert or do you wrap it to mail merge field?
Please show us the entire scenario step-by-step, so we could assist you promptly.
Sorry, there’s no way to attach drop event to the plugin.
Hi,
yes , it’s a self-written plugin.
drop content is “table.entityfieldname” eg. “Syscustomer.name” ,using the following code to wrap in mergefield:
var oRunField = Api.CreateRun();
oRunField.AddText(Asc.scope.field);
targetParagraph.AddElement(oRunField);
oRunField.WrapInMailMergeField();
Hello @softboy99
Technically, your plugin is an HTML page and you can get the content from it for drag’n’drop, but it is not quite clear for me why you would want to use this approach. If you consider my answer from your another topic, you can simply implement insertion of merge fields with InsertContent
method as follows:
let doc = Api.GetDocument();
let para = Api.CreateParagraph();
para.AddText("field name"); // define merge field name
para.WrapInMailMergeField(); // convert the text to a merge field
doc.InsertContent([para], true); // insert merge field into current cursor position
I believe this is the easiest way to achieve your goal, if I understand it correctly.
By the way, are you developing plugin for Docs or for Desktop Editors?
Hi,
Thanks for your help. We need to know whether it is in table for the merge field “TableStart” and “TableEnd” for the following:
Hi,
is there anyway to know the para, which is created by Api.CreateParagraph(), is in table? we need to give the proper merge field “TableStart” and “TableEnd” for the field name:
let para = Api.CreateParagraph();
para.AddText(“field name”); // define merge field name
I am not following your goal with the plugin. As I can see, you have a panel in your plugin with fields to insert into a document, initially you wanted to drag’n’drop them, but I do not see any reason to do that. Since the panel already contains a number of merge fields for insertion, from which you can manually select a field to insert, I do not understand why you would like to know where the cursor is instead of simply putting cursor to required position and then adding the field from the list.
Please provide more details to your designed. For now, it seems we are running in circles.
Hi,
Sorry, for the confusion, we need to define the fieldname, eg. when it in normal cusror postion, the merge field code would be: “<<Sample.sampleNo>>”, however, when it in table, we need to define teh merge field code: “<<TableStart:Sample>> <<>>” or “<<TableEnd:Sample>> <<>>”
I’m afraid there is no such method that would allow getting the object under the cursor and getting its class type. Considering this, I am suggesting to revise the logic of your plugin. You can create as many needed merge fields on your panel and add them by click to cursor position with InsertContent
method only.
Hi,
I doesn’t agree with you, the senario plugin is a general template designer. It’s normal mergefield or TableStart/TableEnd mergefield is decided by the target template not by the plugin.