openfig-cli 0.3.28 → 0.3.29
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/lib/rasterizer/svg-builder.mjs +21 -1
- package/manifest.json +1 -1
- package/package.json +1 -1
|
@@ -271,6 +271,8 @@ function esc(s) {
|
|
|
271
271
|
*/
|
|
272
272
|
function isStaleLayout(chars, baselines, glyphs) {
|
|
273
273
|
if (!chars) return false;
|
|
274
|
+
// No derivedTextData at all (e.g. programmatically created text)
|
|
275
|
+
if (!baselines?.length && !glyphs?.length) return true;
|
|
274
276
|
const len = chars.length;
|
|
275
277
|
|
|
276
278
|
if (baselines?.length) {
|
|
@@ -356,9 +358,27 @@ function fallbackTextTspans(dispChars, fontSize, node) {
|
|
|
356
358
|
: adjLineAscent;
|
|
357
359
|
}
|
|
358
360
|
|
|
361
|
+
// List marker support: read lineType from textData.lines
|
|
362
|
+
const linesMeta = node.textData?.lines ?? [];
|
|
363
|
+
let orderedCounter = 0;
|
|
364
|
+
|
|
359
365
|
const tspans = lines.map((line, i) => {
|
|
360
366
|
const y = startY + i * adjLineHeight;
|
|
361
|
-
|
|
367
|
+
const meta = linesMeta[i];
|
|
368
|
+
const lineType = meta?.lineType;
|
|
369
|
+
const indent = (meta?.indentationLevel ?? 0) * adjFontSize * 0.8;
|
|
370
|
+
let prefix = '';
|
|
371
|
+
if (lineType === 'UNORDERED_LIST') {
|
|
372
|
+
prefix = '\u2022 '; // bullet •
|
|
373
|
+
orderedCounter = 0;
|
|
374
|
+
} else if (lineType === 'ORDERED_LIST') {
|
|
375
|
+
orderedCounter++;
|
|
376
|
+
prefix = `${orderedCounter}. `;
|
|
377
|
+
} else {
|
|
378
|
+
orderedCounter = 0;
|
|
379
|
+
}
|
|
380
|
+
const x = startX + indent;
|
|
381
|
+
return `<tspan x="${x.toFixed(2)}" y="${y.toFixed(2)}" text-anchor="${anchor}">${esc(prefix + line) || ' '}</tspan>`;
|
|
362
382
|
}).join('');
|
|
363
383
|
|
|
364
384
|
return { tspans, fontSize: adjFontSize };
|
package/manifest.json
CHANGED