Add tables, to-dos, callouts and the rest of editor parity

The editor gains the blocks and formatting it lacked next to AFFiNE:

- Tables with a header row, resizable columns, a toolbar to add, delete,
  merge and split, and rows that move by a drag grip, toolbar buttons or
  Ctrl+Alt+Up/Down.
- To-do lists (also from "[] "), callouts with an emoji and colour, and
  headings down to level 6 (Ctrl+Shift+0-6 for text and headings).
- Text colour and highlights from a fixed palette that follows the theme,
  and left, centre and right alignment.
- Optional line numbers on code blocks, with a default hosts can set.
- PDF attachments show their pages inline; pdf.js loads only then, and
  the mobile bundle leaves it out.
- The selection toolbar adds underline, colour, align, inline math, make a
  linked page and copy block link. A grip beside each block drags it and
  opens a menu: turn into, move, duplicate, copy, copy link, delete.
- The slash menu adds Today, Tomorrow, Yesterday, Now and New page.

The web app translates the new words and makes linked pages as children
of the open page. The mobile bridge gets underline, to-do, callout and
table commands, so its protocol moves to version 2 and the bundle is
rebuilt.

docwell-server's converters learn the new nodes: Markdown writes task
lists, GitHub alerts and tables and reads them back; HTML keeps colours
and alignment and reads its own output back; PDF draws tables, to-dos,
callouts and coloured text; Word import keeps tables, alignment, H4-H6
and colours; Notion import turns databases into tables and keeps
callouts and to-dos. Imported tables and H4-H6 headings no longer
collapse into paragraphs and H3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tajniak81andClaude Opus 5.5 committed 2026-11-14 12:20:08 +01:00
1 parent 3c7403ddf9
commit d28f1e02db
44 files changed
+4318 -338

No files matched your search

