a tool for shared writing and social publishing
0
fork

Configure Feed

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

added lastHighlightColor as a UIState so that we can use it in the highlight keyboard shortcut

celine 6ad39d18 2bfdc3c7

+14 -5
+3 -1
components/Blocks/TextBlock/keymap.ts
··· 26 26 "Meta-u": toggleMark(schema.marks.underline), 27 27 "Meta-i": toggleMark(schema.marks.em), 28 28 "Ctrl-Meta-x": toggleMark(schema.marks.strikethrough), 29 - "Ctrl-Meta-h": toggleMark(schema.marks.highlight), 29 + "Ctrl-Meta-h": toggleMark(schema.marks.highlight, { 30 + color: useUIState.getState().lastUsedHighlight, 31 + }), 30 32 Tab: () => { 31 33 if (useUIState.getState().selectedBlock.length > 1) return false; 32 34 if (!repRef.current || !propsRef.current.previousBlock) return false;
+10 -4
components/Toolbar/index.tsx
··· 45 45 "default" | "highlight" | "link" | "header" | "list" | "linkBlock" 46 46 >("default"); 47 47 48 - let [lastUsedHighlight, setlastUsedHighlight] = useState<"1" | "2" | "3">( 49 - "1", 50 - ); 48 + // let [lastUsedHighlight, setlastUsedHighlight] = useState<"1" | "2" | "3">( 49 + // "1", 50 + // ); 51 + 52 + let lastUsedHighlight = useUIState((s) => s.lastUsedHighlight); 53 + let setLastUsedHighlight = (color: "1" | "2" | "3") => 54 + useUIState.setState({ 55 + lastUsedHighlight: color, 56 + }); 51 57 52 58 let activeEditor = useEditorStates((s) => s.editorStates[props.blockID]); 53 59 ··· 184 190 onClose={() => setToolbarState("default")} 185 191 lastUsedHighlight={lastUsedHighlight} 186 192 setLastUsedHighlight={(color: "1" | "2" | "3") => 187 - setlastUsedHighlight(color) 193 + setLastUsedHighlight(color) 188 194 } 189 195 /> 190 196 ) : toolbarState === "link" ? (
+1
src/useUIState.ts
··· 6 6 export const useUIState = create( 7 7 combine( 8 8 { 9 + lastUsedHighlight: "1" as "1" | "2" | "3", 9 10 focusedBlock: null as 10 11 | { type: "card"; entityID: string } 11 12 | { type: "block"; entityID: string; parent: string }