Remove comments

pull/1801/head
Douglas Ward 1 year ago
parent ea7ba7e712
commit 0593877997
  1. 36
      example/lib/screens/quill/my_quill_toolbar.dart
  2. 5
      lib/src/models/documents/document.dart
  3. 3
      lib/src/models/rules/insert.dart
  4. 12
      lib/src/widgets/quill/quill_controller.dart

@ -223,24 +223,24 @@ class MyQuillToolbar extends StatelessWidget {
'40': '40.0' '40': '40.0'
}, },
// headerStyleType: HeaderStyleType.buttons, // headerStyleType: HeaderStyleType.buttons,
buttonOptions: QuillSimpleToolbarButtonOptions( // buttonOptions: QuillSimpleToolbarButtonOptions(
base: QuillToolbarBaseButtonOptions( // base: QuillToolbarBaseButtonOptions(
afterButtonPressed: focusNode.requestFocus, // afterButtonPressed: focusNode.requestFocus,
// iconSize: 20, // // iconSize: 20,
// iconTheme: QuillIconTheme( // iconTheme: QuillIconTheme(
// iconButtonSelectedData: IconButtonData( // iconButtonSelectedData: IconButtonData(
// style: IconButton.styleFrom( // style: IconButton.styleFrom(
// foregroundColor: Colors.blue, // foregroundColor: Colors.blue,
// ), // ),
// ), // ),
// iconButtonUnselectedData: IconButtonData( // iconButtonUnselectedData: IconButtonData(
// style: IconButton.styleFrom( // style: IconButton.styleFrom(
// foregroundColor: Colors.red, // foregroundColor: Colors.red,
// ), // ),
// ), // ),
// ), // ),
), // ),
), // ),
customButtons: [ customButtons: [
QuillToolbarCustomButtonOptions( QuillToolbarCustomButtonOptions(
icon: const Icon(Icons.add_alarm_rounded), icon: const Icon(Icons.add_alarm_rounded),

@ -185,11 +185,6 @@ class Document {
} }
if (res.offset == 0) { if (res.offset == 0) {
return rangeStyle = (res.node as Line).collectStyle(res.offset, len); return rangeStyle = (res.node as Line).collectStyle(res.offset, len);
//COMMENT: Selecting the start of a line, user expects the style to be the visible style of the line including inline styles
// return rangeStyle.removeAll({
// for (final attr in rangeStyle.values)
// if (attr.isInline) attr
// });
} }
rangeStyle = (res.node as Line).collectStyle(res.offset - 1, len); rangeStyle = (res.node as Line).collectStyle(res.offset - 1, len);
final linkAttribute = rangeStyle.attributes[Attribute.link.key]; final linkAttribute = rangeStyle.attributes[Attribute.link.key];

@ -560,9 +560,6 @@ class PreserveInlineStylesRule extends InsertRule {
final itr = DeltaIterator(document); final itr = DeltaIterator(document);
var prev = itr.skip(len == 0 ? index : index + 1); var prev = itr.skip(len == 0 ? index : index + 1);
//
// Inserting at start of line should use style for first character on the line
//
if (prev == null || if (prev == null ||
(prev.data is String && (prev.data as String).endsWith('\n'))) { (prev.data is String && (prev.data as String).endsWith('\n'))) {
prev = itr.next(); prev = itr.next();

@ -478,24 +478,13 @@ class QuillController extends ChangeNotifier {
super.dispose(); super.dispose();
} }
/// Comments:
/// Removed param:
/// 'ChangeSource source' as not used within this function!
/// Added param:
/// insertNewline is non-null when user makes an editing change, true when newline is inserted to allow style to be maintained
void _updateSelection(TextSelection textSelection, {bool insertNewline = false}) { void _updateSelection(TextSelection textSelection, {bool insertNewline = false}) {
_selection = textSelection; _selection = textSelection;
final end = document.length - 1; final end = document.length - 1;
_selection = selection.copyWith( _selection = selection.copyWith(
baseOffset: math.min(selection.baseOffset, end), baseOffset: math.min(selection.baseOffset, end),
extentOffset: math.min(selection.extentOffset, end)); extentOffset: math.min(selection.extentOffset, end));
//
if (keepStyleOnNewLine) { if (keepStyleOnNewLine) {
//
// Update toggledStyle:
// if insertNewline: gets style from preceding/last character entered (if any)
// else clears so style will be style of selection
//
if (insertNewline && selection.start > 0) { if (insertNewline && selection.start > 0) {
final style = document.collectStyle(selection.start - 1, 0); final style = document.collectStyle(selection.start - 1, 0);
final ignoredStyles = style.attributes.values.where( final ignoredStyles = style.attributes.values.where(
@ -508,7 +497,6 @@ class QuillController extends ChangeNotifier {
} else { } else {
toggledStyle = const Style(); toggledStyle = const Style();
} }
//
onSelectionChanged?.call(textSelection); onSelectionChanged?.call(textSelection);
} }

Loading…
Cancel
Save