小编Ser*_*tov的帖子

如何在CKEditor 5中添加占位符?

import BalloonEditor from '@ckeditor/ckeditor5-editor-balloon/src/ballooneditor';

import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials';
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';

BalloonEditor
                .create( elem, {
                    plugins: [ Markdown, Essentials, Paragraph, Bold, Italic ],
                    toolbar: [ 'bold' ]
                })
                .then((editor) => {
                    ....
                })
                .catch( error => {
                    console.error( error );
                } );
Run Code Online (Sandbox Code Playgroud)

我尝试使用https://ckeditor.com/docs/ckeditor5/latest/api/module_engine_view_placeholder.html#static-function-attachPlaceholder中的AttachPlaceholder

import { attachPlaceholder } from "@ckeditor/ckeditor5-engine/src/view/placeholder";
Run Code Online (Sandbox Code Playgroud)

您能否向我展示如何使用此方法(attachPlaceholder)或如何执行的简单示例。

placeholder ckeditor5

3
推荐指数
1
解决办法
7099
查看次数

当元素处于条件内时如何使用useRef?

问题是 useRef 在第一次渲染期间被触发。可能有问题的两个例子。

  1. 当一个人可以有一些负载
const Problem1 = () => {  
 const ref = useRef();

 if (loading)    
     return null;

 return <input ref={ref} value={} />;

}
Run Code Online (Sandbox Code Playgroud)
  1. 当 ref 在某个条件内时。
const Problem2 = () => {
 const ref = useRef();

 return user ? <input ref={ref} value={user.name} /> : <Exit >;

}
Run Code Online (Sandbox Code Playgroud)

沙盒示例 https://codesandbox.io/s/nifty-feynman-z68k0

在第二种情况下,我至少可以在开头显示元素 display: none。但是如何解决第一个问题我不知道。

在这些情况下,最佳做法是什么?

reactjs react-hooks

3
推荐指数
1
解决办法
3565
查看次数

标签 统计

ckeditor5 ×1

placeholder ×1

react-hooks ×1

reactjs ×1