From 7a0b678fc2e41dc5fa446154f12de7ae9cefb742 Mon Sep 17 00:00:00 2001 From: Face <69168154+face-hh@users.noreply.github.com> Date: Wed, 23 Jul 2025 13:35:42 +0300 Subject: [PATCH] h1, h2, h3, h4, h5, h6 tags --- Scenes/Tags/h1.tscn | 22 ++++++++ Scenes/Tags/h2.tscn | 22 ++++++++ Scenes/Tags/h3.tscn | 22 ++++++++ Scenes/Tags/h4.tscn | 22 ++++++++ Scenes/Tags/h5.tscn | 22 ++++++++ Scenes/Tags/h6.tscn | 22 ++++++++ Scripts/B9/HTMLParser.gd | 3 ++ Scripts/Tags/h1.gd | 7 +++ Scripts/Tags/h1.gd.uid | 1 + Scripts/Tags/h2.gd | 7 +++ Scripts/Tags/h2.gd.uid | 1 + Scripts/Tags/h3.gd | 7 +++ Scripts/Tags/h3.gd.uid | 1 + Scripts/Tags/h4.gd | 7 +++ Scripts/Tags/h4.gd.uid | 1 + Scripts/Tags/h5.gd | 7 +++ Scripts/Tags/h5.gd.uid | 1 + Scripts/Tags/h6.gd | 7 +++ Scripts/Tags/h6.gd.uid | 1 + Scripts/main.gd | 49 ++++++++++++++++++ ...godotgif.windows.template_debug.x86_64.dll | Bin 0 -> 516608 bytes 21 files changed, 232 insertions(+) create mode 100644 Scenes/Tags/h1.tscn create mode 100644 Scenes/Tags/h2.tscn create mode 100644 Scenes/Tags/h3.tscn create mode 100644 Scenes/Tags/h4.tscn create mode 100644 Scenes/Tags/h5.tscn create mode 100644 Scenes/Tags/h6.tscn create mode 100644 Scripts/Tags/h1.gd create mode 100644 Scripts/Tags/h1.gd.uid create mode 100644 Scripts/Tags/h2.gd create mode 100644 Scripts/Tags/h2.gd.uid create mode 100644 Scripts/Tags/h3.gd create mode 100644 Scripts/Tags/h3.gd.uid create mode 100644 Scripts/Tags/h4.gd create mode 100644 Scripts/Tags/h4.gd.uid create mode 100644 Scripts/Tags/h5.gd create mode 100644 Scripts/Tags/h5.gd.uid create mode 100644 Scripts/Tags/h6.gd create mode 100644 Scripts/Tags/h6.gd.uid create mode 100644 godotgif/bin/~godotgif.windows.template_debug.x86_64.dll diff --git a/Scenes/Tags/h1.tscn b/Scenes/Tags/h1.tscn new file mode 100644 index 0000000..8a22d73 --- /dev/null +++ b/Scenes/Tags/h1.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=3 format=3 uid="uid://gta3tqpcfrpf"] + +[ext_resource type="Script" uid="uid://fxad8ggthycp" path="res://Scripts/Tags/h1.gd" id="1_d7u74"] +[ext_resource type="Theme" uid="uid://bn6rbmdy60lhr" path="res://Scenes/Styles/BrowserText.tres" id="2_3j5k0"] + +[node name="H1" type="VBoxContainer"] +anchors_preset = 10 +anchor_right = 1.0 +grow_horizontal = 2 +script = ExtResource("1_d7u74") + +[node name="RichTextLabel" type="RichTextLabel" parent="."] +layout_mode = 2 +size_flags_horizontal = 3 +focus_mode = 2 +mouse_default_cursor_shape = 1 +theme = ExtResource("2_3j5k0") +theme_override_colors/default_color = Color(0, 0, 0, 1) +bbcode_enabled = true +text = "Placeholder" +fit_content = true +selection_enabled = true diff --git a/Scenes/Tags/h2.tscn b/Scenes/Tags/h2.tscn new file mode 100644 index 0000000..ed22c91 --- /dev/null +++ b/Scenes/Tags/h2.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=3 format=3 uid="uid://cgsn36srgjt8"] + +[ext_resource type="Script" uid="uid://bdq7nrg2l36nh" path="res://Scripts/Tags/h2.gd" id="1_vk1fi"] +[ext_resource type="Theme" uid="uid://bn6rbmdy60lhr" path="res://Scenes/Styles/BrowserText.tres" id="2_q3fx7"] + +[node name="H2" type="VBoxContainer"] +anchors_preset = 10 +anchor_right = 1.0 +grow_horizontal = 2 +script = ExtResource("1_vk1fi") + +[node name="RichTextLabel" type="RichTextLabel" parent="."] +layout_mode = 2 +size_flags_horizontal = 3 +focus_mode = 2 +mouse_default_cursor_shape = 1 +theme = ExtResource("2_q3fx7") +theme_override_colors/default_color = Color(0, 0, 0, 1) +bbcode_enabled = true +text = "Placeholder" +fit_content = true +selection_enabled = true diff --git a/Scenes/Tags/h3.tscn b/Scenes/Tags/h3.tscn new file mode 100644 index 0000000..fb5eeb7 --- /dev/null +++ b/Scenes/Tags/h3.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=3 format=3 uid="uid://di6midc3a0ddy"] + +[ext_resource type="Script" uid="uid://cnlm4o4aul6um" path="res://Scripts/Tags/h3.gd" id="1_chgqi"] +[ext_resource type="Theme" uid="uid://bn6rbmdy60lhr" path="res://Scenes/Styles/BrowserText.tres" id="2_qca7w"] + +[node name="H3" type="VBoxContainer"] +anchors_preset = 10 +anchor_right = 1.0 +grow_horizontal = 2 +script = ExtResource("1_chgqi") + +[node name="RichTextLabel" type="RichTextLabel" parent="."] +layout_mode = 2 +size_flags_horizontal = 3 +focus_mode = 2 +mouse_default_cursor_shape = 1 +theme = ExtResource("2_qca7w") +theme_override_colors/default_color = Color(0, 0, 0, 1) +bbcode_enabled = true +text = "Placeholder" +fit_content = true +selection_enabled = true diff --git a/Scenes/Tags/h4.tscn b/Scenes/Tags/h4.tscn new file mode 100644 index 0000000..e09950d --- /dev/null +++ b/Scenes/Tags/h4.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=3 format=3 uid="uid://di4rd8y76rwrq"] + +[ext_resource type="Script" uid="uid://j68a278yusxa" path="res://Scripts/Tags/h4.gd" id="1_jrcwo"] +[ext_resource type="Theme" uid="uid://bn6rbmdy60lhr" path="res://Scenes/Styles/BrowserText.tres" id="2_t8dmp"] + +[node name="H4" type="VBoxContainer"] +anchors_preset = 10 +anchor_right = 1.0 +grow_horizontal = 2 +script = ExtResource("1_jrcwo") + +[node name="RichTextLabel" type="RichTextLabel" parent="."] +layout_mode = 2 +size_flags_horizontal = 3 +focus_mode = 2 +mouse_default_cursor_shape = 1 +theme = ExtResource("2_t8dmp") +theme_override_colors/default_color = Color(0, 0, 0, 1) +bbcode_enabled = true +text = "Placeholder" +fit_content = true +selection_enabled = true diff --git a/Scenes/Tags/h5.tscn b/Scenes/Tags/h5.tscn new file mode 100644 index 0000000..05a041e --- /dev/null +++ b/Scenes/Tags/h5.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=3 format=3 uid="uid://2rirrb0genlv"] + +[ext_resource type="Script" uid="uid://648taty6aixn" path="res://Scripts/Tags/h5.gd" id="1_02y7j"] +[ext_resource type="Theme" uid="uid://bn6rbmdy60lhr" path="res://Scenes/Styles/BrowserText.tres" id="2_msjhe"] + +[node name="H5" type="VBoxContainer"] +anchors_preset = 10 +anchor_right = 1.0 +grow_horizontal = 2 +script = ExtResource("1_02y7j") + +[node name="RichTextLabel" type="RichTextLabel" parent="."] +layout_mode = 2 +size_flags_horizontal = 3 +focus_mode = 2 +mouse_default_cursor_shape = 1 +theme = ExtResource("2_msjhe") +theme_override_colors/default_color = Color(0, 0, 0, 1) +bbcode_enabled = true +text = "Placeholder" +fit_content = true +selection_enabled = true diff --git a/Scenes/Tags/h6.tscn b/Scenes/Tags/h6.tscn new file mode 100644 index 0000000..8e0f145 --- /dev/null +++ b/Scenes/Tags/h6.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=3 format=3 uid="uid://bc0gy4dxuaaii"] + +[ext_resource type="Script" uid="uid://tv6sv6og67q6" path="res://Scripts/Tags/h6.gd" id="1_eqyqa"] +[ext_resource type="Theme" uid="uid://bn6rbmdy60lhr" path="res://Scenes/Styles/BrowserText.tres" id="2_4427h"] + +[node name="H6" type="VBoxContainer"] +anchors_preset = 10 +anchor_right = 1.0 +grow_horizontal = 2 +script = ExtResource("1_eqyqa") + +[node name="RichTextLabel" type="RichTextLabel" parent="."] +layout_mode = 2 +size_flags_horizontal = 3 +focus_mode = 2 +mouse_default_cursor_shape = 1 +theme = ExtResource("2_4427h") +theme_override_colors/default_color = Color(0, 0, 0, 1) +bbcode_enabled = true +text = "Placeholder" +fit_content = true +selection_enabled = true diff --git a/Scripts/B9/HTMLParser.gd b/Scripts/B9/HTMLParser.gd index 6b91fdf..d99a853 100644 --- a/Scripts/B9/HTMLParser.gd +++ b/Scripts/B9/HTMLParser.gd @@ -80,6 +80,9 @@ class HTMLElement: func is_inline_element() -> bool: return tag_name in ["b", "i", "u", "small", "mark", "code", "span", "a"] + + func is_heading_element() -> bool: + return tag_name in ["h1", "h2", "h3", "h4", "h5", "h6"] class ParseResult: var root: HTMLElement diff --git a/Scripts/Tags/h1.gd b/Scripts/Tags/h1.gd new file mode 100644 index 0000000..e46813e --- /dev/null +++ b/Scripts/Tags/h1.gd @@ -0,0 +1,7 @@ +extends Control + +@onready var rich_text_label: RichTextLabel = $RichTextLabel + +func init(element: HTMLParser.HTMLElement) -> void: + var label: RichTextLabel = $RichTextLabel + label.text = "[font_size=48][b]%s[/b][/font_size]" % element.get_bbcode_formatted_text() diff --git a/Scripts/Tags/h1.gd.uid b/Scripts/Tags/h1.gd.uid new file mode 100644 index 0000000..2a0146b --- /dev/null +++ b/Scripts/Tags/h1.gd.uid @@ -0,0 +1 @@ +uid://fxad8ggthycp diff --git a/Scripts/Tags/h2.gd b/Scripts/Tags/h2.gd new file mode 100644 index 0000000..02f3a68 --- /dev/null +++ b/Scripts/Tags/h2.gd @@ -0,0 +1,7 @@ +extends Control + +@onready var rich_text_label: RichTextLabel = $RichTextLabel + +func init(element: HTMLParser.HTMLElement) -> void: + var label: RichTextLabel = $RichTextLabel + label.text = "[font_size=36][b]%s[/b][/font_size]" % element.get_bbcode_formatted_text() diff --git a/Scripts/Tags/h2.gd.uid b/Scripts/Tags/h2.gd.uid new file mode 100644 index 0000000..743064c --- /dev/null +++ b/Scripts/Tags/h2.gd.uid @@ -0,0 +1 @@ +uid://bdq7nrg2l36nh diff --git a/Scripts/Tags/h3.gd b/Scripts/Tags/h3.gd new file mode 100644 index 0000000..b16fa8f --- /dev/null +++ b/Scripts/Tags/h3.gd @@ -0,0 +1,7 @@ +extends Control + +@onready var rich_text_label: RichTextLabel = $RichTextLabel + +func init(element: HTMLParser.HTMLElement) -> void: + var label: RichTextLabel = $RichTextLabel + label.text = "[font_size=28][b]%s[/b][/font_size]" % element.get_bbcode_formatted_text() diff --git a/Scripts/Tags/h3.gd.uid b/Scripts/Tags/h3.gd.uid new file mode 100644 index 0000000..187c821 --- /dev/null +++ b/Scripts/Tags/h3.gd.uid @@ -0,0 +1 @@ +uid://cnlm4o4aul6um diff --git a/Scripts/Tags/h4.gd b/Scripts/Tags/h4.gd new file mode 100644 index 0000000..ed415f4 --- /dev/null +++ b/Scripts/Tags/h4.gd @@ -0,0 +1,7 @@ +extends Control + +@onready var rich_text_label: RichTextLabel = $RichTextLabel + +func init(element: HTMLParser.HTMLElement) -> void: + var label: RichTextLabel = $RichTextLabel + label.text = "[font_size=24][b]%s[/b][/font_size]" % element.get_bbcode_formatted_text() diff --git a/Scripts/Tags/h4.gd.uid b/Scripts/Tags/h4.gd.uid new file mode 100644 index 0000000..f59a644 --- /dev/null +++ b/Scripts/Tags/h4.gd.uid @@ -0,0 +1 @@ +uid://j68a278yusxa diff --git a/Scripts/Tags/h5.gd b/Scripts/Tags/h5.gd new file mode 100644 index 0000000..19a53b7 --- /dev/null +++ b/Scripts/Tags/h5.gd @@ -0,0 +1,7 @@ +extends Control + +@onready var rich_text_label: RichTextLabel = $RichTextLabel + +func init(element: HTMLParser.HTMLElement) -> void: + var label: RichTextLabel = $RichTextLabel + label.text = "[font_size=20][b]%s[/b][/font_size]" % element.get_bbcode_formatted_text() diff --git a/Scripts/Tags/h5.gd.uid b/Scripts/Tags/h5.gd.uid new file mode 100644 index 0000000..0210d51 --- /dev/null +++ b/Scripts/Tags/h5.gd.uid @@ -0,0 +1 @@ +uid://648taty6aixn diff --git a/Scripts/Tags/h6.gd b/Scripts/Tags/h6.gd new file mode 100644 index 0000000..d05f716 --- /dev/null +++ b/Scripts/Tags/h6.gd @@ -0,0 +1,7 @@ +extends Control + +@onready var rich_text_label: RichTextLabel = $RichTextLabel + +func init(element: HTMLParser.HTMLElement) -> void: + var label: RichTextLabel = $RichTextLabel + label.text = "[font_size=16][b]%s[/b][/font_size]" % element.get_bbcode_formatted_text() diff --git a/Scripts/Tags/h6.gd.uid b/Scripts/Tags/h6.gd.uid new file mode 100644 index 0000000..7822b1d --- /dev/null +++ b/Scripts/Tags/h6.gd.uid @@ -0,0 +1 @@ +uid://tv6sv6og67q6 diff --git a/Scripts/main.gd b/Scripts/main.gd index 472ba83..523c13a 100644 --- a/Scripts/main.gd +++ b/Scripts/main.gd @@ -13,6 +13,12 @@ const SEPARATOR = preload("res://Scenes/Tags/separator.tscn") const PRE = preload("res://Scenes/Tags/pre.tscn") const BR = preload("res://Scenes/Tags/br.tscn") const SPAN = preload("res://Scenes/Tags/span.tscn") +const H1 = preload("res://Scenes/Tags/h1.tscn") +const H2 = preload("res://Scenes/Tags/h2.tscn") +const H3 = preload("res://Scenes/Tags/h3.tscn") +const H4 = preload("res://Scenes/Tags/h4.tscn") +const H5 = preload("res://Scenes/Tags/h5.tscn") +const H6 = preload("res://Scenes/Tags/h6.tscn") func render(): # Clear existing content @@ -31,6 +37,13 @@ func render():
+Hey there! this is a test
This is bold This is italic actually, and it's pretty cool @@ -111,6 +124,42 @@ line breaks website_container.add_child(p) if contains_hyperlink(element): p.rich_text_label.meta_clicked.connect(func(meta): OS.shell_open(str(meta))) + "h1": + var h1 = H1.instantiate() + h1.init(element) + website_container.add_child(h1) + if contains_hyperlink(element): + h1.rich_text_label.meta_clicked.connect(func(meta): OS.shell_open(str(meta))) + "h2": + var h2 = H2.instantiate() + h2.init(element) + website_container.add_child(h2) + if contains_hyperlink(element): + h2.rich_text_label.meta_clicked.connect(func(meta): OS.shell_open(str(meta))) + "h3": + var h3 = H3.instantiate() + h3.init(element) + website_container.add_child(h3) + if contains_hyperlink(element): + h3.rich_text_label.meta_clicked.connect(func(meta): OS.shell_open(str(meta))) + "h4": + var h4 = H4.instantiate() + h4.init(element) + website_container.add_child(h4) + if contains_hyperlink(element): + h4.rich_text_label.meta_clicked.connect(func(meta): OS.shell_open(str(meta))) + "h5": + var h5 = H5.instantiate() + h5.init(element) + website_container.add_child(h5) + if contains_hyperlink(element): + h5.rich_text_label.meta_clicked.connect(func(meta): OS.shell_open(str(meta))) + "h6": + var h6 = H6.instantiate() + h6.init(element) + website_container.add_child(h6) + if contains_hyperlink(element): + h6.rich_text_label.meta_clicked.connect(func(meta): OS.shell_open(str(meta))) "pre": var pre = PRE.instantiate() pre.init(element) diff --git a/godotgif/bin/~godotgif.windows.template_debug.x86_64.dll b/godotgif/bin/~godotgif.windows.template_debug.x86_64.dll new file mode 100644 index 0000000000000000000000000000000000000000..cfcbc522e3bfffda7353f86e57425696608614dd GIT binary patch literal 516608 zcmeEvd0doL`}eSnj0+BKiJCeoCZ;KgCWaQHjNYR&N$%!`sbytmIV9#12B_2Bq&?YU zT3L@hW}9n@W(A6ZD{7XQrL^fGtZ+$D%Xz=oIrlQd3?x18?~ix!^TGRU*E!dI_A}1= zml(nf217Xhyk3JL2VeS^#Q(4Uzo-y{p?>Ra^$nY9AGjqa#Bt!3p;I27VVVBq;}1PK z;W5j^3Dc%M?y@{E+45xCG|R)&EXjk0SRQ+P(&WyOk#%B}s*T@&AXzhZwNU@MhvYUt zhIsdoyyoNhcX#u_{F~pr4=G+
z#C_06ev*4?Oe)uZ{!4S1{z`J0l*859>y5DYv_+Y-c0(_>T0kRdbP5Z*7z)gw4QL$4
zKI6Vddj U*r14>uK~UEExz3GpMmfa^5 6%)eQMlGR`1{npG-BUEFXS^lao7qCB7MI-kfUPgwB?}W5-(-uBPuA
zY)Y-JZ$9Fwq3`DIwdmX5(svfbqHnCF@5%8Y`tF%ui@s~Dn|6Iax+9#vEo;&D3&c}H
z-=x~~eHI}}%XGCR-PHG5<6g4L3Dx&POEsH)TUs~m`bLM<_f~9fu5MpfZTe1xLI@aI
z9xBkhh`#4o`o3=5OIFX}%2pm`%&Wz|w^}#t`VP81oP8IsuBq=$h^K~qi!ZB1-waFN
zyC9bG@aOGvm8^col}+D`57(maV(X?|- >_h1vXQqElmR^>vuRv@`7{nV1A5Aez!ZXcFTX{kIX4Fr&Q8^{m
zYdlyv+aIZ=R2N*r9(W40lj
zj#4303354yRQ&VDK5e#9A&
XxLA$y#nwBv)bTE_3r*
io2cr^A3$kM9h9NTR-W+l18fhahB&S;rz1A|j?IW$Jxf2TFVcT6i+bW;81}
z-eh`wAAgew-+
#XyLJQSGP=kZ08g1V&L0xX4+;-IW
Y0nrF<~3YP;3g(D>T2S3d_(H
z?T)~