EditorSproutyDialogsTextEditor
Inherits: Panel
Description
The text editor component is a panel that allows the user to add text effects, font styles, colors and others using BBCode tags in a user friendly way.
The text editor is shown when the user clicks on a expand button from a ExpandableTextBox.
Methods
| Return Type | Method |
|---|---|
| CodeEdit | get_text_input() |
| void | show_text_editor(text_box: Variant) |
| void | update_text_editor(text_box: Variant) |
| void | hide_text_editor() |
| void | change_option_bar(bar_index: int) |
| Array[Vector2i] | get_selected_text_position() |
| Array[Vector2i] | find_tags_around_cursor(open_tag: String, close_tag: String) |
| void | insert_tags_on_selected_text(open_tag: String, close_tag: String, add_on_empty: bool, placeholder: String) |
| void | insert_tags_at_cursor_pos(open_tag: String, close_tag: String) |
| void | update_code_tags(open_tag: String, close_tag: String, ignore_attr: String, add_on_empty: bool, add_another_tag: Array) |
| void | add_attribute_to_tag(tag_name: String, attr: String, value: Variant, default-value: Variant) |
Method Descriptions
func get_text_input() -> CodeEdit
Return the text input from the text editor.
func show_text_editor(text_box: Variant) -> void
Show the text editor. Needs a LineEdit or TextEdit from where to get and update the text.
func update_text_editor(text_box: Variant) -> void
Update the text editor with the text box content. If the text editor is visible and a different text box is provided, switches to editing that text box's content.
func hide_text_editor() -> void
Hide the text editor and clear its content.
func change_option_bar(bar_index: int) -> void
Change the current option bar shown in the text editor. Different option bars provide different formatting tools (text styles, colors, outline, variables, URLs, etc.).
func get_selected_text_position() -> Array[Vector2i]
Get the position of the selected text in the text input. Returns an array of two Vector2i elements: the first is the start position (column, line) and the second is the end position (column, line).
func find_tags_around_cursor(open_tag: String, close_tag: String) -> Array[Vector2i]
Find the given tags around the cursor position. Returns an array with the positions of the opening and closing tags, or an empty array if tags are not found around the cursor.
func insert_tags_on_selected_text(open_tag: String, close_tag: String, add_on_empty: bool = false, placeholder: String = "") -> void
Insert tags in the selected text. If there is no text selected, do nothing or add tags with a placeholder. If add_on_empty is true, the placeholder will be added between the tags.
func insert_tags_at_cursor_pos(open_tag: String, close_tag: String) -> void
Insert tags at the cursor position without requiring selected text.
func update_code_tags(open_tag: String, close_tag: String, ignore_attr: String = "", add_on_empty: bool = false, add_another_tag: Array = []) -> void
Update the code tags in the selected text. With ignore_attr you can specify an attribute that will not be updated. If there is no text selected, do nothing or add tags with a placeholder if add_on_empty is true. For some cases, an additional tag can be added using add_another_tag array with the open and close tag strings.
func add_attribute_to_tag(tag_name: String, attr: String, value: Variant, default-value: Variant) -> void
Add a tag attribute to the selected text. If the value is the default value, the attribute will be removed from the tag.