@lynx-js/web-elements 0.12.5 → 0.12.7
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
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @lynx-js/web-elements
|
|
2
2
|
|
|
3
|
+
## 0.12.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix internal variable typo (`mesaurement` -> `measurement`). No behavior change. ([#3128](https://github.com/lynx-family/lynx-stack/pull/3128))
|
|
8
|
+
|
|
9
|
+
- Fix x-text custom truncation when inline x-view elements are included in the measured text. ([#2998](https://github.com/lynx-family/lynx-stack/pull/2998))
|
|
10
|
+
|
|
11
|
+
- Update `dompurify` from `^3.3.1` to `^3.4.12` ([#3200](https://github.com/lynx-family/lynx-stack/pull/3200))
|
|
12
|
+
|
|
13
|
+
- Update `markdown-it` from `^14.1.0` to `^14.3.0` ([#3121](https://github.com/lynx-family/lynx-stack/pull/3121))
|
|
14
|
+
|
|
15
|
+
- Document and verify the `message` event forwarded from an `x-webview` iframe. ([#3167](https://github.com/lynx-family/lynx-stack/pull/3167))
|
|
16
|
+
|
|
17
|
+
## 0.12.6
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Fix `x-text` custom inline truncation so inline `x-view` children are measured as one inline box instead of double-counting their descendants as extra lines. ([#2917](https://github.com/lynx-family/lynx-stack/pull/2917))
|
|
22
|
+
|
|
3
23
|
## 0.12.5
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -7,6 +7,39 @@ import { __esDecorate, __runInitializers } from "tslib";
|
|
|
7
7
|
import { boostedQueueMicrotask, genDomGetter, registerAttributeHandler, } from '../../element-reactive/index.js';
|
|
8
8
|
import { commonComponentEventSetting } from '../common/commonEventInitConfiguration.js';
|
|
9
9
|
import { registerEventEnableStatusChangeHandler } from '../../element-reactive/index.js';
|
|
10
|
+
const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
11
|
+
const getSiblingIndex = (node) => {
|
|
12
|
+
let index = 0;
|
|
13
|
+
let previousNode = node.previousSibling;
|
|
14
|
+
while (previousNode) {
|
|
15
|
+
index++;
|
|
16
|
+
previousNode = previousNode.previousSibling;
|
|
17
|
+
}
|
|
18
|
+
return index;
|
|
19
|
+
};
|
|
20
|
+
const getRangePosition = (nodeInfo, offsetInNode) => {
|
|
21
|
+
const { node } = nodeInfo;
|
|
22
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
23
|
+
return {
|
|
24
|
+
container: node,
|
|
25
|
+
offset: clamp(offsetInNode, 0, node.data.length),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// Elements are one virtual character, while DOM Range offsets address child
|
|
29
|
+
// indexes. Use the parent's before/after-element boundary instead.
|
|
30
|
+
const elementOffset = offsetInNode > 0 ? 1 : 0;
|
|
31
|
+
const parentNode = node.parentNode;
|
|
32
|
+
if (!parentNode) {
|
|
33
|
+
return {
|
|
34
|
+
container: node,
|
|
35
|
+
offset: clamp(elementOffset, 0, node.childNodes.length),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
container: parentNode,
|
|
40
|
+
offset: getSiblingIndex(node) + elementOffset,
|
|
41
|
+
};
|
|
42
|
+
};
|
|
10
43
|
let XTextTruncation = (() => {
|
|
11
44
|
var _a;
|
|
12
45
|
let _instanceExtraInitializers = [];
|
|
@@ -144,12 +177,14 @@ let XTextTruncation = (() => {
|
|
|
144
177
|
let currentNodeInfo = measure
|
|
145
178
|
.getNodeInfoByCharIndex(maxLineEndAt);
|
|
146
179
|
const endCharInNodeIndex = end - currentNodeInfo.start;
|
|
147
|
-
|
|
148
|
-
range.
|
|
180
|
+
const initialRangePosition = getRangePosition(currentNodeInfo, endCharInNodeIndex);
|
|
181
|
+
range.setEnd(initialRangePosition.container, initialRangePosition.offset);
|
|
182
|
+
range.setStart(initialRangePosition.container, initialRangePosition.offset);
|
|
149
183
|
while (range.getBoundingClientRect().width < inlineTruncationWidth
|
|
150
184
|
&& (maxLineEndAt -= 1)
|
|
151
185
|
&& (currentNodeInfo = measure.getNodeInfoByCharIndex(maxLineEndAt))) {
|
|
152
|
-
|
|
186
|
+
const rangePosition = getRangePosition(currentNodeInfo, maxLineEndAt - currentNodeInfo.start);
|
|
187
|
+
range.setStart(rangePosition.container, rangePosition.offset);
|
|
153
188
|
}
|
|
154
189
|
}
|
|
155
190
|
else {
|
|
@@ -353,11 +388,11 @@ class TextRenderingMeasureTool {
|
|
|
353
388
|
if (lastRectInfo.node.nodeType === Node.TEXT_NODE) {
|
|
354
389
|
const { rect, rectIndex } = lastRectInfo;
|
|
355
390
|
const textNode = lastRectInfo.node;
|
|
356
|
-
const
|
|
357
|
-
|
|
391
|
+
const measurementRange = document.createRange();
|
|
392
|
+
measurementRange.selectNode(textNode);
|
|
358
393
|
for (let charIndex = 0; charIndex < textNode.data.length; charIndex++) {
|
|
359
|
-
|
|
360
|
-
const targetRect =
|
|
394
|
+
measurementRange.setEnd(textNode, charIndex);
|
|
395
|
+
const targetRect = measurementRange.getClientRects().item(rectIndex);
|
|
361
396
|
if (targetRect && targetRect.right === rect.right) {
|
|
362
397
|
return charIndex;
|
|
363
398
|
}
|
|
@@ -543,6 +578,12 @@ class LazyNodesList {
|
|
|
543
578
|
#treeWalker;
|
|
544
579
|
constructor(dom) {
|
|
545
580
|
this.#treeWalker = document.createTreeWalker(dom, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT, (node) => {
|
|
581
|
+
for (let element = node.parentElement; element && element !== dom; element = element.parentElement) {
|
|
582
|
+
if (element.tagName === 'X-VIEW') {
|
|
583
|
+
// x-view is measured as a single inline box, so skip its subtree.
|
|
584
|
+
return NodeFilter.FILTER_REJECT;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
546
587
|
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
547
588
|
const tagName = node.tagName;
|
|
548
589
|
if (tagName === 'X-TEXT'
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* Events:
|
|
11
11
|
* - `bindload`: Fired when the page loads. Detail: `{ url }`.
|
|
12
12
|
* - `binderror`: Fired when an error occurs. Detail: `{ errorMsg }`.
|
|
13
|
+
* - `message`: Fired when the page posts a message to its parent. Detail:
|
|
14
|
+
* `{ msg, data }`.
|
|
13
15
|
* - `bindmessage`: Fired when a message is received from the page. Detail: `{ msg }`.
|
|
14
16
|
*
|
|
15
17
|
* Methods:
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* Events:
|
|
14
14
|
* - `bindload`: Fired when the page loads. Detail: `{ url }`.
|
|
15
15
|
* - `binderror`: Fired when an error occurs. Detail: `{ errorMsg }`.
|
|
16
|
+
* - `message`: Fired when the page posts a message to its parent. Detail:
|
|
17
|
+
* `{ msg, data }`.
|
|
16
18
|
* - `bindmessage`: Fired when a message is received from the page. Detail: `{ msg }`.
|
|
17
19
|
*
|
|
18
20
|
* Methods:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-elements",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -134,15 +134,16 @@
|
|
|
134
134
|
"**/*.css"
|
|
135
135
|
],
|
|
136
136
|
"dependencies": {
|
|
137
|
-
"dompurify": "^3.
|
|
138
|
-
"markdown-it": "^14.
|
|
137
|
+
"dompurify": "^3.4.12",
|
|
138
|
+
"markdown-it": "^14.3.0"
|
|
139
139
|
},
|
|
140
140
|
"devDependencies": {
|
|
141
141
|
"@playwright/test": "^1.61.1",
|
|
142
|
-
"@rsbuild/core": "2.
|
|
143
|
-
"@rsbuild/plugin-source-build": "1.0.
|
|
144
|
-
"@types/markdown-it": "^14.1.
|
|
145
|
-
"
|
|
142
|
+
"@rsbuild/core": "2.1.7",
|
|
143
|
+
"@rsbuild/plugin-source-build": "1.0.6",
|
|
144
|
+
"@types/markdown-it": "^14.1.2",
|
|
145
|
+
"@types/node": "^24.13.3",
|
|
146
|
+
"nyc": "^18.0.0",
|
|
146
147
|
"tslib": "^2.8.1",
|
|
147
148
|
"@lynx-js/playwright-fixtures": "0.0.0"
|
|
148
149
|
},
|