I am not a programmer.
Can someone help me with the following.
I am following this guide on how to make a google doc add-on.
http://www.cs.ucr.edu/~vahid/usefulstuff/gdoc_addon/
I have gotten this to work.
What I want to achieve is,
The user types in the google doc as normal and adds words typed in text box (in the sidebar) with some formatting added by app-script, where the cursor is.
for example
//on button click insert text in gdoc where the cursor is
"formatting1" + textbox1-text + "formating2" + textbox2-text + "formating3"
Any help would be appreciated.
Textbox is an image right, so you get all the images and check which one is a textbox image and look for the text inside it by perhaps using a get text method.
DocumentApp.getActiveDocument().getBody().getImages().forEach((elem) => {//your logic});
Related
all. I'm curious to know if the regular text input (not text area) could detect multiple lines value. If I copy any string that has various lines and pastes it into a standard input box, it will display as a single-line string and has no idea whether it has multiple lines or a single line.
I just want to know if we can preserve the original value (with multiple lines)
Original string value
INVOICE_500
INVOICE_501
After pasting it into the regular text input
INVOICE_500 INVOICE_501
Thanks in advance.
I found an article from a previous post where an way has been shown. We can use clipboard API as it copy text as it was written. It was applied on a div. I have converted it on a input field. I have attached the code below. Hope this might help you.
Reference article: Clipboard data on paste event
function handlePaste(e) {
var clipboardData, pastedData;
// Stop data actually being pasted into input
e.stopPropagation();
e.preventDefault();
// Get pasted data via clipboard API
clipboardData = e.clipboardData || window.clipboardData;
pastedData = clipboardData.getData('Text');
// Do whatever with pasteddata
alert(pastedData);
}
document.getElementById('pasteInput').addEventListener('paste', handlePaste);
<input id='pasteInput' placeholder='Paste text here'></div>
No you can't, the only HTML input element that's designed to be multi-line is the "textarea" element.
<textarea name="textArea" cols="40" rows="5">
I'm trying to create a script to format selected text (selected by the user using a mouse) on a Google Slide. For example, the script might change the selected text to Arial Font, size 11, left aligned.
I know how to create a new menu item to run the script within slides - so I've got that part of the puzzle.
I've tried converting a similar script created for Google Sheets ... but it doesn't seem to work with slides.
This is what I have so far:
function onOpen() {
let ui = SlidesApp.getUi();
ui.createMenu('Macros').addItem('ParagraphFormat',
'ParagraphFormat').addToUi();
};
function ParagraphFormat() {
var slide = SlidesApp.getActivePresentation();
slide.getSelection()
.setFontSize(11)
.setFontFamily('Arial');
};
I believe your goal is as follows.
You want to change the text style of the selected text in the text box of Google Slides.
getSelection() returns Class Selection. In this case, there are no methods of setFontSize and setFontFamily. I think that this is the reason for your current issue. When you want to use setFontSize and setFontFamily to the selected text, how about the following modification?
From:
slide.getSelection()
.setFontSize(11)
.setFontFamily('Arial');
To:
var textRange = slide.getSelection().getTextRange();
if (textRange) {
textRange.getTextStyle().setFontSize(11).setFontFamily('Arial');
}
When you use this modification, please select a text in the text box and run the script. By this, setFontSize and setFontFamily are reflected in the selected text.
References:
Class Selection
getTextRange()
Added:
About your new question of One more cheeky question: how would I add one more property to align the text to the left? (eg. adding .setTextAlignment('left') ... but this doesn't work), in the current stage, only a part of the text the text in the text box cannot be aligned. So, in this case, the paragraph of the selected text can be aligned. If you want to do this, how about the following sample script?
var textRange = slide.getSelection().getTextRange();
if (textRange) {
textRange.getTextStyle().setFontSize(11).setFontFamily('Arial');
textRange.getParagraphStyle().setParagraphAlignment(SlidesApp.ParagraphAlignment.START);
}
I am extremely new to Powerapps in fact this is my first project with it. What I want to do is link to a web-page that contains a Knowledge base the body of the hyperlink stays as it is the only thing that changes is the ID it needs to look for.
I have created an app and each article contains its own KB# and i need that KB# to be inserted into the hyperlink. The Text I marked in bold below is the only change in the link. I have created a button that should run the Hyperlink once click and in the OnSelect area I add the below but that is just a static link.
If(Rule2, Launch("https://placeholder.com/nav_to.do?uri=%2Fkb_view.do%3Fsysparm_article%3D||KB0010007||%26sysparm_stack%3D%26sysparm_view%3D")
, Launch("https://placeholder.com/nav_to.do?uri=%2Fkb_view.do%3Fsysparm_article%3DKB0011526%26sysparm_stack%3D%26sysparm_view%3D")
)
You should use string concatenation operator &
In your case:
If(Rule2,
Launch("https://placeholder.com/nav_to.do?uri=%2Fkb_view.do%3Fsysparm_article%3D||KB" & DataSource.column_name & "||%26sysparm_stack%3D%26sysparm_view%3D") ,
Launch("https://placeholder.com/nav_to.do?uri=%2Fkb_view.do%3Fsysparm_article%3DKB0011526%26sysparm_stack%3D%26sysparm_view%3D") )
Can someone tell me how to achieve below UI in Gmail Add-on using Google Apps Script? I tried KeyValue for the icon with text which is clickable and I am able to achieve that but I don't know how to put email text, next to the keyValue icon. Right now, I don't care about the position of the icon with counter and email text, I want them in the same row doesn't matter left or right. This is my code which is just showing icon with counter on the left side but not able to add email text anywhere.
var card = CardService.newCardBuilder()
.setHeader(
CardService.newCardHeader()
.setTitle('some Title')
);
var section = CardService.newCardSection();
var keyValue = CardService.newKeyValue()
.setContent(getNumberOfPosts())
.setIconUrl('https://ayz.png')
.setOnClickAction(action);
section.addWidget(keyValue);
card.addSection(section);
Take a look at this screenshot
I used an emoji for the eye (Add-on support emojis). Does this get you what you are looking for?
settingSection.addWidget(CardService.newKeyValue()
.setContent("User#email.com")
.setOnClickAction(saveAction)
.setButton(CardService.newTextButton()
.setText("👁️ 2")
.setOnClickAction(saveAction))
);
I am looking for a way that I can create custom text on an HTML page dependent on user input from a submit form. I've looked at similar threads online but can't figure out how to do this on my own page.
Basically I have a text area with this default text "My name is and I want to give $10 to charity".
If I have a submit form button how do I get it to take the name entered from the form and then put that value in to the portion of the text?
Thanks
Andrew
This is probably what you are looking for:
http://jsfiddle.net/NbuF6/2/
Basically, you have a textarea (id: final-text) and an input (id: name). The button (this can be changed to the form's onsubmit function if you want to) calls the following JavaScript function to fill the textarea:
function fill_textarea() {
document.getElementById('final-text').value = 'My name is ' + document.getElementById('name').value + ' and I want to give $10 to charity';
}