Skip to content

Commit e3b9fa2

Browse files
authored
Update article.md
1 parent 01c5e49 commit e3b9fa2

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

2-ui/99-ui-misc/02-selection-range/article.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,41 @@
1-
libs:
1+
کتابخانه ها:
22
- d3
33
- domtree
44

55
---
66

77
# Selection and Range
88

9-
In this chapter we'll cover selection in the document, as well as selection in form fields, such as `<input>`.
109

11-
JavaScript can access an existing selection, select/deselect DOM nodes as a whole or partially, remove the selected content from the document, wrap it into a tag, and so on.
10+
جاوااسکریپت می‌تواند به یک انتخاب موجود دسترسی داشته باشد، گره‌های DOM را به‌طور کلی یا جزئی انتخاب یا لغو انتخاب کند، محتوای انتخاب‌شده را از سند حذف کند، آن را در یک برچسب قرار دهد و غیره.
1211

13-
You can find some recipes for common tasks at the end of the chapter, in "Summary" section. Maybe that covers your current needs, but you'll get much more if you read the whole text.
12+
می‌توانید دستور العمل‌هایی برای کارهای رایج در انتهای فصل، در بخش "Summary" بیابید. شاید این نیازهای فعلی شما را پوشش دهد، اما اگر متن کامل را بخوانید، خیلی بیشتر به دست خواهید آورد.
1413

15-
The underlying `Range` and `Selection` objects are easy to grasp, and then you'll need no recipes to make them do what you want.
14+
درک اشیاء زیربنایی `Range` و`Selection` آسان است، و پس از آن برای اینکه آنها را به آنچه می‌خواهید انجام دهند، به هیچ دستور العملی نیاز نخواهید داشت.
1615

1716
## Range
1817

19-
The basic concept of selection is [Range](https://dom.spec.whatwg.org/#ranges), that is essentially a pair of "boundary points": range start and range end.
18+
فهوم اصلی انتخاب [Range](https://dom.spec.whatwg.org/#ranges) است، که اساساً یک جفت "boundary points"است: شروع محدوده و پایان محدوده.
2019

21-
A `Range` object is created without parameters:
20+
21+
یک `Range` object بدون پارامتر ساخته می شود:
2222

2323
```js
2424
let range = new Range();
2525
```
2626

27-
Then we can set the selection boundaries using `range.setStart(node, offset)` and `range.setEnd(node, offset)`.
27+
پس می‌توانیم مرزهای انتخاب را با استفاده از `range.setStart(node, offset)` و `range.setEnd(node, offset)` تنظیم کنیم.
2828

29-
As you might guess, further we'll use the `Range` objects for selection, but first let's create few such objects.
29+
همانطور که ممکن است حدس بزنید، در ادامه از اشیاء `Range` برای انتخاب استفاده خواهیم کرد، اما ابتدا اجازه دهید تعداد کمی از این اشیاء ایجاد کنیم.
3030

3131
### Selecting the text partially
3232

33-
The interesting thing is that the first argument `node` in both methods can be either a text node or an element node, and the meaning of the second argument depends on that.
33+
نکته جالب این است که آرگومان اول `node` در هر دو روش می تواند یک text node یا یelement node عنصر باشد و معنای آرگومان دوم به آن بستگی دارد.
34+
3435

35-
**If `node` is a text node, then `offset` must be the position in its text.**
36+
**اگر `node` یک text nodeاست، `offset` باید موقعیتی در متن آن باشد.**
3637

37-
For example, given the element `<p>Hello</p>`, we can create the range containing the letters "ll" as follows:
38+
به عنوان مثال، با توجه به عنصر `<p>Hello</p>`، می‌توانیم محدوده حاوی حروف «ll» را به صورت زیر ایجاد کنیم:
3839

3940
```html run
4041
<p id="p">Hello</p>
@@ -48,10 +49,9 @@ For example, given the element `<p>Hello</p>`, we can create the range containin
4849
</script>
4950
```
5051

51-
Here we take the first child of `<p>` (that's the text node) and specify the text positions inside it:
52+
در اینجا اولین فرزند `<p>` را می گیریم (این text node است) و موقعیت های متن را در داخل آن مشخص می کنیم:
5253

5354
![](range-hello-1.svg)
54-
5555
### Selecting element nodes
5656

5757
**Alternatively, if `node` is an element node, then `offset` must be the child number.**

0 commit comments

Comments
 (0)