dartlangeditorflutterflutter-appsflutter-examplesflutter-packageflutter-widgetquillquill-deltaquilljsreactquillrich-textrich-text-editorwysiwygwysiwyg-editor
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
6.7 KiB
142 lines
6.7 KiB
import 'package:flutter/widgets.dart' show BuildContext; |
|
|
|
import '../../flutter_quill.dart'; |
|
|
|
// TODO: The comments of this file is outdated and needs to be updated |
|
|
|
/// Public shared extension |
|
extension QuillProviderExt on BuildContext { |
|
/// return nullable [QuillProvider] |
|
/// don't throw exception if it's not in the widget tree |
|
/// instead it will be null |
|
QuillProvider? get quillProvider { |
|
return QuillProvider.of(this); |
|
} |
|
|
|
/// return nullable [QuillController] |
|
/// since the quill controller is in the [QuillProvider] then we need to get |
|
/// the provider widget first and then we will return the controller |
|
/// don't throw exception if [QuillProvider] is not in the widget tree |
|
/// instead it will be null |
|
QuillController? get quilController { |
|
return quillToolbarConfigurations?.controller ?? |
|
quillEditorConfigurations?.controller; |
|
} |
|
|
|
/// return [QuillController] as not null |
|
/// since the quill controller is in the [QuillProvider] then we need to get |
|
/// the provider widget first and then we will return the controller |
|
/// throw exception if [QuillProvider] is not in the widget tree |
|
QuillController get requireQuillController { |
|
return quillToolbarConfigurations?.controller ?? |
|
quillEditorConfigurations?.controller ?? |
|
(throw ArgumentError( |
|
'The quill provider is required, you must only call requireQuillController inside the QuillToolbar and QuillEditor')); |
|
} |
|
|
|
/// return nullable [QuillConfigurations] |
|
/// since the quill configurations is in the [QuillProvider] then we need to |
|
/// get the provider widget first and then we will return quill configurations |
|
/// don't throw exception if [QuillProvider] is not in the widget tree |
|
QuillConfigurations? get quillConfigurations { |
|
return quillProvider?.configurations; |
|
} |
|
|
|
/// return nullable [QuillSharedConfigurations] . Since the quill |
|
/// shared configurations is in the [QuillProvider] then we need to get the |
|
/// provider widget first and then we will return shared configurations |
|
/// don't throw exception if [QuillProvider] is not in the widget tree |
|
QuillSharedConfigurations? get quillSharedConfigurations { |
|
return quillConfigurations?.sharedConfigurations; |
|
} |
|
|
|
/// return [QuillEditorConfigurations] as not null . Since the quill |
|
/// editor configurations is in the [QuillEditorProvider] |
|
/// then we need to get the |
|
/// provider widget first and then we will return editor configurations |
|
/// throw exception if [QuillProvider] is not in the widget tree |
|
QuillEditorConfigurations get requireQuillEditorConfigurations { |
|
return QuillEditorProvider.ofNotNull(this).editorConfigurations; |
|
} |
|
|
|
/// return nullable [QuillEditorConfigurations]. Since the quill |
|
/// editor configurations is in the [QuillEditorProvider] |
|
/// then we need to get the |
|
/// provider widget first and then we will return editor configurations |
|
/// don't throw exception if [QuillProvider] is not in the widget tree |
|
QuillEditorConfigurations? get quillEditorConfigurations { |
|
return QuillEditorProvider.of(this)?.editorConfigurations; |
|
} |
|
|
|
/// return [QuillSimpleToolbarConfigurations] as not null . Since the quill |
|
/// toolbar configurations is in the [QuillToolbarProvider] |
|
/// then we need to get the |
|
/// provider widget first and then we will return toolbar configurations |
|
/// throw exception if [QuillProvider] is not in the widget tree |
|
QuillSimpleToolbarConfigurations get requireQuillToolbarConfigurations { |
|
return QuillToolbarProvider.ofNotNull(this).toolbarConfigurations; |
|
} |
|
|
|
/// return nullable [QuillSimpleToolbarConfigurations]. Since the quill |
|
/// toolbar configurations is in the [QuillToolbarProvider] |
|
/// then we need to get the |
|
/// provider widget first and then we will return toolbar configurations |
|
/// don't throw exception if [QuillProvider] is not in the widget tree |
|
QuillSimpleToolbarConfigurations? get quillToolbarConfigurations { |
|
return QuillToolbarProvider.of(this)?.toolbarConfigurations; |
|
} |
|
|
|
/// return [QuillToolbarConfigurations] as not null . Since the quill |
|
/// toolbar configurations is in the [QuillBaseToolbarProvider] |
|
/// then we need to get the |
|
/// provider widget first and then we will return toolbar configurations |
|
/// throw exception if [QuillBaseToolbarProvider] is not in the widget tree |
|
QuillToolbarConfigurations get requireQuillBaseToolbarConfigurations { |
|
return QuillBaseToolbarProvider.ofNotNull(this).toolbarConfigurations; |
|
} |
|
|
|
/// return nullable [QuillToolbarConfigurations]. Since the quill |
|
/// toolbar configurations is in the [QuillBaseToolbarProvider] |
|
/// then we need to get the |
|
/// provider widget first and then we will return toolbar configurations |
|
/// don't throw exception if [QuillBaseToolbarProvider] is not in the widget tree |
|
QuillToolbarConfigurations? get quillBaseToolbarConfigurations { |
|
return QuillBaseToolbarProvider.of(this)?.toolbarConfigurations; |
|
} |
|
|
|
/// return nullable [QuillToolbarBaseButtonOptions]. Since the quill |
|
/// toolbar base button options is in the [QuillProvider] then we need to |
|
/// get the provider widget first and then we will return base button |
|
/// don't throw exception if [QuillProvider] is not in the widget tree |
|
QuillToolbarBaseButtonOptions? get quillToolbarBaseButtonOptions { |
|
return quillToolbarConfigurations?.buttonOptions.base; |
|
} |
|
|
|
/// return [QuillToolbarBaseButtonOptions] as not null. Since the quill |
|
/// toolbar base button options is in the [QuillProvider] then we need to |
|
/// get the provider widget first and then we will return base button |
|
/// throw exception if [QuillProvider] is not in the widget tree |
|
QuillToolbarBaseButtonOptions get requireQuillToolbarBaseButtonOptions { |
|
return quillToolbarConfigurations?.buttonOptions.base ?? |
|
quillBaseToolbarConfigurations?.buttonOptions.base ?? |
|
(throw ArgumentError( |
|
"The buttonOptions is required and it's null because the toolbar configurations is.", |
|
)); |
|
} |
|
|
|
/// return nullable [QuillToolbarBaseButtonOptions]. Since the quill |
|
/// quill editor block options is in the [QuillEditorProvider] then we need to |
|
/// get the provider widget first and then we will return block options |
|
/// throw exception if [QuillEditorProvider] is not in the widget tree |
|
QuillEditorElementOptions? get quillEditorElementOptions { |
|
return quillEditorConfigurations?.elementOptions; |
|
} |
|
|
|
/// return [QuillToolbarBaseButtonOptions] as not null. Since the quill |
|
/// quill editor block options is in the [QuillEditorProvider] then we need to |
|
/// get the provider widget first and then we will return block options |
|
/// don't throw exception if [QuillEditorProvider] is not in the widget tree |
|
QuillEditorElementOptions get requireQuillEditorElementOptions { |
|
return requireQuillEditorConfigurations.elementOptions; |
|
} |
|
}
|
|
|