Skip to content

Commit d5890f2

Browse files
committed
re-add some comments
1 parent 0d3c411 commit d5890f2

File tree

1 file changed

+40
-49
lines changed

1 file changed

+40
-49
lines changed

src/components/editors/ScriptEditor/index.tsx

Lines changed: 40 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
import { leftBarTrackScaleWidth, useTimeline } from '@aitube/timeline'
21
import Editor, { Monaco } from '@monaco-editor/react'
2+
import {
3+
leftBarTrackScaleWidth,
4+
TimelineStore,
5+
useTimeline,
6+
} from '@aitube/timeline'
37
import MonacoEditor from 'monaco-editor'
48
import { useEffect } from 'react'
59

610
import { useScriptEditor } from '@/services/editors/script-editor/useScriptEditor'
711
import { useUI } from '@/services/ui'
812
import { themes } from '@/services/ui/theme'
913

10-
import { ScriptEditorStore } from '@aitube/clapper-services'
1114
import './styles.css'
1215

1316
export function ScriptEditor() {
@@ -18,25 +21,14 @@ export function ScriptEditor() {
1821
const current = useScriptEditor((s) => s.current)
1922
const setCurrent = useScriptEditor((s) => s.setCurrent)
2023
const publish = useScriptEditor((s) => s.publish)
21-
const onDidScrollChange = useScriptEditor(
22-
(s: ScriptEditorStore) => s.onDidScrollChange
23-
)
24-
const jumpCursorOnLineClick = useScriptEditor(
25-
(s: { jumpCursorOnLineClick: any }) => s.jumpCursorOnLineClick
26-
)
27-
const highlightElements = useScriptEditor(
28-
(s: { highlightElements: any }) => s.highlightElements
29-
)
30-
const applyClassNameToKeywords = useScriptEditor(
31-
(s: { applyClassNameToKeywords: any }) => s.applyClassNameToKeywords
32-
)
24+
const onDidScrollChange = useScriptEditor((s) => s.onDidScrollChange)
25+
const jumpCursorOnLineClick = useScriptEditor((s) => s.jumpCursorOnLineClick)
26+
const highlightElements = useScriptEditor((s) => s.highlightElements)
3327

34-
const scrollHeight = useScriptEditor(
35-
(s: { scrollHeight: any }) => s.scrollHeight
36-
)
28+
const scrollHeight = useScriptEditor((s) => s.scrollHeight)
3729

38-
const scrollX = useTimeline((s: { scrollX: any }) => s.scrollX)
39-
const contentWidth = useTimeline((s: { contentWidth: any }) => s.contentWidth)
30+
const scrollX = useTimeline((s) => s.scrollX)
31+
const contentWidth = useTimeline((s) => s.contentWidth)
4032
const horizontalTimelineRatio = Math.round(
4133
((scrollX - leftBarTrackScaleWidth) / contentWidth) * scrollHeight - 31
4234
)
@@ -98,38 +90,37 @@ export function ScriptEditor() {
9890
// as an optimization we can use this later, for surgical edits,
9991
// to perform real time updates of the timeline
10092

101-
/* textModel.onDidChangeContent(
102-
(
103-
modelContentChangedEvent: MonacoEditor.editor.IModelContentChangedEvent
104-
) => {
105-
console.log('onDidChangeContent:')
106-
for (const change of modelContentChangedEvent.changes) {
107-
console.log(" - change:", change)
108-
}
109-
}
110-
)
111-
*/
93+
/*
94+
textModel.onDidChangeContent(
95+
(
96+
modelContentChangedEvent: MonacoEditor.editor.IModelContentChangedEvent
97+
) => {
98+
console.log('onDidChangeContent:')
99+
for (const change of modelContentChangedEvent.changes) {
100+
console.log(" - change:", change)
101+
}
102+
}
103+
)
104+
*/
112105
highlightElements()
113106
}
114107

115-
const setMonaco = useScriptEditor((s: { setMonaco: any }) => s.setMonaco)
116-
const setTextModel = useScriptEditor(
117-
(s: { setTextModel: any }) => s.setTextModel
118-
)
119-
const setMouseIsInside = useScriptEditor(
120-
(s: { setMouseIsInside: any }) => s.setMouseIsInside
121-
)
108+
const setMonaco = useScriptEditor((s) => s.setMonaco)
109+
const setTextModel = useScriptEditor((s) => s.setTextModel)
110+
const setMouseIsInside = useScriptEditor((s) => s.setMouseIsInside)
122111
const themeName = useUI((s) => s.themeName)
123112
const editorFontSize = useUI((s) => s.editorFontSize)
124113

125114
const beforeMount = (monaco: Monaco) => {
126115
setMonaco(monaco)
127116

128-
// Create themes
117+
// create our themes
129118
for (const theme of Object.values(themes)) {
119+
// console.log("loading editor theme:", theme)
120+
// Define a custom theme with the provided color palette
130121
monaco.editor.defineTheme(theme.id, {
131-
base: 'vs-dark',
132-
inherit: true,
122+
base: 'vs-dark', // Base theme (you can change to vs for a lighter theme if preferred)
123+
inherit: true, // Inherit the default rules
133124
rules: [
134125
{ token: 'scene.int', foreground: '#4EC9B0' },
135126
{ token: 'scene.ext', foreground: '#9CDCFE' },
@@ -142,17 +133,17 @@ export function ScriptEditor() {
142133
],
143134
colors: {
144135
'editor.background':
145-
theme.editorBgColor || theme.defaultBgColor || '#000000',
136+
theme.editorBgColor || theme.defaultBgColor || '#000000', // Editor background color (given)
146137
'editorCursor.foreground':
147-
theme.editorCursorColor || theme.defaultPrimaryColor || '',
148-
'editor.lineHighlightBackground': '#44403c',
149-
'editorLineNumber.foreground': '#78716c',
150-
'editor.selectionBackground': '#44403c',
138+
theme.editorCursorColor || theme.defaultPrimaryColor || '', // Cursor color
139+
'editor.lineHighlightBackground': '#44403c', // Highlighted line color
140+
'editorLineNumber.foreground': '#78716c', // Line Numbers color
141+
'editor.selectionBackground': '#44403c', // Selection color
151142
'editor.foreground':
152-
theme.editorTextColor || theme.defaultTextColor || '',
153-
'editorIndentGuide.background': '#78716c',
154-
'editorIndentGuide.activeBackground': '#a8a29e',
155-
'editorWhitespace.foreground': '#a8a29e',
143+
theme.editorTextColor || theme.defaultTextColor || '', // Main text color
144+
'editorIndentGuide.background': '#78716c', // Indent guides color
145+
'editorIndentGuide.activeBackground': '#a8a29e', // Active indent guides color
146+
'editorWhitespace.foreground': '#a8a29e', // Whitespace symbols color
156147
},
157148
})
158149
}

0 commit comments

Comments
 (0)