gpt4 book ai didi

reactjs - 在 React 的 Froala wysiwyg 编辑器中调用方法

转载 作者:行者123 更新时间:2023-12-03 14:31:41 25 4
gpt4 key购买 nike

我正在使用名为 Froala 的富文本编辑器,其 React 版本。这些文档适用于 JQuery 文档。从有关 React 的少量文字中,我找到了这些说明:

Events and Methods Events can be passed in with the options, with a key events and object where the key is the event name and the value is the callback function.

options: {
placeholder: "Edit Me",
events : {
'froalaEditor.focus' : function(e, editor) {
console.log(editor.selection.get());
}
}
}

Using the editor instance from the arguments of the callback you can call editor methods as described in the method docs. Froala events are described in the events docs.

我了解如何使用事件,但不了解如何调用方法。这是否意味着我只能从事件访问编辑器实例?有人可以澄清这一点吗?例如,我想使用 html.insert() 方法,如下所述:

$('.selector').froalaEditor('html.insert', 'foo bar', true);

如何将其与 Froala React 组件一起使用?

最佳答案

如果有人感兴趣,我实现了一个简单的解决方法:

我使用“initialized”事件,只是为了获取 Froala 实例,并在我的类中放置对它的引用::

'froalaEditor.initialized' : (e, editor)=> {
this.froalaInstance = editor;

}

现在我可以访问 Froala 实例...

关于reactjs - 在 React 的 Froala wysiwyg 编辑器中调用方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50098850/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com