Merge pull request #15637 from germanocaumo/tldraw-disable-select

fix(tldraw): disable selecting shapes on certain cases
This commit is contained in:
Ramón Souza 2022-09-21 16:46:26 -03:00 committed by GitHub
commit e413499bb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -316,6 +316,22 @@ export default function Whiteboard(props) {
`set_hovered_id`
);
};
// disable selecting background slide shape
app.setSelectedIds = (ids) => {
ids = ids.filter(id => !id.includes('slide-background'))
app.patchState(
{
document: {
pageStates: {
[app.getPage()?.id]: {
selectedIds: ids || [],
},
},
},
},
`selected`
);
};
}
if (curPageId) {
@ -377,6 +393,23 @@ export default function Whiteboard(props) {
const zoom = calculateZoom(slidePosition.viewBoxWidth, slidePosition.viewBoxHeight)
tldrawAPI?.setCamera([slidePosition.x, slidePosition.y], zoom);
}
// disable select for non presenter that doesn't have multi user access
if (!hasWBAccess && !isPresenter) {
if (e?.getPageState()?.brush || e?.selectedIds?.length !== 0) {
e.patchState(
{
document: {
pageStates: {
[e?.currentPageId]: {
selectedIds: [],
brush: null,
},
},
},
},
);
}
}
if (reason && reason === 'patched_shapes') {
const patchedShape = e?.getShape(e?.getPageState()?.editingId);