appflowy-editor icon indicating copy to clipboard operation
appflowy-editor copied to clipboard

Where to find the list of available attributes?

Open e200 opened this issue 2 years ago • 1 comments

I'm creating a simple custom toolbar. I'm not being able to find the right attributes to call editorState.toggleAttribute or it just doesn't work for attributes like quote.

The only ones I've found that are working are the ones inside AppFlowyRichTextKeys like AppFlowyRichTextKeys.bold. But whenever I use quote or quotes nothing happens.

What I want to achieve: quote a selected text based on a custom button event.

e200 avatar Oct 12 '23 13:10 e200

I was able to achieve it by:

onTap: () {
  final editor = widget.editorState;
  final selection = editor.selectionNotifier.value;

  if (selection != null) {
    final node = editor.getNodeAtPath(selection.start.path);

    final isQuote = node != null && node.type == QuoteBlockKeys.type;

    editor.formatNode(
      selection,
      (node) => node.copyWith(
        type: isQuote ? ParagraphBlockKeys.type : QuoteBlockKeys.type,
        attributes: {
          ParagraphBlockKeys.delta: (node.delta ?? Delta()).toJson(),
        },
      ),
    );
  }
}

Wondering why it's not in the docs project docs.

e200 avatar Oct 12 '23 14:10 e200