|
1 | 1 | /* ============================================================ |
2 | | - OpenCut CEP Panel - Main Controller v1.10.2 |
| 2 | + OpenCut CEP Panel - Main Controller v1.10.3 |
3 | 3 | 6-Tab Professional Toolkit |
4 | 4 | ============================================================ */ |
5 | 5 | (function () { |
|
1408 | 1408 | // Every ExtendScript operation that mutates the Premiere project calls |
1409 | 1409 | // journalRecord() after success. The Journal sub-tab under Settings |
1410 | 1410 | // renders the history and dispatches inverse calls via PremiereBridge. |
1411 | | - function journalRecord(action, label, inversePayload, clipPath) { |
| 1411 | + function journalRecord(action, label, inversePayload, clipPath, forwardPayload) { |
1412 | 1412 | if (!connected) return; |
1413 | | - api("POST", "/journal/record", { |
| 1413 | + var body = { |
1414 | 1414 | action: action, |
1415 | 1415 | label: label || "", |
1416 | 1416 | clip_path: clipPath || "", |
1417 | 1417 | inverse: inversePayload || {} |
1418 | | - }, function (err, entry) { |
| 1418 | + }; |
| 1419 | + // v1.10.3 (N): include forward {endpoint, payload} so journal |
| 1420 | + // rows can later expose "Apply to selection". |
| 1421 | + if (forwardPayload) body.forward = forwardPayload; |
| 1422 | + api("POST", "/journal/record", body, function (err, entry) { |
1419 | 1423 | if (err) { |
1420 | 1424 | // Never surface journal-record failures to the user — the |
1421 | 1425 | // forward operation already succeeded. |
|
3225 | 3229 | "import_sequence", |
3226 | 3230 | _sessionCtxOpText(job) + " → '" + r.sequence_name + "'", |
3227 | 3231 | { name: r.sequence_name }, |
3228 | | - selectedPath |
| 3232 | + selectedPath, |
| 3233 | + // Forward replay = re-run the same job type |
| 3234 | + // (silence / full / etc) on a different clip. |
| 3235 | + job.endpoint && job.payload |
| 3236 | + ? { endpoint: job.endpoint, payload: job.payload } |
| 3237 | + : null |
3229 | 3238 | ); |
3230 | 3239 | } |
3231 | 3240 | } catch (e) { console.error("XML import parse error:", e); } |
|
6252 | 6261 | actions.appendChild(revertBtn); |
6253 | 6262 | } |
6254 | 6263 |
|
| 6264 | + // v1.10.3 (N): "Apply to selection" when the journal entry has a |
| 6265 | + // forward payload and the user currently has a different clip |
| 6266 | + // selected than the one the entry ran on. |
| 6267 | + var fwd = entry.forward; |
| 6268 | + var canReplay = fwd && fwd.endpoint && |
| 6269 | + selectedPath && entry.clip_path && selectedPath !== entry.clip_path; |
| 6270 | + if (canReplay) { |
| 6271 | + var applyBtn = document.createElement("button"); |
| 6272 | + applyBtn.type = "button"; |
| 6273 | + applyBtn.className = "btn btn-ghost btn-sm"; |
| 6274 | + applyBtn.textContent = "Apply to selection"; |
| 6275 | + applyBtn.title = "Run the same action on '" + |
| 6276 | + (selectedName || "selection") + "' with the same params"; |
| 6277 | + applyBtn.addEventListener("click", function () { |
| 6278 | + _journalApplyToSelection(entry); |
| 6279 | + }); |
| 6280 | + actions.appendChild(applyBtn); |
| 6281 | + } |
| 6282 | + |
6255 | 6283 | row.appendChild(actions); |
6256 | 6284 | return row; |
6257 | 6285 | } |
6258 | 6286 |
|
| 6287 | + function _journalApplyToSelection(entry) { |
| 6288 | + var fwd = entry && entry.forward; |
| 6289 | + if (!fwd) return; |
| 6290 | + if (!selectedPath) { showAlert("Select a clip first."); return; } |
| 6291 | + // ExtendScript-dispatch actions get a special pseudo-endpoint. |
| 6292 | + if (fwd.endpoint === "__jsx_add_markers__") { |
| 6293 | + if (!inPremiere) { |
| 6294 | + showAlert("Premiere connection required."); |
| 6295 | + return; |
| 6296 | + } |
| 6297 | + var markers = (fwd.payload && fwd.payload.markers) || []; |
| 6298 | + if (!markers.length) { showAlert("No markers to replay."); return; } |
| 6299 | + var payload = JSON.stringify(markers); |
| 6300 | + cs.evalScript( |
| 6301 | + "ocAddSequenceMarkers('" + |
| 6302 | + payload.replace(/\\/g, "\\\\").replace(/'/g, "\\'") + "')", |
| 6303 | + function (result) { |
| 6304 | + try { |
| 6305 | + var r = JSON.parse(result || "{}"); |
| 6306 | + if (r.error) { showAlert("Apply failed: " + r.error); return; } |
| 6307 | + showToast("Re-added " + markers.length + " markers on '" + |
| 6308 | + (selectedName || "selection") + "'", "success"); |
| 6309 | + } catch (e) { showAlert("Apply failed: " + (result || e.message)); } |
| 6310 | + } |
| 6311 | + ); |
| 6312 | + return; |
| 6313 | + } |
| 6314 | + // HTTP endpoints: replace filepath with the current selection |
| 6315 | + var replay = JSON.parse(JSON.stringify(fwd.payload || {})); |
| 6316 | + replay.filepath = selectedPath; |
| 6317 | + showToast("Applying " + _journalActionLabel(entry.action) + |
| 6318 | + " to '" + (selectedName || "selection") + "'…", "info"); |
| 6319 | + startJob(fwd.endpoint, replay); |
| 6320 | + } |
| 6321 | + |
6259 | 6322 | function _journalRevert(entry, btn) { |
6260 | 6323 | if (!inPremiere) { showAlert("Premiere Pro connection required to revert."); return; } |
6261 | 6324 | if (!entry.revertible) { return; } |
|
10486 | 10549 | "add_markers", |
10487 | 10550 | _journalLabelForMarkers(markers.length, selectedName), |
10488 | 10551 | { markers: fingerprints }, |
10489 | | - selectedPath |
| 10552 | + selectedPath, |
| 10553 | + // Forward op: re-add the same beat markers on a |
| 10554 | + // different clip. endpoint dispatches to ExtendScript. |
| 10555 | + { endpoint: "__jsx_add_markers__", |
| 10556 | + payload: { markers: markers } } |
10490 | 10557 | ); |
10491 | 10558 | } |
10492 | 10559 | } catch (e) { showAlert("Error adding markers: " + (result || e.message)); } |
|
10707 | 10774 | journalRecord( |
10708 | 10775 | "batch_rename", |
10709 | 10776 | _journalLabelForRename(reverseList.length), |
10710 | | - { renames: reverseList } |
| 10777 | + { renames: reverseList }, |
| 10778 | + "", |
| 10779 | + // Forward replay isn't meaningful for rename — |
| 10780 | + // the nodeIds are project-scoped and the "new" |
| 10781 | + // names were project-specific. |
| 10782 | + null |
10711 | 10783 | ); |
10712 | 10784 | } |
10713 | 10785 | } catch (e) { showAlert("Error: " + (result || e.message)); } |
|
0 commit comments