Add databases: table, kanban and calendar views with rows as pages
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>
This commit is contained in:
tajniak81andClaude Opus 5.5 committed 2026-11-14 20:06:18 +01:00
1 parent 53dd43cc2e
commit 3102a476a6
34 files changed
+6833 -83

No files matched your search

+927
View File
@@ -1240,3 +1240,930 @@
.dw-prose .dw-synced__body .dw-prose {
min-height: 0;
}
/* ---- Databases (database/): table, kanban and calendar views ---- */
.dw-db-node {
margin: 1em 0;
}
.dw-db {
font-family: var(--font-sans);
font-size: 14px;
color: var(--color-ink);
}
.dw-db__head {
margin-bottom: 4px;
}
.dw-db__title,
.dw-db__title-input {
font-size: 1.25rem;
font-weight: 650;
line-height: 1.3;
}
.dw-db__title .is-empty {
color: var(--color-ink-faint);
}
.dw-db__title-input {
width: 100%;
padding: 2px 0;
border: none;
background: none;
color: inherit;
font-family: inherit;
}
.dw-db__title-input:focus {
outline: none;
}
.dw-db__title-input::placeholder {
color: var(--color-ink-faint);
}
.dw-db__bar {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 4px 12px;
padding-bottom: 4px;
border-bottom: 1px solid var(--color-line);
}
.dw-db__tabs,
.dw-db__tools {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 2px;
}
.dw-db__tab,
.dw-db__btn {
display: inline-flex;
align-items: center;
gap: 6px;
min-height: 28px;
padding: 2px 8px;
border: none;
border-radius: var(--radius-sm);
background: none;
color: var(--color-ink-muted);
font: inherit;
font-size: 13px;
white-space: nowrap;
cursor: pointer;
}
.dw-db__tab:hover,
.dw-db__btn:hover:not(:disabled) {
background: var(--color-surface-hover);
color: var(--color-ink);
}
.dw-db__tab.is-active {
color: var(--color-ink);
font-weight: 600;
box-shadow: inset 0 -2px 0 var(--color-accent);
border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.dw-db__btn--icon {
width: 28px;
padding: 0;
justify-content: center;
}
.dw-db__btn.is-on {
color: var(--color-accent);
}
.dw-db__btn:disabled {
opacity: 0.4;
cursor: default;
}
.dw-db__btn[hidden] {
display: none;
}
.dw-db__btn--primary {
background: var(--color-primary);
color: var(--color-on-primary);
}
.dw-db__btn--primary:hover:not(:disabled) {
background: var(--color-primary-hover);
color: var(--color-on-primary);
}
.dw-db__tab:focus-visible,
.dw-db__btn:focus-visible,
.dw-db-t__head:focus-visible,
.dw-db-t__wrap:focus-visible,
.dw-db-k__card:focus-visible,
.dw-db-peek__value:focus-visible {
outline: 2px solid var(--color-focus-ring);
outline-offset: 1px;
}
.dw-db__search {
width: 12rem;
max-width: 50vw;
}
.dw-db__search[hidden] {
display: none;
}
.dw-db__bulk {
display: flex;
align-items: center;
gap: 8px;
padding: 4px 8px;
margin-top: 4px;
border-radius: var(--radius-sm);
background: var(--color-accent-soft);
font-size: 13px;
}
.dw-db__bulk[hidden] {
display: none;
}
.dw-db__empty {
margin: 12px 0;
color: var(--color-ink-faint);
font-size: 13px;
}
.dw-db__more {
margin-top: 4px;
}
.dw-db-input {
width: 100%;
min-height: 30px;
padding: 4px 8px;
border: 1px solid var(--color-line);
border-radius: var(--radius-sm);
background: var(--color-surface);
color: var(--color-ink);
font: inherit;
font-size: 13px;
}
.dw-db-input--small {
width: 9rem;
}
.dw-db-input:focus,
.dw-db-select:focus {
outline: 2px solid var(--color-focus-ring);
outline-offset: -1px;
}
.dw-db-select {
min-height: 30px;
max-width: 12rem;
padding: 2px 6px;
border: 1px solid var(--color-line);
border-radius: var(--radius-sm);
background: var(--color-surface);
color: var(--color-ink);
font: inherit;
font-size: 13px;
}
/* Tags (select choices), people and files inside cells. */
.dw-db-tags {
display: inline-flex;
flex-wrap: wrap;
gap: 4px;
min-width: 0;
}
.dw-db-tag {
display: inline-flex;
align-items: center;
gap: 2px;
max-width: 100%;
padding: 0 6px;
border-radius: var(--radius-xs);
background: var(--dw-bg, var(--dw-bg-gray));
color: var(--color-ink);
font-size: 12.5px;
line-height: 20px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.dw-db-tag__x {
padding: 0 2px;
border: none;
background: none;
color: var(--color-ink-muted);
font: inherit;
cursor: pointer;
}
.dw-db-person,
.dw-db-file {
display: inline-flex;
align-items: center;
gap: 4px;
font-size: 13px;
color: var(--color-ink);
text-decoration: none;
white-space: nowrap;
}
.dw-db-person__dot {
display: inline-grid;
place-items: center;
width: 18px;
height: 18px;
border-radius: 50%;
background: var(--color-accent-soft);
color: var(--color-accent);
font-size: 10px;
font-weight: 700;
}
.dw-db-check {
display: inline-grid;
place-items: center;
width: 16px;
height: 16px;
border: 1.5px solid var(--color-line-strong);
border-radius: 4px;
vertical-align: middle;
}
.dw-db-check.is-on {
border-color: var(--color-accent);
background: var(--color-accent);
color: var(--color-on-primary);
}
.dw-db-progress {
display: inline-flex;
align-items: center;
gap: 8px;
width: 100%;
}
.dw-db-progress__bar {
flex: 1;
height: 6px;
border-radius: 3px;
background: var(--color-surface-sunken);
overflow: hidden;
}
.dw-db-progress__fill {
display: block;
height: 100%;
background: var(--color-accent);
}
.dw-db-progress__num {
min-width: 3ch;
color: var(--color-ink-muted);
font-size: 12px;
font-variant-numeric: tabular-nums;
}
.dw-db-cell__title {
font-weight: 550;
}
.dw-db-cell__title.is-empty {
color: var(--color-ink-faint);
font-weight: 400;
}
.dw-db-cell__number {
display: block;
text-align: right;
font-variant-numeric: tabular-nums;
}
.dw-db-cell__link {
color: var(--color-accent);
text-decoration: underline;
text-underline-offset: 2px;
}
/* ---- Table view ---- */
.dw-db-t__wrap {
overflow-x: auto;
outline: none;
}
.dw-prose .dw-db-t,
.dw-db-t {
width: max-content;
min-width: 100%;
margin: 0;
border-collapse: collapse;
table-layout: fixed;
}
.dw-prose .dw-db-t th,
.dw-prose .dw-db-t td,
.dw-db-t th,
.dw-db-t td {
position: relative;
min-width: 0;
padding: 0;
border: none;
border-bottom: 1px solid var(--color-line);
background: none;
text-align: left;
vertical-align: middle;
}
.dw-prose .dw-db-t th + th,
.dw-prose .dw-db-t td.dw-db-t__cell + td.dw-db-t__cell,
.dw-db-t th + th,
.dw-db-t td.dw-db-t__cell + td.dw-db-t__cell {
border-left: 1px solid var(--color-line);
}
.dw-db-t__gutter-col {
width: 48px;
}
.dw-db-t__add-col {
width: 40px;
}
.dw-db-t__gutter {
white-space: nowrap;
}
.dw-db-t__pick,
.dw-db-t__grip {
opacity: 0;
vertical-align: middle;
}
.dw-db-t__grip {
display: inline-grid;
color: var(--color-ink-faint);
cursor: grab;
}
.dw-db-t tr:hover .dw-db-t__pick,
.dw-db-t tr:hover .dw-db-t__grip,
.dw-db-t tr.is-picked .dw-db-t__pick,
.dw-db-t__pick:focus-visible {
opacity: 1;
}
.dw-db-t tr.is-picked td {
background: var(--color-accent-soft);
}
.dw-db-t__head {
display: flex;
align-items: center;
gap: 6px;
width: 100%;
min-height: 34px;
padding: 0 8px;
border: none;
background: none;
color: var(--color-ink-muted);
font: inherit;
font-size: 13px;
font-weight: 500;
text-align: left;
cursor: pointer;
}
.dw-db-t__head:hover {
background: var(--color-surface-hover);
}
.dw-db-t__name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.dw-db-t__name-input {
width: 100%;
min-height: 34px;
padding: 0 8px;
border: none;
background: var(--color-surface);
color: var(--color-ink);
font: inherit;
font-size: 13px;
outline: 2px solid var(--color-focus-ring);
outline-offset: -2px;
}
.dw-db-t__resize {
position: absolute;
top: 0;
right: -3px;
z-index: 1;
width: 6px;
height: 100%;
cursor: col-resize;
}
.dw-db-t__resize:hover {
background: var(--color-accent);
}
.dw-db-t th.is-drop {
box-shadow: inset 3px 0 0 var(--color-accent);
}
.dw-prose .dw-db-t td.dw-db-t__cell,
.dw-db-t__cell {
height: 34px;
padding: 4px 8px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
cursor: default;
}
.dw-db-t__cell.is-in-range {
background: var(--color-selection);
}
.dw-db-t__cell.is-selected {
box-shadow: inset 0 0 0 2px var(--color-focus-ring);
}
.dw-prose .dw-db-t td.dw-db-t__cell.is-editing {
padding: 0;
}
.dw-db-cell__input {
width: 100%;
height: 34px;
padding: 0 8px;
border: none;
background: var(--color-surface);
color: var(--color-ink);
font: inherit;
outline: 2px solid var(--color-focus-ring);
outline-offset: -2px;
}
.dw-db-t__open {
position: absolute;
top: 50%;
right: 6px;
display: none;
align-items: center;
gap: 4px;
padding: 2px 6px;
border: 1px solid var(--color-line);
border-radius: var(--radius-xs);
background: var(--color-surface-raised);
color: var(--color-ink-muted);
font: inherit;
font-size: 12px;
transform: translateY(-50%);
cursor: pointer;
}
.dw-db-t tr:hover .dw-db-t__open,
.dw-db-t__open:focus-visible {
display: inline-flex;
}
.dw-db-t tr.is-drop-above td {
box-shadow: inset 0 2px 0 var(--color-accent);
}
.dw-db-t tr.is-drop-below td {
box-shadow: inset 0 -2px 0 var(--color-accent);
}
.dw-db-t__new,
.dw-db-t__group {
display: inline-flex;
align-items: center;
gap: 6px;
width: 100%;
min-height: 32px;
padding: 0 8px;
border: none;
background: none;
color: var(--color-ink-faint);
font: inherit;
font-size: 13px;
text-align: left;
cursor: pointer;
}
.dw-db-t__new:hover {
background: var(--color-surface-hover);
color: var(--color-ink);
}
.dw-db-t__group {
color: var(--color-ink);
font-weight: 600;
padding-top: 8px;
}
.dw-db-t__count {
color: var(--color-ink-faint);
font-size: 12px;
font-weight: 400;
}
.dw-prose .dw-db-t .dw-db-t__group-row td,
.dw-prose .dw-db-t .dw-db-t__new-row td {
border-bottom-color: transparent;
}
/* ---- Kanban view ---- */
.dw-db-k {
display: flex;
gap: 12px;
padding: 12px 0 4px;
overflow-x: auto;
}
.dw-db-k__col {
flex: 0 0 260px;
display: flex;
flex-direction: column;
gap: 8px;
}
.dw-db-k__head {
display: flex;
align-items: center;
gap: 8px;
min-height: 24px;
font-size: 13px;
}
.dw-db-k__label {
font-weight: 600;
}
.dw-db-k__cards {
display: flex;
flex-direction: column;
gap: 6px;
min-height: 48px;
padding: 4px;
border-radius: var(--radius-md);
background: var(--color-surface-sunken);
}
.dw-db-k__cards.is-drop {
outline: 2px dashed var(--color-accent);
outline-offset: -2px;
}
.dw-db-k__card {
display: flex;
flex-direction: column;
gap: 4px;
padding: 8px 10px;
border: 1px solid var(--color-line);
border-radius: var(--radius-sm);
background: var(--color-surface-raised);
box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
cursor: pointer;
}
.dw-db-k__card:hover {
border-color: var(--color-line-strong);
}
.dw-db-k__card.is-dragging {
opacity: 0.4;
}
.dw-db-k__prop .dw-db-cell__number {
text-align: left;
}
.dw-db-k__prop {
min-width: 0;
overflow: hidden;
color: var(--color-ink-muted);
font-size: 13px;
text-overflow: ellipsis;
white-space: nowrap;
}
/* ---- Calendar view ---- */
.dw-db-c {
padding-top: 8px;
}
.dw-db-c__nav {
display: flex;
align-items: center;
gap: 4px;
margin-bottom: 8px;
}
.dw-db-c__month {
margin-right: auto;
font-size: 15px;
text-transform: capitalize;
}
.dw-db-c__grid {
display: grid;
grid-template-columns: repeat(7, minmax(0, 1fr));
border-top: 1px solid var(--color-line);
border-left: 1px solid var(--color-line);
}
.dw-db-c__wd {
padding: 4px 6px;
border-right: 1px solid var(--color-line);
border-bottom: 1px solid var(--color-line);
color: var(--color-ink-muted);
font-size: 12px;
text-transform: capitalize;
}
.dw-db-c__day {
position: relative;
display: flex;
flex-direction: column;
gap: 2px;
min-width: 0;
min-height: 88px;
padding: 4px;
border-right: 1px solid var(--color-line);
border-bottom: 1px solid var(--color-line);
}
.dw-db-c__day.is-out {
background: var(--color-surface-sunken);
}
.dw-db-c__day.is-out .dw-db-c__num {
color: var(--color-ink-faint);
}
.dw-db-c__day.is-drop {
background: var(--color-accent-soft);
}
.dw-db-c__num {
align-self: flex-start;
min-width: 22px;
padding: 0 4px;
border-radius: 11px;
font-size: 12px;
line-height: 22px;
text-align: center;
}
.dw-db-c__day.is-today .dw-db-c__num {
background: var(--color-accent);
color: var(--color-on-primary);
font-weight: 700;
}
.dw-db-c__chip {
display: block;
width: 100%;
padding: 1px 6px;
border: none;
border-radius: var(--radius-xs);
background: var(--color-accent-soft);
color: var(--color-ink);
font: inherit;
font-size: 12px;
text-align: left;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
cursor: pointer;
}
.dw-db-c__add {
position: absolute;
top: 4px;
right: 4px;
display: none;
place-items: center;
width: 20px;
height: 20px;
border: none;
border-radius: var(--radius-xs);
background: var(--color-surface-hover);
color: var(--color-ink-muted);
cursor: pointer;
}
.dw-db-c__day:hover .dw-db-c__add,
.dw-db-c__add:focus-visible {
display: grid;
}
.dw-db-c__undated {
margin-top: 8px;
font-size: 13px;
color: var(--color-ink-muted);
}
.dw-db-c__chips {
display: flex;
flex-wrap: wrap;
gap: 4px;
margin-top: 6px;
}
.dw-db-c__chips .dw-db-c__chip {
width: auto;
max-width: 16rem;
}
@media (max-width: 640px) {
.dw-db-c__day {
min-height: 56px;
}
.dw-db-c__chip {
padding: 0 3px;
font-size: 11px;
}
.dw-db__tools .dw-db__btn span {
display: none;
}
}
/* ---- Panels and pickers (outside the page, in body) ---- */
.dw-db-pop {
position: fixed;
z-index: 70;
left: 0;
top: 0;
display: flex;
flex-direction: column;
gap: 6px;
min-width: 14rem;
max-width: calc(100vw - 16px);
max-height: 24rem;
overflow-y: auto;
padding: 8px;
border: 1px solid var(--color-line);
border-radius: var(--radius-md);
background: var(--color-surface-raised);
box-shadow: var(--shadow-menu);
color: var(--color-ink);
font-family: var(--font-sans);
font-size: 13px;
}
.dw-db-pop--panel {
min-width: 20rem;
}
.dw-db-pop--choices {
width: 18rem;
}
.dw-db-pop__row {
display: flex;
align-items: center;
gap: 6px;
}
.dw-db-pop__row--end {
justify-content: flex-end;
}
.dw-db-pop__line {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 4px;
}
.dw-db-pop__label {
color: var(--color-ink-muted);
font-size: 12px;
}
.dw-db-pop__list {
display: flex;
flex-direction: column;
gap: 1px;
}
.dw-db-pop__item {
display: flex;
align-items: center;
gap: 8px;
width: 100%;
min-height: 30px;
padding: 2px 6px;
border: none;
border-radius: var(--radius-sm);
background: none;
color: var(--color-ink);
font: inherit;
text-align: left;
cursor: pointer;
}
.dw-db-pop__item:hover:not(:disabled),
.dw-db-pop__item.is-active {
background: var(--color-surface-hover);
}
.dw-db-pop__item:disabled {
cursor: default;
opacity: 0.7;
}
.dw-db-pop__check {
display: inline-grid;
place-items: center;
width: 16px;
color: var(--color-ink-muted);
}
.dw-db-pop__grow {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.dw-db-pop__more {
margin-left: auto;
}
.dw-db-pop__chosen:empty {
display: none;
}
.dw-db-pop__empty {
margin: 4px 2px;
color: var(--color-ink-faint);
}
.dw-db-pop__add {
align-self: flex-start;
}
.dw-db-switch {
position: relative;
flex-shrink: 0;
width: 28px;
height: 16px;
border-radius: 8px;
background: var(--color-line-strong);
}
.dw-db-switch::after {
content: "";
position: absolute;
top: 2px;
left: 2px;
width: 12px;
height: 12px;
border-radius: 50%;
background: var(--color-surface);
transition: transform 0.12s;
}
.dw-db-switch.is-on {
background: var(--color-accent);
}
.dw-db-switch.is-on::after {
transform: translateX(12px);
}
.dw-db-range {
flex: 1;
accent-color: var(--color-accent);
}
/* ---- A row opened as a page ---- */
.dw-db-peek {
position: fixed;
inset: 0;
z-index: 65;
display: flex;
justify-content: flex-end;
background: rgb(0 0 0 / 0.25);
}
.dw-db-peek__panel {
display: flex;
flex-direction: column;
width: min(720px, 100vw);
height: 100%;
overflow-y: auto;
background: var(--color-surface);
box-shadow: var(--shadow-dialog);
outline: none;
font-family: var(--font-sans);
color: var(--color-ink);
}
.dw-db-peek__panel.is-wide {
width: 100vw;
}
.dw-db-peek__head {
position: sticky;
top: 0;
z-index: 1;
display: flex;
align-items: center;
gap: 4px;
padding: 8px 16px;
border-bottom: 1px solid var(--color-line);
background: var(--color-surface);
}
.dw-db-peek__db {
display: inline-flex;
align-items: center;
gap: 6px;
min-width: 0;
color: var(--color-ink-muted);
font-size: 13px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.dw-db-peek__grow {
flex: 1;
}
.dw-db-peek__props {
display: flex;
flex-direction: column;
gap: 2px;
padding: 24px 48px 12px;
border-bottom: 1px solid var(--color-line);
}
.dw-db-peek__panel.is-wide .dw-db-peek__props,
.dw-db-peek__panel.is-wide .dw-db-peek__body {
box-sizing: border-box;
width: min(900px, 100%);
margin: 0 auto;
}
.dw-db-peek__title {
width: 100%;
margin: 0 0 12px;
padding: 0;
border: none;
background: none;
color: var(--color-ink);
font: inherit;
font-size: 1.75rem;
font-weight: 700;
line-height: 1.25;
}
.dw-db-peek__title:focus {
outline: none;
}
.dw-db-peek__prop {
display: grid;
grid-template-columns: 11rem minmax(0, 1fr);
align-items: center;
min-height: 34px;
}
.dw-db-peek__label {
display: flex;
align-items: center;
gap: 6px;
overflow: hidden;
color: var(--color-ink-muted);
font-size: 13px;
white-space: nowrap;
}
.dw-db-peek__value {
display: flex;
align-items: center;
min-width: 0;
min-height: 30px;
padding: 2px 8px;
border-radius: var(--radius-sm);
cursor: pointer;
}
.dw-db-peek__value:hover {
background: var(--color-surface-hover);
}
.dw-db-peek__value.is-editing {
padding: 0;
}
.dw-db-peek__add {
align-self: flex-start;
margin-top: 4px;
}
.dw-db-peek__body {
padding: 16px 48px 64px;
}
.dw-db-peek__note {
color: var(--color-ink-faint);
font-size: 14px;
}
@media (max-width: 640px) {
.dw-db-peek__props,
.dw-db-peek__body {
padding-left: 16px;
padding-right: 16px;
}
.dw-db-peek__prop {
grid-template-columns: 8rem minmax(0, 1fr);
}
}