小编Pav*_*nyi的帖子

Draft.js.如何从ContentState获取所有实体数据

从官方文档中我了解了两种方法:通过其键获取实体并获取最后创建的实体.在我的例子中,我还需要一种方法来访问当前ContentState中的所有实体.有没有什么方法可以执行此操作?如果没有,是否有一个可以提供所有实体密钥?谢谢

javascript reactjs draftjs

4
推荐指数
2
解决办法
3195
查看次数

Webpack:如何查找特定文件夹名称内的所有文件

我有一个文件树,就像app/components/forms/components/formError/components 我需要编写一条规则来测试.scss仅位于根目录components或scene文件夹中的所有文件。我怎样才能做到这一点?当前规则是下一个:

{
      test: /.*\/(components|scenes)\/.*\.scss$/,
      use: [{
        loader: 'style-loader',
      }, {
        loader: 'css-loader',
        options: {
          modules: true,
          localIdentName: '[local]___[hash:base64:5]',
        },
      }, {
        loader: 'sass-loader',
      }],
    }
Run Code Online (Sandbox Code Playgroud)

但找不到所需的文件

regex webpack

4
推荐指数
1
解决办法
1520
查看次数

Draft.js:如何在原子之前插入新块

我想在块后添加新行.我目前的功能是下一个:

   _insert_new_block(editorState) {
      const selection = editorState.getSelection();
      const newBlock = new ContentBlock({
         key: genKey(),
         type: 'unstyled',
         text: ' ',
         characterList: List()
      });
      const contentState = editorState.getCurrentContent();
      const new_block_map = contentState.getBlockMap().set(newBlock.key, newBlock);
      const newContentState = contentState.set('blockMap', new_block_map);
      const new_contentState = contentState.merge({
        blockMap: new_block_map,
        selectionBefore: selection.merge({
          anchorKey: newBlock.key,
          anchorOffset: 0,
          focusKey: newBlock.key,
          focusOffset: 0,
          isBackward: false
        }),
        selectionAfter: selection
      });
      return EditorState.push(
         editorState,
         new_contentState,
         'insert-fragment'
      );
   }
Run Code Online (Sandbox Code Playgroud)

新内容插入到我的内容的末尾但是当我点击新创建的块时我收到此错误 -

getUpdatedSelectionState.js:38 Uncaught TypeError: Cannot read property 'get' of undefined
Run Code Online (Sandbox Code Playgroud)

和错误所在的文件

'use strict';

var …
Run Code Online (Sandbox Code Playgroud)

reactjs draftjs

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

标签 统计

draftjs ×2

reactjs ×2

javascript ×1

regex ×1

webpack ×1