Skip to content

Commit 7d0a189

Browse files
committed
2-ui/99-ui-misc/02: Translation
1 parent 62879a4 commit 7d0a189

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ libs:
66

77
# Selection і Range
88

9-
У цьому розділі ми розглянемо виділення у документі, або в полях форми, наприклад в ,`<input>`.
9+
У цьому розділі ми розглянемо виділення у документі та в полях форми, наприклад в ,`<input>`.
1010

1111
JavaScript може отримати доступ до наявного виділення тексту, вибирати/скасовувати виділення вузлів DOM повністю або частково, видаляти вибраний вміст із документа, або обгорнути його в тег тощо.
1212

@@ -16,25 +16,25 @@ JavaScript може отримати доступ до наявного виді
1616

1717
## Range
1818

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.
19+
Основою виділення є [Range](https://dom.spec.whatwg.org/#ranges), який по своїй суті є парою "граничних точок": початком і кінцем діапазону.
2020

21-
A `Range` object is created without parameters:
21+
Об'єкт `Range`(діапазон) створюється без параметрів:
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

31-
### Selecting the text partially
31+
### Часткове виділення тексту
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` в обох методах може бути або текстовим вузлом, або вузлом елементом, і від цього залежить значення другого аргументу.
3434

35-
**If `node` is a text node, then `offset` must be the position in its text.**
35+
**Якщо `node` -- це текстовий вузол, то `offset` має бути позицією в його тексті.**
3636

37-
For example, given the element `<p>Hello</p>`, we can create the range containing the letters "ll" as follows:
37+
Наприклад, в елементі `<p>Hello</p>`, ми можемо створити діапазон, що містить літери "ll" таким чином:
3838

3939
```html run
4040
<p id="p">Hello</p>
@@ -43,28 +43,28 @@ For example, given the element `<p>Hello</p>`, we can create the range containin
4343
range.setStart(p.firstChild, 2);
4444
range.setEnd(p.firstChild, 4);
4545
46-
// toString of a range returns its content as text
46+
// toString діапазону повертає його вміст як текст
4747
console.log(range); // ll
4848
</script>
4949
```
5050

51-
Here we take the first child of `<p>` (that's the text node) and specify the text positions inside it:
51+
Тут ми беремо перший дочірній елемент всередині `<p>` (це текстовий вузол) і вказуємо позиції тексту для виділення:
5252

5353
![](range-hello-1.svg)
5454

55-
### Selecting element nodes
55+
### Виділення вузлів елементів
5656

57-
**Alternatively, if `node` is an element node, then `offset` must be the child number.**
57+
**Проте, якщо `node` є вузлом елементом, тоді `offset` має бути номером дочірнього елементу.**
5858

59-
That's handy for making ranges that contain nodes as a whole, not stop somewhere inside their text.
59+
Це зручно для створення діапазонів, які містять вузли в цілому, а не зупиняються десь усередині їхнього тексту.
6060

61-
For example, we have a more complex document fragment:
61+
Наприклад, маємо більш складний фрагмент документу:
6262

6363
```html autorun
6464
<p id="p">Example: <i>italic</i> and <b>bold</b></p>
6565
```
6666

67-
Here's its DOM structure with both element and text nodes:
67+
Ось його структура DOM з елементами та текстовими вузлами:
6868

6969
<div class="select-p-domtree"></div>
7070

@@ -102,9 +102,9 @@ let selectPDomtree = {
102102
drawHtmlTree(selectPDomtree, 'div.select-p-domtree', 690, 320);
103103
</script>
104104

105-
Let's make a range for `"Example: <i>italic</i>"`.
105+
Зробимо діапазон для `"Example: <i>italic</i>"`.
106106

107-
As we can see, this phrase consists of exactly two children of `<p>`, with indexes `0` and `1`:
107+
Як ми бачимо, ця фраза складається рівно з двох нащадків `<p>` з індексами `0` і `1`:
108108

109109
![](range-example-p-0-1.svg)
110110

0 commit comments

Comments
 (0)