File size: 2,176 Bytes
ef987bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
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
36
37
38
39
40
41
42
43
44
45
<!doctype html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>Multi Block Prompt Fixture</title>
  <style>

    :root { --sidebar-width: 240px; --content-max-width: 900px; }

    body { margin: 0; font-family: Arial, sans-serif; }

    .app { display: flex; min-height: 100vh; }

    [data-testid="sidebar"] { width: 240px; padding: 16px; background: #1f2937; color: white; overflow-y: auto; }

    [data-testid="content"] { width: 900px; max-width: 100%; margin: 0 auto; padding: 24px; }

    [data-testid="prompt-response-block"] { border: 1px solid #bbb; padding: 12px; margin-bottom: 12px; }

    textarea { width: 100%; min-height: 56px; }

  </style>
</head>
<body>
  <div class="app">
    <aside data-testid="sidebar"><h2>Blocks</h2><ol data-testid="sidebar-list"><li>block-1 idle</li></ol></aside>
    <main data-testid="content">
      <section data-testid="blocks">
        <article data-testid="prompt-response-block" data-block-id="block-1">
          <textarea data-testid="prompt-input" placeholder="Prompt"></textarea>
          <button data-testid="send-button">Send</button>
          <output data-testid="response">not sent</output>
        </article>
      </section>
      <button data-testid="new-block-placeholder">New block</button>
    </main>
  </div>
  <script>

    window.BlockManager = null;

    const blocks = document.querySelector('[data-testid="blocks"]');

    document.querySelector('[data-testid="new-block-placeholder"]').addEventListener('click', () => {

      blocks.insertAdjacentHTML('beforeend', '<article data-testid="prompt-response-block" data-block-id="block-2"><textarea data-testid="prompt-input" placeholder="Prompt"></textarea><button data-testid="send-button">Send</button><output data-testid="response">not sent</output></article>');

    });

    document.addEventListener('click', event => {

      if (event.target.matches('[data-testid="send-button"]')) {

        const block = event.target.closest('[data-testid="prompt-response-block"]');

        block.querySelector('[data-testid="response"]').textContent = 'shared response';

      }

    });

  </script>
</body>
</html>