mirror of
https://github.com/penpot/penpot-mcp.git
synced 2026-04-25 11:18:37 +00:00
REPL: Reuse last input
This commit is contained in:
parent
6daede99b2
commit
bc5936365a
@ -171,7 +171,7 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Penpot MCP REPL</h1>
|
<h1>Penpot API REPL</h1>
|
||||||
|
|
||||||
<div class="repl-container" id="repl-container">
|
<div class="repl-container" id="repl-container">
|
||||||
<!-- REPL entries will be dynamically added here -->
|
<!-- REPL entries will be dynamically added here -->
|
||||||
@ -183,25 +183,26 @@
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
let isExecuting = false;
|
let isExecuting = false;
|
||||||
let entryCounter = 1;
|
let entryCounter = 1;
|
||||||
|
let lastCode = ""; // store the last executed code
|
||||||
|
|
||||||
// create the initial input entry
|
// create the initial input entry
|
||||||
createNewEntry();
|
createNewEntry();
|
||||||
|
|
||||||
function createNewEntry() {
|
function createNewEntry() {
|
||||||
const entryId = `entry-${entryCounter}`;
|
const entryId = `entry-${entryCounter}`;
|
||||||
|
const defaultCode = lastCode || "";
|
||||||
const entryHtml = `
|
const entryHtml = `
|
||||||
<div class="repl-entry" id="${entryId}">
|
<div class="repl-entry" id="${entryId}">
|
||||||
<div class="entry-number">In [${entryCounter}]:</div>
|
<div class="entry-number">In [${entryCounter}]:</div>
|
||||||
<div class="input-section">
|
<div class="input-section">
|
||||||
<textarea class="code-input" id="code-input-${entryCounter}"
|
<textarea class="code-input" id="code-input-${entryCounter}"
|
||||||
placeholder="Enter your JavaScript code here...
|
placeholder="// Enter your JavaScript code here...
|
||||||
// Example:
|
|
||||||
console.log('Hello from Penpot!');
|
console.log('Hello from Penpot!');
|
||||||
return 'This will be the result';"></textarea>
|
return 'This will be the result';">${escapeHtml(defaultCode)}</textarea>
|
||||||
<button class="execute-btn" id="execute-btn-${entryCounter}">Execute Code</button>
|
<button class="execute-btn" id="execute-btn-${entryCounter}">Execute Code</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
`;
|
||||||
`;
|
|
||||||
|
|
||||||
$("#repl-container").append(entryHtml);
|
$("#repl-container").append(entryHtml);
|
||||||
|
|
||||||
@ -327,6 +328,9 @@ return 'This will be the result';"></textarea>
|
|||||||
$codeInput.prop("readonly", true);
|
$codeInput.prop("readonly", true);
|
||||||
$(`#execute-btn-${entryNum}`).remove();
|
$(`#execute-btn-${entryNum}`).remove();
|
||||||
|
|
||||||
|
// store the code for the next entry
|
||||||
|
lastCode = code;
|
||||||
|
|
||||||
// create a new entry for the next input
|
// create a new entry for the next input
|
||||||
createNewEntry();
|
createNewEntry();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user