تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
عنصر النطاق
غلاف حول Element مع إزاحة محتملة للبدء والانتهاء تسمح هذه العناصر المرجعية بتمثيل
نطاق من الأحرف ضمن عنصر Text
في نتائج البحث وعمليات اختيار المستندات والنطاقات المُسمّاة.
constrangeElement=DocumentApp.getActiveDocument().getSelection().getRangeElements()[0];// Log debug information about a range element.Logger.log(`Element type: ${rangeElement.getElement().getType()}`);if(rangeElement.isPartial()){Logger.log(`The character range begins at ${rangeElement.getStartOffset()}`);Logger.log(`The character range ends at ${rangeElement.getEndOffsetInclusive()}`,);}else{Logger.log('The entire range element is included.');}
تحصل على موضع نهاية نطاق جزئي ضمن عنصر النطاق. إذا كان العنصر هو عنصر
Text وعرض isPartial() القيمة true، يكون البدء هو عدد الأحرف قبل الحرف
الأول في النطاق (أي فهرس الحرف الأول في النطاق). وفي أي حالة
أخرى، تعرض هذه الطريقة القيمة -1.
الإرجاع
Integer — بالنسبة إلى عناصر Text، هو
عدد الأحرف قبل الحرف الأخير في النطاق، وبالنسبة إلى العناصر الأخرى، هو -1
التفويض
تتطلّب النصوص البرمجية التي تستخدِم هذه الطريقة الحصول على إذن واحد أو أكثر من النطاقات التالية:
تحصل على موضع بداية نطاق جزئي ضمن عنصر النطاق. إذا كان العنصر هو عنصر
Text وعرضت isPartial() القيمة true، يكون البادئة هو عدد الأحرف قبل بداية
النطاق (أي فهرس الحرف الأول في النطاق). وفي أي حالة أخرى، تعرض هذه العبارة
-1.
الإرجاع
Integer: بالنسبة إلى عناصر Text، هو
عدد الأحرف قبل بداية النطاق، وبالنسبة إلى العناصر الأخرى، هو -1
التفويض
تتطلّب النصوص البرمجية التي تستخدِم هذه الطريقة الحصول على إذن واحد أو أكثر من النطاقات التالية:
تحدِّد ما إذا كان عنصر النطاق هذا يغطي العنصر بأكمله أو اختيارًا جزئيًا من
أحرف العنصر. يمكن تحديد بداية ونهاية نطاق عنصر النطاق الجزئي باستخدام getStartOffset() وgetEndOffsetInclusive() على التوالي.
الإرجاع
Boolean: true إذا كان العنصر مضمّنًا جزئيًا، false إذا لم يكن كذلك
التفويض
تتطلّب النصوص البرمجية التي تستخدِم هذه الطريقة الحصول على إذن واحد أو أكثر من النطاقات التالية:
تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003e\u003ccode\u003eRangeElement\u003c/code\u003e is a wrapper around an \u003ccode\u003eElement\u003c/code\u003e that can represent a range of characters within a \u003ccode\u003eText\u003c/code\u003e element.\u003c/p\u003e\n"],["\u003cp\u003eIt is used in search results, document selections, and named ranges, allowing for partial or full element selection.\u003c/p\u003e\n"],["\u003cp\u003eYou can get the corresponding \u003ccode\u003eElement\u003c/code\u003e, determine if the range is partial, and find the start and end positions of partial ranges using its methods.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eRangeElement\u003c/code\u003e methods require authorization with specific scopes, like \u003ccode\u003ehttps://www.googleapis.com/auth/documents\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["RangeElement\n\nA wrapper around an [Element](/apps-script/reference/document/element) with a possible start and end offset. These offsets allow a\nrange of characters within a [Text](/apps-script/reference/document/text)\nelement to be represented in search results, document selections, and named ranges. \n\nMethods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------------|----------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|\n| [getElement()](#getElement()) | [Element](/apps-script/reference/document/element) | Gets the [Element](/apps-script/reference/document/element) that corresponds to this `Range``Element`. |\n| [getEndOffsetInclusive()](#getEndOffsetInclusive()) | `Integer` | Gets the position of the end of a partial range within the range element. |\n| [getStartOffset()](#getStartOffset()) | `Integer` | Gets the position of the start of a partial range within the range element. |\n| [isPartial()](#isPartial()) | `Boolean` | Determines whether this range element covers the entire element or a partial selection of the element's characters. |\n\nDetailed documentation \n\n`get``Element()` \nGets the [Element](/apps-script/reference/document/element) that corresponds to this `Range``Element`.\n\n```javascript\nconst rangeElement = DocumentApp.getActiveDocument().getSelection().getRangeElements()[0];\n\n// Log debug information about a range element.\nLogger.log(`Element type: ${rangeElement.getElement().getType()}`);\nif (rangeElement.isPartial()) {\n Logger.log(`The character range begins at ${rangeElement.getStartOffset()}`);\n Logger.log(\n `The character range ends at ${rangeElement.getEndOffsetInclusive()}`,\n );\n} else {\n Logger.log('The entire range element is included.');\n}\n```\n\nReturn\n\n\n[Element](/apps-script/reference/document/element) --- the element that corresponds to this `Range``Element`\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/documents.currentonly`\n- `https://www.googleapis.com/auth/documents`\n\n*** ** * ** ***\n\n`get``End``Offset``Inclusive()` \nGets the position of the end of a partial range within the range element. If the element is a\n[Text](/apps-script/reference/document/text) element and [isPartial()](#isPartial()) returns `true`, the offset is the number of characters before the last\ncharacter in the range (that is, the index of the last character in the range); in any other\ncase, this method returns `-1`.\n\nReturn\n\n\n`Integer` --- for [Text](/apps-script/reference/document/text) elements, the\nnumber of character before the last character in the range; for other elements, `-1`\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/documents.currentonly`\n- `https://www.googleapis.com/auth/documents`\n\n*** ** * ** ***\n\n`get``Start``Offset()` \nGets the position of the start of a partial range within the range element. If the element is a\n[Text](/apps-script/reference/document/text) element and [isPartial()](#isPartial()) returns `true`, the offset is the number of characters before the start of\nthe range (that is, the index of the first character in the range); in any other case, this\nmethod returns `-1`.\n\nReturn\n\n\n`Integer` --- for [Text](/apps-script/reference/document/text) elements, the\nnumber of characters before the start of the range; for other elements, `-1`\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/documents.currentonly`\n- `https://www.googleapis.com/auth/documents`\n\n*** ** * ** ***\n\n`is``Partial()` \nDetermines whether this range element covers the entire element or a partial selection of the\nelement's characters. The beginning and end of a partial range element's range can be\ndetermined using [getStartOffset()](#getStartOffset()) and [getEndOffsetInclusive()](#getEndOffsetInclusive()), respectively.\n\nReturn\n\n\n`Boolean` --- `true` if the element is partially included; `false` if not\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/documents.currentonly`\n- `https://www.googleapis.com/auth/documents`"]]