Yatay kuralı temsil eden bir öğe. HorizontalRule, ListItem veya Paragraph içinde yer alabilir ancak kendisi başka bir öğe içeremez. Belge yapısı hakkında daha fazla bilgi için Google Dokümanlar'ı genişletme rehberine bakın.
Yöntemler
| Yöntem | Dönüş türü | Kısa açıklama |
|---|---|---|
copy() | Horizontal | Geçerli öğenin ayrılmış, derin bir kopyasını döndürür. |
get | Object | Öğenin özelliklerini alır. |
get | Element|null | Öğenin sonraki kardeş öğesini alır. |
get | Container | Öğenin üst öğesini alır. |
get | Element|null | Öğenin önceki kardeş öğesini alır. |
get | Element | Öğenin Element değerini alır. |
is | Boolean | Öğenin Document sonunda olup olmadığını belirler. |
remove | Horizontal | Öğeyi üst öğesinden kaldırır. |
set | Horizontal | Öğenin özelliklerini ayarlar. |
Ayrıntılı belgeler
copy()
Geçerli öğenin ayrılmış, derin bir kopyasını döndürür.
Öğede bulunan tüm alt öğeler de kopyalanır. Yeni öğenin üst öğesi yok.
Return
HorizontalRule: Yeni kopya.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getAttributes()
Öğenin özelliklerini alır.
Sonuç, her geçerli öğe özelliği için bir özellik içeren bir nesnedir. Her özellik adı, DocumentApp.Attribute numaralandırmasındaki bir öğeye karşılık gelir.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Append a styled paragraph. const par = body.appendParagraph('A bold, italicized paragraph.'); par.setBold(true); par.setItalic(true); // Retrieve the paragraph's attributes. const atts = par.getAttributes(); // Log the paragraph attributes. for (const att in atts) { Logger.log(`${att}:${atts[att]}`); }
Return
Object: Öğenin özellikleri.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getNextSibling()
Öğenin sonraki kardeş öğesini alır.
Bir sonraki kardeş öğe, aynı üst öğeye sahiptir ve geçerli öğeyi takip eder.
Return
Element|null: Sonraki kardeş öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getParent()
Öğenin üst öğesini alır.
Üst öğe, geçerli öğeyi içerir.
Return
ContainerElement|null: Üst öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getPreviousSibling()
Öğenin önceki kardeş öğesini alır.
Önceki kardeş öğe, aynı üst öğeye sahiptir ve geçerli öğeden önce gelir.
Return
Element|null: Önceki kardeş öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getType()
Öğenin ElementType değerini alır.
Belirli bir öğenin tam türünü belirlemek için getType() kullanın.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Obtain the first element in the active tab's body. const firstChild = body.getChild(0); // Use getType() to determine the element's type. if (firstChild.getType() === DocumentApp.ElementType.PARAGRAPH) { Logger.log('The first element is a paragraph.'); } else { Logger.log('The first element is not a paragraph.'); }
Return
ElementType: Öğe türü.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
isAtDocumentEnd()
Öğenin Document sonunda olup olmadığını belirler.
Return
Boolean: Öğenin sekmenin sonunda olup olmadığı.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
removeFromParent()
Öğeyi üst öğesinden kaldırır.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Remove all images in the active tab's body. const imgs = body.getImages(); for (let i = 0; i < imgs.length; i++) { imgs[i].removeFromParent(); }
Return
HorizontalRule|null: Kaldırılan öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setAttributes(attributes)
Öğenin özelliklerini ayarlar.
Belirtilen özellikler parametresi, her özellik adının DocumentApp.Attribute numaralandırmasındaki bir öğe ve her özellik değerinin uygulanacak yeni değer olduğu bir nesne olmalıdır.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Define a custom paragraph style. const style = {}; style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] = DocumentApp.HorizontalAlignment.RIGHT; style[DocumentApp.Attribute.FONT_FAMILY] = 'Calibri'; style[DocumentApp.Attribute.FONT_SIZE] = 18; style[DocumentApp.Attribute.BOLD] = true; // Append a plain paragraph. const par = body.appendParagraph('A paragraph with custom style.'); // Apply the custom style. par.setAttributes(style);
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
attributes | Object | Öğenin özellikleri. |
Return
HorizontalRule: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents