@qualweb/util 0.6.6 → 0.7.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/dist/__webpack/util.bundle.js +1 -1
- package/dist/domUtils/domUtils.d.ts +1 -0
- package/dist/domUtils/domUtils.d.ts.map +1 -1
- package/dist/domUtils/domUtils.js +10 -0
- package/dist/domUtils/getVisibleText.d.ts +4 -0
- package/dist/domUtils/getVisibleText.d.ts.map +1 -0
- package/dist/domUtils/getVisibleText.js +18 -0
- package/package.json +1 -1
|
@@ -23,6 +23,7 @@ declare class DomUtils {
|
|
|
23
23
|
static elementHasContent(element: QWElement, checkChildren: boolean): boolean;
|
|
24
24
|
static isElementHiddenByCSSAux(element: QWElement): boolean;
|
|
25
25
|
static getTrimmedText(element: QWElement): string;
|
|
26
|
+
static getVisibleText(element: QWElement): string;
|
|
26
27
|
}
|
|
27
28
|
export default DomUtils;
|
|
28
29
|
//# sourceMappingURL=domUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domUtils.d.ts","sourceRoot":"","sources":["../../src/domUtils/domUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,kCAAkC,MAAM,8BAA8B,CAAC;AAG9E,OAAO,4BAA4B,MAAM,wBAAwB,CAAC;AAElE,OAAO,0BAA0B,MAAM,0CAA0C,CAAC;AAKlF,OAAO,wBAAwB,MAAM,oBAAoB,CAAC;AAG1D,OAAO,8BAA8B,MAAM,0BAA0B,CAAC;AACtE,OAAO,uBAAuB,MAAM,mBAAmB,CAAC;AACxD,OAAO,mBAAmB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"domUtils.d.ts","sourceRoot":"","sources":["../../src/domUtils/domUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,kCA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G,MAAM;CAGzD;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -28,6 +28,7 @@ const getTrimmedText_1 = __importDefault(require("./getTrimmedText"));
|
|
|
28
28
|
const objectElementIsNonText_1 = __importDefault(require("./objectElementIsNonText"));
|
|
29
29
|
const isHumanLanguage_1 = __importDefault(require("./isHumanLanguage"));
|
|
30
30
|
const getTextSize_1 = __importDefault(require("./getTextSize"));
|
|
31
|
+
const getVisibleText_1 = __importDefault(require("./getVisibleText"));
|
|
31
32
|
const cache_1 = require("../cache");
|
|
32
33
|
class DomUtils {
|
|
33
34
|
static isElementHidden(element) {
|
|
@@ -57,6 +58,9 @@ class DomUtils {
|
|
|
57
58
|
static getTrimmedText(element) {
|
|
58
59
|
return (0, getTrimmedText_1.default)(element);
|
|
59
60
|
}
|
|
61
|
+
static getVisibleText(element) {
|
|
62
|
+
return (0, getVisibleText_1.default)(element);
|
|
63
|
+
}
|
|
60
64
|
}
|
|
61
65
|
DomUtils.getVideoMetadata = getVideoMetadata_1.default;
|
|
62
66
|
DomUtils.getElementReferencedByHREF = getElementReferencedByHREF_1.default;
|
|
@@ -121,4 +125,10 @@ __decorate([
|
|
|
121
125
|
__metadata("design:paramtypes", [Function]),
|
|
122
126
|
__metadata("design:returntype", String)
|
|
123
127
|
], DomUtils, "getTrimmedText", null);
|
|
128
|
+
__decorate([
|
|
129
|
+
(0, cache_1.Cache)('DomUtils.getVisibleText'),
|
|
130
|
+
__metadata("design:type", Function),
|
|
131
|
+
__metadata("design:paramtypes", [Function]),
|
|
132
|
+
__metadata("design:returntype", String)
|
|
133
|
+
], DomUtils, "getVisibleText", null);
|
|
124
134
|
exports.default = DomUtils;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getVisibleText.d.ts","sourceRoot":"","sources":["../../src/domUtils/getVisibleText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,iBAAS,cAAc,CAAC,OAAO,EAAE,SAAS,GAAG,MAAM,CAgBlD;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function getVisibleText(element) {
|
|
4
|
+
const children = element.getElementChildren();
|
|
5
|
+
let text = '';
|
|
6
|
+
if (children.length === 0) {
|
|
7
|
+
text = element.getElementText();
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
for (const child of children) {
|
|
11
|
+
if (window.DomUtils.isElementVisible(child)) {
|
|
12
|
+
text += ' ' + getVisibleText(child);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return text ? text.trim() : '';
|
|
17
|
+
}
|
|
18
|
+
exports.default = getVisibleText;
|