mirror of
https://git.srhtnin.garden/sarah/SaraView.git
synced 2026-10-15 10:43:17 +02:00
Client: links and images open, line breaks like the web, directory notes setting
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
55ee8e2f23
commit
0513d94c6a
8 files changed
+134
-23
No files matched your search
@@ -20,7 +20,7 @@ from typing import Callable, Optional
|
||||
import flet as ft
|
||||
|
||||
import Core
|
||||
from Core import CodeStyleSheet, MarkdownCodeTheme, MarkdownSheet, Palette
|
||||
from Core import CodeStyleSheet, HardLineBreaks, MarkdownCodeTheme, MarkdownSheet, Palette
|
||||
from Properties import ParseProperties, PropertiesView, ToggleLine, WithCheckboxes
|
||||
from Variables import Substitute
|
||||
|
||||
@@ -117,7 +117,8 @@ class LiveMarkdown(ft.Column):
|
||||
def __init__(self, Document: str, FontSize: int, OnChange: Callable[[], None],
|
||||
OnFocusChange: Callable[[bool], None], OnTapLink: Callable,
|
||||
MakeDiagram: Optional[Callable[[str, int], Optional[ft.Control]]] = None,
|
||||
GetSpans: Optional[Callable[[str], list[dict]]] = None):
|
||||
GetSpans: Optional[Callable[[str], list[dict]]] = None,
|
||||
MakeImage: Optional[Callable[[str, str], Optional[ft.Control]]] = None):
|
||||
super().__init__(scroll=ft.ScrollMode.AUTO, expand=True, spacing=0,
|
||||
horizontal_alignment=ft.CrossAxisAlignment.STRETCH)
|
||||
self.Document = Document
|
||||
@@ -127,6 +128,7 @@ class LiveMarkdown(ft.Column):
|
||||
self.OnTapLink = OnTapLink
|
||||
self.MakeDiagram = MakeDiagram
|
||||
self.GetSpans = GetSpans
|
||||
self.MakeImage = MakeImage
|
||||
self.SpansFor: tuple[str, list[dict]] = ("", []) # (document, its spans)
|
||||
self.Blocks: list[Block] = []
|
||||
self.BlockControls: list[ft.Control] = []
|
||||
@@ -237,7 +239,7 @@ class LiveMarkdown(ft.Column):
|
||||
|
||||
def _Markdown(self, Text: str) -> ft.Control:
|
||||
return ft.Markdown(
|
||||
value=Text,
|
||||
value=HardLineBreaks(Text),
|
||||
extension_set=ft.MarkdownExtensionSet.GITHUB_FLAVORED,
|
||||
md_style_sheet=MarkdownSheet(self.FontSize),
|
||||
code_theme=MarkdownCodeTheme(),
|
||||
@@ -263,7 +265,8 @@ class LiveMarkdown(ft.Column):
|
||||
elif Kind == "Properties" and (Found := ParseProperties(Text)) is not None:
|
||||
Rendered.content = PropertiesView(Found, self.FontSize, self._Markdown, Toggle)
|
||||
elif Kind == "Text":
|
||||
Parts = WithCheckboxes(Shown if Shown is not None else Text, 0, self._Markdown, Toggle, self.FontSize, LineMap)
|
||||
Parts = WithCheckboxes(Shown if Shown is not None else Text, 0, self._Markdown, Toggle, self.FontSize, LineMap,
|
||||
self.MakeImage)
|
||||
Rendered.content = Parts[0] if len(Parts) == 1 else ft.Column(Parts, spacing=0, tight=True)
|
||||
else:
|
||||
Rendered.content = self._Markdown(Shown if Shown is not None and Kind == "Heading" else Text)
|
||||
|
||||
Reference in new issue
Block a user