قوانین و رفتار ویرایش ساختاری
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
این بخش رفتارها و محدودیتهایی را توضیح میدهد که باید هنگام ویرایش اسناد با استفاده از Google Docs API درک کنید.
به طور کلی، شما نمی توانید ویرایش هایی را که باعث ساختار نامعتبر عناصر در یک سند می شود، اجرا کنید. هر روش درخواست documents.batchUpdate
را برای محدودیتها و قوانین اعمال شده برای آن درخواستها بررسی کنید.
بخشهای زیر قوانین کلیدی این روشها را خلاصه میکند.
درج متن
- درج یک کاراکتر خط جدید به طور ضمنی یک
Paragraph
در آن شاخص ایجاد می کند. سبک پاراگراف پاراگراف جدید از پاراگراف در نمایه درج فعلی، شامل لیست ها و گلوله ها، کپی می شود. - متن باید در محدوده یک
Paragraph
موجود درج شود. به عنوان مثال، متن را نمی توان در فهرست شروع جدول درج کرد. متن باید در پاراگراف قبل درج شود. - API ممکن است به طور ضمنی مکان را برای جلوگیری از درج در خوشههای گرافی یونیکد تنظیم کند. هنگامی که این اتفاق می افتد، متن بلافاصله بعد از خوشه نمودار درج می شود.
- سبک های متن برای متن درج شده به طور خودکار تعیین می شوند و به طور کلی سبک متن همسایه را حفظ می کنند. به طور معمول، سبک متن برای متن درج شده با متن بلافاصله قبل از نمایه درج مطابقت دارد.
- برخی از نویسههای کنترلی (
U+0000-U+0008, U+000C-U+001F
) و نویسههای منطقه استفاده خصوصی هواپیمای چند زبانه پایه یونیکد ( U+E000-U+F8FF
) از متن درجشده حذف میشوند. - برای اطلاعات بیشتر، درج، حذف، و انتقال متن را ببینید.
درج تصاویر درون خطی
- اندازه تصویر باید کمتر از 50 مگابایت باشد، نباید بیش از 25 مگاپیکسل باشد و باید در یکی از فرمتهای PNG، JPEG یا GIF باشد.
- URI ارائه شده باید در دسترس عموم و حداکثر 2 کیلوبایت باشد.
- تصویر باید در محدوده یک
Paragraph
موجود درج شود. به عنوان مثال، متن را نمی توان در فهرست شروع جدول درج کرد. - تصاویر را نمی توان در پاورقی یا معادله درج کرد.
- برای اطلاعات بیشتر، درج تصاویر درون خطی را ببینید.
قالب بندی متن
- وقتی قالب بندی در سطح پاراگراف را برای یک محدوده اعمال می کنید، قالب بندی برای هر پاراگرافی اعمال می شود که به طور جزئی یا کامل با آن محدوده همپوشانی داشته باشد.
- دامنه ممکن است برای شامل خطوط جدید مجاور گسترش یابد.
- اگر محدوده به طور کامل شامل یک پاراگراف متعلق به یک لیست باشد، گلوله پاراگراف نیز با سبک متن منطبق به روز می شود.
- برای اطلاعات بیشتر، به قالب بندی متن مراجعه کنید.
گلوله های پاراگراف ایجاد کنید
- گلوله هایی را برای همه پاراگراف هایی که با محدوده داده شده همپوشانی دارند ایجاد می کند.
- سطح تودرتوی هر پاراگراف با تعداد زبانه های پیشرو قبل از هر پاراگراف تعیین می شود.
- هنگام ایجاد گلوله ها، برگه های اصلی حذف می شوند، که ممکن است نمایه های بخش هایی از متن را تغییر دهد.
- اگر گلولههای پاراگراف را که دقیقاً قبل از پاراگراف مورد نظر مطابق با موارد فهرست است اضافه کنید، آن پاراگراف به لیست ملحق میشود.
- برای اطلاعات بیشتر، به کار با لیست ها مراجعه کنید.
متن را حذف کنید
حذف متنی که از مرز پاراگراف عبور می کند ممکن است باعث ایجاد تغییراتی در سبک های پاراگراف، لیست ها، اشیاء قرار داده شده و نشانک ها با ادغام دو پاراگراف شود.
حذف هایی که باعث ساختار سند نامعتبر می شوند مجاز نیستند. چند نمونه از درخواست های حذف نامعتبر عبارتند از:
برای اطلاعات بیشتر، درج، حذف، و انتقال متن را ببینید.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Structural edit rules and behavior\n\nThis section describes behaviors and limitations that you must understand when\nyou edit documents using the Google Docs API.\n\nIn general, you cannot execute edits that cause the invalid structure of\nelements within a document. Review each\n[`documents.batchUpdate`](/workspace/docs/api/reference/rest/v1/documents/batchUpdate)\nrequest method for constraints and rules that apply to those\n[requests](/workspace/docs/api/reference/rest/v1/documents/request).\n\nThe following sections summarize the key rules across these methods.\n\nInsert text\n-----------\n\n- Inserting a newline character implicitly creates a [`Paragraph`](/workspace/docs/api/reference/rest/v1/documents#paragraph) at that index. The paragraph style of the new paragraph is copied from the paragraph at the current insertion index, including lists and bullets.\n- Text must be inserted within the bounds of an existing `Paragraph`. For example, text cannot be inserted at a table's start index. The text must be inserted in the preceding paragraph.\n- The API may implicitly adjust the location to prevent insertions within Unicode grapheme clusters. When this happens, the text is inserted immediately after the grapheme cluster.\n- Text styles for inserted text are determined automatically, generally preserving the styling of neighboring text. Typically, the text style for the inserted text matches the text immediately before the insertion index.\n- Some control characters (`U+0000-U+0008, U+000C-U+001F`) and characters from the Unicode Basic Multilingual Plane Private Use Area (`U+E000-U+F8FF`) are stripped out of inserted text.\n- For more information, see [Insert, delete, and move\n text](/workspace/docs/api/how-tos/move-text).\n\nInsert inline images\n--------------------\n\n- Image must be less than 50 MB in size, cannot exceed 25 megapixels, and must be in one of PNG, JPEG, or GIF formats.\n- The provided URI must be publicly accessible and at most 2 KB in length.\n- Image must be inserted within the bounds of an existing `Paragraph`. For example, text cannot be inserted at a table's start index.\n- Images can't be inserted inside a footnote or equation.\n- For more information, see [Insert inline\n images](/workspace/docs/api/how-tos/images).\n\nFormat text\n-----------\n\n- When you apply paragraph-level formatting to a range, the formatting is applied to any paragraph that's partially or completely overlapped by that range.\n- The range might be extended to include adjacent newlines.\n- If the range fully contains a paragraph belonging to a list, the paragraph's bullet is also updated with the matching text style.\n- For more information, see [Format\n text](/workspace/docs/api/how-tos/format-text).\n\nCreate paragraph bullets\n------------------------\n\n- Creates bullets for all paragraphs that overlap with the given range.\n- The nesting level of each paragraph is determined by the number of leading tabs before each paragraph.\n- The leading tabs are removed when creating the bullets, which might change the indexes of parts of the text.\n- If you add paragraph bullets that match those of a list immediately before the target paragraph, the paragraph is joined to the list.\n- For more information, see [Work with lists](/workspace/docs/api/how-tos/lists).\n\nDelete text\n-----------\n\n- Deleting text that crosses a paragraph boundary might cause changes to\n paragraph styles, lists, positioned objects, and bookmarks as the two\n paragraphs are merged.\n\n- Deletions that cause an invalid document structure are not permitted. Some\n examples of invalid delete requests include:\n\n - Deleting one code unit of a surrogate pair.\n\n - Deleting the last newline character of a\n [`Body`](/workspace/docs/api/reference/rest/v1/documents#body),\n [`Header`](/workspace/docs/api/reference/rest/v1/documents#header),\n [`Footer`](/workspace/docs/api/reference/rest/v1/documents#footer),\n [`Footnote`](/workspace/docs/api/reference/rest/v1/documents#footnote),\n [`TableCell`](/workspace/docs/api/reference/rest/v1/documents#tablecell), or\n [`TableOfContents`](/workspace/docs/api/reference/rest/v1/documents#tableofcontents).\n\n - Deleting the start or end of a\n [`Table`](/workspace/docs/api/reference/rest/v1/documents#table),\n `TableOfContents`, or\n [`Equation`](/workspace/docs/api/reference/rest/v1/documents#equation)\n without deleting the entire element.\n\n - Deleting the newline character before a `Table`, `TableOfContents`, or\n [`SectionBreak`](/workspace/docs/api/reference/rest/v1/documents#sectionbreak)\n without deleting the element.\n\n - Deleting individual rows or cells of a table. Deleting the content in a\n table cell is allowed.\n\n- For more information, see [Insert, delete, and move\n text](/workspace/docs/api/how-tos/move-text).\n\nRelated topics\n--------------\n\n- [Structure of a Google Docs document](/workspace/docs/api/concepts/structure)\n- [Requests and responses](/workspace/docs/api/concepts/request-response)"]]