Skip to content

Commit d281ca5

Browse files
committed
Notes view enhancements
Added proper styles for markdown notes
1 parent 88822ed commit d281ca5

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

‎src/O2/uMain.pas‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,21 +1781,29 @@ procedure TMainForm.UpdateFieldsView;
17811781
end;
17821782

17831783
procedure TMainForm.UpdateNotesView;
1784+
const
1785+
Styles: array [TO2TextType] of string = (
1786+
'body { color: #000; background-color: #fff; font-size: 1rem; font-family: monospace; white-space: pre-wrap; }',
1787+
'body { color: #000; background-color: #fff; font-size: 1rem; font-family: sans-serif; } hr { border-style: solid; color: silver; } table { border-collapse: collapse; } thead { border-bottom: 1px solid silver; } th, td { padding: .125rem; } tr:nth-child(even) { background-color: lightgrey; }');
17841788
var
1789+
TextType: TO2TextType;
17851790
SB: TStringBuilder;
17861791
begin
1792+
if HasSelectedObject then
1793+
TextType := SelectedObject.TextType
1794+
else
1795+
TextType := ttPlainText;
1796+
17871797
SB := TStringBuilder.Create;
17881798
try
1789-
SB.Append('<!DOCTYPE html><html>').AppendContextMenuBlockerScript.Append(
1790-
'<body style="color: #000; background-color: #fff; font-size: 1rem;');
1791-
1792-
if HasSelectedObject and (SelectedObject.TextType = ttCommonMark) then
1793-
SB.Append('font-family: sans-serif;">')
1794-
else
1795-
SB.Append('font-family: monospace; white-space: pre-wrap;">');
1799+
SB.Append('<!DOCTYPE html><html><head>')
1800+
.AppendContextMenuBlockerScript
1801+
.Append('<style>')
1802+
.Append(Styles[TextType])
1803+
.Append('</style></head><body>');
17961804

17971805
if HasSelectedObject then
1798-
SB.AppendHTML(SelectedObject.Text, SelectedObject.TextType);
1806+
SB.AppendHTML(SelectedObject.Text, TextType);
17991807

18001808
SB.Append('</body></html>');
18011809

0 commit comments

Comments
 (0)