Skip to content

Commit

Permalink
Chore: deprecate embed table feature (#2254)
Browse files Browse the repository at this point in the history
  • Loading branch information
CatHood0 authored Sep 21, 2024
1 parent f3089c5 commit 4953bd1
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 12 deletions.
1 change: 0 additions & 1 deletion example/lib/screens/quill/my_quill_toolbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ class MyQuillToolbar extends StatelessWidget {
: onImageInsert,
),
),
tableButtonOptions: const QuillToolbarTableButtonOptions(),
),
),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:meta/meta.dart';

@experimental
@Deprecated(
'TableCellWidget will no longer used and it will be removed in future releases')
class TableCellWidget extends StatefulWidget {
const TableCellWidget({
required this.cellId,
Expand All @@ -18,6 +22,7 @@ class TableCellWidget extends StatefulWidget {
State<TableCellWidget> createState() => _TableCellWidgetState();
}

// ignore: deprecated_member_use_from_same_package
class _TableCellWidgetState extends State<TableCellWidget> {
late final TextEditingController controller;
late final FocusNode node;
Expand Down
11 changes: 11 additions & 0 deletions flutter_quill_extensions/lib/src/editor/table/table_embed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_quill/flutter_quill.dart';
import 'package:flutter_quill/quill_delta.dart';
import 'package:meta/meta.dart';
import '../../common/utils/quill_table_utils.dart';
import 'table_cell_embed.dart';
import 'table_models.dart';

@experimental
@Deprecated(
'CustomTableEmbed will no longer used and it will be removed in future releases')
class CustomTableEmbed extends CustomBlockEmbed {
const CustomTableEmbed(String value) : super(tableType, value);

Expand All @@ -20,6 +24,7 @@ class CustomTableEmbed extends CustomBlockEmbed {

//Embed builder

@experimental
class QuillEditorTableEmbedBuilder extends EmbedBuilder {
@override
String get key => 'table';
Expand All @@ -34,13 +39,17 @@ class QuillEditorTableEmbedBuilder extends EmbedBuilder {
TextStyle textStyle,
) {
final tableData = node.value.data;
// ignore: deprecated_member_use_from_same_package
return TableWidget(
tableData: tableData,
controller: controller,
);
}
}

@experimental
@Deprecated(
'TableWidget will no longer used and it will be removed in future releases')
class TableWidget extends StatefulWidget {
const TableWidget({
required this.tableData,
Expand All @@ -54,6 +63,7 @@ class TableWidget extends StatefulWidget {
State<TableWidget> createState() => _TableWidgetState();
}

// ignore: deprecated_member_use_from_same_package
class _TableWidgetState extends State<TableWidget> {
TableModel _tableModel = TableModel(columns: {}, rows: {});
String _selectedColumnId = '';
Expand Down Expand Up @@ -214,6 +224,7 @@ class _TableWidgetState extends State<TableWidget> {
if (key != 'id') {
final columnId = key;
final data = value;
// ignore: deprecated_member_use_from_same_package
rowCells.add(TableCellWidget(
cellId: rowKey,
onTap: (node) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'package:meta/meta.dart';

@experimental
class TableModel {
TableModel({required this.columns, required this.rows});

Expand Down Expand Up @@ -42,6 +45,7 @@ class TableModel {
}
}

@experimental
class ColumnModel {
ColumnModel({required this.id, required this.position});

Expand All @@ -62,6 +66,7 @@ class ColumnModel {
}
}

@experimental
class RowModel {
// Key is column ID, value is cell content

Expand Down
18 changes: 8 additions & 10 deletions flutter_quill_extensions/lib/src/flutter_quill_embeds.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter_quill/flutter_quill.dart' as fq;
import 'package:meta/meta.dart' show immutable;
import 'package:meta/meta.dart' show experimental, immutable;

import 'editor/image/image_embed.dart';
import 'editor/image/models/image_configurations.dart';
import 'editor/table/table_embed.dart';
import 'editor/video/models/video_configurations.dart';
import 'editor/video/models/video_web_configurations.dart';
import 'editor/video/video_embed.dart';
Expand All @@ -14,7 +13,6 @@ import 'toolbar/camera/models/camera_configurations.dart';
import 'toolbar/image/image_button.dart';
import 'toolbar/image/models/image_configurations.dart';
import 'toolbar/table/models/table_configurations.dart';
import 'toolbar/table/table_button.dart';
import 'toolbar/video/models/video_configurations.dart';
import 'toolbar/video/video_button.dart';

Expand Down Expand Up @@ -62,7 +60,10 @@ class FlutterQuillEmbeds {
QuillEditorVideoEmbedBuilder(
configurations: videoEmbedConfigurations,
),
QuillEditorTableEmbedBuilder(),
// We disable the table feature is in experimental phase
// and it does not work as we expect
// https://github.com/singerdmx/flutter-quill/pull/2238#pullrequestreview-2312706901
// QuillEditorTableEmbedBuilder(),
];
}
Expand Down Expand Up @@ -119,6 +120,9 @@ class FlutterQuillEmbeds {
QuillToolbarVideoButtonOptions? videoButtonOptions =
const QuillToolbarVideoButtonOptions(),
QuillToolbarCameraButtonOptions? cameraButtonOptions,
@experimental
@Deprecated(
'tableButtonOptions will no longer used by now, and probably will be removed in future releases.')
QuillToolbarTableButtonOptions? tableButtonOptions,
}) =>
[
Expand All @@ -140,11 +144,5 @@ class FlutterQuillEmbeds {
controller: controller,
options: cameraButtonOptions,
),
if (tableButtonOptions != null)
(controller, toolbarIconSize, iconTheme, dialogTheme) =>
QuillToolbarTableButton(
controller: controller,
options: tableButtonOptions,
),
];
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'package:flutter_quill/flutter_quill.dart';
import 'package:meta/meta.dart' show immutable;
import 'package:meta/meta.dart' show experimental, immutable;

@experimental
@Deprecated(
'QuillToolbarTableButtonExtraOptions is not stable at this moment and it should not be used. Probably will be removed in future releases')
class QuillToolbarTableButtonExtraOptions
extends QuillToolbarBaseButtonExtraOptions {
const QuillToolbarTableButtonExtraOptions({
Expand All @@ -11,6 +14,9 @@ class QuillToolbarTableButtonExtraOptions
}

@immutable
@experimental
@Deprecated(
'QuillToolbarTableButton is not stable at this moment and it should not be used. Probably will be removed in future releases')
class QuillToolbarTableButtonOptions extends QuillToolbarBaseButtonOptions<
QuillToolbarTableButtonOptions, QuillToolbarTableButtonExtraOptions> {
const QuillToolbarTableButtonOptions({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import 'package:flutter/material.dart';
import 'package:flutter_quill/flutter_quill.dart';
import 'package:flutter_quill/translations.dart';
import 'package:meta/meta.dart';

import '../../common/utils/quill_table_utils.dart';
import 'models/table_configurations.dart';

@experimental
@Deprecated(
'QuillToolbarTableButton will no longer used and will be removed in future releases')
class QuillToolbarTableButton extends StatelessWidget {
const QuillToolbarTableButton({
required this.controller,
Expand Down

0 comments on commit 4953bd1

Please sign in to comment.