handleCopy function

void handleCopy(
  1. EditorState editorState
)

Implementation

void handleCopy(EditorState editorState) async {
  final selection = editorState.selection?.normalized;
  if (selection == null || selection.isCollapsed) {
    return;
  }
  final text = editorState.getTextInSelection(selection).join('\n');
  final nodes = editorState.getSelectedNodes(selection: selection);
  if (nodes.isEmpty) {
    return;
  }
  final html = documentToHTML(
    Document(
      root: Node(
        type: 'page',
        children: nodes,
      ),
    ),
  );
  return AppFlowyClipboard.setData(
    text: text,
    html: html.isEmpty ? null : html,
  );
}