fix(editor): tables with whole-number sizes, or none, show
The editor casts a table's sizes (its column width, row height, height, and each cell's width and height) to decimals, and finds a row's default height with a null check. JSON written elsewhere may hold whole numbers, 40 where the editor writes 40.0, or no sizes at all: such a table showed Flutter's error box instead. The Writing System paths in an archive brought over from elsewhere hold whole numbers. Opening content now gives its tables their sizes as the editor reads them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MMm7usAo6q9ZZRoPkWjoxi Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
42395a9dbc
commit
277994d31b
1 changed files with 102 additions and 1 deletions
|
|
@ -37,6 +37,61 @@ void main() {
|
|||
await tester.pump(const Duration(seconds: 1));
|
||||
}
|
||||
|
||||
testWidgets('shows a table whose sizes are whole numbers, or missing, as '
|
||||
'JSON written elsewhere may hold them', (tester) async {
|
||||
Map<String, Object?> cell(int column, int row, Map<String, Object?> data) =>
|
||||
{
|
||||
'type': 'table/cell',
|
||||
'data': {'colPosition': column, 'rowPosition': row, ...data},
|
||||
'children': [
|
||||
{
|
||||
'type': 'paragraph',
|
||||
'data': {
|
||||
'delta': [
|
||||
{'insert': '$column$row'},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
for (final (table, cells) in [
|
||||
// As an archive from elsewhere brought it: whole numbers.
|
||||
(
|
||||
{
|
||||
'colsLen': 2,
|
||||
'rowsLen': 1,
|
||||
'colsHeight': 82,
|
||||
'colDefaultWidth': 160,
|
||||
'rowDefaultHeight': 40,
|
||||
'colMinimumWidth': 40,
|
||||
},
|
||||
{'width': 80, 'height': 40},
|
||||
),
|
||||
// Without the editor's sizes.
|
||||
(<String, Object?>{'colsLen': 2, 'rowsLen': 1}, <String, Object?>{}),
|
||||
]) {
|
||||
await show(
|
||||
tester,
|
||||
RichContent({
|
||||
'document': {
|
||||
'type': 'page',
|
||||
'children': [
|
||||
{
|
||||
'type': 'table',
|
||||
'data': table,
|
||||
'children': [cell(0, 0, cells), cell(1, 0, cells)],
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.textContaining('00', findRichText: true), findsOneWidget);
|
||||
expect(find.textContaining('10', findRichText: true), findsOneWidget);
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('shows the content', (tester) async {
|
||||
await show(tester, paragraph('猫は動物です。'));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue