tldraw/apps/www/components/ReadOnlyMultiplayerEditor.tsx

54 lines
1.2 KiB
TypeScript
Raw Normal View History

1.20.0 (#797) * Edit Farsi translations (#788) * Add a Ukrainian translation (#786) * Add a Ukrainian translation * Clarify some strings in the Ukrainian translation * feat: change dock position (#774) * feat: change dock position * fix grid row and column * add top position * fix responsive for the top position * change content side * fix overflowing menu * [improvement] theme on body (#790) * Update Tldraw.tsx * Add theme on body, adjust dark page options dialog * fix test * Preparing for global integration (#775) * Update translations.ts * Create en.json * Make main translation default * Remove unused locale property of translation Co-authored-by: Steve Ruiz <steveruizok@gmail.com> * Fix language menu * Update ar.json (#793) * feature/add Hebrew translations (#792) * hebrew translations * pr fixes Co-authored-by: Steve Ruiz <steveruizok@gmail.com> * fix toolspanel item position (#791) * fix toolspanel item position * add translation Co-authored-by: Steve Ruiz <steveruizok@gmail.com> * Add remote caching * Adds link to translation guide (#794) * Update ar.json (#795) * [feature] readonly link (#796) * Copy readonly link * Update [id].tsx * Add readonly label * update psuedohash * Update utils.ts Co-authored-by: Baahar Ebrahimi <108254874+Baahaarmast@users.noreply.github.com> Co-authored-by: walking-octopus <46994949+walking-octopus@users.noreply.github.com> Co-authored-by: Judicael <46365844+judicaelandria@users.noreply.github.com> Co-authored-by: Ali Alhaidary <75235623+ali-alhaidary@users.noreply.github.com> Co-authored-by: gadi246 <gadi246@gmail.com>
2022-07-08 13:09:08 +00:00
import { Tldraw, useFileSystem } from '@tldraw/tldraw'
import * as React from 'react'
import { useReadOnlyMultiplayerState } from '~hooks/useReadOnlyMultiplayerState'
import { styled } from '~styles'
import { RoomProvider } from '~utils/liveblocks'
1.20.0 (#797) * Edit Farsi translations (#788) * Add a Ukrainian translation (#786) * Add a Ukrainian translation * Clarify some strings in the Ukrainian translation * feat: change dock position (#774) * feat: change dock position * fix grid row and column * add top position * fix responsive for the top position * change content side * fix overflowing menu * [improvement] theme on body (#790) * Update Tldraw.tsx * Add theme on body, adjust dark page options dialog * fix test * Preparing for global integration (#775) * Update translations.ts * Create en.json * Make main translation default * Remove unused locale property of translation Co-authored-by: Steve Ruiz <steveruizok@gmail.com> * Fix language menu * Update ar.json (#793) * feature/add Hebrew translations (#792) * hebrew translations * pr fixes Co-authored-by: Steve Ruiz <steveruizok@gmail.com> * fix toolspanel item position (#791) * fix toolspanel item position * add translation Co-authored-by: Steve Ruiz <steveruizok@gmail.com> * Add remote caching * Adds link to translation guide (#794) * Update ar.json (#795) * [feature] readonly link (#796) * Copy readonly link * Update [id].tsx * Add readonly label * update psuedohash * Update utils.ts Co-authored-by: Baahar Ebrahimi <108254874+Baahaarmast@users.noreply.github.com> Co-authored-by: walking-octopus <46994949+walking-octopus@users.noreply.github.com> Co-authored-by: Judicael <46365844+judicaelandria@users.noreply.github.com> Co-authored-by: Ali Alhaidary <75235623+ali-alhaidary@users.noreply.github.com> Co-authored-by: gadi246 <gadi246@gmail.com>
2022-07-08 13:09:08 +00:00
interface Props {
roomId: string
}
const ReadOnlyMultiplayerEditor = ({ roomId }: Props) => {
1.20.0 (#797) * Edit Farsi translations (#788) * Add a Ukrainian translation (#786) * Add a Ukrainian translation * Clarify some strings in the Ukrainian translation * feat: change dock position (#774) * feat: change dock position * fix grid row and column * add top position * fix responsive for the top position * change content side * fix overflowing menu * [improvement] theme on body (#790) * Update Tldraw.tsx * Add theme on body, adjust dark page options dialog * fix test * Preparing for global integration (#775) * Update translations.ts * Create en.json * Make main translation default * Remove unused locale property of translation Co-authored-by: Steve Ruiz <steveruizok@gmail.com> * Fix language menu * Update ar.json (#793) * feature/add Hebrew translations (#792) * hebrew translations * pr fixes Co-authored-by: Steve Ruiz <steveruizok@gmail.com> * fix toolspanel item position (#791) * fix toolspanel item position * add translation Co-authored-by: Steve Ruiz <steveruizok@gmail.com> * Add remote caching * Adds link to translation guide (#794) * Update ar.json (#795) * [feature] readonly link (#796) * Copy readonly link * Update [id].tsx * Add readonly label * update psuedohash * Update utils.ts Co-authored-by: Baahar Ebrahimi <108254874+Baahaarmast@users.noreply.github.com> Co-authored-by: walking-octopus <46994949+walking-octopus@users.noreply.github.com> Co-authored-by: Judicael <46365844+judicaelandria@users.noreply.github.com> Co-authored-by: Ali Alhaidary <75235623+ali-alhaidary@users.noreply.github.com> Co-authored-by: gadi246 <gadi246@gmail.com>
2022-07-08 13:09:08 +00:00
return (
<RoomProvider id={roomId}>
<ReadOnlyEditor roomId={roomId} />
1.20.0 (#797) * Edit Farsi translations (#788) * Add a Ukrainian translation (#786) * Add a Ukrainian translation * Clarify some strings in the Ukrainian translation * feat: change dock position (#774) * feat: change dock position * fix grid row and column * add top position * fix responsive for the top position * change content side * fix overflowing menu * [improvement] theme on body (#790) * Update Tldraw.tsx * Add theme on body, adjust dark page options dialog * fix test * Preparing for global integration (#775) * Update translations.ts * Create en.json * Make main translation default * Remove unused locale property of translation Co-authored-by: Steve Ruiz <steveruizok@gmail.com> * Fix language menu * Update ar.json (#793) * feature/add Hebrew translations (#792) * hebrew translations * pr fixes Co-authored-by: Steve Ruiz <steveruizok@gmail.com> * fix toolspanel item position (#791) * fix toolspanel item position * add translation Co-authored-by: Steve Ruiz <steveruizok@gmail.com> * Add remote caching * Adds link to translation guide (#794) * Update ar.json (#795) * [feature] readonly link (#796) * Copy readonly link * Update [id].tsx * Add readonly label * update psuedohash * Update utils.ts Co-authored-by: Baahar Ebrahimi <108254874+Baahaarmast@users.noreply.github.com> Co-authored-by: walking-octopus <46994949+walking-octopus@users.noreply.github.com> Co-authored-by: Judicael <46365844+judicaelandria@users.noreply.github.com> Co-authored-by: Ali Alhaidary <75235623+ali-alhaidary@users.noreply.github.com> Co-authored-by: gadi246 <gadi246@gmail.com>
2022-07-08 13:09:08 +00:00
</RoomProvider>
)
}
// Inner Editor
function ReadOnlyEditor({ roomId }: Props) {
1.20.0 (#797) * Edit Farsi translations (#788) * Add a Ukrainian translation (#786) * Add a Ukrainian translation * Clarify some strings in the Ukrainian translation * feat: change dock position (#774) * feat: change dock position * fix grid row and column * add top position * fix responsive for the top position * change content side * fix overflowing menu * [improvement] theme on body (#790) * Update Tldraw.tsx * Add theme on body, adjust dark page options dialog * fix test * Preparing for global integration (#775) * Update translations.ts * Create en.json * Make main translation default * Remove unused locale property of translation Co-authored-by: Steve Ruiz <steveruizok@gmail.com> * Fix language menu * Update ar.json (#793) * feature/add Hebrew translations (#792) * hebrew translations * pr fixes Co-authored-by: Steve Ruiz <steveruizok@gmail.com> * fix toolspanel item position (#791) * fix toolspanel item position * add translation Co-authored-by: Steve Ruiz <steveruizok@gmail.com> * Add remote caching * Adds link to translation guide (#794) * Update ar.json (#795) * [feature] readonly link (#796) * Copy readonly link * Update [id].tsx * Add readonly label * update psuedohash * Update utils.ts Co-authored-by: Baahar Ebrahimi <108254874+Baahaarmast@users.noreply.github.com> Co-authored-by: walking-octopus <46994949+walking-octopus@users.noreply.github.com> Co-authored-by: Judicael <46365844+judicaelandria@users.noreply.github.com> Co-authored-by: Ali Alhaidary <75235623+ali-alhaidary@users.noreply.github.com> Co-authored-by: gadi246 <gadi246@gmail.com>
2022-07-08 13:09:08 +00:00
const { onSaveProjectAs, onSaveProject } = useFileSystem()
const { error, ...events } = useReadOnlyMultiplayerState(roomId)
if (error) return <LoadingScreen>Error: {error.message}</LoadingScreen>
return (
<div className="tldraw">
<Tldraw
autofocus
disableAssets={false}
showPages={false}
onSaveProjectAs={onSaveProjectAs}
onSaveProject={onSaveProject}
readOnly
{...events}
/>
</div>
)
}
export default ReadOnlyMultiplayerEditor
const LoadingScreen = styled('div', {
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
})