我的应用程序中有一个石板文本编辑器,并且想使用 giphy 链接插入 gif。 我尝试使用 insertNodes 函数进行添加,但这似乎只是添加了一个新行。我在下面列出了我用来添加 gif 的函数;
function insertImage(editor, url) {
const element = { type: 'video', url, children: [{ text: '' }] }
Transforms.insertNodes(editor, element)
}
我只是使用公开可用的 gif 链接来确保我实际上可以将 gif 添加到编辑器中。所以我确信链接或其他任何东西都不是问题。我也尝试过使用其他地方的链接进行此操作,但没有成功,因此我将不胜感激。
还在下面添加我的渲染元素功能;
const renderElement = useCallback((props) =>, []);
最后是我的元素定义;
const Element = ({ attributes, children, element }) => {
const style = { textAlign: element.align }
switch (element.type) {
case "block-quote":
return (
{children}
)
case "bulleted-list":
return (
{children}
) } }Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号