@teipublisher/pb-components 1.29.0 → 1.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/pb-components-bundle.js +106 -106
- package/package.json +1 -1
- package/src/pb-view-annotate.js +14 -7
package/package.json
CHANGED
package/src/pb-view-annotate.js
CHANGED
|
@@ -112,12 +112,13 @@ function ancestors(node, selector) {
|
|
|
112
112
|
* @param {Node} node the current node
|
|
113
113
|
* @returns next text node or the current node if none is found
|
|
114
114
|
*/
|
|
115
|
-
function nextTextNode(node) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
function nextTextNode(context, node) {
|
|
116
|
+
const walker = document.createTreeWalker(context, NodeFilter.SHOW_TEXT);
|
|
117
|
+
walker.currentNode = node;
|
|
118
|
+
if (walker.nextNode()) {
|
|
119
|
+
return walker.currentNode;
|
|
119
120
|
}
|
|
120
|
-
return
|
|
121
|
+
return node;
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
/**
|
|
@@ -433,12 +434,16 @@ class PbViewAnnotate extends PbView {
|
|
|
433
434
|
|
|
434
435
|
console.log('<pb-view-annotate> Range before adjust: %o %o', startPoint, endPoint);
|
|
435
436
|
if (startPoint[1] === startPoint[0].textContent.length) {
|
|
436
|
-
|
|
437
|
+
// try to find the next text node
|
|
438
|
+
const nextNode = nextTextNode(context, startPoint[0]);
|
|
437
439
|
// next text node is the endpoint: start there
|
|
438
440
|
if (nextNode === endPoint[0]) {
|
|
439
441
|
range.setStart(nextNode, 0);
|
|
442
|
+
// adjust startPoint for check below
|
|
443
|
+
startPoint[0] = nextNode;
|
|
444
|
+
startPoint[1] = 0;
|
|
440
445
|
} else {
|
|
441
|
-
range.setStartBefore(startPoint[0].nextSibling);
|
|
446
|
+
range.setStartBefore(startPoint[0].nextSibling || nextNode);
|
|
442
447
|
}
|
|
443
448
|
} else if (startPoint[0] !== endPoint[0] && startPoint[1] === 0) {
|
|
444
449
|
range.setStartBefore(extendRange(startPoint[0], context));
|
|
@@ -980,6 +985,7 @@ class PbViewAnnotate extends PbView {
|
|
|
980
985
|
lightness: [30, 60]
|
|
981
986
|
}));
|
|
982
987
|
});
|
|
988
|
+
this.emitTo('pb-annotation-colors', { colors: this._annotationColors });
|
|
983
989
|
}
|
|
984
990
|
|
|
985
991
|
_checkAnnotationColor(type) {
|
|
@@ -992,6 +998,7 @@ class PbViewAnnotate extends PbView {
|
|
|
992
998
|
lightness: [30, 60]
|
|
993
999
|
}));
|
|
994
1000
|
this._annotationStyles();
|
|
1001
|
+
this.emitTo('pb-annotation-colors', { colors: this._annotationColors });
|
|
995
1002
|
}
|
|
996
1003
|
|
|
997
1004
|
_annotationStyles() {
|