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 select all if double hit cmd-a

+24
+24
components/Blocks/TextBlock/keymap.ts
··· 15 15 import { v7 } from "uuid"; 16 16 import { scanIndex } from "src/replicache/utils"; 17 17 import { indent, outdent } from "src/utils/list-operations"; 18 + import { getBlocksWithType } from "src/hooks/queries/useBlocks"; 18 19 19 20 type PropsRef = MutableRefObject<BlockProps & { entity_set: { set: string } }>; 20 21 export const TextBlockKeymap = ( ··· 32 33 "Ctrl-Meta-h": toggleMark(schema.marks.highlight, { 33 34 color: useUIState.getState().lastUsedHighlight, 34 35 }), 36 + "Meta-a": (state, _dispatch, view) => { 37 + const { from, to } = state.selection; 38 + // Check if the entire content of the blockk is selected 39 + const isFullySelected = from === 0 && to === state.doc.content.size; 40 + 41 + if (!isFullySelected) { 42 + // If the entire block is selected, we don't need to do anything 43 + return false 44 + } else { 45 + // Remove the selection 46 + view?.dispatch(state.tr.setSelection(TextSelection.create(state.doc, from))); 47 + view?.dom.blur() 48 + repRef.current?.query(async tx=>{ 49 + let allBlocks = await getBlocksWithType(tx, propsRef.current.parent) ||[] 50 + console.log("allBlocks", allBlocks) 51 + useUIState.setState({ 52 + selectedBlock: allBlocks.map(b=>({value: b.value, parent: propsRef.current.parent})) 53 + }) 54 + }) 55 + return true 56 + } 57 + 58 + }, 35 59 Tab: () => { 36 60 if (useUIState.getState().selectedBlock.length > 1) return false; 37 61 if (!repRef.current || !propsRef.current.previousBlock) return false;