27 lines
		
	
	
	
		
			587 B
		
	
	
	
		
			GDScript
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
	
		
			587 B
		
	
	
	
		
			GDScript
		
	
	
	
	
	
| class_name MarkdownTextEdit extends TextEdit
 | |
| 
 | |
| @export var h1 = HeaderFormat.new() : set = _set_h1_format
 | |
| 
 | |
| var _converted_text: String
 | |
| 
 | |
| func _ready() -> void:
 | |
| 	h1.changed.connect(_update)
 | |
| 	
 | |
| 	
 | |
| # Called every frame. 'delta' is the elapsed time since the previous frame.
 | |
| func _process(delta: float) -> void:
 | |
| 	pass
 | |
| 
 | |
| 
 | |
| func _update() -> void:
 | |
| 	text = _convert_markdown(markdown_text)
 | |
| 	queue_redraw()
 | |
| 	
 | |
| func _set_h1_format(new_format: HeaderFormat) -> void:
 | |
| 	h1 = new_format
 | |
| 	_update()
 | |
| 	
 | |
| func _convert_markdown(text: String = "") -> String:
 | |
| 	_converted_text = ""
 | |
| 	var lines = text.split("\n")
 | |
| 	
 |