a tool for shared writing and social publishing
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add some more permission checking

+5 -1
+2
components/Blocks/index.tsx
··· 204 204 if (!block) return; 205 205 } 206 206 if (e.key === "Backspace") { 207 + if (!entity_set.permissions.write) return; 207 208 if (textBlocks[props.type]) return; 208 209 e.preventDefault(); 209 210 r.mutate.removeBlock({ blockEntity: props.entityID }); ··· 213 214 } 214 215 if (e.key === "Enter") { 215 216 let newEntityID = v7(); 217 + if (!entity_set.permissions.write) return; 216 218 r.mutate.addBlock({ 217 219 permission_set: entity_set.set, 218 220 newEntityID,
+3 -1
components/SelectionManager.tsx
··· 7 7 import { scanIndex } from "src/replicache/utils"; 8 8 import { focusBlock } from "./Blocks"; 9 9 import { useEditorStates } from "src/state/useEditorState"; 10 + import { useEntitySetContext } from "./EntitySetProvider"; 10 11 export const useSelectingMouse = create(() => ({ 11 12 start: null as null | string, 12 13 })); ··· 16 17 17 18 export function SelectionManager() { 18 19 let moreThanOneSelected = useUIState((s) => s.selectedBlock.length > 1); 20 + let entity_set = useEntitySetContext(); 19 21 let { rep } = useReplicache(); 20 22 useEffect(() => { 21 23 let listener = async (e: KeyboardEvent) => { 22 24 if (e.key === "Backspace" || e.key === "Delete") { 25 + if (!entity_set.permissions.write) return; 23 26 if (moreThanOneSelected) { 24 27 let selectedBlocks = useUIState.getState().selectedBlock; 25 28 let firstBlock = selectedBlocks.sort((a, b) => ··· 254 257 }, [moreThanOneSelected, rep]); 255 258 256 259 let [mouseDown, setMouseDown] = useState(false); 257 - let dragStart = useSelectingMouse((s) => s.start); 258 260 let initialContentEditableParent = useRef<null | Node>(null); 259 261 let savedSelection = useRef<SavedRange[] | null>(); 260 262 useEffect(() => {