-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
339 additions
and
91 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/apps/client/src/BackendPlayground/BackendPlayground.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React, { useContext } from 'react' | ||
import { TestInterface } from '../TestInterface' | ||
import { TestPlaylists } from '../TestPlaylists' | ||
import { APIConnectionContext } from '../api/ApiConnectionContext' | ||
|
||
export function BackendPlayground(): React.JSX.Element { | ||
const api = useContext(APIConnectionContext) | ||
|
||
return ( | ||
<> | ||
<div> | ||
<TestInterface api={api} /> | ||
</div> | ||
<div> | ||
<TestPlaylists api={api} /> | ||
</div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/apps/client/src/MobXPlayground/MobXPlayground.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { CurrentRundown } from '../CurrentRundown/CurrentRundown' | ||
import { RundownList } from '../RundownList/RundownList' | ||
|
||
export function MobXPlayground(): React.JSX.Element { | ||
return ( | ||
<> | ||
<div> | ||
<RundownList /> | ||
</div> | ||
<div> | ||
<CurrentRundown /> | ||
</div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React, { useEffect, useRef } from 'react' | ||
import { schema } from 'prosemirror-schema-basic' | ||
import { undo, redo, history } from 'prosemirror-history' | ||
import { keymap } from 'prosemirror-keymap' | ||
import { EditorState } from 'prosemirror-state' | ||
import { EditorView } from 'prosemirror-view' | ||
import { baseKeymap } from 'prosemirror-commands' | ||
|
||
export function Editor({ | ||
initialValue, | ||
}: { | ||
initialValue?: string | ||
onChange?: (e: OnChangeEvent) => void | ||
}): React.JSX.Element { | ||
const containerEl = useRef<HTMLDivElement>(null) | ||
const editorView = useRef<EditorView>() | ||
const editorState = useRef<EditorState>() | ||
|
||
void initialValue | ||
|
||
useEffect(() => { | ||
if (!containerEl.current) return | ||
|
||
const state = EditorState.create({ schema }) | ||
const view = new EditorView(containerEl.current, { | ||
state, | ||
plugins: [history(), keymap({ 'Mod-z': undo, 'Mod-y': redo }), keymap(baseKeymap)], | ||
}) | ||
|
||
editorView.current = view | ||
editorState.current = state | ||
}, []) | ||
|
||
return <div ref={containerEl}></div> | ||
} | ||
|
||
type OnChangeEvent = { | ||
value: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react' | ||
import { Editor } from './Editor' | ||
|
||
export function ScriptEditor(): React.JSX.Element { | ||
return ( | ||
<> | ||
<Editor /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react' | ||
import { APIConnection } from './ApiConnection' | ||
import { assertType } from '@sofie-prompter-editor/shared-lib' | ||
import { RundownPlaylist, RundownPlaylistId } from '@sofie-prompter-editor/shared-model' | ||
|
||
const api = new APIConnection() | ||
api.on('connected', () => console.log('connected')) | ||
api.on('disconnected', () => console.log('disconnected')) | ||
|
||
api.playlist.on('tmpPong', (payload) => { | ||
assertType<string>(payload) | ||
console.log(`Got a tmpPong message: "${payload}"`) | ||
}) | ||
api.playlist.on('created', (payload) => { | ||
assertType<RundownPlaylist>(payload) | ||
console.log(`playlist created: "${JSON.stringify(payload)}"`) | ||
}) | ||
api.playlist.on('patched', (payload) => { | ||
assertType<Partial<RundownPlaylist>>(payload) | ||
console.log(`playlist patched: "${JSON.stringify(payload)}"`) | ||
}) | ||
api.playlist.on('updated', (payload) => { | ||
assertType<RundownPlaylist>(payload) | ||
console.log(`playlist updated: "${JSON.stringify(payload)}"`) | ||
}) | ||
api.playlist.on('removed', (id) => { | ||
assertType<RundownPlaylistId>(id) | ||
console.log(`playlist removed: "${id}"`) | ||
}) | ||
api.example.on('pongGeneric', (payload) => { | ||
assertType<string>(payload) | ||
console.log(`Got a pongGeneric message: "${payload}"`) | ||
}) | ||
api.example.on('pongCategory', (message) => { | ||
console.log(`Got a pongCategory "${message.category}" message: "${message.payload}"`) | ||
}) | ||
|
||
export const APIConnectionContext = React.createContext<APIConnection>(api) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.