OneLauncher-Cracked/packages/oneclient_app/src/components/markdown/mod.rs
oiupoyt 163eb0ac0c
Some checks are pending
Release Multiplatform Binaries / build (deb,appimage, linux-x86_64, ubuntu-22.04, x86_64-unknown-linux-gnu) (push) Waiting to run
Release Multiplatform Binaries / build (dmg,app, macos-arm64, macos-14, aarch64-apple-darwin) (push) Waiting to run
Release Multiplatform Binaries / build (dmg,app, macos-x86_64, macos-14, x86_64-apple-darwin) (push) Waiting to run
Release Multiplatform Binaries / build (nsis, windows-x86_64, windows-latest, x86_64-pc-windows-msvc) (push) Waiting to run
Release Multiplatform Binaries / create-release (push) Blocked by required conditions
feat: update base to official upstream 2.3.1 with all cracked features intact (2.3.1-c1)
- Rebased onto official Polyfrost OneLauncher v2.3.1 (commit 0e49c691)
- Preserved 100% offline authentication without requiring Microsoft accounts
- Integrated custom 3D offline skin changer with UUID character slot targeting
- Maintained CustomSkinLoader auto-configuration for Ely.by and SkinRestorer
- Maintained direct GitHub Releases auto-updater pointing to oiupoyt/OneLauncher-Cracked
- Maintained mods filter popover fix eliminating text ghosting/duplication
- Configured dev profile to prevent debug symbol bloat
2026-09-07 17:38:22 +05:30

118 lines
2.9 KiB
Rust

use std::borrow::Cow;
use freya::prelude::*;
use pulldown_cmark::HeadingLevel;
mod image;
mod parse;
mod render;
#[derive(Clone, PartialEq)]
pub struct MarkdownStyle {
pub color: Color,
pub color_link: Color,
pub color_code: Color,
pub background_code: Color,
pub background_blockquote: Color,
pub border_blockquote: Color,
pub background_divider: Color,
pub headings: [f32; 6],
pub paragraph_size: f32,
pub code_font_size: f32,
pub table_font_size: f32,
pub code_font_family: Cow<'static, str>,
}
impl Default for MarkdownStyle {
fn default() -> Self {
Self {
color: Color::WHITE,
color_link: Color::from_rgb(90, 160, 255),
color_code: Color::WHITE,
background_code: Color::from_rgb(32, 32, 32),
background_blockquote: Color::from_rgb(32, 32, 32),
border_blockquote: Color::from_rgb(80, 80, 80),
background_divider: Color::from_rgb(64, 64, 64),
headings: [32., 28., 24., 20., 18., 16.],
paragraph_size: 16.,
code_font_size: 14.,
table_font_size: 14.,
code_font_family: Cow::Borrowed("Jetbrains Mono"),
}
}
}
impl MarkdownStyle {
fn heading_size(&self, level: HeadingLevel) -> f32 {
self.headings[match level {
HeadingLevel::H1 => 0,
HeadingLevel::H2 => 1,
HeadingLevel::H3 => 2,
HeadingLevel::H4 => 3,
HeadingLevel::H5 => 4,
HeadingLevel::H6 => 5,
}]
}
}
#[derive(PartialEq)]
pub struct Markdown {
content: String,
style: MarkdownStyle,
layout: LayoutData,
key: DiffKey,
}
impl Markdown {
pub fn new(content: impl Into<String>) -> Self {
Self {
content: content.into(),
style: MarkdownStyle::default(),
layout: LayoutData::default(),
key: DiffKey::None,
}
}
pub fn style(mut self, style: MarkdownStyle) -> Self {
self.style = style;
self
}
}
impl KeyExt for Markdown {
fn write_key(&mut self) -> &mut DiffKey {
&mut self.key
}
}
impl LayoutExt for Markdown {
fn get_layout(&mut self) -> &mut LayoutData {
&mut self.layout
}
}
impl ContainerExt for Markdown {}
impl Component for Markdown {
fn render(&self) -> impl IntoElement {
let content = use_reactive(&self.content);
let blocks = use_memo(move || parse::parse(&content.read()));
let blocks = blocks.read();
rect()
.vertical()
.layout(self.layout.clone())
.spacing(12.)
.children(
blocks
.iter()
.enumerate()
.map(|(idx, block)| render::render_block(block, idx, &self.style)),
)
}
fn render_key(&self) -> DiffKey {
self.key.clone().or(self.default_key())
}
}