feat: add built-in markdown editor with search jump and typing helpers

This commit is contained in:
randogoth 2026-10-13 10:47:34 +03:00
parent db27f64e42
commit ed2de5e67f
16 changed files with 1146 additions and 561 deletions

View file

@ -19,37 +19,64 @@ const TextTheme dayText = TextTheme(
);
const dayTheme = {
'root':
TextStyle(backgroundColor: Color(0xffF6F4F1), color: Color(0xff333333)),
'comment': TextStyle(color: Color(0xff969896)),
'meta': TextStyle(color: Color(0xff969896)),
'variable': TextStyle(color: Color(0xffdf5000)),
'template-variable': TextStyle(color: Color(0xffdf5000)),
'strong': TextStyle(color: Color(0xffdf5000)),
'emphasis': TextStyle(color: Color(0xffdf5000)),
'quote': TextStyle(color: Color(0xffdf5000)),
'keyword': TextStyle(color: Color(0xffd73a49)),
'selector-tag': TextStyle(color: Color(0xffd73a49)),
'type': TextStyle(color: Color(0xffd73a49)),
'literal': TextStyle(color: Color(0xff0086b3)),
'symbol': TextStyle(color: Color(0xff0086b3)),
'bullet': TextStyle(color: Color(0xff0086b3)),
'attribute': TextStyle(color: Color(0xff0086b3)),
'section': TextStyle(color: Color(0xff63a35c)),
'name': TextStyle(color: Color(0xff63a35c)),
'tag': TextStyle(color: Color(0xff333333)),
'title': TextStyle(color: Color(0xff6f42c1)),
'attr': TextStyle(color: Color(0xff6f42c1)),
'selector-id': TextStyle(color: Color(0xff6f42c1)),
'selector-class': TextStyle(color: Color(0xff6f42c1)),
'selector-attr': TextStyle(color: Color(0xff6f42c1)),
'selector-pseudo': TextStyle(color: Color(0xff6f42c1)),
'addition':
TextStyle(color: Color(0xff55a532), backgroundColor: Color(0xffeaffea)),
'deletion':
TextStyle(color: Color(0xffbd2c00), backgroundColor: Color(0xffffecec)),
'number': TextStyle(color: Color(0xff005cc5)),
'string': TextStyle(color: Color(0xff032f62)),
// General text
'root': TextStyle(backgroundColor: Color(0xffF6F4F1), color: Color(0xff333333)),
// Headers
'header-h1': TextStyle(color: Color(0xff63a35c)), // Green for H1
'header-h2': TextStyle(color: Color(0xff63a35c), fontWeight: FontWeight.w600, fontSize: 22), // Green for H2
'header-h3': TextStyle(color: Color(0xff63a35c), fontWeight: FontWeight.w600, fontSize: 20), // Green for H3
'header-h4': TextStyle(color: Color(0xff63a35c), fontWeight: FontWeight.w600, fontSize: 18), // Green for H4
'header-h5': TextStyle(color: Color(0xff63a35c), fontWeight: FontWeight.w600, fontSize: 16), // Green for H5
'header-h6': TextStyle(color: Color(0xff63a35c), fontWeight: FontWeight.w600, fontSize: 14), // Green for H6
'header-underline': TextStyle(color: Color(0xff63a35c)), // Green for underlined headers
// Lists
'list': TextStyle(color: Color(0xff0086b3)), // Blue for lists
// Bold text
'bold': TextStyle(fontWeight: FontWeight.bold, color: Color(0xffdf5000)), // Orange for bold text
// Italic text
'italic': TextStyle(fontStyle: FontStyle.italic, color: Color(0xffdf5000)), // Orange for italic text
// Blockquotes
'blockquote': TextStyle(color: Color(0xffdf5000)), // Orange for blockquotes
// Code blocks and inline code
'code': TextStyle(color: Color(0xff005cc5), backgroundColor: Color(0xffeaffea)), // Blue for code
// Horizontal rules
'horizontal-rule': TextStyle(color: Color(0xffbd2c00)), // Red for horizontal rules
// Horizontal rules
'command': TextStyle(fontStyle: FontStyle.italic, color: Color(0xffbd2c00)), // Red for horizontal rules
// Links and images
'link-text': TextStyle(color: Color(0xff0086b3)), // Blue for link text
'link-url': TextStyle(color: Color(0xffd73a49)), // Red for link URLs
'link-reference': TextStyle(color: Color(0xff0086b3)), // Blue for link references
// Strikethrough text
'strikethrough': TextStyle(color: Color(0xffbd2c00), decoration: TextDecoration.lineThrough), // Red for strikethrough
// Tables
'table': TextStyle(color: Color(0xff333333)), // Black for tables
'table-header': TextStyle(color: Color(0xff6f42c1), fontWeight: FontWeight.w600), // Purple for table headers
'table-row': TextStyle(color: Color(0xff333333)), // Black for table rows
'table-cell': TextStyle(color: Color(0xff333333)), // Black for table cells
// Task lists
'task-list': TextStyle(color: Color(0xff0086b3)), // Blue for task lists
// Emphasis and strong
'emphasis': TextStyle(fontStyle: FontStyle.italic, color: Color(0xffdf5000)), // Orange for emphasis
'strong': TextStyle(fontWeight: FontWeight.bold, color: Color(0xffdf5000)), // Orange for strong
// Comments and quotes
'comment': TextStyle(color: Color(0xff969896)), // Gray for comments
'quote': TextStyle(color: Color(0xffdf5000)), // Orange for quotes
'tag-hash': TextStyle(
color: Colors.pinkAccent,
fontStyle: FontStyle.italic,

View file

@ -1,81 +0,0 @@
import 'package:highlight/highlight.dart';
final markdown = Mode(refs: {}, aliases: [
"md",
"mkdown",
"mkd"
], contains: [
Mode(className: "section", variants: [
Mode(begin: "^#\\s{1,6}", end: "\$"),
Mode(begin: "^.+?\\n[=-]{2,}\$")
]),
Mode(begin: "<", end: ">", subLanguage: ["xml"], relevance: 0),
Mode(className: "bullet", begin: "^\\s*([*+-]|(\\d+\\.))\\s+"),
Mode(className: "strong", begin: "[*_]{2}.+?[*_]{2}"),
Mode(
className: "emphasis",
variants: [Mode(begin: "\\*.+?\\*"), Mode(begin: "_.+?_", relevance: 0)]),
Mode(className: "quote", begin: "^>\\s+", end: "\$"),
Mode(className: "code", variants: [
Mode(begin: "^```\\w*\\s*\$", end: "^```[ ]*\$"),
Mode(begin: "`.+?`"),
Mode(begin: "^( {4}|\\t)", end: "\$", relevance: 0)
]),
Mode(begin: "^[-\\*]{3,}", end: "\$"),
Mode(
begin: "\\[.+?\\][\\(\\[].*?[\\)\\]]",
returnBegin: true,
contains: [
Mode(
className: "string",
begin: "\\[",
end: "\\]",
excludeBegin: true,
returnEnd: true,
relevance: 0),
Mode(
className: "link",
begin: "\\]\\(",
end: "\\)",
excludeBegin: true,
excludeEnd: true),
Mode(
className: "symbol",
begin: "\\]\\[",
end: "\\]",
excludeBegin: true,
excludeEnd: true)
],
relevance: 10),
Mode(begin: "^\\[[^\\n]+\\]:", returnBegin: true, contains: [
Mode(
className: "symbol",
begin: "\\[",
end: "\\]",
excludeBegin: true,
excludeEnd: true),
Mode(className: "link", begin: ":\\s*", end: "\$", excludeBegin: true)
]),
// Custom Tag Highlighting
Mode(
className: "tag-hash",
begin: "(?<=\\s|^)#[a-zA-Z0-9_]+",
relevance: 10), // Magenta
Mode(
className: "tag-plus",
begin: "(?<=\\s|^)\\+[a-zA-Z0-9_]+",
relevance: 10), // Cyan
Mode(
className: "tag-at",
begin: "(?<=\\s|^)@[a-zA-Z0-9_]+",
relevance: 10), // Yellow
Mode(
className: "keyword",
begin: "(?<=\\s|^):[a-zA-Z0-9_]+",
relevance: 10),
Mode(
className: "variable",
begin: "(?<=\\s|^)\/[a-zA-Z0-9_\/]+",
relevance: 10), // Yellow
]);

View file

@ -19,37 +19,64 @@ const TextTheme nightText = TextTheme(
);
const nightTheme = {
'comment': TextStyle(color: Color(0xff969896)),
'quote': TextStyle(color: Color(0xff969896)),
'variable': TextStyle(color: Color(0xffcc6666)),
'template-variable': TextStyle(color: Color(0xffcc6666)),
'tag': TextStyle(color: Color(0xffcc6666)),
'name': TextStyle(color: Color(0xffcc6666)),
'selector-id': TextStyle(color: Color(0xffcc6666)),
'selector-class': TextStyle(color: Color(0xffcc6666)),
'regexp': TextStyle(color: Color(0xffcc6666)),
'deletion': TextStyle(color: Color(0xffcc6666)),
'number': TextStyle(color: Color(0xffde935f)),
'built_in': TextStyle(color: Color(0xffde935f)),
'builtin-name': TextStyle(color: Color(0xffde935f)),
'literal': TextStyle(color: Color(0xffde935f)),
'type': TextStyle(color: Color(0xffde935f)),
'params': TextStyle(color: Color(0xffde935f)),
'meta': TextStyle(color: Color(0xffde935f)),
'link': TextStyle(color: Color(0xffde935f)),
'attribute': TextStyle(color: Color(0xfff0c674)),
'string': TextStyle(color: Color(0xffb5bd68)),
'symbol': TextStyle(color: Color(0xffb5bd68)),
'bullet': TextStyle(color: Color(0xffb5bd68)),
'addition': TextStyle(color: Color(0xffb5bd68)),
'title': TextStyle(color: Color(0xff81a2be)),
'section': TextStyle(color: Color(0xff81a2be), fontWeight: FontWeight.w600, fontSize: 18),
'keyword': TextStyle(color: Color(0xffb294bb)),
'selector-tag': TextStyle(color: Color(0xffb294bb)),
'root':
TextStyle(backgroundColor: Color(0xFF121212), color: Color(0xffc5c8c6)),
'emphasis': TextStyle(fontStyle: FontStyle.italic),
'strong': TextStyle(fontWeight: FontWeight.bold),
// General text
'root': TextStyle(backgroundColor: Color(0xFF121212), color: Color(0xffc5c8c6)),
// Headers
'header-h1': TextStyle(color: Color(0xff81a2be)), // Blue for H1
'header-h2': TextStyle(color: Color(0xff81a2be), fontWeight: FontWeight.w600, fontSize: 22), // Blue for H2
'header-h3': TextStyle(color: Color(0xff81a2be), fontWeight: FontWeight.w600, fontSize: 20), // Blue for H3
'header-h4': TextStyle(color: Color(0xff81a2be), fontWeight: FontWeight.w600, fontSize: 18), // Blue for H4
'header-h5': TextStyle(color: Color(0xff81a2be), fontWeight: FontWeight.w600, fontSize: 16), // Blue for H5
'header-h6': TextStyle(color: Color(0xff81a2be), fontWeight: FontWeight.w600, fontSize: 14), // Blue for H6
'header-underline': TextStyle(color: Color(0xff81a2be)), // Blue for underlined headers
// Lists
'list': TextStyle(color: Color(0xffb5bd68)), // Green for lists
// Bold text
'bold': TextStyle(fontWeight: FontWeight.bold, color: Color(0xffb5bd68)), // White for bold text
// Italic text
'italic': TextStyle(fontStyle: FontStyle.italic, color: Color(0xffb5bd68)), // White for italic text
// Blockquotes
'blockquote': TextStyle(color: Color(0xff969896)), // Gray for blockquotes
// Code blocks and inline code
'code': TextStyle(color: Color(0xffde935f), backgroundColor: Color(0xff1d1f21)), // Orange for code
// Horizontal rules
'horizontal-rule': TextStyle(color: Color(0xffcc6666)), // Red for horizontal rules
// Horizontal rules
'command': TextStyle(fontStyle: FontStyle.italic, color: Color(0xffcc6666)), // Red for horizontal rules
// Links and images
'link-text': TextStyle(color: Color(0xff81a2be)), // Blue for link text
'link-url': TextStyle(color: Color(0xffde935f)), // Orange for link URLs
'link-reference': TextStyle(color: Color(0xffb5bd68)), // Green for link references
// Strikethrough text
'strikethrough': TextStyle(color: Color(0xffcc6666), decoration: TextDecoration.lineThrough), // Red for strikethrough
// Tables
'table': TextStyle(color: Color(0xffc5c8c6)), // White for tables
'table-header': TextStyle(color: Color(0xff81a2be), fontWeight: FontWeight.w600), // Blue for table headers
'table-row': TextStyle(color: Color(0xffc5c8c6)), // White for table rows
'table-cell': TextStyle(color: Color(0xffc5c8c6)), // White for table cells
// Task lists
'task-list': TextStyle(color: Color(0xffb5bd68)), // Green for task lists
// Emphasis and strong
'emphasis': TextStyle(fontStyle: FontStyle.italic, color: Color(0xffc5c8c6)), // White for emphasis
'strong': TextStyle(fontWeight: FontWeight.bold, color: Color(0xffc5c8c6)), // White for strong
// Comments and quotes
'comment': TextStyle(color: Color(0xff969896)), // Gray for comments
'quote': TextStyle(color: Color(0xff969896)), // Gray for quotes
'tag-hash': TextStyle(
color: Colors.pinkAccent,
fontStyle: FontStyle.italic,