I am trying to set a feature to update images on Google documents, similarly LucicTouch add-ons But its "inserted diagram updated" feature, for this, I am currently doing the following:
- Creating named ranges and accumulating its ID on document properties, as well as receiving the image To get data, retrieve later.
- On update, replace call body.getNamedRangeById () and the element with a new generated image.
This works, but I have the following problems that are not with Lucidchart:
- After each update, add a blank line after the image Is given.
- If the user drags it inside the document to restore it and leaves the image, then the designated range disappears and I'm not able to retrieve it later
- If the user centralizes the image, the image returns back to the left, then even copies its features after the update
Does anyone change / update Has a good strategy The image referenced on Google Docs, similarly does the Lucidchart add-on update feature work?
Thanks
The range is moved when the named range is actually lost So they are not very good for your scenario, but there is no other way to identify the elements (which is a great misconception of Google Docs).
In the case of an image, you can use LINK_URL to identify it, which seems to be using the Lucidchart, it does not come in the way of the user, so this can be a good solution. is.
When I insert an image, I imagine about getting a blank row and losing properties (because you have not shared any code), you can insert an image directly into the document body instead of paragraph Going. Then a paragraph is created automatically to clear your image, resulting in empty rows and attributes.
Here is an example of some code:
function initial insert () {var data = charts.New DataTable (). AddColumn (Chart. Column type. STRING, fruit '). AddColumn (Chart, column type number, 'zodiac'). AddRow (['Apple', 15]). AddRow (['Orange', 6]) addRow (['banana', 14]). Build (); Var Chart = Chart.NewEpatch (). Set DataTable (Data) .build (); Var body = Document app.actactive document (). Beacode () Body.Append Image (chart) .setLinkUrl ('http: // mychart'); // Here we are inserting directly into the body, a wrapping paragraph element for us will be created} function updateImage () {var data = Charts.newDataTable (). AddColumn (Charts.ColumnType.STRING, 'Fruits') addColumn (charts, type column, number, 'amount'). (['Apple', monastery.floor (monastery) * 31)]). AddRow (['Ken', Mutt Foolur (Math. Random)) * 31) Random Intel ('Orange', Mathematics) between 0 and 30 .floor (Math.Rendam) * 31)]). ]). Build (); Var Chart = Chart.NewEpatch (). Set DataTable (Data) .build (); Var img = getMyImg (DocumentApp.getActiveDocument (). GetBody (), 'http: // mychart'); // Let's put on the current parent instead of the body, var parent = img.getParent (); // Maybe there is a paragraph, but in fact the parents have no relation. Insert Inline Image (Parents .getChildIndex (IMG) +1, chart) .setLinkUrl ('http: // mychart'); Img.removeFromParent (); } GetMyImg function (docBody, linkUrl) {var imgs = docBody.getImages (); For (var i = 0; i & lt; imgs.length; ++ i) if (IMGS [i] .getLinkUrl () === linkUrl) return IMGS [I]; Return tap; }
Regarding link_url, you can definitely do such a lucid chart and link back to your site. So it's not broken just for the user.
Comments
Post a Comment