@pyreon/code 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/lib/analysis/index.js.html +5406 -0
- package/lib/dist-B5vB-rif.js +3904 -0
- package/lib/dist-B5vB-rif.js.map +1 -0
- package/lib/dist-BAfzu5eu.js +1428 -0
- package/lib/dist-BAfzu5eu.js.map +1 -0
- package/lib/dist-BLlV_D16.js +1166 -0
- package/lib/dist-BLlV_D16.js.map +1 -0
- package/lib/dist-BNmKLTu8.js +373 -0
- package/lib/dist-BNmKLTu8.js.map +1 -0
- package/lib/dist-BZtTlC1J.js +692 -0
- package/lib/dist-BZtTlC1J.js.map +1 -0
- package/lib/dist-CTDqGIAf.js +856 -0
- package/lib/dist-CTDqGIAf.js.map +1 -0
- package/lib/dist-CTPisNZp.js +83 -0
- package/lib/dist-CTPisNZp.js.map +1 -0
- package/lib/dist-Ce2tvOxv.js +379 -0
- package/lib/dist-Ce2tvOxv.js.map +1 -0
- package/lib/dist-CttF0OTv.js +465 -0
- package/lib/dist-CttF0OTv.js.map +1 -0
- package/lib/dist-DS2tluW9.js +818 -0
- package/lib/dist-DS2tluW9.js.map +1 -0
- package/lib/dist-DUNx9ldu.js +460 -0
- package/lib/dist-DUNx9ldu.js.map +1 -0
- package/lib/dist-Dej_yf3k.js +473 -0
- package/lib/dist-Dej_yf3k.js.map +1 -0
- package/lib/dist-DshStUxU.js +283 -0
- package/lib/dist-DshStUxU.js.map +1 -0
- package/lib/dist-qTrOe7xY.js +461 -0
- package/lib/dist-qTrOe7xY.js.map +1 -0
- package/lib/dist-v09vikKr.js +2421 -0
- package/lib/dist-v09vikKr.js.map +1 -0
- package/lib/index.js +915 -0
- package/lib/index.js.map +1 -0
- package/lib/types/dist.d.ts +798 -0
- package/lib/types/dist.d.ts.map +1 -0
- package/lib/types/dist10.d.ts +67 -0
- package/lib/types/dist10.d.ts.map +1 -0
- package/lib/types/dist11.d.ts +126 -0
- package/lib/types/dist11.d.ts.map +1 -0
- package/lib/types/dist12.d.ts +21 -0
- package/lib/types/dist12.d.ts.map +1 -0
- package/lib/types/dist13.d.ts +404 -0
- package/lib/types/dist13.d.ts.map +1 -0
- package/lib/types/dist14.d.ts +292 -0
- package/lib/types/dist14.d.ts.map +1 -0
- package/lib/types/dist15.d.ts +132 -0
- package/lib/types/dist15.d.ts.map +1 -0
- package/lib/types/dist2.d.ts +15 -0
- package/lib/types/dist2.d.ts.map +1 -0
- package/lib/types/dist3.d.ts +106 -0
- package/lib/types/dist3.d.ts.map +1 -0
- package/lib/types/dist4.d.ts +67 -0
- package/lib/types/dist4.d.ts.map +1 -0
- package/lib/types/dist5.d.ts +95 -0
- package/lib/types/dist5.d.ts.map +1 -0
- package/lib/types/dist6.d.ts +330 -0
- package/lib/types/dist6.d.ts.map +1 -0
- package/lib/types/dist7.d.ts +15 -0
- package/lib/types/dist7.d.ts.map +1 -0
- package/lib/types/dist8.d.ts +15 -0
- package/lib/types/dist8.d.ts.map +1 -0
- package/lib/types/dist9.d.ts +635 -0
- package/lib/types/dist9.d.ts.map +1 -0
- package/lib/types/index.d.ts +852 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index2.d.ts +347 -0
- package/lib/types/index2.d.ts.map +1 -0
- package/package.json +79 -0
- package/src/components/code-editor.tsx +42 -0
- package/src/components/diff-editor.tsx +97 -0
- package/src/components/tabbed-editor.tsx +86 -0
- package/src/editor.ts +652 -0
- package/src/index.ts +52 -0
- package/src/languages.ts +77 -0
- package/src/minimap.ts +160 -0
- package/src/tabbed-editor.ts +231 -0
- package/src/tests/code.test.ts +505 -0
- package/src/themes.ts +87 -0
- package/src/types.ts +253 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { VNodeChild } from '@pyreon/core'
|
|
2
|
+
import type { TabbedEditorProps } from '../types'
|
|
3
|
+
import { CodeEditor } from './code-editor'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Tabbed code editor component — renders tab bar + editor.
|
|
7
|
+
* Headless styling — the tab bar is a plain div with button tabs.
|
|
8
|
+
* Consumers can style via CSS classes.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const editor = createTabbedEditor({
|
|
13
|
+
* tabs: [
|
|
14
|
+
* { name: 'index.ts', language: 'typescript', value: 'const x = 1' },
|
|
15
|
+
* { name: 'style.css', language: 'css', value: '.app { }' },
|
|
16
|
+
* ],
|
|
17
|
+
* theme: 'dark',
|
|
18
|
+
* })
|
|
19
|
+
*
|
|
20
|
+
* <TabbedEditor instance={editor} style="height: 500px" />
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function TabbedEditor(props: TabbedEditorProps): VNodeChild {
|
|
24
|
+
const { instance } = props
|
|
25
|
+
|
|
26
|
+
const containerStyle = `display: flex; flex-direction: column; width: 100%; height: 100%; ${props.style ?? ''}`
|
|
27
|
+
|
|
28
|
+
const tabBarStyle =
|
|
29
|
+
'display: flex; overflow-x: auto; background: #f1f5f9; border-bottom: 1px solid #e2e8f0; min-height: 34px; flex-shrink: 0;'
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div
|
|
33
|
+
class={`pyreon-tabbed-editor ${props.class ?? ''}`}
|
|
34
|
+
style={containerStyle}
|
|
35
|
+
>
|
|
36
|
+
{() => {
|
|
37
|
+
const tabs = instance.tabs()
|
|
38
|
+
const activeId = instance.activeTabId()
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div class="pyreon-tabbed-editor-tabs" style={tabBarStyle}>
|
|
42
|
+
{tabs.map((tab) => {
|
|
43
|
+
const id = tab.id ?? tab.name
|
|
44
|
+
const isActive = id === activeId
|
|
45
|
+
|
|
46
|
+
const tabStyle = `display: flex; align-items: center; gap: 6px; padding: 6px 12px; border: none; background: ${isActive ? 'white' : 'transparent'}; border-bottom: ${isActive ? '2px solid #3b82f6' : '2px solid transparent'}; cursor: pointer; font-size: 13px; color: ${isActive ? '#1e293b' : '#64748b'}; white-space: nowrap; position: relative; font-family: inherit;`
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<button
|
|
50
|
+
type="button"
|
|
51
|
+
key={id}
|
|
52
|
+
class={`pyreon-tab ${isActive ? 'active' : ''} ${tab.modified ? 'modified' : ''}`}
|
|
53
|
+
style={tabStyle}
|
|
54
|
+
onClick={() => instance.switchTab(id)}
|
|
55
|
+
>
|
|
56
|
+
<span>{tab.name}</span>
|
|
57
|
+
{tab.modified && (
|
|
58
|
+
<span
|
|
59
|
+
style="width: 6px; height: 6px; border-radius: 50%; background: #f59e0b; flex-shrink: 0;"
|
|
60
|
+
title="Modified"
|
|
61
|
+
/>
|
|
62
|
+
)}
|
|
63
|
+
{tab.closable !== false && (
|
|
64
|
+
<span
|
|
65
|
+
style="font-size: 14px; line-height: 1; opacity: 0.5; cursor: pointer; padding: 0 2px; margin-left: 2px;"
|
|
66
|
+
title="Close"
|
|
67
|
+
onClick={(e: MouseEvent) => {
|
|
68
|
+
e.stopPropagation()
|
|
69
|
+
instance.closeTab(id)
|
|
70
|
+
}}
|
|
71
|
+
>
|
|
72
|
+
×
|
|
73
|
+
</span>
|
|
74
|
+
)}
|
|
75
|
+
</button>
|
|
76
|
+
)
|
|
77
|
+
})}
|
|
78
|
+
</div>
|
|
79
|
+
)
|
|
80
|
+
}}
|
|
81
|
+
<div style="flex: 1; min-height: 0;">
|
|
82
|
+
<CodeEditor instance={instance.editor} />
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
)
|
|
86
|
+
}
|