+429 -7
View File
@@ -20,7 +20,7 @@
.dw-prose > * + * {
margin-top: 8px;
}
.dw-prose > :is(h1, h2, h3) {
.dw-prose > :is(h1, h2, h3, h4, h5, h6) {
margin-top: 20px;
}
.dw-prose h1 {
@@ -102,7 +102,7 @@
border-radius: var(--radius-md);
}
.dw-prose img.ProseMirror-selectednode,
.dw-prose .dw-file.ProseMirror-selectednode,
.dw-prose .dw-file-block.ProseMirror-selectednode .dw-file,
.dw-prose .ProseMirror-selectednode:is(.dw-mermaid, .dw-diagram, .dw-toc, .tiptap-mathematics-render) {
outline: 2px solid var(--color-focus-ring);
outline-offset: 2px;
@@ -609,9 +609,17 @@
.dw-block-host {
position: relative;
}
.dw-block-handle {
.dw-block-gutter {
position: absolute;
left: -30px;
right: calc(100% + 6px);
display: flex;
gap: 2px;
}
.dw-block-gutter[hidden],
.dw-block-handle[hidden] {
display: none;
}
.dw-block-handle {
display: grid;
place-items: center;
width: 22px;
@@ -628,7 +636,7 @@
}
/* Phones have no margin to spare and no hover. */
@media (max-width: 640px), (hover: none) {
.dw-block-handle {
.dw-block-gutter {
display: none;
}
}
@@ -706,10 +714,424 @@
/* The page's body font, chosen per page; headings follow it too. */
.dw-font-serif .dw-prose,
.dw-font-serif .dw-prose :is(h1, h2, h3) {
.dw-font-serif .dw-prose :is(h1, h2, h3, h4, h5, h6) {
font-family: var(--font-serif);
}
.dw-font-mono .dw-prose,
.dw-font-mono .dw-prose :is(h1, h2, h3) {
.dw-font-mono .dw-prose :is(h1, h2, h3, h4, h5, h6) {
font-family: var(--font-mono);
}
/* ---- Headings 4–6 ("Other headings") ---- */
.dw-prose h4 {
font-size: var(--text-doc-body);
line-height: var(--text-doc-body--line-height);
font-weight: 600;
}
.dw-prose h5 {
font-size: var(--text-ui-md);
font-weight: 600;
}
.dw-prose h6 {
font-size: var(--text-ui-sm);
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.04em;
color: var(--color-ink-muted);
}
/* ---- Palette colours (colors.ts): text, highlight and callout shades ---- */
:root {
--dw-c-gray: #6b6f6d;
--dw-c-red: #c0392b;
--dw-c-orange: #c2571a;
--dw-c-yellow: #9a7400;
--dw-c-green: #3d7a1f;
--dw-c-teal: #1f7f79;
--dw-c-blue: #2f6fbf;
--dw-c-purple: #7c5cc4;
--dw-c-pink: #b8327a;
--dw-bg-gray: #ecece9;
--dw-bg-red: #fbe3df;
--dw-bg-orange: #fbe7d7;
--dw-bg-yellow: #fbf1c7;
--dw-bg-green: #e4f1d8;
--dw-bg-teal: #d9efec;
--dw-bg-blue: #dfe9f7;
--dw-bg-purple: #ebe4f7;
--dw-bg-pink: #f8e0ec;
}
.dark {
--dw-c-gray: #a3a8a5;
--dw-c-red: #f08a7e;
--dw-c-orange: #f0a26a;
--dw-c-yellow: #e5c454;
--dw-c-green: #93c96b;
--dw-c-teal: #6cc9bf;
--dw-c-blue: #86b2ec;
--dw-c-purple: #b9a2ec;
--dw-c-pink: #eb8fc0;
--dw-bg-gray: #34383a;
--dw-bg-red: #4a2723;
--dw-bg-orange: #4a3020;
--dw-bg-yellow: #45391a;
--dw-bg-green: #2c3f22;
--dw-bg-teal: #1e3d3a;
--dw-bg-blue: #22334d;
--dw-bg-purple: #352b4d;
--dw-bg-pink: #47263a;
}
[data-color="gray"] {
--dw-c: var(--dw-c-gray);
--dw-bg: var(--dw-bg-gray);
}
[data-color="red"] {
--dw-c: var(--dw-c-red);
--dw-bg: var(--dw-bg-red);
}
[data-color="orange"] {
--dw-c: var(--dw-c-orange);
--dw-bg: var(--dw-bg-orange);
}
[data-color="yellow"] {
--dw-c: var(--dw-c-yellow);
--dw-bg: var(--dw-bg-yellow);
}
[data-color="green"] {
--dw-c: var(--dw-c-green);
--dw-bg: var(--dw-bg-green);
}
[data-color="teal"] {
--dw-c: var(--dw-c-teal);
--dw-bg: var(--dw-bg-teal);
}
[data-color="blue"] {
--dw-c: var(--dw-c-blue);
--dw-bg: var(--dw-bg-blue);
}
[data-color="purple"] {
--dw-c: var(--dw-c-purple);
--dw-bg: var(--dw-bg-purple);
}
[data-color="pink"] {
--dw-c: var(--dw-c-pink);
--dw-bg: var(--dw-bg-pink);
}
.dw-prose .dw-text-color {
color: var(--dw-c);
}
.dw-prose mark.dw-highlight {
background: var(--dw-bg, var(--dw-bg-yellow));
color: inherit;
border-radius: 2px;
padding: 0 1px;
}
/* The swatches in the selection toolbar's colour panel. */
.dw-swatch {
display: grid;
place-items: center;
width: 22px;
height: 22px;
border: 1px solid var(--color-line);
border-radius: var(--radius-xs);
background: var(--color-surface);
font-family: var(--font-sans);
font-size: 12px;
font-weight: 700;
color: var(--dw-c, var(--color-ink));
cursor: pointer;
}
.dw-swatch--fill {
background: var(--dw-bg);
}
.dw-swatch--none {
background: linear-gradient(135deg, transparent 45%, var(--color-danger) 45% 55%, transparent 55%);
}
.dw-swatch[aria-pressed="true"],
.dw-swatch:hover {
outline: 2px solid var(--color-focus-ring);
outline-offset: 1px;
}
/* ---- Callouts ---- */
.dw-prose .dw-callout {
display: flex;
gap: 10px;
padding: 12px 16px 12px 12px;
border-radius: var(--radius-md);
background: var(--dw-bg, var(--dw-bg-blue));
}
.dw-callout__side {
display: flex;
flex-direction: column;
align-items: center;
gap: 4px;
user-select: none;
}
.dw-callout__emoji {
display: grid;
place-items: center;
width: 28px;
height: 28px;
border: none;
border-radius: var(--radius-sm);
background: none;
font-size: 20px;
line-height: 1;
cursor: pointer;
}
.dw-callout__emoji:hover {
background: color-mix(in srgb, var(--dw-c) 14%, transparent);
}
.dw-callout__color {
width: 12px;
height: 12px;
border: 2px solid var(--color-surface);
border-radius: 50%;
background: var(--dw-c);
cursor: pointer;
opacity: 0;
}
.dw-callout:hover .dw-callout__color,
.dw-callout__color:focus-visible {
opacity: 1;
}
.dw-prose[contenteditable="false"] .dw-callout__color {
display: none;
}
.dw-prose[contenteditable="false"] .dw-callout__emoji {
cursor: default;
}
.dw-callout__body {
flex: 1;
min-width: 0;
padding-top: 2px;
}
.dw-callout__body > * + * {
margin-top: 8px;
}
/* ---- To-do lists ---- */
.dw-prose ul[data-type="taskList"] {
list-style: none;
padding-left: 2px;
}
.dw-prose ul[data-type="taskList"] li {
display: flex;
align-items: flex-start;
gap: 8px;
}
.dw-prose ul[data-type="taskList"] li > label {
flex-shrink: 0;
margin-top: 0.3em;
user-select: none;
}
.dw-prose ul[data-type="taskList"] li > label input {
width: 16px;
height: 16px;
accent-color: var(--color-primary);
cursor: pointer;
}
.dw-prose ul[data-type="taskList"] li > div {
flex: 1;
min-width: 0;
}
.dw-prose ul[data-type="taskList"] li[data-checked="true"] > div > p {
color: var(--color-ink-muted);
text-decoration: line-through;
}
.dw-prose ul[data-type="taskList"] ul[data-type="taskList"] {
margin-top: 4px;
}
/* ---- Tables ---- */
.dw-prose .tableWrapper {
overflow-x: auto;
margin: 12px 0;
}
.dw-prose table {
border-collapse: collapse;
table-layout: fixed;
width: 100%;
overflow: hidden;
}
.dw-prose :is(td, th) {
position: relative;
min-width: 60px;
padding: 6px 10px;
border: 1px solid var(--color-line-strong);
vertical-align: top;
box-sizing: border-box;
}
.dw-prose :is(td, th) > * + * {
margin-top: 6px;
}
.dw-prose th {
background: var(--color-surface-sunken);
font-weight: 600;
text-align: left;
}
.dw-prose .selectedCell::after {
content: "";
position: absolute;
inset: 0;
background: var(--color-selection);
pointer-events: none;
}
.dw-prose .column-resize-handle {
position: absolute;
top: 0;
right: -2px;
bottom: -2px;
width: 4px;
background: var(--color-focus-ring);
pointer-events: none;
}
.dw-prose.resize-cursor {
cursor: col-resize;
}
/* ---- Code line numbers ---- */
.dw-prose pre.dw-code {
display: flex;
gap: 12px;
}
.dw-prose pre.dw-code > code {
flex: 1;
min-width: 0;
}
.dw-prose pre .dw-code__gutter {
display: none;
flex-shrink: 0;
min-width: 1.5em;
padding-right: 10px;
border-right: 1px solid var(--color-line);
color: var(--color-ink-faint);
text-align: right;
/* ProseMirror resets white-space on parts that are not editable. */
white-space: pre;
user-select: none;
}
.dw-prose pre.dw-code--numbered .dw-code__gutter {
display: block;
}
/* ---- PDFs shown inline ---- */
.dw-prose .dw-file-block > * + * {
margin-top: 6px;
}
.dw-pdf {
display: flex;
flex-direction: column;
gap: 8px;
max-height: 560px;
padding: 8px;
overflow-y: auto;
border: 1px solid var(--color-line);
border-radius: var(--radius-md);
background: var(--color-surface-sunken);
}
.dw-pdf:focus-visible {
outline: 2px solid var(--color-focus-ring);
}
.dw-pdf__page {
width: 100%;
background: #fff;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.dw-pdf__page canvas {
display: block;
width: 100%;
height: auto;
}
.dw-pdf__status {
padding: 24px;
text-align: center;
font-family: var(--font-sans);
font-size: var(--text-ui-sm);
color: var(--color-ink-muted);
}
/* ---- The block grip and its menu ---- */
.dw-block-grip {
cursor: grab;
}
.dw-block-grip[aria-expanded="true"] {
background: var(--color-surface-hover);
color: var(--color-ink);
}
.dw-block-menu {
width: 15rem;
}
.dw-block-menu .dw-suggest__item {
width: 100%;
border: none;
background: none;
font: inherit;
text-align: left;
cursor: pointer;
}
.dw-block-menu .dw-suggest__item.is-active {
background: var(--color-surface-hover);
}
.dw-block-menu .dw-suggest__item:focus {
outline: none;
}
.dw-block-menu .dw-suggest__item.is-danger :is(.dw-suggest__label, .dw-suggest__icon) {
color: var(--color-danger);
}
.dw-block-menu__more {
margin-left: auto;
color: var(--color-ink-faint);
}
/* ---- Moving table rows (tablerows.ts) ---- */
.dw-row-grip {
position: absolute;
z-index: 5;
display: grid;
place-items: center;
width: 14px;
height: 22px;
padding: 0;
border: 1px solid var(--color-line-strong);
border-radius: var(--radius-xs);
background: var(--color-surface-raised);
color: var(--color-ink-faint);
cursor: grab;
touch-action: none;
}
.dw-row-grip::before {
content: "";
width: 4px;
height: 10px;
background: radial-gradient(circle, currentColor 1px, transparent 1.5px) 0 0 / 4px 4px;
}
.dw-row-grip:hover,
.dw-row-grip:active {
color: var(--color-ink);
border-color: var(--color-focus-ring);
}
.dw-row-grip:active {
cursor: grabbing;
}
.dw-row-grip[hidden],
.dw-row-drop[hidden] {
display: none;
}
.dw-row-drop {
position: absolute;
z-index: 5;
height: 2px;
background: var(--color-focus-ring);
pointer-events: none;
}
.dw-prose tr.dw-row-dragging {
opacity: 0.45;
}
@media (max-width: 640px), (hover: none) {
.dw-row-grip {
display: none;
}
}