Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
ab27506
feat(edgeless): build a mind map with no editor, text measurement inj…
Nov 10, 2026
bb75335
fix(edgeless): bound a built mind map's text and wrap long words in l…
Nov 10, 2026
65767d7
chore(edgeless): regenerate the architecture map for the mind map bui…
Nov 10, 2026
b9b1c58
test(edgeless): read node boxes through the surface in the mind map p…
Nov 10, 2026
14cdacd
fix(edgeless): draw the canvas viewer under a strict content security…
Nov 10, 2026
78416b6
fix(edgeless): settle synced docs of named pages and follow only the …
Nov 10, 2026
13357b1
fix(blocks): keep emotion's rules out of a style element a strict pol…
Nov 10, 2026
70e5257
feat(edgeless): make the canvas viewer the editor itself, derived fro…
Nov 10, 2026
b3d0470
test(edgeless): paint the canvas viewer in a browser under a strict p…
Nov 10, 2026
aa0d642
fix(edgeless): viewer guard reads the mounted list, keys and clicks a…
Nov 10, 2026
50664cd
Merge remote-tracking branch 'origin/blocksuite-labre-main' into feat…
Nov 12, 2026
e97977c
chore(edgeless): regenerate the architecture map after the merge
Nov 12, 2026
d7f2d34
fix(database): read a malformed cell as its property default
Nov 12, 2026
a66a21c
fix(blocks): keep a fractional index key before its next neighbour
Nov 12, 2026
6d1f01e
feat(blocks): open the icon picker outside an editor from a public entry
Nov 12, 2026
6503e18
fix(blocks): keep the canvas selection when a table selects or clears
Nov 12, 2026
86eda11
fix(blocks): keep the start number of a numbered list on export
Nov 12, 2026
02a15cb
fix(edgeless): wrap a built mind map's text exactly as the editor does
Nov 12, 2026
730ca5b
test(edgeless): guard the mind map style colour past the palette
Nov 12, 2026
5247d70
feat(playground): build a mind map with no editor from the debug menu
Nov 12, 2026
918df2c
chore(playground): regenerate the architecture map for the mind map r…
Nov 12, 2026
ec83bf3
fix(edgeless): show a focused frame's title badge in the canvas viewer
Nov 12, 2026
b7952a6
test(edgeless): paint the canvas viewer under the site's own policy
Nov 12, 2026
4cb4426
docs: tell a host what a strict policy needs from the canvas viewer
Nov 12, 2026
9cb0812
feat(playground): open the document in the canvas viewer
Nov 12, 2026
f30fdd1
fix(blocks): flip the code toolbar wrap and line-number switches once
Nov 12, 2026
de965d5
fix(database): draw a blank select option as untitled
Nov 12, 2026
cfd83e2
test(edgeless): report the stage a framed canvas viewer stalls at
Nov 12, 2026
15c1284
fix(playground): keep the canvas viewer page's status off window.status
Nov 12, 2026
1020225
chore: refresh the architecture map for the canvas viewer
Nov 12, 2026
27ad2e4
fix(database): open a document row from a read-only desktop view
Nov 12, 2026
0256ac4
chore(database): refresh the architecture map for the tag label
Nov 12, 2026
4508572
fix(edgeless): ignore a pinch step whose fingers started on one point
Nov 12, 2026
73d8e84
fix(edgeless): name a frozen canvas view and repaint it when page fon…
Nov 12, 2026
d7d63f7
docs: say the canvas viewer repaints when the page's fonts load
Nov 12, 2026
56549a5
fix(blocks): keep a native modal dialog open when escape closes the i…
Nov 12, 2026
93d6697
fix(blocks): flip a menu toggle row once per click
Nov 12, 2026
ade058f
fix(blocks): bound the steps moving a fractional index key towards b
Nov 12, 2026
7d642d1
fix(blocks): write no list start past nine digits
Nov 12, 2026
c959280
fix(database): open a read-only kanban card from its cells
Nov 12, 2026
40f98a9
test(blocks): leave the column select-and-clear case to the unit spec
Nov 12, 2026
a1455f1
test(blocks): drop the words path from the code toggle unit spec
Nov 12, 2026
7e6fb0e
docs(edgeless): say why the export options menu rebuilds its rows
Nov 12, 2026
bab59d4
refactor(edgeless): carry the palette values in the library's theme
Nov 12, 2026
de28885
fix(blocks): keep the random postfix past the fractional index step b…
Nov 12, 2026
8004e3b
test(edgeless): drop a duplicate type check and a repeated comment
Nov 12, 2026
54a9907
fix(blocks): give a menu toggle row's focus back after a switch click
Nov 12, 2026
0069e9d
fix(blocks): give the library an emotion instance of its own
Nov 12, 2026
a140c46
fix(edgeless): deny the pages a canvas viewer is not given, free its …
Nov 12, 2026
c327fd2
docs: canvas viewer pages, host seams and emotion instance
Nov 12, 2026
4c08e54
fix(database): decide a kanban card's read-only open at the click
Nov 12, 2026
8c1aafa
fix(blocks): bound the last list number, not the start, on export
Nov 12, 2026
3e69def
chore: refresh the architecture map for the viewer's styles module
Nov 12, 2026
0179f24
docs(blocks): say why the fractional index fallback guard is required
Nov 12, 2026
3213bdc
fix(database): keep a read-only kanban card from opening a row twice
Nov 12, 2026
e6998e3
fix(edgeless): read the host's translation in the canvas viewer's own…
Nov 12, 2026
fe62de7
chore: refresh the architecture map after the viewer translation fix
Nov 12, 2026
aa5c39c
fix(playground): show the interactive canvas viewer across the whole …
Nov 12, 2026
54bf8cd
fix(page): store the outline type-icon switch's own value
Nov 12, 2026
c89de83
docs: record the unpushed host-session work and the browser-start fal…
Nov 12, 2026
bbb78fc
fix(database): read a malformed data-view cell as its column default
Nov 12, 2026
7385047
fix(blocks): refuse an oversized fractional index key with a named error
Nov 12, 2026
83af34d
fix(blocks): keep a shadow-held portal open on a click inside it
Nov 12, 2026
1982460
fix(blocks): count only list items when importing an html start number
Nov 12, 2026
33d8b68
fix(edgeless): cache a canvas character's width by the whole character
Nov 12, 2026
44335e0
docs(database): record the virtual table's missing row open button
Nov 12, 2026
09c9e1c
test(blocks): take every deep shadow query from the shared helper
Nov 12, 2026
b1c6ce3
feat(blocks): unify the emoji picker on the callout's emoji-mart picker
Nov 12, 2026
549b801
fix(blocks): write list markers in plain text
Nov 12, 2026
eb08a8e
fix(blocks): keep frequently used for every emoji picker after one wi…
Nov 12, 2026
945e2b0
fix(database): give a duplicated column its own option ids
Nov 12, 2026
1bc03d0
fix(edgeless): follow a middle click in the canvas viewer through its…
Nov 12, 2026
a49fc3f
fix(blocks): open no emoji picker on a read-only callout
Nov 12, 2026
e37de3f
fix(database): keep a rich-text cell stored as a string in a data-view
Nov 12, 2026
1367140
fix(database): keep a rich-text cell stored as a string
Nov 12, 2026
9d7d485
fix(blocks): name the fractional index stack overflow instead of boun…
Nov 12, 2026
47901a7
fix(blocks): separate copied blocks by a newline in plain text
Nov 12, 2026
d000e2c
fix(database): drag-to-fill a rich-text cell stored as a string
Nov 12, 2026
5e4f935
fix(blocks): name the fractional index overflow on firefox too
Nov 12, 2026
9b1226e
fix(edgeless): drop the canvas viewer's auxclick branch for other but…
Nov 12, 2026
de75035
refactor(blocks): move the list start number rule to affine-shared
Nov 12, 2026
66f812d
fix(blocks): copy the text alone from inside one list item
Nov 12, 2026
0de5685
Merge branch 'fix/fractional-index-between' into recette/2026-11-12
Nov 12, 2026
e5fcb33
Merge branch 'fix/list-export-start' into recette/2026-11-12
Nov 12, 2026
d1cb264
Merge branch 'fix/database-cell-default' into recette/2026-11-12
Nov 12, 2026
4163d80
Merge branch 'fix/select-tag-blank-name' into recette/2026-11-12
Nov 12, 2026
7fb6da6
Merge branch 'fix/database-readonly-row-open' into recette/2026-11-12
Nov 12, 2026
9d43478
Merge branch 'fix/table-selection-keeps-canvas' into recette/2026-11-12
Nov 12, 2026
2a56c1c
Merge branch 'fix/code-toggle-double' into recette/2026-11-12
Nov 12, 2026
1d2f5d2
Merge branch 'fix/menu-toggle-row' into recette/2026-11-12
Nov 12, 2026
91f4f67
Merge branch 'feat/icon-picker-standalone' into recette/2026-11-12
Nov 12, 2026
e4a9135
Merge branch 'feat/unified-emoji-picker' into recette/2026-11-12
Nov 12, 2026
08aa090
Merge branch 'feat/mindmap-headless-builder' into recette/2026-11-12
Nov 12, 2026
babac7d
Merge branch 'feat/canvas-viewer-editor' into recette/2026-11-12
Nov 12, 2026
3235c76
Merge branch 'fix/data-view-cell-default' into recette/2026-11-12
Nov 12, 2026
5bb7118
Merge branch 'fix/database-duplicate-property-options' into recette/2…
Nov 12, 2026
3586ae2
Merge branch 'fix/outline-setting-toggle' into recette/2026-11-12
Nov 12, 2026
4f5d947
Merge branch 'fix/portal-click-away-composed' into recette/2026-11-12
Nov 12, 2026
bff0877
Merge branch 'fix/text-char-width-codepoint' into recette/2026-11-12
Nov 12, 2026
e2c578e
Merge branch 'fix/list-html-import-order' into recette/2026-11-12
Nov 12, 2026
406824a
Merge branch 'fix/plain-text-list-markers' into recette/2026-11-12
Nov 12, 2026
d1d7c97
Merge branch 'fix/plain-text-block-separator' into recette/2026-11-12
Nov 12, 2026
a94136b
Merge branch 'docs/lessons-3-5-0' into recette/2026-11-12
Nov 12, 2026
bbbfb00
chore: refresh the architecture map for the recette merge
Nov 12, 2026
7cb87b5
chore(blocks): drop the switch click stop the toggle fix made redundant
Nov 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(blocks): keep the canvas selection when a table selects or clears
The table selection controller wrote its selection with `set` and
cleared it with `clear()`, both of which replace every selection group.
In edgeless that dropped the `gfx` group: the note being edited left edit
mode when the caret entered a cell, and selecting then clearing a column
wiped an unrelated canvas selection. `setSelected` now writes only the
`TableSelection` group through `setGroup` (issue #659, upstream
toeverything/AFFiNE#15791).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Loading branch information
r and claude committed Nov 12, 2026
commit 6503e18e528d75d653fd69b1bfafe1873427604b
5 changes: 5 additions & 0 deletions .changeset/table-selection-keeps-canvas.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@labre/affine-block-table': patch
---

A table selection no longer wipes the canvas selection: in edgeless, placing the caret in a table cell or selecting then clearing a column keeps the note in edit mode and leaves other selected canvas elements selected (#659, upstream toeverything/AFFiNE#15791).
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* A table selection lives in the `note` group, beside the canvas selection
* (`gfx` group) of the note being edited. `setSelected` once wrote it with
* `selection.set([...])` and cleared it with `selection.clear()`, which
* replace every group: in edgeless, focusing a cell or selecting then
* clearing a column dropped the canvas selection, so the note left edit mode
* under the user's caret (issue #659, upstream toeverything/AFFiNE#15791).
*
* The spec drives the real `StoreSelectionExtension` and reads the `gfx`
* group back after each write. The canvas side of the same path is held by
* `integration-test/src/__tests__/edgeless/table-selection-keeps-canvas.spec.ts`.
*/
import { SurfaceSelection } from '@labre/std';
import { type Store, StoreSelectionExtension } from '@labre/store';
import { describe, expect, it } from 'vitest';

import { SelectionController } from '../selection-controller.js';
import type { TableBlockComponent } from '../table-block.js';

function createController() {
const store = {
id: 'doc',
awarenessStore: { setLocalSelection: () => {} },
} as unknown as Store;
const selection = new StoreSelectionExtension(store);
const host = {
model: { id: 'table' },
selection,
addController: () => {},
} as unknown as TableBlockComponent;
return { controller: new SelectionController(host), selection };
}

describe('table selection group', () => {
it('keeps the canvas selection when a column is selected then cleared', () => {
const { controller, selection } = createController();
const canvas = new SurfaceSelection('surface', ['note'], true);
selection.setGroup('gfx', [canvas]);

controller.setSelected({ type: 'column', columnId: 'column' });

expect(controller.getSelected()).toEqual({
type: 'column',
columnId: 'column',
});
expect(selection.getGroup('gfx')).toEqual([canvas]);

controller.setSelected(undefined);

expect(controller.getSelected()).toBeUndefined();
expect(selection.getGroup('gfx')).toEqual([canvas]);
});
});
7 changes: 5 additions & 2 deletions packages/affine/blocks/table/src/selection-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -597,14 +597,17 @@ export class SelectionController implements ReactiveController {
if (removeNativeSelection) {
getSelection()?.removeAllRanges();
}
this.host.selection.set([
// One group, never all of them: `set` and `clear()` would also drop the
// canvas selection of the note being edited (`gfx` group), so in
// edgeless the note left edit mode under the caret (#659).
this.host.selection.setGroup(TableSelection.group, [
new TableSelection({
blockId: this.host.model.id,
data: selection,
}),
]);
} else {
this.host.selection.clear();
this.host.selection.setGroup(TableSelection.group, []);
}
}
selected$ = computed(() => this.getSelected());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/**
* A table selection belongs to the `note` group; the canvas selection of the
* note being edited belongs to the `gfx` group. The table's selection
* controller once wrote its selection with `selection.set([...])` and cleared
* it with `selection.clear()`, which replace EVERY group (issue #659, upstream
* toeverything/AFFiNE#15791). In edgeless that meant:
*
* - placing the caret in a cell (the cell answers with an `area` selection)
* dropped the note's editing selection, so the note left edit mode under
* the user's caret;
* - selecting then clearing a column (the column menu does both) replaced an
* unrelated canvas selection with nothing.
*
* Both paths are driven here on a real edgeless editor and the `gfx` group is
* read back after each one. Page mode runs the same steps to hold that the
* fix writes no canvas selection where there was none. No pointer gesture:
* the selection is set through the selection API, as the column menu and the
* cell focus do, so the spec does not depend on where the shared page left
* the camera.
*/
import type { TableSelectionData } from '@labre/affine/blocks/table';
import { SurfaceSelection } from '@labre/std';
import { Text } from '@labre/store';
import { userEvent } from '@vitest/browser/context';
import { beforeEach, describe, expect, test } from 'vitest';

import { wait } from '../utils/common.js';
import { addNote } from '../utils/edgeless.js';
import { setupEditor } from '../utils/setup.js';

// The block component is not exported by the table package: the spec only
// needs the controller it hangs off.
type TableHost = HTMLElement & {
selectionController: {
setSelected(selection: TableSelectionData | undefined): void;
getSelected(): TableSelectionData | undefined;
};
};

type CellHost = HTMLElement & {
inlineEditor?: { focusEnd(): void };
};

function addTable(noteId: string) {
return doc.addBlock(
'affine:table',
{
rows: { row: { rowId: 'row', order: 'a0' } },
columns: { column: { columnId: 'column', order: 'a0' } },
cells: { 'row:column': { text: new Text('abc') } },
},
noteId
);
}

function cellText(tableId: string) {
const model = doc.getBlock(tableId)!.model as unknown as {
props: { cells: Record<string, { text: { toString(): string } }> };
};
return model.props.cells['row:column']!.text.toString();
}

describe.each(['page', 'edgeless'] as const)(
'table selection in %s mode',
mode => {
let noteId!: string;
let tableId!: string;
let table!: TableHost;
let canvas!: SurfaceSelection[];

beforeEach(async () => {
const cleanup = await setupEditor(mode);
noteId = addNote(doc);
tableId = addTable(noteId);
await wait();
table = editor.host!.view.getBlock(tableId) as unknown as TableHost;
const surfaceId = doc.getModelsByFlavour('affine:surface')[0]!.id;
canvas =
mode === 'edgeless'
? [new SurfaceSelection(surfaceId, [noteId], true)]
: [];
if (mode === 'edgeless') {
editor.std.selection.setGroup('gfx', canvas);
}
return cleanup;
});

test('typing at the end of a cell keeps the note in edit mode', async () => {
const cell = table.querySelector('affine-table-cell') as CellHost;
cell.inlineEditor!.focusEnd();
await wait(50);

expect(table.selectionController.getSelected()?.type).toBe('area');
expect(editor.std.selection.getGroup('gfx')).toEqual(canvas);

await userEvent.keyboard('xyz');
await wait(50);

expect(cellText(tableId)).toBe('abcxyz');
expect(editor.std.selection.getGroup('gfx')).toEqual(canvas);
});

test('selecting then clearing a column keeps the canvas selection', async () => {
table.selectionController.setSelected({
type: 'column',
columnId: 'column',
});
expect(table.selectionController.getSelected()?.type).toBe('column');
expect(editor.std.selection.getGroup('gfx')).toEqual(canvas);

table.selectionController.setSelected(undefined);
expect(table.selectionController.getSelected()).toBeUndefined();
expect(editor.std.selection.getGroup('gfx')).toEqual(canvas);
});
}
);