@hirokisakabe/pom 9.1.2 → 10.0.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/buildContext.js +2 -2
- package/dist/buildContext.js.map +1 -1
- package/dist/buildPptx.d.ts +2 -1
- package/dist/buildPptx.d.ts.map +1 -1
- package/dist/buildPptx.js +4 -3
- package/dist/buildPptx.js.map +1 -1
- package/dist/calcYogaLayout/calcYogaLayout.js +1 -1
- package/dist/calcYogaLayout/calcYogaLayout.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/registry/definitions/icon.js +1 -1
- package/dist/registry/definitions/list.js.map +1 -1
- package/dist/renderPptx/nodes/chart.js +172 -47
- package/dist/renderPptx/nodes/chart.js.map +1 -1
- package/dist/renderPptx/nodes/flow.js +4 -1
- package/dist/renderPptx/nodes/flow.js.map +1 -1
- package/dist/renderPptx/nodes/icon.js +5 -2
- package/dist/renderPptx/nodes/icon.js.map +1 -1
- package/dist/renderPptx/nodes/list.js +7 -9
- package/dist/renderPptx/nodes/list.js.map +1 -1
- package/dist/renderPptx/nodes/matrix.js +4 -1
- package/dist/renderPptx/nodes/matrix.js.map +1 -1
- package/dist/renderPptx/nodes/processArrow.js +8 -2
- package/dist/renderPptx/nodes/processArrow.js.map +1 -1
- package/dist/renderPptx/nodes/pyramid.js +4 -1
- package/dist/renderPptx/nodes/pyramid.js.map +1 -1
- package/dist/renderPptx/nodes/shape.js +5 -2
- package/dist/renderPptx/nodes/shape.js.map +1 -1
- package/dist/renderPptx/nodes/table.js +89 -59
- package/dist/renderPptx/nodes/table.js.map +1 -1
- package/dist/renderPptx/nodes/text.js +1 -18
- package/dist/renderPptx/nodes/text.js.map +1 -1
- package/dist/renderPptx/nodes/timeline.js +9 -3
- package/dist/renderPptx/nodes/timeline.js.map +1 -1
- package/dist/renderPptx/nodes/tree.js +4 -1
- package/dist/renderPptx/nodes/tree.js.map +1 -1
- package/dist/renderPptx/pptxAuthoring.js +381 -0
- package/dist/renderPptx/pptxAuthoring.js.map +1 -0
- package/dist/renderPptx/renderPptx.js +157 -126
- package/dist/renderPptx/renderPptx.js.map +1 -1
- package/dist/renderPptx/textOptions.js +7 -8
- package/dist/renderPptx/textOptions.js.map +1 -1
- package/dist/renderPptx/units.js +3 -3
- package/dist/renderPptx/units.js.map +1 -1
- package/dist/renderPptx/utils/backgroundBorder.js +30 -44
- package/dist/renderPptx/utils/backgroundBorder.js.map +1 -1
- package/dist/renderPptx/utils/contentArea.js +1 -1
- package/dist/renderPptx/utils/contentArea.js.map +1 -1
- package/dist/renderPptx/utils/glimpsePicture.js +3 -22
- package/dist/renderPptx/utils/glimpsePicture.js.map +1 -1
- package/dist/renderPptx/utils/glimpseShape.js +6 -25
- package/dist/renderPptx/utils/glimpseShape.js.map +1 -1
- package/dist/renderPptx/utils/glimpseTextBox.js +41 -60
- package/dist/renderPptx/utils/glimpseTextBox.js.map +1 -1
- package/dist/renderPptx/utils/straightLine.js +5 -2
- package/dist/renderPptx/utils/straightLine.js.map +1 -1
- package/dist/renderPptx/utils/visualStyle.js +3 -33
- package/dist/renderPptx/utils/visualStyle.js.map +1 -1
- package/dist/renderPptx/writablePptx.d.ts +23 -0
- package/dist/renderPptx/writablePptx.d.ts.map +1 -0
- package/dist/renderPptx/writablePptx.js +74 -0
- package/dist/renderPptx/writablePptx.js.map +1 -0
- package/dist/shared/measureImage.js.map +1 -1
- package/package.json +4 -5
- package/dist/renderPptx/glimpseTextBoxes.js +0 -646
- package/dist/renderPptx/glimpseTextBoxes.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon.js","names":[],"sources":["../../../src/renderPptx/nodes/icon.ts"],"sourcesContent":["import { asEmu } from \"@pptx-glimpse/document\";\nimport type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { toColorInput } from \"../
|
|
1
|
+
{"version":3,"file":"icon.js","names":[],"sources":["../../../src/renderPptx/nodes/icon.ts"],"sourcesContent":["import { asEmu } from \"@pptx-glimpse/document\";\nimport type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { toColorInput } from \"../pptxAuthoring.ts\";\nimport { pxToEmu } from \"../units.ts\";\nimport {\n addGlimpsePicture,\n imageBytesFromSource,\n} from \"../utils/glimpsePicture.ts\";\nimport {\n addGlimpseShape,\n createShapeBoundsInput,\n createShapeRotationInput,\n noShapeOutline,\n noneShapeFill,\n shapeOutline,\n solidShapeFill,\n} from \"../utils/glimpseShape.ts\";\n\ntype IconPositionedNode = Extract<PositionedNode, { type: \"icon\" }>;\n\nexport function renderIconNode(\n node: IconPositionedNode,\n ctx: RenderContext,\n): void {\n // variant 指定時は背景図形を描画\n if (node.variant) {\n const isCircle = node.variant.startsWith(\"circle\");\n const isFilled = node.variant.endsWith(\"-filled\");\n const bgColor = node.bgColor ?? \"#E0E0E0\";\n const colorValue = bgColor.replace(/^#/, \"\");\n\n // 背景図形の line のデフォルト: outlined variant は colorValue / 1.5pt 相当 (2px)、\n // filled variant は undefined (枠線なし)。\n const variantDefaultLine = isFilled\n ? undefined\n : { color: colorValue, width: 2 };\n // outline 指定時は variant のデフォルト line とフィールド単位でマージする。\n // outline 側で省略された属性は variant default の値を引き継ぐので、例えば\n // outlined variant に `outline.color` だけ指定すると、太さは 1.5pt のまま\n // 色だけ outline で上書きされる。\n const outlineLine = node.outline\n ? {\n color: node.outline.color ?? variantDefaultLine?.color ?? \"FFFFFF\",\n width:\n node.outline.size !== undefined\n ? node.outline.size\n : (variantDefaultLine?.width ?? 1),\n }\n : variantDefaultLine;\n\n const bounds = {\n x: node.bgX ?? node.x,\n y: node.bgY ?? node.y,\n w: node.bgW ?? node.w,\n h: node.bgH ?? node.h,\n };\n const shapeType = isCircle ? \"ellipse\" : \"roundRect\";\n\n addGlimpseShape(\n ctx,\n {\n geometry: { kind: \"preset\", preset: shapeType },\n ...createShapeBoundsInput(bounds),\n rotation: createShapeRotationInput(node.rotate),\n fill: isFilled ? solidShapeFill(colorValue) : noneShapeFill(),\n outline: outlineLine ? shapeOutline(outlineLine) : noShapeOutline(),\n effects: node.glow\n ? {\n glow: {\n radius: asEmu(Math.round(pxToEmu(node.glow.size ?? 8))),\n color: toColorInput(node.glow.color ?? \"FFFFFF\")!,\n },\n }\n : undefined,\n },\n bounds,\n {\n fillColor: isFilled ? colorValue : undefined,\n glow: node.glow,\n rectRadius: isCircle ? undefined : 0.1,\n },\n );\n }\n\n addGlimpsePicture(\n ctx,\n {\n x: node.iconX ?? node.x,\n y: node.iconY ?? node.y,\n w: node.iconW ?? node.w,\n h: node.iconH ?? node.h,\n },\n imageBytesFromSource(\"\", node.iconImageData),\n { rotate: node.rotate },\n );\n}\n"],"mappings":";;;;;;AAqBA,SAAgB,eACd,MACA,KACM;CAEN,IAAI,KAAK,SAAS;EAChB,MAAM,WAAW,KAAK,QAAQ,WAAW,QAAQ;EACjD,MAAM,WAAW,KAAK,QAAQ,SAAS,SAAS;EAEhD,MAAM,cADU,KAAK,WAAW,UAAA,CACL,QAAQ,MAAM,EAAE;EAI3C,MAAM,qBAAqB,WACvB,KAAA,IACA;GAAE,OAAO;GAAY,OAAO;EAAE;EAKlC,MAAM,cAAc,KAAK,UACrB;GACE,OAAO,KAAK,QAAQ,SAAS,oBAAoB,SAAS;GAC1D,OACE,KAAK,QAAQ,SAAS,KAAA,IAClB,KAAK,QAAQ,OACZ,oBAAoB,SAAS;EACtC,IACA;EAEJ,MAAM,SAAS;GACb,GAAG,KAAK,OAAO,KAAK;GACpB,GAAG,KAAK,OAAO,KAAK;GACpB,GAAG,KAAK,OAAO,KAAK;GACpB,GAAG,KAAK,OAAO,KAAK;EACtB;EAGA,gBACE,KACA;GACE,UAAU;IAAE,MAAM;IAAU,QALd,WAAW,YAAY;GAKS;GAC9C,GAAG,uBAAuB,MAAM;GAChC,UAAU,yBAAyB,KAAK,MAAM;GAC9C,MAAM,WAAW,eAAe,UAAU,IAAI,cAAc;GAC5D,SAAS,cAAc,aAAa,WAAW,IAAI,eAAe;GAClE,SAAS,KAAK,OACV,EACE,MAAM;IACJ,QAAQ,MAAM,KAAK,MAAM,QAAQ,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC;IACtD,OAAO,aAAa,KAAK,KAAK,SAAS,QAAQ;GACjD,EACF,IACA,KAAA;EACN,GACA,QACA;GACE,WAAW,WAAW,aAAa,KAAA;GACnC,MAAM,KAAK;GACX,YAAY,WAAW,KAAA,IAAY;EACrC,CACF;CACF;CAEA,kBACE,KACA;EACE,GAAG,KAAK,SAAS,KAAK;EACtB,GAAG,KAAK,SAAS,KAAK;EACtB,GAAG,KAAK,SAAS,KAAK;EACtB,GAAG,KAAK,SAAS,KAAK;CACxB,GACA,qBAAqB,IAAI,KAAK,aAAa,GAC3C,EAAE,QAAQ,KAAK,OAAO,CACxB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getContentArea } from "../utils/contentArea.js";
|
|
2
2
|
import { resolveSubSup } from "../textOptions.js";
|
|
3
|
-
import { addGlimpseTextBox, createGlimpseRunProperties
|
|
3
|
+
import { addGlimpseTextBox, createGlimpseRunProperties } from "../utils/glimpseTextBox.js";
|
|
4
4
|
//#region src/renderPptx/nodes/list.ts
|
|
5
5
|
function resolveStyle(li, parent) {
|
|
6
6
|
const subSup = resolveSubSup(li, parent);
|
|
@@ -98,10 +98,8 @@ function renderUlNode(node, ctx) {
|
|
|
98
98
|
highlight: node.highlight,
|
|
99
99
|
paragraphs,
|
|
100
100
|
hyperlinks,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
lineHeight: node.lineHeight
|
|
104
|
-
})
|
|
101
|
+
lineHeight: node.lineHeight,
|
|
102
|
+
bullet: { kind: "bullet" }
|
|
105
103
|
});
|
|
106
104
|
}
|
|
107
105
|
function renderOlNode(node, ctx) {
|
|
@@ -125,12 +123,12 @@ function renderOlNode(node, ctx) {
|
|
|
125
123
|
highlight: node.highlight,
|
|
126
124
|
paragraphs,
|
|
127
125
|
hyperlinks,
|
|
128
|
-
|
|
126
|
+
lineHeight: node.lineHeight,
|
|
127
|
+
bullet: {
|
|
129
128
|
kind: "number",
|
|
130
129
|
scheme: node.numberType,
|
|
131
|
-
startAt: node.numberStartAt
|
|
132
|
-
|
|
133
|
-
})
|
|
130
|
+
startAt: node.numberStartAt
|
|
131
|
+
}
|
|
134
132
|
});
|
|
135
133
|
}
|
|
136
134
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","names":[],"sources":["../../../src/renderPptx/nodes/list.ts"],"sourcesContent":["import type { PositionedNode, LiNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { resolveSubSup } from \"../textOptions.ts\";\nimport { getContentArea } from \"../utils/contentArea.ts\";\nimport {\n addGlimpseTextBox,\n createGlimpseRunProperties,\n
|
|
1
|
+
{"version":3,"file":"list.js","names":[],"sources":["../../../src/renderPptx/nodes/list.ts"],"sourcesContent":["import type { PositionedNode, LiNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { resolveSubSup } from \"../textOptions.ts\";\nimport { getContentArea } from \"../utils/contentArea.ts\";\nimport {\n addGlimpseTextBox,\n createGlimpseRunProperties,\n type GlimpseTextRunStyle,\n} from \"../utils/glimpseTextBox.ts\";\nimport {\n type AddTextBoxParagraphInput,\n type AddTextBoxRunInput,\n} from \"@pptx-glimpse/document\";\n\ntype UlPositionedNode = Extract<PositionedNode, { type: \"ul\" }>;\ntype OlPositionedNode = Extract<PositionedNode, { type: \"ol\" }>;\n\nfunction resolveStyle(li: LiNode, parent: UlPositionedNode | OlPositionedNode) {\n const subSup = resolveSubSup(li, parent);\n return {\n fontSize: li.fontSize ?? parent.fontSize ?? 24,\n color: li.color ?? parent.color,\n bold: li.bold ?? parent.bold,\n italic: li.italic ?? parent.italic,\n underline: li.underline ?? parent.underline,\n strike: li.strike ?? parent.strike,\n subscript: subSup.subscript,\n superscript: subSup.superscript,\n highlight: li.highlight ?? parent.highlight,\n fontFamily: li.fontFamily ?? parent.fontFamily ?? \"Noto Sans JP\",\n };\n}\n\nfunction paragraphProperties(parent: UlPositionedNode | OlPositionedNode) {\n return {\n align: parent.textAlign ?? \"left\",\n };\n}\n\nfunction toRunStyle(\n style: ReturnType<typeof resolveStyle>,\n): GlimpseTextRunStyle {\n return {\n fontSize: style.fontSize,\n fontFace: style.fontFamily,\n color: style.color,\n bold: style.bold,\n italic: style.italic,\n underline: style.underline,\n strike: style.strike,\n subscript: style.subscript,\n superscript: style.superscript,\n highlight: style.highlight,\n };\n}\n\nfunction buildListParagraphs(\n items: LiNode[],\n parent: UlPositionedNode | OlPositionedNode,\n): {\n paragraphs: AddTextBoxParagraphInput[];\n hyperlinks: (string | undefined)[];\n} {\n const paragraphs: AddTextBoxParagraphInput[] = [];\n const hyperlinks: (string | undefined)[] = [];\n for (let i = 0; i < items.length; i++) {\n const li = items[i];\n const style = resolveStyle(li, parent);\n const runs: AddTextBoxRunInput[] = [];\n if (li.runs && li.runs.length > 0) {\n for (const run of li.runs) {\n const runSubSup = resolveSubSup(run, style);\n runs.push({\n text: run.text,\n properties: createGlimpseRunProperties({\n fontSize: run.fontSize ?? style.fontSize,\n fontFace: run.fontFamily ?? style.fontFamily,\n color: run.color ?? style.color,\n bold: run.bold ?? style.bold,\n italic: run.italic ?? style.italic,\n underline: run.underline ?? style.underline,\n strike: run.strike ?? style.strike,\n subscript: runSubSup.subscript,\n superscript: runSubSup.superscript,\n highlight: run.highlight ?? style.highlight,\n }),\n });\n hyperlinks.push(run.text ? run.href : undefined);\n }\n } else {\n runs.push({\n text: li.text,\n properties: createGlimpseRunProperties(toRunStyle(style)),\n });\n hyperlinks.push(undefined);\n }\n paragraphs.push({\n properties: paragraphProperties(parent),\n runs,\n });\n }\n return { paragraphs, hyperlinks };\n}\n\nexport function renderUlNode(node: UlPositionedNode, ctx: RenderContext): void {\n const fontSizePx = node.fontSize ?? 24;\n const fontFamily = node.fontFamily ?? \"Noto Sans JP\";\n const content = getContentArea(node);\n\n const { paragraphs, hyperlinks } = buildListParagraphs(node.items, node);\n addGlimpseTextBox(ctx, content, {\n fontSize: fontSizePx,\n fontFace: fontFamily,\n align: node.textAlign ?? \"left\",\n valign: \"top\",\n margin: 0,\n color: node.color,\n bold: node.bold,\n italic: node.italic,\n underline: node.underline,\n strike: node.strike,\n subscript: node.subscript,\n superscript: node.superscript,\n highlight: node.highlight,\n paragraphs,\n hyperlinks,\n lineHeight: node.lineHeight,\n bullet: {\n kind: \"bullet\",\n },\n });\n}\n\nexport function renderOlNode(node: OlPositionedNode, ctx: RenderContext): void {\n const fontSizePx = node.fontSize ?? 24;\n const fontFamily = node.fontFamily ?? \"Noto Sans JP\";\n const content = getContentArea(node);\n\n const { paragraphs, hyperlinks } = buildListParagraphs(node.items, node);\n addGlimpseTextBox(ctx, content, {\n fontSize: fontSizePx,\n fontFace: fontFamily,\n align: node.textAlign ?? \"left\",\n valign: \"top\",\n margin: 0,\n color: node.color,\n bold: node.bold,\n italic: node.italic,\n underline: node.underline,\n strike: node.strike,\n subscript: node.subscript,\n superscript: node.superscript,\n highlight: node.highlight,\n paragraphs,\n hyperlinks,\n lineHeight: node.lineHeight,\n bullet: {\n kind: \"number\",\n scheme: node.numberType,\n startAt: node.numberStartAt,\n },\n });\n}\n"],"mappings":";;;;AAiBA,SAAS,aAAa,IAAY,QAA6C;CAC7E,MAAM,SAAS,cAAc,IAAI,MAAM;CACvC,OAAO;EACL,UAAU,GAAG,YAAY,OAAO,YAAY;EAC5C,OAAO,GAAG,SAAS,OAAO;EAC1B,MAAM,GAAG,QAAQ,OAAO;EACxB,QAAQ,GAAG,UAAU,OAAO;EAC5B,WAAW,GAAG,aAAa,OAAO;EAClC,QAAQ,GAAG,UAAU,OAAO;EAC5B,WAAW,OAAO;EAClB,aAAa,OAAO;EACpB,WAAW,GAAG,aAAa,OAAO;EAClC,YAAY,GAAG,cAAc,OAAO,cAAc;CACpD;AACF;AAEA,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AC;CACH;CACA,OAAO;EAAE;EAAY;CAAW;AAClC;AAEA,SAAgB,aAAa,MAAwB,KAA0B;CAC7E,MAAM,aAAa,KAAK,YAAY;CACpC,MAAM,aAAa,KAAK,cAAc;CACtC,MAAM,UAAU,eAAe,IAAI;CAEnC,MAAM,EAAE,YAAY,eAAe,oBAAoB,KAAK,OAAO,IAAI;CACvE,kBAAkB,KAAK,SAAS;EAC9B,UAAU;EACV,UAAU;EACV,OAAO,KAAK,aAAa;EACzB,QAAQ;EACR,QAAQ;EACR,OAAO,KAAK;EACZ,MAAM,KAAK;EACX,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,aAAa,KAAK;EAClB,WAAW,KAAK;EAChB;EACA;EACA,YAAY,KAAK;EACjB,QAAQ,EACN,MAAM,SACR;CACF,CAAC;AACH;AAEA,SAAgB,aAAa,MAAwB,KAA0B;CAC7E,MAAM,aAAa,KAAK,YAAY;CACpC,MAAM,aAAa,KAAK,cAAc;CACtC,MAAM,UAAU,eAAe,IAAI;CAEnC,MAAM,EAAE,YAAY,eAAe,oBAAoB,KAAK,OAAO,IAAI;CACvE,kBAAkB,KAAK,SAAS;EAC9B,UAAU;EACV,UAAU;EACV,OAAO,KAAK,aAAa;EACzB,QAAQ;EACR,QAAQ;EACR,OAAO,KAAK;EACZ,MAAM,KAAK;EACX,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,aAAa,KAAK;EAClB,WAAW,KAAK;EAChB;EACA;EACA,YAAY,KAAK;EACjB,QAAQ;GACN,MAAM;GACN,QAAQ,KAAK;GACb,SAAS,KAAK;EAChB;CACF,CAAC;AACH"}
|
|
@@ -82,7 +82,10 @@ function renderMatrixNode(node, ctx) {
|
|
|
82
82
|
const itemY = areaY + (1 - item.y) * areaH;
|
|
83
83
|
const itemColor = item.color ?? defaultItemColor;
|
|
84
84
|
addGlimpseShape(ctx, {
|
|
85
|
-
|
|
85
|
+
geometry: {
|
|
86
|
+
kind: "preset",
|
|
87
|
+
preset: "ellipse"
|
|
88
|
+
},
|
|
86
89
|
...createShapeBoundsInput({
|
|
87
90
|
x: itemX - itemSize / 2,
|
|
88
91
|
y: itemY - itemSize / 2,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix.js","names":[],"sources":["../../../src/renderPptx/nodes/matrix.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { stripHash } from \"../utils/visualStyle.ts\";\nimport { measureMatrix } from \"../../calcYogaLayout/measureCompositeNodes.ts\";\nimport { resolveScaledContentArea } from \"../utils/scaleToFit.ts\";\nimport { addStraightLine } from \"../utils/straightLine.ts\";\nimport {\n addGlimpseShape,\n createShapeBoundsInput,\n noShapeOutline,\n solidShapeFill,\n} from \"../utils/glimpseShape.ts\";\nimport { addGlimpseTextBox } from \"../utils/glimpseTextBox.ts\";\n\ntype MatrixPositionedNode = Extract<PositionedNode, { type: \"matrix\" }>;\n\nexport function renderMatrixNode(\n node: MatrixPositionedNode,\n ctx: RenderContext,\n): void {\n const items = node.items;\n const axes = node.axes;\n const quadrants = node.quadrants;\n\n const defaultItemColor = \"1D4ED8\"; // blue\n const baseItemSize = 24; // px\n const baseLineWidth = 2; // px\n const axisColor = \"E2E8F0\";\n const axisLabelColor = stripHash(node.axisLabelColor) ?? \"64748B\";\n const itemLabelColor = stripHash(node.itemLabelColor) ?? \"1E293B\";\n\n // スケール係数を計算(コンテンツ領域基準)\n const { content, scaleFactor } = resolveScaledContentArea(\n node,\n measureMatrix(node),\n ctx,\n );\n\n const itemSize = baseItemSize * scaleFactor;\n const lineWidth = baseLineWidth * scaleFactor;\n\n // マトリクスの描画領域(軸ラベル用の余白を考慮)\n const axisMargin = 60 * scaleFactor; // 軸ラベル用の余白\n const areaX = content.x + axisMargin;\n const areaY = content.y + axisMargin;\n const areaW = content.w - axisMargin * 2;\n const areaH = content.h - axisMargin * 2;\n\n // 中心座標\n const centerX = areaX + areaW / 2;\n const centerY = areaY + areaH / 2;\n\n // === 1. 十字線(軸線)を描画 ===\n // 横線(X軸)\n addStraightLine(\n ctx,\n { x1: areaX, y1: centerY, x2: areaX + areaW, y2: centerY },\n { color: axisColor, lineWidth },\n );\n\n // 縦線(Y軸)\n addStraightLine(\n ctx,\n { x1: centerX, y1: areaY, x2: centerX, y2: areaY + areaH },\n { color: axisColor, lineWidth },\n );\n\n // === 2. 軸ラベルを描画 ===\n const axisLabelW = 120 * scaleFactor;\n const axisLabelH = 24 * scaleFactor;\n\n // X軸ラベル(下部中央)\n addGlimpseTextBox(\n ctx,\n {\n x: centerX - axisLabelW / 2,\n y: areaY + areaH + 8 * scaleFactor,\n w: axisLabelW,\n h: axisLabelH,\n },\n {\n text: axes.x,\n fontSize: 12 * scaleFactor,\n fontFace: \"Noto Sans JP\",\n color: axisLabelColor,\n align: \"center\",\n valign: \"top\",\n },\n );\n\n // Y軸ラベル(左部中央)270° 回転で下から上読み。w が視覚的な高さになるため CJK 5 文字以上も収まる幅を確保\n const yLabelW = 100 * scaleFactor;\n const yLabelH = 20 * scaleFactor;\n addGlimpseTextBox(\n ctx,\n {\n x: content.x + axisMargin / 2 - yLabelW / 2,\n y: centerY - yLabelH / 2,\n w: yLabelW,\n h: yLabelH,\n },\n {\n text: axes.y,\n fontSize: 12 * scaleFactor,\n fontFace: \"Noto Sans JP\",\n color: axisLabelColor,\n align: \"center\",\n valign: \"middle\",\n rotate: 270,\n },\n );\n\n // === 3. 象限ラベルを描画 ===\n if (quadrants) {\n renderQuadrantLabels(\n ctx,\n quadrants,\n areaX,\n areaY,\n areaW,\n areaH,\n centerX,\n centerY,\n scaleFactor,\n stripHash(node.quadrantLabelColor) ?? \"94A3B8\",\n );\n }\n\n // === 4. アイテムをプロット ===\n const itemLabelW = 100 * scaleFactor;\n const itemLabelH = 18 * scaleFactor;\n\n for (const item of items) {\n // 座標変換: (0,0)=左下, (1,1)=右上\n // x: 0 -> areaX, 1 -> areaX + areaW\n // y: 0 -> areaY + areaH, 1 -> areaY (反転)\n const itemX = areaX + item.x * areaW;\n const itemY = areaY + (1 - item.y) * areaH; // Y軸反転\n const itemColor = item.color ?? defaultItemColor;\n\n // 円を描画\n addGlimpseShape(\n ctx,\n {\n preset: \"ellipse\",\n ...createShapeBoundsInput({\n x: itemX - itemSize / 2,\n y: itemY - itemSize / 2,\n w: itemSize,\n h: itemSize,\n }),\n fill: solidShapeFill(itemColor),\n outline: noShapeOutline(),\n },\n {\n x: itemX - itemSize / 2,\n y: itemY - itemSize / 2,\n w: itemSize,\n h: itemSize,\n },\n { fillColor: itemColor },\n );\n\n // ラベルを描画(円の上)\n addGlimpseTextBox(\n ctx,\n {\n x: itemX - itemLabelW / 2,\n y: itemY - itemSize / 2 - 20 * scaleFactor,\n w: itemLabelW,\n h: itemLabelH,\n },\n {\n text: item.label,\n fontSize: 11 * scaleFactor,\n fontFace: \"Noto Sans JP\",\n color: stripHash(item.textColor) ?? itemLabelColor,\n bold: true,\n align: \"center\",\n valign: \"bottom\",\n },\n );\n }\n}\n\nfunction renderQuadrantLabels(\n ctx: RenderContext,\n quadrants: NonNullable<MatrixPositionedNode[\"quadrants\"]>,\n areaX: number,\n areaY: number,\n areaW: number,\n areaH: number,\n centerX: number,\n centerY: number,\n scaleFactor: number,\n quadrantColor: string,\n): void {\n const quadrantFontSize = 11 * scaleFactor;\n const quadrantInset = 10 * scaleFactor;\n const quadrantW = areaW / 2 - 20 * scaleFactor;\n const quadrantH = 48 * scaleFactor;\n\n // 左上\n addGlimpseTextBox(\n ctx,\n {\n x: areaX + quadrantInset,\n y: areaY + quadrantInset,\n w: quadrantW,\n h: quadrantH,\n },\n {\n text: quadrants.topLeft,\n fontSize: quadrantFontSize,\n fontFace: \"Noto Sans JP\",\n color: quadrantColor,\n align: \"left\",\n valign: \"top\",\n },\n );\n\n // 右上\n addGlimpseTextBox(\n ctx,\n {\n x: centerX + quadrantInset,\n y: areaY + quadrantInset,\n w: quadrantW,\n h: quadrantH,\n },\n {\n text: quadrants.topRight,\n fontSize: quadrantFontSize,\n fontFace: \"Noto Sans JP\",\n color: quadrantColor,\n align: \"right\",\n valign: \"top\",\n },\n );\n\n // 左下\n addGlimpseTextBox(\n ctx,\n {\n x: areaX + quadrantInset,\n y: centerY + areaH / 2 - quadrantH - quadrantInset,\n w: quadrantW,\n h: quadrantH,\n },\n {\n text: quadrants.bottomLeft,\n fontSize: quadrantFontSize,\n fontFace: \"Noto Sans JP\",\n color: quadrantColor,\n align: \"left\",\n valign: \"bottom\",\n },\n );\n\n // 右下\n addGlimpseTextBox(\n ctx,\n {\n x: centerX + quadrantInset,\n y: centerY + areaH / 2 - quadrantH - quadrantInset,\n w: quadrantW,\n h: quadrantH,\n },\n {\n text: quadrants.bottomRight,\n fontSize: quadrantFontSize,\n fontFace: \"Noto Sans JP\",\n color: quadrantColor,\n align: \"right\",\n valign: \"bottom\",\n },\n );\n}\n"],"mappings":";;;;;;;AAgBA,SAAgB,iBACd,MACA,KACM;CACN,MAAM,QAAQ,KAAK;CACnB,MAAM,OAAO,KAAK;CAClB,MAAM,YAAY,KAAK;CAEvB,MAAM,mBAAmB;CACzB,MAAM,eAAe;CACrB,MAAM,gBAAgB;CACtB,MAAM,YAAY;CAClB,MAAM,iBAAiB,UAAU,KAAK,cAAc,KAAK;CACzD,MAAM,iBAAiB,UAAU,KAAK,cAAc,KAAK;CAGzD,MAAM,EAAE,SAAS,gBAAgB,yBAC/B,MACA,cAAc,IAAI,GAClB,GACF;CAEA,MAAM,WAAW,eAAe;CAChC,MAAM,YAAY,gBAAgB;CAGlC,MAAM,aAAa,KAAK;CACxB,MAAM,QAAQ,QAAQ,IAAI;CAC1B,MAAM,QAAQ,QAAQ,IAAI;CAC1B,MAAM,QAAQ,QAAQ,IAAI,aAAa;CACvC,MAAM,QAAQ,QAAQ,IAAI,aAAa;CAGvC,MAAM,UAAU,QAAQ,QAAQ;CAChC,MAAM,UAAU,QAAQ,QAAQ;CAIhC,gBACE,KACA;EAAE,IAAI;EAAO,IAAI;EAAS,IAAI,QAAQ;EAAO,IAAI;CAAQ,GACzD;EAAE,OAAO;EAAW;CAAU,CAChC;CAGA,gBACE,KACA;EAAE,IAAI;EAAS,IAAI;EAAO,IAAI;EAAS,IAAI,QAAQ;CAAM,GACzD;EAAE,OAAO;EAAW;CAAU,CAChC;CAGA,MAAM,aAAa,MAAM;CACzB,MAAM,aAAa,KAAK;CAGxB,kBACE,KACA;EACE,GAAG,UAAU,aAAa;EAC1B,GAAG,QAAQ,QAAQ,IAAI;EACvB,GAAG;EACH,GAAG;CACL,GACA;EACE,MAAM,KAAK;EACX,UAAU,KAAK;EACf,UAAU;EACV,OAAO;EACP,OAAO;EACP,QAAQ;CACV,CACF;CAGA,MAAM,UAAU,MAAM;CACtB,MAAM,UAAU,KAAK;CACrB,kBACE,KACA;EACE,GAAG,QAAQ,IAAI,aAAa,IAAI,UAAU;EAC1C,GAAG,UAAU,UAAU;EACvB,GAAG;EACH,GAAG;CACL,GACA;EACE,MAAM,KAAK;EACX,UAAU,KAAK;EACf,UAAU;EACV,OAAO;EACP,OAAO;EACP,QAAQ;EACR,QAAQ;CACV,CACF;CAGA,IAAI,WACF,qBACE,KACA,WACA,OACA,OACA,OACA,OACA,SACA,SACA,aACA,UAAU,KAAK,kBAAkB,KAAK,QACxC;CAIF,MAAM,aAAa,MAAM;CACzB,MAAM,aAAa,KAAK;CAExB,KAAK,MAAM,QAAQ,OAAO;EAIxB,MAAM,QAAQ,QAAQ,KAAK,IAAI;EAC/B,MAAM,QAAQ,SAAS,IAAI,KAAK,KAAK;EACrC,MAAM,YAAY,KAAK,SAAS;EAGhC,gBACE,KACA;GACE,QAAQ;
|
|
1
|
+
{"version":3,"file":"matrix.js","names":[],"sources":["../../../src/renderPptx/nodes/matrix.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { stripHash } from \"../utils/visualStyle.ts\";\nimport { measureMatrix } from \"../../calcYogaLayout/measureCompositeNodes.ts\";\nimport { resolveScaledContentArea } from \"../utils/scaleToFit.ts\";\nimport { addStraightLine } from \"../utils/straightLine.ts\";\nimport {\n addGlimpseShape,\n createShapeBoundsInput,\n noShapeOutline,\n solidShapeFill,\n} from \"../utils/glimpseShape.ts\";\nimport { addGlimpseTextBox } from \"../utils/glimpseTextBox.ts\";\n\ntype MatrixPositionedNode = Extract<PositionedNode, { type: \"matrix\" }>;\n\nexport function renderMatrixNode(\n node: MatrixPositionedNode,\n ctx: RenderContext,\n): void {\n const items = node.items;\n const axes = node.axes;\n const quadrants = node.quadrants;\n\n const defaultItemColor = \"1D4ED8\"; // blue\n const baseItemSize = 24; // px\n const baseLineWidth = 2; // px\n const axisColor = \"E2E8F0\";\n const axisLabelColor = stripHash(node.axisLabelColor) ?? \"64748B\";\n const itemLabelColor = stripHash(node.itemLabelColor) ?? \"1E293B\";\n\n // スケール係数を計算(コンテンツ領域基準)\n const { content, scaleFactor } = resolveScaledContentArea(\n node,\n measureMatrix(node),\n ctx,\n );\n\n const itemSize = baseItemSize * scaleFactor;\n const lineWidth = baseLineWidth * scaleFactor;\n\n // マトリクスの描画領域(軸ラベル用の余白を考慮)\n const axisMargin = 60 * scaleFactor; // 軸ラベル用の余白\n const areaX = content.x + axisMargin;\n const areaY = content.y + axisMargin;\n const areaW = content.w - axisMargin * 2;\n const areaH = content.h - axisMargin * 2;\n\n // 中心座標\n const centerX = areaX + areaW / 2;\n const centerY = areaY + areaH / 2;\n\n // === 1. 十字線(軸線)を描画 ===\n // 横線(X軸)\n addStraightLine(\n ctx,\n { x1: areaX, y1: centerY, x2: areaX + areaW, y2: centerY },\n { color: axisColor, lineWidth },\n );\n\n // 縦線(Y軸)\n addStraightLine(\n ctx,\n { x1: centerX, y1: areaY, x2: centerX, y2: areaY + areaH },\n { color: axisColor, lineWidth },\n );\n\n // === 2. 軸ラベルを描画 ===\n const axisLabelW = 120 * scaleFactor;\n const axisLabelH = 24 * scaleFactor;\n\n // X軸ラベル(下部中央)\n addGlimpseTextBox(\n ctx,\n {\n x: centerX - axisLabelW / 2,\n y: areaY + areaH + 8 * scaleFactor,\n w: axisLabelW,\n h: axisLabelH,\n },\n {\n text: axes.x,\n fontSize: 12 * scaleFactor,\n fontFace: \"Noto Sans JP\",\n color: axisLabelColor,\n align: \"center\",\n valign: \"top\",\n },\n );\n\n // Y軸ラベル(左部中央)270° 回転で下から上読み。w が視覚的な高さになるため CJK 5 文字以上も収まる幅を確保\n const yLabelW = 100 * scaleFactor;\n const yLabelH = 20 * scaleFactor;\n addGlimpseTextBox(\n ctx,\n {\n x: content.x + axisMargin / 2 - yLabelW / 2,\n y: centerY - yLabelH / 2,\n w: yLabelW,\n h: yLabelH,\n },\n {\n text: axes.y,\n fontSize: 12 * scaleFactor,\n fontFace: \"Noto Sans JP\",\n color: axisLabelColor,\n align: \"center\",\n valign: \"middle\",\n rotate: 270,\n },\n );\n\n // === 3. 象限ラベルを描画 ===\n if (quadrants) {\n renderQuadrantLabels(\n ctx,\n quadrants,\n areaX,\n areaY,\n areaW,\n areaH,\n centerX,\n centerY,\n scaleFactor,\n stripHash(node.quadrantLabelColor) ?? \"94A3B8\",\n );\n }\n\n // === 4. アイテムをプロット ===\n const itemLabelW = 100 * scaleFactor;\n const itemLabelH = 18 * scaleFactor;\n\n for (const item of items) {\n // 座標変換: (0,0)=左下, (1,1)=右上\n // x: 0 -> areaX, 1 -> areaX + areaW\n // y: 0 -> areaY + areaH, 1 -> areaY (反転)\n const itemX = areaX + item.x * areaW;\n const itemY = areaY + (1 - item.y) * areaH; // Y軸反転\n const itemColor = item.color ?? defaultItemColor;\n\n // 円を描画\n addGlimpseShape(\n ctx,\n {\n geometry: { kind: \"preset\", preset: \"ellipse\" },\n ...createShapeBoundsInput({\n x: itemX - itemSize / 2,\n y: itemY - itemSize / 2,\n w: itemSize,\n h: itemSize,\n }),\n fill: solidShapeFill(itemColor),\n outline: noShapeOutline(),\n },\n {\n x: itemX - itemSize / 2,\n y: itemY - itemSize / 2,\n w: itemSize,\n h: itemSize,\n },\n { fillColor: itemColor },\n );\n\n // ラベルを描画(円の上)\n addGlimpseTextBox(\n ctx,\n {\n x: itemX - itemLabelW / 2,\n y: itemY - itemSize / 2 - 20 * scaleFactor,\n w: itemLabelW,\n h: itemLabelH,\n },\n {\n text: item.label,\n fontSize: 11 * scaleFactor,\n fontFace: \"Noto Sans JP\",\n color: stripHash(item.textColor) ?? itemLabelColor,\n bold: true,\n align: \"center\",\n valign: \"bottom\",\n },\n );\n }\n}\n\nfunction renderQuadrantLabels(\n ctx: RenderContext,\n quadrants: NonNullable<MatrixPositionedNode[\"quadrants\"]>,\n areaX: number,\n areaY: number,\n areaW: number,\n areaH: number,\n centerX: number,\n centerY: number,\n scaleFactor: number,\n quadrantColor: string,\n): void {\n const quadrantFontSize = 11 * scaleFactor;\n const quadrantInset = 10 * scaleFactor;\n const quadrantW = areaW / 2 - 20 * scaleFactor;\n const quadrantH = 48 * scaleFactor;\n\n // 左上\n addGlimpseTextBox(\n ctx,\n {\n x: areaX + quadrantInset,\n y: areaY + quadrantInset,\n w: quadrantW,\n h: quadrantH,\n },\n {\n text: quadrants.topLeft,\n fontSize: quadrantFontSize,\n fontFace: \"Noto Sans JP\",\n color: quadrantColor,\n align: \"left\",\n valign: \"top\",\n },\n );\n\n // 右上\n addGlimpseTextBox(\n ctx,\n {\n x: centerX + quadrantInset,\n y: areaY + quadrantInset,\n w: quadrantW,\n h: quadrantH,\n },\n {\n text: quadrants.topRight,\n fontSize: quadrantFontSize,\n fontFace: \"Noto Sans JP\",\n color: quadrantColor,\n align: \"right\",\n valign: \"top\",\n },\n );\n\n // 左下\n addGlimpseTextBox(\n ctx,\n {\n x: areaX + quadrantInset,\n y: centerY + areaH / 2 - quadrantH - quadrantInset,\n w: quadrantW,\n h: quadrantH,\n },\n {\n text: quadrants.bottomLeft,\n fontSize: quadrantFontSize,\n fontFace: \"Noto Sans JP\",\n color: quadrantColor,\n align: \"left\",\n valign: \"bottom\",\n },\n );\n\n // 右下\n addGlimpseTextBox(\n ctx,\n {\n x: centerX + quadrantInset,\n y: centerY + areaH / 2 - quadrantH - quadrantInset,\n w: quadrantW,\n h: quadrantH,\n },\n {\n text: quadrants.bottomRight,\n fontSize: quadrantFontSize,\n fontFace: \"Noto Sans JP\",\n color: quadrantColor,\n align: \"right\",\n valign: \"bottom\",\n },\n );\n}\n"],"mappings":";;;;;;;AAgBA,SAAgB,iBACd,MACA,KACM;CACN,MAAM,QAAQ,KAAK;CACnB,MAAM,OAAO,KAAK;CAClB,MAAM,YAAY,KAAK;CAEvB,MAAM,mBAAmB;CACzB,MAAM,eAAe;CACrB,MAAM,gBAAgB;CACtB,MAAM,YAAY;CAClB,MAAM,iBAAiB,UAAU,KAAK,cAAc,KAAK;CACzD,MAAM,iBAAiB,UAAU,KAAK,cAAc,KAAK;CAGzD,MAAM,EAAE,SAAS,gBAAgB,yBAC/B,MACA,cAAc,IAAI,GAClB,GACF;CAEA,MAAM,WAAW,eAAe;CAChC,MAAM,YAAY,gBAAgB;CAGlC,MAAM,aAAa,KAAK;CACxB,MAAM,QAAQ,QAAQ,IAAI;CAC1B,MAAM,QAAQ,QAAQ,IAAI;CAC1B,MAAM,QAAQ,QAAQ,IAAI,aAAa;CACvC,MAAM,QAAQ,QAAQ,IAAI,aAAa;CAGvC,MAAM,UAAU,QAAQ,QAAQ;CAChC,MAAM,UAAU,QAAQ,QAAQ;CAIhC,gBACE,KACA;EAAE,IAAI;EAAO,IAAI;EAAS,IAAI,QAAQ;EAAO,IAAI;CAAQ,GACzD;EAAE,OAAO;EAAW;CAAU,CAChC;CAGA,gBACE,KACA;EAAE,IAAI;EAAS,IAAI;EAAO,IAAI;EAAS,IAAI,QAAQ;CAAM,GACzD;EAAE,OAAO;EAAW;CAAU,CAChC;CAGA,MAAM,aAAa,MAAM;CACzB,MAAM,aAAa,KAAK;CAGxB,kBACE,KACA;E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KAAK,SAAS,KAAK;GACpC,MAAM;GACN,OAAO;GACP,QAAQ;EACV,CACF;CACF;AACF;AAEA,SAAS,qBACP,KACA,WACA,OACA,OACA,OACA,OACA,SACA,SACA,aACA,eACM;CACN,MAAM,mBAAmB,KAAK;CAC9B,MAAM,gBAAgB,KAAK;CAC3B,MAAM,YAAY,QAAQ,IAAI,KAAK;CACnC,MAAM,YAAY,KAAK;CAGvB,kBACE,KACA;EACE,GAAG,QAAQ;EACX,GAAG,QAAQ;EACX,GAAG;EACH,GAAG;CACL,GACA;EACE,MAAM,UAAU;EAChB,UAAU;EACV,UAAU;EACV,OAAO;EACP,OAAO;EACP,QAAQ;CACV,CACF;CAGA,kBACE,KACA;EACE,GAAG,UAAU;EACb,GAAG,QAAQ;EACX,GAAG;EACH,GAAG;CACL,GACA;EACE,MAAM,UAAU;EAChB,UAAU;EACV,UAAU;EACV,OAAO;EACP,OAAO;EACP,QAAQ;CACV,CACF;CAGA,kBACE,KACA;EACE,GAAG,QAAQ;EACX,GAAG,UAAU,QAAQ,IAAI,YAAY;EACrC,GAAG;EACH,GAAG;CACL,GACA;EACE,MAAM,UAAU;EAChB,UAAU;EACV,UAAU;EACV,OAAO;EACP,OAAO;EACP,QAAQ;CACV,CACF;CAGA,kBACE,KACA;EACE,GAAG,UAAU;EACb,GAAG,UAAU,QAAQ,IAAI,YAAY;EACrC,GAAG;EACH,GAAG;CACL,GACA;EACE,MAAM,UAAU;EAChB,UAAU;EACV,UAAU;EACV,OAAO;EACP,OAAO;EACP,QAAQ;CACV,CACF;AACF"}
|
|
@@ -87,7 +87,10 @@ function renderHorizontalProcessArrow(node, ctx, steps, stepCount, itemWidth, it
|
|
|
87
87
|
{ close: true }
|
|
88
88
|
];
|
|
89
89
|
addGlimpseShape(ctx, {
|
|
90
|
-
|
|
90
|
+
geometry: {
|
|
91
|
+
kind: "preset",
|
|
92
|
+
preset: "rect"
|
|
93
|
+
},
|
|
91
94
|
...createShapeBoundsInput({
|
|
92
95
|
x: stepX,
|
|
93
96
|
y: stepY,
|
|
@@ -191,7 +194,10 @@ function renderVerticalProcessArrow(node, ctx, steps, stepCount, itemWidth, item
|
|
|
191
194
|
{ close: true }
|
|
192
195
|
];
|
|
193
196
|
addGlimpseShape(ctx, {
|
|
194
|
-
|
|
197
|
+
geometry: {
|
|
198
|
+
kind: "preset",
|
|
199
|
+
preset: "rect"
|
|
200
|
+
},
|
|
195
201
|
...createShapeBoundsInput({
|
|
196
202
|
x: stepX,
|
|
197
203
|
y: stepY,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processArrow.js","names":[],"sources":["../../../src/renderPptx/nodes/processArrow.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { stripHash } from \"../utils/visualStyle.ts\";\nimport { pxToIn } from \"../units.ts\";\nimport { measureProcessArrow } from \"../../calcYogaLayout/measureCompositeNodes.ts\";\nimport { resolveScaledContentArea } from \"../utils/scaleToFit.ts\";\nimport {\n ARROW_DEPTH_RATIO,\n DEFAULT_PROCESS_ARROW_ITEM_WIDTH,\n DEFAULT_PROCESS_ARROW_ITEM_HEIGHT,\n} from \"../../shared/processArrowConstants.ts\";\nimport { withContentBounds } from \"../utils/contentArea.ts\";\nimport {\n addGlimpseShape,\n createShapeBoundsInput,\n noShapeOutline,\n solidShapeFill,\n} from \"../utils/glimpseShape.ts\";\nimport { addGlimpseTextBox } from \"../utils/glimpseTextBox.ts\";\n\ntype ProcessArrowPositionedNode = Extract<\n PositionedNode,\n { type: \"processArrow\" }\n>;\n\nexport function renderProcessArrowNode(\n node: ProcessArrowPositionedNode,\n ctx: RenderContext,\n): void {\n const direction = node.direction ?? \"horizontal\";\n const steps = node.steps;\n const stepCount = steps.length;\n\n if (stepCount === 0) return;\n\n const defaultColor = \"4472C4\"; // PowerPoint標準の青\n const defaultTextColor = \"FFFFFF\";\n const itemWidth = node.itemWidth ?? DEFAULT_PROCESS_ARROW_ITEM_WIDTH;\n const itemHeight = node.itemHeight ?? DEFAULT_PROCESS_ARROW_ITEM_HEIGHT;\n const arrowDepth = itemHeight * ARROW_DEPTH_RATIO;\n const gap = node.gap ?? -arrowDepth;\n\n // スケール係数を計算(コンテンツ領域基準)\n const { content, scaleFactor } = resolveScaledContentArea(\n node,\n measureProcessArrow(node),\n ctx,\n );\n\n const scaledItemWidth = itemWidth * scaleFactor;\n const scaledItemHeight = itemHeight * scaleFactor;\n const scaledGap = gap * scaleFactor;\n const scaledArrowDepth = arrowDepth * scaleFactor;\n\n // コンテンツ領域を使用するための仮想ノードを作成\n const contentNode = withContentBounds(node, content);\n\n if (direction === \"horizontal\") {\n renderHorizontalProcessArrow(\n contentNode,\n ctx,\n steps,\n stepCount,\n scaledItemWidth,\n scaledItemHeight,\n scaledGap,\n scaledArrowDepth,\n defaultColor,\n defaultTextColor,\n scaleFactor,\n );\n } else {\n renderVerticalProcessArrow(\n contentNode,\n ctx,\n steps,\n stepCount,\n scaledItemWidth,\n scaledItemHeight,\n scaledGap,\n scaledArrowDepth,\n defaultColor,\n defaultTextColor,\n scaleFactor,\n );\n }\n}\n\nfunction renderHorizontalProcessArrow(\n node: ProcessArrowPositionedNode,\n ctx: RenderContext,\n steps: ProcessArrowPositionedNode[\"steps\"],\n stepCount: number,\n itemWidth: number,\n itemHeight: number,\n gap: number,\n arrowDepth: number,\n defaultColor: string,\n defaultTextColor: string,\n scaleFactor: number,\n): void {\n const totalWidth = stepCount * itemWidth + (stepCount - 1) * gap;\n const startX = node.x + (node.w - totalWidth) / 2;\n const centerY = node.y + node.h / 2;\n\n steps.forEach((step, index) => {\n const stepX = startX + index * (itemWidth + gap);\n const stepY = centerY - itemHeight / 2;\n const fillColor = stripHash(step.color) ?? defaultColor;\n const textColor = stripHash(step.textColor) ?? defaultTextColor;\n\n // custGeom でシェブロン形状を描画\n const isFirst = index === 0;\n const points = isFirst\n ? [\n // homePlate 風: 左辺フラット、右辺が矢印\n { x: 0, y: 0 },\n { x: pxToIn(itemWidth - arrowDepth), y: 0 },\n { x: pxToIn(itemWidth), y: pxToIn(itemHeight / 2) },\n { x: pxToIn(itemWidth - arrowDepth), y: pxToIn(itemHeight) },\n { x: 0, y: pxToIn(itemHeight) },\n { close: true as const },\n ]\n : [\n // chevron 風: 左辺に切り欠き、右辺が矢印\n { x: 0, y: 0 },\n { x: pxToIn(itemWidth - arrowDepth), y: 0 },\n { x: pxToIn(itemWidth), y: pxToIn(itemHeight / 2) },\n { x: pxToIn(itemWidth - arrowDepth), y: pxToIn(itemHeight) },\n { x: 0, y: pxToIn(itemHeight) },\n { x: pxToIn(arrowDepth), y: pxToIn(itemHeight / 2) },\n { close: true as const },\n ];\n\n addGlimpseShape(\n ctx,\n {\n preset: \"rect\",\n ...createShapeBoundsInput({\n x: stepX,\n y: stepY,\n w: itemWidth,\n h: itemHeight,\n }),\n fill: solidShapeFill(fillColor),\n outline: noShapeOutline(),\n },\n { x: stepX, y: stepY, w: itemWidth, h: itemHeight },\n {\n fillColor,\n customGeometry: {\n width: pxToIn(itemWidth),\n height: pxToIn(itemHeight),\n points,\n },\n },\n );\n\n // テキストを図形の中央(矢印部分を除いた領域)に配置\n const textOffsetLeft = isFirst ? 0 : arrowDepth;\n const textWidth = Math.max(1, itemWidth - arrowDepth - textOffsetLeft);\n\n addGlimpseTextBox(\n ctx,\n {\n x: stepX + textOffsetLeft,\n y: stepY,\n w: textWidth,\n h: itemHeight,\n },\n {\n text: step.label,\n fontSize: (node.fontSize ?? 14) * scaleFactor,\n fontFace: node.fontFamily ?? \"Noto Sans JP\",\n color: textColor,\n bold: node.bold ?? false,\n italic: node.italic,\n underline: node.underline,\n strike: node.strike,\n highlight: node.highlight,\n align: \"center\",\n valign: \"middle\",\n },\n );\n });\n}\n\nfunction renderVerticalProcessArrow(\n node: ProcessArrowPositionedNode,\n ctx: RenderContext,\n steps: ProcessArrowPositionedNode[\"steps\"],\n stepCount: number,\n itemWidth: number,\n itemHeight: number,\n gap: number,\n arrowDepth: number,\n defaultColor: string,\n defaultTextColor: string,\n scaleFactor: number,\n): void {\n const totalHeight = stepCount * itemHeight + (stepCount - 1) * gap;\n const startY = node.y + (node.h - totalHeight) / 2;\n const centerX = node.x + node.w / 2;\n\n steps.forEach((step, index) => {\n const stepX = centerX - itemWidth / 2;\n const stepY = startY + index * (itemHeight + gap);\n const fillColor = stripHash(step.color) ?? defaultColor;\n const textColor = stripHash(step.textColor) ?? defaultTextColor;\n\n const isFirst = index === 0;\n const points = isFirst\n ? [\n // rect 風: 上辺フラット、下辺が矢印\n { x: 0, y: 0 },\n { x: pxToIn(itemWidth), y: 0 },\n { x: pxToIn(itemWidth), y: pxToIn(itemHeight - arrowDepth) },\n { x: pxToIn(itemWidth / 2), y: pxToIn(itemHeight) },\n { x: 0, y: pxToIn(itemHeight - arrowDepth) },\n { close: true as const },\n ]\n : [\n // pentagon 風: 上辺に切り欠き、下辺が矢印\n { x: pxToIn(itemWidth / 2), y: 0 },\n { x: pxToIn(itemWidth), y: pxToIn(arrowDepth) },\n { x: pxToIn(itemWidth), y: pxToIn(itemHeight - arrowDepth) },\n { x: pxToIn(itemWidth / 2), y: pxToIn(itemHeight) },\n { x: 0, y: pxToIn(itemHeight - arrowDepth) },\n { x: 0, y: pxToIn(arrowDepth) },\n { close: true as const },\n ];\n\n addGlimpseShape(\n ctx,\n {\n preset: \"rect\",\n ...createShapeBoundsInput({\n x: stepX,\n y: stepY,\n w: itemWidth,\n h: itemHeight,\n }),\n fill: solidShapeFill(fillColor),\n outline: noShapeOutline(),\n },\n { x: stepX, y: stepY, w: itemWidth, h: itemHeight },\n {\n fillColor,\n customGeometry: {\n width: pxToIn(itemWidth),\n height: pxToIn(itemHeight),\n points,\n },\n },\n );\n\n // テキストを図形の中央(矢印部分を除いた領域)に配置\n const textOffsetTop = isFirst ? 0 : arrowDepth;\n const textHeight = Math.max(1, itemHeight - arrowDepth - textOffsetTop);\n\n addGlimpseTextBox(\n ctx,\n {\n x: stepX,\n y: stepY + textOffsetTop,\n w: itemWidth,\n h: textHeight,\n },\n {\n text: step.label,\n fontSize: (node.fontSize ?? 14) * scaleFactor,\n fontFace: node.fontFamily ?? \"Noto Sans JP\",\n color: textColor,\n bold: node.bold ?? false,\n italic: node.italic,\n underline: node.underline,\n strike: node.strike,\n highlight: node.highlight,\n align: \"center\",\n valign: \"middle\",\n },\n );\n });\n}\n"],"mappings":";;;;;;;;;AAyBA,SAAgB,uBACd,MACA,KACM;CACN,MAAM,YAAY,KAAK,aAAa;CACpC,MAAM,QAAQ,KAAK;CACnB,MAAM,YAAY,MAAM;CAExB,IAAI,cAAc,GAAG;CAErB,MAAM,eAAe;CACrB,MAAM,mBAAmB;CACzB,MAAM,YAAY,KAAK,aAAA;CACvB,MAAM,aAAa,KAAK,cAAA;CACxB,MAAM,aAAa,aAAa;CAChC,MAAM,MAAM,KAAK,OAAO,CAAC;CAGzB,MAAM,EAAE,SAAS,gBAAgB,yBAC/B,MACA,oBAAoB,IAAI,GACxB,GACF;CAEA,MAAM,kBAAkB,YAAY;CACpC,MAAM,mBAAmB,aAAa;CACtC,MAAM,YAAY,MAAM;CACxB,MAAM,mBAAmB,aAAa;CAGtC,MAAM,cAAc,kBAAkB,MAAM,OAAO;CAEnD,IAAI,cAAc,cAChB,6BACE,aACA,KACA,OACA,WACA,iBACA,kBACA,WACA,kBACA,cACA,kBACA,WACF;MAEA,2BACE,aACA,KACA,OACA,WACA,iBACA,kBACA,WACA,kBACA,cACA,kBACA,WACF;AAEJ;AAEA,SAAS,6BACP,MACA,KACA,OACA,WACA,WACA,YACA,KACA,YACA,cACA,kBACA,aACM;CACN,MAAM,aAAa,YAAY,aAAa,YAAY,KAAK;CAC7D,MAAM,SAAS,KAAK,KAAK,KAAK,IAAI,cAAc;CAChD,MAAM,UAAU,KAAK,IAAI,KAAK,IAAI;CAElC,MAAM,SAAS,MAAM,UAAU;EAC7B,MAAM,QAAQ,SAAS,SAAS,YAAY;EAC5C,MAAM,QAAQ,UAAU,aAAa;E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YAAY,CAAC;IAAG,GAAG,OAAO,UAAU;GAAE;GAClD;IAAE,GAAG;IAAG,GAAG,OAAO,aAAa,UAAU;GAAE;GAC3C;IAAE,GAAG;IAAG,GAAG,OAAO,UAAU;GAAE;GAC9B,EAAE,OAAO,KAAc;EACzB;EAEJ,gBACE,KACA;GACE,QAAQ;GACR,GAAG,uBAAuB;IACxB,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;GACL,CAAC;GACD,MAAM,eAAe,SAAS;GAC9B,SAAS,eAAe;EAC1B,GACA;GAAE,GAAG;GAAO,GAAG;GAAO,GAAG;GAAW,GAAG;EAAW,GAClD;GACE;GACA,gBAAgB;IACd,OAAO,OAAO,SAAS;IACvB,QAAQ,OAAO,UAAU;IACzB;GACF;EACF,CACF;EAGA,MAAM,gBAAgB,UAAU,IAAI;EACpC,MAAM,aAAa,KAAK,IAAI,GAAG,aAAa,aAAa,aAAa;EAEtE,kBACE,KACA;GACE,GAAG;GACH,GAAG,QAAQ;GACX,GAAG;GACH,GAAG;EACL,GACA;GACE,MAAM,KAAK;GACX,WAAW,KAAK,YAAY,MAAM;GAClC,UAAU,KAAK,cAAc;GAC7B,OAAO;GACP,MAAM,KAAK,QAAQ;GACnB,QAAQ,KAAK;GACb,WAAW,KAAK;GAChB,QAAQ,KAAK;GACb,WAAW,KAAK;GAChB,OAAO;GACP,QAAQ;EACV,CACF;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"processArrow.js","names":[],"sources":["../../../src/renderPptx/nodes/processArrow.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { stripHash } from \"../utils/visualStyle.ts\";\nimport { pxToIn } from \"../units.ts\";\nimport { measureProcessArrow } from \"../../calcYogaLayout/measureCompositeNodes.ts\";\nimport { resolveScaledContentArea } from \"../utils/scaleToFit.ts\";\nimport {\n ARROW_DEPTH_RATIO,\n DEFAULT_PROCESS_ARROW_ITEM_WIDTH,\n DEFAULT_PROCESS_ARROW_ITEM_HEIGHT,\n} from \"../../shared/processArrowConstants.ts\";\nimport { withContentBounds } from \"../utils/contentArea.ts\";\nimport {\n addGlimpseShape,\n createShapeBoundsInput,\n noShapeOutline,\n solidShapeFill,\n} from \"../utils/glimpseShape.ts\";\nimport { addGlimpseTextBox } from \"../utils/glimpseTextBox.ts\";\n\ntype ProcessArrowPositionedNode = Extract<\n PositionedNode,\n { type: \"processArrow\" }\n>;\n\nexport function renderProcessArrowNode(\n node: ProcessArrowPositionedNode,\n ctx: RenderContext,\n): void {\n const direction = node.direction ?? \"horizontal\";\n const steps = node.steps;\n const stepCount = steps.length;\n\n if (stepCount === 0) return;\n\n const defaultColor = \"4472C4\"; // PowerPoint標準の青\n const defaultTextColor = \"FFFFFF\";\n const itemWidth = node.itemWidth ?? DEFAULT_PROCESS_ARROW_ITEM_WIDTH;\n const itemHeight = node.itemHeight ?? DEFAULT_PROCESS_ARROW_ITEM_HEIGHT;\n const arrowDepth = itemHeight * ARROW_DEPTH_RATIO;\n const gap = node.gap ?? -arrowDepth;\n\n // スケール係数を計算(コンテンツ領域基準)\n const { content, scaleFactor } = resolveScaledContentArea(\n node,\n measureProcessArrow(node),\n ctx,\n );\n\n const scaledItemWidth = itemWidth * scaleFactor;\n const scaledItemHeight = itemHeight * scaleFactor;\n const scaledGap = gap * scaleFactor;\n const scaledArrowDepth = arrowDepth * scaleFactor;\n\n // コンテンツ領域を使用するための仮想ノードを作成\n const contentNode = withContentBounds(node, content);\n\n if (direction === \"horizontal\") {\n renderHorizontalProcessArrow(\n contentNode,\n ctx,\n steps,\n stepCount,\n scaledItemWidth,\n scaledItemHeight,\n scaledGap,\n scaledArrowDepth,\n defaultColor,\n defaultTextColor,\n scaleFactor,\n );\n } else {\n renderVerticalProcessArrow(\n contentNode,\n ctx,\n steps,\n stepCount,\n scaledItemWidth,\n scaledItemHeight,\n scaledGap,\n scaledArrowDepth,\n defaultColor,\n defaultTextColor,\n scaleFactor,\n );\n }\n}\n\nfunction renderHorizontalProcessArrow(\n node: ProcessArrowPositionedNode,\n ctx: RenderContext,\n steps: ProcessArrowPositionedNode[\"steps\"],\n stepCount: number,\n itemWidth: number,\n itemHeight: number,\n gap: number,\n arrowDepth: number,\n defaultColor: string,\n defaultTextColor: string,\n scaleFactor: number,\n): void {\n const totalWidth = stepCount * itemWidth + (stepCount - 1) * gap;\n const startX = node.x + (node.w - totalWidth) / 2;\n const centerY = node.y + node.h / 2;\n\n steps.forEach((step, index) => {\n const stepX = startX + index * (itemWidth + gap);\n const stepY = centerY - itemHeight / 2;\n const fillColor = stripHash(step.color) ?? defaultColor;\n const textColor = stripHash(step.textColor) ?? defaultTextColor;\n\n // custGeom でシェブロン形状を描画\n const isFirst = index === 0;\n const points = isFirst\n ? [\n // homePlate 風: 左辺フラット、右辺が矢印\n { x: 0, y: 0 },\n { x: pxToIn(itemWidth - arrowDepth), y: 0 },\n { x: pxToIn(itemWidth), y: pxToIn(itemHeight / 2) },\n { x: pxToIn(itemWidth - arrowDepth), y: pxToIn(itemHeight) },\n { x: 0, y: pxToIn(itemHeight) },\n { close: true as const },\n ]\n : [\n // chevron 風: 左辺に切り欠き、右辺が矢印\n { x: 0, y: 0 },\n { x: pxToIn(itemWidth - arrowDepth), y: 0 },\n { x: pxToIn(itemWidth), y: pxToIn(itemHeight / 2) },\n { x: pxToIn(itemWidth - arrowDepth), y: pxToIn(itemHeight) },\n { x: 0, y: pxToIn(itemHeight) },\n { x: pxToIn(arrowDepth), y: pxToIn(itemHeight / 2) },\n { close: true as const },\n ];\n\n addGlimpseShape(\n ctx,\n {\n geometry: { kind: \"preset\", preset: \"rect\" },\n ...createShapeBoundsInput({\n x: stepX,\n y: stepY,\n w: itemWidth,\n h: itemHeight,\n }),\n fill: solidShapeFill(fillColor),\n outline: noShapeOutline(),\n },\n { x: stepX, y: stepY, w: itemWidth, h: itemHeight },\n {\n fillColor,\n customGeometry: {\n width: pxToIn(itemWidth),\n height: pxToIn(itemHeight),\n points,\n },\n },\n );\n\n // テキストを図形の中央(矢印部分を除いた領域)に配置\n const textOffsetLeft = isFirst ? 0 : arrowDepth;\n const textWidth = Math.max(1, itemWidth - arrowDepth - textOffsetLeft);\n\n addGlimpseTextBox(\n ctx,\n {\n x: stepX + textOffsetLeft,\n y: stepY,\n w: textWidth,\n h: itemHeight,\n },\n {\n text: step.label,\n fontSize: (node.fontSize ?? 14) * scaleFactor,\n fontFace: node.fontFamily ?? \"Noto Sans JP\",\n color: textColor,\n bold: node.bold ?? false,\n italic: node.italic,\n underline: node.underline,\n strike: node.strike,\n highlight: node.highlight,\n align: \"center\",\n valign: \"middle\",\n },\n );\n });\n}\n\nfunction renderVerticalProcessArrow(\n node: ProcessArrowPositionedNode,\n ctx: RenderContext,\n steps: ProcessArrowPositionedNode[\"steps\"],\n stepCount: number,\n itemWidth: number,\n itemHeight: number,\n gap: number,\n arrowDepth: number,\n defaultColor: string,\n defaultTextColor: string,\n scaleFactor: number,\n): void {\n const totalHeight = stepCount * itemHeight + (stepCount - 1) * gap;\n const startY = node.y + (node.h - totalHeight) / 2;\n const centerX = node.x + node.w / 2;\n\n steps.forEach((step, index) => {\n const stepX = centerX - itemWidth / 2;\n const stepY = startY + index * (itemHeight + gap);\n const fillColor = stripHash(step.color) ?? defaultColor;\n const textColor = stripHash(step.textColor) ?? defaultTextColor;\n\n const isFirst = index === 0;\n const points = isFirst\n ? [\n // rect 風: 上辺フラット、下辺が矢印\n { x: 0, y: 0 },\n { x: pxToIn(itemWidth), y: 0 },\n { x: pxToIn(itemWidth), y: pxToIn(itemHeight - arrowDepth) },\n { x: pxToIn(itemWidth / 2), y: pxToIn(itemHeight) },\n { x: 0, y: pxToIn(itemHeight - arrowDepth) },\n { close: true as const },\n ]\n : [\n // pentagon 風: 上辺に切り欠き、下辺が矢印\n { x: pxToIn(itemWidth / 2), y: 0 },\n { x: pxToIn(itemWidth), y: pxToIn(arrowDepth) },\n { x: pxToIn(itemWidth), y: pxToIn(itemHeight - arrowDepth) },\n { x: pxToIn(itemWidth / 2), y: pxToIn(itemHeight) },\n { x: 0, y: pxToIn(itemHeight - arrowDepth) },\n { x: 0, y: pxToIn(arrowDepth) },\n { close: true as const },\n ];\n\n addGlimpseShape(\n ctx,\n {\n geometry: { kind: \"preset\", preset: \"rect\" },\n ...createShapeBoundsInput({\n x: stepX,\n y: stepY,\n w: itemWidth,\n h: itemHeight,\n }),\n fill: solidShapeFill(fillColor),\n outline: noShapeOutline(),\n },\n { x: stepX, y: stepY, w: itemWidth, h: itemHeight },\n {\n fillColor,\n customGeometry: {\n width: pxToIn(itemWidth),\n height: pxToIn(itemHeight),\n points,\n },\n },\n );\n\n // テキストを図形の中央(矢印部分を除いた領域)に配置\n const textOffsetTop = isFirst ? 0 : arrowDepth;\n const textHeight = Math.max(1, itemHeight - arrowDepth - textOffsetTop);\n\n addGlimpseTextBox(\n ctx,\n {\n x: stepX,\n y: stepY + textOffsetTop,\n w: itemWidth,\n h: textHeight,\n },\n {\n text: step.label,\n fontSize: (node.fontSize ?? 14) * scaleFactor,\n fontFace: node.fontFamily ?? \"Noto Sans JP\",\n color: textColor,\n bold: node.bold ?? false,\n italic: node.italic,\n underline: node.underline,\n strike: node.strike,\n highlight: node.highlight,\n align: \"center\",\n valign: \"middle\",\n },\n );\n });\n}\n"],"mappings":";;;;;;;;;AAyBA,SAAgB,uBACd,MACA,KACM;CACN,MAAM,YAAY,KAAK,aAAa;CACpC,MAAM,QAAQ,KAAK;CACnB,MAAM,YAAY,MAAM;CAExB,IAAI,cAAc,GAAG;CAErB,MAAM,eAAe;CACrB,MAAM,mBAAmB;CACzB,MAAM,YAAY,KAAK,aAAA;CACvB,MAAM,aAAa,KAAK,cAAA;CACxB,MAAM,aAAa,aAAa;CAChC,MAAM,MAAM,KAAK,OAAO,CAAC;CAGzB,MAAM,EAAE,SAAS,gBAAgB,yBAC/B,MACA,oBAAoB,IAAI,GACxB,GACF;CAEA,MAAM,kBAAkB,YAAY;CACpC,MAAM,mBAAm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G;GACH,GAAG,QAAQ;GACX,GAAG;GACH,GAAG;EACL,GACA;GACE,MAAM,KAAK;GACX,WAAW,KAAK,YAAY,MAAM;GAClC,UAAU,KAAK,cAAc;GAC7B,OAAO;GACP,MAAM,KAAK,QAAQ;GACnB,QAAQ,KAAK;GACb,WAAW,KAAK;GAChB,QAAQ,KAAK;GACb,WAAW,KAAK;GAChB,OAAO;GACP,QAAQ;EACV,CACF;CACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pyramid.js","names":[],"sources":["../../../src/renderPptx/nodes/pyramid.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { stripHash } from \"../utils/visualStyle.ts\";\nimport { pxToIn } from \"../units.ts\";\nimport { measurePyramid } from \"../../calcYogaLayout/measureCompositeNodes.ts\";\nimport { resolveScaledContentArea } from \"../utils/scaleToFit.ts\";\nimport {\n addGlimpseShape,\n createShapeBoundsInput,\n noShapeOutline,\n solidShapeFill,\n} from \"../utils/glimpseShape.ts\";\nimport { addGlimpseTextBox } from \"../utils/glimpseTextBox.ts\";\n\ntype PyramidPositionedNode = Extract<PositionedNode, { type: \"pyramid\" }>;\n\nexport function renderPyramidNode(\n node: PyramidPositionedNode,\n ctx: RenderContext,\n): void {\n const direction = node.direction ?? \"up\";\n const levels = node.levels;\n const levelCount = levels.length;\n\n if (levelCount === 0) return;\n\n const defaultColor = \"4472C4\";\n const defaultTextColor = \"FFFFFF\";\n\n // スケール係数を計算(コンテンツ領域基準)\n const { content, scaleFactor } = resolveScaledContentArea(\n node,\n measurePyramid(node),\n ctx,\n );\n\n const baseWidth = 400 * scaleFactor;\n const layerHeight = 50 * scaleFactor;\n const gap = 2 * scaleFactor;\n\n const totalHeight = levelCount * layerHeight + (levelCount - 1) * gap;\n const startX = content.x + (content.w - baseWidth) / 2;\n const startY = content.y + (content.h - totalHeight) / 2;\n\n for (let i = 0; i < levelCount; i++) {\n const level = levels[i];\n const fillColor = stripHash(level.color) ?? defaultColor;\n const textColor = stripHash(level.textColor) ?? defaultTextColor;\n\n const layerY = startY + i * (layerHeight + gap);\n\n // direction=\"up\": i=0 が最上段(最も狭い=三角形)、i=levelCount-1 が最下段(最も広い)\n // direction=\"down\": i=0 が最上段(最も広い)、i=levelCount-1 が最下段(最も狭い=三角形)\n // 頂点層の上辺は幅0(三角形)、それ以外は台形\n let topWidthRatio: number;\n let bottomWidthRatio: number;\n\n if (direction === \"up\") {\n topWidthRatio = i / levelCount;\n bottomWidthRatio = (i + 1) / levelCount;\n } else {\n topWidthRatio = (levelCount - i) / levelCount;\n bottomWidthRatio = (levelCount - i - 1) / levelCount;\n }\n\n const topWidth = baseWidth * topWidthRatio;\n const bottomWidth = baseWidth * bottomWidthRatio;\n\n const topLeftX = startX + (baseWidth - topWidth) / 2;\n const topRightX = topLeftX + topWidth;\n const bottomLeftX = startX + (baseWidth - bottomWidth) / 2;\n const bottomRightX = bottomLeftX + bottomWidth;\n\n // custGeom のバウンディングボックス\n const bboxX = Math.min(topLeftX, bottomLeftX);\n const bboxW = Math.max(topRightX, bottomRightX) - bboxX;\n\n // points はバウンディングボックス内の相対インチ座標\n const points = [\n { x: pxToIn(topLeftX - bboxX), y: 0 },\n { x: pxToIn(topRightX - bboxX), y: 0 },\n { x: pxToIn(bottomRightX - bboxX), y: pxToIn(layerHeight) },\n { x: pxToIn(bottomLeftX - bboxX), y: pxToIn(layerHeight) },\n { close: true as const },\n ];\n\n addGlimpseShape(\n ctx,\n {\n preset: \"rect\",\n ...createShapeBoundsInput({\n x: bboxX,\n y: layerY,\n w: bboxW,\n h: layerHeight,\n }),\n fill: solidShapeFill(fillColor),\n outline: noShapeOutline(),\n },\n { x: bboxX, y: layerY, w: bboxW, h: layerHeight },\n {\n fillColor,\n customGeometry: {\n width: pxToIn(bboxW),\n height: pxToIn(layerHeight),\n points,\n },\n },\n );\n\n // テキストを図形の中央に重ねて描画\n addGlimpseTextBox(\n ctx,\n {\n x: bboxX,\n y: layerY,\n w: bboxW,\n h: layerHeight,\n },\n {\n text: level.label,\n fontSize: (node.fontSize ?? 14) * scaleFactor,\n fontFace: node.fontFamily ?? \"Noto Sans JP\",\n color: textColor,\n bold: node.bold ?? false,\n align: \"center\",\n valign: \"middle\",\n autoFit: true,\n },\n );\n }\n}\n"],"mappings":";;;;;;;AAgBA,SAAgB,kBACd,MACA,KACM;CACN,MAAM,YAAY,KAAK,aAAa;CACpC,MAAM,SAAS,KAAK;CACpB,MAAM,aAAa,OAAO;CAE1B,IAAI,eAAe,GAAG;CAEtB,MAAM,eAAe;CACrB,MAAM,mBAAmB;CAGzB,MAAM,EAAE,SAAS,gBAAgB,yBAC/B,MACA,eAAe,IAAI,GACnB,GACF;CAEA,MAAM,YAAY,MAAM;CACxB,MAAM,cAAc,KAAK;CACzB,MAAM,MAAM,IAAI;CAEhB,MAAM,cAAc,aAAa,eAAe,aAAa,KAAK;CAClE,MAAM,SAAS,QAAQ,KAAK,QAAQ,IAAI,aAAa;CACrD,MAAM,SAAS,QAAQ,KAAK,QAAQ,IAAI,eAAe;CAEvD,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,KAAK;EACnC,MAAM,QAAQ,OAAO;EACrB,MAAM,YAAY,UAAU,MAAM,KAAK,KAAK;EAC5C,MAAM,YAAY,UAAU,MAAM,SAAS,KAAK;EAEhD,MAAM,SAAS,SAAS,KAAK,cAAc;EAK3C,IAAI;EACJ,IAAI;EAEJ,IAAI,cAAc,MAAM;GACtB,gBAAgB,IAAI;GACpB,oBAAoB,IAAI,KAAK;EAC/B,OAAO;GACL,iBAAiB,aAAa,KAAK;GACnC,oBAAoB,aAAa,IAAI,KAAK;EAC5C;EAEA,MAAM,WAAW,YAAY;EAC7B,MAAM,cAAc,YAAY;EAEhC,MAAM,WAAW,UAAU,YAAY,YAAY;EACnD,MAAM,YAAY,WAAW;EAC7B,MAAM,cAAc,UAAU,YAAY,eAAe;EACzD,MAAM,eAAe,cAAc;EAGnC,MAAM,QAAQ,KAAK,IAAI,UAAU,WAAW;EAC5C,MAAM,QAAQ,KAAK,IAAI,WAAW,YAAY,IAAI;EAGlD,MAAM,SAAS;GACb;IAAE,GAAG,OAAO,WAAW,KAAK;IAAG,GAAG;GAAE;GACpC;IAAE,GAAG,OAAO,YAAY,KAAK;IAAG,GAAG;GAAE;GACrC;IAAE,GAAG,OAAO,eAAe,KAAK;IAAG,GAAG,OAAO,WAAW;GAAE;GAC1D;IAAE,GAAG,OAAO,cAAc,KAAK;IAAG,GAAG,OAAO,WAAW;GAAE;GACzD,EAAE,OAAO,KAAc;EACzB;EAEA,gBACE,KACA;GACE,QAAQ;
|
|
1
|
+
{"version":3,"file":"pyramid.js","names":[],"sources":["../../../src/renderPptx/nodes/pyramid.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { stripHash } from \"../utils/visualStyle.ts\";\nimport { pxToIn } from \"../units.ts\";\nimport { measurePyramid } from \"../../calcYogaLayout/measureCompositeNodes.ts\";\nimport { resolveScaledContentArea } from \"../utils/scaleToFit.ts\";\nimport {\n addGlimpseShape,\n createShapeBoundsInput,\n noShapeOutline,\n solidShapeFill,\n} from \"../utils/glimpseShape.ts\";\nimport { addGlimpseTextBox } from \"../utils/glimpseTextBox.ts\";\n\ntype PyramidPositionedNode = Extract<PositionedNode, { type: \"pyramid\" }>;\n\nexport function renderPyramidNode(\n node: PyramidPositionedNode,\n ctx: RenderContext,\n): void {\n const direction = node.direction ?? \"up\";\n const levels = node.levels;\n const levelCount = levels.length;\n\n if (levelCount === 0) return;\n\n const defaultColor = \"4472C4\";\n const defaultTextColor = \"FFFFFF\";\n\n // スケール係数を計算(コンテンツ領域基準)\n const { content, scaleFactor } = resolveScaledContentArea(\n node,\n measurePyramid(node),\n ctx,\n );\n\n const baseWidth = 400 * scaleFactor;\n const layerHeight = 50 * scaleFactor;\n const gap = 2 * scaleFactor;\n\n const totalHeight = levelCount * layerHeight + (levelCount - 1) * gap;\n const startX = content.x + (content.w - baseWidth) / 2;\n const startY = content.y + (content.h - totalHeight) / 2;\n\n for (let i = 0; i < levelCount; i++) {\n const level = levels[i];\n const fillColor = stripHash(level.color) ?? defaultColor;\n const textColor = stripHash(level.textColor) ?? defaultTextColor;\n\n const layerY = startY + i * (layerHeight + gap);\n\n // direction=\"up\": i=0 が最上段(最も狭い=三角形)、i=levelCount-1 が最下段(最も広い)\n // direction=\"down\": i=0 が最上段(最も広い)、i=levelCount-1 が最下段(最も狭い=三角形)\n // 頂点層の上辺は幅0(三角形)、それ以外は台形\n let topWidthRatio: number;\n let bottomWidthRatio: number;\n\n if (direction === \"up\") {\n topWidthRatio = i / levelCount;\n bottomWidthRatio = (i + 1) / levelCount;\n } else {\n topWidthRatio = (levelCount - i) / levelCount;\n bottomWidthRatio = (levelCount - i - 1) / levelCount;\n }\n\n const topWidth = baseWidth * topWidthRatio;\n const bottomWidth = baseWidth * bottomWidthRatio;\n\n const topLeftX = startX + (baseWidth - topWidth) / 2;\n const topRightX = topLeftX + topWidth;\n const bottomLeftX = startX + (baseWidth - bottomWidth) / 2;\n const bottomRightX = bottomLeftX + bottomWidth;\n\n // custGeom のバウンディングボックス\n const bboxX = Math.min(topLeftX, bottomLeftX);\n const bboxW = Math.max(topRightX, bottomRightX) - bboxX;\n\n // points はバウンディングボックス内の相対インチ座標\n const points = [\n { x: pxToIn(topLeftX - bboxX), y: 0 },\n { x: pxToIn(topRightX - bboxX), y: 0 },\n { x: pxToIn(bottomRightX - bboxX), y: pxToIn(layerHeight) },\n { x: pxToIn(bottomLeftX - bboxX), y: pxToIn(layerHeight) },\n { close: true as const },\n ];\n\n addGlimpseShape(\n ctx,\n {\n geometry: { kind: \"preset\", preset: \"rect\" },\n ...createShapeBoundsInput({\n x: bboxX,\n y: layerY,\n w: bboxW,\n h: layerHeight,\n }),\n fill: solidShapeFill(fillColor),\n outline: noShapeOutline(),\n },\n { x: bboxX, y: layerY, w: bboxW, h: layerHeight },\n {\n fillColor,\n customGeometry: {\n width: pxToIn(bboxW),\n height: pxToIn(layerHeight),\n points,\n },\n },\n );\n\n // テキストを図形の中央に重ねて描画\n addGlimpseTextBox(\n ctx,\n {\n x: bboxX,\n y: layerY,\n w: bboxW,\n h: layerHeight,\n },\n {\n text: level.label,\n fontSize: (node.fontSize ?? 14) * scaleFactor,\n fontFace: node.fontFamily ?? \"Noto Sans JP\",\n color: textColor,\n bold: node.bold ?? false,\n align: \"center\",\n valign: \"middle\",\n autoFit: true,\n },\n );\n }\n}\n"],"mappings":";;;;;;;AAgBA,SAAgB,kBACd,MACA,KACM;CACN,MAAM,YAAY,KAAK,aAAa;CACpC,MAAM,SAAS,KAAK;CACpB,MAAM,aAAa,OAAO;CAE1B,IAAI,eAAe,GAAG;CAEtB,MAAM,eAAe;CACrB,MAAM,mBAAmB;CAGzB,MAAM,EAAE,SAAS,gBAAgB,yBAC/B,MACA,eAAe,IAAI,GACnB,GACF;CAEA,MAAM,YAAY,MAAM;CACxB,MAAM,cAAc,KAAK;CACzB,MAAM,MAAM,IAAI;CAEhB,MAAM,cAAc,aAAa,eAAe,aAAa,KAAK;CAClE,MAAM,SAAS,QAAQ,KAAK,QAAQ,IAAI,aAAa;CACrD,MAAM,SAAS,QAAQ,KAAK,QAAQ,IAAI,eAAe;CAEvD,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,KAAK;EACnC,MAAM,QAAQ,OAAO;EACrB,MAAM,YAAY,UAAU,MAAM,KAAK,KAAK;EAC5C,MAAM,YAAY,UAAU,MAAM,SAAS,KAAK;EAEhD,MAAM,SAAS,SAAS,KAAK,cAAc;EAK3C,IAAI;EACJ,IAAI;EAEJ,IAAI,cAAc,MAAM;GACtB,gBAAgB,IAAI;GACpB,oBAAoB,IAAI,KAAK;EAC/B,OAAO;GACL,iBAAiB,aAAa,KAAK;GACnC,oBAAoB,aAAa,IAAI,KAAK;EAC5C;EAEA,MAAM,WAAW,YAAY;EAC7B,MAAM,cAAc,YAAY;EAEhC,MAAM,WAAW,UAAU,YAAY,YAAY;EACnD,MAAM,YAAY,WAAW;EAC7B,MAAM,cAAc,UAAU,YAAY,eAAe;EACzD,MAAM,eAAe,cAAc;EAGnC,MAAM,QAAQ,KAAK,IAAI,UAAU,WAAW;EAC5C,MAAM,QAAQ,KAAK,IAAI,WAAW,YAAY,IAAI;EAGlD,MAAM,SAAS;GACb;IAAE,GAAG,OAAO,WAAW,KAAK;IAAG,GAAG;GAAE;GACpC;IAAE,GAAG,OAAO,YAAY,KAAK;IAAG,GAAG;GAAE;GACrC;IAAE,GAAG,OAAO,eAAe,KAAK;IAAG,GAAG,OAAO,WAAW;GAAE;GAC1D;IAAE,GAAG,OAAO,cAAc,KAAK;IAAG,GAAG,OAAO,WAAW;GAAE;GACzD,EAAE,OAAO,KAAc;EACzB;EAEA,gBACE,KACA;GACE,UAAU;IAAE,MAAM;IAAU,QAAQ;GAAO;GAC3C,GAAG,uBAAuB;IACxB,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;GACL,CAAC;GACD,MAAM,eAAe,SAAS;GAC9B,SAAS,eAAe;EAC1B,GACA;GAAE,GAAG;GAAO,GAAG;GAAQ,GAAG;GAAO,GAAG;EAAY,GAChD;GACE;GACA,gBAAgB;IACd,OAAO,OAAO,KAAK;IACnB,QAAQ,OAAO,WAAW;IAC1B;GACF;EACF,CACF;EAGA,kBACE,KACA;GACE,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;EACL,GACA;GACE,MAAM,MAAM;GACZ,WAAW,KAAK,YAAY,MAAM;GAClC,UAAU,KAAK,cAAc;GAC7B,OAAO;GACP,MAAM,KAAK,QAAQ;GACnB,OAAO;GACP,QAAQ;GACR,SAAS;EACX,CACF;CACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { pxToEmu, pxToPt } from "../units.js";
|
|
2
2
|
import { getContentArea } from "../utils/contentArea.js";
|
|
3
|
-
import { toColorInput } from "../
|
|
3
|
+
import { toColorInput } from "../pptxAuthoring.js";
|
|
4
4
|
import { addGlimpseShape, createShapeBoundsInput, createShapeRotationInput, noneShapeFill, shapeOutline, solidShapeFill } from "../utils/glimpseShape.js";
|
|
5
5
|
import { asEmu, asHundredthPt, asPt } from "@pptx-glimpse/document";
|
|
6
6
|
//#region src/renderPptx/nodes/shape.ts
|
|
@@ -65,7 +65,10 @@ function renderShapeNode(node, ctx) {
|
|
|
65
65
|
const boundsPx = getContentArea(node);
|
|
66
66
|
const fillOpacity = node.fill?.transparency !== void 0 ? 1 - node.fill.transparency / 100 : void 0;
|
|
67
67
|
addGlimpseShape(ctx, {
|
|
68
|
-
|
|
68
|
+
geometry: {
|
|
69
|
+
kind: "preset",
|
|
70
|
+
preset: node.shapeType
|
|
71
|
+
},
|
|
69
72
|
...createShapeBoundsInput(boundsPx),
|
|
70
73
|
rotation: createShapeRotationInput(node.rotate),
|
|
71
74
|
fill: node.fill?.color ? solidShapeFill(node.fill.color) : noneShapeFill(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shape.js","names":[],"sources":["../../../src/renderPptx/nodes/shape.ts"],"sourcesContent":["import {\n asEmu,\n asHundredthPt,\n asPt,\n type AddShapeParagraphInput,\n type AddShapeRunPropertiesInput,\n} from \"@pptx-glimpse/document\";\nimport type { BorderStyle, PositionedNode, Underline } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { pxToPt } from \"../units.ts\";\nimport { getContentArea } from \"../utils/contentArea.ts\";\nimport { pxToEmu } from \"../units.ts\";\nimport { toColorInput } from \"../
|
|
1
|
+
{"version":3,"file":"shape.js","names":[],"sources":["../../../src/renderPptx/nodes/shape.ts"],"sourcesContent":["import {\n asEmu,\n asHundredthPt,\n asPt,\n type AddShapeParagraphInput,\n type AddShapeRunPropertiesInput,\n} from \"@pptx-glimpse/document\";\nimport type { BorderStyle, PositionedNode, Underline } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { pxToPt } from \"../units.ts\";\nimport { getContentArea } from \"../utils/contentArea.ts\";\nimport { pxToEmu } from \"../units.ts\";\nimport { toColorInput } from \"../pptxAuthoring.ts\";\nimport {\n addGlimpseShape,\n createShapeBoundsInput,\n createShapeRotationInput,\n noneShapeFill,\n shapeOutline,\n solidShapeFill,\n} from \"../utils/glimpseShape.ts\";\n\ntype ShapePositionedNode = Extract<PositionedNode, { type: \"shape\" }>;\n\n/**\n * outline (Text と同じ書式の `outline.size` / `outline.color`) と\n * 既存 `line` 属性 (`line.color` / `line.width` / `line.dashType`) を\n * 1 つの BorderStyle にマージする。\n *\n * フィールド単位のマージで、`outline` の指定があるフィールドは `line` を\n * 上書きするが、`outline` 側で省略されたフィールドは `line` の値を引き継ぎ、\n * `line` にも値が無い場合は Text outline と同じ既定値 (`width: 1pt 相当` /\n * `color: FFFFFF`) を採用する。`dashType` は `outline` に対応フィールドが\n * 無いため `line.dashType` をそのまま使う。\n */\nfunction resolveShapeLine(\n line: BorderStyle | undefined,\n outline: { size?: number; color?: string } | undefined,\n): BorderStyle | undefined {\n if (!outline) return line;\n return {\n color: outline.color ?? line?.color ?? \"FFFFFF\",\n width: outline.size ?? line?.width ?? 1,\n dashType: line?.dashType,\n };\n}\n\nfunction toUnderlineInput(underline: Underline | undefined) {\n if (underline === undefined || underline === false) return undefined;\n if (underline === true) return true;\n return {\n style: underline.style,\n color: toColorInput(underline.color),\n };\n}\n\nfunction buildShapeTextProperties(\n node: ShapePositionedNode,\n): AddShapeRunPropertiesInput {\n return {\n fontFace: node.fontFamily ?? \"Noto Sans JP\",\n fontSize: asPt(pxToPt(node.fontSize ?? 24)),\n color: toColorInput(node.color),\n bold: node.bold,\n italic: node.italic,\n underline: toUnderlineInput(node.underline),\n strike: node.strike,\n baseline: node.subscript\n ? \"subscript\"\n : node.superscript\n ? \"superscript\"\n : undefined,\n highlight: toColorInput(node.highlight),\n };\n}\n\nfunction buildShapeParagraphs(\n node: ShapePositionedNode,\n): AddShapeParagraphInput[] | undefined {\n if (!node.text) return undefined;\n const fontSizePx = node.fontSize ?? 24;\n const lineHeight = node.lineHeight ?? 1.3;\n const properties = buildShapeTextProperties(node);\n return node.text\n .replace(/\\r*\\n/g, \"\\n\")\n .split(\"\\n\")\n .map((text) => ({\n properties: {\n align: node.textAlign ?? \"center\",\n lineSpacing: asHundredthPt(\n Math.round(pxToPt(fontSizePx * lineHeight) * 100),\n ),\n },\n runs: [{ text, properties }],\n }));\n}\n\nexport function renderShapeNode(\n node: ShapePositionedNode,\n ctx: RenderContext,\n): void {\n const lineSpec = resolveShapeLine(node.line, node.outline);\n const boundsPx = getContentArea(node);\n const fillOpacity =\n node.fill?.transparency !== undefined\n ? 1 - node.fill.transparency / 100\n : undefined;\n\n addGlimpseShape(\n ctx,\n {\n geometry: { kind: \"preset\", preset: node.shapeType },\n ...createShapeBoundsInput(boundsPx),\n rotation: createShapeRotationInput(node.rotate),\n fill: node.fill?.color\n ? solidShapeFill(node.fill.color)\n : noneShapeFill(),\n outline: shapeOutline(lineSpec),\n effects: node.glow\n ? {\n glow: {\n radius: asEmu(Math.round(pxToEmu(node.glow.size ?? 8))),\n color: toColorInput(node.glow.color ?? \"FFFFFF\")!,\n },\n }\n : undefined,\n body: node.text\n ? {\n anchor: \"middle\",\n }\n : undefined,\n paragraphs: buildShapeParagraphs(node),\n },\n boundsPx,\n {\n fillColor: node.fill?.color,\n fillOpacity,\n glow: node.glow,\n shadow: node.shadow,\n dashType: lineSpec?.dashType,\n },\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAmCA,SAAS,iBACP,MACA,SACyB;CACzB,IAAI,CAAC,SAAS,OAAO;CACrB,OAAO;EACL,OAAO,QAAQ,SAAS,MAAM,SAAS;EACvC,OAAO,QAAQ,QAAQ,MAAM,SAAS;EACtC,UAAU,MAAM;CAClB;AACF;AAEA,SAAS,iBAAiB,WAAkC;CAC1D,IAAI,cAAc,KAAA,KAAa,cAAc,OAAO,OAAO,KAAA;CAC3D,IAAI,cA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AC9B,SAAS,KAAK,OACV,EACE,MAAM;GACJ,QAAQ,MAAM,KAAK,MAAM,QAAQ,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC;GACtD,OAAO,aAAa,KAAK,KAAK,SAAS,QAAQ;EACjD,EACF,IACA,KAAA;EACJ,MAAM,KAAK,OACP,EACE,QAAQ,SACV,IACA,KAAA;EACJ,YAAY,qBAAqB,IAAI;CACvC,GACA,UACA;EACE,WAAW,KAAK,MAAM;EACtB;EACA,MAAM,KAAK;EACX,QAAQ,KAAK;EACb,UAAU,UAAU;CACtB,CACF;AACF"}
|
|
@@ -1,72 +1,102 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { pxToEmu, pxToPt } from "../units.js";
|
|
2
2
|
import { getContentArea } from "../utils/contentArea.js";
|
|
3
|
-
import {
|
|
3
|
+
import { resolveSubSup } from "../textOptions.js";
|
|
4
|
+
import { cleanHex, toColorInput } from "../pptxAuthoring.js";
|
|
4
5
|
import { resolveColumnWidths, resolveRowHeights } from "../../shared/tableUtils.js";
|
|
6
|
+
import { asEmu, asOoxmlPercent, asPt } from "@pptx-glimpse/document";
|
|
5
7
|
//#region src/renderPptx/nodes/table.ts
|
|
6
8
|
function renderTableNode(node, ctx) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
italic: run.italic ?? cell.italic,
|
|
36
|
-
underline: convertUnderline(run.underline ?? cell.underline),
|
|
37
|
-
strike: convertStrike(run.strike ?? cell.strike),
|
|
38
|
-
subscript: runSubSup.subscript,
|
|
39
|
-
superscript: runSubSup.superscript,
|
|
40
|
-
highlight: run.highlight ?? cell.highlight,
|
|
41
|
-
...run.href ? { hyperlink: { url: run.href } } : {}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
}),
|
|
45
|
-
options: {
|
|
9
|
+
const content = getContentArea(node);
|
|
10
|
+
const rowHeights = resolveRowHeights(node);
|
|
11
|
+
const border = node.cellBorder ? {
|
|
12
|
+
width: asEmu(Math.round(pxToEmu(node.cellBorder.width ?? 1 / .75))),
|
|
13
|
+
color: cleanHex(node.cellBorder.color) ?? "000000",
|
|
14
|
+
dash: toTableDash(node.cellBorder.dashType)
|
|
15
|
+
} : void 0;
|
|
16
|
+
ctx.buildContext.pptxAuthoring.registerTable({
|
|
17
|
+
offsetX: asEmu(Math.round(pxToEmu(content.x))),
|
|
18
|
+
offsetY: asEmu(Math.round(pxToEmu(content.y))),
|
|
19
|
+
width: asEmu(Math.round(pxToEmu(Math.max(content.w, 1)))),
|
|
20
|
+
height: asEmu(Math.round(pxToEmu(Math.max(content.h, 1)))),
|
|
21
|
+
columnWidths: resolveColumnWidths(node, content.w).map((width) => asEmu(Math.round(pxToEmu(Math.max(width, 1))))),
|
|
22
|
+
rows: buildTableRows(node, rowHeights, border)
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function buildTableRows(node, rowHeights, border) {
|
|
26
|
+
const columnCount = node.columns.length;
|
|
27
|
+
const continuationCells = /* @__PURE__ */ new Set();
|
|
28
|
+
return node.rows.map((row, rowIndex) => {
|
|
29
|
+
const cells = Array.from({ length: columnCount });
|
|
30
|
+
for (let columnIndex = 0; columnIndex < columnCount; columnIndex += 1) if (continuationCells.has(`${rowIndex}:${columnIndex}`)) cells[columnIndex] = {};
|
|
31
|
+
let columnIndex = 0;
|
|
32
|
+
for (const cell of row.cells) {
|
|
33
|
+
while (cells[columnIndex] !== void 0) columnIndex += 1;
|
|
34
|
+
cells[columnIndex] = {
|
|
35
|
+
runs: buildTableRuns(cell),
|
|
36
|
+
fill: cleanHex(cell.backgroundColor),
|
|
46
37
|
align: cell.textAlign ?? "left",
|
|
47
|
-
|
|
38
|
+
marginLeft: asEmu(0),
|
|
39
|
+
marginRight: asEmu(0),
|
|
40
|
+
marginTop: asEmu(0),
|
|
41
|
+
marginBottom: asEmu(0),
|
|
42
|
+
borders: border ? {
|
|
43
|
+
top: border,
|
|
44
|
+
right: border,
|
|
45
|
+
bottom: border,
|
|
46
|
+
left: border
|
|
47
|
+
} : void 0,
|
|
48
48
|
colspan: cell.colspan,
|
|
49
49
|
rowspan: cell.rowspan
|
|
50
|
+
};
|
|
51
|
+
const colspan = cell.colspan ?? 1;
|
|
52
|
+
const rowspan = cell.rowspan ?? 1;
|
|
53
|
+
for (let y = rowIndex; y < rowIndex + rowspan; y += 1) for (let x = columnIndex; x < columnIndex + colspan; x += 1) {
|
|
54
|
+
if (x === columnIndex && y === rowIndex) continue;
|
|
55
|
+
continuationCells.add(`${y}:${x}`);
|
|
56
|
+
if (y === rowIndex) cells[x] = {};
|
|
50
57
|
}
|
|
51
|
-
|
|
58
|
+
columnIndex += colspan;
|
|
59
|
+
}
|
|
60
|
+
for (let index = 0; index < cells.length; index += 1) if (cells[index] === void 0) cells[index] = {};
|
|
52
61
|
return {
|
|
53
|
-
|
|
54
|
-
|
|
62
|
+
height: asEmu(Math.round(pxToEmu(Math.max(rowHeights[rowIndex] ?? 0, 1)))),
|
|
63
|
+
cells
|
|
55
64
|
};
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function buildTableRuns(cell) {
|
|
68
|
+
return (cell.runs?.length ? cell.runs : [{ text: cell.text }]).flatMap((run) => {
|
|
69
|
+
const underline = run.underline ?? cell.underline;
|
|
70
|
+
const subSup = resolveSubSup(run, cell);
|
|
71
|
+
const properties = {
|
|
72
|
+
fontSize: asPt(pxToPt(run.fontSize ?? cell.fontSize ?? 18)),
|
|
73
|
+
fontFace: run.fontFamily ?? cell.fontFamily,
|
|
74
|
+
color: cleanHex(run.color ?? cell.color),
|
|
75
|
+
bold: run.bold ?? cell.bold,
|
|
76
|
+
italic: run.italic ?? cell.italic,
|
|
77
|
+
underline: typeof underline === "object" ? {
|
|
78
|
+
style: underline.style,
|
|
79
|
+
color: toColorInput(underline.color)
|
|
80
|
+
} : Boolean(underline),
|
|
81
|
+
strike: run.strike ?? cell.strike,
|
|
82
|
+
baseline: subSup.subscript ? {
|
|
83
|
+
type: "percent",
|
|
84
|
+
value: asOoxmlPercent(-4e4)
|
|
85
|
+
} : subSup.superscript ? {
|
|
86
|
+
type: "percent",
|
|
87
|
+
value: asOoxmlPercent(3e4)
|
|
88
|
+
} : void 0,
|
|
89
|
+
highlight: toColorInput(run.highlight ?? cell.highlight)
|
|
90
|
+
};
|
|
91
|
+
return run.text.replace(/\r*\n/g, "\n").split("\n").map((line, index) => ({
|
|
92
|
+
text: index === 0 ? line : `\n${line}`,
|
|
93
|
+
properties,
|
|
94
|
+
hyperlink: run.href
|
|
95
|
+
}));
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function toTableDash(dash) {
|
|
99
|
+
return dash;
|
|
70
100
|
}
|
|
71
101
|
//#endregion
|
|
72
102
|
export { renderTableNode };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","names":[],"sources":["../../../src/renderPptx/nodes/table.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport {\n resolveColumnWidths,\n resolveRowHeights,\n} from \"../../shared/tableUtils.ts\";\nimport {
|
|
1
|
+
{"version":3,"file":"table.js","names":[],"sources":["../../../src/renderPptx/nodes/table.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport {\n resolveColumnWidths,\n resolveRowHeights,\n} from \"../../shared/tableUtils.ts\";\nimport {\n asEmu,\n asOoxmlPercent,\n asPt,\n type AddTableCellInput,\n type AddTableRowInput,\n type AddTableRunInput,\n type SourceDashStyle,\n} from \"@pptx-glimpse/document\";\nimport { pxToEmu, pxToPt } from \"../units.ts\";\nimport { getContentArea } from \"../utils/contentArea.ts\";\nimport { cleanHex, toColorInput } from \"../pptxAuthoring.ts\";\nimport { resolveSubSup } from \"../textOptions.ts\";\n\ntype TablePositionedNode = Extract<PositionedNode, { type: \"table\" }>;\n\nexport function renderTableNode(\n node: TablePositionedNode,\n ctx: RenderContext,\n): void {\n const content = getContentArea(node);\n const rowHeights = resolveRowHeights(node);\n const border = node.cellBorder\n ? {\n width: asEmu(Math.round(pxToEmu(node.cellBorder.width ?? 1 / 0.75))),\n color: cleanHex(node.cellBorder.color) ?? \"000000\",\n dash: toTableDash(node.cellBorder.dashType),\n }\n : undefined;\n ctx.buildContext.pptxAuthoring.registerTable({\n offsetX: asEmu(Math.round(pxToEmu(content.x))),\n offsetY: asEmu(Math.round(pxToEmu(content.y))),\n width: asEmu(Math.round(pxToEmu(Math.max(content.w, 1)))),\n height: asEmu(Math.round(pxToEmu(Math.max(content.h, 1)))),\n columnWidths: resolveColumnWidths(node, content.w).map((width) =>\n asEmu(Math.round(pxToEmu(Math.max(width, 1)))),\n ),\n rows: buildTableRows(node, rowHeights, border),\n });\n}\n\nfunction buildTableRows(\n node: TablePositionedNode,\n rowHeights: number[],\n border:\n | {\n width: ReturnType<typeof asEmu>;\n color: string;\n dash: SourceDashStyle | undefined;\n }\n | undefined,\n): AddTableRowInput[] {\n const columnCount = node.columns.length;\n const continuationCells = new Set<string>();\n return node.rows.map((row, rowIndex) => {\n const cells: AddTableCellInput[] = Array.from({ length: columnCount });\n for (let columnIndex = 0; columnIndex < columnCount; columnIndex += 1) {\n if (continuationCells.has(`${rowIndex}:${columnIndex}`)) {\n cells[columnIndex] = {};\n }\n }\n\n let columnIndex = 0;\n for (const cell of row.cells) {\n while (cells[columnIndex] !== undefined) columnIndex += 1;\n cells[columnIndex] = {\n runs: buildTableRuns(cell),\n fill: cleanHex(cell.backgroundColor),\n align: cell.textAlign ?? \"left\",\n marginLeft: asEmu(0),\n marginRight: asEmu(0),\n marginTop: asEmu(0),\n marginBottom: asEmu(0),\n borders: border\n ? { top: border, right: border, bottom: border, left: border }\n : undefined,\n colspan: cell.colspan,\n rowspan: cell.rowspan,\n };\n const colspan = cell.colspan ?? 1;\n const rowspan = cell.rowspan ?? 1;\n for (let y = rowIndex; y < rowIndex + rowspan; y += 1) {\n for (let x = columnIndex; x < columnIndex + colspan; x += 1) {\n if (x === columnIndex && y === rowIndex) continue;\n continuationCells.add(`${y}:${x}`);\n if (y === rowIndex) cells[x] = {};\n }\n }\n columnIndex += colspan;\n }\n\n for (let index = 0; index < cells.length; index += 1) {\n if (cells[index] === undefined) cells[index] = {};\n }\n return {\n height: asEmu(\n Math.round(pxToEmu(Math.max(rowHeights[rowIndex] ?? 0, 1))),\n ),\n cells,\n };\n });\n}\n\nfunction buildTableRuns(\n cell: TablePositionedNode[\"rows\"][number][\"cells\"][number],\n): AddTableRunInput[] {\n const runs = cell.runs?.length ? cell.runs : [{ text: cell.text }];\n return runs.flatMap((run) => {\n const underline = run.underline ?? cell.underline;\n const subSup = resolveSubSup(run, cell);\n const properties = {\n fontSize: asPt(pxToPt(run.fontSize ?? cell.fontSize ?? 18)),\n fontFace: run.fontFamily ?? cell.fontFamily,\n color: cleanHex(run.color ?? cell.color),\n bold: run.bold ?? cell.bold,\n italic: run.italic ?? cell.italic,\n underline:\n typeof underline === \"object\"\n ? {\n style: underline.style,\n color: toColorInput(underline.color),\n }\n : Boolean(underline),\n strike: run.strike ?? cell.strike,\n baseline: subSup.subscript\n ? { type: \"percent\" as const, value: asOoxmlPercent(-40000) }\n : subSup.superscript\n ? { type: \"percent\" as const, value: asOoxmlPercent(30000) }\n : undefined,\n highlight: toColorInput(run.highlight ?? cell.highlight),\n };\n const lines = run.text.replace(/\\r*\\n/g, \"\\n\").split(\"\\n\");\n return lines.map((line, index) => ({\n text: index === 0 ? line : `\\n${line}`,\n properties,\n hyperlink: run.href,\n }));\n });\n}\n\nfunction toTableDash(\n dash: NonNullable<TablePositionedNode[\"cellBorder\"]>[\"dashType\"],\n): SourceDashStyle | undefined {\n return dash;\n}\n"],"mappings":";;;;;;;AAsBA,SAAgB,gBACd,MACA,KACM;CACN,MAAM,UAAU,eAAe,IAAI;CACnC,MAAM,aAAa,kBAAkB,IAAI;CACzC,MAAM,SAAS,KAAK,aAChB;EACE,OAAO,MAAM,KAAK,MAAM,QAAQ,KAAK,WAAW,SAAS,IAAI,GAAI,CAAC,CAAC;EACnE,OAAO,SAAS,KAAK,WAAW,KAAK,KAAK;EAC1C,MAAM,YAAY,KAAK,WAAW,QAAQ;CAC5C,IACA,KAAA;CACJ,IAAI,aAAa,cAAc,cAAc;EAC3C,SAAS,MAAM,KAAK,MAAM,QAAQ,QAAQ,CAAC,CAAC,CAAC;EAC7C,SAAS,MAAM,KAAK,MAAM,QAAQ,QAAQ,CAAC,CAAC,CAAC;EAC7C,OAAO,MAAM,KAAK,MAAM,QAAQ,KAAK,IAAI,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;EACxD,QAAQ,MAAM,KAAK,MAAM,QAAQ,KAAK,IAAI,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;EACzD,cAAc,oBAAoB,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAK,UACtD,MAAM,KAAK,MAAM,QAAQ,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAC/C;EACA,MAAM,eAAe,MAAM,YAAY,MAAM;CAC/C,CAAC;AACH;AAEA,SAAS,eACP,MACA,YACA,QAOoB;CACpB,MAAM,cAAc,KAAK,QAAQ;CACjC,MAAM,oCAAoB,IAAI,IAAY;CAC1C,OA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a,KAAK,MAAM,SAAS,KAAK,OAAO,CAAC,EAAE,MAAM,KAAK,KAAK,CAAC,EAAA,CACrD,SAAS,QAAQ;EAC3B,MAAM,YAAY,IAAI,aAAa,KAAK;EACxC,MAAM,SAAS,cAAc,KAAK,IAAI;EACtC,MAAM,aAAa;GACjB,UAAU,KAAK,OAAO,IAAI,YAAY,KAAK,YAAY,EAAE,CAAC;GAC1D,UAAU,IAAI,cAAc,KAAK;GACjC,OAAO,SAAS,IAAI,SAAS,KAAK,KAAK;GACvC,MAAM,IAAI,QAAQ,KAAK;GACvB,QAAQ,IAAI,UAAU,KAAK;GAC3B,WACE,OAAO,cAAc,WACjB;IACE,OAAO,UAAU;IACjB,OAAO,aAAa,UAAU,KAAK;GACrC,IACA,QAAQ,SAAS;GACvB,QAAQ,IAAI,UAAU,KAAK;GAC3B,UAAU,OAAO,YACb;IAAE,MAAM;IAAoB,OAAO,eAAe,IAAM;GAAE,IAC1D,OAAO,cACL;IAAE,MAAM;IAAoB,OAAO,eAAe,GAAK;GAAE,IACzD,KAAA;GACN,WAAW,aAAa,IAAI,aAAa,KAAK,SAAS;EACzD;EAEA,OADc,IAAI,KAAK,QAAQ,UAAU,IAAI,CAAC,CAAC,MAAM,IAC1C,CAAC,CAAC,KAAK,MAAM,WAAW;GACjC,MAAM,UAAU,IAAI,OAAO,KAAK;GAChC;GACA,WAAW,IAAI;EACjB,EAAE;CACJ,CAAC;AACH;AAEA,SAAS,YACP,MAC6B;CAC7B,OAAO;AACT"}
|
|
@@ -1,23 +1,6 @@
|
|
|
1
|
-
import { createTextOptions } from "../textOptions.js";
|
|
2
1
|
//#region src/renderPptx/nodes/text.ts
|
|
3
2
|
function renderTextNode(node, ctx) {
|
|
4
|
-
|
|
5
|
-
const marker = ctx.buildContext.glimpseTextBoxes.register(node);
|
|
6
|
-
ctx.slide.addShape(ctx.pptx.ShapeType.rect, {
|
|
7
|
-
x: textOptions.x,
|
|
8
|
-
y: textOptions.y,
|
|
9
|
-
w: textOptions.w,
|
|
10
|
-
h: textOptions.h,
|
|
11
|
-
fill: {
|
|
12
|
-
color: "FFFFFF",
|
|
13
|
-
transparency: 100
|
|
14
|
-
},
|
|
15
|
-
line: {
|
|
16
|
-
color: "FFFFFF",
|
|
17
|
-
transparency: 100
|
|
18
|
-
},
|
|
19
|
-
objectName: marker
|
|
20
|
-
});
|
|
3
|
+
ctx.buildContext.pptxAuthoring.register(node);
|
|
21
4
|
}
|
|
22
5
|
//#endregion
|
|
23
6
|
export { renderTextNode };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","names":[],"sources":["../../../src/renderPptx/nodes/text.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\
|
|
1
|
+
{"version":3,"file":"text.js","names":[],"sources":["../../../src/renderPptx/nodes/text.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\n\ntype TextPositionedNode = Extract<PositionedNode, { type: \"text\" }>;\n\nexport function renderTextNode(\n node: TextPositionedNode,\n ctx: RenderContext,\n): void {\n ctx.buildContext.pptxAuthoring.register(node);\n}\n"],"mappings":";AAKA,SAAgB,eACd,MACA,KACM;CACN,IAAI,aAAa,cAAc,SAAS,IAAI;AAC9C"}
|