عنصر يمثّل منطقة نص منسّق يجب أن يكون كل النص في Document مضمّنًا في عناصر Text.
يمكن أن يكون العنصر Text مضمّنًا في Equation أو Equation أو List أو Paragraph، ولكن لا يمكن أن يتضمّن أي عنصر آخر. لمزيد من المعلومات حول بنية المستند، يُرجى الاطّلاع على دليل توسيع "مستندات Google".
// Gets the body contents of the active tab. const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Use editAsText to obtain a single text element containing // all the characters in the tab. const text = body.editAsText(); // Insert text at the beginning of the tab. text.insertText(0, 'Inserted text.\n'); // Insert text at the end of the tab. text.appendText('\nAppended text.'); // Make the first half of the tab blue. text.setForegroundColor(0, text.getText().length / 2, '#00FFFF');
الطُرق
| الطريقة | نوع القيمة التي يتم إرجاعها | وصف قصير |
|---|---|---|
append | Text | تضيف هذه الطريقة النص المحدّد إلى نهاية منطقة النص هذه. |
copy() | Text | تعرض نسخة منفصلة وعميقة من العنصر الحالي. |
delete | Text | لحذف نطاق من النص |
edit | Text | يحصل على نسخة Text من العنصر الحالي لتعديلها. |
find | Range | يبحث في محتوى العنصر عن نمط النص المحدّد باستخدام التعبيرات العادية. |
find | Range | يبحث في محتوى العنصر عن نمط النص المحدّد، بدءًا من نتيجة بحث معيّنة. |
get | Object | يستردّ سمات العنصر. |
get | Object | تعرض هذه الطريقة السمات في موضع الإزاحة المحدّد للحرف. |
get | String|null | تعرض هذه السمة إعداد لون الخلفية. |
get | String|null | تعرض هذه السمة لون الخلفية عند موضع الحرف المحدّد. |
get | String|null | تعرض هذه السمة إعدادات مجموعة الخطوط. |
get | String|null | تعرض هذه السمة مجموعة الخطوط في موضع الإزاحة المحدّد للحرف. |
get | Number|null | تعرض هذه السمة إعدادات حجم الخط. |
get | Number|null | تعرض هذه السمة حجم الخط عند الإزاحة المحدّدة للحرف. |
get | String|null | تعرض هذه السمة إعداد لون المقدّمة. |
get | String|null | تعرض هذه السمة لون المقدّمة عند موضع الحرف المحدّد. |
get | String|null | تعرض هذه السمة عنوان URL للرابط. |
get | String|null | يستردّ عنوان URL للرابط عند موضع الإزاحة المحدّد للحرف. |
get | Element|null | يستردّ العنصر الشقيق التالي للعنصر. |
get | Container | تعرض هذه السمة العنصر الرئيسي للعنصر الحالي. |
get | Element|null | يستردّ هذا الإجراء العنصر الشقيق السابق للعنصر. |
get | String | تعرض محتوى العنصر كسلسلة نصية. |
get | Text | تعرض هذه السمة محاذاة النص. |
get | Text | تعرض هذه السمة محاذاة النص لحرف واحد. |
get | Integer[] | تعرض هذه السمة مجموعة فهارس النصوص التي تتوافق مع بداية عمليات تنسيق النصوص المميّزة. |
get | Element | يستردّ Element العنصر. |
insert | Text | تُدرج هذه الطريقة النص المحدّد في موضع الإزاحة المحدّد للحرف. |
is | Boolean | تحدّد هذه السمة ما إذا كان العنصر في نهاية Document. |
is | Boolean|null | تعرض هذه السمة إعداد النص الغامق. |
is | Boolean|null | تعرض هذه السمة إعداد النص الغامق عند إزاحة الحرف المحدّدة. |
is | Boolean|null | تعرض هذه السمة إعداد الخط المائل. |
is | Boolean|null | تعرض هذه السمة إعداد الخط المائل عند إزاحة الحرف المحدّدة. |
is | Boolean|null | تعرض هذه السمة إعداد التشطيب. |
is | Boolean|null | تعرض هذه الطريقة إعداد التشطيب عند موضع الحرف المحدّد. |
is | Boolean|null | تعرض هذه السمة إعداد التسطير. |
is | Boolean|null | تعرض هذه الطريقة إعداد التسطير عند موضع الحرف المحدّد. |
merge() | Text|null | يدمج العنصر مع العنصر الشقيق السابق من النوع نفسه. |
remove | Text|null | يزيل العنصر من العنصر الأصل. |
replace | Element | لاستبدال جميع تكرارات نمط نصي معيّن بسلسلة استبدال معيّنة، باستخدام التعبيرات العادية. |
set | Text | تُطبِّق هذه الدالة السمات المحدّدة على نطاق الأحرف المحدّد. |
set | Text | تضبط هذه السمة سمات العنصر. |
set | Text | تضبط هذه السمة لون الخلفية لنطاق الأحرف المحدّد. |
set | Text | تضبط هذه السمة لون الخلفية. |
set | Text | تضبط هذه السمة إعداد النص الغامق. |
set | Text | تضبط هذه السمة إعداد الخط العريض لنطاق الأحرف المحدّد. |
set | Text | تضبط هذه السمة مجموعة الخطوط لنطاق الأحرف المحدّد. |
set | Text | تضبط هذه السمة مجموعة الخطوط. |
set | Text | تضبط هذه السمة حجم الخط لنطاق الأحرف المحدّد. |
set | Text | تضبط هذه السمة حجم الخط. |
set | Text | تضبط هذه السمة لون المقدّمة لنطاق الأحرف المحدّد. |
set | Text | لضبط لون المقدّمة. |
set | Text | تضبط هذه السمة إعداد الخط المائل. |
set | Text | تضبط هذه السمة إعداد الخط المائل لنطاق الأحرف المحدّد. |
set | Text | تضبط هذه السمة عنوان URL للرابط لنطاق الأحرف المحدّد. |
set | Text | يضبط عنوان URL للرابط. |
set | Text | تضبط هذه السمة إعداد التشطيب. |
set | Text | تضبط هذه السمة إعداد التشطيب لنطاق الأحرف المحدّد. |
set | Text | تضبط هذه السمة محتوى النص. |
set | Text | تضبط هذه السمة محاذاة النص لنطاق أحرف معيّن. |
set | Text | تضبط هذه السمة محاذاة النص. |
set | Text | تضبط هذه السمة إعداد التسطير. |
set | Text | يضبط إعداد التسطير لنطاق الأحرف المحدّد. |
مستندات تفصيلية
append Text(text)
تضيف هذه الطريقة النص المحدّد إلى نهاية منطقة النص هذه.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Adds the text, 'Sample body text,' to the end of the tab body. const text = body.editAsText().appendText('Sample body text');
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
text | String | النص المطلوب إلحاقه |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
copy()
تعرض نسخة منفصلة وعميقة من العنصر الحالي.
يتم أيضًا نسخ أي عناصر فرعية مضمّنة في العنصر. لا يحتوي العنصر الجديد على عنصر رئيسي.
الإرجاع
Text: النسخة الجديدة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
delete Text(startOffset, endOffsetInclusive)
لحذف نطاق من النص
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Deletes the first 10 characters in the body. const text = body.editAsText().deleteText(0, 9);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
start | Integer | إزاحة الحرف الأول المطلوب حذفه |
end | Integer | إزاحة الحرف الأخير المطلوب حذفه |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
edit As Text()
يحصل على نسخة Text من العنصر الحالي لتعديلها.
استخدِم edit لمعالجة محتوى العناصر كنص منسّق. يتجاهل الوضع edit العناصر غير النصية (مثل Inline وHorizontal).
تتم إزالة العناصر الفرعية التي يتم تضمينها بالكامل في نطاق نص محذوف من العنصر.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Insert two paragraphs separated by a paragraph containing an // horizontal rule. body.insertParagraph(0, 'An editAsText sample.'); body.insertHorizontalRule(0); body.insertParagraph(0, 'An example.'); // Delete " sample.\n\n An" removing the horizontal rule in the process. body.editAsText().deleteText(14, 25);
الإرجاع
Text: نسخة نصية من العنصر الحالي
find Text(searchPattern)
يبحث في محتوى العنصر عن نمط النص المحدّد باستخدام التعبيرات العادية.
لا تتوافق مجموعة فرعية من ميزات التعبيرات العادية في JavaScript بشكل كامل، مثل مجموعات الالتقاط ومعدّلات الوضع.
تتم مطابقة نمط التعبير العادي المقدَّم بشكل مستقل مع كل كتلة نصية مضمّنة في العنصر الحالي.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
search | String | النمط المطلوب البحث عنه |
الإرجاع
Range — نتيجة بحث تشير إلى موضع نص البحث، أو قيمة فارغة إذا لم تكن هناك أي مطابقة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
find Text(searchPattern, from)
يبحث في محتوى العنصر عن نمط النص المحدّد، بدءًا من نتيجة بحث معيّنة.
لا تتوافق مجموعة فرعية من ميزات التعبيرات العادية في JavaScript بشكل كامل، مثل مجموعات الالتقاط ومعدّلات الوضع.
تتم مطابقة نمط التعبير العادي المقدَّم بشكل مستقل مع كل كتلة نصية مضمّنة في العنصر الحالي.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
search | String | النمط المطلوب البحث عنه |
from | Range | نتيجة البحث التي تريد البحث منها |
الإرجاع
Range: نتيجة بحث تشير إلى الموضع التالي لنص البحث، أو قيمة فارغة إذا لم تكن هناك أي مطابقة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Attributes()
يستردّ سمات العنصر.
والنتيجة هي عنصر يحتوي على سمة لكل سمة عنصر صالحة، حيث يتطابق اسم كل سمة مع عنصر في التعداد Document.
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]}`); }
الإرجاع
Object: سمات العنصر
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Attributes(offset)
تعرض هذه الطريقة السمات في موضع الإزاحة المحدّد للحرف.
والنتيجة هي عنصر يحتوي على سمة لكل سمة نصية صالحة، حيث يتطابق اسم كل سمة مع عنصر في التعداد Document.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Declares style attributes. const style = {}; style[DocumentApp.Attribute.BOLD] = true; style[DocumentApp.Attribute.ITALIC] = true; style[DocumentApp.Attribute.FONT_SIZE] = 29; // Sets the style attributes to the tab's body. const text = body.editAsText(); text.setAttributes(style); // Gets the style attributes applied to the eleventh character in the // body and logs them to the console. const attributes = text.getAttributes(10); console.log(attributes);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
offset | Integer | إزاحة الحرف |
الإرجاع
Object: سمات العنصر
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Background Color()
تعرض هذه السمة إعداد لون الخلفية.
الإرجاع
String|null: لون الخلفية، منسَّقًا في ترميز CSS (مثل '#ffffff')، أو null إذا كان العنصر يحتوي على قيم متعدّدة لهذه السمة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Background Color(offset)
تعرض هذه السمة لون الخلفية عند موضع الحرف المحدّد.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the background color of the first 3 characters in the body. const text = body.editAsText().setBackgroundColor(0, 2, '#FFC0CB'); // Gets the background color of the first character in the body. const backgroundColor = text.getBackgroundColor(0); // Logs the background color to the console. console.log(backgroundColor);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
offset | Integer | إزاحة الحرف |
الإرجاع
String|null: لون الخلفية، بتنسيق CSS (مثل '#ffffff')
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Font Family()
تعرض هذه السمة إعدادات مجموعة الخطوط. يمكن أن يكون الاسم أي خط من قائمة "الخط" في "مستندات Google" أو Google Fonts، وهو حسّاس لحالة الأحرف. تستخدم الطريقتان get وset الآن أسماء السلاسل للخطوط بدلاً من تعداد . على الرغم من أنّ هذا التعداد
قد تم إيقافه نهائيًا، سيظل متاحًا لضمان التوافق مع النصوص البرمجية القديمة.Font
الإرجاع
String|null: عائلة الخط، أو القيمة null إذا كان العنصر يحتوي على قيم متعددة لهذه السمة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Font Family(offset)
تعرض هذه السمة مجموعة الخطوط في موضع الإزاحة المحدّد للحرف. يمكن أن يكون الاسم أي خط من قائمة الخطوط في "مستندات Google" أو Google Fonts، وهو حساس لحالة الأحرف. تستخدم الطريقتان get وset
الآن أسماء السلاسل للخطوط بدلاً من التعداد . على الرغم من أنّ هذا النوع من التعدادات قد تم إيقافه نهائيًا، سيظل متاحًا لضمان التوافق مع النصوص البرمجية القديمة.
Font
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the font of the first 16 characters to Impact. const text = body.editAsText().setFontFamily(0, 15, 'Impact'); // Gets the font family of the 16th character in the tab body. const fontFamily = text.getFontFamily(15); // Logs the font family to the console. console.log(fontFamily);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
offset | Integer | إزاحة الحرف |
الإرجاع
String|null: مجموعة الخطوط
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Font Size()
تعرض هذه السمة إعدادات حجم الخط.
الإرجاع
Number|null: حجم الخط، أو قيمة فارغة إذا كان العنصر يحتوي على قيم متعدّدة لهذه السمة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Font Size(offset)
تعرض هذه السمة حجم الخط عند الإزاحة المحدّدة للحرف.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the font size of the first 13 characters to 15. const text = body.editAsText().setFontSize(0, 12, 15); // Gets the font size of the first character. const fontSize = text.getFontSize(0); // Logs the font size to the console. console.log(fontSize);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
offset | Integer | إزاحة الحرف |
الإرجاع
Number|null: حجم الخط
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Foreground Color()
تعرض هذه السمة إعداد لون المقدّمة.
الإرجاع
String|null: لون المقدّمة، منسّق في ترميز CSS (مثل '#ffffff')، أو null
إذا كان العنصر يحتوي على قيم متعدّدة لهذه السمة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Foreground Color(offset)
تعرض هذه السمة لون المقدّمة عند موضع الحرف المحدّد.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the foreground color of the first 3 characters in the tab body. const text = body.editAsText().setForegroundColor(0, 2, '#0000FF'); // Gets the foreground color of the first character in the tab body. const foregroundColor = text.getForegroundColor(0); // Logs the foreground color to the console. console.log(foregroundColor);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
offset | Integer | إزاحة الحرف |
الإرجاع
String|null: لون المقدّمة، بتنسيق CSS (مثل '#ffffff').
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Link Url()
تعرض هذه السمة عنوان URL للرابط.
الإرجاع
String|null: عنوان URL للرابط، أو null إذا كان العنصر يحتوي على قيم متعددة لهذه السمة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Link Url(offset)
يستردّ عنوان URL للرابط عند موضع الإزاحة المحدّد للحرف.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Applies a link to the first 10 characters in the body. const text = body.editAsText().setLinkUrl(0, 9, 'https://www.example.com/'); // Gets the URL of the link from the first character. const link = text.getLinkUrl(0); // Logs the link URL to the console. console.log(link);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
offset | Integer | إزاحة الحرف |
الإرجاع
String|null: عنوان URL للرابط
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Next Sibling()
يستردّ العنصر الشقيق التالي للعنصر.
العنصر الشقيق التالي له العنصر الرئيسي نفسه ويتبع العنصر الحالي.
الإرجاع
Element|null: العنصر الشقيق التالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Parent()
تعرض هذه السمة العنصر الرئيسي للعنصر الحالي.
يحتوي العنصر الرئيسي على العنصر الحالي.
الإرجاع
Container: العنصر الرئيسي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Previous Sibling()
يستردّ هذا الإجراء العنصر الشقيق السابق للعنصر.
العنصر الشقيق السابق له العنصر الرئيسي نفسه ويسبق العنصر الحالي.
الإرجاع
Element|null: العنصر الشقيق السابق
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Text()
تعرض محتوى العنصر كسلسلة نصية.
الإرجاع
String: محتوى العنصر كسلسلة نصية
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Text Alignment()
تعرض هذه السمة محاذاة النص. تشمل أنواع المحاذاة المتاحة Document وDocument وDocument.
الإرجاع
Text: نوع محاذاة النص، أو null إذا كان النص يحتوي على أنواع متعدّدة من محاذاة النص أو إذا لم يتم ضبط محاذاة النص مطلقًا
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Text Alignment(offset)
تعرض هذه السمة محاذاة النص لحرف واحد. تشمل أنواع المحاذاة المتاحة Document وDocument وDocument.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the text alignment of the tab's body to NORMAL. const text = body.editAsText().setTextAlignment(DocumentApp.TextAlignment.NORMAL); // Gets the text alignment of the ninth character. const alignment = text.getTextAlignment(8); // Logs the text alignment to the console. console.log(alignment.toString());
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
offset | Integer | إزاحة الحرف |
الإرجاع
Text: نوع محاذاة النص، أو null إذا لم يتم ضبط محاذاة النص مطلقًا
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Text Attribute Indices()
تعرض هذه السمة مجموعة فهارس النصوص التي تتوافق مع بداية عمليات تنسيق النصوص المميّزة.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Gets the text indices at which text formatting changes. const indices = body.editAsText().getTextAttributeIndices(); // Logs the indices to the console. console.log(indices.toString());
الإرجاع
Integer[]: مجموعة مؤشرات النص التي تتغيّر عندها تنسيقات النص
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Type()
يستردّ Element العنصر.
استخدِم get لتحديد النوع الدقيق لعنصر معيّن.
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.'); }
الإرجاع
Element: نوع العنصر
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insert Text(offset, text)
تُدرج هذه الطريقة النص المحدّد في موضع الإزاحة المحدّد للحرف.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Inserts the text, 'Sample inserted text', at the start of the body content. const text = body.editAsText().insertText(0, 'Sample inserted text');
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
offset | Integer | إزاحة الحرف الذي سيتم إدراج النص عنده. |
text | String | النص المطلوب إدراجه |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is At Document End()
تحدّد هذه السمة ما إذا كان العنصر في نهاية Document.
الإرجاع
Boolean: ما إذا كان العنصر في نهاية علامة التبويب.
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Bold()
تعرض هذه السمة إعداد النص الغامق.
الإرجاع
Boolean|null: ما إذا كان النص غامقًا، أو قيمة فارغة إذا كان العنصر يحتوي على قيم متعدّدة لهذه السمة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Bold(offset)
تعرض هذه السمة إعداد النص الغامق عند إزاحة الحرف المحدّدة.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Bolds the first 4 characters in the tab body. const text = body.editAsText().setBold(0, 3, true); // Gets whether or not the text is bold. const bold = text.editAsText().isBold(0); // Logs the text's bold setting to the console console.log(bold);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
offset | Integer | إزاحة الحرف |
الإرجاع
Boolean|null: الإعداد الغامق
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Italic()
تعرض هذه السمة إعداد الخط المائل.
الإرجاع
Boolean|null: ما إذا كان النص مائلاً، أو فارغًا إذا كان العنصر يحتوي على قيم متعدّدة لهذه السمة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Italic(offset)
تعرض هذه السمة إعداد الخط المائل عند إزاحة الحرف المحدّدة.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the first 13 characters of the tab body to italic. const text = body.editAsText().setItalic(0, 12, true); // Gets whether the fifth character in the tab body is set to // italic and logs it to the console. const italic = text.isItalic(4); console.log(italic);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
offset | Integer | إزاحة الحرف |
الإرجاع
Boolean|null: إعداد الخط المائل
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Strikethrough()
تعرض هذه السمة إعداد التشطيب.
الإرجاع
Boolean|null: ما إذا كان النص مشطوبًا، أو فارغًا إذا كان العنصر يحتوي على قيم متعددة لهذه السمة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Strikethrough(offset)
تعرض هذه الطريقة إعداد التشطيب عند موضع الحرف المحدّد.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the first 17 characters of the tab body to strikethrough. const text = body.editAsText().setStrikethrough(0, 16, true); // Gets whether the first character in the tab body is set to // strikethrough and logs it to the console. const strikethrough = text.isStrikethrough(0); console.log(strikethrough);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
offset | Integer | إزاحة الحرف |
الإرجاع
Boolean|null: إعدادات النص المشطوب
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Underline()
تعرض هذه السمة إعداد التسطير.
الإرجاع
Boolean|null: ما إذا كان النص مسطرًا أو فارغًا إذا كان العنصر يحتوي على قيم متعددة لهذه السمة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Underline(offset)
تعرض هذه الطريقة إعداد التسطير عند موضع الحرف المحدّد.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the first 13 characters of the tab body to underline. const text = body.editAsText().setUnderline(0, 12, false); // Gets whether the first character in the tab body is set to // underline and logs it to the console const underline = text.editAsText().isUnderline(0); console.log(underline);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
offset | Integer | إزاحة الحرف |
الإرجاع
Boolean|null: إعداد التسطير
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
merge()
يدمج العنصر مع العنصر الشقيق السابق من النوع نفسه.
يمكن دمج عناصر من Element نفسه فقط. يتم نقل أي عناصر فرعية مضمّنة في العنصر الحالي إلى العنصر الشقيق السابق.
تتم إزالة العنصر الحالي من المستند.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Example 1: Merge paragraphs // Append two paragraphs to the document's active tab. const par1 = body.appendParagraph('Paragraph 1.'); const par2 = body.appendParagraph('Paragraph 2.'); // Merge the newly added paragraphs into a single paragraph. par2.merge(); // Example 2: Merge table cells // Create a two-dimensional array containing the table's cell contents. const cells = [ ['Row 1, Cell 1', 'Row 1, Cell 2'], ['Row 2, Cell 1', 'Row 2, Cell 2'], ]; // Build a table from the array. const table = body.appendTable(cells); // Get the first row in the table. const row = table.getRow(0); // Get the two cells in this row. const cell1 = row.getCell(0); const cell2 = row.getCell(1); // Merge the current cell into its preceding sibling element. const merged = cell2.merge();
الإرجاع
Text|null: العنصر المدمج
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
remove From Parent()
يزيل العنصر من العنصر الأصل.
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(); }
الإرجاع
Text|null: العنصر الذي تمت إزالته
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
replace Text(searchPattern, replacement)
لاستبدال جميع تكرارات نمط نصي معيّن بسلسلة استبدال معيّنة، باستخدام التعبيرات العادية.
يتم تمرير نمط البحث كسلسلة، وليس ككائن تعبير عادي في JavaScript. لهذا السبب، عليك تخطّي أي شرطات مائلة عكسية في النمط.
تستخدِم هذه الطريقة مكتبة RE2 للتعبيرات العادية من Google، ما يحدّ من البنية المتوافقة.
تتم مطابقة نمط التعبير العادي المقدَّم بشكل مستقل مع كل كتلة نصية مضمّنة في العنصر الحالي.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Clear the text surrounding "Apps Script", with or without text. body.replaceText('^.*Apps ?Script.*$', 'Apps Script');
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
search | String | نمط التعبير العادي الذي سيتم البحث عنه |
replacement | String | النص الذي سيتم استخدامه كبديل |
الإرجاع
Element: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Attributes(startOffset, endOffsetInclusive, attributes)
تُطبِّق هذه الدالة السمات المحدّدة على نطاق الأحرف المحدّد.
يجب أن تكون مَعلمة السمات المحدّدة عبارة عن عنصر يكون فيه كل اسم خاصية عنصرًا في التعداد Document، وكل قيمة خاصية هي القيمة الجديدة التي سيتم تطبيقها.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Declares style attributes for font size and font family. const style = {}; style[DocumentApp.Attribute.FONT_SIZE] = 20; style[DocumentApp.Attribute.FONT_FAMILY] = 'Impact'; // Sets the style attributes to the first 9 characters in the tab's body. const text = body.setAttributes(0, 8, style);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
start | Integer | إزاحة بداية نطاق النص |
end | Integer | الإزاحة النهائية لنطاق النص |
attributes | Object | سمات العنصر |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Attributes(attributes)
تضبط هذه السمة سمات العنصر.
يجب أن تكون مَعلمة السمات المحدّدة عبارة عن عنصر يكون فيه كل اسم خاصية عنصرًا في التعداد Document، وكل قيمة خاصية هي القيمة الجديدة التي سيتم تطبيقها.
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);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
attributes | Object | سمات العنصر |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Background Color(startOffset, endOffsetInclusive, color)
تضبط هذه السمة لون الخلفية لنطاق الأحرف المحدّد.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the background color of the first 3 characters in the // tab body to hex color #0000FF. const text = body.editAsText().setBackgroundColor(0, 2, '#0000FF');
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
start | Integer | إزاحة بداية نطاق النص |
end | Integer | الإزاحة النهائية لنطاق النص |
color | String | لون الخلفية، بتنسيق CSS (مثل '#ffffff') |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Background Color(color)
تضبط هذه السمة لون الخلفية.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
color | String | لون الخلفية، بتنسيق CSS (مثل '#ffffff') |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Bold(bold)
تضبط هذه السمة إعداد النص الغامق.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
bold | Boolean | إعداد الخط الغامق |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Bold(startOffset, endOffsetInclusive, bold)
تضبط هذه السمة إعداد الخط العريض لنطاق الأحرف المحدّد.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the first 11 characters in the tab's body to bold. const text = body.editAsText().setBold(0, 10, true);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
start | Integer | إزاحة بداية نطاق النص |
end | Integer | الإزاحة النهائية لنطاق النص |
bold | Boolean | إعداد النص الغامق |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Font Family(startOffset, endOffsetInclusive, fontFamilyName)
تضبط هذه السمة مجموعة الخطوط لنطاق الأحرف المحدّد. يمكن أن يكون الاسم أي خط من قائمة "الخط" في "مستندات Google" أو Google Fonts، وهو حساس لحالة الأحرف.
سيتم عرض أسماء الخطوط غير المعروفة على أنّها Arial. تستخدم الطريقتان get وset الآن أسماء السلاسل للخطوط بدلاً من التعداد . على الرغم من أنّ هذا النوع من التعدادات قد تم إيقافه نهائيًا، سيظل متاحًا لضمان التوافق مع النصوص البرمجية القديمة.
Font
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the font of the first 4 characters in the tab's body to Roboto. const text = body.editAsText().setFontFamily(0, 3, 'Roboto');
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
start | Integer | إزاحة بداية نطاق النص |
end | Integer | الإزاحة النهائية لنطاق النص |
font | String | اسم مجموعة الخطوط، من قائمة "الخط" في "مستندات Google" أو Google Fonts |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Font Family(fontFamilyName)
تضبط هذه السمة مجموعة الخطوط. يمكن أن يكون الاسم أي خط من قائمة "الخط" في "مستندات Google" أو Google Fonts، وهو حسّاس لحالة الأحرف. سيتم عرض أسماء الخطوط غير المعروفة باستخدام خط Arial. تستخدم الطريقتان get وset الآن أسماء السلاسل للخطوط بدلاً من التعداد . على الرغم من أنّ هذا النوع من التعدادات قد تم إيقافه نهائيًا، سيظل متاحًا لضمان التوافق مع النصوص البرمجية القديمة.Font
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
font | String | اسم مجموعة الخطوط، من قائمة "الخط" في "مستندات Google" أو Google Fonts |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Font Size(startOffset, endOffsetInclusive, size)
تضبط هذه السمة حجم الخط لنطاق الأحرف المحدّد.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the size of the first 11 characters in the tab's body to 12. const text = body.editAsText().setFontSize(0, 10, 12);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
start | Integer | إزاحة بداية نطاق النص |
end | Integer | الإزاحة النهائية لنطاق النص |
size | Number | حجم الخط |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Font Size(size)
تضبط هذه السمة حجم الخط.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
size | Number | حجم الخط |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Foreground Color(startOffset, endOffsetInclusive, color)
تضبط هذه السمة لون المقدّمة لنطاق الأحرف المحدّد.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the foreground color of the first 2 characters in the // tab's body to hex color #FF0000. const text = body.editAsText().setForegroundColor(0, 1, '#FF0000'); // Gets the foreground color for the second character in the tab's body. const foregroundColor = text.getForegroundColor(1); // Logs the foreground color to the console. console.log(foregroundColor);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
start | Integer | إزاحة بداية نطاق النص |
end | Integer | الإزاحة النهائية لنطاق النص |
color | String | لون المقدّمة، بتنسيق CSS (مثل '#ffffff') |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Foreground Color(color)
لضبط لون المقدّمة.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
color | String | لون المقدّمة، بتنسيق CSS (مثل '#ffffff') |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Italic(italic)
تضبط هذه السمة إعداد الخط المائل.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
italic | Boolean | إعداد الخط المائل |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Italic(startOffset, endOffsetInclusive, italic)
تضبط هذه السمة إعداد الخط المائل لنطاق الأحرف المحدّد.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the first 11 characters in the tab's body to italic. const text = body.editAsText().setItalic(0, 10, true);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
start | Integer | إزاحة بداية نطاق النص |
end | Integer | الإزاحة النهائية لنطاق النص |
italic | Boolean | إعداد الخط المائل |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Link Url(startOffset, endOffsetInclusive, url)
تضبط هذه السمة عنوان URL للرابط لنطاق الأحرف المحدّد.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Applies a link to the first 11 characters in the body. const text = body.editAsText().setLinkUrl(0, 10, 'https://example.com');
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
start | Integer | إزاحة بداية نطاق النص |
end | Integer | الإزاحة النهائية لنطاق النص |
url | String | تمثّل هذه السمة عنوان URL للرابط. |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Link Url(url)
يضبط عنوان URL للرابط.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
url | String | عنوان URL للرابط |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Strikethrough(strikethrough)
تضبط هذه السمة إعداد التشطيب.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
strikethrough | Boolean | إعداد النص المشطوب |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Strikethrough(startOffset, endOffsetInclusive, strikethrough)
تضبط هذه السمة إعداد التشطيب لنطاق الأحرف المحدّد.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the first 11 characters in the tab's body to strikethrough. const text = body.editAsText().setStrikethrough(0, 10, true);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
start | Integer | إزاحة بداية نطاق النص |
end | Integer | الإزاحة النهائية لنطاق النص |
strikethrough | Boolean | إعداد التشطيب |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Text(text)
تضبط هذه السمة محتوى النص.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Replaces the contents of the body with the text, 'New body text.' const text = body.editAsText().setText('New body text.');
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
text | String | محتوى النص الجديد |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Text Alignment(startOffset, endOffsetInclusive, textAlignment)
تضبط هذه السمة محاذاة النص لنطاق أحرف معيّن. تشمل أنواع المحاذاة المتاحة Document وDocument وDocument.
// Make the first character in the first paragraph of the active tab be // superscript. const documentTab = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab(); const text = documentTab.getBody().getParagraphs()[0].editAsText(); text.setTextAlignment(0, 0, DocumentApp.TextAlignment.SUPERSCRIPT);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
start | Integer | تمثّل هذه السمة إزاحة بداية نطاق الأحرف. |
end | Integer | الإزاحة النهائية لنطاق الأحرف (شاملة) |
text | Text | نوع محاذاة النص المطلوب تطبيقه. |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Text Alignment(textAlignment)
تضبط هذه السمة محاذاة النص. تشمل أنواع المحاذاة المتاحة Document وDocument وDocument.
// Make the entire first paragraph in the active tab be superscript. const documentTab = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab(); const text = documentTab.getBody().getParagraphs()[0].editAsText(); text.setTextAlignment(DocumentApp.TextAlignment.SUPERSCRIPT);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
text | Text | نوع محاذاة النص المطلوب تطبيقه |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Underline(underline)
تضبط هذه السمة إعداد التسطير.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
underline | Boolean | إعداد التسطير |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Underline(startOffset, endOffsetInclusive, underline)
يضبط إعداد التسطير لنطاق الأحرف المحدّد.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the first 11 characters in the tab's body to underline. const text = body.editAsText().setUnderline(0, 10, true);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
start | Integer | إزاحة بداية نطاق النص |
end | Integer | الإزاحة النهائية لنطاق النص |
underline | Boolean | إعداد التسطير |
الإرجاع
Text: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents