mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 15:26:17 +00:00
feat(app): browser-like tabs with per-tab history and persistence
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
39e7e43071
commit
1e32cf0df3
8 files changed
+577
-33
No files matched your search
@@ -317,8 +317,10 @@ class _BlockViewState extends State<BlockView> {
|
||||
base: blockTextStyle(context),
|
||||
refs: app.refs,
|
||||
assetPath: app.backend.assetPath,
|
||||
onPage: app.openTitle,
|
||||
onBlockRef: (r) => app.openId(r.pageId),
|
||||
onPage: (t) => app.navigate(PageTarget(title: t)),
|
||||
onBlockRef: (r) => app.navigate(PageTarget(id: r.pageId)),
|
||||
onPageNewTab: app.openTitleInNewTab,
|
||||
onBlockRefNewTab: (r) => app.openIdInNewTab(r.pageId),
|
||||
onUrl: openUrl,
|
||||
onToggleTodo: () => widget.controller.cycleTodo(widget.node),
|
||||
maxWidth: width,
|
||||
@@ -708,6 +710,8 @@ class _BlockEditorState extends State<BlockEditor> {
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
if (key == LogicalKeyboardKey.tab) {
|
||||
// Ctrl+Tab switches app tabs (handled by the shell shortcuts).
|
||||
if (ctrl) return KeyEventResult.ignored;
|
||||
if (shift) {
|
||||
c.outdent(n, caret: caret);
|
||||
} else {
|
||||
|
||||
@@ -65,6 +65,8 @@ class RenderContext {
|
||||
required this.onBlockRef,
|
||||
required this.onUrl,
|
||||
this.onToggleTodo,
|
||||
this.onPageNewTab,
|
||||
this.onBlockRefNewTab,
|
||||
this.maxWidth = 600,
|
||||
});
|
||||
|
||||
@@ -76,6 +78,10 @@ class RenderContext {
|
||||
final void Function(BlockRefDtoLike ref) onBlockRef;
|
||||
final void Function(String url) onUrl;
|
||||
final VoidCallback? onToggleTodo;
|
||||
|
||||
/// Middle-click on a page link or block ref.
|
||||
final void Function(String title)? onPageNewTab;
|
||||
final void Function(BlockRefDtoLike ref)? onBlockRefNewTab;
|
||||
final double maxWidth;
|
||||
}
|
||||
|
||||
@@ -298,6 +304,9 @@ class BlockRenderer {
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
onTap: () => ctx.onPage(title),
|
||||
onMiddle: ctx.onPageNewTab == null
|
||||
? null
|
||||
: () => ctx.onPageNewTab!(title),
|
||||
);
|
||||
i = plain = close + 2;
|
||||
continue;
|
||||
@@ -476,11 +485,18 @@ class BlockRenderer {
|
||||
return null;
|
||||
}
|
||||
|
||||
void _text(String t, int s0, TextStyle style, {VoidCallback? onTap}) {
|
||||
void _text(
|
||||
String t,
|
||||
int s0,
|
||||
TextStyle style, {
|
||||
VoidCallback? onTap,
|
||||
VoidCallback? onMiddle,
|
||||
}) {
|
||||
if (t.isEmpty) return;
|
||||
TapGestureRecognizer? rec;
|
||||
if (onTap != null) {
|
||||
rec = TapGestureRecognizer()..onTap = onTap;
|
||||
if (onMiddle != null) rec.onTertiaryTapUp = (_) => onMiddle();
|
||||
_recognizers.add(rec);
|
||||
}
|
||||
_spans.add(
|
||||
@@ -513,7 +529,9 @@ class BlockRenderer {
|
||||
TapGestureRecognizer? rec;
|
||||
if (ref != null) {
|
||||
rec = TapGestureRecognizer()
|
||||
..onTap = () => ctx.onBlockRef(BlockRefDtoLike(ref.id, ref.pageId));
|
||||
..onTap = (() => ctx.onBlockRef(BlockRefDtoLike(ref.id, ref.pageId)))
|
||||
..onTertiaryTapUp = (_) =>
|
||||
ctx.onBlockRefNewTab?.call(BlockRefDtoLike(ref.id, ref.pageId));
|
||||
_recognizers.add(rec);
|
||||
}
|
||||
_spans.add(
|
||||
|
||||
Reference in new issue
Block a user