CI / go (Server) (push) Failing after 4m38s
CI / go (Web-App) (push) Successful in 12m18s
Docs / build (push) Canceled after 0s
Docs / deploy (push) Canceled after 0s
CI / frontend (push) Failing after 7m49s
CI / desktop (ubuntu-latest) (push) Successful in 1h25m30s
CI / mobile (push) Failing after 5m14s
CI / docker (push) Successful in 39m26s
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
Databases (ADR-13 follow-ups):
- Relation properties link records to another database, on the same page
or on any page the reader can open (read live and read-only, like synced
pages). Cells list the linked titles; clicking one opens the record.
- Rollup properties work out counts, sums, averages, medians, min/max,
ranges, earliest/latest dates and checked counts over related records.
Neither is stored: views compute them before drawing (linked.ts), so they
follow both databases live, and rollups sort and filter as numbers.
- Exports (Markdown, HTML, PDF, Word) resolve them for same-page databases.
- A record opens as a full page at /p/<page>/r/<database>/<record>, with
"Open as full page" on the side panel and "Back to the page".
Edgeless mode (ADR-14 follow-ups):
- History previews show a version's canvas and count canvas changes.
- Comments can be anchored to canvas elements (anchor {element}); elements
with open threads show a badge that opens the thread.
- Workspaces choose how new pages open (workspaces.default_page_mode); the
per-device choice now defaults to following the workspace.
- Phones edit the canvas once a page is opened for editing; the page note
shows the page title.
Languages:
- The admin panel speaks English, Polish, German, French and Spanish, with
a picker sharing the web app's setting and a key parity test.
- The phone app speaks the same five, follows the phone's language (and
Android's per-app language setting), and has its own parity test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
204 lines
5.7 KiB
Dart
204 lines
5.7 KiB
Dart
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../api/docwell_api.dart';
|
|
import '../app.dart';
|
|
import '../share.dart';
|
|
import 'page_screen.dart';
|
|
import 'widgets.dart';
|
|
import '../l10n.dart';
|
|
|
|
final _url = RegExp(r'https?://[^\s<>"]+');
|
|
|
|
/// The document for shared text: a paragraph per line, with web addresses
|
|
/// as links.
|
|
Map<String, dynamic> sharedDoc(String text) {
|
|
List<Map<String, dynamic>> inline(String line) {
|
|
final out = <Map<String, dynamic>>[];
|
|
var at = 0;
|
|
for (final m in _url.allMatches(line)) {
|
|
if (m.start > at) {
|
|
out.add({'type': 'text', 'text': line.substring(at, m.start)});
|
|
}
|
|
out.add({
|
|
'type': 'text',
|
|
'text': m[0],
|
|
'marks': [
|
|
{
|
|
'type': 'link',
|
|
'attrs': {'href': m[0]},
|
|
},
|
|
],
|
|
});
|
|
at = m.end;
|
|
}
|
|
if (at < line.length) out.add({'type': 'text', 'text': line.substring(at)});
|
|
return out;
|
|
}
|
|
|
|
return {
|
|
'type': 'doc',
|
|
'content': [
|
|
for (final line in text.trim().split(RegExp(r'\r?\n')))
|
|
line.trim().isEmpty
|
|
? {'type': 'paragraph'}
|
|
: {'type': 'paragraph', 'content': inline(line)},
|
|
],
|
|
};
|
|
}
|
|
|
|
/// A title for shared text: the sender's subject, else the first line.
|
|
String sharedTitle(SharedText s) {
|
|
if (s.subject.trim().isNotEmpty) return s.subject.trim();
|
|
final first = s.text.trim().split('\n').first.trim();
|
|
return first.length > 80 ? '${first.substring(0, 79)}…' : first;
|
|
}
|
|
|
|
/// "Save to Docwell": makes a page from text or a link shared by another app.
|
|
class ShareScreen extends StatefulWidget {
|
|
const ShareScreen({super.key, required this.session, required this.shared});
|
|
|
|
final AppSession session;
|
|
final SharedText shared;
|
|
|
|
@override
|
|
State<ShareScreen> createState() => _ShareScreenState();
|
|
}
|
|
|
|
class _ShareScreenState extends State<ShareScreen> {
|
|
DocwellApi get _api => widget.session.api;
|
|
late final _title = TextEditingController(text: sharedTitle(widget.shared));
|
|
List<(Workspace, Space)>? _targets;
|
|
(Workspace, Space)? _target;
|
|
String? _error;
|
|
bool _busy = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_load();
|
|
}
|
|
|
|
/// Every space, in every workspace, the user can add pages to.
|
|
Future<void> _load() async {
|
|
try {
|
|
final targets = <(Workspace, Space)>[];
|
|
for (final ws in await _api.workspaces()) {
|
|
for (final s in await _api.spaces(ws.id)) {
|
|
if (s.role == SpaceCallerRole.admin ||
|
|
s.role == SpaceCallerRole.editor) {
|
|
targets.add((ws, s));
|
|
}
|
|
}
|
|
}
|
|
if (mounted) {
|
|
setState(() {
|
|
_targets = targets;
|
|
_target = targets.firstOrNull;
|
|
});
|
|
}
|
|
} catch (e) {
|
|
if (mounted) setState(() => _error = describeError(e));
|
|
}
|
|
}
|
|
|
|
Future<void> _save() async {
|
|
final target = _target;
|
|
if (target == null) return;
|
|
setState(() => _busy = true);
|
|
try {
|
|
final page = await _api.createPage(
|
|
target.$2.id,
|
|
title: _title.text.trim(),
|
|
);
|
|
await _api.saveContent(page.id, sharedDoc(widget.shared.text));
|
|
if (!mounted) return;
|
|
Navigator.of(context).pushReplacement(
|
|
MaterialPageRoute<void>(
|
|
builder: (_) => PageScreen(session: widget.session, pageId: page.id),
|
|
),
|
|
);
|
|
} catch (e) {
|
|
if (mounted) {
|
|
setState(() {
|
|
_busy = false;
|
|
_error = describeError(e);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_title.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final targets = _targets;
|
|
return Scaffold(
|
|
appBar: AppBar(title: Text(tr('saveTitle'))),
|
|
body: ListView(
|
|
padding: const EdgeInsets.all(16),
|
|
children: [
|
|
TextField(
|
|
key: const Key('share-title'),
|
|
controller: _title,
|
|
decoration: InputDecoration(
|
|
labelText: tr('pageTitle'),
|
|
border: OutlineInputBorder(),
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
if (targets == null && _error == null)
|
|
const Center(child: CircularProgressIndicator())
|
|
else if (targets != null && targets.isEmpty)
|
|
Text(tr('noSpaceToAdd'))
|
|
else if (targets != null)
|
|
DropdownButtonFormField<(Workspace, Space)>(
|
|
initialValue: _target,
|
|
decoration: InputDecoration(
|
|
labelText: tr('space'),
|
|
border: OutlineInputBorder(),
|
|
),
|
|
items: [
|
|
for (final t in targets)
|
|
DropdownMenuItem(
|
|
value: t,
|
|
child: Text(
|
|
'${t.$2.name} · ${t.$1.name}',
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
],
|
|
onChanged: (t) => setState(() => _target = t),
|
|
),
|
|
const SizedBox(height: 16),
|
|
Text(tr('text'), style: Theme.of(context).textTheme.labelLarge),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
widget.shared.text,
|
|
maxLines: 12,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
if (_error != null) ...[
|
|
const SizedBox(height: 12),
|
|
Text(
|
|
_error!,
|
|
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
|
),
|
|
],
|
|
const SizedBox(height: 20),
|
|
FilledButton(
|
|
key: const Key('share-save'),
|
|
onPressed: _busy || _target == null ? null : _save,
|
|
child: Text(tr('saveAsPage')),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|