@cocreate/selection 1.4.28 → 1.4.30
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +15 -0
- package/CoCreate.config.js +6 -22
- package/package.json +4 -4
- package/src/index.js +8 -8
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
## [1.4.30](https://github.com/CoCreate-app/CoCreate-selection/compare/v1.4.29...v1.4.30) (2022-11-23)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* bumped [@cocreate](https://github.com/cocreate) dependencies ([e3c9588](https://github.com/CoCreate-app/CoCreate-selection/commit/e3c9588409ffde1ff777d7908e6404cb84a54917))
|
7
|
+
|
8
|
+
## [1.4.29](https://github.com/CoCreate-app/CoCreate-selection/compare/v1.4.28...v1.4.29) (2022-11-22)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* apply src: {{source}} to CoCreate.config ([59b9d1f](https://github.com/CoCreate-app/CoCreate-selection/commit/59b9d1f214bb888074bcce103699a3c07ec191aa))
|
14
|
+
* workflow docs ([a66f38c](https://github.com/CoCreate-app/CoCreate-selection/commit/a66f38ce2796c2df9b9a603d3f32190558c8a3d5))
|
15
|
+
|
1
16
|
## [1.4.28](https://github.com/CoCreate-app/CoCreate-selection/compare/v1.4.27...v1.4.28) (2022-11-21)
|
2
17
|
|
3
18
|
|
package/CoCreate.config.js
CHANGED
@@ -4,15 +4,15 @@ module.exports = {
|
|
4
4
|
"organization_id": "5ff747727005da1c272740ab",
|
5
5
|
"host": "general.cocreate.app"
|
6
6
|
},
|
7
|
-
|
8
|
-
|
7
|
+
"sources": [
|
8
|
+
{
|
9
9
|
"entry": "./docs/index.html",
|
10
10
|
"collection": "files",
|
11
|
-
"document_id": "60145dc49f64ba1680b86693",
|
12
|
-
"key": "src",
|
13
11
|
"document": {
|
12
|
+
"_id": "637ca63950234ef1671ce331",
|
14
13
|
"name": "index.html",
|
15
14
|
"path": "/docs/selection/index.html",
|
15
|
+
"src": "{{source}}",
|
16
16
|
"domains": [
|
17
17
|
"*",
|
18
18
|
"general.cocreate.app"
|
@@ -23,21 +23,5 @@ module.exports = {
|
|
23
23
|
"website_id": "5ffbceb7f11d2d00103c4535"
|
24
24
|
}
|
25
25
|
}
|
26
|
-
]
|
27
|
-
|
28
|
-
"extract": {
|
29
|
-
"directory": "./src/",
|
30
|
-
"extensions": [
|
31
|
-
"js",
|
32
|
-
"css",
|
33
|
-
"html"
|
34
|
-
],
|
35
|
-
"ignores": [
|
36
|
-
"node_modules",
|
37
|
-
"vendor",
|
38
|
-
"bower_components",
|
39
|
-
"archive"
|
40
|
-
]
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
26
|
+
]
|
27
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@cocreate/selection",
|
3
|
-
"version": "1.4.
|
3
|
+
"version": "1.4.30",
|
4
4
|
"description": "A simple selection component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
|
5
5
|
"keywords": [
|
6
6
|
"selection",
|
@@ -61,8 +61,8 @@
|
|
61
61
|
"webpack-log": "^3.0.1"
|
62
62
|
},
|
63
63
|
"dependencies": {
|
64
|
-
"@cocreate/docs": "^1.
|
65
|
-
"@cocreate/hosting": "^1.
|
66
|
-
"@cocreate/utils": "^1.10.
|
64
|
+
"@cocreate/docs": "^1.4.2",
|
65
|
+
"@cocreate/hosting": "^1.6.1",
|
66
|
+
"@cocreate/utils": "^1.10.21"
|
67
67
|
}
|
68
68
|
}
|
package/src/index.js
CHANGED
@@ -20,7 +20,7 @@ export function getSelection(element) {
|
|
20
20
|
let start = range.startOffset;
|
21
21
|
let end = range.endOffset;
|
22
22
|
let previousSibling = range.startContainer.previousSibling;
|
23
|
-
if(element.innerHTML && previousSibling && previousSibling.nodeType == 3) {
|
23
|
+
if (element.innerHTML && previousSibling && previousSibling.nodeType == 3) {
|
24
24
|
let length = 0;
|
25
25
|
do {
|
26
26
|
length += previousSibling.length;
|
@@ -30,7 +30,7 @@ export function getSelection(element) {
|
|
30
30
|
end += length;
|
31
31
|
}
|
32
32
|
|
33
|
-
if(range.startContainer != range.endContainer) {
|
33
|
+
if (range.startContainer != range.endContainer) {
|
34
34
|
// toDo: replace common ancestor value
|
35
35
|
}
|
36
36
|
let contenteditable = range.startContainer.parentElement.closest('[contenteditable][collection][document_id][name]');
|
@@ -96,23 +96,23 @@ export function processSelection(element, value = "", prev_start, prev_end, star
|
|
96
96
|
if (range) {
|
97
97
|
if (prevStart > prev_start){
|
98
98
|
let length = prevStart - prev_start;
|
99
|
-
if(Math.sign(length) === 1 && range.startOffset >= length)
|
99
|
+
if (Math.sign(length) === 1 && range.startOffset >= length)
|
100
100
|
range.startOffset -= length;
|
101
101
|
}
|
102
102
|
else if (prevStart < prev_start){
|
103
103
|
let length = prev_start - prevStart;
|
104
|
-
if(Math.sign(length) === 1)
|
104
|
+
if (Math.sign(length) === 1)
|
105
105
|
if (range.startOffset == 0 || range.startOffset >= length)
|
106
106
|
range.startOffset += length;
|
107
107
|
}
|
108
108
|
if (prevEnd > prev_end){
|
109
109
|
let length = prevEnd - prev_end;
|
110
|
-
if(Math.sign(length) === 1 && range.endOffset >= length)
|
110
|
+
if (Math.sign(length) === 1 && range.endOffset >= length)
|
111
111
|
range.endOffset -= length;
|
112
112
|
}
|
113
113
|
else if (prevEnd < prev_end){
|
114
114
|
let length = prev_end - prevEnd;
|
115
|
-
if(Math.sign(length) === 1)
|
115
|
+
if (Math.sign(length) === 1)
|
116
116
|
if (range.endOffset == 0 || range.endOffset >= length)
|
117
117
|
range.endOffset += length;
|
118
118
|
}
|
@@ -163,7 +163,7 @@ function getContainer(element, offset){
|
|
163
163
|
|
164
164
|
export function hasSelection(el) {
|
165
165
|
let { start, end } = getSelection(el);
|
166
|
-
if(start != end) {
|
166
|
+
if (start != end) {
|
167
167
|
return true;
|
168
168
|
}
|
169
169
|
}
|
@@ -236,7 +236,7 @@ export function getElementPosition(str, start, end) {
|
|
236
236
|
let insert = getInsertPosition(element);
|
237
237
|
element = insert.target.parentElement;
|
238
238
|
position = insert.position;
|
239
|
-
if(position == 'afterend')
|
239
|
+
if (position == 'afterend')
|
240
240
|
element = element.parentElement;
|
241
241
|
type = 'innerHTML';
|
242
242
|
}
|