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
feat(live-preview): expose text styles for textboxes
hugohe32e144fa54487
diff --git a/skills/ppt-master/scripts/svg_editor/static/app.js b/skills/ppt-master/scripts/svg_editor/static/app.jsindex a5c0e2a3..2796611b 100644--- a/skills/ppt-master/scripts/svg_editor/static/app.js+++ b/skills/ppt-master/scripts/svg_editor/static/app.js@@ -1783,18 +1783,28 @@} catch (e) { /* no geometry */ }html += '</table>';- // L1: text content — only when the element owns no <tspan> children.- if (tag === "text" || tag === "tspan") {+ var textStyleTargets = textStyleTargetsForSelection(el);++ // L1: text content + computed text styles. When a textbox/group is+ // selected, style controls target its descendant text leaves.+ if (tag === "text" || tag === "tspan" || textStyleTargets.length > 0) {html += '<div class="prop-section">' + escapeHtml(t("section_text_style")) + '</div>';html += '<table class="prop-table">';- if (el.querySelector("tspan")) {+ if ((tag === "text" || tag === "tspan") && el.querySelector("tspan")) {html += '<tr><td class="prop-key">content</td><td class="prop-val prop-note">' +escapeHtml(t("prop_multiline_hint")) + '</td></tr>';- } else {+ } else if (tag === "text" || tag === "tspan") {html += '<tr><td class="prop-key">content</td><td class="prop-val">' +'<textarea class="prop-edit prop-edit-content" rows="2">' +escapeHtml(el.textContent || "") + '</textarea></td></tr>';}+ if (textStyleTargets.length > 0) {+ textStyleSpecs(textStyleTargets).forEach(function (spec) {+ html += '<tr><td class="prop-key">' + escapeHtml(spec.key) + '</td><td class="prop-val">';+ html += renderTextStyleControl(spec, textStyleTargets);+ html += '</td></tr>';+ });+ }html += '</table>';}@@ -1844,6 +1854,88 @@return /^[A-Za-z_][A-Za-z0-9_.:-]*$/.test(key);}+ function textStyleTargetsForSelection(el) {+ if (!el) return [];+ var tag = localName(el);+ if (tag === "tspan") return el.id ? [el] : [];+ if (tag === "text") return textStyleLeavesForText(el);++ var targets = [];+ el.querySelectorAll("text").forEach(function (textEl) {+ targets = targets.concat(textStyleLeavesForText(textEl));+ });+ return uniqueElements(targets);+ }++ function textStyleLeavesForText(textEl) {+ var tspans = Array.from(textEl.querySelectorAll("tspan")).filter(function (tspan) {+ return !!tspan.id;+ });+ if (tspans.length > 0) return tspans;+ return textEl.id ? [textEl] : [];+ }++ function uniqueElements(elements) {+ var seen = new Set();+ return elements.filter(function (el) {+ if (!el || !el.id || seen.has(el.id)) return false;+ seen.add(el.id);+ return true;+ });+ }++ function textStyleSpecs(targets) {+ return [+ { key: "fill", type: "color" },+ { key: "font-size", type: "text" },+ { key: "font-family", type: "text" },+ { key: "font-weight", type: "select",+ options: ["", "normal", "bold", "300", "400", "500", "600", "700", "800"] },+ { key: "text-anchor", type: "select", options: ["", "start", "middle", "end"] }+ ].map(function (spec) {+ var value = commonAttrValue(targets, spec.key);+ var copy = Object.assign({}, spec);+ copy.value = value === null ? "" : value;+ copy.mixed = value === null;+ return copy;+ });+ }++ function renderTextStyleControl(spec, targets) {+ var targetIds = encodeURIComponent(JSON.stringify(targets.map(function (el) { return el.id; })));+ var placeholder = spec.mixed ? t("multi_mixed") : "";+ if (spec.type === "color") {+ return '<input type="color" class="prop-edit prop-edit-text-style-color" data-key="' ++ escapeHtml(spec.key) + '" data-target-ids="' + targetIds ++ '" value="' + normalizeHexForPicker(spec.value) + '">' ++ '<input type="text" class="prop-edit prop-edit-text-style" data-key="' ++ escapeHtml(spec.key) + '" data-target-ids="' + targetIds ++ '" placeholder="' + escapeHtml(placeholder) ++ '" value="' + escapeHtml(spec.mixed ? "" : spec.value) + '">';+ }+ if (spec.type === "select") {+ var html = '<select class="prop-edit prop-edit-text-style" data-key="' ++ escapeHtml(spec.key) + '" data-target-ids="' + targetIds + '">';+ var hasValue = spec.options.indexOf(spec.value) !== -1;+ if (!spec.mixed && spec.value && !hasValue) {+ html += '<option value="' + escapeHtml(spec.value) + '" selected>' ++ escapeHtml(spec.value) + '</option>';+ }+ spec.options.forEach(function (opt) {+ var label = opt || placeholder || "";+ var selected = !spec.mixed && spec.value === opt ? " selected" : "";+ html += '<option value="' + escapeHtml(opt) + '"' + selected + '>' ++ escapeHtml(label) + '</option>';+ });+ html += '</select>';+ return html;+ }+ return '<input type="text" class="prop-edit prop-edit-text-style" data-key="' ++ escapeHtml(spec.key) + '" data-target-ids="' + targetIds ++ '" placeholder="' + escapeHtml(placeholder) ++ '" value="' + escapeHtml(spec.mixed ? "" : spec.value) + '">';+ }+function isColorAttribute(key, value) {var k = String(key).toLowerCase();if (["fill", "stroke", "color", "stop-color", "flood-color", "lighting-color"].indexOf(k) !== -1) {@@ -2294,6 +2386,26 @@});});+ panel.querySelectorAll(".prop-edit-text-style-color").forEach(function (picker) {+ var key = picker.getAttribute("data-key");+ var textInput = panel.querySelector('.prop-edit-text-style[data-key="' + key + '"]');+ picker.addEventListener("input", function () {+ if (textInput) textInput.value = picker.value;+ });+ picker.addEventListener("change", function () {+ if (textInput) textInput.value = picker.value;+ stageTextStyleAttr(key, picker.value, picker.getAttribute("data-target-ids"));+ });+ });+ panel.querySelectorAll(".prop-edit-text-style").forEach(function (input) {+ input.addEventListener("change", function () {+ var key = input.getAttribute("data-key");+ var value = input.value.trim();+ if (!value) return;+ stageTextStyleAttr(key, value, input.getAttribute("data-target-ids"));+ });+ });+panel.querySelectorAll(".prop-edit-attr, .prop-edit-attr-area").forEach(function (input) {var key = input.getAttribute("data-key");input.addEventListener("change", function () {@@ -2357,6 +2469,36 @@}}+ function stageTextStyleAttr(key, value, encodedTargetIds) {+ if ((key === "fill" || key === "stroke") && !isSafeColor(value)) {+ showError(t("err_edit") + key);+ return;+ }+ var ids;+ try {+ ids = JSON.parse(decodeURIComponent(encodedTargetIds || "%5B%5D"));+ } catch (e) {+ ids = [];+ }+ var targets = ids.map(function (id) {+ return svgContent.querySelector("#" + CSS.escape(id));+ }).filter(function (target) {+ return target && attrOrComputedValue(target, key) !== value;+ });+ if (targets.length === 0) return;++ var attrs = {};+ attrs[key] = value;+ var jobs = targets.map(function (target) {+ return stageEditRequest(target.id, { attrs: attrs }).then(function () {+ target.setAttribute(key, value);+ });+ });+ Promise.all(jobs)+ .then(function () { updateSelectionPanel(); })+ .catch(function (err) { showError(t("err_edit") + err.message); });+ }+function stageAttr(el, eid, key, value) {if ((key === "fill" || key === "stroke") && !isSafeColor(value)) {showError(t("err_edit") + key);diff --git a/skills/ppt-master/workflows/live-preview.md b/skills/ppt-master/workflows/live-preview.mdindex e20334c7..a80b3663 100644--- a/skills/ppt-master/workflows/live-preview.md+++ b/skills/ppt-master/workflows/live-preview.md@@ -75,7 +75,7 @@ Triggered by the user signals listed in "When to Run".- **UI**: bilingual (EN/中); auto-detects from `navigator.language`, persists in `localStorage`, toggled via the **中 / EN** button on the right panel. The right panel is an **Edit / Annotate** surface: direct SVG edits and AI-needed annotations are visually separated, with a pending-status strip showing staged direct edits and pages with unsaved annotations. Slide navigation: first/prev/next/last buttons at the top of the center panel, plus `←` / `→` / `Home` / `End` (suppressed while typing in the annotation textarea).- **Buttons**: `Add annotation` stages annotation text in memory; `Apply changes` writes staged direct edits plus annotation markers to disk and keeps the service running; `Exit preview` is the only UI action that stops Flask.-- **Direct edit (no AI)**: selection mode determines the right-panel surface. Single element = full object inspector (geometry, safe text content, raw SVG attributes except protected fields like `id`, UI `class`, event handlers, and hrefs). SVG `<g>` group = group-level edit surface; select via `Alt/Option` + click or **Select parent group** from a child element. Multi-select = limited batch editor over top-level selected objects only: shared x/y plus `fill` / `stroke` / `opacity`; text style fields (`font-size` / `font-family` / `font-weight` / `text-anchor`) appear only when every selected object is `text`/`tspan`. Preview updates immediately; disk writes wait for **Apply changes**.+- **Direct edit (no AI)**: selection mode determines the right-panel surface. Single element = full object inspector (geometry, safe text content, computed text styles for the selected text node or descendant text inside a selected textbox/group, raw SVG attributes except protected fields like `id`, UI `class`, event handlers, and hrefs). SVG `<g>` group = group-level edit surface; select via `Alt/Option` + click or **Select parent group** from a child element. Multi-select = limited batch editor over top-level selected objects only: shared x/y plus `fill` / `stroke` / `opacity`; text style fields (`font-size` / `font-family` / `font-weight` / `text-anchor`) appear only when every selected object is `text`/`tspan`. Preview updates immediately; disk writes wait for **Apply changes**.- **Drag to move**: press and drag an already-selected element on the canvas to reposition it (selection stays a separate click, so the background is never dragged by accident); the whole selection moves together under multi-select. The pointer delta is mapped through each element's own CTM, so moves track the cursor regardless of viewport scale or group transforms. Each release stages one direct edit per moved element (the same `x`/`y`-or-`transform` write the geometry inputs produce), previewed live and written only on **Apply changes**; dragging on empty canvas is still rubber-band selection. A failed stage rolls the canvas back to the pre-drag position.- **Arrow-key nudge**: with one or more elements selected, `↑ ↓ ← →` moves the selection 1px and `Shift + arrow` moves 10px (suppressed while typing in the annotation box). Arrow keys navigate slides only when nothing is selected. Same staging/coalescing path as drag, so a burst of nudges collapses to one undo step.- **Overlap picker**: right-click anywhere on the canvas to list every selectable element under the pointer (top→bottom), so stacked shapes can be reached without blind cycling. Left-click is unchanged (selects the topmost). Hovering a row highlights that element; clicking it selects it; `Esc` or an outside click closes the list. With exactly one element under the pointer, right-click selects it directly.