- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
react-rte
是一个基于draft-js
的富文本编辑器。我的目标是使用例如 Material UI React 组件自定义工具栏组件。阅读 react-rte 文档,我认为有两个样式 Hook :
toolbarConfig
用于 CSS ( link );和customControls
用于完全覆盖组件 (as seen in demo)。我相信我的用例需要 customControls
,但是从提供的演示(见下文)中我无法理解如何将自定义组件 Hook 回 rte 的功能。例如,如果我为 BOLD 渲染一个自定义按钮组件,这个按钮如何获得本应由 toolbarConfig
提供的默认按钮的默认功能?
带有自定义控件的编辑器演示:
<RichTextEditor
value={value}
onChange={this._onChange}
className="react-rte-demo"
placeholder="Tell a story"
toolbarClassName="demo-toolbar"
editorClassName="demo-editor"
readOnly={this.state.readOnly}
customControls={[
// eslint-disable-next-line no-unused-vars
(setValue, getValue, editorState) => {
let choices = new Map([
['1', {label: '1'}],
['2', {label: '2'}],
['3', {label: '3'}],
]);
return (
<ButtonGroup key={1}>
<Dropdown
choices={choices}
selectedKey={getValue('my-control-name')}
onChange={(value) => setValue('my-control-name', value)}
/>
</ButtonGroup>
);
},
<ButtonGroup key={2}>
<IconButton
label="Remove Link"
iconName="remove-link"
focusOnClick={false}
onClick={() => console.log('You pressed a button')}
/>
</ButtonGroup>,
]}
/>
我当前无效的实现:
<RichTextEditor
value={this.state.value}
onChange={this.onChange}
customControls={rteCustomControls}
/>
...
const inlineStyleButtonControls = [
{ label: "format_bold", style: "BOLD", component: FormatBoldIcon },
{ label: "format_italic", style: "ITALIC", component: FormatItalicIcon },
{
label: "format_underlined",
style: "UNDERLINE",
component: FormatUnderlinedIcon,
},
];
const rteCustomControls = [
(setValue, getValue, editorState) => {
return inlineStyleButtonControls.map((button, i) => (
<IconButton
key={i}
color="inherit"
aria-label={button.label}
selectedKey={getValue(button.style)}
onClick={value => setValue(button.style, value)}
>
<button.component />
</IconButton>
));
},
];
最佳答案
如果您的目标纯粹是修改显示,您应该能够通过 CSS 定位按钮以更改它们的显示,就像您定位任何其他 DOM 元素一样。
通过 CSS 更改元素显示。
RichTextEditor button:nth-child(1){
background-image: url('/icon1.svg');
}
RichTextEditor button:nth-child(2){
background-image: url('/icon2.svg');
}
或者,通过 javascript 更改元素显示
Array.from(document.querySelectorsAll('RichTextEditor button')).forEach((el)=>{
// Modify element here
})
如果你还想修改按钮的功能,你可以看看code它们被定义的地方,并可能将它们添加为自定义控件。
关于reactjs - react-rte(富文本编辑器): how to implement inline style for custom components?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55388787/
我是 frama-c 的新手。我正在尝试使用 rte 插件生成注释。通过查看链接 [1],我尝试使用以下命令生成注释: frama-c -rte -rte-unsigned-ov test.c 我的
我是 React/Redux 及其作品的新手,所以请原谅这里的任何幼稚假设/问题... 由于 redux-form 的文档,我在为我的应用程序构建的入职流程中取得了很大进展 - 这是一个很棒的库! 但
使用 Sitecore 7.2(可能还有其他版本)中的 RTE,如果将空属性添加到 HTML View 中的元素,切换到设计 View 然后返回 HTML View ,则空属性将被删除。例如,我添加了
今天,在我们的一个旧站点中,我们发现 RTE 编辑器存在问题。对于我们的任何用户,编辑器都不会加载。它卡在加载中,如下图所示。 现在我意识到我们用于 TYPO3 的版本已经非常过时了,4.5 版本的支
今天,在我们的一个旧站点中,我们发现 RTE 编辑器存在问题。对于我们的任何用户,编辑器都不会加载。它卡在加载中,如下图所示。 现在我意识到我们用于 TYPO3 的版本已经非常过时了,4.5 版本的支
任何人都可以指出一个好的富文本编辑器(成本不是问题)的方向,它具有内置的拼写检查或可以配置为指向内部拼写服务。由于驻留在受限网络上的应用程序,我无法使用利用外部 jsonp 服务(google api
我正在尝试将一些自定义类添加到 Sitecore 6.5 的 RTE 中。我已添加到 ToolsFile.xml 和 default.css 文件中,我已确认该文件在浏览器中显示正确的类。但是下拉列表
我正在尝试将一些自定义类添加到 Sitecore 6.5 的 RTE 中。我已添加到 ToolsFile.xml 和 default.css 文件中,我已确认该文件在浏览器中显示正确的类。但是下拉列表
在新建的 AEM 6.3 作者服务器 (Service Pack 2) 上,RTE 组件自动将我们的作者 URL 添加到通过 Assets 选择器选择的任何 Assets 。 只有在选择 Assets
希望大家都一切顺利。我的问题: 我有一个使用 foreach 循环生成的表格,我希望能够单击每行中的特定单元格,这应该获取单元格中的数据并使用它来预填充对话框中的tinyMCE 文本区域。这是我到目前
是否有可能获得与我们在 RTE 的其他表单控件上拥有的焦点和模糊事件等效的事件?也就是说,我想知道给定的 RTE 何时获得焦点以及何时失去焦点。 我看到 RTE 支持很多事件 ( http://dev
我必须使用 javascript 或 JQuery 构建自己的 RTE。但是我真的找不到一些好的、有评论的、有效的例子或教程,只是一段代码。但我不想要一个解决方案,我想要了解我在做什么! 我知道如何将
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我正在使用 mui-rte 的问答平台工作实现表单——就像我现在正在输入的表单一样。我的问题是我不知道如何获取数据,而无需单击随附的“保存”按钮。 替代方案,我怎样才能在 react 中实现这样的 r
我正在尝试为 Sitecore 中的富文本编辑器 (RTE) 创建一个下拉按钮,但无法弄清楚如何实现这一点。我想要类似于下面显示的“插入片段”命令的东西,但是下拉列表的来源是由主数据库中的内容驱动的,
我在 Magnesium 版本(直接从 ubuntu 安装)中遇到 -rte 选项的不连贯行为。我想知道是否有人意识到这个问题,或者我是否做错了什么。 我有一个程序在数组外访问不正确。在没有选项和值分
我想从 TYPO3 4.7.5 更新到 TYPO3 4.7.10。现在我进入了升级向导,它显示: Deprecated RTE properties in Page TSconfig The foll
我正在使用 CLEditor 在我的网络应用程序中自定义富文本编辑器。对于更改字体和字体大小,我更希望有比默认 execCommand 更精细的控制,尤其是对于字体大小,因为据我所知,它只是将它设置为
我可以为 RichTextEditor(RTE) 添加 CSS 样式路径,如下所示,我可以在 RTE 中选择定义的样式。
在 PHP/html 内容管理系统上工作,发现在线免费 RTE,这是一个免费的富文本编辑器。不知道如何将它整合到我自己的东西中。 虽然有示例代码,但是不是很清楚。 有没有人以前用过它或者知道如何集成它
我是一名优秀的程序员,十分优秀!