a tool for shared writing and social publishing
0
fork

Configure Feed

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

fix undo issues and undo grouping

+7 -21
+3 -16
components/Blocks/TextBlock/index.tsx
··· 254 254 }, 255 255 dispatchTransaction(tr) { 256 256 useEditorStates.setState((s) => { 257 + let oldEditorState = this.state; 257 258 let newState = this.state.apply(tr); 258 259 let addToHistory = tr.getMeta("addToHistory"); 259 260 let docHasChanges = tr.steps.length !== 0 || tr.docChanged; ··· 293 294 ...oldState.editorStates, 294 295 [props.entityID]: { 295 296 ...oldState.editorStates[props.entityID]!, 296 - editor: this.state, 297 + editor: oldEditorState, 297 298 }, 298 299 }, 299 300 }; ··· 328 329 }, 329 330 })); 330 331 }; 331 - }, [props.entityID, props.parent, value, handlePaste]); 332 + }, [props.entityID, props.parent, value, handlePaste, rep]); 332 333 333 334 return ( 334 335 <> ··· 342 343 rep.undoManager.endGroup(); 343 344 window.clearTimeout(actionTimeout.current); 344 345 actionTimeout.current = null; 345 - if (editorState?.doc.textContent.startsWith("http")) { 346 - await addLinkBlock( 347 - editorState.doc.textContent, 348 - props.entityID, 349 - rep.rep, 350 - ); 351 - } 352 - // if (editorState.doc.textContent.startsWith("http")) { 353 - // await addLinkBlock( 354 - // editorState.doc.textContent, 355 - // props.entityID, 356 - // rep.rep, 357 - // ); 358 - // } 359 346 } 360 347 }} 361 348 onFocus={() => {
+4 -5
components/Blocks/useBlockKeyboardHandlers.ts
··· 58 58 ) { 59 59 if ((el as HTMLInputElement).value !== "" || e.key === "Tab") return; 60 60 } 61 + if (!AllowedIfTextBlock.includes(e.key) && isTextBlock[props.type]) 62 + return; 61 63 62 64 undoManager.startGroup(); 63 65 command?.({ ··· 86 88 setAreYouSure: (value: boolean) => void; 87 89 }; 88 90 91 + const AllowedIfTextBlock = ["Tab"]; 92 + 89 93 function Tab({ e, props, rep }: Args) { 90 94 // if tab or shift tab, indent or outdent 91 95 if (e.shiftKey) { ··· 101 105 if (args.e.ctrlKey || args.e.metaKey) ArrowDown(args); 102 106 } 103 107 function ArrowDown({ e, props }: Args) { 104 - if (isTextBlock[props.type]) return; 105 108 e.preventDefault(); 106 109 let nextBlock = props.nextBlock; 107 110 if (nextBlock && useUIState.getState().selectedBlocks.length <= 1) ··· 116 119 if (args.e.ctrlKey || args.e.metaKey) ArrowUp(args); 117 120 } 118 121 function ArrowUp({ e, props }: Args) { 119 - if (isTextBlock[props.type]) return; 120 122 e.preventDefault(); 121 123 let prevBlock = props.previousBlock; 122 124 if (prevBlock && useUIState.getState().selectedBlocks.length <= 1) { ··· 139 141 }: Args) { 140 142 // if this is a textBlock, let the textBlock/keymap handle the backspace 141 143 if (isLocked) return; 142 - if (isTextBlock[props.type]) return; 143 144 // if its an input, label, or teatarea with content, do nothing (do the broswer default instead) 144 145 let el = e.target as HTMLElement; 145 146 if ( ··· 189 190 } 190 191 191 192 async function Enter({ e, props, rep, entity_set }: Args) { 192 - if (isTextBlock[props.type]) return; 193 193 let newEntityID = v7(); 194 194 let position; 195 195 let el = e.target as HTMLElement; ··· 279 279 } 280 280 281 281 function Escape({ e, props, areYouSure, setAreYouSure }: Args) { 282 - if (isTextBlock[props.type]) return; 283 282 e.preventDefault(); 284 283 if (areYouSure) { 285 284 setAreYouSure(false);