fix: fixed text going offscreen in comment and post

Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
limited_dev 2023-06-13 14:35:44 +02:00
parent 9d733af389
commit 13b4935d6a
3 changed files with 70 additions and 46 deletions

View file

@ -38,7 +38,7 @@
{ {
className = "greenText"; className = "greenText";
} }
<span class='threadText @className'> <p class='threadText @className'>
@for (var x = 0; x < s.Split(" ").Length; x++) @for (var x = 0; x < s.Split(" ").Length; x++)
{ {
var line = s.Split(" ")[x]; var line = s.Split(" ")[x];
@ -49,11 +49,12 @@
var y1 = y; var y1 = y;
var commentNumber = int.Parse(Regex.Match(s, ">>(\\d+)").Value.Substring(2)); var commentNumber = int.Parse(Regex.Match(s, ">>(\\d+)").Value.Substring(2));
className2 = "redText"; className2 = "redText";
<span <a
@onmouseenter="() => onHover(x1, y1, commentNumber)" @onmousedown="() => onHover(x1, y1, commentNumber)"
@onmouseleave="() => onHover(x1, y1, -1)" class="threadMsg @className2"> @onmouseup="() => onHover(x1, y1, -1)"
class="threadMsg @className2">
@line @line
</span> </a>
@if (hoveringOver.p != -1 && hoveringOver == (x, y, commentNumber) && (hoverComment.ContainsKey(commentNumber) || hoverPost.ContainsKey(commentNumber))) @if (hoveringOver.p != -1 && hoveringOver == (x, y, commentNumber) && (hoverComment.ContainsKey(commentNumber) || hoverPost.ContainsKey(commentNumber)))
{ {
@if (isComment[commentNumber]) @if (isComment[commentNumber])
@ -74,17 +75,16 @@
{ {
@if (line.StartsWith("https://") || line.StartsWith("http://")) @if (line.StartsWith("https://") || line.StartsWith("http://"))
{ {
<a href="@line" target="_blank">@line</a> <a href="@line">@line</a>
} }
else else
{ {
<span class="threadMsg">@line</span> @line
} }
<span >&nbsp;</span> @(" ")
} }
<span>&nbsp;</span>
} }
</span> </p>
} }
</div> </div>
</div> </div>

View file

@ -22,34 +22,40 @@
</div> </div>
} }
<div class="threadTextContainer"> <div class="threadTextContainer">
@foreach (string s in @comment.Content.Split("\n")) @for (var y = 0; y < comment.Content.Split("\n").Length; y++)
{ {
var s = comment.Content.Split("\n")[y];
var className = ""; var className = "";
@if (s.StartsWith(">") && !Regex.IsMatch(s, "^>{2,}")) @if (s.StartsWith(">") && !Regex.IsMatch(s, "^>{2,}"))
{ {
className = "greenText"; className = "greenText";
} }
<p class='threadText @className'>
<span class='threadText @className'> @for (var x = 0; x < s.Split(" ").Length; x++)
@foreach (string line in s.Split(" "))
{ {
var className2 = ""; var line = s.Split(" ")[x];
@if (@Regex.IsMatch(line, ">>\\d+")) @if (@Regex.IsMatch(line, ">>\\d+"))
{ {
className2 = "redText"; var className2 = "";
<a href="/@comment.Board/@comment.PostID/@Regex.Match(s, ">>(\\d+)").Value.Substring(2)" class="threadMsg @className2"> <a class="redText">
@line @line
</a> </a>
} }
else else
{ {
<span class="threadMsg"> @if (line.StartsWith("https://") || line.StartsWith("http://"))
{
<a href="@line">@line</a>
}
else
{
@line @line
</span> }
@(" ")
} }
<span>&nbsp;</span>
} }
</span> </p>
} }
</div> </div>
</div> </div>

View file

@ -50,31 +50,32 @@
<div class="threadTextContainer"> <div class="threadTextContainer">
@if (showOpenThread) @if (showOpenThread)
{ {
@foreach (string s in post.Content.Split("\n").ToList().Take(6)) @foreach (string s in post.Content.Split("\n").Take(6))
{ {
var className = ""; var className = "";
@if (s.StartsWith(">") && !Regex.IsMatch(s, "^>{2,}")) @if (s.StartsWith(">") && !Regex.IsMatch(s, "^>{2,}"))
{ {
className = "greenText"; className = "greenText";
} }
@foreach (string s2 in s.Split(" ")) <p class="@className">
{ @foreach (string s2 in s.Split(" "))
@if (s2.StartsWith("https://") || s.StartsWith("http://"))
{ {
<a href="@s2" target="_blank">@s2</a> @if (s2.StartsWith("https://") || s2.StartsWith("http://"))
{
<a href="@s2">@s2</a>
}
else
{
@s2
}
@(" ")
} }
else </p>
{ <p/>
<span class="@className">@s2</span>
}
<span class="@className">&nbsp;</span>
}
<br/>
} }
@if (post.Content.Split("\n").Length > 6) @if (post.Content.Split("\n").Length > 6)
{ {
<br/> <p class="greenText">[Open thread to read more...]</p>
<span class="greenText">[Open Thread to read more...]</span>
} }
} }
else else
@ -86,19 +87,21 @@
{ {
className = "greenText"; className = "greenText";
} }
@foreach (string s2 in s.Split(" ")) <p class="@className">
{ @foreach (string s2 in s.Split(" "))
@if (s2.StartsWith("https://") || s2.StartsWith("http://"))
{ {
<a href="@s2" target="_blank">@s2</a> @if (s2.StartsWith("https://") || s2.StartsWith("http://"))
{
<a href="@s2">@s2</a>
}
else
{
@s2
}
@(" ")
} }
else </p>
{ <p/>
<span class="@className">@s2</span>
}
<span class="@className">&nbsp;</span>
}
<br/>
} }
} }
</div> </div>
@ -146,6 +149,21 @@
</div> </div>
@code { @code {
/*
private RenderFragment[] RenderWithAnchorTags(string input)
{
return input.Split(' ').Select(e => e.StartsWith("https://") || e.StartsWith("http://")
? (RenderFragment)(builder =>
{
builder.OpenElement(0, "a");
builder.AddAttribute(1, "href", e);
builder.AddContent(2, e);
builder.CloseElement();
})
: (RenderFragment)(builder => builder.AddContent(0, e))).ToArray();
}
*/
private string reportURL { get; set; } private string reportURL { get; set; }
private string threadURL { get; set; } private string threadURL { get; set; }