-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add etherpad UI components (#206)
* feat: add etherpad iframe, improve H5P security * feat: add etherpad icon * fix: pass styles to etherpad iframe * fix: allow etherpad iframe to ring service server * chore: bump @graasp/sdk
- Loading branch information
Alexandre Chau
authored
Jan 6, 2023
1 parent
92535f8
commit 5c6bf3f
Showing
6 changed files
with
78 additions
and
8 deletions.
There are no files selected for viewing
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
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,61 @@ | ||
import React, { FC } from 'react'; | ||
|
||
import { SCREEN_MAX_HEIGHT } from '../constants'; | ||
|
||
/** | ||
* @see https://etherpad.org/doc/v1.8.18/#index_embed-parameters | ||
*/ | ||
type EtherpadEmbedOptions = { | ||
showLineNumbers?: boolean; | ||
showControls?: boolean; | ||
showChat?: boolean; | ||
useMonospaceFont?: boolean; | ||
userName?: string; | ||
userColor?: string; | ||
noColors?: boolean; | ||
alwaysShowChat?: boolean; | ||
lang?: string; | ||
rtl?: boolean; | ||
'#L'?: number; | ||
}; | ||
|
||
interface EtherpadItemProps { | ||
itemId: string; | ||
padUrl: string; | ||
iframeId?: string; | ||
options?: EtherpadEmbedOptions; | ||
style?: React.CSSProperties; | ||
} | ||
|
||
const EtherpadItem: FC<EtherpadItemProps> = ({ | ||
itemId, | ||
padUrl, | ||
iframeId = `etherpad-container-${itemId}`, | ||
options, | ||
style, | ||
}) => { | ||
const src = new URL(padUrl); | ||
if (options) { | ||
Object.entries(options).forEach(([param, value]) => | ||
src.searchParams.set(param, String(value)), | ||
); | ||
} | ||
|
||
return ( | ||
<iframe | ||
id={iframeId} | ||
src={src.href} | ||
frameBorder={0} | ||
sandbox='allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-presentation allow-scripts allow-same-origin' | ||
style={{ | ||
width: '100%', | ||
height: SCREEN_MAX_HEIGHT, | ||
border: 'none', | ||
display: 'block', | ||
...style, | ||
}} | ||
></iframe> | ||
); | ||
}; | ||
|
||
export default EtherpadItem; |
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
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