@openpresentation/opf-render 0.1.0 → 0.1.1
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/svg.js +9 -1
- package/package.json +2 -2
package/dist/svg.js
CHANGED
|
@@ -1182,7 +1182,15 @@ function renderRichLines(value,fit,box,bound,config) {
|
|
|
1182
1182
|
if(run.link&&/^(https?:|mailto:)/i.test(run.link))return tag('a',{href:run.link,target:'_blank',rel:'noopener noreferrer'},rendered);
|
|
1183
1183
|
return rendered;
|
|
1184
1184
|
}));
|
|
1185
|
-
|
|
1185
|
+
let cursor=0;
|
|
1186
|
+
const whole=value.map(run=>typeof run==='string'?run:run.text).join('');
|
|
1187
|
+
const lineTrace=config.options.trace?fit.richLines.map((line,index)=>{
|
|
1188
|
+
if(index){const newline=/^(\r\n|\r|\n)/.exec(whole.slice(cursor));if(newline)cursor+=newline[0].length;}
|
|
1189
|
+
const start=cursor;cursor+=(fit.lines[index]??'').length;
|
|
1190
|
+
const offset=alignment==='right'?box.width-line.width:alignment==='center'?(box.width-line.width)/2:0;
|
|
1191
|
+
return {start,end:cursor,x:box.x+offset,y:box.y+line.y,height:line.height};
|
|
1192
|
+
}):undefined;
|
|
1193
|
+
return tag('g',{...traceAttrs(config.options,config.path),...(config.options.trace?{'data-opf-box-width':box.width,'data-opf-rich-text':config.rich===false?undefined:'true','data-opf-rich-lines':JSON.stringify(lineTrace)}:{}),...(fit.overflow?{'data-opf-overflow':'true'}:{})},content.join('\n'));
|
|
1186
1194
|
}
|
|
1187
1195
|
|
|
1188
1196
|
function renderTextBox(text, box, bound, config) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpresentation/opf-render",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Deterministic local OPF renderer for SVG, PNG, and PDF output.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"build": "node scripts/build.mjs",
|
|
58
58
|
"typecheck": "node --check src/index.js && node --check scripts/build.mjs && node --check scripts/validate-package.mjs && node --check test/smoke.mjs && node --check test/golden.mjs && node --check src/fonts.js && node --check src/fonts-node.js && node --check src/font-compatibility.js && node --check test/office-fonts.mjs && node --check src/fonts-browser.js && node --check test/fonts-browser.mjs && node --check src/svg.js && node --check src/raster.js",
|
|
59
59
|
"validate": "node scripts/validate-package.mjs",
|
|
60
|
-
"test": "npm run build && node test/smoke.mjs && node test/fonts.mjs && node test/office-fonts.mjs && node test/timeline.mjs && node test/golden-gate.mjs && node test/golden.mjs && node test/fonts-browser.mjs && node test/design-preview.mjs",
|
|
60
|
+
"test": "npm run build && node test/smoke.mjs && node test/fonts.mjs && node test/office-fonts.mjs && node test/timeline.mjs && node test/rich-trace.mjs && node test/golden-gate.mjs && node test/golden.mjs && node test/fonts-browser.mjs && node test/design-preview.mjs",
|
|
61
61
|
"test:golden": "npm run build && node test/golden.mjs",
|
|
62
62
|
"golden:update": "npm run build && node test/golden.mjs --update",
|
|
63
63
|
"prepack": "npm run build"
|