AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He
refactor(svg): make viewBox the single source of truth for canvas size
hugohe30ebb54c7a0e0
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.mdindex 8714ebd6..40fc20ac 100644--- a/skills/ppt-master/references/shared-standards.md+++ b/skills/ppt-master/references/shared-standards.md@@ -169,7 +169,7 @@ One offending character invalidates the file and aborts export. Numeric refs (`&## 4. Basic SVG Rules-- **viewBox** must match the canvas dimensions (`width`/`height` must match `viewBox`)+- **viewBox** MUST match the canvas dimensions; it is the single source of truth for canvas size. Root `width`/`height` are optional — if written, they MUST equal `viewBox`- **Background**: Use `<rect>` to define the page background color- **`<tspan>`** has two purposes: (1) manual line breaks (use `dy` or explicit `y`); (2) inline run formatting on the same line (color/weight/size). `<foreignObject>` is FORBIDDEN. See "Single logical line" rule below.- **Fonts**: every `font-family` stack MUST end with a pre-installed family (Microsoft YaHei / SimSun / Arial / Times New Roman / Consolas …); `@font-face` is FORBIDDEN. Full rule: [`strategist.md §g`](strategist.md).diff --git a/skills/ppt-master/references/template-designer.md b/skills/ppt-master/references/template-designer.mdindex 37b88825..248fd7f7 100644--- a/skills/ppt-master/references/template-designer.md+++ b/skills/ppt-master/references/template-designer.md@@ -194,7 +194,7 @@ When rewriting an existing template that contains the omitted sections, delete t### 2. Inherit Design SpecificationTemplates must strictly follow the finalized template brief and the generated `design_spec.md`:-- **Canvas dimensions**: `canvas_format` is not enough; root SVG `width` / `height` / `viewBox` match `canvas_width`, `canvas_height`, and `canvas_viewbox` in the design spec+- **Canvas dimensions**: `canvas_format` is not enough; root SVG `viewBox` matches `canvas_viewbox` in the design spec (`width` / `height`, if written, equal it)- **Source canvas**: when a PPTX/SVG reference is used, record `source_canvas_width`, `source_canvas_height`, and `source_viewbox`. If the output canvas differs from the source, normalize all geometry, typography, line heights, strokes, and image crop coordinates explicitly instead of relying on the shared aspect ratio.- **Color scheme**: Uses primary, secondary, and accent colors from the spec- **Font plan**: Uses the per-role font families declared in the specdiff --git a/skills/ppt-master/scripts/svg_editor/static/app.js b/skills/ppt-master/scripts/svg_editor/static/app.jsindex 40c8763f..745221d7 100644--- a/skills/ppt-master/scripts/svg_editor/static/app.js+++ b/skills/ppt-master/scripts/svg_editor/static/app.js@@ -62,7 +62,6 @@overlap_caption: "Overlapping here — pick one",err_empty_svg: "Slide loaded but the canvas is empty. The SVG may be malformed or missing a root <svg> element.",warn_icon_inline: "{count} icon(s) failed to render: {names}",- warn_svg_no_dims: "SVG is missing width/height attributes. Please ask the AI to strictly follow shared-standards.md §4 and include width & height in the SVG root element.",warn_matrix_transform: "This geometry edit is stored as a transform matrix. Preview is exact; PPTX export depends on matrix-aware conversion.",modal_matrix_transform_note: "\n\nNote: at least one staged geometry edit uses a transform matrix. Re-export with the current PPTX exporter so the matrix is applied.",slide_error_tooltip: "Failed to parse this slide: ",@@ -138,7 +137,6 @@overlap_caption: "要素が重なっています — 1つ選択してください",err_empty_svg: "スライドは読み込めましたがキャンバスが空です。SVGが不正か、ルート<svg>要素がない可能性があります。",warn_icon_inline: "{count}個のアイコンを描画できませんでした: {names}",- warn_svg_no_dims: "SVGにwidth/height属性がありません。shared-standards.md §4に厳密に従い、SVGルート要素にwidthとheightを含めるようAIに依頼してください。",warn_matrix_transform: "このジオメトリ編集は transform matrix として保存されます。プレビューは正確ですが、PPTX出力にはmatrix対応の現行エクスポーターが必要です。",modal_matrix_transform_note: "\n\n注意:一時保存済みのジオメトリ編集に transform matrix を使うものがあります。matrixが反映されるよう、現行のPPTXエクスポーターで再エクスポートしてください。",slide_error_tooltip: "このスライドの解析に失敗: ",@@ -214,7 +212,6 @@overlap_caption: "此处重叠元素——点击选择",err_empty_svg: "幻灯片已加载但画布为空。SVG 可能损坏或缺少根 <svg> 元素。",warn_icon_inline: "{count} 个图标渲染失败:{names}",- warn_svg_no_dims: "SVG 缺少 width/height 属性,预览可能异常。请让 AI 严格遵守 shared-standards.md §4 规范,在 SVG 根元素中补全 width 和 height。",warn_matrix_transform: "本次几何修改会以 transform matrix 保存。预览是准确的;PPTX 导出需要使用支持 matrix 的当前导出器。",modal_matrix_transform_note: "\n\n提示:至少有一条暂存几何修改使用了 transform matrix。请用当前 PPTX 导出器重新导出,确保 matrix 被应用。",slide_error_tooltip: "该幻灯片解析失败:",@@ -599,10 +596,6 @@// Selecting a slide implicitly dismisses any stale "page updated" banner.hideReloadBanner();- // Remove any stale spec-violation banner from a previous load.- var oldSpecBanner = document.getElementById("spec-banner");- if (oldSpecBanner) oldSpecBanner.remove();-fetch("/api/slide/" + encodeURIComponent(name)).then(function (res) { return res.json(); }).then(function (data) {@@ -625,16 +618,15 @@// Empty-canvas guard: surface a clear error if the SVG parsed// to nothing renderable (issue #115's silent-blank scenario).var rootSvg = svgContent.querySelector("svg");- // Spec observability: missing width/height → red banner only+ // The width/height:auto preview CSS collapses without the root+ // attributes (issue #115); derive them from viewBox at render+ // time. View-layer only — the file on disk is never touched.if (rootSvg && (!rootSvg.hasAttribute("width") || !rootSvg.hasAttribute("height"))) {- var specBanner = document.createElement("div");- specBanner.id = "spec-banner";- specBanner.style.cssText = "position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);"- + "background:#fee2e2;color:#b91c1c;border:2px solid #f87171;border-radius:8px;"- + "padding:24px 36px;font-size:16px;font-weight:bold;text-align:center;z-index:9999;"- + "width:420px;line-height:1.6;box-shadow:0 4px 12px rgba(0,0,0,0.15);";- specBanner.textContent = t("warn_svg_no_dims");- document.body.appendChild(specBanner);+ var vb = (rootSvg.getAttribute("viewBox") || "").trim().split(/[\s,]+/);+ if (vb.length === 4 && parseFloat(vb[2]) > 0 && parseFloat(vb[3]) > 0) {+ if (!rootSvg.hasAttribute("width")) rootSvg.setAttribute("width", vb[2]);+ if (!rootSvg.hasAttribute("height")) rootSvg.setAttribute("height", vb[3]);+ }}var hasContent = false;if (rootSvg) {diff --git a/skills/ppt-master/scripts/svg_quality_checker.py b/skills/ppt-master/scripts/svg_quality_checker.pyindex fa65a231..90a36ff7 100644--- a/skills/ppt-master/scripts/svg_quality_checker.py+++ b/skills/ppt-master/scripts/svg_quality_checker.py@@ -297,31 +297,28 @@ class SVGQualityChecker:# 4. Check fontsself._check_fonts(content, result)- # 5. Check width/height consistency with viewBox- self._check_dimensions(content, result)-- # 6. Check text wrapping methods+ # 5. Check text wrapping methodsself._check_text_elements(content, result)- # 7. Check image references (file existence and resolution)+ # 6. Check image references (file existence and resolution)self._check_image_references(content, svg_path, result)- # 8. Check object-level animation anchor quality.+ # 7. Check object-level animation anchor quality.self._check_animation_group_ids(content, result)- # 8b. Check <pattern> elements declare a PPTX preset.+ # 7b. Check <pattern> elements declare a PPTX preset.self._check_pattern_fills(content, result)- # 8c. Check opt-in native table/chart markers before export.+ # 7c. Check opt-in native table/chart markers before export.self._check_native_object_markers(content, result)- # 9. Check spec_lock drift (colors / font-family / font-size).+ # 8. Check spec_lock drift (colors / font-family / font-size).# Templates do not ship a spec_lock.md, so skip in template# mode to avoid noise.if not self.template_mode:self._check_spec_lock_drift(content, svg_path, result)- # 10. Check web-sourced image attribution. Templates don't carry+ # 9. Check web-sourced image attribution. Templates don't carry# image_sources.json; skip in template mode.if not self.template_mode:self._check_sourced_image_attribution(content, svg_path, result)@@ -566,27 +563,6 @@ class SVGQualityChecker:)break- def _check_dimensions(self, content: str, result: Dict):- """Check width/height consistency with viewBox"""- width_match = re.search(r'width="(\d+)"', content)- height_match = re.search(r'height="(\d+)"', content)-- if width_match and height_match:- width = width_match.group(1)- height = height_match.group(1)- result['info']['dimensions'] = f"{width}x{height}"-- # Check consistency with viewBox- if 'viewbox' in result['info']:- viewbox_parts = result['info']['viewbox'].split()- if len(viewbox_parts) == 4:- vb_width, vb_height = viewbox_parts[2], viewbox_parts[3]- if width != vb_width or height != vb_height:- result['warnings'].append(- f"width/height ({width}x{height}) does not match viewBox "- f"({vb_width}x{vb_height})"- )-def _check_text_elements(self, content: str, result: Dict):"""Check text elements and wrapping methods"""# Count text and tspan elementsdiff --git a/skills/ppt-master/workflows/create-template.md b/skills/ppt-master/workflows/create-template.mdindex a84dfb19..1f49d867 100644--- a/skills/ppt-master/workflows/create-template.md+++ b/skills/ppt-master/workflows/create-template.md@@ -351,7 +351,7 @@ python3 skills/ppt-master/scripts/svg_quality_checker.py "skills/ppt-master/temp- [ ] Variant filenames follow the letter-suffix convention (e.g. `03a_content_two_col.svg`); variants typically reuse the parent type's placeholder set unless the spec frontmatter declares otherwise- [ ] If TOC exists, placeholder pattern uses the canonical indexed form- [ ] `design_spec.md` frontmatter declares `canvas_format`, `canvas_width`, `canvas_height`, and `canvas_viewbox`; PPTX/SVG-backed templates also declare `source_canvas_width`, `source_canvas_height`, and `source_viewbox`-- [ ] SVG `width` / `height` / `viewBox` match the declared canvas dimensions, not just the aspect ratio (for `ppt169`: `1280x720`, `0 0 1280 720`; for `banner`: `1920x1080`, `0 0 1920 1080`)+- [ ] SVG `viewBox` matches the declared canvas dimensions, not just the aspect ratio (for `ppt169`: `0 0 1280 720`; for `banner`: `0 0 1920 1080`); `width` / `height`, if written, equal it- [ ] Placeholder names follow the canonical convention where applicable; templates with intentionally different vocabularies (e.g. `{{KEY_MESSAGE}}` instead of `{{PAGE_TITLE}}`) should declare a `placeholders:` frontmatter block to silence advisory warnings- [ ] Asset files referenced by SVGs actually exist in the template package- [ ] If any SVG references an extracted vector `data-icon`, the corresponding SVG asset exists directly under the package's `icons/` directory; do not add a separate illustration embedding script