CI / go (Server) (push) Failing after 4m1s
CI / go (Web-App) (push) Successful in 10m50s
CI / frontend (push) Failing after 6m46s
CI / desktop (ubuntu-latest) (push) Successful in 1h10m39s
CI / mobile (push) Failing after 3m2s
CI / docker (push) Successful in 35m59s
Docs / build (push) Successful in 13m26s
Docs / deploy (push) Skipped
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
Phase C of docs/AFFINE.md (ADR-13).
A database is a block whose records live in the page's Y.Doc, in
ydoc.getMap("blocks") under the block's id: columns, rows (each cell its
own map entry, so concurrent edits to one row merge) and views. Order is
a fractional position per item, so moving a row keeps edits made to it at
the same time. Database edits share the page's undo history.
- Thirteen property types: title, text, number, checkbox, select,
multi-select, date, progress, link, attachment, member, created time
and created by. The column menu renames, changes type (converting the
values), sorts, filters, hides, inserts, moves, duplicates and deletes;
columns resize and drag.
- Table view: keyboard navigation, range selection, typing to edit,
copy and paste with spreadsheets (pasting adds rows as needed), row
dragging, bulk delete, grouping.
- Views in tabs, each with its own filters (all/any), sorts, grouping
and visible properties; kanban grouped by select, multi-select,
checkbox or member with cards dragged between columns; calendar by a
date property with records dragged between days.
- A record opens beside the page with its properties and a body of its
own (a Y.XmlFragment in the row, edited by a second editor).
- /database, Ctrl+G or "Group as database" turns a list into a database;
CSV export and import; a copied, pasted or duplicated database gets
its own copy of the records.
Server: yrs writes each database's records into its node as attrs.data
when it turns a document into JSON, adds them to the search text, and
writes them back on imports, restores and templates. Markdown, HTML,
PDF and Word exports show a database as a table of its first view's
columns. Notion database CSVs import as database blocks with guessed
types. Share links and history previews show databases read-only.
Strings are translated into all five languages, the user guide covers
databases, and the mobile editor bundle is rebuilt.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
1.5 KiB
Go
49 lines
1.5 KiB
Go
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
package convert
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestDatabaseExportsAsTable(t *testing.T) {
|
|
doc, err := Parse([]byte(`{"type":"doc","content":[{"type":"callout","content":[{"type":"database","attrs":{"id":"d","data":{
|
|
"title":"Tasks",
|
|
"columns":[
|
|
{"id":"t","name":"Name","type":"title"},
|
|
{"id":"s","name":"Status","type":"select","options":[{"id":"o","name":"Doing","color":"blue"}]},
|
|
{"id":"m","name":"Tags","type":"multiSelect","options":[{"id":"a","name":"red"},{"id":"b","name":"blue"}]},
|
|
{"id":"c","name":"Done","type":"checkbox"},
|
|
{"id":"h","name":"Secret","type":"text"}
|
|
],
|
|
"rows":[
|
|
{"id":"r1","createdAt":1,"cells":{"t":"Write","s":"o","m":["a","b"],"c":true,"h":"x"}},
|
|
{"id":"r2","createdAt":2,"cells":{"t":"Ship"}}
|
|
],
|
|
"views":[{"id":"v","type":"table","hidden":["h"]}]
|
|
}}}]}]}`))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
md := Markdown(doc, Options{})
|
|
for _, want := range []string{"**Tasks**", "| Name | Status | Tags | Done |", "| Write | Doing | red, blue | ✓ |", "| Ship |"} {
|
|
if !strings.Contains(md, want) {
|
|
t.Errorf("markdown lacks %q:\n%s", want, md)
|
|
}
|
|
}
|
|
if strings.Contains(md, "Secret") {
|
|
t.Errorf("hidden column exported:\n%s", md)
|
|
}
|
|
h := HTML(doc, Options{})
|
|
if !strings.Contains(h, "<th>") || !strings.Contains(h, "Doing") {
|
|
t.Errorf("html lacks the table:\n%s", h)
|
|
}
|
|
if _, err := DOCX("T", doc, DOCXOptions{}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := PDF("T", doc, PDFOptions{}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|