braft-utils icon indicating copy to clipboard operation
braft-utils copied to clipboard

不通过控件controls去改变选区的大小颜色或者背景颜色怎么实现?

Open ChaoshengZhang opened this issue 6 years ago • 2 comments

不通过控件controls去改变选区的大小颜色或者背景颜色怎么实现?

我获取的编辑器实例里面有一个方法是handleKeyCommand

可以通过 this.editorInstance.handleKeyCommand('bold',this.state.editorState)实现选择加粗

但是选择区域的字体大小或者添加背景色怎么去操作,希望作者可以解惑。

ChaoshengZhang avatar Jan 18 '19 08:01 ChaoshengZhang

额,你可以看看源码: 设置选区字号:https://github.com/margox/braft-utils/blob/master/src/content.js#L315 设置选区颜色:https://github.com/margox/braft-utils/blob/master/src/content.js#L307 以及:使用ContentUtils操作编辑器内容

margox avatar Jan 18 '19 08:01 margox

我也需要这个,UI设计的icon和自带的不一样,但是换了,功能就没了,尤其是字体大小。要想word一样,选择了还要显示在icon后面,看源码改下比较麻烦,希望作者提供api,嘿嘿!!!但是,我发现 这样好像可以实现,const instance = ContentUtils.toggleSelectionFontSize(editorState, '90'); this.setState({ editorState: instance, });

shellyaoo avatar Jan 19 '21 08:01 shellyaoo