73 lines
2.7 KiB
Python
Executable file
73 lines
2.7 KiB
Python
Executable file
import re
|
|
|
|
with open('C:/ScriptoriumAI/scriptoriumai-ui/src/pages/EditorSimplified.tsx', 'r', encoding='utf-8') as f:
|
|
data = f.read()
|
|
|
|
# 1. Add import
|
|
import_str = "import { MemoryInspector } from '../components/memory/MemoryInspector'"
|
|
if import_str not in data:
|
|
data = data.replace(
|
|
"import { Activity,",
|
|
import_str + "\nimport { Activity,"
|
|
)
|
|
|
|
# 2. Add Tab button
|
|
tab_old = ''' >
|
|
Insights
|
|
</button>
|
|
</div>'''
|
|
tab_new = ''' >
|
|
Insights
|
|
</button>
|
|
<button
|
|
type="button"
|
|
onClick={() => setActiveRightPaneTab('memory')}
|
|
className={px-2 py-1 text-xs rounded }
|
|
>
|
|
Memory
|
|
</button>
|
|
</div>'''
|
|
data = data.replace(tab_old, tab_new)
|
|
|
|
# 3. Add Component Render
|
|
render_old = ''' ) : activeRightPaneTab === 'native_pdf' ? (
|
|
<NativePdfPanelShell
|
|
status={nativePdfPanelStatus}
|
|
source={{
|
|
uri: pdfUrl,
|
|
bytesCacheKey: nativePdfBytesCacheKey,
|
|
pageCount: nativePdfPageCount,
|
|
byteLength: nativePdfByteLength,
|
|
}}
|
|
virtualization={{ pageWindow: 4, overscanPages: 2 }}
|
|
errorMessage={compileError || nativePdfRuntimeError}
|
|
onRequestRenderPage={handleNativePdfRenderPageRequest}
|
|
/>
|
|
) : (
|
|
<div className="h-full overflow-auto p-4 space-y-4">'''
|
|
|
|
render_new = ''' ) : activeRightPaneTab === 'native_pdf' ? (
|
|
<NativePdfPanelShell
|
|
status={nativePdfPanelStatus}
|
|
source={{
|
|
uri: pdfUrl,
|
|
bytesCacheKey: nativePdfBytesCacheKey,
|
|
pageCount: nativePdfPageCount,
|
|
byteLength: nativePdfByteLength,
|
|
}}
|
|
virtualization={{ pageWindow: 4, overscanPages: 2 }}
|
|
errorMessage={compileError || nativePdfRuntimeError}
|
|
onRequestRenderPage={handleNativePdfRenderPageRequest}
|
|
/>
|
|
) : activeRightPaneTab === 'memory' ? (
|
|
<div className="h-full overflow-auto bg-gray-900">
|
|
<MemoryInspector />
|
|
</div>
|
|
) : (
|
|
<div className="h-full overflow-auto p-4 space-y-4">'''
|
|
data = data.replace(render_old, render_new)
|
|
|
|
with open('C:/ScriptoriumAI/scriptoriumai-ui/src/pages/EditorSimplified.tsx', 'w', encoding='utf-8') as f:
|
|
f.write(data)
|
|
|
|
print("Done")
|