mirror of
				https://github.com/usememos/memos.git
				synced 2025-11-01 01:06:04 +08:00 
			
		
		
		
	feat: automatically add a new table row in the editor when pressing enter (#4706)
Automatically add a new table row in the editor when pressing enter
This commit is contained in:
		
							parent
							
								
									72babbb393
								
							
						
					
					
						commit
						c2528c57f0
					
				
					 1 changed files with 12 additions and 0 deletions
				
			
		|  | @ -192,7 +192,19 @@ const Editor = forwardRef(function Editor(props: Props, ref: React.ForwardedRef< | |||
|       } else if (lastNode.type === NodeType.ORDERED_LIST_ITEM) { | ||||
|         const { number } = lastNode.orderedListItemNode as OrderedListItemNode; | ||||
|         insertText += `${Number(number) + 1}. `; | ||||
|       } else if (lastNode.type === NodeType.TABLE) { | ||||
|         const columns = lastNode.tableNode?.header.length; | ||||
|         if (!columns) { | ||||
|           return; | ||||
|         } | ||||
| 
 | ||||
|         insertText += "| "; | ||||
|         for (let i = 1; i < columns; i++) { | ||||
|           insertText += " | "; | ||||
|         } | ||||
|         insertText += " |"; | ||||
|       } | ||||
| 
 | ||||
|       if (insertText) { | ||||
|         editorActions.insertText(insertText); | ||||
|       } | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue