|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CatCutTextEditor extends HTMLElement { |
|
|
constructor() { |
|
|
super(); |
|
|
this.attachShadow({ mode: 'open' }); |
|
|
this.segments = []; |
|
|
} |
|
|
|
|
|
connectedCallback() { |
|
|
this.render(); |
|
|
this.setupEventListeners(); |
|
|
} |
|
|
|
|
|
render() { |
|
|
this.shadowRoot.innerHTML = ` |
|
|
<style> |
|
|
:host { |
|
|
display: block; |
|
|
height: 100%; |
|
|
background: #f8fafc; |
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; |
|
|
} |
|
|
|
|
|
.editor-container { |
|
|
height: 100%; |
|
|
overflow-y: auto; |
|
|
padding: 1.5rem; |
|
|
} |
|
|
|
|
|
.editor-header { |
|
|
display: flex; |
|
|
justify-content: space-between; |
|
|
align-items: center; |
|
|
margin-bottom: 1.5rem; |
|
|
} |
|
|
|
|
|
.editor-title { |
|
|
font-size: 1.25rem; |
|
|
font-weight: 600; |
|
|
color: #1e293b; |
|
|
} |
|
|
|
|
|
.editor-controls { |
|
|
display: flex; |
|
|
gap: 0.5rem; |
|
|
} |
|
|
|
|
|
.control-btn { |
|
|
padding: 0.5rem; |
|
|
background: #ffffff; |
|
|
border: 1px solid #e2e8f0; |
|
|
border-radius: 0.375rem; |
|
|
cursor: pointer; |
|
|
transition: all 0.2s ease; |
|
|
display: flex; |
|
|
align-items: center; |
|
|
justify-content: center; |
|
|
} |
|
|
|
|
|
.control-btn:hover { |
|
|
border-color: #f59e0b; |
|
|
color: #f59e0b; |
|
|
} |
|
|
|
|
|
.control-btn.active { |
|
|
background: #fffbeb; |
|
|
border-color: #f59e0b; |
|
|
color: #f59e0b; |
|
|
} |
|
|
|
|
|
.editor-content { |
|
|
font-size: 1.125rem; |
|
|
line-height: 1.7; |
|
|
color: #334155; |
|
|
outline: none; |
|
|
min-height: 200px; |
|
|
} |
|
|
|
|
|
.editor-content:focus { |
|
|
outline: none; |
|
|
} |
|
|
|
|
|
.story-segment { |
|
|
position: relative; |
|
|
padding: 1rem; |
|
|
margin-bottom: 0.75rem; |
|
|
border-radius: 0.5rem; |
|
|
border: 1px solid transparent; |
|
|
transition: all 0.3s ease; |
|
|
cursor: pointer; |
|
|
background: white; |
|
|
} |
|
|
|
|
|
.story-segment:hover { |
|
|
border-color: rgba(245, 158, 11, 0.3); |
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); |
|
|
} |
|
|
|
|
|
.story-segment.active { |
|
|
border-color: #f59e0b; |
|
|
background: #fffbeb; |
|
|
box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1); |
|
|
} |
|
|
|
|
|
.story-segment.locked { |
|
|
border-color: #94a3b8; |
|
|
background: #f8fafc; |
|
|
} |
|
|
|
|
|
.segment-controls { |
|
|
position: absolute; |
|
|
top: 0.5rem; |
|
|
right: 0.5rem; |
|
|
display: flex; |
|
|
gap: 0.5rem; |
|
|
opacity: 0; |
|
|
transition: opacity 0.2s ease; |
|
|
} |
|
|
|
|
|
.story-segment:hover .segment-controls { |
|
|
opacity: 1; |
|
|
} |
|
|
|
|
|
.control-btn-small { |
|
|
width: 1.75rem; |
|
|
height: 1.75rem; |
|
|
border-radius: 0.375rem; |
|
|
border: none; |
|
|
cursor: pointer; |
|
|
display: flex; |
|
|
align-items: center; |
|
|
justify-content: center; |
|
|
transition: all 0.2s ease; |
|
|
background: #f1f5f9; |
|
|
color: #64748b; |
|
|
} |
|
|
|
|
|
.control-btn-small:hover { |
|
|
background: #f59e0b; |
|
|
color: white; |
|
|
} |
|
|
|
|
|
.control-btn-small.danger:hover { |
|
|
background: #ef4444; |
|
|
} |
|
|
|
|
|
.segment-text { |
|
|
margin: 0; |
|
|
padding-right: 2rem; |
|
|
white-space: pre-wrap; |
|
|
word-wrap: break-word; |
|
|
} |
|
|
|
|
|
.segment-text:focus { |
|
|
outline: 2px solid #f59e0b; |
|
|
outline-offset: 4px; |
|
|
border-radius: 4px; |
|
|
} |
|
|
|
|
|
.segment-metadata { |
|
|
margin-top: 0.75rem; |
|
|
font-size: 0.875rem; |
|
|
display: flex; |
|
|
justify-content: space-between; |
|
|
align-items: center; |
|
|
} |
|
|
|
|
|
.ai-confidence { |
|
|
display: flex; |
|
|
align-items: center; |
|
|
gap: 0.5rem; |
|
|
} |
|
|
|
|
|
.confidence-bar { |
|
|
width: 60px; |
|
|
height: 4px; |
|
|
background: #e2e8f0; |
|
|
border-radius: 2px; |
|
|
overflow: hidden; |
|
|
} |
|
|
|
|
|
.confidence-fill { |
|
|
height: 100%; |
|
|
background: #f59e0b; |
|
|
transition: width 0.3s ease; |
|
|
} |
|
|
|
|
|
.segment-timestamp { |
|
|
color: #64748b; |
|
|
font-variant-numeric: tabular-nums; |
|
|
} |
|
|
|
|
|
.add-segment-btn { |
|
|
width: 100%; |
|
|
padding: 1rem; |
|
|
border: 2px dashed #e2e8f0; |
|
|
border-radius: 0.5rem; |
|
|
background: transparent; |
|
|
color: #64748b; |
|
|
cursor: pointer; |
|
|
transition: all |