visual-space / visual-editor

Rich text editor for Flutter based on Delta format (Quill fork)
MIT License
290 stars 46 forks source link

Toolbar - Custom toolbars, Export Toolbar buttons #65

Closed adrian-moisa closed 2 years ago

adrian-moisa commented 2 years ago

Currently it is possible only to use the predefined set of buttons. New buttons can be added via the customButtons property however they are inserted only at the end of the toolbar. Adding new editing options in the middle of the Toolbar is impossible. The goal of this ticket is to export the Toolbar buttons such that developers can create custom looking toolbars with a mix of internal buttons and custom made buttons.

Join on discord to get advice and help or follow us on YouTube Visual Coding to learn more about the architecture of Visual Editor and other Flutter apps.

adrian-moisa commented 2 years ago

Now creating custom toolbars is entirely possible:


Widget _toolbar() => Container(
  padding: const EdgeInsets.symmetric(
    vertical: 16,
    horizontal: 8,
  ),
  child: EditorToolbar(
    children: [
      ToggleStyleButton(
        attribute: AttributeM.bold,
        icon: Icons.format_bold,
        iconSize: toolbarIconSize,
        controller: _controller!,
      ),
      ToggleStyleButton(
        attribute: AttributeM.italic,
        icon: Icons.format_italic,
        iconSize: toolbarIconSize,
        controller: _controller!,
      ),
      Padding(
        padding: const EdgeInsets.only(top: 12),
        child: Text(
          'Custom Content',
          style: TextStyle(
            fontSize: 20,
          ),
        ),
      ),
      ToggleStyleButton(
        attribute: AttributeM.small,
        icon: Icons.format_size,
        iconSize: toolbarIconSize,
        controller: _controller!,
      ),
      ToggleStyleButton(
        attribute: AttributeM.underline,
        icon: Icons.format_underline,
        iconSize: toolbarIconSize,
        controller: _controller!,
      ),
      ToggleStyleButton(
        attribute: AttributeM.strikeThrough,
        icon: Icons.format_strikethrough,
        iconSize: toolbarIconSize,
        controller: _controller!,
      ),
    ],
  ),
);
Screenshot 2022-07-03 at 21 04 56