Merge pull request #15637 from germanocaumo/tldraw-disable-select
fix(tldraw): disable selecting shapes on certain cases
This commit is contained in:
commit
e413499bb9
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user