@aseity/igrid-react 0.4.1 → 0.5.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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @aseity/igrid-react
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Improve CJK wrapping across rich-text runs, preserve explicit paragraph
8
+ indentation, and use actual font bounds to prevent overly tight multiline spacing.
9
+ - Update the exact engine dependency to `@aseity/igrid-engine@0.5.0`, adding
10
+ named-constant calculation and correcting merged borders and hidden dimensions.
11
+
3
12
  ## 0.4.1
4
13
 
5
14
  ### Patch Changes
package/dist/text.js CHANGED
@@ -16,9 +16,6 @@ export function drawText(context, list, index) {
16
16
  ];
17
17
  }
18
18
  const lines = wrap ? wrapLines(context, segments, available) : [segments];
19
- const lineHeight = ((Math.max(base.size, ...segments.map((segment) => segment.size)) * 96) /
20
- 72) *
21
- 1.25;
22
19
  context.textBaseline = "alphabetic";
23
20
  const metrics = lines
24
21
  .flat()
@@ -29,6 +26,9 @@ export function drawText(context, list, index) {
29
26
  });
30
27
  const ascent = Math.max(0, ...metrics.map((metric) => metric.fontBoundingBoxAscent));
31
28
  const descent = Math.max(0, ...metrics.map((metric) => metric.fontBoundingBoxDescent));
29
+ const lineHeight = Math.max(((Math.max(base.size, ...segments.map((segment) => segment.size)) * 96) /
30
+ 72) *
31
+ 1.25, ascent + descent);
32
32
  const blockHeight = (lines.length - 1) * lineHeight + ascent + descent;
33
33
  const top = vertical === 0
34
34
  ? y + 2
@@ -164,24 +164,27 @@ function glyphs(data, index) {
164
164
  function wrapLines(context, segments, available) {
165
165
  const lines = [[]];
166
166
  let width = 0;
167
- const newline = () => {
167
+ let paragraphStart = true;
168
+ const newline = (explicit = false) => {
168
169
  lines.push([]);
169
170
  width = 0;
171
+ paragraphStart = explicit;
170
172
  };
171
173
  for (const segment of segments) {
172
174
  context.font = segment.font;
173
- for (const token of segment.text.split(/(\n|[^\S\n]+)/)) {
175
+ for (const token of segment.text.split(/(\r\n|[\r\n]|[^\S\r\n]+|[(「『【《〈“‘]*[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Bopomofo}][,。、;:!?)』」】》〉”’]*)/u)) {
174
176
  if (!token)
175
177
  continue;
176
- if (token === "\n") {
177
- newline();
178
+ if (/^[\r\n]+$/.test(token)) {
179
+ newline(true);
178
180
  continue;
179
181
  }
180
182
  let tokenWidth = context.measureText(token).width;
181
- if (width && width + tokenWidth > available)
183
+ if (width && width + tokenWidth > available && tokenWidth <= available)
182
184
  newline();
183
- if (!width && /^\s+$/.test(token))
185
+ if (!width && !paragraphStart && /^\s+$/.test(token))
184
186
  continue;
187
+ paragraphStart = false;
185
188
  if (tokenWidth <= available) {
186
189
  lines[lines.length - 1].push({
187
190
  ...segment,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aseity/igrid-react",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -11,7 +11,7 @@
11
11
  "./styles.css": "./dist/style.css"
12
12
  },
13
13
  "dependencies": {
14
- "@aseity/igrid-engine": "0.4.1",
14
+ "@aseity/igrid-engine": "0.5.0",
15
15
  "echarts": "6.1.0"
16
16
  },
17
17
  "peerDependencies": {