margox / braft-utils

Braft Editor基础工具包
37 stars 34 forks source link

toggleSelectionColor 如何使用? #21

Open jockey100332 opened 3 years ago

jockey100332 commented 3 years ago
 const editorState = BraftEditor.createEditorState(`<div>${props.value}</div` || '<div></div>');
    <BraftEditor
      ref={ref}
      controls={[]}
      extendControls={[
        {
          key: 'custom-button',
          type: 'button',
          text: '按钮',
          onClick: () => {
            console.log(editorState);
            const newEditorState = ContentUtils.toggleSelectionColor(editorState, '#f39c12');
            console.log(newEditorState.toHTML());
            // ref.current.refs.toggleSelectionColor('#ffffff')
            // ref.current?.handleKeyCommand('blob')
          },
        },
      ]}

通过ContentUtils 方法没办法进行颜色的修改,是调用的方式不对吗?

jockey100332 commented 3 years ago

发现 editorState.getSelection 该方法是无法获取到选中的内容