Here are the steps to add a RichLink (Chip Block) into Google Docs using Google Apps Script:
First, open a Google Doc and go to Tools > Script editor.
In the Script editor, create a new script file and name it something like "AddRichLinkToDoc".
Next, in the script file, add the following code to create a RichLink Block:
function createRichLink() {
var richLink = {
title: 'Google',
link: 'https://www.google.com',
description: 'Search the world\'s information, including webpages, images, videos and more.',
thumbnailUrl: 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png'
};
var richLinkBlock = {
richLink: richLink
};
return richLinkBlock;
}
This code creates a new RichLink object with the title, link, description, and thumbnail URL, and then returns a block object containing the RichLink.
function insertRichLink() {
var richLinkBlock = createRichLink();
var selection = DocumentApp.getActiveDocument().getSelection();
if (selection) {
var element = selection.getSelectedElements()[0];
var range = element.getElement().getParent();
range.insertBlock(richLinkBlock);
}
}
This code calls the createRichLink
function to create a new RichLink block, gets the current selection in the document, and then inserts the RichLink block into the document.
insertRichLink
function to add the RichLink to your document.Overall, with these steps, you can easily add RichLink (Chip Block) to Google Doc using Google App Script.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-01 15:16:16 +0000
Seen: 20 times
Last updated: May 01 '23
How can I center a button using CSS if it is not movable?
Why aren't my try-catch blocks catching exceptions in .Net Maui Android?
How can I replace or modify a specific block within a theme layout in Hugo?
What does it mean when the if block is not being executed?
How can strings be added to a code block by looking for a matching string within it?
How to perform AES encryption in Golang using the "global" cipher?